@dxos/react-ui 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f

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