@traefik-labs/faency 13.3.0 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/components/Alert/Alert.cjs.map +1 -1
  2. package/dist/components/Alert/Alert.js.map +1 -1
  3. package/dist/components/AriaTable/AriaTable.cjs +15 -5
  4. package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
  5. package/dist/components/AriaTable/AriaTable.js +16 -6
  6. package/dist/components/AriaTable/AriaTable.js.map +1 -1
  7. package/dist/components/Badge/Badge.vanilla.css.cjs.map +1 -1
  8. package/dist/components/Badge/Badge.vanilla.css.js.map +1 -1
  9. package/dist/components/Card/Card.cjs.map +1 -1
  10. package/dist/components/Card/Card.js.map +1 -1
  11. package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
  12. package/dist/components/CodeBlock/CodeBlock.js +2 -2
  13. package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +3 -3
  14. package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -3
  15. package/dist/components/Combobox/Combobox.vanilla.cjs +170 -0
  16. package/dist/components/Combobox/Combobox.vanilla.cjs.map +1 -0
  17. package/dist/components/Combobox/Combobox.vanilla.css.cjs +33 -0
  18. package/dist/components/Combobox/Combobox.vanilla.css.cjs.map +1 -0
  19. package/dist/components/Combobox/Combobox.vanilla.css.js +29 -0
  20. package/dist/components/Combobox/Combobox.vanilla.css.js.map +1 -0
  21. package/dist/components/Combobox/Combobox.vanilla.js +167 -0
  22. package/dist/components/Combobox/Combobox.vanilla.js.map +1 -0
  23. package/dist/components/DateTimePicker/DateTimePicker.cjs +1 -1
  24. package/dist/components/DateTimePicker/DateTimePicker.js +1 -1
  25. package/dist/components/Dialog/Dialog.cjs +1 -1
  26. package/dist/components/Dialog/Dialog.js +1 -1
  27. package/dist/components/Field/Field.cjs +80 -33
  28. package/dist/components/Field/Field.cjs.map +1 -1
  29. package/dist/components/Field/Field.js +80 -33
  30. package/dist/components/Field/Field.js.map +1 -1
  31. package/dist/components/Field/Field.vanilla.cjs +62 -32
  32. package/dist/components/Field/Field.vanilla.cjs.map +1 -1
  33. package/dist/components/Field/Field.vanilla.css.cjs +6 -0
  34. package/dist/components/Field/Field.vanilla.css.cjs.map +1 -1
  35. package/dist/components/Field/Field.vanilla.css.js +4 -1
  36. package/dist/components/Field/Field.vanilla.css.js.map +1 -1
  37. package/dist/components/Field/Field.vanilla.js +63 -33
  38. package/dist/components/Field/Field.vanilla.js.map +1 -1
  39. package/dist/components/Field/FieldContext.cjs +48 -10
  40. package/dist/components/Field/FieldContext.cjs.map +1 -1
  41. package/dist/components/Field/FieldContext.js +48 -10
  42. package/dist/components/Field/FieldContext.js.map +1 -1
  43. package/dist/components/List/List.cjs +1 -1
  44. package/dist/components/List/List.js +1 -1
  45. package/dist/components/Meter/Meter.vanilla.cjs +74 -0
  46. package/dist/components/Meter/Meter.vanilla.cjs.map +1 -0
  47. package/dist/components/Meter/Meter.vanilla.css.cjs +26 -0
  48. package/dist/components/Meter/Meter.vanilla.css.cjs.map +1 -0
  49. package/dist/components/Meter/Meter.vanilla.css.js +21 -0
  50. package/dist/components/Meter/Meter.vanilla.css.js.map +1 -0
  51. package/dist/components/Meter/Meter.vanilla.js +72 -0
  52. package/dist/components/Meter/Meter.vanilla.js.map +1 -0
  53. package/dist/components/NavigationTree/NavigationTreeItem.cjs +2 -2
  54. package/dist/components/NavigationTree/NavigationTreeItem.js +2 -2
  55. package/dist/components/RowLink/RowLink.cjs +35 -12
  56. package/dist/components/RowLink/RowLink.cjs.map +1 -1
  57. package/dist/components/RowLink/RowLink.js +34 -12
  58. package/dist/components/RowLink/RowLink.js.map +1 -1
  59. package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs +57 -0
  60. package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs.map +1 -0
  61. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs +35 -0
  62. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs.map +1 -0
  63. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js +34 -0
  64. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js.map +1 -0
  65. package/dist/components/SegmentedControl/SegmentedControl.vanilla.js +53 -0
  66. package/dist/components/SegmentedControl/SegmentedControl.vanilla.js.map +1 -0
  67. package/dist/components/Select/Select.cjs +1 -1
  68. package/dist/components/Select/Select.js +1 -1
  69. package/dist/components/Spinner/Spinner.vanilla.cjs +50 -0
  70. package/dist/components/Spinner/Spinner.vanilla.cjs.map +1 -0
  71. package/dist/components/Spinner/Spinner.vanilla.css.cjs +21 -0
  72. package/dist/components/Spinner/Spinner.vanilla.css.cjs.map +1 -0
  73. package/dist/components/Spinner/Spinner.vanilla.css.js +19 -0
  74. package/dist/components/Spinner/Spinner.vanilla.css.js.map +1 -0
  75. package/dist/components/Spinner/Spinner.vanilla.js +48 -0
  76. package/dist/components/Spinner/Spinner.vanilla.js.map +1 -0
  77. package/dist/components/SplitLayout/SplitLayout.vanilla.cjs +214 -0
  78. package/dist/components/SplitLayout/SplitLayout.vanilla.cjs.map +1 -0
  79. package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs +14 -0
  80. package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs.map +1 -0
  81. package/dist/components/SplitLayout/SplitLayout.vanilla.css.js +10 -0
  82. package/dist/components/SplitLayout/SplitLayout.vanilla.css.js.map +1 -0
  83. package/dist/components/SplitLayout/SplitLayout.vanilla.js +210 -0
  84. package/dist/components/SplitLayout/SplitLayout.vanilla.js.map +1 -0
  85. package/dist/components/Table/Table.cjs +13 -4
  86. package/dist/components/Table/Table.cjs.map +1 -1
  87. package/dist/components/Table/Table.js +13 -4
  88. package/dist/components/Table/Table.js.map +1 -1
  89. package/dist/components/TextField/TextField.cjs +1 -1
  90. package/dist/components/TextField/TextField.js +1 -1
  91. package/dist/components/TextField/TextField.vanilla.cjs +1 -1
  92. package/dist/components/TextField/TextField.vanilla.js +1 -1
  93. package/dist/components/Textarea/Textarea.cjs +2 -2
  94. package/dist/components/Textarea/Textarea.js +2 -2
  95. package/dist/components/Textarea/Textarea.vanilla.cjs +2 -2
  96. package/dist/components/Textarea/Textarea.vanilla.js +2 -2
  97. package/dist/components/Toast/Toast.vanilla.cjs +96 -0
  98. package/dist/components/Toast/Toast.vanilla.cjs.map +1 -0
  99. package/dist/components/Toast/Toast.vanilla.css.cjs +44 -0
  100. package/dist/components/Toast/Toast.vanilla.css.cjs.map +1 -0
  101. package/dist/components/Toast/Toast.vanilla.css.js +37 -0
  102. package/dist/components/Toast/Toast.vanilla.css.js.map +1 -0
  103. package/dist/components/Toast/Toast.vanilla.js +90 -0
  104. package/dist/components/Toast/Toast.vanilla.js.map +1 -0
  105. package/dist/components/Toast/ToastProvider.vanilla.cjs +98 -0
  106. package/dist/components/Toast/ToastProvider.vanilla.cjs.map +1 -0
  107. package/dist/components/Toast/ToastProvider.vanilla.js +94 -0
  108. package/dist/components/Toast/ToastProvider.vanilla.js.map +1 -0
  109. package/dist/faency.css +3315 -2335
  110. package/dist/index.cjs +55 -32
  111. package/dist/index.d.ts +809 -14
  112. package/dist/index.js +41 -33
  113. package/dist/styles/cssProps.cjs +3 -10
  114. package/dist/styles/cssProps.cjs.map +1 -1
  115. package/dist/styles/cssProps.js +3 -10
  116. package/dist/styles/cssProps.js.map +1 -1
  117. package/dist/styles/resolveColor.cjs +18 -0
  118. package/dist/styles/resolveColor.cjs.map +1 -0
  119. package/dist/styles/resolveColor.js +18 -0
  120. package/dist/styles/resolveColor.js.map +1 -0
  121. package/dist/styles/themes.css.cjs.map +1 -1
  122. package/dist/styles/themes.css.js.map +1 -1
  123. package/dist/styles/tokens.css.cjs +484 -0
  124. package/dist/styles/tokens.css.cjs.map +1 -0
  125. package/dist/styles/tokens.css.js +484 -0
  126. package/dist/styles/tokens.css.js.map +1 -0
  127. package/dist/utils/warnOnce.cjs +13 -0
  128. package/dist/utils/warnOnce.cjs.map +1 -0
  129. package/dist/utils/warnOnce.js +13 -0
  130. package/dist/utils/warnOnce.js.map +1 -0
  131. package/package.json +12 -25
@@ -0,0 +1,96 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_cssProps = require("../../styles/cssProps.cjs");
3
+ const require_themeContext = require("../../styles/themeContext.cjs");
4
+ const require_Button_vanilla = require("../Button/Button.vanilla.cjs");
5
+ const require_IconButton_vanilla = require("../IconButton/IconButton.vanilla.cjs");
6
+ const require_Toast_vanilla_css = require("./Toast.vanilla.css.cjs");
7
+ let _radix_ui_react_icons = require("@radix-ui/react-icons");
8
+ let react = require("react");
9
+ react = require_runtime.__toESM(react, 1);
10
+ let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ let _radix_ui_react_toast = require("@radix-ui/react-toast");
13
+ _radix_ui_react_toast = require_runtime.__toESM(_radix_ui_react_toast, 1);
14
+ // components/Toast/Toast.vanilla.tsx
15
+ var DEFAULT_ICONS = {
16
+ gray: null,
17
+ info: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.InfoCircledIcon, {}),
18
+ success: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CheckCircledIcon, {}),
19
+ warning: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.ExclamationTriangleIcon, {}),
20
+ error: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CrossCircledIcon, {})
21
+ };
22
+ var joinClassNames = (...classNames) => classNames.filter(Boolean).join(" ");
23
+ var useCssProp = (css, style) => {
24
+ const { colors } = require_themeContext.useVanillaExtractTheme();
25
+ const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
26
+ return {
27
+ ...cssStyles,
28
+ ...style,
29
+ ...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
30
+ };
31
+ };
32
+ var ToastVanilla = (0, react.forwardRef)(({ variant = "gray", icon, closeLabel = "Close", type, className, css, style, children, ...props }, ref) => {
33
+ const mergedStyles = useCssProp(css, style);
34
+ const resolvedIcon = icon === void 0 ? DEFAULT_ICONS[variant] : icon;
35
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_toast.Root, {
36
+ ref,
37
+ type: type ?? (variant === "error" ? "foreground" : "background"),
38
+ className: joinClassNames(require_Toast_vanilla_css.toastRoot, className),
39
+ style: mergedStyles,
40
+ ...props,
41
+ children: [
42
+ resolvedIcon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
43
+ className: require_Toast_vanilla_css.toastIconRecipe({ variant }),
44
+ "aria-hidden": true,
45
+ children: resolvedIcon
46
+ }) : null,
47
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
48
+ className: require_Toast_vanilla_css.toastContent,
49
+ children
50
+ }),
51
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Close, {
52
+ asChild: true,
53
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_IconButton_vanilla.IconButtonVanilla, {
54
+ size: "1",
55
+ "aria-label": closeLabel,
56
+ className: require_Toast_vanilla_css.toastClose,
57
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.Cross2Icon, { "aria-hidden": true })
58
+ })
59
+ })
60
+ ]
61
+ });
62
+ });
63
+ ToastVanilla.displayName = "ToastVanilla";
64
+ var ToastTitleVanilla = (0, react.forwardRef)(({ className, css, style, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Title, {
65
+ ref,
66
+ className: joinClassNames(require_Toast_vanilla_css.toastTitle, className),
67
+ style: useCssProp(css, style),
68
+ ...props
69
+ }));
70
+ ToastTitleVanilla.displayName = "ToastTitleVanilla";
71
+ var ToastDescriptionVanilla = (0, react.forwardRef)(({ className, css, style, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Description, {
72
+ ref,
73
+ className: joinClassNames(require_Toast_vanilla_css.toastDescription, className),
74
+ style: useCssProp(css, style),
75
+ ...props
76
+ }));
77
+ ToastDescriptionVanilla.displayName = "ToastDescriptionVanilla";
78
+ var ToastActionVanilla = (0, react.forwardRef)(({ altText, className, css, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Action, {
79
+ altText,
80
+ asChild: true,
81
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button_vanilla.ButtonVanilla, {
82
+ ref,
83
+ variant: "secondary",
84
+ size: "small",
85
+ css,
86
+ className: joinClassNames(require_Toast_vanilla_css.toastAction, className),
87
+ ...props
88
+ })
89
+ }));
90
+ ToastActionVanilla.displayName = "ToastActionVanilla";
91
+ exports.ToastActionVanilla = ToastActionVanilla;
92
+ exports.ToastDescriptionVanilla = ToastDescriptionVanilla;
93
+ exports.ToastTitleVanilla = ToastTitleVanilla;
94
+ exports.ToastVanilla = ToastVanilla;
95
+
96
+ //# sourceMappingURL=Toast.vanilla.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.vanilla.cjs","names":["InfoCircledIcon","CheckCircledIcon","ExclamationTriangleIcon","CrossCircledIcon","useVanillaExtractTheme","processCSSProp","assignInlineVars","forwardRef","ToastPrimitive","toastRoot","toastIconRecipe","toastContent","IconButtonVanilla","toastClose","Cross2Icon","toastTitle","toastDescription","ButtonVanilla","toastAction"],"sources":["../../../components/Toast/Toast.vanilla.tsx"],"sourcesContent":["import {\n CheckCircledIcon,\n Cross2Icon,\n CrossCircledIcon,\n ExclamationTriangleIcon,\n InfoCircledIcon,\n} from '@radix-ui/react-icons';\nimport * as ToastPrimitive from '@radix-ui/react-toast';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { ComponentPropsWithoutRef, forwardRef, ReactNode } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { ButtonVanilla } from '../Button/Button.vanilla';\nimport { IconButtonVanilla } from '../IconButton/IconButton.vanilla';\nimport {\n toastAction,\n toastClose,\n toastContent,\n toastDescription,\n toastIconRecipe,\n toastRoot,\n toastTitle,\n ToastVariant,\n} from './Toast.vanilla.css';\n\nexport type { ToastVariant };\n\nconst DEFAULT_ICONS: Record<ToastVariant, ReactNode> = {\n gray: null,\n info: <InfoCircledIcon />,\n success: <CheckCircledIcon />,\n warning: <ExclamationTriangleIcon />,\n error: <CrossCircledIcon />,\n};\n\nconst joinClassNames = (...classNames: (string | undefined)[]) =>\n classNames.filter(Boolean).join(' ');\n\nconst useCssProp = (css: CSSProps['css'], style?: React.CSSProperties) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n return { ...cssStyles, ...style, ...assignInlineVars(vars) };\n};\n\nexport interface ToastVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Root>, 'asChild'>, CSSProps {\n variant?: ToastVariant;\n /** Replaces the variant icon. Pass `null` to show no icon. */\n icon?: ReactNode;\n closeLabel?: string;\n}\n\nexport const ToastVanilla = forwardRef<HTMLLIElement, ToastVanillaProps>(\n (\n {\n variant = 'gray',\n icon,\n closeLabel = 'Close',\n type,\n className,\n css,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const mergedStyles = useCssProp(css, style);\n const resolvedIcon = icon === undefined ? DEFAULT_ICONS[variant] : icon;\n\n return (\n <ToastPrimitive.Root\n ref={ref}\n type={type ?? (variant === 'error' ? 'foreground' : 'background')}\n className={joinClassNames(toastRoot, className)}\n style={mergedStyles}\n {...props}\n >\n {resolvedIcon ? (\n <span className={toastIconRecipe({ variant })} aria-hidden>\n {resolvedIcon}\n </span>\n ) : null}\n <div className={toastContent}>{children}</div>\n <ToastPrimitive.Close asChild>\n <IconButtonVanilla size=\"1\" aria-label={closeLabel} className={toastClose}>\n <Cross2Icon aria-hidden />\n </IconButtonVanilla>\n </ToastPrimitive.Close>\n </ToastPrimitive.Root>\n );\n },\n);\n\nToastVanilla.displayName = 'ToastVanilla';\n\nexport interface ToastTitleVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Title>, 'asChild'>, CSSProps {}\n\nexport const ToastTitleVanilla = forwardRef<HTMLDivElement, ToastTitleVanillaProps>(\n ({ className, css, style, ...props }, ref) => (\n <ToastPrimitive.Title\n ref={ref}\n className={joinClassNames(toastTitle, className)}\n style={useCssProp(css, style)}\n {...props}\n />\n ),\n);\n\nToastTitleVanilla.displayName = 'ToastTitleVanilla';\n\nexport interface ToastDescriptionVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Description>, 'asChild'>, CSSProps {}\n\nexport const ToastDescriptionVanilla = forwardRef<HTMLDivElement, ToastDescriptionVanillaProps>(\n ({ className, css, style, ...props }, ref) => (\n <ToastPrimitive.Description\n ref={ref}\n className={joinClassNames(toastDescription, className)}\n style={useCssProp(css, style)}\n {...props}\n />\n ),\n);\n\nToastDescriptionVanilla.displayName = 'ToastDescriptionVanilla';\n\nexport interface ToastActionVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Action>, 'asChild'>, CSSProps {}\n\nexport const ToastActionVanilla = forwardRef<HTMLButtonElement, ToastActionVanillaProps>(\n ({ altText, className, css, ...props }, ref) => (\n <ToastPrimitive.Action altText={altText} asChild>\n <ButtonVanilla\n ref={ref}\n variant=\"secondary\"\n size=\"small\"\n css={css}\n className={joinClassNames(toastAction, className)}\n {...props}\n />\n </ToastPrimitive.Action>\n ),\n);\n\nToastActionVanilla.displayName = 'ToastActionVanilla';\n"],"mappings":"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"}
@@ -0,0 +1,44 @@
1
+ ;/* empty css */
2
+ let _vanilla_extract_recipes_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
3
+ // components/Toast/Toast.vanilla.css.ts
4
+ var toastViewportRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
5
+ defaultClassName: "av46n5",
6
+ variantClassNames: { position: {
7
+ "top-left": "av46n6",
8
+ "top-center": "av46n7",
9
+ "top-right": "av46n8",
10
+ "bottom-left": "av46n9",
11
+ "bottom-center": "av46na",
12
+ "bottom-right": "av46nb"
13
+ } },
14
+ defaultVariants: { position: "bottom-right" },
15
+ compoundVariants: []
16
+ });
17
+ var toastRoot = "av46nc";
18
+ var toastIconRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
19
+ defaultClassName: "av46nd",
20
+ variantClassNames: { variant: {
21
+ gray: "av46ne",
22
+ info: "av46nf",
23
+ success: "av46ng",
24
+ warning: "av46nh",
25
+ error: "av46ni"
26
+ } },
27
+ defaultVariants: { variant: "gray" },
28
+ compoundVariants: []
29
+ });
30
+ var toastContent = "av46nj";
31
+ var toastTitle = "av46nk";
32
+ var toastDescription = "av46nl";
33
+ var toastAction = "av46nm";
34
+ var toastClose = "av46nn";
35
+ exports.toastAction = toastAction;
36
+ exports.toastClose = toastClose;
37
+ exports.toastContent = toastContent;
38
+ exports.toastDescription = toastDescription;
39
+ exports.toastIconRecipe = toastIconRecipe;
40
+ exports.toastRoot = toastRoot;
41
+ exports.toastTitle = toastTitle;
42
+ exports.toastViewportRecipe = toastViewportRecipe;
43
+
44
+ //# sourceMappingURL=Toast.vanilla.css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.vanilla.css.cjs","names":["_7a468"],"sources":["../../../components/Toast/Toast.vanilla.css.ts"],"sourcesContent":["import { createVar, keyframes, style } from '@vanilla-extract/css';\nimport { recipe, RecipeVariants } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\nconst enterX = createVar();\nconst enterY = createVar();\n\nconst slideIn = keyframes({\n from: { opacity: 0, transform: `translate(${enterX}, ${enterY})` },\n to: { opacity: 1, transform: 'translate(0, 0)' },\n});\n\nconst fadeOut = keyframes({\n from: { opacity: 1 },\n to: { opacity: 0 },\n});\n\nconst swipeOut = keyframes({\n from: {\n transform: 'translate(var(--radix-toast-swipe-end-x), var(--radix-toast-swipe-end-y))',\n },\n to: { transform: `translate(${enterX}, ${enterY})` },\n});\n\nexport const toastViewportRecipe = recipe({\n base: {\n position: 'fixed',\n zIndex: tokens.zIndices.max,\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.space['2'],\n boxSizing: 'border-box',\n width: '380px',\n maxWidth: '100vw',\n margin: 0,\n padding: tokens.space['5'],\n listStyle: 'none',\n outline: 'none',\n pointerEvents: 'none',\n vars: { [enterX]: '0', [enterY]: '0' },\n },\n\n variants: {\n position: {\n 'top-left': { top: 0, left: 0, vars: { [enterX]: '-100%' } },\n 'top-center': {\n top: 0,\n left: '50%',\n transform: 'translateX(-50%)',\n vars: { [enterY]: '-100%' },\n },\n 'top-right': { top: 0, right: 0, vars: { [enterX]: '100%' } },\n 'bottom-left': { bottom: 0, left: 0, vars: { [enterX]: '-100%' } },\n 'bottom-center': {\n bottom: 0,\n left: '50%',\n transform: 'translateX(-50%)',\n vars: { [enterY]: '100%' },\n },\n 'bottom-right': { bottom: 0, right: 0, vars: { [enterX]: '100%' } },\n },\n },\n\n defaultVariants: {\n position: 'bottom-right',\n },\n});\n\nexport type ToastPosition = NonNullable<\n NonNullable<RecipeVariants<typeof toastViewportRecipe>>['position']\n>;\n\nexport const toastRoot = style({\n boxSizing: 'border-box',\n position: 'relative',\n display: 'flex',\n alignItems: 'flex-start',\n gap: tokens.space['2'],\n padding: tokens.space['3'],\n backgroundColor: tokens.colors.cardBackground,\n border: `1px solid ${tokens.colors.toastBorder}`,\n borderRadius: tokens.radii['3'],\n color: tokens.colors.hiContrast,\n fontFamily: tokens.fonts.rubik,\n pointerEvents: 'auto',\n\n selectors: {\n '&:focus-visible': {\n outline: `2px solid ${tokens.colors.focusOutline}`,\n outlineOffset: '2px',\n },\n '&[data-state=\"open\"]': {\n animation: `${slideIn} 200ms cubic-bezier(0.16, 1, 0.3, 1)`,\n },\n '&[data-state=\"closed\"]': {\n animation: `${fadeOut} 150ms ease-in`,\n },\n '&[data-swipe=\"move\"]': {\n transform: 'translate(var(--radix-toast-swipe-move-x), var(--radix-toast-swipe-move-y))',\n },\n '&[data-swipe=\"cancel\"]': {\n transform: 'translate(0, 0)',\n transition: 'transform 200ms ease-out',\n },\n '&[data-swipe=\"end\"]': {\n animation: `${swipeOut} 100ms ease-out`,\n },\n },\n\n '@media': {\n [breakpoints.motion]: {\n selectors: {\n '&[data-state=\"open\"], &[data-state=\"closed\"], &[data-swipe=\"end\"]': {\n animation: 'none',\n },\n '&[data-swipe=\"cancel\"]': {\n transition: 'none',\n },\n },\n },\n },\n});\n\nexport const toastIconRecipe = recipe({\n base: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n flexShrink: 0,\n width: tokens.sizes['4'],\n height: tokens.sizes['4'],\n },\n\n variants: {\n variant: {\n gray: { color: tokens.colors.toneNeutralText },\n info: { color: tokens.colors.toneInfoSolid },\n success: { color: tokens.colors.toneSuccessSolid },\n warning: { color: tokens.colors.toneWarningSolid },\n error: { color: tokens.colors.toneDangerSolid },\n },\n },\n\n defaultVariants: {\n variant: 'gray',\n },\n});\n\nexport type ToastVariant = NonNullable<\n NonNullable<RecipeVariants<typeof toastIconRecipe>>['variant']\n>;\n\nexport const toastContent = style({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'flex-start',\n gap: tokens.space['1'],\n flex: 1,\n minWidth: 0,\n});\n\nexport const toastTitle = style({\n margin: 0,\n fontSize: tokens.fontSizes['3'],\n fontWeight: tokens.fontWeights.medium,\n lineHeight: tokens.sizes['4'],\n color: tokens.colors.hiContrast,\n overflowWrap: 'anywhere',\n});\n\nexport const toastDescription = style({\n margin: 0,\n fontSize: tokens.fontSizes['2'],\n lineHeight: tokens.sizes['4'],\n color: tokens.colors.textDefault,\n overflowWrap: 'anywhere',\n});\n\nexport const toastAction = style({\n marginTop: tokens.space['1'],\n});\n\nexport const toastClose = style({\n flexShrink: 0,\n});\n"],"mappings":""}
@@ -0,0 +1,37 @@
1
+ /* empty css */
2
+ import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
3
+ // components/Toast/Toast.vanilla.css.ts
4
+ var toastViewportRecipe = createRuntimeFn({
5
+ defaultClassName: "av46n5",
6
+ variantClassNames: { position: {
7
+ "top-left": "av46n6",
8
+ "top-center": "av46n7",
9
+ "top-right": "av46n8",
10
+ "bottom-left": "av46n9",
11
+ "bottom-center": "av46na",
12
+ "bottom-right": "av46nb"
13
+ } },
14
+ defaultVariants: { position: "bottom-right" },
15
+ compoundVariants: []
16
+ });
17
+ var toastRoot = "av46nc";
18
+ var toastIconRecipe = createRuntimeFn({
19
+ defaultClassName: "av46nd",
20
+ variantClassNames: { variant: {
21
+ gray: "av46ne",
22
+ info: "av46nf",
23
+ success: "av46ng",
24
+ warning: "av46nh",
25
+ error: "av46ni"
26
+ } },
27
+ defaultVariants: { variant: "gray" },
28
+ compoundVariants: []
29
+ });
30
+ var toastContent = "av46nj";
31
+ var toastTitle = "av46nk";
32
+ var toastDescription = "av46nl";
33
+ var toastAction = "av46nm";
34
+ var toastClose = "av46nn";
35
+ export { toastAction, toastClose, toastContent, toastDescription, toastIconRecipe, toastRoot, toastTitle, toastViewportRecipe };
36
+
37
+ //# sourceMappingURL=Toast.vanilla.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.vanilla.css.js","names":["_7a468"],"sources":["../../../components/Toast/Toast.vanilla.css.ts"],"sourcesContent":["import { createVar, keyframes, style } from '@vanilla-extract/css';\nimport { recipe, RecipeVariants } from '@vanilla-extract/recipes';\n\nimport { breakpoints } from '../../styles/breakpoints.css';\nimport { tokens } from '../../styles/tokens.css';\n\nconst enterX = createVar();\nconst enterY = createVar();\n\nconst slideIn = keyframes({\n from: { opacity: 0, transform: `translate(${enterX}, ${enterY})` },\n to: { opacity: 1, transform: 'translate(0, 0)' },\n});\n\nconst fadeOut = keyframes({\n from: { opacity: 1 },\n to: { opacity: 0 },\n});\n\nconst swipeOut = keyframes({\n from: {\n transform: 'translate(var(--radix-toast-swipe-end-x), var(--radix-toast-swipe-end-y))',\n },\n to: { transform: `translate(${enterX}, ${enterY})` },\n});\n\nexport const toastViewportRecipe = recipe({\n base: {\n position: 'fixed',\n zIndex: tokens.zIndices.max,\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.space['2'],\n boxSizing: 'border-box',\n width: '380px',\n maxWidth: '100vw',\n margin: 0,\n padding: tokens.space['5'],\n listStyle: 'none',\n outline: 'none',\n pointerEvents: 'none',\n vars: { [enterX]: '0', [enterY]: '0' },\n },\n\n variants: {\n position: {\n 'top-left': { top: 0, left: 0, vars: { [enterX]: '-100%' } },\n 'top-center': {\n top: 0,\n left: '50%',\n transform: 'translateX(-50%)',\n vars: { [enterY]: '-100%' },\n },\n 'top-right': { top: 0, right: 0, vars: { [enterX]: '100%' } },\n 'bottom-left': { bottom: 0, left: 0, vars: { [enterX]: '-100%' } },\n 'bottom-center': {\n bottom: 0,\n left: '50%',\n transform: 'translateX(-50%)',\n vars: { [enterY]: '100%' },\n },\n 'bottom-right': { bottom: 0, right: 0, vars: { [enterX]: '100%' } },\n },\n },\n\n defaultVariants: {\n position: 'bottom-right',\n },\n});\n\nexport type ToastPosition = NonNullable<\n NonNullable<RecipeVariants<typeof toastViewportRecipe>>['position']\n>;\n\nexport const toastRoot = style({\n boxSizing: 'border-box',\n position: 'relative',\n display: 'flex',\n alignItems: 'flex-start',\n gap: tokens.space['2'],\n padding: tokens.space['3'],\n backgroundColor: tokens.colors.cardBackground,\n border: `1px solid ${tokens.colors.toastBorder}`,\n borderRadius: tokens.radii['3'],\n color: tokens.colors.hiContrast,\n fontFamily: tokens.fonts.rubik,\n pointerEvents: 'auto',\n\n selectors: {\n '&:focus-visible': {\n outline: `2px solid ${tokens.colors.focusOutline}`,\n outlineOffset: '2px',\n },\n '&[data-state=\"open\"]': {\n animation: `${slideIn} 200ms cubic-bezier(0.16, 1, 0.3, 1)`,\n },\n '&[data-state=\"closed\"]': {\n animation: `${fadeOut} 150ms ease-in`,\n },\n '&[data-swipe=\"move\"]': {\n transform: 'translate(var(--radix-toast-swipe-move-x), var(--radix-toast-swipe-move-y))',\n },\n '&[data-swipe=\"cancel\"]': {\n transform: 'translate(0, 0)',\n transition: 'transform 200ms ease-out',\n },\n '&[data-swipe=\"end\"]': {\n animation: `${swipeOut} 100ms ease-out`,\n },\n },\n\n '@media': {\n [breakpoints.motion]: {\n selectors: {\n '&[data-state=\"open\"], &[data-state=\"closed\"], &[data-swipe=\"end\"]': {\n animation: 'none',\n },\n '&[data-swipe=\"cancel\"]': {\n transition: 'none',\n },\n },\n },\n },\n});\n\nexport const toastIconRecipe = recipe({\n base: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n flexShrink: 0,\n width: tokens.sizes['4'],\n height: tokens.sizes['4'],\n },\n\n variants: {\n variant: {\n gray: { color: tokens.colors.toneNeutralText },\n info: { color: tokens.colors.toneInfoSolid },\n success: { color: tokens.colors.toneSuccessSolid },\n warning: { color: tokens.colors.toneWarningSolid },\n error: { color: tokens.colors.toneDangerSolid },\n },\n },\n\n defaultVariants: {\n variant: 'gray',\n },\n});\n\nexport type ToastVariant = NonNullable<\n NonNullable<RecipeVariants<typeof toastIconRecipe>>['variant']\n>;\n\nexport const toastContent = style({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'flex-start',\n gap: tokens.space['1'],\n flex: 1,\n minWidth: 0,\n});\n\nexport const toastTitle = style({\n margin: 0,\n fontSize: tokens.fontSizes['3'],\n fontWeight: tokens.fontWeights.medium,\n lineHeight: tokens.sizes['4'],\n color: tokens.colors.hiContrast,\n overflowWrap: 'anywhere',\n});\n\nexport const toastDescription = style({\n margin: 0,\n fontSize: tokens.fontSizes['2'],\n lineHeight: tokens.sizes['4'],\n color: tokens.colors.textDefault,\n overflowWrap: 'anywhere',\n});\n\nexport const toastAction = style({\n marginTop: tokens.space['1'],\n});\n\nexport const toastClose = style({\n flexShrink: 0,\n});\n"],"mappings":""}
@@ -0,0 +1,90 @@
1
+ import { processCSSProp } from "../../styles/cssProps.js";
2
+ import { useVanillaExtractTheme } from "../../styles/themeContext.js";
3
+ import { ButtonVanilla } from "../Button/Button.vanilla.js";
4
+ import { IconButtonVanilla } from "../IconButton/IconButton.vanilla.js";
5
+ import { toastAction, toastClose, toastContent, toastDescription, toastIconRecipe, toastRoot, toastTitle } from "./Toast.vanilla.css.js";
6
+ import { CheckCircledIcon, Cross2Icon, CrossCircledIcon, ExclamationTriangleIcon, InfoCircledIcon } from "@radix-ui/react-icons";
7
+ import { forwardRef } from "react";
8
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import * as ToastPrimitive from "@radix-ui/react-toast";
11
+ // components/Toast/Toast.vanilla.tsx
12
+ var DEFAULT_ICONS = {
13
+ gray: null,
14
+ info: /* @__PURE__ */ jsx(InfoCircledIcon, {}),
15
+ success: /* @__PURE__ */ jsx(CheckCircledIcon, {}),
16
+ warning: /* @__PURE__ */ jsx(ExclamationTriangleIcon, {}),
17
+ error: /* @__PURE__ */ jsx(CrossCircledIcon, {})
18
+ };
19
+ var joinClassNames = (...classNames) => classNames.filter(Boolean).join(" ");
20
+ var useCssProp = (css, style) => {
21
+ const { colors } = useVanillaExtractTheme();
22
+ const { style: cssStyles, vars } = processCSSProp(css, colors);
23
+ return {
24
+ ...cssStyles,
25
+ ...style,
26
+ ...assignInlineVars(vars)
27
+ };
28
+ };
29
+ var ToastVanilla = forwardRef(({ variant = "gray", icon, closeLabel = "Close", type, className, css, style, children, ...props }, ref) => {
30
+ const mergedStyles = useCssProp(css, style);
31
+ const resolvedIcon = icon === void 0 ? DEFAULT_ICONS[variant] : icon;
32
+ return /* @__PURE__ */ jsxs(ToastPrimitive.Root, {
33
+ ref,
34
+ type: type ?? (variant === "error" ? "foreground" : "background"),
35
+ className: joinClassNames(toastRoot, className),
36
+ style: mergedStyles,
37
+ ...props,
38
+ children: [
39
+ resolvedIcon ? /* @__PURE__ */ jsx("span", {
40
+ className: toastIconRecipe({ variant }),
41
+ "aria-hidden": true,
42
+ children: resolvedIcon
43
+ }) : null,
44
+ /* @__PURE__ */ jsx("div", {
45
+ className: toastContent,
46
+ children
47
+ }),
48
+ /* @__PURE__ */ jsx(ToastPrimitive.Close, {
49
+ asChild: true,
50
+ children: /* @__PURE__ */ jsx(IconButtonVanilla, {
51
+ size: "1",
52
+ "aria-label": closeLabel,
53
+ className: toastClose,
54
+ children: /* @__PURE__ */ jsx(Cross2Icon, { "aria-hidden": true })
55
+ })
56
+ })
57
+ ]
58
+ });
59
+ });
60
+ ToastVanilla.displayName = "ToastVanilla";
61
+ var ToastTitleVanilla = forwardRef(({ className, css, style, ...props }, ref) => /* @__PURE__ */ jsx(ToastPrimitive.Title, {
62
+ ref,
63
+ className: joinClassNames(toastTitle, className),
64
+ style: useCssProp(css, style),
65
+ ...props
66
+ }));
67
+ ToastTitleVanilla.displayName = "ToastTitleVanilla";
68
+ var ToastDescriptionVanilla = forwardRef(({ className, css, style, ...props }, ref) => /* @__PURE__ */ jsx(ToastPrimitive.Description, {
69
+ ref,
70
+ className: joinClassNames(toastDescription, className),
71
+ style: useCssProp(css, style),
72
+ ...props
73
+ }));
74
+ ToastDescriptionVanilla.displayName = "ToastDescriptionVanilla";
75
+ var ToastActionVanilla = forwardRef(({ altText, className, css, ...props }, ref) => /* @__PURE__ */ jsx(ToastPrimitive.Action, {
76
+ altText,
77
+ asChild: true,
78
+ children: /* @__PURE__ */ jsx(ButtonVanilla, {
79
+ ref,
80
+ variant: "secondary",
81
+ size: "small",
82
+ css,
83
+ className: joinClassNames(toastAction, className),
84
+ ...props
85
+ })
86
+ }));
87
+ ToastActionVanilla.displayName = "ToastActionVanilla";
88
+ export { ToastActionVanilla, ToastDescriptionVanilla, ToastTitleVanilla, ToastVanilla };
89
+
90
+ //# sourceMappingURL=Toast.vanilla.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.vanilla.js","names":[],"sources":["../../../components/Toast/Toast.vanilla.tsx"],"sourcesContent":["import {\n CheckCircledIcon,\n Cross2Icon,\n CrossCircledIcon,\n ExclamationTriangleIcon,\n InfoCircledIcon,\n} from '@radix-ui/react-icons';\nimport * as ToastPrimitive from '@radix-ui/react-toast';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { ComponentPropsWithoutRef, forwardRef, ReactNode } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { ButtonVanilla } from '../Button/Button.vanilla';\nimport { IconButtonVanilla } from '../IconButton/IconButton.vanilla';\nimport {\n toastAction,\n toastClose,\n toastContent,\n toastDescription,\n toastIconRecipe,\n toastRoot,\n toastTitle,\n ToastVariant,\n} from './Toast.vanilla.css';\n\nexport type { ToastVariant };\n\nconst DEFAULT_ICONS: Record<ToastVariant, ReactNode> = {\n gray: null,\n info: <InfoCircledIcon />,\n success: <CheckCircledIcon />,\n warning: <ExclamationTriangleIcon />,\n error: <CrossCircledIcon />,\n};\n\nconst joinClassNames = (...classNames: (string | undefined)[]) =>\n classNames.filter(Boolean).join(' ');\n\nconst useCssProp = (css: CSSProps['css'], style?: React.CSSProperties) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n return { ...cssStyles, ...style, ...assignInlineVars(vars) };\n};\n\nexport interface ToastVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Root>, 'asChild'>, CSSProps {\n variant?: ToastVariant;\n /** Replaces the variant icon. Pass `null` to show no icon. */\n icon?: ReactNode;\n closeLabel?: string;\n}\n\nexport const ToastVanilla = forwardRef<HTMLLIElement, ToastVanillaProps>(\n (\n {\n variant = 'gray',\n icon,\n closeLabel = 'Close',\n type,\n className,\n css,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const mergedStyles = useCssProp(css, style);\n const resolvedIcon = icon === undefined ? DEFAULT_ICONS[variant] : icon;\n\n return (\n <ToastPrimitive.Root\n ref={ref}\n type={type ?? (variant === 'error' ? 'foreground' : 'background')}\n className={joinClassNames(toastRoot, className)}\n style={mergedStyles}\n {...props}\n >\n {resolvedIcon ? (\n <span className={toastIconRecipe({ variant })} aria-hidden>\n {resolvedIcon}\n </span>\n ) : null}\n <div className={toastContent}>{children}</div>\n <ToastPrimitive.Close asChild>\n <IconButtonVanilla size=\"1\" aria-label={closeLabel} className={toastClose}>\n <Cross2Icon aria-hidden />\n </IconButtonVanilla>\n </ToastPrimitive.Close>\n </ToastPrimitive.Root>\n );\n },\n);\n\nToastVanilla.displayName = 'ToastVanilla';\n\nexport interface ToastTitleVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Title>, 'asChild'>, CSSProps {}\n\nexport const ToastTitleVanilla = forwardRef<HTMLDivElement, ToastTitleVanillaProps>(\n ({ className, css, style, ...props }, ref) => (\n <ToastPrimitive.Title\n ref={ref}\n className={joinClassNames(toastTitle, className)}\n style={useCssProp(css, style)}\n {...props}\n />\n ),\n);\n\nToastTitleVanilla.displayName = 'ToastTitleVanilla';\n\nexport interface ToastDescriptionVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Description>, 'asChild'>, CSSProps {}\n\nexport const ToastDescriptionVanilla = forwardRef<HTMLDivElement, ToastDescriptionVanillaProps>(\n ({ className, css, style, ...props }, ref) => (\n <ToastPrimitive.Description\n ref={ref}\n className={joinClassNames(toastDescription, className)}\n style={useCssProp(css, style)}\n {...props}\n />\n ),\n);\n\nToastDescriptionVanilla.displayName = 'ToastDescriptionVanilla';\n\nexport interface ToastActionVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Action>, 'asChild'>, CSSProps {}\n\nexport const ToastActionVanilla = forwardRef<HTMLButtonElement, ToastActionVanillaProps>(\n ({ altText, className, css, ...props }, ref) => (\n <ToastPrimitive.Action altText={altText} asChild>\n <ButtonVanilla\n ref={ref}\n variant=\"secondary\"\n size=\"small\"\n css={css}\n className={joinClassNames(toastAction, className)}\n {...props}\n />\n </ToastPrimitive.Action>\n ),\n);\n\nToastActionVanilla.displayName = 'ToastActionVanilla';\n"],"mappings":";;;;;;;;;;;AA4BA,IAAM,gBAAiD;CACrD,MAAM;CACN,MAAM,oBAAC,iBAAD,CAAkB,CAAA;CACxB,SAAS,oBAAC,kBAAD,CAAmB,CAAA;CAC5B,SAAS,oBAAC,yBAAD,CAA0B,CAAA;CACnC,OAAO,oBAAC,kBAAD,CAAmB,CAAA;AAC5B;AAEA,IAAM,kBAAkB,GAAG,eACzB,WAAW,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AAErC,IAAM,cAAc,KAAsB,UAAgC;CACxE,MAAM,EAAE,WAAW,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAC7D,OAAO;EAAE,GAAG;EAAW,GAAG;EAAO,GAAG,iBAAiB,IAAI;CAAE;AAC7D;AAUA,IAAa,eAAe,YAExB,EACE,UAAU,QACV,MACA,aAAa,SACb,MACA,WACA,KACA,OACA,UACA,GAAG,SAEL,QACG;CACH,MAAM,eAAe,WAAW,KAAK,KAAK;CAC1C,MAAM,eAAe,SAAS,KAAA,IAAY,cAAc,WAAW;CAEnE,OACE,qBAAC,eAAe,MAAhB;EACO;EACL,MAAM,SAAS,YAAY,UAAU,eAAe;EACpD,WAAW,eAAe,WAAW,SAAS;EAC9C,OAAO;EACP,GAAI;EALN,UAAA;GAOG,eACC,oBAAC,QAAD;IAAM,WAAW,gBAAgB,EAAE,QAAQ,CAAC;IAAG,eAAA;IAC5C,UAAA;GACG,CAAA,IACJ;GACJ,oBAAC,OAAD;IAAK,WAAW;IAAe;GAAc,CAAA;GAC7C,oBAAC,eAAe,OAAhB;IAAsB,SAAA;IACpB,UAAA,oBAAC,mBAAD;KAAmB,MAAK;KAAI,cAAY;KAAY,WAAW;KAC7D,UAAA,oBAAC,YAAD,EAAY,eAAA,KAAa,CAAA;IACR,CAAA;GACC,CAAA;EACH;;AAEzB,CACF;AAEA,aAAa,cAAc;AAK3B,IAAa,oBAAoB,YAC9B,EAAE,WAAW,KAAK,OAAO,GAAG,SAAS,QACpC,oBAAC,eAAe,OAAhB;CACO;CACL,WAAW,eAAe,YAAY,SAAS;CAC/C,OAAO,WAAW,KAAK,KAAK;CAC5B,GAAI;AACL,CAAA,CAEL;AAEA,kBAAkB,cAAc;AAKhC,IAAa,0BAA0B,YACpC,EAAE,WAAW,KAAK,OAAO,GAAG,SAAS,QACpC,oBAAC,eAAe,aAAhB;CACO;CACL,WAAW,eAAe,kBAAkB,SAAS;CACrD,OAAO,WAAW,KAAK,KAAK;CAC5B,GAAI;AACL,CAAA,CAEL;AAEA,wBAAwB,cAAc;AAKtC,IAAa,qBAAqB,YAC/B,EAAE,SAAS,WAAW,KAAK,GAAG,SAAS,QACtC,oBAAC,eAAe,QAAhB;CAAgC;CAAS,SAAA;CACvC,UAAA,oBAAC,eAAD;EACO;EACL,SAAQ;EACR,MAAK;EACA;EACL,WAAW,eAAe,aAAa,SAAS;EAChD,GAAI;CACL,CAAA;AACoB,CAAA,CAE3B;AAEA,mBAAmB,cAAc"}
@@ -0,0 +1,98 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_Toast_vanilla = require("./Toast.vanilla.cjs");
3
+ const require_Toast_vanilla_css = require("./Toast.vanilla.css.cjs");
4
+ let react = require("react");
5
+ react = require_runtime.__toESM(react, 1);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let _radix_ui_react_toast = require("@radix-ui/react-toast");
8
+ _radix_ui_react_toast = require_runtime.__toESM(_radix_ui_react_toast, 1);
9
+ // components/Toast/ToastProvider.vanilla.tsx
10
+ var REMOVE_DELAY = 1e3;
11
+ var SWIPE_DIRECTIONS = {
12
+ "top-left": "left",
13
+ "top-center": "up",
14
+ "top-right": "right",
15
+ "bottom-left": "left",
16
+ "bottom-center": "down",
17
+ "bottom-right": "right"
18
+ };
19
+ var ToastContext = (0, react.createContext)(void 0);
20
+ var ToastProviderVanilla = ({ children, position = "bottom-right", duration = 5e3, label = "Notification", closeLabel }) => {
21
+ const [toasts, setToasts] = (0, react.useState)([]);
22
+ const nextIdRef = (0, react.useRef)(0);
23
+ const removeTimersRef = (0, react.useRef)(/* @__PURE__ */ new Map());
24
+ (0, react.useEffect)(() => {
25
+ const timers = removeTimersRef.current;
26
+ return () => timers.forEach(clearTimeout);
27
+ }, []);
28
+ const scheduleRemove = (0, react.useCallback)((id) => {
29
+ if (removeTimersRef.current.has(id)) return;
30
+ removeTimersRef.current.set(id, setTimeout(() => {
31
+ removeTimersRef.current.delete(id);
32
+ setToasts((current) => current.filter((entry) => entry.id !== id));
33
+ }, REMOVE_DELAY));
34
+ }, []);
35
+ const toast = (0, react.useCallback)((options) => {
36
+ nextIdRef.current += 1;
37
+ const id = `toast-${nextIdRef.current}`;
38
+ setToasts((current) => [...current, {
39
+ ...options,
40
+ id,
41
+ open: true
42
+ }]);
43
+ return id;
44
+ }, []);
45
+ (0, react.useEffect)(() => {
46
+ toasts.forEach((entry) => {
47
+ if (!entry.open) scheduleRemove(entry.id);
48
+ });
49
+ }, [toasts, scheduleRemove]);
50
+ const dismiss = (0, react.useCallback)((id) => {
51
+ setToasts((current) => current.map((entry) => entry.open && (id === void 0 || entry.id === id) ? {
52
+ ...entry,
53
+ open: false
54
+ } : entry));
55
+ }, []);
56
+ const value = (0, react.useMemo)(() => ({
57
+ toast,
58
+ dismiss
59
+ }), [toast, dismiss]);
60
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Provider, {
61
+ duration,
62
+ label,
63
+ swipeDirection: SWIPE_DIRECTIONS[position],
64
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToastContext.Provider, {
65
+ value,
66
+ children: [
67
+ children,
68
+ toasts.map(({ id, open, title, description, action, ...options }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Toast_vanilla.ToastVanilla, {
69
+ open,
70
+ onOpenChange: (isOpen) => {
71
+ if (!isOpen) dismiss(id);
72
+ },
73
+ closeLabel,
74
+ ...options,
75
+ children: [
76
+ title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Toast_vanilla.ToastTitleVanilla, { children: title }) : null,
77
+ description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Toast_vanilla.ToastDescriptionVanilla, { children: description }) : null,
78
+ action ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Toast_vanilla.ToastActionVanilla, {
79
+ altText: action.altText,
80
+ onClick: action.onClick,
81
+ children: action.label
82
+ }) : null
83
+ ]
84
+ }, id)),
85
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_toast.Viewport, { className: require_Toast_vanilla_css.toastViewportRecipe({ position }) })
86
+ ]
87
+ })
88
+ });
89
+ };
90
+ var useToast = () => {
91
+ const context = (0, react.useContext)(ToastContext);
92
+ if (context === void 0) throw new Error("useToast must be used within a ToastProviderVanilla");
93
+ return context;
94
+ };
95
+ exports.ToastProviderVanilla = ToastProviderVanilla;
96
+ exports.useToast = useToast;
97
+
98
+ //# sourceMappingURL=ToastProvider.vanilla.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.vanilla.cjs","names":["createContext","useState","useRef","useCallback","useMemo","ToastPrimitive","ToastVanilla","ToastTitleVanilla","ToastDescriptionVanilla","ToastActionVanilla","toastViewportRecipe","useContext"],"sources":["../../../components/Toast/ToastProvider.vanilla.tsx"],"sourcesContent":["import * as ToastPrimitive from '@radix-ui/react-toast';\nimport React, {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n ToastActionVanilla,\n ToastDescriptionVanilla,\n ToastTitleVanilla,\n ToastVanilla,\n ToastVanillaProps,\n} from './Toast.vanilla';\nimport { ToastPosition, toastViewportRecipe } from './Toast.vanilla.css';\n\nexport type { ToastPosition };\n\n// Leaves time for the close animation before the toast leaves the list.\nconst REMOVE_DELAY = 1000;\n\nconst SWIPE_DIRECTIONS: Record<\n ToastPosition,\n NonNullable<ToastPrimitive.ToastProviderProps['swipeDirection']>\n> = {\n 'top-left': 'left',\n 'top-center': 'up',\n 'top-right': 'right',\n 'bottom-left': 'left',\n 'bottom-center': 'down',\n 'bottom-right': 'right',\n};\n\nexport interface ToastOptions extends Pick<\n ToastVanillaProps,\n 'variant' | 'icon' | 'duration' | 'type'\n> {\n title?: ReactNode;\n description?: ReactNode;\n action?: {\n label: ReactNode;\n altText: string;\n onClick: () => void;\n };\n}\n\ninterface ToastEntry extends ToastOptions {\n id: string;\n open: boolean;\n}\n\ninterface ToastContextValue {\n toast: (options: ToastOptions) => string;\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport interface ToastProviderVanillaProps {\n children?: ReactNode;\n position?: ToastPosition;\n duration?: number;\n label?: string;\n closeLabel?: string;\n}\n\nexport const ToastProviderVanilla = ({\n children,\n position = 'bottom-right',\n duration = 5000,\n label = 'Notification',\n closeLabel,\n}: ToastProviderVanillaProps) => {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const nextIdRef = useRef(0);\n const removeTimersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n\n useEffect(() => {\n const timers = removeTimersRef.current;\n return () => timers.forEach(clearTimeout);\n }, []);\n\n const scheduleRemove = useCallback((id: string) => {\n if (removeTimersRef.current.has(id)) return;\n removeTimersRef.current.set(\n id,\n setTimeout(() => {\n removeTimersRef.current.delete(id);\n setToasts((current) => current.filter((entry) => entry.id !== id));\n }, REMOVE_DELAY),\n );\n }, []);\n\n const toast = useCallback((options: ToastOptions) => {\n nextIdRef.current += 1;\n const id = `toast-${nextIdRef.current}`;\n setToasts((current) => [...current, { ...options, id, open: true }]);\n return id;\n }, []);\n\n useEffect(() => {\n toasts.forEach((entry) => {\n if (!entry.open) scheduleRemove(entry.id);\n });\n }, [toasts, scheduleRemove]);\n\n const dismiss = useCallback((id?: string) => {\n setToasts((current) =>\n current.map((entry) =>\n entry.open && (id === undefined || entry.id === id) ? { ...entry, open: false } : entry,\n ),\n );\n }, []);\n\n const value = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n\n return (\n <ToastPrimitive.Provider\n duration={duration}\n label={label}\n swipeDirection={SWIPE_DIRECTIONS[position]}\n >\n <ToastContext.Provider value={value}>\n {children}\n {toasts.map(({ id, open, title, description, action, ...options }) => (\n <ToastVanilla\n key={id}\n open={open}\n onOpenChange={(isOpen) => {\n if (!isOpen) dismiss(id);\n }}\n closeLabel={closeLabel}\n {...options}\n >\n {title ? <ToastTitleVanilla>{title}</ToastTitleVanilla> : null}\n {description ? <ToastDescriptionVanilla>{description}</ToastDescriptionVanilla> : null}\n {action ? (\n <ToastActionVanilla altText={action.altText} onClick={action.onClick}>\n {action.label}\n </ToastActionVanilla>\n ) : null}\n </ToastVanilla>\n ))}\n <ToastPrimitive.Viewport className={toastViewportRecipe({ position })} />\n </ToastContext.Provider>\n </ToastPrimitive.Provider>\n );\n};\n\nexport const useToast = () => {\n const context = useContext(ToastContext);\n if (context === undefined) {\n throw new Error('useToast must be used within a ToastProviderVanilla');\n }\n return context;\n};\n"],"mappings":"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"}
@@ -0,0 +1,94 @@
1
+ import { ToastActionVanilla, ToastDescriptionVanilla, ToastTitleVanilla, ToastVanilla } from "./Toast.vanilla.js";
2
+ import { toastViewportRecipe } from "./Toast.vanilla.css.js";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import * as ToastPrimitive from "@radix-ui/react-toast";
6
+ // components/Toast/ToastProvider.vanilla.tsx
7
+ var REMOVE_DELAY = 1e3;
8
+ var SWIPE_DIRECTIONS = {
9
+ "top-left": "left",
10
+ "top-center": "up",
11
+ "top-right": "right",
12
+ "bottom-left": "left",
13
+ "bottom-center": "down",
14
+ "bottom-right": "right"
15
+ };
16
+ var ToastContext = createContext(void 0);
17
+ var ToastProviderVanilla = ({ children, position = "bottom-right", duration = 5e3, label = "Notification", closeLabel }) => {
18
+ const [toasts, setToasts] = useState([]);
19
+ const nextIdRef = useRef(0);
20
+ const removeTimersRef = useRef(/* @__PURE__ */ new Map());
21
+ useEffect(() => {
22
+ const timers = removeTimersRef.current;
23
+ return () => timers.forEach(clearTimeout);
24
+ }, []);
25
+ const scheduleRemove = useCallback((id) => {
26
+ if (removeTimersRef.current.has(id)) return;
27
+ removeTimersRef.current.set(id, setTimeout(() => {
28
+ removeTimersRef.current.delete(id);
29
+ setToasts((current) => current.filter((entry) => entry.id !== id));
30
+ }, REMOVE_DELAY));
31
+ }, []);
32
+ const toast = useCallback((options) => {
33
+ nextIdRef.current += 1;
34
+ const id = `toast-${nextIdRef.current}`;
35
+ setToasts((current) => [...current, {
36
+ ...options,
37
+ id,
38
+ open: true
39
+ }]);
40
+ return id;
41
+ }, []);
42
+ useEffect(() => {
43
+ toasts.forEach((entry) => {
44
+ if (!entry.open) scheduleRemove(entry.id);
45
+ });
46
+ }, [toasts, scheduleRemove]);
47
+ const dismiss = useCallback((id) => {
48
+ setToasts((current) => current.map((entry) => entry.open && (id === void 0 || entry.id === id) ? {
49
+ ...entry,
50
+ open: false
51
+ } : entry));
52
+ }, []);
53
+ const value = useMemo(() => ({
54
+ toast,
55
+ dismiss
56
+ }), [toast, dismiss]);
57
+ return /* @__PURE__ */ jsx(ToastPrimitive.Provider, {
58
+ duration,
59
+ label,
60
+ swipeDirection: SWIPE_DIRECTIONS[position],
61
+ children: /* @__PURE__ */ jsxs(ToastContext.Provider, {
62
+ value,
63
+ children: [
64
+ children,
65
+ toasts.map(({ id, open, title, description, action, ...options }) => /* @__PURE__ */ jsxs(ToastVanilla, {
66
+ open,
67
+ onOpenChange: (isOpen) => {
68
+ if (!isOpen) dismiss(id);
69
+ },
70
+ closeLabel,
71
+ ...options,
72
+ children: [
73
+ title ? /* @__PURE__ */ jsx(ToastTitleVanilla, { children: title }) : null,
74
+ description ? /* @__PURE__ */ jsx(ToastDescriptionVanilla, { children: description }) : null,
75
+ action ? /* @__PURE__ */ jsx(ToastActionVanilla, {
76
+ altText: action.altText,
77
+ onClick: action.onClick,
78
+ children: action.label
79
+ }) : null
80
+ ]
81
+ }, id)),
82
+ /* @__PURE__ */ jsx(ToastPrimitive.Viewport, { className: toastViewportRecipe({ position }) })
83
+ ]
84
+ })
85
+ });
86
+ };
87
+ var useToast = () => {
88
+ const context = useContext(ToastContext);
89
+ if (context === void 0) throw new Error("useToast must be used within a ToastProviderVanilla");
90
+ return context;
91
+ };
92
+ export { ToastProviderVanilla, useToast };
93
+
94
+ //# sourceMappingURL=ToastProvider.vanilla.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastProvider.vanilla.js","names":[],"sources":["../../../components/Toast/ToastProvider.vanilla.tsx"],"sourcesContent":["import * as ToastPrimitive from '@radix-ui/react-toast';\nimport React, {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n ToastActionVanilla,\n ToastDescriptionVanilla,\n ToastTitleVanilla,\n ToastVanilla,\n ToastVanillaProps,\n} from './Toast.vanilla';\nimport { ToastPosition, toastViewportRecipe } from './Toast.vanilla.css';\n\nexport type { ToastPosition };\n\n// Leaves time for the close animation before the toast leaves the list.\nconst REMOVE_DELAY = 1000;\n\nconst SWIPE_DIRECTIONS: Record<\n ToastPosition,\n NonNullable<ToastPrimitive.ToastProviderProps['swipeDirection']>\n> = {\n 'top-left': 'left',\n 'top-center': 'up',\n 'top-right': 'right',\n 'bottom-left': 'left',\n 'bottom-center': 'down',\n 'bottom-right': 'right',\n};\n\nexport interface ToastOptions extends Pick<\n ToastVanillaProps,\n 'variant' | 'icon' | 'duration' | 'type'\n> {\n title?: ReactNode;\n description?: ReactNode;\n action?: {\n label: ReactNode;\n altText: string;\n onClick: () => void;\n };\n}\n\ninterface ToastEntry extends ToastOptions {\n id: string;\n open: boolean;\n}\n\ninterface ToastContextValue {\n toast: (options: ToastOptions) => string;\n dismiss: (id?: string) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport interface ToastProviderVanillaProps {\n children?: ReactNode;\n position?: ToastPosition;\n duration?: number;\n label?: string;\n closeLabel?: string;\n}\n\nexport const ToastProviderVanilla = ({\n children,\n position = 'bottom-right',\n duration = 5000,\n label = 'Notification',\n closeLabel,\n}: ToastProviderVanillaProps) => {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const nextIdRef = useRef(0);\n const removeTimersRef = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n\n useEffect(() => {\n const timers = removeTimersRef.current;\n return () => timers.forEach(clearTimeout);\n }, []);\n\n const scheduleRemove = useCallback((id: string) => {\n if (removeTimersRef.current.has(id)) return;\n removeTimersRef.current.set(\n id,\n setTimeout(() => {\n removeTimersRef.current.delete(id);\n setToasts((current) => current.filter((entry) => entry.id !== id));\n }, REMOVE_DELAY),\n );\n }, []);\n\n const toast = useCallback((options: ToastOptions) => {\n nextIdRef.current += 1;\n const id = `toast-${nextIdRef.current}`;\n setToasts((current) => [...current, { ...options, id, open: true }]);\n return id;\n }, []);\n\n useEffect(() => {\n toasts.forEach((entry) => {\n if (!entry.open) scheduleRemove(entry.id);\n });\n }, [toasts, scheduleRemove]);\n\n const dismiss = useCallback((id?: string) => {\n setToasts((current) =>\n current.map((entry) =>\n entry.open && (id === undefined || entry.id === id) ? { ...entry, open: false } : entry,\n ),\n );\n }, []);\n\n const value = useMemo(() => ({ toast, dismiss }), [toast, dismiss]);\n\n return (\n <ToastPrimitive.Provider\n duration={duration}\n label={label}\n swipeDirection={SWIPE_DIRECTIONS[position]}\n >\n <ToastContext.Provider value={value}>\n {children}\n {toasts.map(({ id, open, title, description, action, ...options }) => (\n <ToastVanilla\n key={id}\n open={open}\n onOpenChange={(isOpen) => {\n if (!isOpen) dismiss(id);\n }}\n closeLabel={closeLabel}\n {...options}\n >\n {title ? <ToastTitleVanilla>{title}</ToastTitleVanilla> : null}\n {description ? <ToastDescriptionVanilla>{description}</ToastDescriptionVanilla> : null}\n {action ? (\n <ToastActionVanilla altText={action.altText} onClick={action.onClick}>\n {action.label}\n </ToastActionVanilla>\n ) : null}\n </ToastVanilla>\n ))}\n <ToastPrimitive.Viewport className={toastViewportRecipe({ position })} />\n </ToastContext.Provider>\n </ToastPrimitive.Provider>\n );\n};\n\nexport const useToast = () => {\n const context = useContext(ToastContext);\n if (context === undefined) {\n throw new Error('useToast must be used within a ToastProviderVanilla');\n }\n return context;\n};\n"],"mappings":";;;;;;AAwBA,IAAM,eAAe;AAErB,IAAM,mBAGF;CACF,YAAY;CACZ,cAAc;CACd,aAAa;CACb,eAAe;CACf,iBAAiB;CACjB,gBAAgB;AAClB;AAyBA,IAAM,eAAe,cAA6C,KAAA,CAAS;AAU3E,IAAa,wBAAwB,EACnC,UACA,WAAW,gBACX,WAAW,KACX,QAAQ,gBACR,iBAC+B;CAC/B,MAAM,CAAC,QAAQ,aAAa,SAAuB,CAAC,CAAC;CACrD,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,kBAAkB,uBAAO,IAAI,IAA2C,CAAC;CAE/E,gBAAgB;EACd,MAAM,SAAS,gBAAgB;EAC/B,aAAa,OAAO,QAAQ,YAAY;CAC1C,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,aAAa,OAAe;EACjD,IAAI,gBAAgB,QAAQ,IAAI,EAAE,GAAG;EACrC,gBAAgB,QAAQ,IACtB,IACA,iBAAiB;GACf,gBAAgB,QAAQ,OAAO,EAAE;GACjC,WAAW,YAAY,QAAQ,QAAQ,UAAU,MAAM,OAAO,EAAE,CAAC;EACnE,GAAG,YAAY,CACjB;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,aAAa,YAA0B;EACnD,UAAU,WAAW;EACrB,MAAM,KAAK,SAAS,UAAU;EAC9B,WAAW,YAAY,CAAC,GAAG,SAAS;GAAE,GAAG;GAAS;GAAI,MAAM;EAAK,CAAC,CAAC;EACnE,OAAO;CACT,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,OAAO,SAAS,UAAU;GACxB,IAAI,CAAC,MAAM,MAAM,eAAe,MAAM,EAAE;EAC1C,CAAC;CACH,GAAG,CAAC,QAAQ,cAAc,CAAC;CAE3B,MAAM,UAAU,aAAa,OAAgB;EAC3C,WAAW,YACT,QAAQ,KAAK,UACX,MAAM,SAAS,OAAO,KAAA,KAAa,MAAM,OAAO,MAAM;GAAE,GAAG;GAAO,MAAM;EAAM,IAAI,KACpF,CACF;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,eAAe;EAAE;EAAO;CAAQ,IAAI,CAAC,OAAO,OAAO,CAAC;CAElE,OACE,oBAAC,eAAe,UAAhB;EACY;EACH;EACP,gBAAgB,iBAAiB;EAEjC,UAAA,qBAAC,aAAa,UAAd;GAA8B;GAA9B,UAAA;IACG;IACA,OAAO,KAAK,EAAE,IAAI,MAAM,OAAO,aAAa,QAAQ,GAAG,cACtD,qBAAC,cAAD;KAEQ;KACN,eAAe,WAAW;MACxB,IAAI,CAAC,QAAQ,QAAQ,EAAE;KACzB;KACY;KACZ,GAAI;KAPN,UAAA;MASG,QAAQ,oBAAC,mBAAD,EAAA,UAAoB,MAAyB,CAAA,IAAI;MACzD,cAAc,oBAAC,yBAAD,EAAA,UAA0B,YAAqC,CAAA,IAAI;MACjF,SACC,oBAAC,oBAAD;OAAoB,SAAS,OAAO;OAAS,SAAS,OAAO;OAC1D,UAAA,OAAO;MACU,CAAA,IAClB;KACQ;IAfP,GAAA,EAeO,CACf;IACD,oBAAC,eAAe,UAAhB,EAAyB,WAAW,oBAAoB,EAAE,SAAS,CAAC,EAAI,CAAA;GACnD;;CACA,CAAA;AAE7B;AAEA,IAAa,iBAAiB;CAC5B,MAAM,UAAU,WAAW,YAAY;CACvC,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,qDAAqD;CAEvE,OAAO;AACT"}