@erxes/ui 3.2.22-1 → 3.2.25-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,14 @@ export declare const ComboboxContent: React.ForwardRefExoticComponent<Omit<Omit<
18
18
  export declare const ComboboxCheck: React.ForwardRefExoticComponent<Omit<import("@tabler/icons-react").IconProps & React.RefAttributes<import("@tabler/icons-react").Icon>, "ref"> & {
19
19
  checked?: boolean;
20
20
  } & React.RefAttributes<import("@tabler/icons-react").Icon>>;
21
+ export declare const ComboboxChipTrigger: ({ label, children, className, disabled, onClear, clearLabel, }: {
22
+ label?: string;
23
+ children: React.ReactNode;
24
+ className?: string;
25
+ disabled?: boolean;
26
+ onClear?: () => void;
27
+ clearLabel?: string;
28
+ }) => import("react/jsx-runtime").JSX.Element;
21
29
  export declare const ComboboxFetchMore: React.ForwardRefExoticComponent<Omit<Omit<{
22
30
  children?: React.ReactNode;
23
31
  } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
@@ -53,6 +61,14 @@ export declare const Combobox: {
53
61
  Check: React.ForwardRefExoticComponent<Omit<import("@tabler/icons-react").IconProps & React.RefAttributes<import("@tabler/icons-react").Icon>, "ref"> & {
54
62
  checked?: boolean;
55
63
  } & React.RefAttributes<import("@tabler/icons-react").Icon>>;
64
+ ChipTrigger: ({ label, children, className, disabled, onClear, clearLabel, }: {
65
+ label?: string;
66
+ children: React.ReactNode;
67
+ className?: string;
68
+ disabled?: boolean;
69
+ onClear?: () => void;
70
+ clearLabel?: string;
71
+ }) => import("react/jsx-runtime").JSX.Element;
56
72
  FetchMore: React.ForwardRefExoticComponent<Omit<Omit<{
57
73
  children?: React.ReactNode;
58
74
  } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/ui",
3
- "version": "3.2.22-1",
3
+ "version": "3.2.25-2",
4
4
  "description": "erxes design system: UI primitives, business modules, hooks and shared frontend state",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Button } from './button';
3
3
  import { cn } from '../lib/utils';
4
- import { IconCheck, IconChevronDown } from '@tabler/icons-react';
4
+ import { IconCheck, IconChevronDown, IconX } from '@tabler/icons-react';
5
5
  import { Popover } from './popover';
6
6
  import { Command } from './command';
7
7
  import { useInView } from 'react-intersection-observer';
@@ -139,6 +139,72 @@ export const ComboboxCheck = React.forwardRef<
139
139
 
140
140
  ComboboxCheck.displayName = 'ComboboxCheck';
141
141
 
142
+ export const ComboboxChipTrigger = ({
143
+ label,
144
+ children,
145
+ className,
146
+ disabled,
147
+ onClear,
148
+ clearLabel,
149
+ }: {
150
+ label?: string;
151
+ children: React.ReactNode;
152
+ className?: string;
153
+ disabled?: boolean;
154
+ onClear?: () => void;
155
+ clearLabel?: string;
156
+ }) => {
157
+ const trigger = (
158
+ <ComboboxTriggerBase
159
+ className={cn(
160
+ 'group w-fit max-w-sm h-7 rounded p-0 gap-0 overflow-hidden',
161
+ 'data-[state=open]:border-primary/40',
162
+ className,
163
+ )}
164
+ disabled={disabled}
165
+ >
166
+ {label && (
167
+ <span className="flex h-full shrink-0 items-center whitespace-nowrap px-3 text-muted-foreground bg-muted/40 border-r">
168
+ {label}
169
+ </span>
170
+ )}
171
+ <span className="flex min-w-0 items-center gap-1.5 pl-3 pr-2.5 font-medium text-foreground">
172
+ <span className="flex min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap [&_svg]:size-4 [&_svg]:shrink-0">
173
+ {children}
174
+ </span>
175
+ {onClear ? (
176
+ <span className="size-5 shrink-0" />
177
+ ) : (
178
+ <IconChevronDown className="size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" />
179
+ )}
180
+ </span>
181
+ </ComboboxTriggerBase>
182
+ );
183
+
184
+ if (!onClear) {
185
+ return trigger;
186
+ }
187
+
188
+ return (
189
+ <div className="relative w-fit max-w-sm">
190
+ {trigger}
191
+ <Button
192
+ variant="ghost"
193
+ size="icon"
194
+ aria-label={clearLabel}
195
+ title={clearLabel}
196
+ className="absolute right-2 top-1/2 size-5 -translate-y-1/2 p-0 text-muted-foreground"
197
+ onClick={(e) => {
198
+ e.stopPropagation();
199
+ onClear();
200
+ }}
201
+ >
202
+ <IconX />
203
+ </Button>
204
+ </div>
205
+ );
206
+ };
207
+
142
208
  export const ComboboxFetchMore = React.forwardRef<
143
209
  React.ElementRef<typeof Command.Item>,
144
210
  React.ComponentPropsWithoutRef<typeof Command.Item> & {
@@ -207,6 +273,7 @@ export const Combobox = {
207
273
  Value: ComboboxValue,
208
274
  Content: ComboboxContent,
209
275
  Check: ComboboxCheck,
276
+ ChipTrigger: ComboboxChipTrigger,
210
277
  FetchMore: ComboboxFetchMore,
211
278
  Empty: ComboboxEmpty,
212
279
  };
@@ -32,6 +32,14 @@ const findSidebarPanelSlot = (panel: HTMLElement | null) => {
32
32
  return null;
33
33
  };
34
34
 
35
+ const SidebarPanelInnerTriggerHiddenContext = React.createContext(false);
36
+
37
+ const isSlotAbovePanel = (slot: HTMLElement, panel: HTMLElement | null) =>
38
+ Boolean(
39
+ panel &&
40
+ slot.compareDocumentPosition(panel) & Node.DOCUMENT_POSITION_FOLLOWING,
41
+ );
42
+
35
43
  const useSidebarPanelSlot = (
36
44
  panelRef: React.RefObject<HTMLDivElement | null>,
37
45
  open: boolean,
@@ -40,13 +48,9 @@ const useSidebarPanelSlot = (
40
48
  const [claimed, setClaimed] = React.useState(false);
41
49
 
42
50
  React.useLayoutEffect(() => {
43
- if (open) {
44
- return;
45
- }
46
-
47
51
  const found = findSidebarPanelSlot(panelRef.current);
48
52
 
49
- if (!found) {
53
+ if (!found || (open && !isSlotAbovePanel(found, panelRef.current))) {
50
54
  setSlot(null);
51
55
  setClaimed(false);
52
56
  return;
@@ -68,19 +72,24 @@ const useSidebarPanelSlot = (
68
72
  };
69
73
  }, [open, panelRef]);
70
74
 
71
- return { slot: open ? null : slot, claimed };
75
+ return { slot, claimed };
72
76
  };
73
77
 
74
78
  export const SidebarPanelTrigger = React.forwardRef<
75
79
  React.ElementRef<typeof Button>,
76
80
  React.ComponentProps<typeof Button>
77
81
  >(({ className, onClick, ...props }, ref) => {
82
+ const hidden = React.useContext(SidebarPanelInnerTriggerHiddenContext);
78
83
  const [open, setOpen] = useAtom(sidebarPanelOpenState);
79
84
  const { t } = useTranslation('common', { keyPrefix: 'navigation' });
80
85
  const toggleLabel = open
81
86
  ? t('collapse-sidebar', 'Collapse sidebar')
82
87
  : t('expand-sidebar', 'Expand sidebar');
83
88
 
89
+ if (hidden) {
90
+ return null;
91
+ }
92
+
84
93
  return (
85
94
  <Button
86
95
  ref={ref}
@@ -116,6 +125,7 @@ export const SidebarPanel = React.forwardRef<
116
125
  const open = useAtomValue(sidebarPanelOpenState);
117
126
  const [panelRef, setRefs] = useComposedRef(ref);
118
127
  const { slot, claimed } = useSidebarPanelSlot(panelRef, open);
128
+ const triggerInSlot = Boolean(slot && claimed);
119
129
 
120
130
  return (
121
131
  <div
@@ -138,28 +148,27 @@ export const SidebarPanel = React.forwardRef<
138
148
  </Portal.Root>
139
149
  )}
140
150
  {!open && !slot && (
141
- <div className="absolute top-2 left-2 z-20">
151
+ <div className="absolute top-2.5 left-2 z-20">
142
152
  <SidebarPanelTrigger className="size-7 border bg-background shadow-xs" />
143
153
  </div>
144
154
  )}
145
- {open && label && (
146
- <div className="flex shrink-0 items-center gap-1 pt-3 pr-3 pl-4">
147
- <span className="min-w-0 flex-1 truncate px-2 font-mono text-xs font-semibold uppercase text-accent-foreground">
148
- {label}
149
- </span>
150
- {actions}
151
- <SidebarPanelTrigger />
152
- </div>
153
- )}
154
- <div
155
- hidden={!open}
156
- className={cn(
157
- 'flex min-h-0 flex-1 flex-col overflow-y-auto',
158
- label && '[&>[data-sidebar=group]:first-child]:pt-0',
155
+ <SidebarPanelInnerTriggerHiddenContext.Provider value={triggerInSlot}>
156
+ {open && label && (
157
+ <div className="flex h-12 shrink-0 items-center gap-1 px-2">
158
+ <span className="min-w-0 flex-1 truncate px-2 text-sm font-medium">
159
+ {label}
160
+ </span>
161
+ {actions}
162
+ <SidebarPanelTrigger className="size-8" />
163
+ </div>
159
164
  )}
160
- >
161
- {children}
162
- </div>
165
+ <div
166
+ hidden={!open}
167
+ className="flex min-h-0 flex-1 flex-col overflow-y-auto"
168
+ >
169
+ {children}
170
+ </div>
171
+ </SidebarPanelInnerTriggerHiddenContext.Provider>
163
172
  </div>
164
173
  );
165
174
  });