@dxos/react-ui 0.8.2-main.30e4dbb → 0.8.2-main.4c6cf53

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 (103) hide show
  1. package/dist/lib/browser/chunk-5Y5JI6KC.mjs +4355 -0
  2. package/dist/lib/browser/chunk-5Y5JI6KC.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +73 -3518
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +85 -0
  7. package/dist/lib/browser/testing/index.mjs.map +7 -0
  8. package/dist/lib/node/chunk-KMS7RFL7.cjs +4340 -0
  9. package/dist/lib/node/chunk-KMS7RFL7.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +69 -3480
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +114 -0
  14. package/dist/lib/node/testing/index.cjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-ANVE7WX5.mjs +4357 -0
  16. package/dist/lib/node-esm/chunk-ANVE7WX5.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +72 -3518
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +86 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/components/Avatars/Avatar.d.ts +2 -2
  23. package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
  24. package/dist/types/src/components/Avatars/Avatar.stories.d.ts +2 -2
  25. package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +0 -1
  27. package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Buttons/IconButton.d.ts +1 -2
  29. package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
  30. package/dist/types/src/components/Buttons/IconButton.stories.d.ts +7 -6
  31. package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
  33. package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +1 -4
  34. package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
  35. package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +2 -2
  36. package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/Dialogs/Dialog.d.ts +1 -5
  38. package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
  39. package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +2 -2
  40. package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
  41. package/dist/types/src/components/Input/Input.d.ts +1 -1
  42. package/dist/types/src/components/Input/Input.d.ts.map +1 -1
  43. package/dist/types/src/components/Input/Input.stories.d.ts +33 -159
  44. package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
  45. package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
  46. package/dist/types/src/components/Lists/Treegrid.stories.d.ts +1 -1
  47. package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
  48. package/dist/types/src/components/Main/Main.d.ts.map +1 -1
  49. package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
  50. package/dist/types/src/components/Message/Message.stories.d.ts +2 -2
  51. package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
  52. package/dist/types/src/components/Popover/Popover.d.ts +13 -5
  53. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  54. package/dist/types/src/components/Popover/Popover.stories.d.ts +5 -1
  55. package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
  56. package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
  57. package/dist/types/src/components/Toast/Toast.stories.d.ts +2 -2
  58. package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  60. package/dist/types/src/components/Tooltip/Tooltip.d.ts +0 -2
  61. package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  62. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +2 -3
  63. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
  64. package/dist/types/src/testing/decorators/index.d.ts +1 -1
  65. package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
  66. package/dist/types/src/testing/decorators/{withVariants.d.ts → withSurfaceVariantsLayout.d.ts} +2 -3
  67. package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.d.ts.map +1 -0
  68. package/package.json +24 -15
  69. package/src/components/Avatars/Avatar.stories.tsx +27 -27
  70. package/src/components/Avatars/Avatar.tsx +7 -8
  71. package/src/components/Avatars/AvatarGroup.stories.tsx +4 -5
  72. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
  73. package/src/components/Buttons/Button.stories.tsx +2 -2
  74. package/src/components/Buttons/IconButton.stories.tsx +9 -10
  75. package/src/components/Buttons/IconButton.tsx +4 -8
  76. package/src/components/Buttons/Toggle.stories.tsx +2 -2
  77. package/src/components/Buttons/ToggleGroup.stories.tsx +3 -7
  78. package/src/components/Dialogs/AlertDialog.stories.tsx +4 -11
  79. package/src/components/Dialogs/Dialog.stories.tsx +3 -3
  80. package/src/components/Dialogs/Dialog.tsx +6 -8
  81. package/src/components/Input/Input.stories.tsx +69 -58
  82. package/src/components/Input/Input.tsx +1 -0
  83. package/src/components/Lists/Tree.stories.tsx +2 -2
  84. package/src/components/Lists/Treegrid.stories.tsx +12 -12
  85. package/src/components/Main/Main.stories.tsx +2 -2
  86. package/src/components/Main/Main.tsx +1 -0
  87. package/src/components/Menus/ContextMenu.stories.tsx +2 -2
  88. package/src/components/Menus/DropdownMenu.stories.tsx +2 -2
  89. package/src/components/Message/Message.stories.tsx +3 -3
  90. package/src/components/Popover/Popover.stories.tsx +2 -2
  91. package/src/components/Popover/Popover.tsx +5 -4
  92. package/src/components/ScrollArea/ScrollArea.stories.tsx +4 -4
  93. package/src/components/Select/Select.stories.tsx +2 -2
  94. package/src/components/Toast/Toast.stories.tsx +15 -10
  95. package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
  96. package/src/components/Tooltip/Tooltip.stories.tsx +3 -3
  97. package/src/components/Tooltip/Tooltip.tsx +1 -16
  98. package/src/playground/Controls.stories.tsx +2 -2
  99. package/src/playground/Typography.stories.tsx +2 -2
  100. package/src/testing/decorators/index.ts +1 -1
  101. package/src/testing/decorators/withSurfaceVariantsLayout.tsx +53 -0
  102. package/dist/types/src/testing/decorators/withVariants.d.ts.map +0 -1
  103. package/src/testing/decorators/withVariants.tsx +0 -45
@@ -1,3523 +1,78 @@
1
+ import {
2
+ AlertDialog,
3
+ AnchoredOverflow,
4
+ Avatar,
5
+ BUTTON_GROUP_NAME,
6
+ Breadcrumb,
7
+ Button,
8
+ ButtonGroup,
9
+ Clipboard,
10
+ ContextMenu,
11
+ DensityContext,
12
+ DensityProvider,
13
+ Dialog,
14
+ DropdownMenu,
15
+ ElevationContext,
16
+ ElevationProvider,
17
+ Icon,
18
+ IconButton,
19
+ Input,
20
+ LIST_ITEM_NAME,
21
+ LIST_NAME,
22
+ Link,
23
+ List,
24
+ ListItem,
25
+ Main,
26
+ Message,
27
+ Popover,
28
+ ScrollArea,
29
+ Select,
30
+ Separator,
31
+ Status,
32
+ Tag,
33
+ ThemeContext,
34
+ ThemeProvider,
35
+ Toast,
36
+ Toggle,
37
+ ToggleGroup,
38
+ ToggleGroupItem,
39
+ Toolbar,
40
+ Tooltip,
41
+ Tree,
42
+ TreeItem,
43
+ Treegrid,
44
+ createDropdownMenuScope,
45
+ createPopoverScope,
46
+ createTooltipScope,
47
+ hasIosKeyboard,
48
+ initialSafeArea,
49
+ isLabel,
50
+ toLocalizedString,
51
+ useAvatarContext,
52
+ useButtonGroupContext,
53
+ useClipboard,
54
+ useDensityContext,
55
+ useDropdownMenuContext,
56
+ useDropdownMenuMenuScope,
57
+ useElevationContext,
58
+ useIconHref,
59
+ useLandmarkMover,
60
+ useListContext,
61
+ useListItemContext,
62
+ useMainContext,
63
+ useSafeArea,
64
+ useSidebars,
65
+ useThemeContext,
66
+ useTooltipContext,
67
+ useTranslation,
68
+ useTranslationsContext,
69
+ useVisualViewport
70
+ } from "./chunk-5Y5JI6KC.mjs";
71
+
1
72
  // packages/ui/react-ui/src/index.ts
2
73
  import { Trans } from "react-i18next";
3
74
  export * from "@dxos/react-hooks";
4
75
  export * from "@dxos/react-ui-types";
5
-
6
- // packages/ui/react-ui/src/components/AnchoredOverflow/AnchoredOverflow.tsx
7
- import { Primitive } from "@radix-ui/react-primitive";
8
- import { Slot } from "@radix-ui/react-slot";
9
- import React2, { forwardRef } from "react";
10
-
11
- // packages/ui/react-ui/src/hooks/useDensityContext.ts
12
- import { useContext } from "react";
13
- var useDensityContext = (propsDensity) => {
14
- const { density } = useContext(DensityContext);
15
- return propsDensity ?? density;
16
- };
17
-
18
- // packages/ui/react-ui/src/hooks/useElevationContext.ts
19
- import { useContext as useContext2 } from "react";
20
- var useElevationContext = (propsElevation) => {
21
- const { elevation } = useContext2(ElevationContext);
22
- return propsElevation ?? elevation;
23
- };
24
-
25
- // packages/ui/react-ui/src/hooks/useThemeContext.ts
26
- import { useContext as useContext3 } from "react";
27
- import { raise } from "@dxos/debug";
28
- var useThemeContext = () => useContext3(ThemeContext) ?? raise(new Error("Missing ThemeContext"));
29
-
30
- // packages/ui/react-ui/src/hooks/useIconHref.ts
31
- var ICONS_URL = "/icons.svg";
32
- var useIconHref = (icon) => {
33
- const { noCache } = useThemeContext();
34
- const url = noCache ? `${ICONS_URL}?nocache=${(/* @__PURE__ */ new Date()).getMinutes()}` : ICONS_URL;
35
- return icon ? `${url}#${icon}` : void 0;
36
- };
37
-
38
- // packages/ui/react-ui/src/hooks/useSafeArea.ts
39
- import { useCallback, useState } from "react";
40
- import { useResize } from "@dxos/react-hooks";
41
- var initialSafeArea = {
42
- top: NaN,
43
- right: NaN,
44
- bottom: NaN,
45
- left: NaN
46
- };
47
- var useSafeArea = () => {
48
- const [padding, setPadding] = useState(initialSafeArea);
49
- const handleResize = useCallback(() => {
50
- setPadding({
51
- top: parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--safe-area-top")),
52
- right: parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--safe-area-right")),
53
- bottom: parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--safe-area-bottom")),
54
- left: parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--safe-area-left"))
55
- });
56
- }, []);
57
- useResize(handleResize);
58
- return padding;
59
- };
60
-
61
- // packages/ui/react-ui/src/hooks/useTranslationsContext.ts
62
- import { useContext as useContext5 } from "react";
63
-
64
- // packages/ui/react-ui/src/components/ThemeProvider/TranslationsProvider.tsx
65
- import { enUS as dtLocaleEnUs } from "date-fns/locale";
66
- import i18Next from "i18next";
67
- import React, { useEffect, createContext, useState as useState2, Suspense, useContext as useContext4 } from "react";
68
- import { initReactI18next, useTranslation as useI18NextTranslation } from "react-i18next";
69
- var initialLng = "en-US";
70
- var initialNs = "dxos-common";
71
- var initialDtLocale = dtLocaleEnUs;
72
- var isLabel = (o) => typeof o === "string" || Array.isArray(o) && o.length === 2 && typeof o[0] === "string" && !!o[1] && typeof o[1] === "object" && "ns" in o[1] && typeof o[1].ns === "string";
73
- var toLocalizedString = (label, t) => Array.isArray(label) ? t(...label) : label;
74
- var resources = {
75
- [initialLng]: {
76
- [initialNs]: {
77
- "loading translations": "Loading translations\u2026"
78
- }
79
- }
80
- };
81
- void i18Next.use(initReactI18next).init({
82
- resources,
83
- lng: initialLng,
84
- defaultNS: initialNs,
85
- interpolation: {
86
- escapeValue: false
87
- }
88
- });
89
- var TranslationsContext = /* @__PURE__ */ createContext({
90
- appNs: initialNs,
91
- dtLocale: initialDtLocale
92
- });
93
- var useTranslation = (...args) => {
94
- const result = useI18NextTranslation(...args);
95
- const { dtLocale } = useContext4(TranslationsContext);
96
- return {
97
- ...result,
98
- dtLocale
99
- };
100
- };
101
- var TranslationsProvider = ({ fallback, resourceExtensions, children, appNs, dtLocale }) => {
102
- const [loaded, setLoaded] = useState2(false);
103
- useEffect(() => {
104
- setLoaded(false);
105
- if (resourceExtensions && resourceExtensions.length) {
106
- resourceExtensions.forEach((resource) => {
107
- Object.keys(resource).forEach((language) => {
108
- Object.keys(resource[language]).forEach((ns) => {
109
- i18Next.addResourceBundle(language, ns, resource[language][ns]);
110
- });
111
- });
112
- });
113
- }
114
- setLoaded(true);
115
- }, [
116
- resourceExtensions
117
- ]);
118
- return /* @__PURE__ */ React.createElement(TranslationsContext.Provider, {
119
- value: {
120
- appNs: appNs ?? initialNs,
121
- dtLocale: dtLocale ?? initialDtLocale
122
- }
123
- }, /* @__PURE__ */ React.createElement(Suspense, {
124
- fallback
125
- }, loaded ? children : fallback));
126
- };
127
-
128
- // packages/ui/react-ui/src/hooks/useTranslationsContext.ts
129
- var useTranslationsContext = () => useContext5(TranslationsContext);
130
-
131
- // packages/ui/react-ui/src/hooks/useVisualViewport.ts
132
- import { useCallback as useCallback2, useState as useState3 } from "react";
133
- import { useResize as useResize2 } from "@dxos/react-hooks";
134
- var useVisualViewport = (deps) => {
135
- const [width, setWidth] = useState3(null);
136
- const [height, setHeight] = useState3(null);
137
- const handleResize = useCallback2(() => {
138
- if (window.visualViewport) {
139
- setWidth(window.visualViewport.width);
140
- setHeight(window.visualViewport.height);
141
- }
142
- }, []);
143
- useResize2(handleResize);
144
- return {
145
- width,
146
- height
147
- };
148
- };
149
-
150
- // packages/ui/react-ui/src/components/AnchoredOverflow/AnchoredOverflow.tsx
151
- var AnchoredOverflowRoot = /* @__PURE__ */ forwardRef(({ asChild, classNames, children, ...props }, forwardedRef) => {
152
- const { tx } = useThemeContext();
153
- const Root7 = asChild ? Slot : Primitive.div;
154
- return /* @__PURE__ */ React2.createElement(Root7, {
155
- role: "none",
156
- ...props,
157
- className: tx("anchoredOverflow.root", "overflow-anchored", {}, classNames),
158
- ref: forwardedRef
159
- }, children);
160
- });
161
- var AnchoredOverflowAnchor = /* @__PURE__ */ forwardRef(({ asChild, classNames, children, ...props }, forwardedRef) => {
162
- const { tx } = useThemeContext();
163
- const Root7 = asChild ? Slot : Primitive.div;
164
- return /* @__PURE__ */ React2.createElement(Root7, {
165
- role: "none",
166
- ...props,
167
- className: tx("anchoredOverflow.anchor", "overflow-anchor", {}, classNames),
168
- ref: forwardedRef
169
- }, children);
170
- });
171
- var AnchoredOverflow = {
172
- Root: AnchoredOverflowRoot,
173
- Anchor: AnchoredOverflowAnchor
174
- };
175
-
176
- // packages/ui/react-ui/src/components/Avatars/Avatar.tsx
177
- import "@dxos/lit-ui/dx-avatar.pcss";
178
- import { createComponent } from "@lit/react";
179
- import { createContext as createContext2 } from "@radix-ui/react-context";
180
- import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
181
- import { Slot as Slot2 } from "@radix-ui/react-slot";
182
- import React3, { forwardRef as forwardRef2 } from "react";
183
- import { DxAvatar as NaturalDxAvatar } from "@dxos/lit-ui";
184
- import { useId } from "@dxos/react-hooks";
185
- import { mx } from "@dxos/react-ui-theme";
186
- var AVATAR_NAME = "Avatar";
187
- var [AvatarProvider, useAvatarContext] = createContext2(AVATAR_NAME);
188
- var AvatarRoot = ({ children, labelId: propsLabelId, descriptionId: propsDescriptionId }) => {
189
- const labelId = useId("avatar__label", propsLabelId);
190
- const descriptionId = useId("avatar__description", propsDescriptionId);
191
- return /* @__PURE__ */ React3.createElement(AvatarProvider, {
192
- labelId,
193
- descriptionId
194
- }, children);
195
- };
196
- var DxAvatar = createComponent({
197
- tagName: "dx-avatar",
198
- elementClass: NaturalDxAvatar,
199
- react: React3
200
- });
201
- var AvatarContent = /* @__PURE__ */ forwardRef2(({ icon, classNames, ...props }, forwardedRef) => {
202
- const href = useIconHref(icon);
203
- const { labelId, descriptionId } = useAvatarContext("AvatarContent");
204
- return /* @__PURE__ */ React3.createElement(DxAvatar, {
205
- ...props,
206
- icon: href,
207
- "aria-labelledby": labelId,
208
- "aria-describedby": descriptionId,
209
- rootClassName: mx(classNames),
210
- ref: forwardedRef
211
- });
212
- });
213
- var AvatarLabel = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
214
- const Root7 = asChild ? Slot2 : Primitive2.span;
215
- const { tx } = useThemeContext();
216
- const { labelId } = useAvatarContext("AvatarLabel");
217
- return /* @__PURE__ */ React3.createElement(Root7, {
218
- ...props,
219
- id: labelId,
220
- ref: forwardedRef,
221
- className: tx("avatar.label", "avatar__label", {
222
- srOnly
223
- }, classNames)
224
- });
225
- });
226
- var AvatarDescription = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
227
- const Root7 = asChild ? Slot2 : Primitive2.span;
228
- const { tx } = useThemeContext();
229
- const { descriptionId } = useAvatarContext("AvatarDescription");
230
- return /* @__PURE__ */ React3.createElement(Root7, {
231
- ...props,
232
- id: descriptionId,
233
- ref: forwardedRef,
234
- className: tx("avatar.description", "avatar__description", {
235
- srOnly
236
- }, classNames)
237
- });
238
- });
239
- var Avatar = {
240
- Root: AvatarRoot,
241
- Content: AvatarContent,
242
- Label: AvatarLabel,
243
- Description: AvatarDescription
244
- };
245
-
246
- // packages/ui/react-ui/src/components/Breadcrumb/Breadcrumb.tsx
247
- import { Dot } from "@phosphor-icons/react";
248
- import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
249
- import { Slot as Slot4 } from "@radix-ui/react-slot";
250
- import React5, { forwardRef as forwardRef4 } from "react";
251
-
252
- // packages/ui/react-ui/src/components/Link/Link.tsx
253
- import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
254
- import { Slot as Slot3 } from "@radix-ui/react-slot";
255
- import React4, { forwardRef as forwardRef3 } from "react";
256
- var Link = /* @__PURE__ */ forwardRef3(({ asChild, variant, classNames, ...props }, forwardedRef) => {
257
- const { tx } = useThemeContext();
258
- const Root7 = asChild ? Slot3 : Primitive3.a;
259
- return /* @__PURE__ */ React4.createElement(Root7, {
260
- ...props,
261
- className: tx("link.root", "link", {
262
- variant
263
- }, classNames),
264
- ref: forwardedRef
265
- });
266
- });
267
-
268
- // packages/ui/react-ui/src/components/Breadcrumb/Breadcrumb.tsx
269
- var BreadcrumbRoot = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
270
- const { tx } = useThemeContext();
271
- const Root7 = asChild ? Slot4 : Primitive4.div;
272
- return /* @__PURE__ */ React5.createElement(Root7, {
273
- role: "navigation",
274
- ...props,
275
- className: tx("breadcrumb.root", "breadcrumb", {}, classNames),
276
- ref: forwardedRef
277
- });
278
- });
279
- var BreadcrumbList = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
280
- const { tx } = useThemeContext();
281
- const Root7 = asChild ? Slot4 : Primitive4.ol;
282
- return /* @__PURE__ */ React5.createElement(Root7, {
283
- role: "list",
284
- ...props,
285
- className: tx("breadcrumb.list", "breadcrumb__list", {}, classNames),
286
- ref: forwardedRef
287
- });
288
- });
289
- var BreadcrumbListItem = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
290
- const { tx } = useThemeContext();
291
- const Root7 = asChild ? Slot4 : Primitive4.li;
292
- return /* @__PURE__ */ React5.createElement(Root7, {
293
- role: "listitem",
294
- ...props,
295
- className: tx("breadcrumb.listItem", "breadcrumb__list__item", {}, classNames),
296
- ref: forwardedRef
297
- });
298
- });
299
- var BreadcrumbLink = /* @__PURE__ */ forwardRef4(({ asChild, ...props }, forwardedRef) => {
300
- const Root7 = asChild ? Slot4 : Link;
301
- return /* @__PURE__ */ React5.createElement(Root7, {
302
- ...props,
303
- ref: forwardedRef
304
- });
305
- });
306
- var BreadcrumbCurrent = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
307
- const { tx } = useThemeContext();
308
- const Root7 = asChild ? Slot4 : "h1";
309
- return /* @__PURE__ */ React5.createElement(Root7, {
310
- ...props,
311
- "aria-current": "page",
312
- className: tx("breadcrumb.current", "breadcrumb__item__heading--current", {}, classNames),
313
- ref: forwardedRef
314
- });
315
- });
316
- var BreadcrumbSeparator = ({ children, classNames, ...props }) => {
317
- const { tx } = useThemeContext();
318
- return /* @__PURE__ */ React5.createElement(Primitive4.span, {
319
- role: "separator",
320
- "aria-hidden": "true",
321
- ...props,
322
- className: tx("breadcrumb.separator", "breadcrumb__separator", {}, classNames)
323
- }, children ?? /* @__PURE__ */ React5.createElement(Dot, {
324
- weight: "bold"
325
- }));
326
- };
327
- var Breadcrumb = {
328
- Root: BreadcrumbRoot,
329
- List: BreadcrumbList,
330
- ListItem: BreadcrumbListItem,
331
- Link: BreadcrumbLink,
332
- Current: BreadcrumbCurrent,
333
- Separator: BreadcrumbSeparator
334
- };
335
-
336
- // packages/ui/react-ui/src/components/Buttons/Button.tsx
337
- import { createContext as createContext3 } from "@radix-ui/react-context";
338
- import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
339
- import { Slot as Slot5 } from "@radix-ui/react-slot";
340
- import React6, { forwardRef as forwardRef5, memo } from "react";
341
- var BUTTON_GROUP_NAME = "ButtonGroup";
342
- var BUTTON_NAME = "Button";
343
- var [ButtonGroupProvider, useButtonGroupContext] = createContext3(BUTTON_GROUP_NAME, {
344
- inGroup: false
345
- });
346
- var Button = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef5(({ classNames, children, density: propsDensity, elevation: propsElevation, variant = "default", asChild, ...props }, ref) => {
347
- const { inGroup } = useButtonGroupContext(BUTTON_NAME);
348
- const { tx } = useThemeContext();
349
- const elevation = useElevationContext(propsElevation);
350
- const density = useDensityContext(propsDensity);
351
- const Root7 = asChild ? Slot5 : Primitive5.button;
352
- return /* @__PURE__ */ React6.createElement(Root7, {
353
- ref,
354
- ...props,
355
- "data-variant": variant,
356
- "data-density": density,
357
- "data-props": inGroup ? "grouped" : "",
358
- className: tx("button.root", "button", {
359
- variant,
360
- inGroup,
361
- disabled: props.disabled,
362
- density,
363
- elevation
364
- }, classNames),
365
- ...props.disabled && {
366
- disabled: true
367
- }
368
- }, children);
369
- }));
370
- Button.displayName = BUTTON_NAME;
371
- var ButtonGroup = /* @__PURE__ */ forwardRef5(({ children, elevation: propsElevation, classNames, asChild, ...props }, forwardedRef) => {
372
- const { tx } = useThemeContext();
373
- const elevation = useElevationContext(propsElevation);
374
- const Root7 = asChild ? Slot5 : Primitive5.div;
375
- return /* @__PURE__ */ React6.createElement(Root7, {
376
- role: "none",
377
- ...props,
378
- className: tx("button.group", "button-group", {
379
- elevation
380
- }, classNames),
381
- ref: forwardedRef
382
- }, /* @__PURE__ */ React6.createElement(ButtonGroupProvider, {
383
- inGroup: true
384
- }, children));
385
- });
386
- ButtonGroup.displayName = BUTTON_GROUP_NAME;
387
-
388
- // packages/ui/react-ui/src/components/Buttons/IconButton.tsx
389
- import React9, { forwardRef as forwardRef8 } from "react";
390
-
391
- // packages/ui/react-ui/src/components/Icon/Icon.tsx
392
- import React7, { forwardRef as forwardRef6, memo as memo2 } from "react";
393
- var Icon = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef6(({ icon, classNames, size, ...props }, forwardedRef) => {
394
- const { tx } = useThemeContext();
395
- const href = useIconHref(icon);
396
- return /* @__PURE__ */ React7.createElement("svg", {
397
- ...props,
398
- className: tx("icon.root", "icon", {
399
- size
400
- }, classNames),
401
- ref: forwardedRef
402
- }, /* @__PURE__ */ React7.createElement("use", {
403
- href
404
- }));
405
- }));
406
-
407
- // packages/ui/react-ui/src/components/Tooltip/Tooltip.tsx
408
- import { composeEventHandlers } from "@radix-ui/primitive";
409
- import { useComposedRefs } from "@radix-ui/react-compose-refs";
410
- import { createContextScope } from "@radix-ui/react-context";
411
- import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
412
- import { useId as useId2 } from "@radix-ui/react-id";
413
- import * as PopperPrimitive from "@radix-ui/react-popper";
414
- import { createPopperScope } from "@radix-ui/react-popper";
415
- import { Portal as PortalPrimitive } from "@radix-ui/react-portal";
416
- import { Presence } from "@radix-ui/react-presence";
417
- import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
418
- import { Slottable } from "@radix-ui/react-slot";
419
- import { useControllableState } from "@radix-ui/react-use-controllable-state";
420
- import * as VisuallyHiddenPrimitive from "@radix-ui/react-visually-hidden";
421
- import React8, { forwardRef as forwardRef7, useCallback as useCallback3, useEffect as useEffect2, useMemo, useRef, useState as useState4 } from "react";
422
- var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
423
- createPopperScope
424
- ]);
425
- var usePopperScope = createPopperScope();
426
- var DEFAULT_DELAY_DURATION = 700;
427
- var TOOLTIP_OPEN = "tooltip.open";
428
- var TOOLTIP_NAME = "Tooltip";
429
- var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
430
- var TooltipProvider = (props) => {
431
- const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent = false, delayDuration = DEFAULT_DELAY_DURATION, skipDelayDuration = 300 } = props;
432
- const isOpenDelayedRef = useRef(true);
433
- const isPointerInTransitRef = useRef(false);
434
- const skipDelayTimerRef = useRef(0);
435
- useEffect2(() => {
436
- const skipDelayTimer = skipDelayTimerRef.current;
437
- return () => window.clearTimeout(skipDelayTimer);
438
- }, []);
439
- const popperScope = usePopperScope(__scopeTooltip);
440
- const [trigger, setTrigger] = useState4(null);
441
- const [content, setContent] = useState4("");
442
- const [side, setSide] = useState4(void 0);
443
- const triggerRef = useRef(trigger);
444
- const handleTriggerChange = useCallback3((nextTrigger) => {
445
- setTrigger(nextTrigger);
446
- triggerRef.current = nextTrigger;
447
- setContent(nextTrigger?.getAttribute("data-tooltip-content") ?? "");
448
- setSide(nextTrigger?.getAttribute("data-tooltip-side") ?? void 0);
449
- }, []);
450
- const contentId = useId2();
451
- const openTimerRef = useRef(0);
452
- const wasOpenDelayedRef = useRef(false);
453
- const handleOpenChange = useCallback3((open2) => {
454
- if (open2) {
455
- window.clearTimeout(skipDelayTimerRef.current);
456
- isOpenDelayedRef.current = false;
457
- document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
458
- } else {
459
- window.clearTimeout(skipDelayTimerRef.current);
460
- skipDelayTimerRef.current = window.setTimeout(() => isOpenDelayedRef.current = true, skipDelayDuration);
461
- }
462
- onOpenChange?.(open2);
463
- }, [
464
- skipDelayDuration,
465
- onOpenChange
466
- ]);
467
- const [open = false, setOpen] = useControllableState({
468
- prop: openProp,
469
- defaultProp: defaultOpen,
470
- onChange: handleOpenChange
471
- });
472
- const stateAttribute = useMemo(() => {
473
- return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
474
- }, [
475
- open
476
- ]);
477
- const handleOpen = useCallback3(() => {
478
- window.clearTimeout(openTimerRef.current);
479
- openTimerRef.current = 0;
480
- wasOpenDelayedRef.current = false;
481
- setOpen(true);
482
- }, [
483
- setOpen
484
- ]);
485
- const handleClose = useCallback3(() => {
486
- window.clearTimeout(openTimerRef.current);
487
- openTimerRef.current = 0;
488
- setOpen(false);
489
- }, [
490
- setOpen
491
- ]);
492
- const handleDelayedOpen = useCallback3(() => {
493
- window.clearTimeout(openTimerRef.current);
494
- openTimerRef.current = window.setTimeout(() => {
495
- wasOpenDelayedRef.current = true;
496
- setOpen(true);
497
- openTimerRef.current = 0;
498
- }, delayDuration);
499
- }, [
500
- delayDuration,
501
- setOpen
502
- ]);
503
- useEffect2(() => {
504
- return () => {
505
- if (openTimerRef.current) {
506
- window.clearTimeout(openTimerRef.current);
507
- openTimerRef.current = 0;
508
- }
509
- };
510
- }, []);
511
- const { tx } = useThemeContext();
512
- const elevation = useElevationContext();
513
- return /* @__PURE__ */ React8.createElement(PopperPrimitive.Root, popperScope, /* @__PURE__ */ React8.createElement(TooltipContextProvider, {
514
- scope: __scopeTooltip,
515
- contentId,
516
- open,
517
- stateAttribute,
518
- trigger,
519
- onTriggerChange: handleTriggerChange,
520
- onTriggerEnter: useCallback3(() => {
521
- if (isOpenDelayedRef.current) {
522
- handleDelayedOpen();
523
- } else {
524
- handleOpen();
525
- }
526
- }, [
527
- isOpenDelayedRef,
528
- handleDelayedOpen,
529
- handleOpen
530
- ]),
531
- onTriggerLeave: useCallback3(() => {
532
- if (disableHoverableContent) {
533
- handleClose();
534
- } else {
535
- window.clearTimeout(openTimerRef.current);
536
- openTimerRef.current = 0;
537
- }
538
- }, [
539
- handleClose,
540
- disableHoverableContent
541
- ]),
542
- onOpen: handleOpen,
543
- onClose: handleClose,
544
- disableHoverableContent,
545
- isPointerInTransitRef,
546
- onPointerInTransitChange: useCallback3((inTransit) => {
547
- isPointerInTransitRef.current = inTransit;
548
- }, [])
549
- }, /* @__PURE__ */ React8.createElement(TooltipContent, {
550
- side,
551
- className: tx("tooltip.content", "tooltip", {
552
- elevation
553
- })
554
- }, content, /* @__PURE__ */ React8.createElement(TooltipArrow, {
555
- className: tx("tooltip.arrow", "tooltip__arrow")
556
- })), /* @__PURE__ */ React8.createElement(TooltipVirtualTrigger, {
557
- virtualRef: triggerRef
558
- }), children));
559
- };
560
- TooltipProvider.displayName = TOOLTIP_NAME;
561
- var TooltipVirtualTrigger = ({ virtualRef, __scopeTooltip }) => {
562
- const popperScope = usePopperScope(__scopeTooltip);
563
- return /* @__PURE__ */ React8.createElement(PopperPrimitive.Anchor, {
564
- asChild: true,
565
- ...popperScope,
566
- virtualRef
567
- });
568
- };
569
- var TRIGGER_NAME = "TooltipTrigger";
570
- var TooltipTrigger = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
571
- const {
572
- __scopeTooltip,
573
- onInteract,
574
- // TODO(thure): Pass `delayDuration` into the context.
575
- delayDuration: _delayDuration,
576
- suppressNextTooltip,
577
- side,
578
- content,
579
- ...triggerProps
580
- } = props;
581
- const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
582
- const ref = useRef(null);
583
- const composedRefs = useComposedRefs(forwardedRef, ref);
584
- const isPointerDownRef = useRef(false);
585
- const hasPointerMoveOpenedRef = useRef(false);
586
- const handlePointerUp = useCallback3(() => isPointerDownRef.current = false, []);
587
- useEffect2(() => {
588
- return () => document.removeEventListener("pointerup", handlePointerUp);
589
- }, [
590
- handlePointerUp
591
- ]);
592
- return /* @__PURE__ */ React8.createElement(Primitive6.button, {
593
- // We purposefully avoid adding `type=button` here because tooltip triggers are also
594
- // commonly anchors and the anchor `type` attribute signifies MIME type.
595
- "aria-describedby": context.open ? context.contentId : void 0,
596
- "data-state": context.stateAttribute,
597
- "data-tooltip-content": content,
598
- "data-tooltip-side": side,
599
- ...triggerProps,
600
- ref: composedRefs,
601
- onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
602
- if (event.pointerType === "touch") {
603
- return;
604
- }
605
- if (!hasPointerMoveOpenedRef.current && !context.isPointerInTransitRef.current) {
606
- onInteract?.(event);
607
- if (event.defaultPrevented) {
608
- return;
609
- }
610
- context.onTriggerChange(ref.current);
611
- context.onTriggerEnter();
612
- hasPointerMoveOpenedRef.current = true;
613
- }
614
- }),
615
- onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
616
- context.onTriggerLeave();
617
- hasPointerMoveOpenedRef.current = false;
618
- }),
619
- onPointerDown: composeEventHandlers(props.onPointerDown, () => {
620
- if (context.open) {
621
- context.onClose();
622
- }
623
- isPointerDownRef.current = true;
624
- document.addEventListener("pointerup", handlePointerUp, {
625
- once: true
626
- });
627
- }),
628
- onFocus: composeEventHandlers(props.onFocus, (event) => {
629
- if (!isPointerDownRef.current) {
630
- onInteract?.(event);
631
- if (event.defaultPrevented) {
632
- return;
633
- }
634
- if (suppressNextTooltip?.current) {
635
- suppressNextTooltip.current = false;
636
- } else {
637
- context.onTriggerChange(ref.current);
638
- context.onOpen();
639
- }
640
- }
641
- }),
642
- onBlur: composeEventHandlers(props.onBlur, context.onClose),
643
- onClick: composeEventHandlers(props.onClick, context.onClose)
644
- });
645
- });
646
- TooltipTrigger.displayName = TRIGGER_NAME;
647
- var PORTAL_NAME = "TooltipPortal";
648
- var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
649
- forceMount: void 0
650
- });
651
- var TooltipPortal = (props) => {
652
- const { __scopeTooltip, forceMount, children, container } = props;
653
- const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
654
- return /* @__PURE__ */ React8.createElement(PortalProvider, {
655
- scope: __scopeTooltip,
656
- forceMount
657
- }, /* @__PURE__ */ React8.createElement(Presence, {
658
- present: forceMount || context.open
659
- }, /* @__PURE__ */ React8.createElement(PortalPrimitive, {
660
- asChild: true,
661
- container
662
- }, children)));
663
- };
664
- TooltipPortal.displayName = PORTAL_NAME;
665
- var CONTENT_NAME = "TooltipContent";
666
- var TooltipContent = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
667
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
668
- const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
669
- const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
670
- return /* @__PURE__ */ React8.createElement(Presence, {
671
- present: forceMount || context.open
672
- }, context.disableHoverableContent ? /* @__PURE__ */ React8.createElement(TooltipContentImpl, {
673
- side,
674
- ...contentProps,
675
- ref: forwardedRef
676
- }) : /* @__PURE__ */ React8.createElement(TooltipContentHoverable, {
677
- side,
678
- ...contentProps,
679
- ref: forwardedRef
680
- }));
681
- });
682
- var TooltipContentHoverable = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
683
- const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
684
- const ref = useRef(null);
685
- const composedRefs = useComposedRefs(forwardedRef, ref);
686
- const [pointerGraceArea, setPointerGraceArea] = useState4(null);
687
- const { trigger, onClose } = context;
688
- const content = ref.current;
689
- const { onPointerInTransitChange } = context;
690
- const handleRemoveGraceArea = useCallback3(() => {
691
- setPointerGraceArea(null);
692
- onPointerInTransitChange(false);
693
- }, [
694
- onPointerInTransitChange
695
- ]);
696
- const handleCreateGraceArea = useCallback3((event, hoverTarget) => {
697
- const currentTarget = event.currentTarget;
698
- const exitPoint = {
699
- x: event.clientX,
700
- y: event.clientY
701
- };
702
- const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
703
- const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
704
- const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
705
- const graceArea = getHull([
706
- ...paddedExitPoints,
707
- ...hoverTargetPoints
708
- ]);
709
- setPointerGraceArea(graceArea);
710
- onPointerInTransitChange(true);
711
- }, [
712
- onPointerInTransitChange
713
- ]);
714
- useEffect2(() => {
715
- return () => handleRemoveGraceArea();
716
- }, [
717
- handleRemoveGraceArea
718
- ]);
719
- useEffect2(() => {
720
- if (trigger && content) {
721
- const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
722
- const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
723
- trigger.addEventListener("pointerleave", handleTriggerLeave);
724
- content.addEventListener("pointerleave", handleContentLeave);
725
- return () => {
726
- trigger.removeEventListener("pointerleave", handleTriggerLeave);
727
- content.removeEventListener("pointerleave", handleContentLeave);
728
- };
729
- }
730
- }, [
731
- trigger,
732
- content,
733
- handleCreateGraceArea,
734
- handleRemoveGraceArea
735
- ]);
736
- useEffect2(() => {
737
- if (pointerGraceArea) {
738
- const handleTrackPointerGrace = (event) => {
739
- const target = event.target;
740
- const pointerPosition = {
741
- x: event.clientX,
742
- y: event.clientY
743
- };
744
- const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
745
- const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
746
- if (hasEnteredTarget) {
747
- handleRemoveGraceArea();
748
- } else if (isPointerOutsideGraceArea) {
749
- handleRemoveGraceArea();
750
- onClose();
751
- }
752
- };
753
- document.addEventListener("pointermove", handleTrackPointerGrace);
754
- return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
755
- }
756
- }, [
757
- trigger,
758
- content,
759
- pointerGraceArea,
760
- onClose,
761
- handleRemoveGraceArea
762
- ]);
763
- return /* @__PURE__ */ React8.createElement(TooltipContentImpl, {
764
- ...props,
765
- ref: composedRefs
766
- });
767
- });
768
- var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, {
769
- isInside: false
770
- });
771
- var TooltipContentImpl = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
772
- const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
773
- const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
774
- const popperScope = usePopperScope(__scopeTooltip);
775
- const { onClose } = context;
776
- useEffect2(() => {
777
- document.addEventListener(TOOLTIP_OPEN, onClose);
778
- return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
779
- }, [
780
- onClose
781
- ]);
782
- useEffect2(() => {
783
- if (context.trigger) {
784
- const handleScroll = (event) => {
785
- const target = event.target;
786
- if (target?.contains(context.trigger)) {
787
- onClose();
788
- }
789
- };
790
- window.addEventListener("scroll", handleScroll, {
791
- capture: true
792
- });
793
- return () => window.removeEventListener("scroll", handleScroll, {
794
- capture: true
795
- });
796
- }
797
- }, [
798
- context.trigger,
799
- onClose
800
- ]);
801
- return /* @__PURE__ */ React8.createElement(DismissableLayer, {
802
- asChild: true,
803
- disableOutsidePointerEvents: false,
804
- onEscapeKeyDown,
805
- onPointerDownOutside,
806
- onFocusOutside: (event) => event.preventDefault(),
807
- onDismiss: onClose
808
- }, /* @__PURE__ */ React8.createElement(PopperPrimitive.Content, {
809
- "data-state": context.stateAttribute,
810
- ...popperScope,
811
- ...contentProps,
812
- ref: forwardedRef,
813
- style: {
814
- ...contentProps.style,
815
- // re-namespace exposed content custom properties
816
- ...{
817
- "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
818
- "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
819
- "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
820
- "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
821
- "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
822
- }
823
- }
824
- }, /* @__PURE__ */ React8.createElement(Slottable, null, children), /* @__PURE__ */ React8.createElement(VisuallyHiddenContentContextProvider, {
825
- scope: __scopeTooltip,
826
- isInside: true
827
- }, /* @__PURE__ */ React8.createElement(VisuallyHiddenPrimitive.Root, {
828
- id: context.contentId,
829
- role: "tooltip"
830
- }, ariaLabel || children))));
831
- });
832
- TooltipContent.displayName = CONTENT_NAME;
833
- var ARROW_NAME = "TooltipArrow";
834
- var TooltipArrow = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
835
- const { __scopeTooltip, ...arrowProps } = props;
836
- const popperScope = usePopperScope(__scopeTooltip);
837
- const visuallyHiddenContentContext = useVisuallyHiddenContentContext(ARROW_NAME, __scopeTooltip);
838
- return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ React8.createElement(PopperPrimitive.Arrow, {
839
- ...popperScope,
840
- ...arrowProps,
841
- ref: forwardedRef
842
- });
843
- });
844
- TooltipArrow.displayName = ARROW_NAME;
845
- var getExitSideFromRect = (point, rect) => {
846
- const top = Math.abs(rect.top - point.y);
847
- const bottom = Math.abs(rect.bottom - point.y);
848
- const right = Math.abs(rect.right - point.x);
849
- const left = Math.abs(rect.left - point.x);
850
- switch (Math.min(top, bottom, right, left)) {
851
- case left:
852
- return "left";
853
- case right:
854
- return "right";
855
- case top:
856
- return "top";
857
- case bottom:
858
- return "bottom";
859
- default:
860
- throw new Error("unreachable");
861
- }
862
- };
863
- var getPaddedExitPoints = (exitPoint, exitSide, padding = 5) => {
864
- const paddedExitPoints = [];
865
- switch (exitSide) {
866
- case "top":
867
- paddedExitPoints.push({
868
- x: exitPoint.x - padding,
869
- y: exitPoint.y + padding
870
- }, {
871
- x: exitPoint.x + padding,
872
- y: exitPoint.y + padding
873
- });
874
- break;
875
- case "bottom":
876
- paddedExitPoints.push({
877
- x: exitPoint.x - padding,
878
- y: exitPoint.y - padding
879
- }, {
880
- x: exitPoint.x + padding,
881
- y: exitPoint.y - padding
882
- });
883
- break;
884
- case "left":
885
- paddedExitPoints.push({
886
- x: exitPoint.x + padding,
887
- y: exitPoint.y - padding
888
- }, {
889
- x: exitPoint.x + padding,
890
- y: exitPoint.y + padding
891
- });
892
- break;
893
- case "right":
894
- paddedExitPoints.push({
895
- x: exitPoint.x - padding,
896
- y: exitPoint.y - padding
897
- }, {
898
- x: exitPoint.x - padding,
899
- y: exitPoint.y + padding
900
- });
901
- break;
902
- }
903
- return paddedExitPoints;
904
- };
905
- var getPointsFromRect = (rect) => {
906
- const { top, right, bottom, left } = rect;
907
- return [
908
- {
909
- x: left,
910
- y: top
911
- },
912
- {
913
- x: right,
914
- y: top
915
- },
916
- {
917
- x: right,
918
- y: bottom
919
- },
920
- {
921
- x: left,
922
- y: bottom
923
- }
924
- ];
925
- };
926
- var isPointInPolygon = (point, polygon) => {
927
- const { x, y } = point;
928
- let inside = false;
929
- for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
930
- const xi = polygon[i].x;
931
- const yi = polygon[i].y;
932
- const xj = polygon[j].x;
933
- const yj = polygon[j].y;
934
- const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
935
- if (intersect) {
936
- inside = !inside;
937
- }
938
- }
939
- return inside;
940
- };
941
- var getHull = (points) => {
942
- const newPoints = points.slice();
943
- newPoints.sort((a, b) => {
944
- if (a.x < b.x) {
945
- return -1;
946
- } else if (a.x > b.x) {
947
- return 1;
948
- } else if (a.y < b.y) {
949
- return -1;
950
- } else if (a.y > b.y) {
951
- return 1;
952
- } else {
953
- return 0;
954
- }
955
- });
956
- return getHullPresorted(newPoints);
957
- };
958
- var getHullPresorted = (points) => {
959
- if (points.length <= 1) {
960
- return points.slice();
961
- }
962
- const upperHull = [];
963
- for (let i = 0; i < points.length; i++) {
964
- const p = points[i];
965
- while (upperHull.length >= 2) {
966
- const q = upperHull[upperHull.length - 1];
967
- const r = upperHull[upperHull.length - 2];
968
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) {
969
- upperHull.pop();
970
- } else {
971
- break;
972
- }
973
- }
974
- upperHull.push(p);
975
- }
976
- upperHull.pop();
977
- const lowerHull = [];
978
- for (let i = points.length - 1; i >= 0; i--) {
979
- const p = points[i];
980
- while (lowerHull.length >= 2) {
981
- const q = lowerHull[lowerHull.length - 1];
982
- const r = lowerHull[lowerHull.length - 2];
983
- if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) {
984
- lowerHull.pop();
985
- } else {
986
- break;
987
- }
988
- }
989
- lowerHull.push(p);
990
- }
991
- lowerHull.pop();
992
- if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
993
- return upperHull;
994
- } else {
995
- return upperHull.concat(lowerHull);
996
- }
997
- };
998
- var Tooltip = {
999
- Provider: TooltipProvider,
1000
- Trigger: TooltipTrigger
1001
- };
1002
-
1003
- // packages/ui/react-ui/src/components/Buttons/IconButton.tsx
1004
- var IconOnlyButton = /* @__PURE__ */ forwardRef8(({ noTooltip, tooltipPortal = true, tooltipSide, suppressNextTooltip, ...props }, forwardedRef) => {
1005
- if (noTooltip) {
1006
- return /* @__PURE__ */ React9.createElement(LabelledIconButton, {
1007
- ...props,
1008
- ref: forwardedRef
1009
- });
1010
- }
1011
- return /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
1012
- asChild: true,
1013
- content: props.label,
1014
- side: tooltipSide,
1015
- suppressNextTooltip
1016
- }, /* @__PURE__ */ React9.createElement(LabelledIconButton, {
1017
- ...props,
1018
- ref: forwardedRef
1019
- }));
1020
- });
1021
- var LabelledIconButton = /* @__PURE__ */ forwardRef8(({ icon, size, iconOnly, label, classNames, iconClassNames, caretDown, suppressNextTooltip, ...props }, forwardedRef) => {
1022
- const { tx } = useThemeContext();
1023
- return /* @__PURE__ */ React9.createElement(Button, {
1024
- ...props,
1025
- classNames: tx("iconButton.root", "iconButton", {}, classNames),
1026
- ref: forwardedRef
1027
- }, /* @__PURE__ */ React9.createElement(Icon, {
1028
- icon,
1029
- size,
1030
- classNames: iconClassNames
1031
- }), /* @__PURE__ */ React9.createElement("span", {
1032
- className: iconOnly ? "sr-only" : void 0
1033
- }, label), caretDown && /* @__PURE__ */ React9.createElement(Icon, {
1034
- size: 3,
1035
- icon: "ph--caret-down--bold"
1036
- }));
1037
- });
1038
- var IconButton = /* @__PURE__ */ forwardRef8((props, forwardedRef) => props.iconOnly ? /* @__PURE__ */ React9.createElement(IconOnlyButton, {
1039
- ...props,
1040
- ref: forwardedRef
1041
- }) : /* @__PURE__ */ React9.createElement(LabelledIconButton, {
1042
- ...props,
1043
- ref: forwardedRef
1044
- }));
1045
-
1046
- // packages/ui/react-ui/src/components/Buttons/Toggle.tsx
1047
- import { Toggle as TogglePrimitive } from "@radix-ui/react-toggle";
1048
- import React10, { forwardRef as forwardRef9 } from "react";
1049
- var Toggle = /* @__PURE__ */ forwardRef9(({ defaultPressed, pressed, onPressedChange, ...props }, forwardedRef) => {
1050
- return /* @__PURE__ */ React10.createElement(TogglePrimitive, {
1051
- defaultPressed,
1052
- pressed,
1053
- onPressedChange,
1054
- asChild: true
1055
- }, /* @__PURE__ */ React10.createElement(Button, {
1056
- ...props,
1057
- ref: forwardedRef
1058
- }));
1059
- });
1060
-
1061
- // packages/ui/react-ui/src/components/Buttons/ToggleGroup.tsx
1062
- import { ToggleGroup as ToggleGroupPrimitive, ToggleGroupItem as ToggleGroupItemPrimitive } from "@radix-ui/react-toggle-group";
1063
- import React11, { forwardRef as forwardRef10 } from "react";
1064
- var ToggleGroup = /* @__PURE__ */ forwardRef10(({ classNames, children, ...props }, forwardedRef) => {
1065
- return /* @__PURE__ */ React11.createElement(ToggleGroupPrimitive, {
1066
- ...props,
1067
- asChild: true
1068
- }, /* @__PURE__ */ React11.createElement(ButtonGroup, {
1069
- classNames,
1070
- children,
1071
- ref: forwardedRef
1072
- }));
1073
- });
1074
- var ToggleGroupItem = /* @__PURE__ */ forwardRef10(({ variant, elevation, density, classNames, children, ...props }, forwardedRef) => {
1075
- return /* @__PURE__ */ React11.createElement(ToggleGroupItemPrimitive, {
1076
- ...props,
1077
- asChild: true
1078
- }, /* @__PURE__ */ React11.createElement(Button, {
1079
- variant,
1080
- elevation,
1081
- density,
1082
- classNames,
1083
- children,
1084
- ref: forwardedRef
1085
- }));
1086
- });
1087
-
1088
- // packages/ui/react-ui/src/components/Clipboard/ClipboardProvider.tsx
1089
- import React12, { createContext as createContext4, useCallback as useCallback4, useContext as useContext6, useState as useState5 } from "react";
1090
- var ClipboardContext = /* @__PURE__ */ createContext4({
1091
- textValue: "",
1092
- setTextValue: async (_) => {
1093
- }
1094
- });
1095
- var useClipboard = () => useContext6(ClipboardContext);
1096
- var ClipboardProvider = ({ children }) => {
1097
- const [textValue, setInternalTextValue] = useState5("");
1098
- const setTextValue = useCallback4(async (nextValue) => {
1099
- await navigator.clipboard.writeText(nextValue);
1100
- return setInternalTextValue(nextValue);
1101
- }, []);
1102
- return /* @__PURE__ */ React12.createElement(ClipboardContext.Provider, {
1103
- value: {
1104
- textValue,
1105
- setTextValue
1106
- }
1107
- }, children);
1108
- };
1109
-
1110
- // packages/ui/react-ui/src/components/Clipboard/CopyButton.tsx
1111
- import React16 from "react";
1112
- import { mx as mx2 } from "@dxos/react-ui-theme";
1113
-
1114
- // packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
1115
- import { createKeyborg } from "keyborg";
1116
- import React15, { createContext as createContext7, useEffect as useEffect3, useMemo as useMemo2 } from "react";
1117
-
1118
- // packages/ui/react-ui/src/util/hasIosKeyboard.ts
1119
- var hasIosKeyboard = () => {
1120
- return !!navigator.userAgent.match(/iP(ad|od|hone).+Safari/);
1121
- };
1122
-
1123
- // packages/ui/react-ui/src/components/DensityProvider/DensityProvider.tsx
1124
- import React13, { createContext as createContext5 } from "react";
1125
- var DensityContext = /* @__PURE__ */ createContext5({
1126
- density: "fine"
1127
- });
1128
- var DensityProvider = ({ density, children }) => /* @__PURE__ */ React13.createElement(DensityContext.Provider, {
1129
- value: {
1130
- density
1131
- }
1132
- }, children);
1133
-
1134
- // packages/ui/react-ui/src/components/ElevationProvider/ElevationProvider.tsx
1135
- import React14, { createContext as createContext6 } from "react";
1136
- var ElevationContext = /* @__PURE__ */ createContext6({
1137
- elevation: "base"
1138
- });
1139
- var ElevationProvider = ({ elevation, children }) => /* @__PURE__ */ React14.createElement(ElevationContext.Provider, {
1140
- value: {
1141
- elevation
1142
- }
1143
- }, children);
1144
-
1145
- // packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
1146
- var ThemeContext = /* @__PURE__ */ createContext7(void 0);
1147
- var ThemeProvider = ({ children, fallback = null, resourceExtensions, appNs, tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName, themeMode = "dark", rootDensity = "fine", ...rest }) => {
1148
- useEffect3(() => {
1149
- if (document.defaultView) {
1150
- const kb = createKeyborg(document.defaultView);
1151
- kb.subscribe(handleInputModalityChange);
1152
- return () => kb.unsubscribe(handleInputModalityChange);
1153
- }
1154
- }, []);
1155
- const safeAreaPadding = useSafeArea();
1156
- const contextValue = useMemo2(() => ({
1157
- tx,
1158
- themeMode,
1159
- hasIosKeyboard: hasIosKeyboard(),
1160
- safeAreaPadding,
1161
- ...rest
1162
- }), [
1163
- tx,
1164
- themeMode,
1165
- safeAreaPadding,
1166
- rest
1167
- ]);
1168
- return /* @__PURE__ */ React15.createElement(ThemeContext.Provider, {
1169
- value: contextValue
1170
- }, /* @__PURE__ */ React15.createElement(TranslationsProvider, {
1171
- fallback,
1172
- resourceExtensions,
1173
- appNs
1174
- }, /* @__PURE__ */ React15.createElement(ElevationProvider, {
1175
- elevation: "base"
1176
- }, /* @__PURE__ */ React15.createElement(DensityProvider, {
1177
- density: rootDensity
1178
- }, children))));
1179
- };
1180
- var handleInputModalityChange = (isUsingKeyboard) => {
1181
- if (isUsingKeyboard) {
1182
- document.body.setAttribute("data-is-keyboard", "true");
1183
- } else {
1184
- document.body.removeAttribute("data-is-keyboard");
1185
- }
1186
- };
1187
-
1188
- // packages/ui/react-ui/src/components/Clipboard/CopyButton.tsx
1189
- var inactiveLabelStyles = "invisible bs-px -mbe-px overflow-hidden";
1190
- var CopyButton = ({ value, classNames, iconProps, ...props }) => {
1191
- const { t } = useTranslation("os");
1192
- const { textValue, setTextValue } = useClipboard();
1193
- const isCopied = textValue === value;
1194
- return /* @__PURE__ */ React16.createElement(Button, {
1195
- ...props,
1196
- classNames: [
1197
- "inline-flex flex-col justify-center",
1198
- classNames
1199
- ],
1200
- onClick: () => setTextValue(value),
1201
- "data-testid": "copy-invitation"
1202
- }, /* @__PURE__ */ React16.createElement("div", {
1203
- role: "none",
1204
- className: mx2("flex gap-1 items-center", isCopied && inactiveLabelStyles)
1205
- }, /* @__PURE__ */ React16.createElement("span", {
1206
- className: "pli-1"
1207
- }, t("copy label")), /* @__PURE__ */ React16.createElement(Icon, {
1208
- icon: "ph--copy--regular",
1209
- size: 5,
1210
- ...iconProps
1211
- })), /* @__PURE__ */ React16.createElement("div", {
1212
- role: "none",
1213
- className: mx2("flex gap-1 items-center", !isCopied && inactiveLabelStyles)
1214
- }, /* @__PURE__ */ React16.createElement("span", {
1215
- className: "pli-1"
1216
- }, t("copy success label")), /* @__PURE__ */ React16.createElement(Icon, {
1217
- icon: "ph--check--regular",
1218
- size: 5,
1219
- ...iconProps
1220
- })));
1221
- };
1222
- var CopyButtonIconOnly = ({ __scopeTooltip, value, classNames, iconProps, variant, ...props }) => {
1223
- const { t } = useTranslation("os");
1224
- const { textValue, setTextValue } = useClipboard();
1225
- const isCopied = textValue === value;
1226
- const label = isCopied ? t("copy success label") : props.label ?? t("copy label");
1227
- const { onOpen } = useTooltipContext("CopyButton", __scopeTooltip);
1228
- return /* @__PURE__ */ React16.createElement(IconButton, {
1229
- iconOnly: true,
1230
- label,
1231
- icon: "ph--copy--regular",
1232
- size: 5,
1233
- variant,
1234
- classNames: [
1235
- "inline-flex flex-col justify-center",
1236
- classNames
1237
- ],
1238
- onClick: () => setTextValue(value).then(onOpen),
1239
- "data-testid": "copy-invitation"
1240
- });
1241
- };
1242
-
1243
- // packages/ui/react-ui/src/components/Clipboard/index.ts
1244
- var Clipboard = {
1245
- Button: CopyButton,
1246
- IconButton: CopyButtonIconOnly,
1247
- Provider: ClipboardProvider
1248
- };
1249
-
1250
- // packages/ui/react-ui/src/components/Dialogs/Dialog.tsx
1251
- import { createContext as createContext8 } from "@radix-ui/react-context";
1252
- import { Root as DialogRootPrimitive, DialogTrigger as DialogTriggerPrimitive, DialogPortal as DialogPortalPrimitive, DialogOverlay as DialogOverlayPrimitive, DialogTitle as DialogTitlePrimitive, DialogDescription as DialogDescriptionPrimitive, DialogClose as DialogClosePrimitive, DialogContent as DialogContentPrimitive } from "@radix-ui/react-dialog";
1253
- import React17, { forwardRef as forwardRef11 } from "react";
1254
- var DialogRoot = (props) => /* @__PURE__ */ React17.createElement(ElevationProvider, {
1255
- elevation: "dialog"
1256
- }, /* @__PURE__ */ React17.createElement(DialogRootPrimitive, props));
1257
- var DialogTrigger = DialogTriggerPrimitive;
1258
- var DialogPortal = DialogPortalPrimitive;
1259
- var DialogTitle = /* @__PURE__ */ forwardRef11(({ classNames, srOnly, ...props }, forwardedRef) => {
1260
- const { tx } = useThemeContext();
1261
- return /* @__PURE__ */ React17.createElement(DialogTitlePrimitive, {
1262
- ...props,
1263
- className: tx("dialog.title", "dialog__title", {
1264
- srOnly
1265
- }, classNames),
1266
- ref: forwardedRef
1267
- });
1268
- });
1269
- var DialogDescription = /* @__PURE__ */ forwardRef11(({ classNames, srOnly, ...props }, forwardedRef) => {
1270
- const { tx } = useThemeContext();
1271
- return /* @__PURE__ */ React17.createElement(DialogDescriptionPrimitive, {
1272
- ...props,
1273
- className: tx("dialog.description", "dialog__description", {
1274
- srOnly
1275
- }, classNames),
1276
- ref: forwardedRef
1277
- });
1278
- });
1279
- var DialogClose = DialogClosePrimitive;
1280
- var DIALOG_OVERLAY_NAME = "DialogOverlay";
1281
- var DIALOG_CONTENT_NAME = "DialogContent";
1282
- var [OverlayLayoutProvider, useOverlayLayoutContext] = createContext8(DIALOG_OVERLAY_NAME, {});
1283
- var DialogOverlay = /* @__PURE__ */ forwardRef11(({ classNames, children, blockAlign, ...props }, forwardedRef) => {
1284
- const { tx } = useThemeContext();
1285
- return /* @__PURE__ */ React17.createElement(DialogOverlayPrimitive, {
1286
- ...props,
1287
- className: tx("dialog.overlay", "dialog__overlay", {}, classNames),
1288
- ref: forwardedRef,
1289
- "data-block-align": blockAlign
1290
- }, /* @__PURE__ */ React17.createElement(OverlayLayoutProvider, {
1291
- inOverlayLayout: true
1292
- }, children));
1293
- });
1294
- DialogOverlay.displayName = DIALOG_OVERLAY_NAME;
1295
- var DialogContent = /* @__PURE__ */ forwardRef11(({ classNames, children, inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
1296
- const { tx } = useThemeContext();
1297
- const { inOverlayLayout, descriptionId } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
1298
- return /* @__PURE__ */ React17.createElement(DialogContentPrimitive, {
1299
- // NOTE: Radix warning unless set.
1300
- "aria-describedby": descriptionId ?? "unknown",
1301
- ...props,
1302
- className: tx("dialog.content", "dialog", {
1303
- inOverlayLayout: propsInOverlayLayout || inOverlayLayout
1304
- }, classNames),
1305
- ref: forwardedRef
1306
- }, children);
1307
- });
1308
- DialogContent.displayName = DIALOG_CONTENT_NAME;
1309
- var Dialog = {
1310
- Root: DialogRoot,
1311
- Trigger: DialogTrigger,
1312
- Portal: DialogPortal,
1313
- Overlay: DialogOverlay,
1314
- Content: DialogContent,
1315
- Title: DialogTitle,
1316
- Description: DialogDescription,
1317
- Close: DialogClose
1318
- };
1319
-
1320
- // packages/ui/react-ui/src/components/Dialogs/AlertDialog.tsx
1321
- import { Root as AlertDialogRootPrimitive, AlertDialogTrigger as AlertDialogTriggerPrimitive, AlertDialogPortal as AlertDialogPortalPrimitive, AlertDialogOverlay as AlertDialogOverlayPrimitive, AlertDialogTitle as AlertDialogTitlePrimitive, AlertDialogDescription as AlertDialogDescriptionPrimitive, AlertDialogAction as AlertDialogActionPrimitive, AlertDialogCancel as AlertDialogCancelPrimitive, AlertDialogContent as AlertDialogContentPrimitive } from "@radix-ui/react-alert-dialog";
1322
- import { createContext as createContext9 } from "@radix-ui/react-context";
1323
- import React18, { forwardRef as forwardRef12 } from "react";
1324
- var AlertDialogRoot = (props) => /* @__PURE__ */ React18.createElement(ElevationProvider, {
1325
- elevation: "dialog"
1326
- }, /* @__PURE__ */ React18.createElement(AlertDialogRootPrimitive, props));
1327
- var AlertDialogTrigger = AlertDialogTriggerPrimitive;
1328
- var AlertDialogPortal = AlertDialogPortalPrimitive;
1329
- var AlertDialogCancel = AlertDialogCancelPrimitive;
1330
- var AlertDialogAction = AlertDialogActionPrimitive;
1331
- var AlertDialogTitle = /* @__PURE__ */ forwardRef12(({ classNames, srOnly, ...props }, forwardedRef) => {
1332
- const { tx } = useThemeContext();
1333
- return /* @__PURE__ */ React18.createElement(AlertDialogTitlePrimitive, {
1334
- ...props,
1335
- className: tx("dialog.title", "dialog--alert__title", {
1336
- srOnly
1337
- }, classNames),
1338
- ref: forwardedRef
1339
- });
1340
- });
1341
- var AlertDialogDescription = /* @__PURE__ */ forwardRef12(({ classNames, srOnly, ...props }, forwardedRef) => {
1342
- const { tx } = useThemeContext();
1343
- return /* @__PURE__ */ React18.createElement(AlertDialogDescriptionPrimitive, {
1344
- ...props,
1345
- className: tx("dialog.description", "dialog--alert__description", {
1346
- srOnly
1347
- }, classNames),
1348
- ref: forwardedRef
1349
- });
1350
- });
1351
- var ALERT_DIALOG_OVERLAY_NAME = "AlertDialogOverlay";
1352
- var ALERT_DIALOG_CONTENT_NAME = "AlertDialogContent";
1353
- var [OverlayLayoutProvider2, useOverlayLayoutContext2] = createContext9(ALERT_DIALOG_OVERLAY_NAME, {
1354
- inOverlayLayout: false
1355
- });
1356
- var AlertDialogOverlay = /* @__PURE__ */ forwardRef12(({ classNames, children, blockAlign, ...props }, forwardedRef) => {
1357
- const { tx } = useThemeContext();
1358
- return /* @__PURE__ */ React18.createElement(AlertDialogOverlayPrimitive, {
1359
- ...props,
1360
- className: tx("dialog.overlay", "dialog--alert__overlay", {}, classNames, "data-[block-align=start]:justify-center", "data-[block-align=start]:items-start", "data-[block-align=center]:place-content-center"),
1361
- ref: forwardedRef,
1362
- "data-block-align": blockAlign
1363
- }, /* @__PURE__ */ React18.createElement(OverlayLayoutProvider2, {
1364
- inOverlayLayout: true
1365
- }, children));
1366
- });
1367
- AlertDialogOverlay.displayName = ALERT_DIALOG_OVERLAY_NAME;
1368
- var AlertDialogContent = /* @__PURE__ */ forwardRef12(({ classNames, children, ...props }, forwardedRef) => {
1369
- const { tx } = useThemeContext();
1370
- const { inOverlayLayout } = useOverlayLayoutContext2(ALERT_DIALOG_CONTENT_NAME);
1371
- return /* @__PURE__ */ React18.createElement(AlertDialogContentPrimitive, {
1372
- ...props,
1373
- className: tx("dialog.content", "dialog--alert", {
1374
- inOverlayLayout
1375
- }, classNames),
1376
- ref: forwardedRef
1377
- }, children);
1378
- });
1379
- AlertDialogContent.displayName = ALERT_DIALOG_CONTENT_NAME;
1380
- var AlertDialog = {
1381
- Root: AlertDialogRoot,
1382
- Trigger: AlertDialogTrigger,
1383
- Portal: AlertDialogPortal,
1384
- Overlay: AlertDialogOverlay,
1385
- Content: AlertDialogContent,
1386
- Title: AlertDialogTitle,
1387
- Description: AlertDialogDescription,
1388
- Cancel: AlertDialogCancel,
1389
- Action: AlertDialogAction
1390
- };
1391
-
1392
- // packages/ui/react-ui/src/components/Input/Input.tsx
1393
- import { Root as CheckboxPrimitive } from "@radix-ui/react-checkbox";
1394
- import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
1395
- import React19, { forwardRef as forwardRef13, useCallback as useCallback5 } from "react";
1396
- import { InputRoot, PinInput as PinInputPrimitive, TextInput as TextInputPrimitive, TextArea as TextAreaPrimitive, useInputContext, INPUT_NAME, Description as DescriptionPrimitive, DescriptionAndValidation as DescriptionAndValidationPrimitive, Label as LabelPrimitive, Validation as ValidationPrimitive } from "@dxos/react-input";
1397
- import { mx as mx3 } from "@dxos/react-ui-theme";
1398
- var Label = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1399
- const { tx } = useThemeContext();
1400
- return /* @__PURE__ */ React19.createElement(LabelPrimitive, {
1401
- ...props,
1402
- className: tx("input.label", "input__label", {
1403
- srOnly
1404
- }, classNames),
1405
- ref: forwardedRef
1406
- }, children);
1407
- });
1408
- var Description = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1409
- const { tx } = useThemeContext();
1410
- return /* @__PURE__ */ React19.createElement(DescriptionPrimitive, {
1411
- ...props,
1412
- className: tx("input.description", "input__description", {
1413
- srOnly
1414
- }, classNames),
1415
- ref: forwardedRef
1416
- }, children);
1417
- });
1418
- var Validation = /* @__PURE__ */ forwardRef13(({ __inputScope, srOnly, classNames, children, ...props }, forwardedRef) => {
1419
- const { tx } = useThemeContext();
1420
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1421
- return /* @__PURE__ */ React19.createElement(ValidationPrimitive, {
1422
- ...props,
1423
- className: tx("input.validation", `input__validation-message input__validation-message--${validationValence}`, {
1424
- srOnly,
1425
- validationValence
1426
- }, classNames),
1427
- ref: forwardedRef
1428
- }, children);
1429
- });
1430
- var DescriptionAndValidation = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1431
- const { tx } = useThemeContext();
1432
- return /* @__PURE__ */ React19.createElement(DescriptionAndValidationPrimitive, {
1433
- ...props,
1434
- className: tx("input.descriptionAndValidation", "input__description-and-validation", {
1435
- srOnly
1436
- }, classNames),
1437
- ref: forwardedRef
1438
- }, children);
1439
- });
1440
- var PinInput = /* @__PURE__ */ forwardRef13(({ density: propsDensity, elevation: propsElevation, segmentClassName: propsSegmentClassName, inputClassName, variant, ...props }, forwardedRef) => {
1441
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1442
- const { tx } = useThemeContext();
1443
- const density = useDensityContext(propsDensity);
1444
- const elevation = useElevationContext(propsElevation);
1445
- const segmentClassName = useCallback5(({ focused, validationValence }) => tx("input.input", "input--pin-segment", {
1446
- variant: "static",
1447
- focused,
1448
- disabled: props.disabled,
1449
- density,
1450
- elevation,
1451
- validationValence
1452
- }, propsSegmentClassName), [
1453
- tx,
1454
- props.disabled,
1455
- elevation,
1456
- propsElevation,
1457
- density
1458
- ]);
1459
- return /* @__PURE__ */ React19.createElement(PinInputPrimitive, {
1460
- ...props,
1461
- segmentClassName,
1462
- ...props.autoFocus && !hasIosKeyboard2 && {
1463
- autoFocus: true
1464
- },
1465
- inputClassName: tx("input.inputWithSegments", "input input--pin", {
1466
- disabled: props.disabled
1467
- }, inputClassName),
1468
- ref: forwardedRef
1469
- });
1470
- });
1471
- var TextInput = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1472
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1473
- const themeContextValue = useThemeContext();
1474
- const density = useDensityContext(propsDensity);
1475
- const elevation = useElevationContext(propsElevation);
1476
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1477
- const { tx } = themeContextValue;
1478
- return /* @__PURE__ */ React19.createElement(TextInputPrimitive, {
1479
- ...props,
1480
- className: tx("input.input", "input", {
1481
- variant,
1482
- disabled: props.disabled,
1483
- density,
1484
- elevation,
1485
- validationValence
1486
- }, classNames),
1487
- ...props.autoFocus && !hasIosKeyboard2 && {
1488
- autoFocus: true
1489
- },
1490
- ref: forwardedRef
1491
- });
1492
- });
1493
- var TextArea = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1494
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1495
- const { tx } = useThemeContext();
1496
- const density = useDensityContext(propsDensity);
1497
- const elevation = useElevationContext(propsElevation);
1498
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1499
- return /* @__PURE__ */ React19.createElement(TextAreaPrimitive, {
1500
- ...props,
1501
- className: tx("input.input", "input--text-area", {
1502
- variant,
1503
- disabled: props.disabled,
1504
- density,
1505
- elevation,
1506
- validationValence
1507
- }, classNames),
1508
- ...props.autoFocus && !hasIosKeyboard2 && {
1509
- autoFocus: true
1510
- },
1511
- ref: forwardedRef
1512
- });
1513
- });
1514
- var Checkbox = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, size, weight = "bold", classNames, ...props }, forwardedRef) => {
1515
- const [checked, onCheckedChange] = useControllableState2({
1516
- prop: propsChecked,
1517
- defaultProp: propsDefaultChecked,
1518
- onChange: propsOnCheckedChange
1519
- });
1520
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1521
- const { tx } = useThemeContext();
1522
- return /* @__PURE__ */ React19.createElement(CheckboxPrimitive, {
1523
- ...props,
1524
- checked,
1525
- onCheckedChange,
1526
- id,
1527
- "aria-describedby": descriptionId,
1528
- ...validationValence === "error" && {
1529
- "aria-invalid": "true",
1530
- "aria-errormessage": errorMessageId
1531
- },
1532
- className: tx("input.checkbox", "input--checkbox", {
1533
- size
1534
- }, "shrink-0", classNames),
1535
- ref: forwardedRef
1536
- }, /* @__PURE__ */ React19.createElement(Icon, {
1537
- icon: checked === "indeterminate" ? "ph--minus--regular" : "ph--check--regular",
1538
- classNames: tx("input.checkboxIndicator", "input--checkbox__indicator", {
1539
- size,
1540
- checked
1541
- })
1542
- }));
1543
- });
1544
- var Switch = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, classNames, ...props }, forwardedRef) => {
1545
- const [checked, onCheckedChange] = useControllableState2({
1546
- prop: propsChecked,
1547
- defaultProp: propsDefaultChecked ?? false,
1548
- onChange: propsOnCheckedChange
1549
- });
1550
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1551
- return /* @__PURE__ */ React19.createElement("input", {
1552
- type: "checkbox",
1553
- className: mx3("dx-checkbox--switch dx-focus-ring", classNames),
1554
- checked,
1555
- onChange: (event) => {
1556
- onCheckedChange(event.target.checked);
1557
- },
1558
- id,
1559
- "aria-describedby": descriptionId,
1560
- ...props,
1561
- ...validationValence === "error" && {
1562
- "aria-invalid": "true",
1563
- "aria-errormessage": errorMessageId
1564
- },
1565
- ref: forwardedRef
1566
- });
1567
- });
1568
- var Input = {
1569
- Root: InputRoot,
1570
- PinInput,
1571
- TextInput,
1572
- TextArea,
1573
- Checkbox,
1574
- Switch,
1575
- Label,
1576
- Description,
1577
- Validation,
1578
- DescriptionAndValidation
1579
- };
1580
-
1581
- // packages/ui/react-ui/src/components/Lists/List.tsx
1582
- import { CaretDown, CaretRight } from "@phosphor-icons/react";
1583
- import { Slot as Slot6 } from "@radix-ui/react-slot";
1584
- import React21, { forwardRef as forwardRef14 } from "react";
1585
- import { List as ListPrimitive, ListItemHeading as ListPrimitiveItemHeading, ListItemOpenTrigger as ListPrimitiveItemOpenTrigger, ListItemCollapsibleContent, ListItem as ListPrimitiveItem, LIST_NAME, LIST_ITEM_NAME, useListContext, useListItemContext } from "@dxos/react-list";
1586
-
1587
- // packages/ui/react-ui/src/components/Lists/ListDropIndicator.tsx
1588
- import React20 from "react";
1589
- var edgeToOrientationMap = {
1590
- top: "horizontal",
1591
- bottom: "horizontal",
1592
- left: "vertical",
1593
- right: "vertical"
1594
- };
1595
- var orientationStyles = {
1596
- horizontal: "h-[--line-thickness] left-[calc(var(--line-inset)+var(--terminal-radius))] right-[--line-inset] before:left-[--terminal-inset]",
1597
- vertical: "w-[--line-thickness] top-[calc(var(--line-inset)+var(--terminal-radius))] bottom-[--line-inset] before:top-[--terminal-inset]"
1598
- };
1599
- var edgeStyles = {
1600
- top: "top-[--line-offset] before:top-[--offset-terminal]",
1601
- right: "right-[--line-offset] before:right-[--offset-terminal]",
1602
- bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
1603
- left: "left-[--line-offset] before:left-[--offset-terminal]"
1604
- };
1605
- var strokeSize = 2;
1606
- var terminalSize = 8;
1607
- var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
1608
- var ListDropIndicator = ({ edge, gap = 0, lineInset = 0, terminalInset = lineInset - terminalSize }) => {
1609
- const orientation = edgeToOrientationMap[edge];
1610
- return /* @__PURE__ */ React20.createElement("div", {
1611
- role: "none",
1612
- style: {
1613
- "--line-thickness": `${strokeSize}px`,
1614
- "--line-offset": `calc(-0.5 * (${gap}px + ${strokeSize}px))`,
1615
- "--line-inset": `${lineInset}px`,
1616
- "--terminal-size": `${terminalSize}px`,
1617
- "--terminal-radius": `${terminalSize / 2}px`,
1618
- "--terminal-inset": `${terminalInset}px`,
1619
- "--offset-terminal": `${offsetToAlignTerminalWithLine}px`
1620
- },
1621
- className: `absolute z-10 pointer-events-none bg-accentSurface before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles[orientation]} ${edgeStyles[edge]}`
1622
- });
1623
- };
1624
-
1625
- // packages/ui/react-ui/src/components/Lists/List.tsx
1626
- var List = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1627
- const { tx } = useThemeContext();
1628
- const density = useDensityContext(props.density);
1629
- return /* @__PURE__ */ React21.createElement(DensityProvider, {
1630
- density
1631
- }, /* @__PURE__ */ React21.createElement(ListPrimitive, {
1632
- ...props,
1633
- className: tx("list.root", "list", {}, classNames),
1634
- ref: forwardedRef
1635
- }, children));
1636
- });
1637
- var ListItemEndcap = /* @__PURE__ */ forwardRef14(({ children, classNames, asChild, ...props }, forwardedRef) => {
1638
- const Root7 = asChild ? Slot6 : "div";
1639
- const density = useDensityContext();
1640
- const { tx } = useThemeContext();
1641
- return /* @__PURE__ */ React21.createElement(Root7, {
1642
- ...!asChild && {
1643
- role: "none"
1644
- },
1645
- ...props,
1646
- className: tx("list.item.endcap", "list__listItem__endcap", {
1647
- density
1648
- }, classNames),
1649
- ref: forwardedRef
1650
- }, children);
1651
- });
1652
- var MockListItemOpenTrigger = ({ classNames, ...props }) => {
1653
- const density = useDensityContext();
1654
- const { tx } = useThemeContext();
1655
- return /* @__PURE__ */ React21.createElement("div", {
1656
- role: "none",
1657
- ...props,
1658
- className: tx("list.item.openTrigger", "list__listItem__openTrigger--mock", {
1659
- density
1660
- }, classNames)
1661
- });
1662
- };
1663
- var ListItemHeading = /* @__PURE__ */ forwardRef14(({ children, classNames, ...props }, forwardedRef) => {
1664
- const { tx } = useThemeContext();
1665
- const density = useDensityContext();
1666
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemHeading, {
1667
- ...props,
1668
- className: tx("list.item.heading", "list__listItem__heading", {
1669
- density
1670
- }, classNames),
1671
- ref: forwardedRef
1672
- }, children);
1673
- });
1674
- var ListItemOpenTrigger = /* @__PURE__ */ forwardRef14(({ __listItemScope, classNames, children, ...props }, forwardedRef) => {
1675
- const { tx } = useThemeContext();
1676
- const density = useDensityContext();
1677
- const { open } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
1678
- const Icon3 = open ? CaretDown : CaretRight;
1679
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemOpenTrigger, {
1680
- ...props,
1681
- className: tx("list.item.openTrigger", "list__listItem__openTrigger", {
1682
- density
1683
- }, classNames),
1684
- ref: forwardedRef
1685
- }, children || /* @__PURE__ */ React21.createElement(Icon3, {
1686
- weight: "bold",
1687
- className: tx("list.item.openTriggerIcon", "list__listItem__openTrigger__icon", {})
1688
- }));
1689
- });
1690
- var ListItemRoot = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1691
- const { tx } = useThemeContext();
1692
- const density = useDensityContext();
1693
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItem, {
1694
- ...props,
1695
- className: tx("list.item.root", "list__listItem", {
1696
- density,
1697
- collapsible: props.collapsible
1698
- }, classNames),
1699
- ref: forwardedRef
1700
- }, children);
1701
- });
1702
- var ListItem = {
1703
- Root: ListItemRoot,
1704
- Endcap: ListItemEndcap,
1705
- Heading: ListItemHeading,
1706
- OpenTrigger: ListItemOpenTrigger,
1707
- CollapsibleContent: ListItemCollapsibleContent,
1708
- MockOpenTrigger: MockListItemOpenTrigger,
1709
- DropIndicator: ListDropIndicator
1710
- };
1711
-
1712
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1713
- import React23, { forwardRef as forwardRef15 } from "react";
1714
-
1715
- // packages/ui/react-ui/src/components/Lists/TreeDropIndicator.tsx
1716
- import React22 from "react";
1717
- var edgeToOrientationMap2 = {
1718
- "reorder-above": "sibling",
1719
- "reorder-below": "sibling",
1720
- "make-child": "child",
1721
- reparent: "child"
1722
- };
1723
- var orientationStyles2 = {
1724
- // TODO(wittjosiah): Stop using left/right here.
1725
- sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
1726
- child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
1727
- };
1728
- var instructionStyles = {
1729
- "reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
1730
- "reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
1731
- "make-child": "border-accentSurface",
1732
- // TODO(wittjosiah): This is not occurring in the current implementation.
1733
- reparent: ""
1734
- };
1735
- var strokeSize2 = 2;
1736
- var terminalSize2 = 8;
1737
- var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
1738
- var TreeDropIndicator = ({ instruction, gap = 0 }) => {
1739
- const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
1740
- const isBlocked = instruction.type === "instruction-blocked";
1741
- const desiredInstruction = isBlocked ? instruction.desired : instruction;
1742
- const orientation = edgeToOrientationMap2[desiredInstruction.type];
1743
- if (isBlocked) {
1744
- return null;
1745
- }
1746
- return /* @__PURE__ */ React22.createElement("div", {
1747
- style: {
1748
- "--line-thickness": `${strokeSize2}px`,
1749
- "--line-offset": `${lineOffset}`,
1750
- "--terminal-size": `${terminalSize2}px`,
1751
- "--terminal-radius": `${terminalSize2 / 2}px`,
1752
- "--negative-terminal-size": `-${terminalSize2}px`,
1753
- "--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
1754
- "--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
1755
- },
1756
- className: `absolute z-10 pointer-events-none before:is-[--terminal-size] before:bs-[--terminal-size] box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full ${orientationStyles2[orientation]} ${instructionStyles[desiredInstruction.type]}`
1757
- });
1758
- };
1759
-
1760
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1761
- var TreeRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1762
- return /* @__PURE__ */ React23.createElement(List, {
1763
- ...props,
1764
- ref: forwardedRef
1765
- });
1766
- });
1767
- var TreeBranch = /* @__PURE__ */ forwardRef15(({ __listScope, ...props }, forwardedRef) => {
1768
- const { headingId } = useListItemContext(LIST_ITEM_NAME, __listScope);
1769
- return /* @__PURE__ */ React23.createElement(List, {
1770
- ...props,
1771
- "aria-labelledby": headingId,
1772
- ref: forwardedRef
1773
- });
1774
- });
1775
- var TreeItemRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1776
- return /* @__PURE__ */ React23.createElement(ListItem.Root, {
1777
- role: "treeitem",
1778
- ...props,
1779
- ref: forwardedRef
1780
- });
1781
- });
1782
- var TreeItemHeading = ListItem.Heading;
1783
- var TreeItemOpenTrigger = ListItem.OpenTrigger;
1784
- var MockTreeItemOpenTrigger = ListItem.MockOpenTrigger;
1785
- var TreeItemBody = ListItem.CollapsibleContent;
1786
- var Tree = {
1787
- Root: TreeRoot,
1788
- Branch: TreeBranch
1789
- };
1790
- var TreeItem = {
1791
- Root: TreeItemRoot,
1792
- Heading: TreeItemHeading,
1793
- Body: TreeItemBody,
1794
- OpenTrigger: TreeItemOpenTrigger,
1795
- MockOpenTrigger: MockTreeItemOpenTrigger,
1796
- DropIndicator: TreeDropIndicator
1797
- };
1798
-
1799
- // packages/ui/react-ui/src/components/Lists/Treegrid.tsx
1800
- import { useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
1801
- import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
1802
- import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1803
- import { Slot as Slot7 } from "@radix-ui/react-slot";
1804
- import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
1805
- import React24, { forwardRef as forwardRef16 } from "react";
1806
- var TREEGRID_ROW_NAME = "TreegridRow";
1807
- var [createTreegridRowContext, createTreegridRowScope] = createContextScope2(TREEGRID_ROW_NAME, []);
1808
- var [TreegridRowProvider, useTreegridRowContext] = createTreegridRowContext(TREEGRID_ROW_NAME);
1809
- var PATH_SEPARATOR = "~";
1810
- var PARENT_OF_SEPARATOR = " ";
1811
- var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
1812
- const { tx } = useThemeContext();
1813
- const Root7 = asChild ? Slot7 : Primitive7.div;
1814
- const arrowNavigationAttrs = useArrowNavigationGroup({
1815
- axis: "vertical",
1816
- tabbable: false,
1817
- circular: true
1818
- });
1819
- return /* @__PURE__ */ React24.createElement(Root7, {
1820
- role: "treegrid",
1821
- ...arrowNavigationAttrs,
1822
- ...props,
1823
- className: tx("treegrid.root", "treegrid", {}, classNames),
1824
- style: {
1825
- ...style,
1826
- gridTemplateColumns
1827
- },
1828
- ref: forwardedRef
1829
- }, children);
1830
- });
1831
- var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, classNames, children, id, parentOf, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, ...props }, forwardedRef) => {
1832
- const { tx } = useThemeContext();
1833
- const Root7 = asChild ? Slot7 : Primitive7.div;
1834
- const pathParts = id.split(PATH_SEPARATOR);
1835
- const level = pathParts.length - 1;
1836
- const [open, onOpenChange] = useControllableState3({
1837
- prop: propsOpen,
1838
- onChange: propsOnOpenChange,
1839
- defaultProp: defaultOpen
1840
- });
1841
- const focusableGroupAttrs = useFocusableGroup({
1842
- tabBehavior: "limited"
1843
- });
1844
- const arrowGroupAttrs = useArrowNavigationGroup({
1845
- axis: "horizontal",
1846
- tabbable: false,
1847
- circular: false,
1848
- memorizeCurrent: false
1849
- });
1850
- return /* @__PURE__ */ React24.createElement(TreegridRowProvider, {
1851
- open,
1852
- onOpenChange,
1853
- scope: __treegridRowScope
1854
- }, /* @__PURE__ */ React24.createElement(Root7, {
1855
- role: "row",
1856
- "aria-level": level,
1857
- className: tx("treegrid.row", "treegrid__row", {
1858
- level
1859
- }, classNames),
1860
- ...parentOf && {
1861
- "aria-expanded": open,
1862
- "aria-owns": parentOf
1863
- },
1864
- tabIndex: 0,
1865
- ...focusableGroupAttrs,
1866
- ...props,
1867
- id,
1868
- ref: forwardedRef
1869
- }, /* @__PURE__ */ React24.createElement("div", {
1870
- role: "none",
1871
- className: "contents",
1872
- ...arrowGroupAttrs
1873
- }, children)));
1874
- });
1875
- var TreegridCell = /* @__PURE__ */ forwardRef16(({ classNames, children, indent, ...props }, forwardedRef) => {
1876
- const { tx } = useThemeContext();
1877
- return /* @__PURE__ */ React24.createElement("div", {
1878
- role: "gridcell",
1879
- className: tx("treegrid.cell", "treegrid__cell", {
1880
- indent
1881
- }, classNames),
1882
- ...props,
1883
- ref: forwardedRef
1884
- }, children);
1885
- });
1886
- var Treegrid = {
1887
- Root: TreegridRoot,
1888
- Row: TreegridRow,
1889
- Cell: TreegridCell,
1890
- PARENT_OF_SEPARATOR,
1891
- PATH_SEPARATOR,
1892
- createTreegridRowScope,
1893
- useTreegridRowContext
1894
- };
1895
-
1896
- // packages/ui/react-ui/src/components/Main/Main.tsx
1897
- import { createContext as createContext10 } from "@radix-ui/react-context";
1898
- import { Root as DialogRoot2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@radix-ui/react-dialog";
1899
- import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1900
- import { Slot as Slot8 } from "@radix-ui/react-slot";
1901
- import { useControllableState as useControllableState4 } from "@radix-ui/react-use-controllable-state";
1902
- import React25, { forwardRef as forwardRef17, useCallback as useCallback7, useEffect as useEffect5, useRef as useRef2, useState as useState7 } from "react";
1903
- import { log } from "@dxos/log";
1904
- import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
1905
-
1906
- // packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
1907
- import { useCallback as useCallback6, useEffect as useEffect4, useState as useState6 } from "react";
1908
- var MotionState;
1909
- (function(MotionState2) {
1910
- MotionState2[MotionState2["IDLE"] = 0] = "IDLE";
1911
- MotionState2[MotionState2["DEBOUNCING"] = 1] = "DEBOUNCING";
1912
- MotionState2[MotionState2["FOLLOWING"] = 2] = "FOLLOWING";
1913
- })(MotionState || (MotionState = {}));
1914
- var useSwipeToDismiss = (ref, {
1915
- onDismiss,
1916
- dismissThreshold = 64,
1917
- debounceThreshold = 8,
1918
- offset = 0
1919
- /* side = 'inline-start' */
1920
- }) => {
1921
- const $root = ref.current;
1922
- const [motionState, setMotionState] = useState6(0);
1923
- const [gestureStartX, setGestureStartX] = useState6(0);
1924
- const setIdle = useCallback6(() => {
1925
- setMotionState(0);
1926
- $root?.style.removeProperty("inset-inline-start");
1927
- $root?.style.setProperty("transition-duration", "200ms");
1928
- }, [
1929
- $root
1930
- ]);
1931
- const setFollowing = useCallback6(() => {
1932
- setMotionState(2);
1933
- $root?.style.setProperty("transition-duration", "0ms");
1934
- }, [
1935
- $root
1936
- ]);
1937
- const handlePointerDown = useCallback6(({ screenX }) => {
1938
- if (motionState === 0) {
1939
- setMotionState(1);
1940
- setGestureStartX(screenX);
1941
- }
1942
- }, [
1943
- motionState
1944
- ]);
1945
- const handlePointerMove = useCallback6(({ screenX }) => {
1946
- if ($root) {
1947
- const delta = Math.min(screenX - gestureStartX, 0);
1948
- switch (motionState) {
1949
- case 2:
1950
- if (Math.abs(delta) > dismissThreshold) {
1951
- setIdle();
1952
- onDismiss?.();
1953
- } else {
1954
- $root.style.setProperty("inset-inline-start", `${offset + delta}px`);
1955
- }
1956
- break;
1957
- case 1:
1958
- if (Math.abs(delta) > debounceThreshold) {
1959
- setFollowing();
1960
- }
1961
- break;
1962
- }
1963
- }
1964
- }, [
1965
- $root,
1966
- motionState,
1967
- gestureStartX
1968
- ]);
1969
- const handlePointerUp = useCallback6(() => {
1970
- setIdle();
1971
- }, [
1972
- setIdle
1973
- ]);
1974
- useEffect4(() => {
1975
- $root?.addEventListener("pointerdown", handlePointerDown);
1976
- return () => {
1977
- $root?.removeEventListener("pointerdown", handlePointerDown);
1978
- };
1979
- }, [
1980
- $root,
1981
- handlePointerDown
1982
- ]);
1983
- useEffect4(() => {
1984
- $root && document.documentElement.addEventListener("pointermove", handlePointerMove);
1985
- return () => {
1986
- document.documentElement.removeEventListener("pointermove", handlePointerMove);
1987
- };
1988
- }, [
1989
- $root,
1990
- handlePointerMove
1991
- ]);
1992
- useEffect4(() => {
1993
- $root && document.documentElement.addEventListener("pointerup", handlePointerUp);
1994
- return () => {
1995
- document.documentElement.removeEventListener("pointerup", handlePointerUp);
1996
- };
1997
- }, [
1998
- $root,
1999
- handlePointerUp
2000
- ]);
2001
- };
2002
-
2003
- // packages/ui/react-ui/src/components/Main/Main.tsx
2004
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui/src/components/Main/Main.tsx";
2005
- var MAIN_ROOT_NAME = "MainRoot";
2006
- var NAVIGATION_SIDEBAR_NAME = "NavigationSidebar";
2007
- var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
2008
- var MAIN_NAME = "Main";
2009
- var GENERIC_CONSUMER_NAME = "GenericConsumer";
2010
- var landmarkAttr = "data-main-landmark";
2011
- var useLandmarkMover = (propsOnKeyDown, landmark) => {
2012
- const handleKeyDown = useCallback7((event) => {
2013
- const target = event.target;
2014
- if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
2015
- event.preventDefault();
2016
- const landmarks = Array.from(document.querySelectorAll(`[${landmarkAttr}]:not([inert])`)).map((el) => el.hasAttribute(landmarkAttr) ? parseInt(el.getAttribute(landmarkAttr)) : NaN).sort();
2017
- const l = landmarks.length;
2018
- const cursor = landmarks.indexOf(parseInt(target.getAttribute(landmarkAttr)));
2019
- const nextLandmark = landmarks[(cursor + l + (event.getModifierState("Shift") ? -1 : 1)) % l];
2020
- document.querySelector(`[${landmarkAttr}="${nextLandmark}"]`)?.focus();
2021
- }
2022
- propsOnKeyDown?.(event);
2023
- }, [
2024
- propsOnKeyDown
2025
- ]);
2026
- const focusableGroupAttrs = window ? {} : {
2027
- tabBehavior: "limited",
2028
- ignoreDefaultKeydown: {
2029
- Tab: true
2030
- }
2031
- };
2032
- return {
2033
- onKeyDown: handleKeyDown,
2034
- [landmarkAttr]: landmark,
2035
- tabIndex: 0,
2036
- ...focusableGroupAttrs
2037
- };
2038
- };
2039
- var [MainProvider, useMainContext] = createContext10(MAIN_NAME, {
2040
- resizing: false,
2041
- navigationSidebarState: "closed",
2042
- setNavigationSidebarState: (nextState) => {
2043
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
2044
- F: __dxlog_file,
2045
- L: 82,
2046
- S: void 0,
2047
- C: (f, a) => f(...a)
2048
- });
2049
- },
2050
- complementarySidebarState: "closed",
2051
- setComplementarySidebarState: (nextState) => {
2052
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
2053
- F: __dxlog_file,
2054
- L: 87,
2055
- S: void 0,
2056
- C: (f, a) => f(...a)
2057
- });
2058
- }
2059
- });
2060
- var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
2061
- const { setNavigationSidebarState, navigationSidebarState, setComplementarySidebarState, complementarySidebarState } = useMainContext(consumerName);
2062
- return {
2063
- navigationSidebarState,
2064
- setNavigationSidebarState,
2065
- toggleNavigationSidebar: useCallback7(() => setNavigationSidebarState(navigationSidebarState === "expanded" ? "closed" : "expanded"), [
2066
- navigationSidebarState,
2067
- setNavigationSidebarState
2068
- ]),
2069
- openNavigationSidebar: useCallback7(() => setNavigationSidebarState("expanded"), []),
2070
- collapseNavigationSidebar: useCallback7(() => setNavigationSidebarState("collapsed"), []),
2071
- closeNavigationSidebar: useCallback7(() => setNavigationSidebarState("closed"), []),
2072
- complementarySidebarState,
2073
- setComplementarySidebarState,
2074
- toggleComplementarySidebar: useCallback7(() => setComplementarySidebarState(complementarySidebarState === "expanded" ? "closed" : "expanded"), [
2075
- complementarySidebarState,
2076
- setComplementarySidebarState
2077
- ]),
2078
- openComplementarySidebar: useCallback7(() => setComplementarySidebarState("expanded"), []),
2079
- collapseComplementarySidebar: useCallback7(() => setComplementarySidebarState("collapsed"), []),
2080
- closeComplementarySidebar: useCallback7(() => setComplementarySidebarState("closed"), [])
2081
- };
2082
- };
2083
- var resizeDebounce = 3e3;
2084
- var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNavigationSidebarState, onNavigationSidebarStateChange, complementarySidebarState: propsComplementarySidebarState, defaultComplementarySidebarState, onComplementarySidebarStateChange, children, ...props }) => {
2085
- const [isLg] = useMediaQuery("lg", {
2086
- ssr: false
2087
- });
2088
- const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] = useControllableState4({
2089
- prop: propsNavigationSidebarState,
2090
- defaultProp: defaultNavigationSidebarState,
2091
- onChange: onNavigationSidebarStateChange
2092
- });
2093
- const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] = useControllableState4({
2094
- prop: propsComplementarySidebarState,
2095
- defaultProp: defaultComplementarySidebarState,
2096
- onChange: onComplementarySidebarStateChange
2097
- });
2098
- const [resizing, setResizing] = useState7(false);
2099
- const resizeInterval = useRef2(null);
2100
- const handleResize = useCallback7(() => {
2101
- setResizing(true);
2102
- if (resizeInterval.current) {
2103
- clearTimeout(resizeInterval.current);
2104
- }
2105
- resizeInterval.current = setTimeout(() => {
2106
- setResizing(false);
2107
- resizeInterval.current = null;
2108
- }, resizeDebounce);
2109
- }, []);
2110
- useEffect5(() => {
2111
- window.addEventListener("resize", handleResize);
2112
- return () => window.removeEventListener("resize", handleResize);
2113
- }, [
2114
- handleResize
2115
- ]);
2116
- return /* @__PURE__ */ React25.createElement(MainProvider, {
2117
- ...props,
2118
- navigationSidebarState,
2119
- setNavigationSidebarState,
2120
- complementarySidebarState,
2121
- setComplementarySidebarState,
2122
- resizing
2123
- }, children);
2124
- };
2125
- MainRoot.displayName = MAIN_ROOT_NAME;
2126
- var handleOpenAutoFocus = (event) => {
2127
- !document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
2128
- };
2129
- var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToDismiss, onOpenAutoFocus, state, resizing, onStateChange, side, label, ...props }, forwardedRef) => {
2130
- const [isLg] = useMediaQuery("lg", {
2131
- ssr: false
2132
- });
2133
- const { tx } = useThemeContext();
2134
- const { t } = useTranslation();
2135
- const ref = useForwardedRef(forwardedRef);
2136
- const noopRef = useRef2(null);
2137
- useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
2138
- onDismiss: () => onStateChange?.("closed")
2139
- });
2140
- const handleKeyDown = useCallback7((event) => {
2141
- if (event.key === "Escape") {
2142
- event.target.closest("[data-tabster]")?.focus();
2143
- }
2144
- props.onKeyDown?.(event);
2145
- }, [
2146
- props.onKeyDown
2147
- ]);
2148
- const Root7 = isLg ? Primitive8.div : DialogContent2;
2149
- return /* @__PURE__ */ React25.createElement(DialogRoot2, {
2150
- open: state !== "closed",
2151
- "aria-label": toLocalizedString(label, t),
2152
- modal: false
2153
- }, !isLg && /* @__PURE__ */ React25.createElement(DialogTitle2, {
2154
- className: "sr-only"
2155
- }, toLocalizedString(label, t)), /* @__PURE__ */ React25.createElement(Root7, {
2156
- ...!isLg && {
2157
- forceMount: true,
2158
- tabIndex: -1,
2159
- onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus
2160
- },
2161
- ...props,
2162
- "data-side": side === "inline-end" ? "ie" : "is",
2163
- "data-state": state,
2164
- "data-resizing": resizing ? "true" : "false",
2165
- className: tx("main.sidebar", "main__sidebar", {}, classNames),
2166
- onKeyDown: handleKeyDown,
2167
- ...state === "closed" && {
2168
- inert: "true"
2169
- },
2170
- ref
2171
- }, children));
2172
- });
2173
- var MainNavigationSidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
2174
- const { navigationSidebarState, setNavigationSidebarState, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
2175
- const mover = useLandmarkMover(props.onKeyDown, "0");
2176
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
2177
- ...mover,
2178
- ...props,
2179
- state: navigationSidebarState,
2180
- onStateChange: setNavigationSidebarState,
2181
- resizing,
2182
- side: "inline-start",
2183
- ref: forwardedRef
2184
- });
2185
- });
2186
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2187
- var MainComplementarySidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
2188
- const { complementarySidebarState, setComplementarySidebarState, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
2189
- const mover = useLandmarkMover(props.onKeyDown, "2");
2190
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
2191
- ...mover,
2192
- ...props,
2193
- state: complementarySidebarState,
2194
- onStateChange: setComplementarySidebarState,
2195
- resizing,
2196
- side: "inline-end",
2197
- ref: forwardedRef
2198
- });
2199
- });
2200
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2201
- var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
2202
- const { navigationSidebarState, complementarySidebarState } = useMainContext(MAIN_NAME);
2203
- const { tx } = useThemeContext();
2204
- const Root7 = asChild ? Slot8 : role ? "div" : "main";
2205
- const mover = useLandmarkMover(props.onKeyDown, "1");
2206
- return /* @__PURE__ */ React25.createElement(Root7, {
2207
- role,
2208
- ...handlesFocus && {
2209
- ...mover
2210
- },
2211
- ...props,
2212
- "data-sidebar-inline-start-state": navigationSidebarState,
2213
- "data-sidebar-inline-end-state": complementarySidebarState,
2214
- className: tx("main.content", "main", {
2215
- bounce,
2216
- handlesFocus
2217
- }, classNames),
2218
- ref: forwardedRef
2219
- }, children);
2220
- });
2221
- MainContent.displayName = MAIN_NAME;
2222
- var MainOverlay = /* @__PURE__ */ forwardRef17(({ classNames, ...props }, forwardedRef) => {
2223
- const [isLg] = useMediaQuery("lg", {
2224
- ssr: false
2225
- });
2226
- const { navigationSidebarState, setNavigationSidebarState, complementarySidebarState, setComplementarySidebarState } = useMainContext(MAIN_NAME);
2227
- const { tx } = useThemeContext();
2228
- return /* @__PURE__ */ React25.createElement("div", {
2229
- onClick: () => {
2230
- setNavigationSidebarState("collapsed");
2231
- setComplementarySidebarState("collapsed");
2232
- },
2233
- ...props,
2234
- className: tx("main.overlay", "main__overlay", {
2235
- isLg,
2236
- inlineStartSidebarOpen: navigationSidebarState,
2237
- inlineEndSidebarOpen: complementarySidebarState
2238
- }, classNames),
2239
- "data-state": navigationSidebarState === "expanded" || complementarySidebarState === "expanded" ? "open" : "closed",
2240
- "aria-hidden": "true",
2241
- ref: forwardedRef
2242
- });
2243
- });
2244
- var Main = {
2245
- Root: MainRoot,
2246
- Content: MainContent,
2247
- Overlay: MainOverlay,
2248
- NavigationSidebar: MainNavigationSidebar,
2249
- ComplementarySidebar: MainComplementarySidebar
2250
- };
2251
-
2252
- // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
2253
- import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
2254
- import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
2255
- import { Slot as Slot9 } from "@radix-ui/react-slot";
2256
- import React26, { forwardRef as forwardRef18 } from "react";
2257
-
2258
- // packages/ui/react-ui/src/hooks/useSafeCollisionPadding.ts
2259
- import { useMemo as useMemo3 } from "react";
2260
- var propIsNumber = (prop) => Number.isFinite(prop);
2261
- var propsIsRecord = (prop) => !!(prop && typeof prop === "object");
2262
- var safePadding = (propsPadding, safePadding2, side) => {
2263
- return (propIsNumber(safePadding2[side]) ? safePadding2[side] : 0) + (propIsNumber(propsPadding) ? propsPadding : propsIsRecord(propsPadding) ? propsPadding[side] ?? 0 : 0);
2264
- };
2265
- var useSafeCollisionPadding = (collisionPadding) => {
2266
- const { safeAreaPadding } = useThemeContext();
2267
- return useMemo3(() => ({
2268
- top: safePadding(collisionPadding, safeAreaPadding, "top"),
2269
- right: safePadding(collisionPadding, safeAreaPadding, "right"),
2270
- bottom: safePadding(collisionPadding, safeAreaPadding, "bottom"),
2271
- left: safePadding(collisionPadding, safeAreaPadding, "left")
2272
- }), [
2273
- collisionPadding,
2274
- safeAreaPadding
2275
- ]);
2276
- };
2277
-
2278
- // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
2279
- var ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
2280
- var ContextMenuTrigger = ContextMenuPrimitive.Trigger;
2281
- var ContextMenuPortal = ContextMenuPrimitive.Portal;
2282
- var ContextMenuContent = /* @__PURE__ */ forwardRef18(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
2283
- const { tx } = useThemeContext();
2284
- const elevation = useElevationContext();
2285
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
2286
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Content, {
2287
- ...props,
2288
- collisionPadding: safeCollisionPadding,
2289
- className: tx("menu.content", "menu", {
2290
- elevation
2291
- }, classNames),
2292
- ref: forwardedRef
2293
- }, children);
2294
- });
2295
- var ContextMenuViewport = /* @__PURE__ */ forwardRef18(({ classNames, asChild, children, ...props }, forwardedRef) => {
2296
- const { tx } = useThemeContext();
2297
- const Root7 = asChild ? Slot9 : Primitive9.div;
2298
- return /* @__PURE__ */ React26.createElement(Root7, {
2299
- ...props,
2300
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
2301
- ref: forwardedRef
2302
- }, children);
2303
- });
2304
- var ContextMenuArrow = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2305
- const { tx } = useThemeContext();
2306
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Arrow, {
2307
- ...props,
2308
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
2309
- ref: forwardedRef
2310
- });
2311
- });
2312
- var ContextMenuGroup = ContextMenuPrimitive.Group;
2313
- var ContextMenuItemIndicator = ContextMenuPrimitive.ItemIndicator;
2314
- var ContextMenuItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2315
- const { tx } = useThemeContext();
2316
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Item, {
2317
- ...props,
2318
- className: tx("menu.item", "menu__item", {}, classNames),
2319
- ref: forwardedRef
2320
- });
2321
- });
2322
- var ContextMenuCheckboxItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2323
- const { tx } = useThemeContext();
2324
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.CheckboxItem, {
2325
- ...props,
2326
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
2327
- ref: forwardedRef
2328
- });
2329
- });
2330
- var ContextMenuSeparator = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2331
- const { tx } = useThemeContext();
2332
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Separator, {
2333
- ...props,
2334
- className: tx("menu.separator", "menu__item", {}, classNames),
2335
- ref: forwardedRef
2336
- });
2337
- });
2338
- var ContextMenuGroupLabel = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2339
- const { tx } = useThemeContext();
2340
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Label, {
2341
- ...props,
2342
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
2343
- ref: forwardedRef
2344
- });
2345
- });
2346
- var ContextMenu2 = {
2347
- Root: ContextMenuRoot,
2348
- Trigger: ContextMenuTrigger,
2349
- Portal: ContextMenuPortal,
2350
- Content: ContextMenuContent,
2351
- Viewport: ContextMenuViewport,
2352
- Arrow: ContextMenuArrow,
2353
- Group: ContextMenuGroup,
2354
- Item: ContextMenuItem,
2355
- CheckboxItem: ContextMenuCheckboxItem,
2356
- ItemIndicator: ContextMenuItemIndicator,
2357
- Separator: ContextMenuSeparator,
2358
- GroupLabel: ContextMenuGroupLabel
2359
- };
2360
-
2361
- // packages/ui/react-ui/src/components/Menus/DropdownMenu.tsx
2362
- import { composeEventHandlers as composeEventHandlers2 } from "@radix-ui/primitive";
2363
- import { composeRefs } from "@radix-ui/react-compose-refs";
2364
- import { createContextScope as createContextScope3 } from "@radix-ui/react-context";
2365
- import { useId as useId3 } from "@radix-ui/react-id";
2366
- import * as MenuPrimitive from "@radix-ui/react-menu";
2367
- import { createMenuScope } from "@radix-ui/react-menu";
2368
- import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
2369
- import { Slot as Slot10 } from "@radix-ui/react-slot";
2370
- import { useControllableState as useControllableState5 } from "@radix-ui/react-use-controllable-state";
2371
- import React27, { useRef as useRef3, useCallback as useCallback8, forwardRef as forwardRef19, useEffect as useEffect6 } from "react";
2372
- var DROPDOWN_MENU_NAME = "DropdownMenu";
2373
- var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope3(DROPDOWN_MENU_NAME, [
2374
- createMenuScope
2375
- ]);
2376
- var useMenuScope = createMenuScope();
2377
- var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
2378
- var DropdownMenuRoot = (props) => {
2379
- const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
2380
- const menuScope = useMenuScope(__scopeDropdownMenu);
2381
- const triggerRef = useRef3(null);
2382
- const [open = false, setOpen] = useControllableState5({
2383
- prop: openProp,
2384
- defaultProp: defaultOpen,
2385
- onChange: onOpenChange
2386
- });
2387
- return /* @__PURE__ */ React27.createElement(DropdownMenuProvider, {
2388
- scope: __scopeDropdownMenu,
2389
- triggerId: useId3(),
2390
- triggerRef,
2391
- contentId: useId3(),
2392
- open,
2393
- onOpenChange: setOpen,
2394
- onOpenToggle: useCallback8(() => setOpen((prevOpen) => !prevOpen), [
2395
- setOpen
2396
- ]),
2397
- modal
2398
- }, /* @__PURE__ */ React27.createElement(MenuPrimitive.Root, {
2399
- ...menuScope,
2400
- open,
2401
- onOpenChange: setOpen,
2402
- dir,
2403
- modal
2404
- }, children));
2405
- };
2406
- DropdownMenuRoot.displayName = DROPDOWN_MENU_NAME;
2407
- var TRIGGER_NAME2 = "DropdownMenuTrigger";
2408
- var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2409
- const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
2410
- const context = useDropdownMenuContext(TRIGGER_NAME2, __scopeDropdownMenu);
2411
- const menuScope = useMenuScope(__scopeDropdownMenu);
2412
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
2413
- asChild: true,
2414
- ...menuScope
2415
- }, /* @__PURE__ */ React27.createElement(Primitive10.button, {
2416
- type: "button",
2417
- id: context.triggerId,
2418
- "aria-haspopup": "menu",
2419
- "aria-expanded": context.open,
2420
- "aria-controls": context.open ? context.contentId : void 0,
2421
- "data-state": context.open ? "open" : "closed",
2422
- "data-disabled": disabled ? "" : void 0,
2423
- disabled,
2424
- ...triggerProps,
2425
- ref: composeRefs(forwardedRef, context.triggerRef),
2426
- onPointerDown: composeEventHandlers2(props.onPointerDown, (event) => {
2427
- if (!disabled && event.button === 0 && event.ctrlKey === false) {
2428
- context.onOpenToggle();
2429
- if (!context.open) {
2430
- event.preventDefault();
2431
- }
2432
- }
2433
- }),
2434
- onKeyDown: composeEventHandlers2(props.onKeyDown, (event) => {
2435
- if (disabled) {
2436
- return;
2437
- }
2438
- if ([
2439
- "Enter",
2440
- " "
2441
- ].includes(event.key)) {
2442
- context.onOpenToggle();
2443
- }
2444
- if (event.key === "ArrowDown") {
2445
- context.onOpenChange(true);
2446
- }
2447
- if ([
2448
- "Enter",
2449
- " ",
2450
- "ArrowDown"
2451
- ].includes(event.key)) {
2452
- event.preventDefault();
2453
- }
2454
- })
2455
- }));
2456
- });
2457
- DropdownMenuTrigger.displayName = TRIGGER_NAME2;
2458
- var VIRTUAL_TRIGGER_NAME = "DropdownMenuVirtualTrigger";
2459
- var DropdownMenuVirtualTrigger = (props) => {
2460
- const { __scopeDropdownMenu, virtualRef } = props;
2461
- const context = useDropdownMenuContext(VIRTUAL_TRIGGER_NAME, __scopeDropdownMenu);
2462
- const menuScope = useMenuScope(__scopeDropdownMenu);
2463
- useEffect6(() => {
2464
- if (virtualRef.current) {
2465
- context.triggerRef.current = virtualRef.current;
2466
- }
2467
- });
2468
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
2469
- ...menuScope,
2470
- virtualRef
2471
- });
2472
- };
2473
- DropdownMenuVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME;
2474
- var PORTAL_NAME2 = "DropdownMenuPortal";
2475
- var DropdownMenuPortal = (props) => {
2476
- const { __scopeDropdownMenu, ...portalProps } = props;
2477
- const menuScope = useMenuScope(__scopeDropdownMenu);
2478
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Portal, {
2479
- ...menuScope,
2480
- ...portalProps
2481
- });
2482
- };
2483
- DropdownMenuPortal.displayName = PORTAL_NAME2;
2484
- var DropdownMenuViewport = /* @__PURE__ */ forwardRef19(({ classNames, asChild, children, ...props }, forwardedRef) => {
2485
- const { tx } = useThemeContext();
2486
- const Root7 = asChild ? Slot10 : Primitive10.div;
2487
- return /* @__PURE__ */ React27.createElement(Root7, {
2488
- ...props,
2489
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
2490
- ref: forwardedRef
2491
- }, children);
2492
- });
2493
- var CONTENT_NAME2 = "DropdownMenuContent";
2494
- var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2495
- const { __scopeDropdownMenu, classNames, collisionPadding = 8, ...contentProps } = props;
2496
- const { tx } = useThemeContext();
2497
- const context = useDropdownMenuContext(CONTENT_NAME2, __scopeDropdownMenu);
2498
- const elevation = useElevationContext();
2499
- const menuScope = useMenuScope(__scopeDropdownMenu);
2500
- const hasInteractedOutsideRef = useRef3(false);
2501
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
2502
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Content, {
2503
- id: context.contentId,
2504
- "aria-labelledby": context.triggerId,
2505
- ...menuScope,
2506
- ...contentProps,
2507
- collisionPadding: safeCollisionPadding,
2508
- ref: forwardedRef,
2509
- onCloseAutoFocus: composeEventHandlers2(props.onCloseAutoFocus, (event) => {
2510
- if (!hasInteractedOutsideRef.current) {
2511
- context.triggerRef.current?.focus();
2512
- }
2513
- hasInteractedOutsideRef.current = false;
2514
- event.preventDefault();
2515
- }),
2516
- onInteractOutside: composeEventHandlers2(props.onInteractOutside, (event) => {
2517
- const originalEvent = event.detail.originalEvent;
2518
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
2519
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
2520
- if (!context.modal || isRightClick) {
2521
- hasInteractedOutsideRef.current = true;
2522
- }
2523
- }),
2524
- className: tx("menu.content", "menu", {
2525
- elevation
2526
- }, classNames),
2527
- style: {
2528
- ...props.style,
2529
- // re-namespace exposed content custom properties
2530
- ...{
2531
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2532
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2533
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2534
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2535
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2536
- }
2537
- }
2538
- });
2539
- });
2540
- DropdownMenuContent.displayName = CONTENT_NAME2;
2541
- var GROUP_NAME = "DropdownMenuGroup";
2542
- var DropdownMenuGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2543
- const { __scopeDropdownMenu, ...groupProps } = props;
2544
- const menuScope = useMenuScope(__scopeDropdownMenu);
2545
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Group, {
2546
- ...menuScope,
2547
- ...groupProps,
2548
- ref: forwardedRef
2549
- });
2550
- });
2551
- DropdownMenuGroup.displayName = GROUP_NAME;
2552
- var LABEL_NAME = "DropdownMenuLabel";
2553
- var DropdownMenuGroupLabel = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2554
- const { __scopeDropdownMenu, classNames, ...labelProps } = props;
2555
- const menuScope = useMenuScope(__scopeDropdownMenu);
2556
- const { tx } = useThemeContext();
2557
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Label, {
2558
- ...menuScope,
2559
- ...labelProps,
2560
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
2561
- ref: forwardedRef
2562
- });
2563
- });
2564
- DropdownMenuGroupLabel.displayName = LABEL_NAME;
2565
- var ITEM_NAME = "DropdownMenuItem";
2566
- var DropdownMenuItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2567
- const { __scopeDropdownMenu, classNames, ...itemProps } = props;
2568
- const menuScope = useMenuScope(__scopeDropdownMenu);
2569
- const { tx } = useThemeContext();
2570
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Item, {
2571
- ...menuScope,
2572
- ...itemProps,
2573
- className: tx("menu.item", "menu__item", {}, classNames),
2574
- ref: forwardedRef
2575
- });
2576
- });
2577
- DropdownMenuItem.displayName = ITEM_NAME;
2578
- var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
2579
- var DropdownMenuCheckboxItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2580
- const { __scopeDropdownMenu, classNames, ...checkboxItemProps } = props;
2581
- const menuScope = useMenuScope(__scopeDropdownMenu);
2582
- const { tx } = useThemeContext();
2583
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.CheckboxItem, {
2584
- ...menuScope,
2585
- ...checkboxItemProps,
2586
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
2587
- ref: forwardedRef
2588
- });
2589
- });
2590
- DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
2591
- var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
2592
- var DropdownMenuRadioGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2593
- const { __scopeDropdownMenu, ...radioGroupProps } = props;
2594
- const menuScope = useMenuScope(__scopeDropdownMenu);
2595
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioGroup, {
2596
- ...menuScope,
2597
- ...radioGroupProps,
2598
- ref: forwardedRef
2599
- });
2600
- });
2601
- DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
2602
- var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
2603
- var DropdownMenuRadioItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2604
- const { __scopeDropdownMenu, ...radioItemProps } = props;
2605
- const menuScope = useMenuScope(__scopeDropdownMenu);
2606
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioItem, {
2607
- ...menuScope,
2608
- ...radioItemProps,
2609
- ref: forwardedRef
2610
- });
2611
- });
2612
- DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
2613
- var INDICATOR_NAME = "DropdownMenuItemIndicator";
2614
- var DropdownMenuItemIndicator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2615
- const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
2616
- const menuScope = useMenuScope(__scopeDropdownMenu);
2617
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.ItemIndicator, {
2618
- ...menuScope,
2619
- ...itemIndicatorProps,
2620
- ref: forwardedRef
2621
- });
2622
- });
2623
- DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
2624
- var SEPARATOR_NAME = "DropdownMenuSeparator";
2625
- var DropdownMenuSeparator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2626
- const { __scopeDropdownMenu, classNames, ...separatorProps } = props;
2627
- const menuScope = useMenuScope(__scopeDropdownMenu);
2628
- const { tx } = useThemeContext();
2629
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Separator, {
2630
- ...menuScope,
2631
- ...separatorProps,
2632
- className: tx("menu.separator", "menu__item", {}, classNames),
2633
- ref: forwardedRef
2634
- });
2635
- });
2636
- DropdownMenuSeparator.displayName = SEPARATOR_NAME;
2637
- var ARROW_NAME2 = "DropdownMenuArrow";
2638
- var DropdownMenuArrow = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2639
- const { __scopeDropdownMenu, classNames, ...arrowProps } = props;
2640
- const menuScope = useMenuScope(__scopeDropdownMenu);
2641
- const { tx } = useThemeContext();
2642
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Arrow, {
2643
- ...menuScope,
2644
- ...arrowProps,
2645
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
2646
- ref: forwardedRef
2647
- });
2648
- });
2649
- DropdownMenuArrow.displayName = ARROW_NAME2;
2650
- var DropdownMenuSub = (props) => {
2651
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
2652
- const menuScope = useMenuScope(__scopeDropdownMenu);
2653
- const [open = false, setOpen] = useControllableState5({
2654
- prop: openProp,
2655
- defaultProp: defaultOpen,
2656
- onChange: onOpenChange
2657
- });
2658
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Sub, {
2659
- ...menuScope,
2660
- open,
2661
- onOpenChange: setOpen
2662
- }, children);
2663
- };
2664
- var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
2665
- var DropdownMenuSubTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2666
- const { __scopeDropdownMenu, ...subTriggerProps } = props;
2667
- const menuScope = useMenuScope(__scopeDropdownMenu);
2668
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubTrigger, {
2669
- ...menuScope,
2670
- ...subTriggerProps,
2671
- ref: forwardedRef
2672
- });
2673
- });
2674
- DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
2675
- var SUB_CONTENT_NAME = "DropdownMenuSubContent";
2676
- var DropdownMenuSubContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2677
- const { __scopeDropdownMenu, ...subContentProps } = props;
2678
- const menuScope = useMenuScope(__scopeDropdownMenu);
2679
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubContent, {
2680
- ...menuScope,
2681
- ...subContentProps,
2682
- ref: forwardedRef,
2683
- style: {
2684
- ...props.style,
2685
- // re-namespace exposed content custom properties
2686
- ...{
2687
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2688
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2689
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2690
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2691
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2692
- }
2693
- }
2694
- });
2695
- });
2696
- DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
2697
- var DropdownMenu = {
2698
- Root: DropdownMenuRoot,
2699
- Trigger: DropdownMenuTrigger,
2700
- VirtualTrigger: DropdownMenuVirtualTrigger,
2701
- Portal: DropdownMenuPortal,
2702
- Content: DropdownMenuContent,
2703
- Viewport: DropdownMenuViewport,
2704
- Group: DropdownMenuGroup,
2705
- GroupLabel: DropdownMenuGroupLabel,
2706
- Item: DropdownMenuItem,
2707
- CheckboxItem: DropdownMenuCheckboxItem,
2708
- RadioGroup: DropdownMenuRadioGroup,
2709
- RadioItem: DropdownMenuRadioItem,
2710
- ItemIndicator: DropdownMenuItemIndicator,
2711
- Separator: DropdownMenuSeparator,
2712
- Arrow: DropdownMenuArrow,
2713
- Sub: DropdownMenuSub,
2714
- SubTrigger: DropdownMenuSubTrigger,
2715
- SubContent: DropdownMenuSubContent
2716
- };
2717
- var useDropdownMenuMenuScope = useMenuScope;
2718
-
2719
- // packages/ui/react-ui/src/components/Message/Message.tsx
2720
- import { createContext as createContext11 } from "@radix-ui/react-context";
2721
- import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
2722
- import { Slot as Slot11 } from "@radix-ui/react-slot";
2723
- import React28, { forwardRef as forwardRef20 } from "react";
2724
- import { useId as useId4 } from "@dxos/react-hooks";
2725
- var MESSAGE_NAME = "Message";
2726
- var [MessageProvider, useMessageContext] = createContext11(MESSAGE_NAME);
2727
- var MessageRoot = /* @__PURE__ */ forwardRef20(({ asChild, valence, elevation: propsElevation, className, titleId: propsTitleId, descriptionId: propsDescriptionId, children, ...props }, forwardedRef) => {
2728
- const { tx } = useThemeContext();
2729
- const titleId = useId4("message__title", propsTitleId);
2730
- const descriptionId = useId4("message__description", propsDescriptionId);
2731
- const elevation = useElevationContext(propsElevation);
2732
- const Root7 = asChild ? Slot11 : Primitive11.div;
2733
- return /* @__PURE__ */ React28.createElement(MessageProvider, {
2734
- titleId,
2735
- descriptionId
2736
- }, /* @__PURE__ */ React28.createElement(Root7, {
2737
- ...props,
2738
- className: tx("message.root", "message", {
2739
- valence,
2740
- elevation
2741
- }, className),
2742
- "aria-labelledby": titleId,
2743
- "aria-describedby": descriptionId,
2744
- ref: forwardedRef
2745
- }, children));
2746
- });
2747
- MessageRoot.displayName = MESSAGE_NAME;
2748
- var MESSAGE_TITLE_NAME = "MessageTitle";
2749
- var MessageTitle = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
2750
- const { tx } = useThemeContext();
2751
- const { titleId } = useMessageContext(MESSAGE_TITLE_NAME);
2752
- const Root7 = asChild ? Slot11 : Primitive11.h2;
2753
- return /* @__PURE__ */ React28.createElement(Root7, {
2754
- ...props,
2755
- className: tx("message.title", "message__title", {}, className),
2756
- id: titleId,
2757
- ref: forwardedRef
2758
- }, children);
2759
- });
2760
- MessageTitle.displayName = MESSAGE_TITLE_NAME;
2761
- var MESSAGE_BODY_NAME = "MessageBody";
2762
- var MessageBody = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
2763
- const { tx } = useThemeContext();
2764
- const { descriptionId } = useMessageContext(MESSAGE_BODY_NAME);
2765
- const Root7 = asChild ? Slot11 : Primitive11.p;
2766
- return /* @__PURE__ */ React28.createElement(Root7, {
2767
- ...props,
2768
- className: tx("message.body", "message__body", {}, className),
2769
- id: descriptionId,
2770
- ref: forwardedRef
2771
- }, children);
2772
- });
2773
- MessageBody.displayName = MESSAGE_BODY_NAME;
2774
- var Message = {
2775
- Root: MessageRoot,
2776
- Title: MessageTitle,
2777
- Body: MessageBody
2778
- };
2779
-
2780
- // packages/ui/react-ui/src/components/Popover/Popover.tsx
2781
- import { composeEventHandlers as composeEventHandlers3 } from "@radix-ui/primitive";
2782
- import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
2783
- import { createContextScope as createContextScope4 } from "@radix-ui/react-context";
2784
- import { DismissableLayer as DismissableLayer2 } from "@radix-ui/react-dismissable-layer";
2785
- import { useFocusGuards } from "@radix-ui/react-focus-guards";
2786
- import { FocusScope } from "@radix-ui/react-focus-scope";
2787
- import { useId as useId5 } from "@radix-ui/react-id";
2788
- import * as PopperPrimitive2 from "@radix-ui/react-popper";
2789
- import { createPopperScope as createPopperScope2 } from "@radix-ui/react-popper";
2790
- import { Portal as PortalPrimitive2 } from "@radix-ui/react-portal";
2791
- import { Presence as Presence2 } from "@radix-ui/react-presence";
2792
- import { Primitive as Primitive12 } from "@radix-ui/react-primitive";
2793
- import { Slot as Slot12 } from "@radix-ui/react-slot";
2794
- import { useControllableState as useControllableState6 } from "@radix-ui/react-use-controllable-state";
2795
- import { hideOthers } from "aria-hidden";
2796
- import React29, { forwardRef as forwardRef21, useRef as useRef4, useCallback as useCallback9, useState as useState8, useEffect as useEffect7 } from "react";
2797
- import { RemoveScroll } from "react-remove-scroll";
2798
- var POPOVER_NAME = "Popover";
2799
- var [createPopoverContext, createPopoverScope] = createContextScope4(POPOVER_NAME, [
2800
- createPopperScope2
2801
- ]);
2802
- var usePopperScope2 = createPopperScope2();
2803
- var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
2804
- var PopoverRoot = (props) => {
2805
- const { __scopePopover, children, open: openProp, defaultOpen, onOpenChange, modal = false } = props;
2806
- const popperScope = usePopperScope2(__scopePopover);
2807
- const triggerRef = useRef4(null);
2808
- const [hasCustomAnchor, setHasCustomAnchor] = useState8(false);
2809
- const [open = false, setOpen] = useControllableState6({
2810
- prop: openProp,
2811
- defaultProp: defaultOpen,
2812
- onChange: onOpenChange
2813
- });
2814
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Root, popperScope, /* @__PURE__ */ React29.createElement(PopoverProvider, {
2815
- scope: __scopePopover,
2816
- contentId: useId5(),
2817
- triggerRef,
2818
- open,
2819
- onOpenChange: setOpen,
2820
- onOpenToggle: useCallback9(() => setOpen((prevOpen) => !prevOpen), [
2821
- setOpen
2822
- ]),
2823
- hasCustomAnchor,
2824
- onCustomAnchorAdd: useCallback9(() => setHasCustomAnchor(true), []),
2825
- onCustomAnchorRemove: useCallback9(() => setHasCustomAnchor(false), []),
2826
- modal
2827
- }, children));
2828
- };
2829
- PopoverRoot.displayName = POPOVER_NAME;
2830
- var ANCHOR_NAME = "PopoverAnchor";
2831
- var PopoverAnchor = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2832
- const { __scopePopover, ...anchorProps } = props;
2833
- const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
2834
- const popperScope = usePopperScope2(__scopePopover);
2835
- const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
2836
- useEffect7(() => {
2837
- onCustomAnchorAdd();
2838
- return () => onCustomAnchorRemove();
2839
- }, [
2840
- onCustomAnchorAdd,
2841
- onCustomAnchorRemove
2842
- ]);
2843
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2844
- ...popperScope,
2845
- ...anchorProps,
2846
- ref: forwardedRef
2847
- });
2848
- });
2849
- PopoverAnchor.displayName = ANCHOR_NAME;
2850
- var TRIGGER_NAME3 = "PopoverTrigger";
2851
- var PopoverTrigger = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2852
- const { __scopePopover, ...triggerProps } = props;
2853
- const context = usePopoverContext(TRIGGER_NAME3, __scopePopover);
2854
- const popperScope = usePopperScope2(__scopePopover);
2855
- const composedTriggerRef = useComposedRefs2(forwardedRef, context.triggerRef);
2856
- const trigger = /* @__PURE__ */ React29.createElement(Primitive12.button, {
2857
- type: "button",
2858
- "aria-haspopup": "dialog",
2859
- "aria-expanded": context.open,
2860
- "aria-controls": context.contentId,
2861
- "data-state": getState(context.open),
2862
- ...triggerProps,
2863
- ref: composedTriggerRef,
2864
- onClick: composeEventHandlers3(props.onClick, context.onOpenToggle)
2865
- });
2866
- return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2867
- asChild: true,
2868
- ...popperScope
2869
- }, trigger);
2870
- });
2871
- PopoverTrigger.displayName = TRIGGER_NAME3;
2872
- var VIRTUAL_TRIGGER_NAME2 = "PopoverVirtualTrigger";
2873
- var PopoverVirtualTrigger = (props) => {
2874
- const { __scopePopover, virtualRef } = props;
2875
- const context = usePopoverContext(VIRTUAL_TRIGGER_NAME2, __scopePopover);
2876
- const popperScope = usePopperScope2(__scopePopover);
2877
- useEffect7(() => {
2878
- if (virtualRef.current) {
2879
- context.triggerRef.current = virtualRef.current;
2880
- }
2881
- });
2882
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2883
- ...popperScope,
2884
- virtualRef
2885
- });
2886
- };
2887
- PopoverVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME2;
2888
- var PORTAL_NAME3 = "PopoverPortal";
2889
- var [PortalProvider2, usePortalContext2] = createPopoverContext(PORTAL_NAME3, {
2890
- forceMount: void 0
2891
- });
2892
- var PopoverPortal = (props) => {
2893
- const { __scopePopover, forceMount, children, container } = props;
2894
- const context = usePopoverContext(PORTAL_NAME3, __scopePopover);
2895
- return /* @__PURE__ */ React29.createElement(PortalProvider2, {
2896
- scope: __scopePopover,
2897
- forceMount
2898
- }, /* @__PURE__ */ React29.createElement(Presence2, {
2899
- present: forceMount || context.open
2900
- }, /* @__PURE__ */ React29.createElement(PortalPrimitive2, {
2901
- asChild: true,
2902
- container
2903
- }, children)));
2904
- };
2905
- PopoverPortal.displayName = PORTAL_NAME3;
2906
- var CONTENT_NAME3 = "PopoverContent";
2907
- var PopoverContent = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2908
- const portalContext = usePortalContext2(CONTENT_NAME3, props.__scopePopover);
2909
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
2910
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2911
- return /* @__PURE__ */ React29.createElement(Presence2, {
2912
- present: forceMount || context.open
2913
- }, context.modal ? /* @__PURE__ */ React29.createElement(PopoverContentModal, {
2914
- ...contentProps,
2915
- ref: forwardedRef
2916
- }) : /* @__PURE__ */ React29.createElement(PopoverContentNonModal, {
2917
- ...contentProps,
2918
- ref: forwardedRef
2919
- }));
2920
- });
2921
- PopoverContent.displayName = CONTENT_NAME3;
2922
- var PopoverContentModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2923
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2924
- const contentRef = useRef4(null);
2925
- const composedRefs = useComposedRefs2(forwardedRef, contentRef);
2926
- const isRightClickOutsideRef = useRef4(false);
2927
- useEffect7(() => {
2928
- const content = contentRef.current;
2929
- if (content) {
2930
- return hideOthers(content);
2931
- }
2932
- }, []);
2933
- return /* @__PURE__ */ React29.createElement(RemoveScroll, {
2934
- as: Slot12,
2935
- allowPinchZoom: true
2936
- }, /* @__PURE__ */ React29.createElement(PopoverContentImpl, {
2937
- ...props,
2938
- ref: composedRefs,
2939
- // we make sure we're not trapping once it's been closed
2940
- // (closed !== unmounted when animating out)
2941
- trapFocus: context.open,
2942
- disableOutsidePointerEvents: true,
2943
- onCloseAutoFocus: composeEventHandlers3(props.onCloseAutoFocus, (event) => {
2944
- event.preventDefault();
2945
- if (!isRightClickOutsideRef.current) {
2946
- context.triggerRef.current?.focus();
2947
- }
2948
- }),
2949
- onPointerDownOutside: composeEventHandlers3(props.onPointerDownOutside, (event) => {
2950
- const originalEvent = event.detail.originalEvent;
2951
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
2952
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
2953
- isRightClickOutsideRef.current = isRightClick;
2954
- }, {
2955
- checkForDefaultPrevented: false
2956
- }),
2957
- // When focus is trapped, a `focusout` event may still happen.
2958
- // We make sure we don't trigger our `onDismiss` in such case.
2959
- onFocusOutside: composeEventHandlers3(props.onFocusOutside, (event) => event.preventDefault(), {
2960
- checkForDefaultPrevented: false
2961
- })
2962
- }));
2963
- });
2964
- var PopoverContentNonModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2965
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2966
- const hasInteractedOutsideRef = useRef4(false);
2967
- const hasPointerDownOutsideRef = useRef4(false);
2968
- return /* @__PURE__ */ React29.createElement(PopoverContentImpl, {
2969
- ...props,
2970
- ref: forwardedRef,
2971
- trapFocus: false,
2972
- disableOutsidePointerEvents: false,
2973
- onCloseAutoFocus: (event) => {
2974
- props.onCloseAutoFocus?.(event);
2975
- if (!event.defaultPrevented) {
2976
- if (!hasInteractedOutsideRef.current) {
2977
- context.triggerRef.current?.focus();
2978
- }
2979
- event.preventDefault();
2980
- }
2981
- hasInteractedOutsideRef.current = false;
2982
- hasPointerDownOutsideRef.current = false;
2983
- },
2984
- onInteractOutside: (event) => {
2985
- props.onInteractOutside?.(event);
2986
- if (!event.defaultPrevented) {
2987
- hasInteractedOutsideRef.current = true;
2988
- if (event.detail.originalEvent.type === "pointerdown") {
2989
- hasPointerDownOutsideRef.current = true;
2990
- }
2991
- }
2992
- const target = event.target;
2993
- const targetIsTrigger = context.triggerRef.current?.contains(target);
2994
- if (targetIsTrigger) {
2995
- event.preventDefault();
2996
- }
2997
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
2998
- event.preventDefault();
2999
- }
3000
- }
3001
- });
3002
- });
3003
- var PopoverContentImpl = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3004
- const { __scopePopover, trapFocus, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, collisionPadding = 8, classNames, ...contentProps } = props;
3005
- const context = usePopoverContext(CONTENT_NAME3, __scopePopover);
3006
- const popperScope = usePopperScope2(__scopePopover);
3007
- const { tx } = useThemeContext();
3008
- const elevation = useElevationContext();
3009
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
3010
- useFocusGuards();
3011
- return /* @__PURE__ */ React29.createElement(FocusScope, {
3012
- asChild: true,
3013
- loop: true,
3014
- trapped: trapFocus,
3015
- onMountAutoFocus: onOpenAutoFocus,
3016
- onUnmountAutoFocus: onCloseAutoFocus
3017
- }, /* @__PURE__ */ React29.createElement(DismissableLayer2, {
3018
- asChild: true,
3019
- disableOutsidePointerEvents,
3020
- onInteractOutside,
3021
- onEscapeKeyDown,
3022
- onPointerDownOutside,
3023
- onFocusOutside,
3024
- onDismiss: () => context.onOpenChange(false)
3025
- }, /* @__PURE__ */ React29.createElement(PopperPrimitive2.Content, {
3026
- "data-state": getState(context.open),
3027
- role: "dialog",
3028
- id: context.contentId,
3029
- ...popperScope,
3030
- ...contentProps,
3031
- collisionPadding: safeCollisionPadding,
3032
- className: tx("popover.content", "popover", {
3033
- elevation
3034
- }, classNames),
3035
- ref: forwardedRef,
3036
- style: {
3037
- ...contentProps.style,
3038
- // re-namespace exposed content custom properties
3039
- ...{
3040
- "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
3041
- "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
3042
- "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
3043
- "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
3044
- "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
3045
- }
3046
- }
3047
- })));
3048
- });
3049
- var CLOSE_NAME = "PopoverClose";
3050
- var PopoverClose = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3051
- const { __scopePopover, ...closeProps } = props;
3052
- const context = usePopoverContext(CLOSE_NAME, __scopePopover);
3053
- return /* @__PURE__ */ React29.createElement(Primitive12.button, {
3054
- type: "button",
3055
- ...closeProps,
3056
- ref: forwardedRef,
3057
- onClick: composeEventHandlers3(props.onClick, () => context.onOpenChange(false))
3058
- });
3059
- });
3060
- PopoverClose.displayName = CLOSE_NAME;
3061
- var ARROW_NAME3 = "PopoverArrow";
3062
- var PopoverArrow = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3063
- const { __scopePopover, classNames, ...arrowProps } = props;
3064
- const popperScope = usePopperScope2(__scopePopover);
3065
- const { tx } = useThemeContext();
3066
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Arrow, {
3067
- ...popperScope,
3068
- ...arrowProps,
3069
- className: tx("popover.arrow", "popover__arrow", {}, classNames),
3070
- ref: forwardedRef
3071
- });
3072
- });
3073
- PopoverArrow.displayName = ARROW_NAME3;
3074
- var PopoverViewport = /* @__PURE__ */ forwardRef21(({ classNames, asChild, constrainInline = true, constrainBlock = true, children, ...props }, forwardedRef) => {
3075
- const { tx } = useThemeContext();
3076
- const Root7 = asChild ? Slot12 : Primitive12.div;
3077
- return /* @__PURE__ */ React29.createElement(Root7, {
3078
- ...props,
3079
- className: tx("popover.viewport", "popover__viewport", {
3080
- constrainInline,
3081
- constrainBlock
3082
- }, classNames),
3083
- ref: forwardedRef
3084
- }, children);
3085
- });
3086
- var getState = (open) => open ? "open" : "closed";
3087
- var Popover = {
3088
- Root: PopoverRoot,
3089
- Anchor: PopoverAnchor,
3090
- Trigger: PopoverTrigger,
3091
- VirtualTrigger: PopoverVirtualTrigger,
3092
- Portal: PopoverPortal,
3093
- Content: PopoverContent,
3094
- Close: PopoverClose,
3095
- Arrow: PopoverArrow,
3096
- Viewport: PopoverViewport
3097
- };
3098
-
3099
- // packages/ui/react-ui/src/components/Status/Status.tsx
3100
- import React30, { forwardRef as forwardRef22 } from "react";
3101
- var Status = /* @__PURE__ */ forwardRef22(({ classNames, children, progress = 0, indeterminate, variant, ...props }, forwardedRef) => {
3102
- const { tx } = useThemeContext();
3103
- return /* @__PURE__ */ React30.createElement("span", {
3104
- role: "status",
3105
- ...props,
3106
- className: tx("status.root", "status", {
3107
- indeterminate,
3108
- variant
3109
- }, classNames),
3110
- ref: forwardedRef
3111
- }, /* @__PURE__ */ React30.createElement("span", {
3112
- role: "none",
3113
- className: tx("status.bar", "status__bar", {
3114
- indeterminate,
3115
- variant
3116
- }, classNames),
3117
- ...!indeterminate && {
3118
- style: {
3119
- width: `${Math.round(progress * 100)}%`
3120
- }
3121
- }
3122
- }), children);
3123
- });
3124
-
3125
- // packages/ui/react-ui/src/components/ScrollArea/ScrollArea.tsx
3126
- import { Root as ScrollAreaPrimitiveRoot, Viewport as ScrollAreaPrimitiveViewport, Scrollbar as ScrollAreaPrimitiveScrollbar, Thumb as ScrollAreaPrimitiveThumb, Corner as ScrollAreaPrimitiveCorner } from "@radix-ui/react-scroll-area";
3127
- import React31, { forwardRef as forwardRef23 } from "react";
3128
- var ScrollAreaRoot = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3129
- const { tx } = useThemeContext();
3130
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveRoot, {
3131
- ...props,
3132
- className: tx("scrollArea.root", "scroll-area", {}, classNames),
3133
- ref: forwardedRef
3134
- });
3135
- });
3136
- var ScrollAreaViewport = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3137
- const { tx } = useThemeContext();
3138
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveViewport, {
3139
- ...props,
3140
- className: tx("scrollArea.viewport", "scroll-area", {}, classNames),
3141
- ref: forwardedRef
3142
- });
3143
- });
3144
- var ScrollAreaScrollbar = /* @__PURE__ */ forwardRef23(({ classNames, variant = "fine", ...props }, forwardedRef) => {
3145
- const { tx } = useThemeContext();
3146
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveScrollbar, {
3147
- "data-variant": variant,
3148
- ...props,
3149
- className: tx("scrollArea.scrollbar", "scroll-area__scrollbar", {}, classNames),
3150
- ref: forwardedRef
3151
- });
3152
- });
3153
- var ScrollAreaThumb = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3154
- const { tx } = useThemeContext();
3155
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveThumb, {
3156
- ...props,
3157
- className: tx("scrollArea.thumb", "scroll-area__thumb", {}, classNames),
3158
- ref: forwardedRef
3159
- });
3160
- });
3161
- var ScrollAreaCorner = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3162
- const { tx } = useThemeContext();
3163
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveCorner, {
3164
- ...props,
3165
- className: tx("scrollArea.corner", "scroll-area__corner", {}, classNames),
3166
- ref: forwardedRef
3167
- });
3168
- });
3169
- var ScrollArea = {
3170
- Root: ScrollAreaRoot,
3171
- Viewport: ScrollAreaViewport,
3172
- Scrollbar: ScrollAreaScrollbar,
3173
- Thumb: ScrollAreaThumb,
3174
- Corner: ScrollAreaCorner
3175
- };
3176
-
3177
- // packages/ui/react-ui/src/components/Select/Select.tsx
3178
- import { CaretDown as CaretDown2, CaretUp } from "@phosphor-icons/react";
3179
- import * as SelectPrimitive from "@radix-ui/react-select";
3180
- import React32, { forwardRef as forwardRef24 } from "react";
3181
- var SelectRoot = SelectPrimitive.Root;
3182
- var SelectTrigger = SelectPrimitive.Trigger;
3183
- var SelectValue = SelectPrimitive.Value;
3184
- var SelectIcon = SelectPrimitive.Icon;
3185
- var SelectPortal = SelectPrimitive.Portal;
3186
- var SelectTriggerButton = /* @__PURE__ */ forwardRef24(({ children, placeholder, ...props }, forwardedRef) => {
3187
- const { tx } = useThemeContext();
3188
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Trigger, {
3189
- asChild: true,
3190
- ref: forwardedRef
3191
- }, /* @__PURE__ */ React32.createElement(Button, props, /* @__PURE__ */ React32.createElement(SelectPrimitive.Value, {
3192
- placeholder
3193
- }, children), /* @__PURE__ */ React32.createElement("span", {
3194
- className: "w-1 flex-1"
3195
- }), /* @__PURE__ */ React32.createElement(SelectPrimitive.Icon, {
3196
- asChild: true
3197
- }, /* @__PURE__ */ React32.createElement(CaretDown2, {
3198
- className: tx("select.triggerIcon", "select__trigger__icon", {}),
3199
- weight: "bold"
3200
- }))));
3201
- });
3202
- var SelectContent = /* @__PURE__ */ forwardRef24(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
3203
- const { tx } = useThemeContext();
3204
- const elevation = useElevationContext();
3205
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
3206
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Content, {
3207
- ...props,
3208
- collisionPadding: safeCollisionPadding,
3209
- className: tx("select.content", "select__content", {
3210
- elevation
3211
- }, classNames),
3212
- position: "popper",
3213
- ref: forwardedRef
3214
- }, children);
3215
- });
3216
- var SelectScrollUpButton2 = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3217
- const { tx } = useThemeContext();
3218
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectScrollUpButton, {
3219
- ...props,
3220
- className: tx("select.scrollButton", "select__scroll-button--up", {}, classNames),
3221
- ref: forwardedRef
3222
- }, children ?? /* @__PURE__ */ React32.createElement(CaretUp, {
3223
- weight: "bold"
3224
- }));
3225
- });
3226
- var SelectScrollDownButton2 = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3227
- const { tx } = useThemeContext();
3228
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectScrollDownButton, {
3229
- ...props,
3230
- className: tx("select.scrollButton", "select__scroll-button--down", {}, classNames),
3231
- ref: forwardedRef
3232
- }, children ?? /* @__PURE__ */ React32.createElement(CaretDown2, {
3233
- weight: "bold"
3234
- }));
3235
- });
3236
- var SelectViewport2 = /* @__PURE__ */ forwardRef24(({ classNames, asChild, children, ...props }, forwardedRef) => {
3237
- const { tx } = useThemeContext();
3238
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectViewport, {
3239
- ...props,
3240
- className: tx("select.viewport", "select__viewport", {}, classNames),
3241
- ref: forwardedRef
3242
- }, children);
3243
- });
3244
- var SelectItem = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3245
- const { tx } = useThemeContext();
3246
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Item, {
3247
- ...props,
3248
- className: tx("select.item", "option", {}, classNames),
3249
- ref: forwardedRef
3250
- });
3251
- });
3252
- var SelectItemText = SelectPrimitive.ItemText;
3253
- var SelectItemIndicator = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3254
- const { tx } = useThemeContext();
3255
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.ItemIndicator, {
3256
- ...props,
3257
- className: tx("select.itemIndicator", "option__indicator", {}, classNames),
3258
- ref: forwardedRef
3259
- }, children);
3260
- });
3261
- var SelectOption = /* @__PURE__ */ forwardRef24(({ children, classNames, ...props }, forwardedRef) => {
3262
- const { tx } = useThemeContext();
3263
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Item, {
3264
- ...props,
3265
- className: tx("select.item", "option", {}, classNames),
3266
- ref: forwardedRef
3267
- }, /* @__PURE__ */ React32.createElement(SelectPrimitive.ItemText, null, children), /* @__PURE__ */ React32.createElement("span", {
3268
- className: "grow w-1"
3269
- }), /* @__PURE__ */ React32.createElement(Icon, {
3270
- icon: "ph--check--regular"
3271
- }));
3272
- });
3273
- var SelectGroup = SelectPrimitive.Group;
3274
- var SelectLabel = SelectPrimitive.Label;
3275
- var SelectSeparator = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3276
- const { tx } = useThemeContext();
3277
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Separator, {
3278
- ...props,
3279
- className: tx("select.separator", "select__separator", {}, classNames),
3280
- ref: forwardedRef
3281
- });
3282
- });
3283
- var SelectArrow = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3284
- const { tx } = useThemeContext();
3285
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Arrow, {
3286
- ...props,
3287
- className: tx("select.arrow", "select__arrow", {}, classNames),
3288
- ref: forwardedRef
3289
- });
3290
- });
3291
- var Select = {
3292
- Root: SelectRoot,
3293
- Trigger: SelectTrigger,
3294
- TriggerButton: SelectTriggerButton,
3295
- Value: SelectValue,
3296
- Icon: SelectIcon,
3297
- Portal: SelectPortal,
3298
- Content: SelectContent,
3299
- ScrollUpButton: SelectScrollUpButton2,
3300
- ScrollDownButton: SelectScrollDownButton2,
3301
- Viewport: SelectViewport2,
3302
- Item: SelectItem,
3303
- ItemText: SelectItemText,
3304
- ItemIndicator: SelectItemIndicator,
3305
- Option: SelectOption,
3306
- Group: SelectGroup,
3307
- Label: SelectLabel,
3308
- Separator: SelectSeparator,
3309
- Arrow: SelectArrow
3310
- };
3311
-
3312
- // packages/ui/react-ui/src/components/Separator/Separator.tsx
3313
- import { Separator as SeparatorPrimitive } from "@radix-ui/react-separator";
3314
- import React33, { forwardRef as forwardRef25 } from "react";
3315
- var Separator4 = /* @__PURE__ */ forwardRef25(({ classNames, orientation = "horizontal", ...props }, forwardedRef) => {
3316
- const { tx } = useThemeContext();
3317
- return /* @__PURE__ */ React33.createElement(SeparatorPrimitive, {
3318
- orientation,
3319
- ...props,
3320
- className: tx("separator.root", "separator", {
3321
- orientation
3322
- }, classNames),
3323
- ref: forwardedRef
3324
- });
3325
- });
3326
-
3327
- // packages/ui/react-ui/src/components/Tag/Tag.tsx
3328
- import { Primitive as Primitive13 } from "@radix-ui/react-primitive";
3329
- import { Slot as Slot13 } from "@radix-ui/react-slot";
3330
- import React34, { forwardRef as forwardRef26 } from "react";
3331
- var Tag = /* @__PURE__ */ forwardRef26(({ asChild, palette = "neutral", classNames, ...props }, forwardedRef) => {
3332
- const { tx } = useThemeContext();
3333
- const Root7 = asChild ? Slot13 : Primitive13.span;
3334
- return /* @__PURE__ */ React34.createElement(Root7, {
3335
- ...props,
3336
- className: tx("tag.root", "dx-tag", {
3337
- palette
3338
- }, classNames),
3339
- "data-hue": palette,
3340
- ref: forwardedRef
3341
- });
3342
- });
3343
-
3344
- // packages/ui/react-ui/src/components/Toast/Toast.tsx
3345
- import { Primitive as Primitive14 } from "@radix-ui/react-primitive";
3346
- import { Slot as Slot14 } from "@radix-ui/react-slot";
3347
- import { ToastProvider as ToastProviderPrimitive, ToastViewport as ToastViewportPrimitive, Root as ToastRootPrimitive, ToastTitle as ToastTitlePrimitive, ToastDescription as ToastDescriptionPrimitive, ToastAction as ToastActionPrimitive, ToastClose as ToastClosePrimitive } from "@radix-ui/react-toast";
3348
- import React35, { forwardRef as forwardRef27 } from "react";
3349
- var ToastProvider = ToastProviderPrimitive;
3350
- var ToastViewport = /* @__PURE__ */ forwardRef27(({ classNames, ...props }, forwardedRef) => {
3351
- const { tx } = useThemeContext();
3352
- return /* @__PURE__ */ React35.createElement(ToastViewportPrimitive, {
3353
- className: tx("toast.viewport", "toast-viewport", {}, classNames),
3354
- ref: forwardedRef
3355
- });
3356
- });
3357
- var ToastRoot = /* @__PURE__ */ forwardRef27(({ classNames, children, ...props }, forwardedRef) => {
3358
- const { tx } = useThemeContext();
3359
- return /* @__PURE__ */ React35.createElement(ToastRootPrimitive, {
3360
- ...props,
3361
- className: tx("toast.root", "toast", {}, classNames),
3362
- ref: forwardedRef
3363
- }, /* @__PURE__ */ React35.createElement(ElevationProvider, {
3364
- elevation: "toast"
3365
- }, children));
3366
- });
3367
- var ToastBody = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3368
- const { tx } = useThemeContext();
3369
- const Root7 = asChild ? Slot14 : Primitive14.div;
3370
- return /* @__PURE__ */ React35.createElement(Root7, {
3371
- ...props,
3372
- className: tx("toast.body", "toast__body", {}, classNames),
3373
- ref: forwardedRef
3374
- });
3375
- });
3376
- var ToastTitle = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3377
- const { tx } = useThemeContext();
3378
- const Root7 = asChild ? Slot14 : ToastTitlePrimitive;
3379
- return /* @__PURE__ */ React35.createElement(Root7, {
3380
- ...props,
3381
- className: tx("toast.title", "toast__title", {}, classNames),
3382
- ref: forwardedRef
3383
- });
3384
- });
3385
- var ToastDescription = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3386
- const { tx } = useThemeContext();
3387
- const Root7 = asChild ? Slot14 : ToastDescriptionPrimitive;
3388
- return /* @__PURE__ */ React35.createElement(Root7, {
3389
- ...props,
3390
- className: tx("toast.description", "toast__description", {}, classNames),
3391
- ref: forwardedRef
3392
- });
3393
- });
3394
- var ToastActions = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3395
- const { tx } = useThemeContext();
3396
- const Root7 = asChild ? Slot14 : Primitive14.div;
3397
- return /* @__PURE__ */ React35.createElement(Root7, {
3398
- ...props,
3399
- className: tx("toast.actions", "toast__actions", {}, classNames),
3400
- ref: forwardedRef
3401
- });
3402
- });
3403
- var ToastAction = ToastActionPrimitive;
3404
- var ToastClose = ToastClosePrimitive;
3405
- var Toast = {
3406
- Provider: ToastProvider,
3407
- Viewport: ToastViewport,
3408
- Root: ToastRoot,
3409
- Body: ToastBody,
3410
- Title: ToastTitle,
3411
- Description: ToastDescription,
3412
- Actions: ToastActions,
3413
- Action: ToastAction,
3414
- Close: ToastClose
3415
- };
3416
-
3417
- // packages/ui/react-ui/src/components/Toolbar/Toolbar.tsx
3418
- import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
3419
- import React36, { forwardRef as forwardRef28 } from "react";
3420
- var ToolbarRoot = /* @__PURE__ */ forwardRef28(({ classNames, children, ...props }, forwardedRef) => {
3421
- const { tx } = useThemeContext();
3422
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Root, {
3423
- ...props,
3424
- className: tx("toolbar.root", "toolbar", {}, classNames),
3425
- ref: forwardedRef
3426
- }, children);
3427
- });
3428
- var ToolbarButton = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3429
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3430
- asChild: true
3431
- }, /* @__PURE__ */ React36.createElement(Button, {
3432
- ...props,
3433
- ref: forwardedRef
3434
- }));
3435
- });
3436
- var ToolbarIconButton = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3437
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3438
- asChild: true
3439
- }, /* @__PURE__ */ React36.createElement(IconButton, {
3440
- ...props,
3441
- ref: forwardedRef
3442
- }));
3443
- });
3444
- var ToolbarToggle = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3445
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3446
- asChild: true
3447
- }, /* @__PURE__ */ React36.createElement(Toggle, {
3448
- ...props,
3449
- ref: forwardedRef
3450
- }));
3451
- });
3452
- var ToolbarLink = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3453
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Link, {
3454
- asChild: true
3455
- }, /* @__PURE__ */ React36.createElement(Link, {
3456
- ...props,
3457
- ref: forwardedRef
3458
- }));
3459
- });
3460
- var ToolbarToggleGroup2 = /* @__PURE__ */ forwardRef28(({ classNames, children, elevation, ...props }, forwardedRef) => {
3461
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleGroup, {
3462
- ...props,
3463
- asChild: true
3464
- }, /* @__PURE__ */ React36.createElement(ButtonGroup, {
3465
- classNames,
3466
- children,
3467
- elevation,
3468
- ref: forwardedRef
3469
- }));
3470
- });
3471
- var ToolbarToggleGroupItem = /* @__PURE__ */ forwardRef28(({ variant, density, elevation, classNames, children, ...props }, forwardedRef) => {
3472
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleItem, {
3473
- ...props,
3474
- asChild: true
3475
- }, /* @__PURE__ */ React36.createElement(Button, {
3476
- variant,
3477
- density,
3478
- elevation,
3479
- classNames,
3480
- children,
3481
- ref: forwardedRef
3482
- }));
3483
- });
3484
- var ToolbarToggleGroupIconItem = /* @__PURE__ */ forwardRef28(({ variant, density, elevation, classNames, icon, label, iconOnly, ...props }, forwardedRef) => {
3485
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleItem, {
3486
- ...props,
3487
- asChild: true
3488
- }, /* @__PURE__ */ React36.createElement(IconButton, {
3489
- variant,
3490
- density,
3491
- elevation,
3492
- classNames,
3493
- icon,
3494
- label,
3495
- iconOnly,
3496
- ref: forwardedRef
3497
- }));
3498
- });
3499
- var ToolbarSeparator = /* @__PURE__ */ forwardRef28(({ variant = "line", ...props }, forwardedRef) => {
3500
- return variant === "line" ? /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Separator, {
3501
- asChild: true
3502
- }, /* @__PURE__ */ React36.createElement(Separator4, {
3503
- ...props,
3504
- ref: forwardedRef
3505
- })) : /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Separator, {
3506
- className: "grow",
3507
- ref: forwardedRef
3508
- });
3509
- });
3510
- var Toolbar = {
3511
- Root: ToolbarRoot,
3512
- Button: ToolbarButton,
3513
- IconButton: ToolbarIconButton,
3514
- Link: ToolbarLink,
3515
- Toggle: ToolbarToggle,
3516
- ToggleGroup: ToolbarToggleGroup2,
3517
- ToggleGroupItem: ToolbarToggleGroupItem,
3518
- ToggleGroupIconItem: ToolbarToggleGroupIconItem,
3519
- Separator: ToolbarSeparator
3520
- };
3521
76
  export {
3522
77
  AlertDialog,
3523
78
  AnchoredOverflow,
@@ -3527,7 +82,7 @@ export {
3527
82
  Button,
3528
83
  ButtonGroup,
3529
84
  Clipboard,
3530
- ContextMenu2 as ContextMenu,
85
+ ContextMenu,
3531
86
  DensityContext,
3532
87
  DensityProvider,
3533
88
  Dialog,
@@ -3547,7 +102,7 @@ export {
3547
102
  Popover,
3548
103
  ScrollArea,
3549
104
  Select,
3550
- Separator4 as Separator,
105
+ Separator,
3551
106
  Status,
3552
107
  Tag,
3553
108
  ThemeContext,