@adecore/ui 0.33.2 → 0.34.0

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.
Files changed (63) hide show
  1. package/dist/Banner.d.ts +2 -1
  2. package/dist/Banner.js +92 -51
  3. package/dist/CopyButton.d.ts +24 -0
  4. package/dist/CopyButton.js +144 -0
  5. package/dist/ErrorBoundary.js +16 -18
  6. package/dist/ProjectSwitcher.js +66 -73
  7. package/dist/RelativeTime.d.ts +9 -0
  8. package/dist/RelativeTime.js +38 -0
  9. package/dist/Segmented.d.ts +4 -1
  10. package/dist/Segmented.js +111 -86
  11. package/dist/Toasts.js +1 -1
  12. package/dist/combobox/index.parts.d.ts +1 -0
  13. package/dist/combobox/index.parts.js +1 -0
  14. package/dist/combobox/parts.d.ts +32 -0
  15. package/dist/combobox/parts.js +556 -0
  16. package/dist/command-palette/index.parts.d.ts +2 -0
  17. package/dist/command-palette/index.parts.js +3 -0
  18. package/dist/command-palette/parts.d.ts +32 -0
  19. package/dist/command-palette/parts.js +422 -0
  20. package/dist/format/datetime.d.ts +1 -0
  21. package/dist/format/datetime.js +8 -0
  22. package/dist/format/duration.d.ts +1 -0
  23. package/dist/format/duration.js +24 -1
  24. package/dist/format/index.d.ts +2 -2
  25. package/dist/format/index.js +2 -2
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.js +5 -0
  28. package/dist/locales/en.d.ts +8 -0
  29. package/dist/locales/en.js +8 -0
  30. package/dist/locales/nl.d.ts +8 -0
  31. package/dist/locales/nl.js +8 -0
  32. package/dist/match.d.ts +1 -0
  33. package/dist/match.js +47 -0
  34. package/dist/segmented-keys.d.ts +3 -0
  35. package/dist/segmented-keys.js +33 -0
  36. package/dist/theme.css +15 -0
  37. package/dist/toast-store.d.ts +1 -0
  38. package/dist/toast-store.js +16 -6
  39. package/dist/workspace/TabStrip.d.ts +2 -1
  40. package/dist/workspace/TabStrip.js +432 -372
  41. package/package.json +1 -1
  42. package/src/Banner.tsx +33 -9
  43. package/src/CopyButton.tsx +86 -0
  44. package/src/ErrorBoundary.tsx +3 -4
  45. package/src/ProjectSwitcher.tsx +4 -2
  46. package/src/RelativeTime.tsx +44 -0
  47. package/src/Segmented.tsx +60 -33
  48. package/src/Toasts.tsx +1 -1
  49. package/src/combobox/index.parts.ts +12 -0
  50. package/src/combobox/parts.tsx +147 -0
  51. package/src/command-palette/index.parts.ts +16 -0
  52. package/src/command-palette/parts.tsx +145 -0
  53. package/src/format/datetime.ts +5 -0
  54. package/src/format/duration.ts +25 -1
  55. package/src/format/index.ts +2 -1
  56. package/src/index.ts +7 -0
  57. package/src/locales/en.ts +8 -0
  58. package/src/locales/nl.ts +8 -0
  59. package/src/match.ts +50 -0
  60. package/src/segmented-keys.ts +33 -0
  61. package/src/theme.css +15 -0
  62. package/src/toast-store.ts +16 -6
  63. package/src/workspace/TabStrip.tsx +31 -2
@@ -4,6 +4,7 @@ export interface SegmentedOption<T extends string> {
4
4
  id: T;
5
5
  label: string;
6
6
  icon?: LucideIcon;
7
+ disabled?: boolean;
7
8
  }
8
9
  export interface SegmentedProps<T extends string> {
9
10
  value: T;
@@ -12,7 +13,9 @@ export interface SegmentedProps<T extends string> {
12
13
  label: string;
13
14
  disabled?: boolean;
14
15
  orientation?: 'horizontal' | 'vertical';
16
+ size?: 'md' | 'sm';
17
+ iconOnly?: boolean;
15
18
  className?: string;
16
19
  ref?: Ref<HTMLDivElement>;
17
20
  }
18
- export declare function Segmented<T extends string>({ value, onValueChange, options, label, disabled, orientation, className, ref }: SegmentedProps<T>): import("react").JSX.Element;
21
+ export declare function Segmented<T extends string>({ value, onValueChange, options, label, disabled, orientation, size, iconOnly, className, ref }: SegmentedProps<T>): import("react").JSX.Element;
package/dist/Segmented.js CHANGED
@@ -1,19 +1,31 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import clsx from 'clsx';
3
3
  import { Icon } from "./Icon.js";
4
+ import { segmentedStop, segmentedTarget } from './segmented-keys.js';
5
+ import { Tooltip } from "./Tooltip.js";
4
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- const STEPS = {
6
- ArrowRight: 1,
7
- ArrowDown: 1,
8
- ArrowLeft: -1,
9
- ArrowUp: -1
7
+ const SIZE = {
8
+ md: {
9
+ track: 'rounded-lg',
10
+ row: 'min-h-8',
11
+ option: 'min-h-7 rounded-md px-3 py-1',
12
+ square: 'size-7 rounded-md',
13
+ icon: 14
14
+ },
15
+ sm: {
16
+ track: 'rounded-md',
17
+ row: 'min-h-7',
18
+ option: 'min-h-6 rounded-sm px-2.5 py-0.5',
19
+ square: 'size-6 rounded-sm',
20
+ icon: 12
21
+ }
10
22
  };
11
23
  /*
12
24
  * One of a few options side by side in one sunken track, the picked one lifted out of it. A radio
13
25
  * group: one tab stop, and the arrows pick and focus the next option, around the ends.
14
26
  */
15
27
  export function Segmented(t0) {
16
- const $ = _c(30);
28
+ const $ = _c(38);
17
29
  const {
18
30
  value,
19
31
  onValueChange,
@@ -21,34 +33,30 @@ export function Segmented(t0) {
21
33
  label,
22
34
  disabled,
23
35
  orientation: t1,
36
+ size: t2,
37
+ iconOnly: t3,
24
38
  className,
25
39
  ref
26
40
  } = t0;
27
41
  const orientation = t1 === undefined ? "horizontal" : t1;
42
+ const size = t2 === undefined ? "md" : t2;
43
+ const iconOnly = t3 === undefined ? false : t3;
28
44
  const vertical = orientation === "vertical";
29
- let t2;
45
+ const sizing = SIZE[size];
46
+ let t4;
30
47
  if ($[0] !== options || $[1] !== value) {
31
- let t3;
32
- if ($[3] !== value) {
33
- t3 = option => option.id === value;
34
- $[3] = value;
35
- $[4] = t3;
36
- } else {
37
- t3 = $[4];
38
- }
39
- t2 = options.findIndex(t3);
48
+ t4 = segmentedStop(options, value);
40
49
  $[0] = options;
41
50
  $[1] = value;
42
- $[2] = t2;
51
+ $[2] = t4;
43
52
  } else {
44
- t2 = $[2];
53
+ t4 = $[2];
45
54
  }
46
- const picked = t2;
47
- const stop = picked === -1 ? 0 : picked;
48
- let t3;
49
- if ($[5] !== onValueChange || $[6] !== options) {
50
- t3 = function move(event, index) {
51
- const next = event.key in STEPS ? (index + STEPS[event.key] + options.length) % options.length : event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : null;
55
+ const stop = t4;
56
+ let t5;
57
+ if ($[3] !== onValueChange || $[4] !== options) {
58
+ t5 = function move(event, index) {
59
+ const next = segmentedTarget(options, index, event.key);
52
60
  if (next === null) {
53
61
  return;
54
62
  }
@@ -56,81 +64,98 @@ export function Segmented(t0) {
56
64
  onValueChange(options[next].id);
57
65
  event.currentTarget.parentElement?.querySelectorAll("[role=\"radio\"]")[next]?.focus();
58
66
  };
59
- $[5] = onValueChange;
60
- $[6] = options;
61
- $[7] = t3;
67
+ $[3] = onValueChange;
68
+ $[4] = options;
69
+ $[5] = t5;
62
70
  } else {
63
- t3 = $[7];
71
+ t5 = $[5];
64
72
  }
65
- const move = t3;
66
- const t4 = vertical ? "w-full flex-col items-stretch gap-0.5" : "min-h-8 w-fit items-center";
67
- let t5;
68
- if ($[8] !== className || $[9] !== t4) {
69
- t5 = clsx("flex rounded-lg bg-surface-sunken p-0.5 text-xs font-medium", t4, className);
70
- $[8] = className;
71
- $[9] = t4;
72
- $[10] = t5;
73
+ const move = t5;
74
+ let t6;
75
+ if ($[6] !== className || $[7] !== sizing.row || $[8] !== sizing.track || $[9] !== vertical) {
76
+ t6 = clsx("flex bg-surface-sunken p-0.5 text-xs font-medium", sizing.track, vertical ? "w-full flex-col items-stretch gap-0.5" : clsx(sizing.row, "w-fit items-center"), className);
77
+ $[6] = className;
78
+ $[7] = sizing.row;
79
+ $[8] = sizing.track;
80
+ $[9] = vertical;
81
+ $[10] = t6;
73
82
  } else {
74
- t5 = $[10];
83
+ t6 = $[10];
75
84
  }
76
- const t6 = vertical ? "vertical" : undefined;
77
- let t7;
78
- if ($[11] !== disabled || $[12] !== move || $[13] !== onValueChange || $[14] !== options || $[15] !== stop || $[16] !== value) {
79
- let t8;
80
- if ($[18] !== disabled || $[19] !== move || $[20] !== onValueChange || $[21] !== stop || $[22] !== value) {
81
- t8 = (option_0, index_0) => /*#__PURE__*/_jsxs("button", {
82
- type: "button",
83
- role: "radio",
84
- "aria-checked": value === option_0.id,
85
- tabIndex: index_0 === stop ? 0 : -1,
86
- disabled: disabled,
87
- className: clsx("flex min-h-7 items-center gap-1.5 rounded-md px-3 py-1 text-left transition-colors disabled:opacity-50", value === option_0.id ? "bg-surface-raised text-text shadow-raised" : "text-text-muted hover:text-text"),
88
- onClick: () => onValueChange(option_0.id),
89
- onKeyDown: event_0 => move(event_0, index_0),
90
- children: [option_0.icon && /*#__PURE__*/_jsx(Icon, {
91
- icon: option_0.icon,
92
- size: 14,
93
- className: "shrink-0"
94
- }), option_0.label]
95
- }, option_0.id);
96
- $[18] = disabled;
97
- $[19] = move;
98
- $[20] = onValueChange;
99
- $[21] = stop;
100
- $[22] = value;
101
- $[23] = t8;
85
+ const t7 = vertical ? "vertical" : undefined;
86
+ let t8;
87
+ if ($[11] !== disabled || $[12] !== iconOnly || $[13] !== move || $[14] !== onValueChange || $[15] !== options || $[16] !== sizing.icon || $[17] !== sizing.option || $[18] !== sizing.square || $[19] !== stop || $[20] !== value) {
88
+ let t9;
89
+ if ($[22] !== disabled || $[23] !== iconOnly || $[24] !== move || $[25] !== onValueChange || $[26] !== sizing.icon || $[27] !== sizing.option || $[28] !== sizing.square || $[29] !== stop || $[30] !== value) {
90
+ t9 = (option, index_0) => {
91
+ const square = iconOnly && option.icon !== undefined;
92
+ const button = /*#__PURE__*/_jsxs("button", {
93
+ type: "button",
94
+ role: "radio",
95
+ "aria-checked": value === option.id,
96
+ tabIndex: index_0 === stop ? 0 : -1,
97
+ disabled: disabled || option.disabled,
98
+ className: clsx("flex items-center transition-colors disabled:opacity-50", square ? clsx(sizing.square, "justify-center") : clsx(sizing.option, "gap-1.5 text-left"), value === option.id ? "bg-surface-raised text-text shadow-raised" : "text-text-muted enabled:hover:text-text"),
99
+ onClick: () => onValueChange(option.id),
100
+ onKeyDown: event_0 => move(event_0, index_0),
101
+ children: [option.icon && /*#__PURE__*/_jsx(Icon, {
102
+ icon: option.icon,
103
+ size: sizing.icon,
104
+ className: "shrink-0"
105
+ }), !square && option.label]
106
+ }, option.id);
107
+ return square ? /*#__PURE__*/_jsx(Tooltip, {
108
+ label: option.label,
109
+ name: true,
110
+ children: button
111
+ }, option.id) : button;
112
+ };
113
+ $[22] = disabled;
114
+ $[23] = iconOnly;
115
+ $[24] = move;
116
+ $[25] = onValueChange;
117
+ $[26] = sizing.icon;
118
+ $[27] = sizing.option;
119
+ $[28] = sizing.square;
120
+ $[29] = stop;
121
+ $[30] = value;
122
+ $[31] = t9;
102
123
  } else {
103
- t8 = $[23];
124
+ t9 = $[31];
104
125
  }
105
- t7 = options.map(t8);
126
+ t8 = options.map(t9);
106
127
  $[11] = disabled;
107
- $[12] = move;
108
- $[13] = onValueChange;
109
- $[14] = options;
110
- $[15] = stop;
111
- $[16] = value;
112
- $[17] = t7;
128
+ $[12] = iconOnly;
129
+ $[13] = move;
130
+ $[14] = onValueChange;
131
+ $[15] = options;
132
+ $[16] = sizing.icon;
133
+ $[17] = sizing.option;
134
+ $[18] = sizing.square;
135
+ $[19] = stop;
136
+ $[20] = value;
137
+ $[21] = t8;
113
138
  } else {
114
- t7 = $[17];
139
+ t8 = $[21];
115
140
  }
116
- let t8;
117
- if ($[24] !== label || $[25] !== ref || $[26] !== t5 || $[27] !== t6 || $[28] !== t7) {
118
- t8 = /*#__PURE__*/_jsx("div", {
141
+ let t9;
142
+ if ($[32] !== label || $[33] !== ref || $[34] !== t6 || $[35] !== t7 || $[36] !== t8) {
143
+ t9 = /*#__PURE__*/_jsx("div", {
119
144
  ref: ref,
120
- className: t5,
145
+ className: t6,
121
146
  role: "radiogroup",
122
147
  "aria-label": label,
123
- "aria-orientation": t6,
124
- children: t7
148
+ "aria-orientation": t7,
149
+ children: t8
125
150
  });
126
- $[24] = label;
127
- $[25] = ref;
128
- $[26] = t5;
129
- $[27] = t6;
130
- $[28] = t7;
131
- $[29] = t8;
151
+ $[32] = label;
152
+ $[33] = ref;
153
+ $[34] = t6;
154
+ $[35] = t7;
155
+ $[36] = t8;
156
+ $[37] = t9;
132
157
  } else {
133
- t8 = $[29];
158
+ t9 = $[37];
134
159
  }
135
- return t8;
160
+ return t9;
136
161
  }
package/dist/Toasts.js CHANGED
@@ -183,7 +183,7 @@ function ToastCard(t0) {
183
183
  const {
184
184
  t
185
185
  } = useTranslation("ui");
186
- const leaves = toast.kind === "deleted" || toast.kind === "success" && toast.persist !== true;
186
+ const leaves = toast.deadline !== undefined;
187
187
  let t1;
188
188
  if ($[0] !== toast.action) {
189
189
  t1 = toast.action === undefined ? [] : [toast.action];
@@ -0,0 +1 @@
1
+ export { ComboboxCollection as Collection, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status } from './parts.tsx';
@@ -0,0 +1 @@
1
+ export { ComboboxCollection as Collection, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxGroupLabel as GroupLabel, ComboboxInput as Input, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status } from "./parts.js";
@@ -0,0 +1,32 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import type { LucideIcon } from 'lucide-react';
3
+ import { Autocomplete } from '@base-ui/react/autocomplete';
4
+ import { type PlacementKey } from '../placement.ts';
5
+ import type { Shortcut } from '../shortcut.ts';
6
+ export declare const ComboboxRoot: typeof Autocomplete.Root;
7
+ export type ComboboxInputProps = Omit<ComponentProps<typeof Autocomplete.Input>, 'size' | 'className'> & {
8
+ className?: string;
9
+ size?: 'md' | 'sm';
10
+ mono?: boolean;
11
+ icon?: LucideIcon;
12
+ };
13
+ export declare function ComboboxInput({ size, mono, icon, className, id, ...props }: ComboboxInputProps): import("react").JSX.Element;
14
+ type Placement = Pick<ComponentProps<typeof Autocomplete.Positioner>, PlacementKey>;
15
+ export type ComboboxPopupProps = ComponentProps<typeof Autocomplete.Popup> & Placement;
16
+ export declare function ComboboxPopup({ side, align, sideOffset, className, ...props }: ComboboxPopupProps): import("react").JSX.Element;
17
+ export declare function ComboboxList(props: ComponentProps<typeof Autocomplete.List>): import("react").JSX.Element;
18
+ export type ComboboxItemProps = ComponentProps<typeof Autocomplete.Item> & {
19
+ icon?: ReactNode;
20
+ hint?: ReactNode;
21
+ description?: ReactNode;
22
+ trailing?: ReactNode;
23
+ shortcut?: Shortcut;
24
+ unstyled?: boolean;
25
+ };
26
+ export declare function ComboboxItem({ icon, hint, description, trailing, shortcut, unstyled, className, children, ...props }: ComboboxItemProps): import("react").JSX.Element;
27
+ export declare const ComboboxGroup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ComboboxGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
28
+ export declare function ComboboxGroupLabel({ className, ...props }: ComponentProps<typeof Autocomplete.GroupLabel>): import("react").JSX.Element;
29
+ export declare const ComboboxCollection: typeof Autocomplete.Collection;
30
+ export declare function ComboboxEmpty({ className, ...props }: ComponentProps<typeof Autocomplete.Empty>): import("react").JSX.Element;
31
+ export declare function ComboboxStatus({ className, ...props }: ComponentProps<typeof Autocomplete.Status>): import("react").JSX.Element;
32
+ export {};