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