@dxos/react-ui 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (57) 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 -3519
  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 -3481
  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 -3519
  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/Buttons/IconButton.d.ts +1 -2
  25. package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
  26. package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +2 -2
  27. package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +2 -2
  29. package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/Main/Main.d.ts.map +1 -1
  31. package/dist/types/src/components/Message/Message.stories.d.ts +6 -0
  32. package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
  33. package/dist/types/src/components/Tooltip/Tooltip.d.ts +0 -2
  34. package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  35. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +0 -1
  36. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
  37. package/dist/types/src/testing/decorators/index.d.ts +1 -1
  38. package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
  39. package/dist/types/src/testing/decorators/{withVariants.d.ts → withSurfaceVariantsLayout.d.ts} +2 -3
  40. package/dist/types/src/testing/decorators/withSurfaceVariantsLayout.d.ts.map +1 -0
  41. package/package.json +24 -15
  42. package/src/components/Avatars/Avatar.tsx +7 -8
  43. package/src/components/Buttons/Button.stories.tsx +2 -2
  44. package/src/components/Buttons/IconButton.tsx +4 -8
  45. package/src/components/Dialogs/AlertDialog.stories.tsx +2 -2
  46. package/src/components/Dialogs/Dialog.stories.tsx +2 -2
  47. package/src/components/Input/Input.stories.tsx +2 -2
  48. package/src/components/Main/Main.tsx +1 -0
  49. package/src/components/Message/Message.stories.tsx +7 -1
  50. package/src/components/ScrollArea/ScrollArea.stories.tsx +2 -2
  51. package/src/components/Select/Select.stories.tsx +2 -2
  52. package/src/components/Tooltip/Tooltip.tsx +1 -16
  53. package/src/playground/Controls.stories.tsx +2 -2
  54. package/src/testing/decorators/index.ts +1 -1
  55. package/src/testing/decorators/withSurfaceVariantsLayout.tsx +53 -0
  56. package/dist/types/src/testing/decorators/withVariants.d.ts.map +0 -1
  57. package/src/testing/decorators/withVariants.tsx +0 -45
@@ -1,3526 +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 } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
1300
- return /* @__PURE__ */ React17.createElement(DialogContentPrimitive, {
1301
- // NOTE: Radix warning unless set to undefined.
1302
- // https://www.radix-ui.com/primitives/docs/components/dialog#description
1303
- "aria-describedby": void 0,
1304
- ...props,
1305
- className: tx("dialog.content", "dialog", {
1306
- inOverlayLayout: propsInOverlayLayout || inOverlayLayout
1307
- }, classNames),
1308
- ref: forwardedRef
1309
- }, children);
1310
- });
1311
- DialogContent.displayName = DIALOG_CONTENT_NAME;
1312
- var Dialog = {
1313
- Root: DialogRoot,
1314
- Trigger: DialogTrigger,
1315
- Portal: DialogPortal,
1316
- Overlay: DialogOverlay,
1317
- Content: DialogContent,
1318
- Title: DialogTitle,
1319
- Description: DialogDescription,
1320
- Close: DialogClose
1321
- };
1322
-
1323
- // packages/ui/react-ui/src/components/Dialogs/AlertDialog.tsx
1324
- 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";
1325
- import { createContext as createContext9 } from "@radix-ui/react-context";
1326
- import React18, { forwardRef as forwardRef12 } from "react";
1327
- var AlertDialogRoot = (props) => /* @__PURE__ */ React18.createElement(ElevationProvider, {
1328
- elevation: "dialog"
1329
- }, /* @__PURE__ */ React18.createElement(AlertDialogRootPrimitive, props));
1330
- var AlertDialogTrigger = AlertDialogTriggerPrimitive;
1331
- var AlertDialogPortal = AlertDialogPortalPrimitive;
1332
- var AlertDialogCancel = AlertDialogCancelPrimitive;
1333
- var AlertDialogAction = AlertDialogActionPrimitive;
1334
- var AlertDialogTitle = /* @__PURE__ */ forwardRef12(({ classNames, srOnly, ...props }, forwardedRef) => {
1335
- const { tx } = useThemeContext();
1336
- return /* @__PURE__ */ React18.createElement(AlertDialogTitlePrimitive, {
1337
- ...props,
1338
- className: tx("dialog.title", "dialog--alert__title", {
1339
- srOnly
1340
- }, classNames),
1341
- ref: forwardedRef
1342
- });
1343
- });
1344
- var AlertDialogDescription = /* @__PURE__ */ forwardRef12(({ classNames, srOnly, ...props }, forwardedRef) => {
1345
- const { tx } = useThemeContext();
1346
- return /* @__PURE__ */ React18.createElement(AlertDialogDescriptionPrimitive, {
1347
- ...props,
1348
- className: tx("dialog.description", "dialog--alert__description", {
1349
- srOnly
1350
- }, classNames),
1351
- ref: forwardedRef
1352
- });
1353
- });
1354
- var ALERT_DIALOG_OVERLAY_NAME = "AlertDialogOverlay";
1355
- var ALERT_DIALOG_CONTENT_NAME = "AlertDialogContent";
1356
- var [OverlayLayoutProvider2, useOverlayLayoutContext2] = createContext9(ALERT_DIALOG_OVERLAY_NAME, {
1357
- inOverlayLayout: false
1358
- });
1359
- var AlertDialogOverlay = /* @__PURE__ */ forwardRef12(({ classNames, children, blockAlign, ...props }, forwardedRef) => {
1360
- const { tx } = useThemeContext();
1361
- return /* @__PURE__ */ React18.createElement(AlertDialogOverlayPrimitive, {
1362
- ...props,
1363
- 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"),
1364
- ref: forwardedRef,
1365
- "data-block-align": blockAlign
1366
- }, /* @__PURE__ */ React18.createElement(OverlayLayoutProvider2, {
1367
- inOverlayLayout: true
1368
- }, children));
1369
- });
1370
- AlertDialogOverlay.displayName = ALERT_DIALOG_OVERLAY_NAME;
1371
- var AlertDialogContent = /* @__PURE__ */ forwardRef12(({ classNames, children, ...props }, forwardedRef) => {
1372
- const { tx } = useThemeContext();
1373
- const { inOverlayLayout } = useOverlayLayoutContext2(ALERT_DIALOG_CONTENT_NAME);
1374
- return /* @__PURE__ */ React18.createElement(AlertDialogContentPrimitive, {
1375
- ...props,
1376
- className: tx("dialog.content", "dialog--alert", {
1377
- inOverlayLayout
1378
- }, classNames),
1379
- ref: forwardedRef
1380
- }, children);
1381
- });
1382
- AlertDialogContent.displayName = ALERT_DIALOG_CONTENT_NAME;
1383
- var AlertDialog = {
1384
- Root: AlertDialogRoot,
1385
- Trigger: AlertDialogTrigger,
1386
- Portal: AlertDialogPortal,
1387
- Overlay: AlertDialogOverlay,
1388
- Content: AlertDialogContent,
1389
- Title: AlertDialogTitle,
1390
- Description: AlertDialogDescription,
1391
- Cancel: AlertDialogCancel,
1392
- Action: AlertDialogAction
1393
- };
1394
-
1395
- // packages/ui/react-ui/src/components/Input/Input.tsx
1396
- import { Root as CheckboxPrimitive } from "@radix-ui/react-checkbox";
1397
- import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
1398
- import React19, { forwardRef as forwardRef13, useCallback as useCallback5 } from "react";
1399
- 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";
1400
- import { mx as mx3 } from "@dxos/react-ui-theme";
1401
- var Label = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1402
- const { tx } = useThemeContext();
1403
- return /* @__PURE__ */ React19.createElement(LabelPrimitive, {
1404
- ...props,
1405
- className: tx("input.label", "input__label", {
1406
- srOnly
1407
- }, classNames),
1408
- ref: forwardedRef
1409
- }, children);
1410
- });
1411
- var Description = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1412
- const { tx } = useThemeContext();
1413
- return /* @__PURE__ */ React19.createElement(DescriptionPrimitive, {
1414
- ...props,
1415
- className: tx("input.description", "input__description", {
1416
- srOnly
1417
- }, classNames),
1418
- ref: forwardedRef
1419
- }, children);
1420
- });
1421
- var Validation = /* @__PURE__ */ forwardRef13(({ __inputScope, srOnly, classNames, children, ...props }, forwardedRef) => {
1422
- const { tx } = useThemeContext();
1423
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1424
- return /* @__PURE__ */ React19.createElement(ValidationPrimitive, {
1425
- ...props,
1426
- className: tx("input.validation", `input__validation-message input__validation-message--${validationValence}`, {
1427
- srOnly,
1428
- validationValence
1429
- }, classNames),
1430
- ref: forwardedRef
1431
- }, children);
1432
- });
1433
- var DescriptionAndValidation = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
1434
- const { tx } = useThemeContext();
1435
- return /* @__PURE__ */ React19.createElement(DescriptionAndValidationPrimitive, {
1436
- ...props,
1437
- className: tx("input.descriptionAndValidation", "input__description-and-validation", {
1438
- srOnly
1439
- }, classNames),
1440
- ref: forwardedRef
1441
- }, children);
1442
- });
1443
- var PinInput = /* @__PURE__ */ forwardRef13(({ density: propsDensity, elevation: propsElevation, segmentClassName: propsSegmentClassName, inputClassName, variant, ...props }, forwardedRef) => {
1444
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1445
- const { tx } = useThemeContext();
1446
- const density = useDensityContext(propsDensity);
1447
- const elevation = useElevationContext(propsElevation);
1448
- const segmentClassName = useCallback5(({ focused, validationValence }) => tx("input.input", "input--pin-segment", {
1449
- variant: "static",
1450
- focused,
1451
- disabled: props.disabled,
1452
- density,
1453
- elevation,
1454
- validationValence
1455
- }, propsSegmentClassName), [
1456
- tx,
1457
- props.disabled,
1458
- elevation,
1459
- propsElevation,
1460
- density
1461
- ]);
1462
- return /* @__PURE__ */ React19.createElement(PinInputPrimitive, {
1463
- ...props,
1464
- segmentClassName,
1465
- ...props.autoFocus && !hasIosKeyboard2 && {
1466
- autoFocus: true
1467
- },
1468
- inputClassName: tx("input.inputWithSegments", "input input--pin", {
1469
- disabled: props.disabled
1470
- }, inputClassName),
1471
- ref: forwardedRef
1472
- });
1473
- });
1474
- var TextInput = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1475
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1476
- const themeContextValue = useThemeContext();
1477
- const density = useDensityContext(propsDensity);
1478
- const elevation = useElevationContext(propsElevation);
1479
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1480
- const { tx } = themeContextValue;
1481
- return /* @__PURE__ */ React19.createElement(TextInputPrimitive, {
1482
- ...props,
1483
- className: tx("input.input", "input", {
1484
- variant,
1485
- disabled: props.disabled,
1486
- density,
1487
- elevation,
1488
- validationValence
1489
- }, classNames),
1490
- ...props.autoFocus && !hasIosKeyboard2 && {
1491
- autoFocus: true
1492
- },
1493
- ref: forwardedRef
1494
- });
1495
- });
1496
- var TextArea = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
1497
- const { hasIosKeyboard: hasIosKeyboard2 } = useThemeContext();
1498
- const { tx } = useThemeContext();
1499
- const density = useDensityContext(propsDensity);
1500
- const elevation = useElevationContext(propsElevation);
1501
- const { validationValence } = useInputContext(INPUT_NAME, __inputScope);
1502
- return /* @__PURE__ */ React19.createElement(TextAreaPrimitive, {
1503
- ...props,
1504
- className: tx("input.input", "input--text-area", {
1505
- variant,
1506
- disabled: props.disabled,
1507
- density,
1508
- elevation,
1509
- validationValence
1510
- }, classNames),
1511
- ...props.autoFocus && !hasIosKeyboard2 && {
1512
- autoFocus: true
1513
- },
1514
- ref: forwardedRef
1515
- });
1516
- });
1517
- var Checkbox = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, size, weight = "bold", classNames, ...props }, forwardedRef) => {
1518
- const [checked, onCheckedChange] = useControllableState2({
1519
- prop: propsChecked,
1520
- defaultProp: propsDefaultChecked,
1521
- onChange: propsOnCheckedChange
1522
- });
1523
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1524
- const { tx } = useThemeContext();
1525
- return /* @__PURE__ */ React19.createElement(CheckboxPrimitive, {
1526
- ...props,
1527
- checked,
1528
- onCheckedChange,
1529
- id,
1530
- "aria-describedby": descriptionId,
1531
- ...validationValence === "error" && {
1532
- "aria-invalid": "true",
1533
- "aria-errormessage": errorMessageId
1534
- },
1535
- className: tx("input.checkbox", "input--checkbox", {
1536
- size
1537
- }, "shrink-0", classNames),
1538
- ref: forwardedRef
1539
- }, /* @__PURE__ */ React19.createElement(Icon, {
1540
- icon: checked === "indeterminate" ? "ph--minus--regular" : "ph--check--regular",
1541
- classNames: tx("input.checkboxIndicator", "input--checkbox__indicator", {
1542
- size,
1543
- checked
1544
- })
1545
- }));
1546
- });
1547
- var Switch = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, classNames, ...props }, forwardedRef) => {
1548
- const [checked, onCheckedChange] = useControllableState2({
1549
- prop: propsChecked,
1550
- defaultProp: propsDefaultChecked ?? false,
1551
- onChange: propsOnCheckedChange
1552
- });
1553
- const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
1554
- return /* @__PURE__ */ React19.createElement("input", {
1555
- type: "checkbox",
1556
- className: mx3("dx-checkbox--switch dx-focus-ring", classNames),
1557
- checked,
1558
- onChange: (event) => {
1559
- onCheckedChange(event.target.checked);
1560
- },
1561
- id,
1562
- "aria-describedby": descriptionId,
1563
- ...props,
1564
- ...validationValence === "error" && {
1565
- "aria-invalid": "true",
1566
- "aria-errormessage": errorMessageId
1567
- },
1568
- ref: forwardedRef
1569
- });
1570
- });
1571
- var Input = {
1572
- Root: InputRoot,
1573
- PinInput,
1574
- TextInput,
1575
- TextArea,
1576
- Checkbox,
1577
- Switch,
1578
- Label,
1579
- Description,
1580
- Validation,
1581
- DescriptionAndValidation
1582
- };
1583
-
1584
- // packages/ui/react-ui/src/components/Lists/List.tsx
1585
- import { CaretDown, CaretRight } from "@phosphor-icons/react";
1586
- import { Slot as Slot6 } from "@radix-ui/react-slot";
1587
- import React21, { forwardRef as forwardRef14 } from "react";
1588
- 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";
1589
-
1590
- // packages/ui/react-ui/src/components/Lists/ListDropIndicator.tsx
1591
- import React20 from "react";
1592
- var edgeToOrientationMap = {
1593
- top: "horizontal",
1594
- bottom: "horizontal",
1595
- left: "vertical",
1596
- right: "vertical"
1597
- };
1598
- var orientationStyles = {
1599
- horizontal: "h-[--line-thickness] left-[calc(var(--line-inset)+var(--terminal-radius))] right-[--line-inset] before:left-[--terminal-inset]",
1600
- vertical: "w-[--line-thickness] top-[calc(var(--line-inset)+var(--terminal-radius))] bottom-[--line-inset] before:top-[--terminal-inset]"
1601
- };
1602
- var edgeStyles = {
1603
- top: "top-[--line-offset] before:top-[--offset-terminal]",
1604
- right: "right-[--line-offset] before:right-[--offset-terminal]",
1605
- bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
1606
- left: "left-[--line-offset] before:left-[--offset-terminal]"
1607
- };
1608
- var strokeSize = 2;
1609
- var terminalSize = 8;
1610
- var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
1611
- var ListDropIndicator = ({ edge, gap = 0, lineInset = 0, terminalInset = lineInset - terminalSize }) => {
1612
- const orientation = edgeToOrientationMap[edge];
1613
- return /* @__PURE__ */ React20.createElement("div", {
1614
- role: "none",
1615
- style: {
1616
- "--line-thickness": `${strokeSize}px`,
1617
- "--line-offset": `calc(-0.5 * (${gap}px + ${strokeSize}px))`,
1618
- "--line-inset": `${lineInset}px`,
1619
- "--terminal-size": `${terminalSize}px`,
1620
- "--terminal-radius": `${terminalSize / 2}px`,
1621
- "--terminal-inset": `${terminalInset}px`,
1622
- "--offset-terminal": `${offsetToAlignTerminalWithLine}px`
1623
- },
1624
- 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]}`
1625
- });
1626
- };
1627
-
1628
- // packages/ui/react-ui/src/components/Lists/List.tsx
1629
- var List = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1630
- const { tx } = useThemeContext();
1631
- const density = useDensityContext(props.density);
1632
- return /* @__PURE__ */ React21.createElement(DensityProvider, {
1633
- density
1634
- }, /* @__PURE__ */ React21.createElement(ListPrimitive, {
1635
- ...props,
1636
- className: tx("list.root", "list", {}, classNames),
1637
- ref: forwardedRef
1638
- }, children));
1639
- });
1640
- var ListItemEndcap = /* @__PURE__ */ forwardRef14(({ children, classNames, asChild, ...props }, forwardedRef) => {
1641
- const Root7 = asChild ? Slot6 : "div";
1642
- const density = useDensityContext();
1643
- const { tx } = useThemeContext();
1644
- return /* @__PURE__ */ React21.createElement(Root7, {
1645
- ...!asChild && {
1646
- role: "none"
1647
- },
1648
- ...props,
1649
- className: tx("list.item.endcap", "list__listItem__endcap", {
1650
- density
1651
- }, classNames),
1652
- ref: forwardedRef
1653
- }, children);
1654
- });
1655
- var MockListItemOpenTrigger = ({ classNames, ...props }) => {
1656
- const density = useDensityContext();
1657
- const { tx } = useThemeContext();
1658
- return /* @__PURE__ */ React21.createElement("div", {
1659
- role: "none",
1660
- ...props,
1661
- className: tx("list.item.openTrigger", "list__listItem__openTrigger--mock", {
1662
- density
1663
- }, classNames)
1664
- });
1665
- };
1666
- var ListItemHeading = /* @__PURE__ */ forwardRef14(({ children, classNames, ...props }, forwardedRef) => {
1667
- const { tx } = useThemeContext();
1668
- const density = useDensityContext();
1669
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemHeading, {
1670
- ...props,
1671
- className: tx("list.item.heading", "list__listItem__heading", {
1672
- density
1673
- }, classNames),
1674
- ref: forwardedRef
1675
- }, children);
1676
- });
1677
- var ListItemOpenTrigger = /* @__PURE__ */ forwardRef14(({ __listItemScope, classNames, children, ...props }, forwardedRef) => {
1678
- const { tx } = useThemeContext();
1679
- const density = useDensityContext();
1680
- const { open } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
1681
- const Icon3 = open ? CaretDown : CaretRight;
1682
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItemOpenTrigger, {
1683
- ...props,
1684
- className: tx("list.item.openTrigger", "list__listItem__openTrigger", {
1685
- density
1686
- }, classNames),
1687
- ref: forwardedRef
1688
- }, children || /* @__PURE__ */ React21.createElement(Icon3, {
1689
- weight: "bold",
1690
- className: tx("list.item.openTriggerIcon", "list__listItem__openTrigger__icon", {})
1691
- }));
1692
- });
1693
- var ListItemRoot = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, forwardedRef) => {
1694
- const { tx } = useThemeContext();
1695
- const density = useDensityContext();
1696
- return /* @__PURE__ */ React21.createElement(ListPrimitiveItem, {
1697
- ...props,
1698
- className: tx("list.item.root", "list__listItem", {
1699
- density,
1700
- collapsible: props.collapsible
1701
- }, classNames),
1702
- ref: forwardedRef
1703
- }, children);
1704
- });
1705
- var ListItem = {
1706
- Root: ListItemRoot,
1707
- Endcap: ListItemEndcap,
1708
- Heading: ListItemHeading,
1709
- OpenTrigger: ListItemOpenTrigger,
1710
- CollapsibleContent: ListItemCollapsibleContent,
1711
- MockOpenTrigger: MockListItemOpenTrigger,
1712
- DropIndicator: ListDropIndicator
1713
- };
1714
-
1715
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1716
- import React23, { forwardRef as forwardRef15 } from "react";
1717
-
1718
- // packages/ui/react-ui/src/components/Lists/TreeDropIndicator.tsx
1719
- import React22 from "react";
1720
- var edgeToOrientationMap2 = {
1721
- "reorder-above": "sibling",
1722
- "reorder-below": "sibling",
1723
- "make-child": "child",
1724
- reparent: "child"
1725
- };
1726
- var orientationStyles2 = {
1727
- // TODO(wittjosiah): Stop using left/right here.
1728
- sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
1729
- child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
1730
- };
1731
- var instructionStyles = {
1732
- "reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
1733
- "reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
1734
- "make-child": "border-accentSurface",
1735
- // TODO(wittjosiah): This is not occurring in the current implementation.
1736
- reparent: ""
1737
- };
1738
- var strokeSize2 = 2;
1739
- var terminalSize2 = 8;
1740
- var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
1741
- var TreeDropIndicator = ({ instruction, gap = 0 }) => {
1742
- const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
1743
- const isBlocked = instruction.type === "instruction-blocked";
1744
- const desiredInstruction = isBlocked ? instruction.desired : instruction;
1745
- const orientation = edgeToOrientationMap2[desiredInstruction.type];
1746
- if (isBlocked) {
1747
- return null;
1748
- }
1749
- return /* @__PURE__ */ React22.createElement("div", {
1750
- style: {
1751
- "--line-thickness": `${strokeSize2}px`,
1752
- "--line-offset": `${lineOffset}`,
1753
- "--terminal-size": `${terminalSize2}px`,
1754
- "--terminal-radius": `${terminalSize2 / 2}px`,
1755
- "--negative-terminal-size": `-${terminalSize2}px`,
1756
- "--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
1757
- "--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
1758
- },
1759
- 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]}`
1760
- });
1761
- };
1762
-
1763
- // packages/ui/react-ui/src/components/Lists/Tree.tsx
1764
- var TreeRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1765
- return /* @__PURE__ */ React23.createElement(List, {
1766
- ...props,
1767
- ref: forwardedRef
1768
- });
1769
- });
1770
- var TreeBranch = /* @__PURE__ */ forwardRef15(({ __listScope, ...props }, forwardedRef) => {
1771
- const { headingId } = useListItemContext(LIST_ITEM_NAME, __listScope);
1772
- return /* @__PURE__ */ React23.createElement(List, {
1773
- ...props,
1774
- "aria-labelledby": headingId,
1775
- ref: forwardedRef
1776
- });
1777
- });
1778
- var TreeItemRoot = /* @__PURE__ */ forwardRef15((props, forwardedRef) => {
1779
- return /* @__PURE__ */ React23.createElement(ListItem.Root, {
1780
- role: "treeitem",
1781
- ...props,
1782
- ref: forwardedRef
1783
- });
1784
- });
1785
- var TreeItemHeading = ListItem.Heading;
1786
- var TreeItemOpenTrigger = ListItem.OpenTrigger;
1787
- var MockTreeItemOpenTrigger = ListItem.MockOpenTrigger;
1788
- var TreeItemBody = ListItem.CollapsibleContent;
1789
- var Tree = {
1790
- Root: TreeRoot,
1791
- Branch: TreeBranch
1792
- };
1793
- var TreeItem = {
1794
- Root: TreeItemRoot,
1795
- Heading: TreeItemHeading,
1796
- Body: TreeItemBody,
1797
- OpenTrigger: TreeItemOpenTrigger,
1798
- MockOpenTrigger: MockTreeItemOpenTrigger,
1799
- DropIndicator: TreeDropIndicator
1800
- };
1801
-
1802
- // packages/ui/react-ui/src/components/Lists/Treegrid.tsx
1803
- import { useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
1804
- import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
1805
- import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1806
- import { Slot as Slot7 } from "@radix-ui/react-slot";
1807
- import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
1808
- import React24, { forwardRef as forwardRef16 } from "react";
1809
- var TREEGRID_ROW_NAME = "TreegridRow";
1810
- var [createTreegridRowContext, createTreegridRowScope] = createContextScope2(TREEGRID_ROW_NAME, []);
1811
- var [TreegridRowProvider, useTreegridRowContext] = createTreegridRowContext(TREEGRID_ROW_NAME);
1812
- var PATH_SEPARATOR = "~";
1813
- var PARENT_OF_SEPARATOR = " ";
1814
- var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
1815
- const { tx } = useThemeContext();
1816
- const Root7 = asChild ? Slot7 : Primitive7.div;
1817
- const arrowNavigationAttrs = useArrowNavigationGroup({
1818
- axis: "vertical",
1819
- tabbable: false,
1820
- circular: true
1821
- });
1822
- return /* @__PURE__ */ React24.createElement(Root7, {
1823
- role: "treegrid",
1824
- ...arrowNavigationAttrs,
1825
- ...props,
1826
- className: tx("treegrid.root", "treegrid", {}, classNames),
1827
- style: {
1828
- ...style,
1829
- gridTemplateColumns
1830
- },
1831
- ref: forwardedRef
1832
- }, children);
1833
- });
1834
- var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, classNames, children, id, parentOf, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, ...props }, forwardedRef) => {
1835
- const { tx } = useThemeContext();
1836
- const Root7 = asChild ? Slot7 : Primitive7.div;
1837
- const pathParts = id.split(PATH_SEPARATOR);
1838
- const level = pathParts.length - 1;
1839
- const [open, onOpenChange] = useControllableState3({
1840
- prop: propsOpen,
1841
- onChange: propsOnOpenChange,
1842
- defaultProp: defaultOpen
1843
- });
1844
- const focusableGroupAttrs = useFocusableGroup({
1845
- tabBehavior: "limited"
1846
- });
1847
- const arrowGroupAttrs = useArrowNavigationGroup({
1848
- axis: "horizontal",
1849
- tabbable: false,
1850
- circular: false,
1851
- memorizeCurrent: false
1852
- });
1853
- return /* @__PURE__ */ React24.createElement(TreegridRowProvider, {
1854
- open,
1855
- onOpenChange,
1856
- scope: __treegridRowScope
1857
- }, /* @__PURE__ */ React24.createElement(Root7, {
1858
- role: "row",
1859
- "aria-level": level,
1860
- className: tx("treegrid.row", "treegrid__row", {
1861
- level
1862
- }, classNames),
1863
- ...parentOf && {
1864
- "aria-expanded": open,
1865
- "aria-owns": parentOf
1866
- },
1867
- tabIndex: 0,
1868
- ...focusableGroupAttrs,
1869
- ...props,
1870
- id,
1871
- ref: forwardedRef
1872
- }, /* @__PURE__ */ React24.createElement("div", {
1873
- role: "none",
1874
- className: "contents",
1875
- ...arrowGroupAttrs
1876
- }, children)));
1877
- });
1878
- var TreegridCell = /* @__PURE__ */ forwardRef16(({ classNames, children, indent, ...props }, forwardedRef) => {
1879
- const { tx } = useThemeContext();
1880
- return /* @__PURE__ */ React24.createElement("div", {
1881
- role: "gridcell",
1882
- className: tx("treegrid.cell", "treegrid__cell", {
1883
- indent
1884
- }, classNames),
1885
- ...props,
1886
- ref: forwardedRef
1887
- }, children);
1888
- });
1889
- var Treegrid = {
1890
- Root: TreegridRoot,
1891
- Row: TreegridRow,
1892
- Cell: TreegridCell,
1893
- PARENT_OF_SEPARATOR,
1894
- PATH_SEPARATOR,
1895
- createTreegridRowScope,
1896
- useTreegridRowContext
1897
- };
1898
-
1899
- // packages/ui/react-ui/src/components/Main/Main.tsx
1900
- import { createContext as createContext10 } from "@radix-ui/react-context";
1901
- import { Root as DialogRoot2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@radix-ui/react-dialog";
1902
- import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1903
- import { Slot as Slot8 } from "@radix-ui/react-slot";
1904
- import { useControllableState as useControllableState4 } from "@radix-ui/react-use-controllable-state";
1905
- import React25, { forwardRef as forwardRef17, useCallback as useCallback7, useEffect as useEffect5, useRef as useRef2, useState as useState7 } from "react";
1906
- import { log } from "@dxos/log";
1907
- import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
1908
-
1909
- // packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
1910
- import { useCallback as useCallback6, useEffect as useEffect4, useState as useState6 } from "react";
1911
- var MotionState;
1912
- (function(MotionState2) {
1913
- MotionState2[MotionState2["IDLE"] = 0] = "IDLE";
1914
- MotionState2[MotionState2["DEBOUNCING"] = 1] = "DEBOUNCING";
1915
- MotionState2[MotionState2["FOLLOWING"] = 2] = "FOLLOWING";
1916
- })(MotionState || (MotionState = {}));
1917
- var useSwipeToDismiss = (ref, {
1918
- onDismiss,
1919
- dismissThreshold = 64,
1920
- debounceThreshold = 8,
1921
- offset = 0
1922
- /* side = 'inline-start' */
1923
- }) => {
1924
- const $root = ref.current;
1925
- const [motionState, setMotionState] = useState6(0);
1926
- const [gestureStartX, setGestureStartX] = useState6(0);
1927
- const setIdle = useCallback6(() => {
1928
- setMotionState(0);
1929
- $root?.style.removeProperty("inset-inline-start");
1930
- $root?.style.setProperty("transition-duration", "200ms");
1931
- }, [
1932
- $root
1933
- ]);
1934
- const setFollowing = useCallback6(() => {
1935
- setMotionState(2);
1936
- $root?.style.setProperty("transition-duration", "0ms");
1937
- }, [
1938
- $root
1939
- ]);
1940
- const handlePointerDown = useCallback6(({ screenX }) => {
1941
- if (motionState === 0) {
1942
- setMotionState(1);
1943
- setGestureStartX(screenX);
1944
- }
1945
- }, [
1946
- motionState
1947
- ]);
1948
- const handlePointerMove = useCallback6(({ screenX }) => {
1949
- if ($root) {
1950
- const delta = Math.min(screenX - gestureStartX, 0);
1951
- switch (motionState) {
1952
- case 2:
1953
- if (Math.abs(delta) > dismissThreshold) {
1954
- setIdle();
1955
- onDismiss?.();
1956
- } else {
1957
- $root.style.setProperty("inset-inline-start", `${offset + delta}px`);
1958
- }
1959
- break;
1960
- case 1:
1961
- if (Math.abs(delta) > debounceThreshold) {
1962
- setFollowing();
1963
- }
1964
- break;
1965
- }
1966
- }
1967
- }, [
1968
- $root,
1969
- motionState,
1970
- gestureStartX
1971
- ]);
1972
- const handlePointerUp = useCallback6(() => {
1973
- setIdle();
1974
- }, [
1975
- setIdle
1976
- ]);
1977
- useEffect4(() => {
1978
- $root?.addEventListener("pointerdown", handlePointerDown);
1979
- return () => {
1980
- $root?.removeEventListener("pointerdown", handlePointerDown);
1981
- };
1982
- }, [
1983
- $root,
1984
- handlePointerDown
1985
- ]);
1986
- useEffect4(() => {
1987
- $root && document.documentElement.addEventListener("pointermove", handlePointerMove);
1988
- return () => {
1989
- document.documentElement.removeEventListener("pointermove", handlePointerMove);
1990
- };
1991
- }, [
1992
- $root,
1993
- handlePointerMove
1994
- ]);
1995
- useEffect4(() => {
1996
- $root && document.documentElement.addEventListener("pointerup", handlePointerUp);
1997
- return () => {
1998
- document.documentElement.removeEventListener("pointerup", handlePointerUp);
1999
- };
2000
- }, [
2001
- $root,
2002
- handlePointerUp
2003
- ]);
2004
- };
2005
-
2006
- // packages/ui/react-ui/src/components/Main/Main.tsx
2007
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui/src/components/Main/Main.tsx";
2008
- var MAIN_ROOT_NAME = "MainRoot";
2009
- var NAVIGATION_SIDEBAR_NAME = "NavigationSidebar";
2010
- var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
2011
- var MAIN_NAME = "Main";
2012
- var GENERIC_CONSUMER_NAME = "GenericConsumer";
2013
- var landmarkAttr = "data-main-landmark";
2014
- var useLandmarkMover = (propsOnKeyDown, landmark) => {
2015
- const handleKeyDown = useCallback7((event) => {
2016
- const target = event.target;
2017
- if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
2018
- event.preventDefault();
2019
- const landmarks = Array.from(document.querySelectorAll(`[${landmarkAttr}]:not([inert])`)).map((el) => el.hasAttribute(landmarkAttr) ? parseInt(el.getAttribute(landmarkAttr)) : NaN).sort();
2020
- const l = landmarks.length;
2021
- const cursor = landmarks.indexOf(parseInt(target.getAttribute(landmarkAttr)));
2022
- const nextLandmark = landmarks[(cursor + l + (event.getModifierState("Shift") ? -1 : 1)) % l];
2023
- document.querySelector(`[${landmarkAttr}="${nextLandmark}"]`)?.focus();
2024
- }
2025
- propsOnKeyDown?.(event);
2026
- }, [
2027
- propsOnKeyDown
2028
- ]);
2029
- const focusableGroupAttrs = window ? {} : {
2030
- tabBehavior: "limited",
2031
- ignoreDefaultKeydown: {
2032
- Tab: true
2033
- }
2034
- };
2035
- return {
2036
- onKeyDown: handleKeyDown,
2037
- [landmarkAttr]: landmark,
2038
- tabIndex: 0,
2039
- ...focusableGroupAttrs
2040
- };
2041
- };
2042
- var [MainProvider, useMainContext] = createContext10(MAIN_NAME, {
2043
- resizing: false,
2044
- navigationSidebarState: "closed",
2045
- setNavigationSidebarState: (nextState) => {
2046
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
2047
- F: __dxlog_file,
2048
- L: 82,
2049
- S: void 0,
2050
- C: (f, a) => f(...a)
2051
- });
2052
- },
2053
- complementarySidebarState: "closed",
2054
- setComplementarySidebarState: (nextState) => {
2055
- log.warn("Attempt to set sidebar state without initializing `MainRoot`", void 0, {
2056
- F: __dxlog_file,
2057
- L: 87,
2058
- S: void 0,
2059
- C: (f, a) => f(...a)
2060
- });
2061
- }
2062
- });
2063
- var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
2064
- const { setNavigationSidebarState, navigationSidebarState, setComplementarySidebarState, complementarySidebarState } = useMainContext(consumerName);
2065
- return {
2066
- navigationSidebarState,
2067
- setNavigationSidebarState,
2068
- toggleNavigationSidebar: useCallback7(() => setNavigationSidebarState(navigationSidebarState === "expanded" ? "closed" : "expanded"), [
2069
- navigationSidebarState,
2070
- setNavigationSidebarState
2071
- ]),
2072
- openNavigationSidebar: useCallback7(() => setNavigationSidebarState("expanded"), []),
2073
- collapseNavigationSidebar: useCallback7(() => setNavigationSidebarState("collapsed"), []),
2074
- closeNavigationSidebar: useCallback7(() => setNavigationSidebarState("closed"), []),
2075
- complementarySidebarState,
2076
- setComplementarySidebarState,
2077
- toggleComplementarySidebar: useCallback7(() => setComplementarySidebarState(complementarySidebarState === "expanded" ? "closed" : "expanded"), [
2078
- complementarySidebarState,
2079
- setComplementarySidebarState
2080
- ]),
2081
- openComplementarySidebar: useCallback7(() => setComplementarySidebarState("expanded"), []),
2082
- collapseComplementarySidebar: useCallback7(() => setComplementarySidebarState("collapsed"), []),
2083
- closeComplementarySidebar: useCallback7(() => setComplementarySidebarState("closed"), [])
2084
- };
2085
- };
2086
- var resizeDebounce = 3e3;
2087
- var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNavigationSidebarState, onNavigationSidebarStateChange, complementarySidebarState: propsComplementarySidebarState, defaultComplementarySidebarState, onComplementarySidebarStateChange, children, ...props }) => {
2088
- const [isLg] = useMediaQuery("lg", {
2089
- ssr: false
2090
- });
2091
- const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] = useControllableState4({
2092
- prop: propsNavigationSidebarState,
2093
- defaultProp: defaultNavigationSidebarState,
2094
- onChange: onNavigationSidebarStateChange
2095
- });
2096
- const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] = useControllableState4({
2097
- prop: propsComplementarySidebarState,
2098
- defaultProp: defaultComplementarySidebarState,
2099
- onChange: onComplementarySidebarStateChange
2100
- });
2101
- const [resizing, setResizing] = useState7(false);
2102
- const resizeInterval = useRef2(null);
2103
- const handleResize = useCallback7(() => {
2104
- setResizing(true);
2105
- if (resizeInterval.current) {
2106
- clearTimeout(resizeInterval.current);
2107
- }
2108
- resizeInterval.current = setTimeout(() => {
2109
- setResizing(false);
2110
- resizeInterval.current = null;
2111
- }, resizeDebounce);
2112
- }, []);
2113
- useEffect5(() => {
2114
- window.addEventListener("resize", handleResize);
2115
- return () => window.removeEventListener("resize", handleResize);
2116
- }, [
2117
- handleResize
2118
- ]);
2119
- return /* @__PURE__ */ React25.createElement(MainProvider, {
2120
- ...props,
2121
- navigationSidebarState,
2122
- setNavigationSidebarState,
2123
- complementarySidebarState,
2124
- setComplementarySidebarState,
2125
- resizing
2126
- }, children);
2127
- };
2128
- MainRoot.displayName = MAIN_ROOT_NAME;
2129
- var handleOpenAutoFocus = (event) => {
2130
- !document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
2131
- };
2132
- var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToDismiss, onOpenAutoFocus, state, resizing, onStateChange, side, label, ...props }, forwardedRef) => {
2133
- const [isLg] = useMediaQuery("lg", {
2134
- ssr: false
2135
- });
2136
- const { tx } = useThemeContext();
2137
- const { t } = useTranslation();
2138
- const ref = useForwardedRef(forwardedRef);
2139
- const noopRef = useRef2(null);
2140
- useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
2141
- onDismiss: () => onStateChange?.("closed")
2142
- });
2143
- const handleKeyDown = useCallback7((event) => {
2144
- if (event.key === "Escape") {
2145
- event.target.closest("[data-tabster]")?.focus();
2146
- }
2147
- props.onKeyDown?.(event);
2148
- }, [
2149
- props.onKeyDown
2150
- ]);
2151
- const Root7 = isLg ? Primitive8.div : DialogContent2;
2152
- return /* @__PURE__ */ React25.createElement(DialogRoot2, {
2153
- open: state !== "closed",
2154
- "aria-label": toLocalizedString(label, t),
2155
- modal: false
2156
- }, !isLg && /* @__PURE__ */ React25.createElement(DialogTitle2, {
2157
- className: "sr-only"
2158
- }, toLocalizedString(label, t)), /* @__PURE__ */ React25.createElement(Root7, {
2159
- ...!isLg && {
2160
- forceMount: true,
2161
- tabIndex: -1,
2162
- onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus
2163
- },
2164
- ...props,
2165
- "data-side": side === "inline-end" ? "ie" : "is",
2166
- "data-state": state,
2167
- "data-resizing": resizing ? "true" : "false",
2168
- className: tx("main.sidebar", "main__sidebar", {}, classNames),
2169
- onKeyDown: handleKeyDown,
2170
- ...state === "closed" && {
2171
- inert: "true"
2172
- },
2173
- ref
2174
- }, children));
2175
- });
2176
- var MainNavigationSidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
2177
- const { navigationSidebarState, setNavigationSidebarState, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
2178
- const mover = useLandmarkMover(props.onKeyDown, "0");
2179
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
2180
- ...mover,
2181
- ...props,
2182
- state: navigationSidebarState,
2183
- onStateChange: setNavigationSidebarState,
2184
- resizing,
2185
- side: "inline-start",
2186
- ref: forwardedRef
2187
- });
2188
- });
2189
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2190
- var MainComplementarySidebar = /* @__PURE__ */ forwardRef17((props, forwardedRef) => {
2191
- const { complementarySidebarState, setComplementarySidebarState, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
2192
- const mover = useLandmarkMover(props.onKeyDown, "2");
2193
- return /* @__PURE__ */ React25.createElement(MainSidebar, {
2194
- ...mover,
2195
- ...props,
2196
- state: complementarySidebarState,
2197
- onStateChange: setComplementarySidebarState,
2198
- resizing,
2199
- side: "inline-end",
2200
- ref: forwardedRef
2201
- });
2202
- });
2203
- MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
2204
- var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
2205
- const { navigationSidebarState, complementarySidebarState } = useMainContext(MAIN_NAME);
2206
- const { tx } = useThemeContext();
2207
- const Root7 = asChild ? Slot8 : role ? "div" : "main";
2208
- const mover = useLandmarkMover(props.onKeyDown, "1");
2209
- return /* @__PURE__ */ React25.createElement(Root7, {
2210
- role,
2211
- ...handlesFocus && {
2212
- ...mover
2213
- },
2214
- ...props,
2215
- "data-sidebar-inline-start-state": navigationSidebarState,
2216
- "data-sidebar-inline-end-state": complementarySidebarState,
2217
- className: tx("main.content", "main", {
2218
- bounce,
2219
- handlesFocus
2220
- }, classNames),
2221
- ref: forwardedRef
2222
- }, children);
2223
- });
2224
- MainContent.displayName = MAIN_NAME;
2225
- var MainOverlay = /* @__PURE__ */ forwardRef17(({ classNames, ...props }, forwardedRef) => {
2226
- const [isLg] = useMediaQuery("lg", {
2227
- ssr: false
2228
- });
2229
- const { navigationSidebarState, setNavigationSidebarState, complementarySidebarState, setComplementarySidebarState } = useMainContext(MAIN_NAME);
2230
- const { tx } = useThemeContext();
2231
- return /* @__PURE__ */ React25.createElement("div", {
2232
- onClick: () => {
2233
- setNavigationSidebarState("collapsed");
2234
- setComplementarySidebarState("collapsed");
2235
- },
2236
- ...props,
2237
- className: tx("main.overlay", "main__overlay", {
2238
- isLg,
2239
- inlineStartSidebarOpen: navigationSidebarState,
2240
- inlineEndSidebarOpen: complementarySidebarState
2241
- }, classNames),
2242
- "data-state": navigationSidebarState === "expanded" || complementarySidebarState === "expanded" ? "open" : "closed",
2243
- "aria-hidden": "true",
2244
- ref: forwardedRef
2245
- });
2246
- });
2247
- var Main = {
2248
- Root: MainRoot,
2249
- Content: MainContent,
2250
- Overlay: MainOverlay,
2251
- NavigationSidebar: MainNavigationSidebar,
2252
- ComplementarySidebar: MainComplementarySidebar
2253
- };
2254
-
2255
- // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
2256
- import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
2257
- import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
2258
- import { Slot as Slot9 } from "@radix-ui/react-slot";
2259
- import React26, { forwardRef as forwardRef18 } from "react";
2260
-
2261
- // packages/ui/react-ui/src/hooks/useSafeCollisionPadding.ts
2262
- import { useMemo as useMemo3 } from "react";
2263
- var propIsNumber = (prop) => Number.isFinite(prop);
2264
- var propsIsRecord = (prop) => !!(prop && typeof prop === "object");
2265
- var safePadding = (propsPadding, safePadding2, side) => {
2266
- return (propIsNumber(safePadding2[side]) ? safePadding2[side] : 0) + (propIsNumber(propsPadding) ? propsPadding : propsIsRecord(propsPadding) ? propsPadding[side] ?? 0 : 0);
2267
- };
2268
- var useSafeCollisionPadding = (collisionPadding) => {
2269
- const { safeAreaPadding } = useThemeContext();
2270
- return useMemo3(() => ({
2271
- top: safePadding(collisionPadding, safeAreaPadding, "top"),
2272
- right: safePadding(collisionPadding, safeAreaPadding, "right"),
2273
- bottom: safePadding(collisionPadding, safeAreaPadding, "bottom"),
2274
- left: safePadding(collisionPadding, safeAreaPadding, "left")
2275
- }), [
2276
- collisionPadding,
2277
- safeAreaPadding
2278
- ]);
2279
- };
2280
-
2281
- // packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
2282
- var ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
2283
- var ContextMenuTrigger = ContextMenuPrimitive.Trigger;
2284
- var ContextMenuPortal = ContextMenuPrimitive.Portal;
2285
- var ContextMenuContent = /* @__PURE__ */ forwardRef18(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
2286
- const { tx } = useThemeContext();
2287
- const elevation = useElevationContext();
2288
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
2289
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Content, {
2290
- ...props,
2291
- collisionPadding: safeCollisionPadding,
2292
- className: tx("menu.content", "menu", {
2293
- elevation
2294
- }, classNames),
2295
- ref: forwardedRef
2296
- }, children);
2297
- });
2298
- var ContextMenuViewport = /* @__PURE__ */ forwardRef18(({ classNames, asChild, children, ...props }, forwardedRef) => {
2299
- const { tx } = useThemeContext();
2300
- const Root7 = asChild ? Slot9 : Primitive9.div;
2301
- return /* @__PURE__ */ React26.createElement(Root7, {
2302
- ...props,
2303
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
2304
- ref: forwardedRef
2305
- }, children);
2306
- });
2307
- var ContextMenuArrow = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2308
- const { tx } = useThemeContext();
2309
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Arrow, {
2310
- ...props,
2311
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
2312
- ref: forwardedRef
2313
- });
2314
- });
2315
- var ContextMenuGroup = ContextMenuPrimitive.Group;
2316
- var ContextMenuItemIndicator = ContextMenuPrimitive.ItemIndicator;
2317
- var ContextMenuItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2318
- const { tx } = useThemeContext();
2319
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Item, {
2320
- ...props,
2321
- className: tx("menu.item", "menu__item", {}, classNames),
2322
- ref: forwardedRef
2323
- });
2324
- });
2325
- var ContextMenuCheckboxItem = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2326
- const { tx } = useThemeContext();
2327
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.CheckboxItem, {
2328
- ...props,
2329
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
2330
- ref: forwardedRef
2331
- });
2332
- });
2333
- var ContextMenuSeparator = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2334
- const { tx } = useThemeContext();
2335
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Separator, {
2336
- ...props,
2337
- className: tx("menu.separator", "menu__item", {}, classNames),
2338
- ref: forwardedRef
2339
- });
2340
- });
2341
- var ContextMenuGroupLabel = /* @__PURE__ */ forwardRef18(({ classNames, ...props }, forwardedRef) => {
2342
- const { tx } = useThemeContext();
2343
- return /* @__PURE__ */ React26.createElement(ContextMenuPrimitive.Label, {
2344
- ...props,
2345
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
2346
- ref: forwardedRef
2347
- });
2348
- });
2349
- var ContextMenu2 = {
2350
- Root: ContextMenuRoot,
2351
- Trigger: ContextMenuTrigger,
2352
- Portal: ContextMenuPortal,
2353
- Content: ContextMenuContent,
2354
- Viewport: ContextMenuViewport,
2355
- Arrow: ContextMenuArrow,
2356
- Group: ContextMenuGroup,
2357
- Item: ContextMenuItem,
2358
- CheckboxItem: ContextMenuCheckboxItem,
2359
- ItemIndicator: ContextMenuItemIndicator,
2360
- Separator: ContextMenuSeparator,
2361
- GroupLabel: ContextMenuGroupLabel
2362
- };
2363
-
2364
- // packages/ui/react-ui/src/components/Menus/DropdownMenu.tsx
2365
- import { composeEventHandlers as composeEventHandlers2 } from "@radix-ui/primitive";
2366
- import { composeRefs } from "@radix-ui/react-compose-refs";
2367
- import { createContextScope as createContextScope3 } from "@radix-ui/react-context";
2368
- import { useId as useId3 } from "@radix-ui/react-id";
2369
- import * as MenuPrimitive from "@radix-ui/react-menu";
2370
- import { createMenuScope } from "@radix-ui/react-menu";
2371
- import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
2372
- import { Slot as Slot10 } from "@radix-ui/react-slot";
2373
- import { useControllableState as useControllableState5 } from "@radix-ui/react-use-controllable-state";
2374
- import React27, { useRef as useRef3, useCallback as useCallback8, forwardRef as forwardRef19, useEffect as useEffect6 } from "react";
2375
- var DROPDOWN_MENU_NAME = "DropdownMenu";
2376
- var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope3(DROPDOWN_MENU_NAME, [
2377
- createMenuScope
2378
- ]);
2379
- var useMenuScope = createMenuScope();
2380
- var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
2381
- var DropdownMenuRoot = (props) => {
2382
- const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
2383
- const menuScope = useMenuScope(__scopeDropdownMenu);
2384
- const triggerRef = useRef3(null);
2385
- const [open = false, setOpen] = useControllableState5({
2386
- prop: openProp,
2387
- defaultProp: defaultOpen,
2388
- onChange: onOpenChange
2389
- });
2390
- return /* @__PURE__ */ React27.createElement(DropdownMenuProvider, {
2391
- scope: __scopeDropdownMenu,
2392
- triggerId: useId3(),
2393
- triggerRef,
2394
- contentId: useId3(),
2395
- open,
2396
- onOpenChange: setOpen,
2397
- onOpenToggle: useCallback8(() => setOpen((prevOpen) => !prevOpen), [
2398
- setOpen
2399
- ]),
2400
- modal
2401
- }, /* @__PURE__ */ React27.createElement(MenuPrimitive.Root, {
2402
- ...menuScope,
2403
- open,
2404
- onOpenChange: setOpen,
2405
- dir,
2406
- modal
2407
- }, children));
2408
- };
2409
- DropdownMenuRoot.displayName = DROPDOWN_MENU_NAME;
2410
- var TRIGGER_NAME2 = "DropdownMenuTrigger";
2411
- var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2412
- const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
2413
- const context = useDropdownMenuContext(TRIGGER_NAME2, __scopeDropdownMenu);
2414
- const menuScope = useMenuScope(__scopeDropdownMenu);
2415
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
2416
- asChild: true,
2417
- ...menuScope
2418
- }, /* @__PURE__ */ React27.createElement(Primitive10.button, {
2419
- type: "button",
2420
- id: context.triggerId,
2421
- "aria-haspopup": "menu",
2422
- "aria-expanded": context.open,
2423
- "aria-controls": context.open ? context.contentId : void 0,
2424
- "data-state": context.open ? "open" : "closed",
2425
- "data-disabled": disabled ? "" : void 0,
2426
- disabled,
2427
- ...triggerProps,
2428
- ref: composeRefs(forwardedRef, context.triggerRef),
2429
- onPointerDown: composeEventHandlers2(props.onPointerDown, (event) => {
2430
- if (!disabled && event.button === 0 && event.ctrlKey === false) {
2431
- context.onOpenToggle();
2432
- if (!context.open) {
2433
- event.preventDefault();
2434
- }
2435
- }
2436
- }),
2437
- onKeyDown: composeEventHandlers2(props.onKeyDown, (event) => {
2438
- if (disabled) {
2439
- return;
2440
- }
2441
- if ([
2442
- "Enter",
2443
- " "
2444
- ].includes(event.key)) {
2445
- context.onOpenToggle();
2446
- }
2447
- if (event.key === "ArrowDown") {
2448
- context.onOpenChange(true);
2449
- }
2450
- if ([
2451
- "Enter",
2452
- " ",
2453
- "ArrowDown"
2454
- ].includes(event.key)) {
2455
- event.preventDefault();
2456
- }
2457
- })
2458
- }));
2459
- });
2460
- DropdownMenuTrigger.displayName = TRIGGER_NAME2;
2461
- var VIRTUAL_TRIGGER_NAME = "DropdownMenuVirtualTrigger";
2462
- var DropdownMenuVirtualTrigger = (props) => {
2463
- const { __scopeDropdownMenu, virtualRef } = props;
2464
- const context = useDropdownMenuContext(VIRTUAL_TRIGGER_NAME, __scopeDropdownMenu);
2465
- const menuScope = useMenuScope(__scopeDropdownMenu);
2466
- useEffect6(() => {
2467
- if (virtualRef.current) {
2468
- context.triggerRef.current = virtualRef.current;
2469
- }
2470
- });
2471
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
2472
- ...menuScope,
2473
- virtualRef
2474
- });
2475
- };
2476
- DropdownMenuVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME;
2477
- var PORTAL_NAME2 = "DropdownMenuPortal";
2478
- var DropdownMenuPortal = (props) => {
2479
- const { __scopeDropdownMenu, ...portalProps } = props;
2480
- const menuScope = useMenuScope(__scopeDropdownMenu);
2481
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Portal, {
2482
- ...menuScope,
2483
- ...portalProps
2484
- });
2485
- };
2486
- DropdownMenuPortal.displayName = PORTAL_NAME2;
2487
- var DropdownMenuViewport = /* @__PURE__ */ forwardRef19(({ classNames, asChild, children, ...props }, forwardedRef) => {
2488
- const { tx } = useThemeContext();
2489
- const Root7 = asChild ? Slot10 : Primitive10.div;
2490
- return /* @__PURE__ */ React27.createElement(Root7, {
2491
- ...props,
2492
- className: tx("menu.viewport", "menu__viewport", {}, classNames),
2493
- ref: forwardedRef
2494
- }, children);
2495
- });
2496
- var CONTENT_NAME2 = "DropdownMenuContent";
2497
- var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2498
- const { __scopeDropdownMenu, classNames, collisionPadding = 8, ...contentProps } = props;
2499
- const { tx } = useThemeContext();
2500
- const context = useDropdownMenuContext(CONTENT_NAME2, __scopeDropdownMenu);
2501
- const elevation = useElevationContext();
2502
- const menuScope = useMenuScope(__scopeDropdownMenu);
2503
- const hasInteractedOutsideRef = useRef3(false);
2504
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
2505
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Content, {
2506
- id: context.contentId,
2507
- "aria-labelledby": context.triggerId,
2508
- ...menuScope,
2509
- ...contentProps,
2510
- collisionPadding: safeCollisionPadding,
2511
- ref: forwardedRef,
2512
- onCloseAutoFocus: composeEventHandlers2(props.onCloseAutoFocus, (event) => {
2513
- if (!hasInteractedOutsideRef.current) {
2514
- context.triggerRef.current?.focus();
2515
- }
2516
- hasInteractedOutsideRef.current = false;
2517
- event.preventDefault();
2518
- }),
2519
- onInteractOutside: composeEventHandlers2(props.onInteractOutside, (event) => {
2520
- const originalEvent = event.detail.originalEvent;
2521
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
2522
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
2523
- if (!context.modal || isRightClick) {
2524
- hasInteractedOutsideRef.current = true;
2525
- }
2526
- }),
2527
- className: tx("menu.content", "menu", {
2528
- elevation
2529
- }, classNames),
2530
- style: {
2531
- ...props.style,
2532
- // re-namespace exposed content custom properties
2533
- ...{
2534
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2535
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2536
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2537
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2538
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2539
- }
2540
- }
2541
- });
2542
- });
2543
- DropdownMenuContent.displayName = CONTENT_NAME2;
2544
- var GROUP_NAME = "DropdownMenuGroup";
2545
- var DropdownMenuGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2546
- const { __scopeDropdownMenu, ...groupProps } = props;
2547
- const menuScope = useMenuScope(__scopeDropdownMenu);
2548
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Group, {
2549
- ...menuScope,
2550
- ...groupProps,
2551
- ref: forwardedRef
2552
- });
2553
- });
2554
- DropdownMenuGroup.displayName = GROUP_NAME;
2555
- var LABEL_NAME = "DropdownMenuLabel";
2556
- var DropdownMenuGroupLabel = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2557
- const { __scopeDropdownMenu, classNames, ...labelProps } = props;
2558
- const menuScope = useMenuScope(__scopeDropdownMenu);
2559
- const { tx } = useThemeContext();
2560
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Label, {
2561
- ...menuScope,
2562
- ...labelProps,
2563
- className: tx("menu.groupLabel", "menu__group__label", {}, classNames),
2564
- ref: forwardedRef
2565
- });
2566
- });
2567
- DropdownMenuGroupLabel.displayName = LABEL_NAME;
2568
- var ITEM_NAME = "DropdownMenuItem";
2569
- var DropdownMenuItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2570
- const { __scopeDropdownMenu, classNames, ...itemProps } = props;
2571
- const menuScope = useMenuScope(__scopeDropdownMenu);
2572
- const { tx } = useThemeContext();
2573
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Item, {
2574
- ...menuScope,
2575
- ...itemProps,
2576
- className: tx("menu.item", "menu__item", {}, classNames),
2577
- ref: forwardedRef
2578
- });
2579
- });
2580
- DropdownMenuItem.displayName = ITEM_NAME;
2581
- var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
2582
- var DropdownMenuCheckboxItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2583
- const { __scopeDropdownMenu, classNames, ...checkboxItemProps } = props;
2584
- const menuScope = useMenuScope(__scopeDropdownMenu);
2585
- const { tx } = useThemeContext();
2586
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.CheckboxItem, {
2587
- ...menuScope,
2588
- ...checkboxItemProps,
2589
- className: tx("menu.item", "menu__item--checkbox", {}, classNames),
2590
- ref: forwardedRef
2591
- });
2592
- });
2593
- DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
2594
- var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
2595
- var DropdownMenuRadioGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2596
- const { __scopeDropdownMenu, ...radioGroupProps } = props;
2597
- const menuScope = useMenuScope(__scopeDropdownMenu);
2598
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioGroup, {
2599
- ...menuScope,
2600
- ...radioGroupProps,
2601
- ref: forwardedRef
2602
- });
2603
- });
2604
- DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
2605
- var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
2606
- var DropdownMenuRadioItem = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2607
- const { __scopeDropdownMenu, ...radioItemProps } = props;
2608
- const menuScope = useMenuScope(__scopeDropdownMenu);
2609
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.RadioItem, {
2610
- ...menuScope,
2611
- ...radioItemProps,
2612
- ref: forwardedRef
2613
- });
2614
- });
2615
- DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
2616
- var INDICATOR_NAME = "DropdownMenuItemIndicator";
2617
- var DropdownMenuItemIndicator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2618
- const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
2619
- const menuScope = useMenuScope(__scopeDropdownMenu);
2620
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.ItemIndicator, {
2621
- ...menuScope,
2622
- ...itemIndicatorProps,
2623
- ref: forwardedRef
2624
- });
2625
- });
2626
- DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
2627
- var SEPARATOR_NAME = "DropdownMenuSeparator";
2628
- var DropdownMenuSeparator = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2629
- const { __scopeDropdownMenu, classNames, ...separatorProps } = props;
2630
- const menuScope = useMenuScope(__scopeDropdownMenu);
2631
- const { tx } = useThemeContext();
2632
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Separator, {
2633
- ...menuScope,
2634
- ...separatorProps,
2635
- className: tx("menu.separator", "menu__item", {}, classNames),
2636
- ref: forwardedRef
2637
- });
2638
- });
2639
- DropdownMenuSeparator.displayName = SEPARATOR_NAME;
2640
- var ARROW_NAME2 = "DropdownMenuArrow";
2641
- var DropdownMenuArrow = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2642
- const { __scopeDropdownMenu, classNames, ...arrowProps } = props;
2643
- const menuScope = useMenuScope(__scopeDropdownMenu);
2644
- const { tx } = useThemeContext();
2645
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Arrow, {
2646
- ...menuScope,
2647
- ...arrowProps,
2648
- className: tx("menu.arrow", "menu__arrow", {}, classNames),
2649
- ref: forwardedRef
2650
- });
2651
- });
2652
- DropdownMenuArrow.displayName = ARROW_NAME2;
2653
- var DropdownMenuSub = (props) => {
2654
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
2655
- const menuScope = useMenuScope(__scopeDropdownMenu);
2656
- const [open = false, setOpen] = useControllableState5({
2657
- prop: openProp,
2658
- defaultProp: defaultOpen,
2659
- onChange: onOpenChange
2660
- });
2661
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.Sub, {
2662
- ...menuScope,
2663
- open,
2664
- onOpenChange: setOpen
2665
- }, children);
2666
- };
2667
- var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
2668
- var DropdownMenuSubTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2669
- const { __scopeDropdownMenu, ...subTriggerProps } = props;
2670
- const menuScope = useMenuScope(__scopeDropdownMenu);
2671
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubTrigger, {
2672
- ...menuScope,
2673
- ...subTriggerProps,
2674
- ref: forwardedRef
2675
- });
2676
- });
2677
- DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
2678
- var SUB_CONTENT_NAME = "DropdownMenuSubContent";
2679
- var DropdownMenuSubContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
2680
- const { __scopeDropdownMenu, ...subContentProps } = props;
2681
- const menuScope = useMenuScope(__scopeDropdownMenu);
2682
- return /* @__PURE__ */ React27.createElement(MenuPrimitive.SubContent, {
2683
- ...menuScope,
2684
- ...subContentProps,
2685
- ref: forwardedRef,
2686
- style: {
2687
- ...props.style,
2688
- // re-namespace exposed content custom properties
2689
- ...{
2690
- "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
2691
- "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
2692
- "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
2693
- "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
2694
- "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
2695
- }
2696
- }
2697
- });
2698
- });
2699
- DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
2700
- var DropdownMenu = {
2701
- Root: DropdownMenuRoot,
2702
- Trigger: DropdownMenuTrigger,
2703
- VirtualTrigger: DropdownMenuVirtualTrigger,
2704
- Portal: DropdownMenuPortal,
2705
- Content: DropdownMenuContent,
2706
- Viewport: DropdownMenuViewport,
2707
- Group: DropdownMenuGroup,
2708
- GroupLabel: DropdownMenuGroupLabel,
2709
- Item: DropdownMenuItem,
2710
- CheckboxItem: DropdownMenuCheckboxItem,
2711
- RadioGroup: DropdownMenuRadioGroup,
2712
- RadioItem: DropdownMenuRadioItem,
2713
- ItemIndicator: DropdownMenuItemIndicator,
2714
- Separator: DropdownMenuSeparator,
2715
- Arrow: DropdownMenuArrow,
2716
- Sub: DropdownMenuSub,
2717
- SubTrigger: DropdownMenuSubTrigger,
2718
- SubContent: DropdownMenuSubContent
2719
- };
2720
- var useDropdownMenuMenuScope = useMenuScope;
2721
-
2722
- // packages/ui/react-ui/src/components/Message/Message.tsx
2723
- import { createContext as createContext11 } from "@radix-ui/react-context";
2724
- import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
2725
- import { Slot as Slot11 } from "@radix-ui/react-slot";
2726
- import React28, { forwardRef as forwardRef20 } from "react";
2727
- import { useId as useId4 } from "@dxos/react-hooks";
2728
- var MESSAGE_NAME = "Message";
2729
- var [MessageProvider, useMessageContext] = createContext11(MESSAGE_NAME);
2730
- var MessageRoot = /* @__PURE__ */ forwardRef20(({ asChild, valence, elevation: propsElevation, className, titleId: propsTitleId, descriptionId: propsDescriptionId, children, ...props }, forwardedRef) => {
2731
- const { tx } = useThemeContext();
2732
- const titleId = useId4("message__title", propsTitleId);
2733
- const descriptionId = useId4("message__description", propsDescriptionId);
2734
- const elevation = useElevationContext(propsElevation);
2735
- const Root7 = asChild ? Slot11 : Primitive11.div;
2736
- return /* @__PURE__ */ React28.createElement(MessageProvider, {
2737
- titleId,
2738
- descriptionId
2739
- }, /* @__PURE__ */ React28.createElement(Root7, {
2740
- ...props,
2741
- className: tx("message.root", "message", {
2742
- valence,
2743
- elevation
2744
- }, className),
2745
- "aria-labelledby": titleId,
2746
- "aria-describedby": descriptionId,
2747
- ref: forwardedRef
2748
- }, children));
2749
- });
2750
- MessageRoot.displayName = MESSAGE_NAME;
2751
- var MESSAGE_TITLE_NAME = "MessageTitle";
2752
- var MessageTitle = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
2753
- const { tx } = useThemeContext();
2754
- const { titleId } = useMessageContext(MESSAGE_TITLE_NAME);
2755
- const Root7 = asChild ? Slot11 : Primitive11.h2;
2756
- return /* @__PURE__ */ React28.createElement(Root7, {
2757
- ...props,
2758
- className: tx("message.title", "message__title", {}, className),
2759
- id: titleId,
2760
- ref: forwardedRef
2761
- }, children);
2762
- });
2763
- MessageTitle.displayName = MESSAGE_TITLE_NAME;
2764
- var MESSAGE_BODY_NAME = "MessageBody";
2765
- var MessageBody = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
2766
- const { tx } = useThemeContext();
2767
- const { descriptionId } = useMessageContext(MESSAGE_BODY_NAME);
2768
- const Root7 = asChild ? Slot11 : Primitive11.p;
2769
- return /* @__PURE__ */ React28.createElement(Root7, {
2770
- ...props,
2771
- className: tx("message.body", "message__body", {}, className),
2772
- id: descriptionId,
2773
- ref: forwardedRef
2774
- }, children);
2775
- });
2776
- MessageBody.displayName = MESSAGE_BODY_NAME;
2777
- var Message = {
2778
- Root: MessageRoot,
2779
- Title: MessageTitle,
2780
- Body: MessageBody
2781
- };
2782
-
2783
- // packages/ui/react-ui/src/components/Popover/Popover.tsx
2784
- import { composeEventHandlers as composeEventHandlers3 } from "@radix-ui/primitive";
2785
- import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
2786
- import { createContextScope as createContextScope4 } from "@radix-ui/react-context";
2787
- import { DismissableLayer as DismissableLayer2 } from "@radix-ui/react-dismissable-layer";
2788
- import { useFocusGuards } from "@radix-ui/react-focus-guards";
2789
- import { FocusScope } from "@radix-ui/react-focus-scope";
2790
- import { useId as useId5 } from "@radix-ui/react-id";
2791
- import * as PopperPrimitive2 from "@radix-ui/react-popper";
2792
- import { createPopperScope as createPopperScope2 } from "@radix-ui/react-popper";
2793
- import { Portal as PortalPrimitive2 } from "@radix-ui/react-portal";
2794
- import { Presence as Presence2 } from "@radix-ui/react-presence";
2795
- import { Primitive as Primitive12 } from "@radix-ui/react-primitive";
2796
- import { Slot as Slot12 } from "@radix-ui/react-slot";
2797
- import { useControllableState as useControllableState6 } from "@radix-ui/react-use-controllable-state";
2798
- import { hideOthers } from "aria-hidden";
2799
- import React29, { forwardRef as forwardRef21, useRef as useRef4, useCallback as useCallback9, useState as useState8, useEffect as useEffect7 } from "react";
2800
- import { RemoveScroll } from "react-remove-scroll";
2801
- var POPOVER_NAME = "Popover";
2802
- var [createPopoverContext, createPopoverScope] = createContextScope4(POPOVER_NAME, [
2803
- createPopperScope2
2804
- ]);
2805
- var usePopperScope2 = createPopperScope2();
2806
- var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
2807
- var PopoverRoot = (props) => {
2808
- const { __scopePopover, children, open: openProp, defaultOpen, onOpenChange, modal = false } = props;
2809
- const popperScope = usePopperScope2(__scopePopover);
2810
- const triggerRef = useRef4(null);
2811
- const [hasCustomAnchor, setHasCustomAnchor] = useState8(false);
2812
- const [open = false, setOpen] = useControllableState6({
2813
- prop: openProp,
2814
- defaultProp: defaultOpen,
2815
- onChange: onOpenChange
2816
- });
2817
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Root, popperScope, /* @__PURE__ */ React29.createElement(PopoverProvider, {
2818
- scope: __scopePopover,
2819
- contentId: useId5(),
2820
- triggerRef,
2821
- open,
2822
- onOpenChange: setOpen,
2823
- onOpenToggle: useCallback9(() => setOpen((prevOpen) => !prevOpen), [
2824
- setOpen
2825
- ]),
2826
- hasCustomAnchor,
2827
- onCustomAnchorAdd: useCallback9(() => setHasCustomAnchor(true), []),
2828
- onCustomAnchorRemove: useCallback9(() => setHasCustomAnchor(false), []),
2829
- modal
2830
- }, children));
2831
- };
2832
- PopoverRoot.displayName = POPOVER_NAME;
2833
- var ANCHOR_NAME = "PopoverAnchor";
2834
- var PopoverAnchor = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2835
- const { __scopePopover, ...anchorProps } = props;
2836
- const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
2837
- const popperScope = usePopperScope2(__scopePopover);
2838
- const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
2839
- useEffect7(() => {
2840
- onCustomAnchorAdd();
2841
- return () => onCustomAnchorRemove();
2842
- }, [
2843
- onCustomAnchorAdd,
2844
- onCustomAnchorRemove
2845
- ]);
2846
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2847
- ...popperScope,
2848
- ...anchorProps,
2849
- ref: forwardedRef
2850
- });
2851
- });
2852
- PopoverAnchor.displayName = ANCHOR_NAME;
2853
- var TRIGGER_NAME3 = "PopoverTrigger";
2854
- var PopoverTrigger = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2855
- const { __scopePopover, ...triggerProps } = props;
2856
- const context = usePopoverContext(TRIGGER_NAME3, __scopePopover);
2857
- const popperScope = usePopperScope2(__scopePopover);
2858
- const composedTriggerRef = useComposedRefs2(forwardedRef, context.triggerRef);
2859
- const trigger = /* @__PURE__ */ React29.createElement(Primitive12.button, {
2860
- type: "button",
2861
- "aria-haspopup": "dialog",
2862
- "aria-expanded": context.open,
2863
- "aria-controls": context.contentId,
2864
- "data-state": getState(context.open),
2865
- ...triggerProps,
2866
- ref: composedTriggerRef,
2867
- onClick: composeEventHandlers3(props.onClick, context.onOpenToggle)
2868
- });
2869
- return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2870
- asChild: true,
2871
- ...popperScope
2872
- }, trigger);
2873
- });
2874
- PopoverTrigger.displayName = TRIGGER_NAME3;
2875
- var VIRTUAL_TRIGGER_NAME2 = "PopoverVirtualTrigger";
2876
- var PopoverVirtualTrigger = (props) => {
2877
- const { __scopePopover, virtualRef } = props;
2878
- const context = usePopoverContext(VIRTUAL_TRIGGER_NAME2, __scopePopover);
2879
- const popperScope = usePopperScope2(__scopePopover);
2880
- useEffect7(() => {
2881
- if (virtualRef.current) {
2882
- context.triggerRef.current = virtualRef.current;
2883
- }
2884
- });
2885
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
2886
- ...popperScope,
2887
- virtualRef
2888
- });
2889
- };
2890
- PopoverVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME2;
2891
- var PORTAL_NAME3 = "PopoverPortal";
2892
- var [PortalProvider2, usePortalContext2] = createPopoverContext(PORTAL_NAME3, {
2893
- forceMount: void 0
2894
- });
2895
- var PopoverPortal = (props) => {
2896
- const { __scopePopover, forceMount, children, container } = props;
2897
- const context = usePopoverContext(PORTAL_NAME3, __scopePopover);
2898
- return /* @__PURE__ */ React29.createElement(PortalProvider2, {
2899
- scope: __scopePopover,
2900
- forceMount
2901
- }, /* @__PURE__ */ React29.createElement(Presence2, {
2902
- present: forceMount || context.open
2903
- }, /* @__PURE__ */ React29.createElement(PortalPrimitive2, {
2904
- asChild: true,
2905
- container
2906
- }, children)));
2907
- };
2908
- PopoverPortal.displayName = PORTAL_NAME3;
2909
- var CONTENT_NAME3 = "PopoverContent";
2910
- var PopoverContent = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2911
- const portalContext = usePortalContext2(CONTENT_NAME3, props.__scopePopover);
2912
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
2913
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2914
- return /* @__PURE__ */ React29.createElement(Presence2, {
2915
- present: forceMount || context.open
2916
- }, context.modal ? /* @__PURE__ */ React29.createElement(PopoverContentModal, {
2917
- ...contentProps,
2918
- ref: forwardedRef
2919
- }) : /* @__PURE__ */ React29.createElement(PopoverContentNonModal, {
2920
- ...contentProps,
2921
- ref: forwardedRef
2922
- }));
2923
- });
2924
- PopoverContent.displayName = CONTENT_NAME3;
2925
- var PopoverContentModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2926
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2927
- const contentRef = useRef4(null);
2928
- const composedRefs = useComposedRefs2(forwardedRef, contentRef);
2929
- const isRightClickOutsideRef = useRef4(false);
2930
- useEffect7(() => {
2931
- const content = contentRef.current;
2932
- if (content) {
2933
- return hideOthers(content);
2934
- }
2935
- }, []);
2936
- return /* @__PURE__ */ React29.createElement(RemoveScroll, {
2937
- as: Slot12,
2938
- allowPinchZoom: true
2939
- }, /* @__PURE__ */ React29.createElement(PopoverContentImpl, {
2940
- ...props,
2941
- ref: composedRefs,
2942
- // we make sure we're not trapping once it's been closed
2943
- // (closed !== unmounted when animating out)
2944
- trapFocus: context.open,
2945
- disableOutsidePointerEvents: true,
2946
- onCloseAutoFocus: composeEventHandlers3(props.onCloseAutoFocus, (event) => {
2947
- event.preventDefault();
2948
- if (!isRightClickOutsideRef.current) {
2949
- context.triggerRef.current?.focus();
2950
- }
2951
- }),
2952
- onPointerDownOutside: composeEventHandlers3(props.onPointerDownOutside, (event) => {
2953
- const originalEvent = event.detail.originalEvent;
2954
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
2955
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
2956
- isRightClickOutsideRef.current = isRightClick;
2957
- }, {
2958
- checkForDefaultPrevented: false
2959
- }),
2960
- // When focus is trapped, a `focusout` event may still happen.
2961
- // We make sure we don't trigger our `onDismiss` in such case.
2962
- onFocusOutside: composeEventHandlers3(props.onFocusOutside, (event) => event.preventDefault(), {
2963
- checkForDefaultPrevented: false
2964
- })
2965
- }));
2966
- });
2967
- var PopoverContentNonModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
2968
- const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
2969
- const hasInteractedOutsideRef = useRef4(false);
2970
- const hasPointerDownOutsideRef = useRef4(false);
2971
- return /* @__PURE__ */ React29.createElement(PopoverContentImpl, {
2972
- ...props,
2973
- ref: forwardedRef,
2974
- trapFocus: false,
2975
- disableOutsidePointerEvents: false,
2976
- onCloseAutoFocus: (event) => {
2977
- props.onCloseAutoFocus?.(event);
2978
- if (!event.defaultPrevented) {
2979
- if (!hasInteractedOutsideRef.current) {
2980
- context.triggerRef.current?.focus();
2981
- }
2982
- event.preventDefault();
2983
- }
2984
- hasInteractedOutsideRef.current = false;
2985
- hasPointerDownOutsideRef.current = false;
2986
- },
2987
- onInteractOutside: (event) => {
2988
- props.onInteractOutside?.(event);
2989
- if (!event.defaultPrevented) {
2990
- hasInteractedOutsideRef.current = true;
2991
- if (event.detail.originalEvent.type === "pointerdown") {
2992
- hasPointerDownOutsideRef.current = true;
2993
- }
2994
- }
2995
- const target = event.target;
2996
- const targetIsTrigger = context.triggerRef.current?.contains(target);
2997
- if (targetIsTrigger) {
2998
- event.preventDefault();
2999
- }
3000
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
3001
- event.preventDefault();
3002
- }
3003
- }
3004
- });
3005
- });
3006
- var PopoverContentImpl = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3007
- const { __scopePopover, trapFocus, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, collisionPadding = 8, classNames, ...contentProps } = props;
3008
- const context = usePopoverContext(CONTENT_NAME3, __scopePopover);
3009
- const popperScope = usePopperScope2(__scopePopover);
3010
- const { tx } = useThemeContext();
3011
- const elevation = useElevationContext();
3012
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
3013
- useFocusGuards();
3014
- return /* @__PURE__ */ React29.createElement(FocusScope, {
3015
- asChild: true,
3016
- loop: true,
3017
- trapped: trapFocus,
3018
- onMountAutoFocus: onOpenAutoFocus,
3019
- onUnmountAutoFocus: onCloseAutoFocus
3020
- }, /* @__PURE__ */ React29.createElement(DismissableLayer2, {
3021
- asChild: true,
3022
- disableOutsidePointerEvents,
3023
- onInteractOutside,
3024
- onEscapeKeyDown,
3025
- onPointerDownOutside,
3026
- onFocusOutside,
3027
- onDismiss: () => context.onOpenChange(false)
3028
- }, /* @__PURE__ */ React29.createElement(PopperPrimitive2.Content, {
3029
- "data-state": getState(context.open),
3030
- role: "dialog",
3031
- id: context.contentId,
3032
- ...popperScope,
3033
- ...contentProps,
3034
- collisionPadding: safeCollisionPadding,
3035
- className: tx("popover.content", "popover", {
3036
- elevation
3037
- }, classNames),
3038
- ref: forwardedRef,
3039
- style: {
3040
- ...contentProps.style,
3041
- // re-namespace exposed content custom properties
3042
- ...{
3043
- "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
3044
- "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
3045
- "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
3046
- "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
3047
- "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
3048
- }
3049
- }
3050
- })));
3051
- });
3052
- var CLOSE_NAME = "PopoverClose";
3053
- var PopoverClose = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3054
- const { __scopePopover, ...closeProps } = props;
3055
- const context = usePopoverContext(CLOSE_NAME, __scopePopover);
3056
- return /* @__PURE__ */ React29.createElement(Primitive12.button, {
3057
- type: "button",
3058
- ...closeProps,
3059
- ref: forwardedRef,
3060
- onClick: composeEventHandlers3(props.onClick, () => context.onOpenChange(false))
3061
- });
3062
- });
3063
- PopoverClose.displayName = CLOSE_NAME;
3064
- var ARROW_NAME3 = "PopoverArrow";
3065
- var PopoverArrow = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
3066
- const { __scopePopover, classNames, ...arrowProps } = props;
3067
- const popperScope = usePopperScope2(__scopePopover);
3068
- const { tx } = useThemeContext();
3069
- return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Arrow, {
3070
- ...popperScope,
3071
- ...arrowProps,
3072
- className: tx("popover.arrow", "popover__arrow", {}, classNames),
3073
- ref: forwardedRef
3074
- });
3075
- });
3076
- PopoverArrow.displayName = ARROW_NAME3;
3077
- var PopoverViewport = /* @__PURE__ */ forwardRef21(({ classNames, asChild, constrainInline = true, constrainBlock = true, children, ...props }, forwardedRef) => {
3078
- const { tx } = useThemeContext();
3079
- const Root7 = asChild ? Slot12 : Primitive12.div;
3080
- return /* @__PURE__ */ React29.createElement(Root7, {
3081
- ...props,
3082
- className: tx("popover.viewport", "popover__viewport", {
3083
- constrainInline,
3084
- constrainBlock
3085
- }, classNames),
3086
- ref: forwardedRef
3087
- }, children);
3088
- });
3089
- var getState = (open) => open ? "open" : "closed";
3090
- var Popover = {
3091
- Root: PopoverRoot,
3092
- Anchor: PopoverAnchor,
3093
- Trigger: PopoverTrigger,
3094
- VirtualTrigger: PopoverVirtualTrigger,
3095
- Portal: PopoverPortal,
3096
- Content: PopoverContent,
3097
- Close: PopoverClose,
3098
- Arrow: PopoverArrow,
3099
- Viewport: PopoverViewport
3100
- };
3101
-
3102
- // packages/ui/react-ui/src/components/Status/Status.tsx
3103
- import React30, { forwardRef as forwardRef22 } from "react";
3104
- var Status = /* @__PURE__ */ forwardRef22(({ classNames, children, progress = 0, indeterminate, variant, ...props }, forwardedRef) => {
3105
- const { tx } = useThemeContext();
3106
- return /* @__PURE__ */ React30.createElement("span", {
3107
- role: "status",
3108
- ...props,
3109
- className: tx("status.root", "status", {
3110
- indeterminate,
3111
- variant
3112
- }, classNames),
3113
- ref: forwardedRef
3114
- }, /* @__PURE__ */ React30.createElement("span", {
3115
- role: "none",
3116
- className: tx("status.bar", "status__bar", {
3117
- indeterminate,
3118
- variant
3119
- }, classNames),
3120
- ...!indeterminate && {
3121
- style: {
3122
- width: `${Math.round(progress * 100)}%`
3123
- }
3124
- }
3125
- }), children);
3126
- });
3127
-
3128
- // packages/ui/react-ui/src/components/ScrollArea/ScrollArea.tsx
3129
- import { Root as ScrollAreaPrimitiveRoot, Viewport as ScrollAreaPrimitiveViewport, Scrollbar as ScrollAreaPrimitiveScrollbar, Thumb as ScrollAreaPrimitiveThumb, Corner as ScrollAreaPrimitiveCorner } from "@radix-ui/react-scroll-area";
3130
- import React31, { forwardRef as forwardRef23 } from "react";
3131
- var ScrollAreaRoot = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3132
- const { tx } = useThemeContext();
3133
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveRoot, {
3134
- ...props,
3135
- className: tx("scrollArea.root", "scroll-area", {}, classNames),
3136
- ref: forwardedRef
3137
- });
3138
- });
3139
- var ScrollAreaViewport = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3140
- const { tx } = useThemeContext();
3141
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveViewport, {
3142
- ...props,
3143
- className: tx("scrollArea.viewport", "scroll-area", {}, classNames),
3144
- ref: forwardedRef
3145
- });
3146
- });
3147
- var ScrollAreaScrollbar = /* @__PURE__ */ forwardRef23(({ classNames, variant = "fine", ...props }, forwardedRef) => {
3148
- const { tx } = useThemeContext();
3149
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveScrollbar, {
3150
- "data-variant": variant,
3151
- ...props,
3152
- className: tx("scrollArea.scrollbar", "scroll-area__scrollbar", {}, classNames),
3153
- ref: forwardedRef
3154
- });
3155
- });
3156
- var ScrollAreaThumb = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3157
- const { tx } = useThemeContext();
3158
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveThumb, {
3159
- ...props,
3160
- className: tx("scrollArea.thumb", "scroll-area__thumb", {}, classNames),
3161
- ref: forwardedRef
3162
- });
3163
- });
3164
- var ScrollAreaCorner = /* @__PURE__ */ forwardRef23(({ classNames, ...props }, forwardedRef) => {
3165
- const { tx } = useThemeContext();
3166
- return /* @__PURE__ */ React31.createElement(ScrollAreaPrimitiveCorner, {
3167
- ...props,
3168
- className: tx("scrollArea.corner", "scroll-area__corner", {}, classNames),
3169
- ref: forwardedRef
3170
- });
3171
- });
3172
- var ScrollArea = {
3173
- Root: ScrollAreaRoot,
3174
- Viewport: ScrollAreaViewport,
3175
- Scrollbar: ScrollAreaScrollbar,
3176
- Thumb: ScrollAreaThumb,
3177
- Corner: ScrollAreaCorner
3178
- };
3179
-
3180
- // packages/ui/react-ui/src/components/Select/Select.tsx
3181
- import { CaretDown as CaretDown2, CaretUp } from "@phosphor-icons/react";
3182
- import * as SelectPrimitive from "@radix-ui/react-select";
3183
- import React32, { forwardRef as forwardRef24 } from "react";
3184
- var SelectRoot = SelectPrimitive.Root;
3185
- var SelectTrigger = SelectPrimitive.Trigger;
3186
- var SelectValue = SelectPrimitive.Value;
3187
- var SelectIcon = SelectPrimitive.Icon;
3188
- var SelectPortal = SelectPrimitive.Portal;
3189
- var SelectTriggerButton = /* @__PURE__ */ forwardRef24(({ children, placeholder, ...props }, forwardedRef) => {
3190
- const { tx } = useThemeContext();
3191
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Trigger, {
3192
- asChild: true,
3193
- ref: forwardedRef
3194
- }, /* @__PURE__ */ React32.createElement(Button, props, /* @__PURE__ */ React32.createElement(SelectPrimitive.Value, {
3195
- placeholder
3196
- }, children), /* @__PURE__ */ React32.createElement("span", {
3197
- className: "w-1 flex-1"
3198
- }), /* @__PURE__ */ React32.createElement(SelectPrimitive.Icon, {
3199
- asChild: true
3200
- }, /* @__PURE__ */ React32.createElement(CaretDown2, {
3201
- className: tx("select.triggerIcon", "select__trigger__icon", {}),
3202
- weight: "bold"
3203
- }))));
3204
- });
3205
- var SelectContent = /* @__PURE__ */ forwardRef24(({ classNames, children, collisionPadding = 8, ...props }, forwardedRef) => {
3206
- const { tx } = useThemeContext();
3207
- const elevation = useElevationContext();
3208
- const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
3209
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Content, {
3210
- ...props,
3211
- collisionPadding: safeCollisionPadding,
3212
- className: tx("select.content", "select__content", {
3213
- elevation
3214
- }, classNames),
3215
- position: "popper",
3216
- ref: forwardedRef
3217
- }, children);
3218
- });
3219
- var SelectScrollUpButton2 = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3220
- const { tx } = useThemeContext();
3221
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectScrollUpButton, {
3222
- ...props,
3223
- className: tx("select.scrollButton", "select__scroll-button--up", {}, classNames),
3224
- ref: forwardedRef
3225
- }, children ?? /* @__PURE__ */ React32.createElement(CaretUp, {
3226
- weight: "bold"
3227
- }));
3228
- });
3229
- var SelectScrollDownButton2 = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3230
- const { tx } = useThemeContext();
3231
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectScrollDownButton, {
3232
- ...props,
3233
- className: tx("select.scrollButton", "select__scroll-button--down", {}, classNames),
3234
- ref: forwardedRef
3235
- }, children ?? /* @__PURE__ */ React32.createElement(CaretDown2, {
3236
- weight: "bold"
3237
- }));
3238
- });
3239
- var SelectViewport2 = /* @__PURE__ */ forwardRef24(({ classNames, asChild, children, ...props }, forwardedRef) => {
3240
- const { tx } = useThemeContext();
3241
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.SelectViewport, {
3242
- ...props,
3243
- className: tx("select.viewport", "select__viewport", {}, classNames),
3244
- ref: forwardedRef
3245
- }, children);
3246
- });
3247
- var SelectItem = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3248
- const { tx } = useThemeContext();
3249
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Item, {
3250
- ...props,
3251
- className: tx("select.item", "option", {}, classNames),
3252
- ref: forwardedRef
3253
- });
3254
- });
3255
- var SelectItemText = SelectPrimitive.ItemText;
3256
- var SelectItemIndicator = /* @__PURE__ */ forwardRef24(({ classNames, children, ...props }, forwardedRef) => {
3257
- const { tx } = useThemeContext();
3258
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.ItemIndicator, {
3259
- ...props,
3260
- className: tx("select.itemIndicator", "option__indicator", {}, classNames),
3261
- ref: forwardedRef
3262
- }, children);
3263
- });
3264
- var SelectOption = /* @__PURE__ */ forwardRef24(({ children, classNames, ...props }, forwardedRef) => {
3265
- const { tx } = useThemeContext();
3266
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Item, {
3267
- ...props,
3268
- className: tx("select.item", "option", {}, classNames),
3269
- ref: forwardedRef
3270
- }, /* @__PURE__ */ React32.createElement(SelectPrimitive.ItemText, null, children), /* @__PURE__ */ React32.createElement("span", {
3271
- className: "grow w-1"
3272
- }), /* @__PURE__ */ React32.createElement(Icon, {
3273
- icon: "ph--check--regular"
3274
- }));
3275
- });
3276
- var SelectGroup = SelectPrimitive.Group;
3277
- var SelectLabel = SelectPrimitive.Label;
3278
- var SelectSeparator = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3279
- const { tx } = useThemeContext();
3280
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Separator, {
3281
- ...props,
3282
- className: tx("select.separator", "select__separator", {}, classNames),
3283
- ref: forwardedRef
3284
- });
3285
- });
3286
- var SelectArrow = /* @__PURE__ */ forwardRef24(({ classNames, ...props }, forwardedRef) => {
3287
- const { tx } = useThemeContext();
3288
- return /* @__PURE__ */ React32.createElement(SelectPrimitive.Arrow, {
3289
- ...props,
3290
- className: tx("select.arrow", "select__arrow", {}, classNames),
3291
- ref: forwardedRef
3292
- });
3293
- });
3294
- var Select = {
3295
- Root: SelectRoot,
3296
- Trigger: SelectTrigger,
3297
- TriggerButton: SelectTriggerButton,
3298
- Value: SelectValue,
3299
- Icon: SelectIcon,
3300
- Portal: SelectPortal,
3301
- Content: SelectContent,
3302
- ScrollUpButton: SelectScrollUpButton2,
3303
- ScrollDownButton: SelectScrollDownButton2,
3304
- Viewport: SelectViewport2,
3305
- Item: SelectItem,
3306
- ItemText: SelectItemText,
3307
- ItemIndicator: SelectItemIndicator,
3308
- Option: SelectOption,
3309
- Group: SelectGroup,
3310
- Label: SelectLabel,
3311
- Separator: SelectSeparator,
3312
- Arrow: SelectArrow
3313
- };
3314
-
3315
- // packages/ui/react-ui/src/components/Separator/Separator.tsx
3316
- import { Separator as SeparatorPrimitive } from "@radix-ui/react-separator";
3317
- import React33, { forwardRef as forwardRef25 } from "react";
3318
- var Separator4 = /* @__PURE__ */ forwardRef25(({ classNames, orientation = "horizontal", ...props }, forwardedRef) => {
3319
- const { tx } = useThemeContext();
3320
- return /* @__PURE__ */ React33.createElement(SeparatorPrimitive, {
3321
- orientation,
3322
- ...props,
3323
- className: tx("separator.root", "separator", {
3324
- orientation
3325
- }, classNames),
3326
- ref: forwardedRef
3327
- });
3328
- });
3329
-
3330
- // packages/ui/react-ui/src/components/Tag/Tag.tsx
3331
- import { Primitive as Primitive13 } from "@radix-ui/react-primitive";
3332
- import { Slot as Slot13 } from "@radix-ui/react-slot";
3333
- import React34, { forwardRef as forwardRef26 } from "react";
3334
- var Tag = /* @__PURE__ */ forwardRef26(({ asChild, palette = "neutral", classNames, ...props }, forwardedRef) => {
3335
- const { tx } = useThemeContext();
3336
- const Root7 = asChild ? Slot13 : Primitive13.span;
3337
- return /* @__PURE__ */ React34.createElement(Root7, {
3338
- ...props,
3339
- className: tx("tag.root", "dx-tag", {
3340
- palette
3341
- }, classNames),
3342
- "data-hue": palette,
3343
- ref: forwardedRef
3344
- });
3345
- });
3346
-
3347
- // packages/ui/react-ui/src/components/Toast/Toast.tsx
3348
- import { Primitive as Primitive14 } from "@radix-ui/react-primitive";
3349
- import { Slot as Slot14 } from "@radix-ui/react-slot";
3350
- 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";
3351
- import React35, { forwardRef as forwardRef27 } from "react";
3352
- var ToastProvider = ToastProviderPrimitive;
3353
- var ToastViewport = /* @__PURE__ */ forwardRef27(({ classNames, ...props }, forwardedRef) => {
3354
- const { tx } = useThemeContext();
3355
- return /* @__PURE__ */ React35.createElement(ToastViewportPrimitive, {
3356
- className: tx("toast.viewport", "toast-viewport", {}, classNames),
3357
- ref: forwardedRef
3358
- });
3359
- });
3360
- var ToastRoot = /* @__PURE__ */ forwardRef27(({ classNames, children, ...props }, forwardedRef) => {
3361
- const { tx } = useThemeContext();
3362
- return /* @__PURE__ */ React35.createElement(ToastRootPrimitive, {
3363
- ...props,
3364
- className: tx("toast.root", "toast", {}, classNames),
3365
- ref: forwardedRef
3366
- }, /* @__PURE__ */ React35.createElement(ElevationProvider, {
3367
- elevation: "toast"
3368
- }, children));
3369
- });
3370
- var ToastBody = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3371
- const { tx } = useThemeContext();
3372
- const Root7 = asChild ? Slot14 : Primitive14.div;
3373
- return /* @__PURE__ */ React35.createElement(Root7, {
3374
- ...props,
3375
- className: tx("toast.body", "toast__body", {}, classNames),
3376
- ref: forwardedRef
3377
- });
3378
- });
3379
- var ToastTitle = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3380
- const { tx } = useThemeContext();
3381
- const Root7 = asChild ? Slot14 : ToastTitlePrimitive;
3382
- return /* @__PURE__ */ React35.createElement(Root7, {
3383
- ...props,
3384
- className: tx("toast.title", "toast__title", {}, classNames),
3385
- ref: forwardedRef
3386
- });
3387
- });
3388
- var ToastDescription = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3389
- const { tx } = useThemeContext();
3390
- const Root7 = asChild ? Slot14 : ToastDescriptionPrimitive;
3391
- return /* @__PURE__ */ React35.createElement(Root7, {
3392
- ...props,
3393
- className: tx("toast.description", "toast__description", {}, classNames),
3394
- ref: forwardedRef
3395
- });
3396
- });
3397
- var ToastActions = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
3398
- const { tx } = useThemeContext();
3399
- const Root7 = asChild ? Slot14 : Primitive14.div;
3400
- return /* @__PURE__ */ React35.createElement(Root7, {
3401
- ...props,
3402
- className: tx("toast.actions", "toast__actions", {}, classNames),
3403
- ref: forwardedRef
3404
- });
3405
- });
3406
- var ToastAction = ToastActionPrimitive;
3407
- var ToastClose = ToastClosePrimitive;
3408
- var Toast = {
3409
- Provider: ToastProvider,
3410
- Viewport: ToastViewport,
3411
- Root: ToastRoot,
3412
- Body: ToastBody,
3413
- Title: ToastTitle,
3414
- Description: ToastDescription,
3415
- Actions: ToastActions,
3416
- Action: ToastAction,
3417
- Close: ToastClose
3418
- };
3419
-
3420
- // packages/ui/react-ui/src/components/Toolbar/Toolbar.tsx
3421
- import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
3422
- import React36, { forwardRef as forwardRef28 } from "react";
3423
- var ToolbarRoot = /* @__PURE__ */ forwardRef28(({ classNames, children, ...props }, forwardedRef) => {
3424
- const { tx } = useThemeContext();
3425
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Root, {
3426
- ...props,
3427
- className: tx("toolbar.root", "toolbar", {}, classNames),
3428
- ref: forwardedRef
3429
- }, children);
3430
- });
3431
- var ToolbarButton = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3432
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3433
- asChild: true
3434
- }, /* @__PURE__ */ React36.createElement(Button, {
3435
- ...props,
3436
- ref: forwardedRef
3437
- }));
3438
- });
3439
- var ToolbarIconButton = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3440
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3441
- asChild: true
3442
- }, /* @__PURE__ */ React36.createElement(IconButton, {
3443
- ...props,
3444
- ref: forwardedRef
3445
- }));
3446
- });
3447
- var ToolbarToggle = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3448
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Button, {
3449
- asChild: true
3450
- }, /* @__PURE__ */ React36.createElement(Toggle, {
3451
- ...props,
3452
- ref: forwardedRef
3453
- }));
3454
- });
3455
- var ToolbarLink = /* @__PURE__ */ forwardRef28((props, forwardedRef) => {
3456
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Link, {
3457
- asChild: true
3458
- }, /* @__PURE__ */ React36.createElement(Link, {
3459
- ...props,
3460
- ref: forwardedRef
3461
- }));
3462
- });
3463
- var ToolbarToggleGroup2 = /* @__PURE__ */ forwardRef28(({ classNames, children, elevation, ...props }, forwardedRef) => {
3464
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleGroup, {
3465
- ...props,
3466
- asChild: true
3467
- }, /* @__PURE__ */ React36.createElement(ButtonGroup, {
3468
- classNames,
3469
- children,
3470
- elevation,
3471
- ref: forwardedRef
3472
- }));
3473
- });
3474
- var ToolbarToggleGroupItem = /* @__PURE__ */ forwardRef28(({ variant, density, elevation, classNames, children, ...props }, forwardedRef) => {
3475
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleItem, {
3476
- ...props,
3477
- asChild: true
3478
- }, /* @__PURE__ */ React36.createElement(Button, {
3479
- variant,
3480
- density,
3481
- elevation,
3482
- classNames,
3483
- children,
3484
- ref: forwardedRef
3485
- }));
3486
- });
3487
- var ToolbarToggleGroupIconItem = /* @__PURE__ */ forwardRef28(({ variant, density, elevation, classNames, icon, label, iconOnly, ...props }, forwardedRef) => {
3488
- return /* @__PURE__ */ React36.createElement(ToolbarPrimitive.ToolbarToggleItem, {
3489
- ...props,
3490
- asChild: true
3491
- }, /* @__PURE__ */ React36.createElement(IconButton, {
3492
- variant,
3493
- density,
3494
- elevation,
3495
- classNames,
3496
- icon,
3497
- label,
3498
- iconOnly,
3499
- ref: forwardedRef
3500
- }));
3501
- });
3502
- var ToolbarSeparator = /* @__PURE__ */ forwardRef28(({ variant = "line", ...props }, forwardedRef) => {
3503
- return variant === "line" ? /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Separator, {
3504
- asChild: true
3505
- }, /* @__PURE__ */ React36.createElement(Separator4, {
3506
- ...props,
3507
- ref: forwardedRef
3508
- })) : /* @__PURE__ */ React36.createElement(ToolbarPrimitive.Separator, {
3509
- className: "grow",
3510
- ref: forwardedRef
3511
- });
3512
- });
3513
- var Toolbar = {
3514
- Root: ToolbarRoot,
3515
- Button: ToolbarButton,
3516
- IconButton: ToolbarIconButton,
3517
- Link: ToolbarLink,
3518
- Toggle: ToolbarToggle,
3519
- ToggleGroup: ToolbarToggleGroup2,
3520
- ToggleGroupItem: ToolbarToggleGroupItem,
3521
- ToggleGroupIconItem: ToolbarToggleGroupIconItem,
3522
- Separator: ToolbarSeparator
3523
- };
3524
77
  export {
3525
78
  AlertDialog,
3526
79
  AnchoredOverflow,
@@ -3530,7 +83,7 @@ export {
3530
83
  Button,
3531
84
  ButtonGroup,
3532
85
  Clipboard,
3533
- ContextMenu2 as ContextMenu,
86
+ ContextMenu,
3534
87
  DensityContext,
3535
88
  DensityProvider,
3536
89
  Dialog,
@@ -3550,7 +103,7 @@ export {
3550
103
  Popover,
3551
104
  ScrollArea,
3552
105
  Select,
3553
- Separator4 as Separator,
106
+ Separator,
3554
107
  Status,
3555
108
  Tag,
3556
109
  ThemeContext,