Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Upgrade react-zen and migrate attribution and menu controls to updated components

Mike Caodf302595c019
diff --git a/package.json b/package.json
index 11310090f..70fb7c4f5 100644
--- a/package.json
+++ b/package.json
@@ -65,7 +65,7 @@
"@prisma/extension-read-replicas": "^0.5.0",
"@svgr/cli": "^8.1.0",
"@tanstack/react-query": "^5.101.4",
- "@umami/react-zen": "^0.247.0",
+ "@umami/react-zen": "^0.248.0",
"bcryptjs": "^3.0.2",
"chalk": "^5.6.2",
"chart.js": "^4.5.1",
diff --git a/patches/@[email protected] b/patches/@[email protected]
deleted file mode 100644
index 2caf21ae2..000000000
--- a/patches/@[email protected]
+++ /dev/null
@@ -1,74 +0,0 @@
-diff --git a/dist/index.js b/dist/index.js
-index 2dd4992d4f033c22be13a8846637d48ef235c57f..cf5264a8ea0b6803b6fb9a950d35e7bd1ed0f959 100644
---- a/dist/index.js
-+++ b/dist/index.js
-@@ -6600,6 +6600,23 @@ function SearchField({
- ] })
- ] });
- }
-+function getSelectItemLabel(children, selectedValue) {
-+ let label;
-+ react.Children.forEach(children, (child) => {
-+ if (label !== void 0 || !react.isValidElement(child)) {
-+ return;
-+ }
-+ if (child.type === ListItem) {
-+ const itemValue = child.props.value ?? child.props.id ?? (typeof child.props.children === "string" ? child.props.children : "");
-+ if (itemValue === selectedValue) {
-+ label = child.props.children;
-+ }
-+ return;
-+ }
-+ label = getSelectItemLabel(child.props.children, selectedValue);
-+ });
-+ return label;
-+}
- function Select({
- value,
- defaultValue,
-@@ -6666,7 +6683,7 @@ function Select({
- ),
- children: [
- /* @__PURE__ */ jsxRuntime.jsx(select.Select.Value, { placeholder, children: (selected) => {
-- const defaultChildren = selected ?? placeholder;
-+ const defaultChildren = selected == null ? placeholder : getSelectItemLabel(collection, selected) ?? selected;
- return typeof renderValue === "function" ? renderValue({
- defaultChildren,
- isPlaceholder: selected == null
-diff --git a/dist/index.mjs b/dist/index.mjs
-index 448a673d0ef00587ba6a233d5e5f8e99efc8215e..f0c0f4e7a5a9f0e2066225e1598f944fbc033c6e 100644
---- a/dist/index.mjs
-+++ b/dist/index.mjs
-@@ -6575,6 +6575,23 @@ function SearchField({
- ] })
- ] });
- }
-+function getSelectItemLabel(children, selectedValue) {
-+ let label;
-+ Children.forEach(children, (child) => {
-+ if (label !== void 0 || !isValidElement(child)) {
-+ return;
-+ }
-+ if (child.type === ListItem) {
-+ const itemValue = child.props.value ?? child.props.id ?? (typeof child.props.children === "string" ? child.props.children : "");
-+ if (itemValue === selectedValue) {
-+ label = child.props.children;
-+ }
-+ return;
-+ }
-+ label = getSelectItemLabel(child.props.children, selectedValue);
-+ });
-+ return label;
-+}
- function Select({
- value,
- defaultValue,
-@@ -6641,7 +6658,7 @@ function Select({
- ),
- children: [
- /* @__PURE__ */ jsx(Select$1.Value, { placeholder, children: (selected) => {
-- const defaultChildren = selected ?? placeholder;
-+ const defaultChildren = selected == null ? placeholder : getSelectItemLabel(collection, selected) ?? selected;
- return typeof renderValue === "function" ? renderValue({
- defaultChildren,
- isPlaceholder: selected == null
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b61bf9059..0a111a113 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4,9 +4,6 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
-patchedDependencies:
- '@umami/[email protected]': 7a13e402d0a59d203f92fa4c64c8511aa38c5cd914092f5232c6271c606c9126
-
importers:
.:
@@ -39,8 +36,8 @@ importers:
specifier: ^5.101.4
version: 5.101.4([email protected])
'@umami/react-zen':
- specifier: ^0.247.0
- version: 0.247.0(patch_hash=7a13e402d0a59d203f92fa4c64c8511aa38c5cd914092f5232c6271c606c9126)(@date-fns/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))
+ specifier: ^0.248.0
bcryptjs:
specifier: ^3.0.2
version: 3.0.3
@@ -2930,8 +2927,8 @@ packages:
resolution: {integrity: sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==}
- '@umami/[email protected]':
- resolution: {integrity: sha512-3I8kCsSX3DEDX2D0ft+2g9fUdmXm5+BWR6mMkbOxYy9bColbL5gTF7UOcl+wuN4ETOh7bo9Lxk5CM6hDyZX6uA==}
+ '@umami/[email protected]':
+ resolution: {integrity: sha512-sCEA+nVko+7cETmnmF+HvKyP54Bn/9S0GPexyA7QCDoYITu5X4FS2TT422kKM2UX6eVmuiq8slMdeZfAlUEynw==}
peerDependencies:
react: ^18.0.0 || ^19.0.0
react-dom: ^18.0.0 || ^19.0.0
@@ -8268,7 +8265,7 @@ snapshots:
dependencies:
'@types/yargs-parser': 21.0.3
dependencies:
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index e4eb84858..162125ee7 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -11,6 +11,4 @@ allowBuilds:
prisma: true
sharp: false
minimumReleaseAgeExclude:
- - '@umami/[email protected]'
-patchedDependencies:
+ - '@umami/react-zen'
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/attribution/AttributionPage.tsx b/src/app/(main)/websites/[websiteId]/(reports)/attribution/AttributionPage.tsx
index fb61610d7..358bb1879 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/attribution/AttributionPage.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/attribution/AttributionPage.tsx
@@ -1,12 +1,13 @@
'use client';
-import { Column, Grid, Label, ListItem, Loading, Select } from '@umami/react-zen';
+import { Column, Grid, ListItem, Select } from '@umami/react-zen';
import { useState } from 'react';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { Empty } from '@/components/common/Empty';
-import { MultiSelect, MultiSelectItem } from '@/components/common/MultiSelect';
import { useDateRange, useMessages, useWebsiteValuesQuery } from '@/components/hooks';
import { Attribution } from './Attribution';
+const stepPlaceholder = 'Select an item';
+
export function AttributionPage({ websiteId }: { websiteId: string }) {
const [model, setModel] = useState('first-click');
const [type, setType] = useState('path');
@@ -31,10 +32,6 @@ export function AttributionPage({ websiteId }: { websiteId: string }) {
setSearch('');
};
- const handleStepChange = (values: string[]) => {
- setStep(values.filter(value => value !== step).pop() ?? '');
- };
-
return (
<Column gap="6">
<WebsiteControls websiteId={websiteId} />
@@ -62,21 +59,24 @@ export function AttributionPage({ websiteId }: { websiteId: string }) {
</Select>
</Column>
<Column>
- <Label>{t(labels.conversionStep)}</Label>
- <MultiSelect
- value={step ? [step] : []}
- onChange={handleStepChange}
+ <Select
+ label={t(labels.conversionStep)}
+ value={step}
+ onChange={value => setStep(value?.toString() ?? '')}
+ placeholder={stepPlaceholder}
+ renderValue={({ defaultChildren }) => (step ? defaultChildren : stepPlaceholder)}
+ isLoading={isLoading}
searchValue={search}
onSearch={setSearch}
- renderEmptyState={() => (isLoading ? <Loading icon="dots" /> : <Empty />)}
+ maxHeight={320}
allowSearch
>
{items.map(({ value }) => (
- <MultiSelectItem key={value} value={value}>
+ <ListItem key={value} id={value}>
{value}
- </MultiSelectItem>
+ </ListItem>
))}
- </MultiSelect>
+ </Select>
</Column>
</Grid>
{step ? (
diff --git a/src/components/common/ControlledDialog.tsx b/src/components/common/ControlledDialog.tsx
index 2030bd273..808253761 100644
--- a/src/components/common/ControlledDialog.tsx
+++ b/src/components/common/ControlledDialog.tsx
@@ -5,7 +5,7 @@ import type { ReactElement } from 'react';
export function ControlledDialog({ children }: { children: ReactElement }) {
return (
<DialogTrigger>
- <span hidden />
+ <button type="button" hidden />
{children}
</DialogTrigger>
);
diff --git a/src/components/input/TeamsButton.tsx b/src/components/input/TeamsButton.tsx
index 268010500..1ef0475f3 100644
--- a/src/components/input/TeamsButton.tsx
+++ b/src/components/input/TeamsButton.tsx
@@ -1,6 +1,5 @@
import {
Button,
- Column,
Icon,
Menu,
MenuItem,
@@ -72,36 +71,34 @@ export function TeamsButton() {
</Icon>
</Button>
<Popover side="bottom" align="start">
- <Column minWidth="300px">
- <Menu selectionMode="single" selectedKeys={selectedKeys}>
- <MenuSection title={t(labels.myAccount)}>
- <MenuItem id="user" onAction={handleAction}>
- <IconLabel icon={<User />} label={user.username} />
+ <Menu className="min-w-[300px]" selectionMode="single" selectedKeys={selectedKeys}>
+ <MenuSection title={t(labels.myAccount)}>
+ <MenuItem id="user" onAction={handleAction}>
+ <IconLabel icon={<User />} label={user.username} />
+ </MenuItem>
+ </MenuSection>
+ <MenuSeparator />
+ <MenuSection title={t(labels.teams)}>
+ {user?.teams?.map(({ id, name }) => (
+ <MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
+ <IconLabel icon={<Users />}>
+ <Text wrap="nowrap">{name}</Text>
+ </IconLabel>
</MenuItem>
- </MenuSection>
+ ))}
<MenuSeparator />
- <MenuSection title={t(labels.teams)}>
- {user?.teams?.map(({ id, name }) => (
- <MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
- <IconLabel icon={<Users />}>
- <Text wrap="nowrap">{name}</Text>
- </IconLabel>
- </MenuItem>
- ))}
- <MenuSeparator />
- <MenuItem id="manage-teams">
- <a href="/settings/teams" style={{ width: '100%' }}>
- <Row alignItems="center" justifyContent="space-between" gap>
- <Text align="center">Manage teams</Text>
- <Icon>
- <ArrowRight />
- </Icon>
- </Row>
- </a>
- </MenuItem>
- </MenuSection>
- </Menu>
- </Column>
+ <MenuItem id="manage-teams">
+ <a href="/settings/teams" style={{ width: '100%' }}>
+ <Row alignItems="center" justifyContent="space-between" gap>
+ <Text align="center">Manage teams</Text>
+ <Icon>
+ <ArrowRight />
+ </Icon>
+ </Row>
+ </a>
+ </MenuItem>
+ </MenuSection>
+ </Menu>
</Popover>
</MenuTrigger>
);