@medusajs/ui 0.0.0-alpha-20230713141422
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.
- package/README.md +3 -0
- package/build/cjs/components/alert-dialog/alert-dialog.js +151 -0
- package/build/cjs/components/avatar/avatar.js +97 -0
- package/build/cjs/components/badge/badge.js +98 -0
- package/build/cjs/components/button/button.js +104 -0
- package/build/cjs/components/checkbox/checkbox.js +45 -0
- package/build/cjs/components/container/container.js +36 -0
- package/build/cjs/components/drawer/drawer.js +136 -0
- package/build/cjs/components/dropdown-menu/dropdown-menu.js +168 -0
- package/build/cjs/components/focus-modal/focus-modal.js +102 -0
- package/build/cjs/components/heading/heading.js +52 -0
- package/build/cjs/components/input/input.js +50 -0
- package/build/cjs/components/kbd/kbd.js +39 -0
- package/build/cjs/components/label/label.js +63 -0
- package/build/cjs/components/radio-group/radio-group.js +60 -0
- package/build/cjs/components/switch/switch.js +67 -0
- package/build/cjs/components/text/text.js +71 -0
- package/build/cjs/components/textarea/textarea.js +39 -0
- package/build/cjs/components/toast/toast.js +130 -0
- package/build/cjs/components/toaster/toaster.js +42 -0
- package/build/cjs/components/tooltip/tooltip.js +68 -0
- package/build/cjs/hooks/use-alert-dialog/dialog.js +97 -0
- package/build/cjs/hooks/use-alert-dialog/use-alert-dialog.js +54 -0
- package/build/cjs/hooks/use-toast/use-toast.js +163 -0
- package/build/cjs/hooks/use-toggle-state/use-toggle-state.js +43 -0
- package/build/cjs/index.js +53 -0
- package/build/cjs/utils/clx.js +10 -0
- package/build/esm/components/alert-dialog/alert-dialog.js +129 -0
- package/build/esm/components/avatar/avatar.js +75 -0
- package/build/esm/components/badge/badge.js +77 -0
- package/build/esm/components/button/button.js +83 -0
- package/build/esm/components/checkbox/checkbox.js +23 -0
- package/build/esm/components/container/container.js +15 -0
- package/build/esm/components/drawer/drawer.js +114 -0
- package/build/esm/components/dropdown-menu/dropdown-menu.js +146 -0
- package/build/esm/components/focus-modal/focus-modal.js +80 -0
- package/build/esm/components/heading/heading.js +30 -0
- package/build/esm/components/input/input.js +29 -0
- package/build/esm/components/kbd/kbd.js +18 -0
- package/build/esm/components/label/label.js +40 -0
- package/build/esm/components/radio-group/radio-group.js +38 -0
- package/build/esm/components/switch/switch.js +45 -0
- package/build/esm/components/text/text.js +49 -0
- package/build/esm/components/textarea/textarea.js +18 -0
- package/build/esm/components/toast/toast.js +106 -0
- package/build/esm/components/toaster/toaster.js +21 -0
- package/build/esm/components/tooltip/tooltip.js +46 -0
- package/build/esm/hooks/use-alert-dialog/dialog.js +74 -0
- package/build/esm/hooks/use-alert-dialog/use-alert-dialog.js +33 -0
- package/build/esm/hooks/use-toast/use-toast.js +140 -0
- package/build/esm/hooks/use-toggle-state/use-toggle-state.js +22 -0
- package/build/esm/index.js +24 -0
- package/build/esm/utils/clx.js +8 -0
- package/build/types/src/components/alert-dialog/alert-dialog.d.ts +14 -0
- package/build/types/src/components/alert-dialog/alert-dialog.d.ts.map +1 -0
- package/build/types/src/components/alert-dialog/index.d.ts +2 -0
- package/build/types/src/components/alert-dialog/index.d.ts.map +1 -0
- package/build/types/src/components/avatar/avatar.d.ts +14 -0
- package/build/types/src/components/avatar/avatar.d.ts.map +1 -0
- package/build/types/src/components/avatar/index.d.ts +2 -0
- package/build/types/src/components/avatar/index.d.ts.map +1 -0
- package/build/types/src/components/badge/badge.d.ts +13 -0
- package/build/types/src/components/badge/badge.d.ts.map +1 -0
- package/build/types/src/components/badge/index.d.ts +2 -0
- package/build/types/src/components/badge/index.d.ts.map +1 -0
- package/build/types/src/components/button/button.d.ts +14 -0
- package/build/types/src/components/button/button.d.ts.map +1 -0
- package/build/types/src/components/button/index.d.ts +2 -0
- package/build/types/src/components/button/index.d.ts.map +1 -0
- package/build/types/src/components/checkbox/checkbox.d.ts +5 -0
- package/build/types/src/components/checkbox/checkbox.d.ts.map +1 -0
- package/build/types/src/components/checkbox/index.d.ts +2 -0
- package/build/types/src/components/checkbox/index.d.ts.map +1 -0
- package/build/types/src/components/container/container.d.ts +4 -0
- package/build/types/src/components/container/container.d.ts.map +1 -0
- package/build/types/src/components/container/index.d.ts +2 -0
- package/build/types/src/components/container/index.d.ts.map +1 -0
- package/build/types/src/components/drawer/drawer.d.ts +22 -0
- package/build/types/src/components/drawer/drawer.d.ts.map +1 -0
- package/build/types/src/components/drawer/index.d.ts +2 -0
- package/build/types/src/components/drawer/index.d.ts.map +1 -0
- package/build/types/src/components/dropdown-menu/dropdown-menu.d.ts +26 -0
- package/build/types/src/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/build/types/src/components/dropdown-menu/index.d.ts +2 -0
- package/build/types/src/components/dropdown-menu/index.d.ts.map +1 -0
- package/build/types/src/components/focus-modal/focus-modal.d.ts +16 -0
- package/build/types/src/components/focus-modal/focus-modal.d.ts.map +1 -0
- package/build/types/src/components/focus-modal/index.d.ts +2 -0
- package/build/types/src/components/focus-modal/index.d.ts.map +1 -0
- package/build/types/src/components/heading/heading.d.ts +9 -0
- package/build/types/src/components/heading/heading.d.ts.map +1 -0
- package/build/types/src/components/heading/index.d.ts +2 -0
- package/build/types/src/components/heading/index.d.ts.map +1 -0
- package/build/types/src/components/input/index.d.ts +2 -0
- package/build/types/src/components/input/index.d.ts.map +1 -0
- package/build/types/src/components/input/input.d.ts +4 -0
- package/build/types/src/components/input/input.d.ts.map +1 -0
- package/build/types/src/components/kbd/index.d.ts +2 -0
- package/build/types/src/components/kbd/index.d.ts.map +1 -0
- package/build/types/src/components/kbd/kbd.d.ts +4 -0
- package/build/types/src/components/kbd/kbd.d.ts.map +1 -0
- package/build/types/src/components/label/index.d.ts +2 -0
- package/build/types/src/components/label/index.d.ts.map +1 -0
- package/build/types/src/components/label/label.d.ts +11 -0
- package/build/types/src/components/label/label.d.ts.map +1 -0
- package/build/types/src/components/radio-group/index.d.ts +2 -0
- package/build/types/src/components/radio-group/index.d.ts.map +1 -0
- package/build/types/src/components/radio-group/radio-group.d.ts +7 -0
- package/build/types/src/components/radio-group/radio-group.d.ts.map +1 -0
- package/build/types/src/components/switch/index.d.ts +2 -0
- package/build/types/src/components/switch/index.d.ts.map +1 -0
- package/build/types/src/components/switch/switch.d.ts +11 -0
- package/build/types/src/components/switch/switch.d.ts.map +1 -0
- package/build/types/src/components/text/index.d.ts +2 -0
- package/build/types/src/components/text/index.d.ts.map +1 -0
- package/build/types/src/components/text/text.d.ts +13 -0
- package/build/types/src/components/text/text.d.ts.map +1 -0
- package/build/types/src/components/textarea/index.d.ts +2 -0
- package/build/types/src/components/textarea/index.d.ts.map +1 -0
- package/build/types/src/components/textarea/textarea.d.ts +4 -0
- package/build/types/src/components/textarea/textarea.d.ts.map +1 -0
- package/build/types/src/components/toast/index.d.ts +2 -0
- package/build/types/src/components/toast/index.d.ts.map +1 -0
- package/build/types/src/components/toast/toast.d.ts +20 -0
- package/build/types/src/components/toast/toast.d.ts.map +1 -0
- package/build/types/src/components/toaster/index.d.ts +2 -0
- package/build/types/src/components/toaster/index.d.ts.map +1 -0
- package/build/types/src/components/toaster/toaster.d.ts +4 -0
- package/build/types/src/components/toaster/toaster.d.ts.map +1 -0
- package/build/types/src/components/tooltip/index.d.ts +2 -0
- package/build/types/src/components/tooltip/index.d.ts.map +1 -0
- package/build/types/src/components/tooltip/tooltip.d.ts +11 -0
- package/build/types/src/components/tooltip/tooltip.d.ts.map +1 -0
- package/build/types/src/hooks/use-alert-dialog/dialog.d.ts +14 -0
- package/build/types/src/hooks/use-alert-dialog/dialog.d.ts.map +1 -0
- package/build/types/src/hooks/use-alert-dialog/index.d.ts +2 -0
- package/build/types/src/hooks/use-alert-dialog/index.d.ts.map +1 -0
- package/build/types/src/hooks/use-alert-dialog/use-alert-dialog.d.ts +5 -0
- package/build/types/src/hooks/use-alert-dialog/use-alert-dialog.d.ts.map +1 -0
- package/build/types/src/hooks/use-toast/index.d.ts +2 -0
- package/build/types/src/hooks/use-toast/index.d.ts.map +1 -0
- package/build/types/src/hooks/use-toast/use-toast.d.ts +45 -0
- package/build/types/src/hooks/use-toast/use-toast.d.ts.map +1 -0
- package/build/types/src/hooks/use-toggle-state/index.d.ts +2 -0
- package/build/types/src/hooks/use-toggle-state/index.d.ts.map +1 -0
- package/build/types/src/hooks/use-toggle-state/use-toggle-state.d.ts +9 -0
- package/build/types/src/hooks/use-toggle-state/use-toggle-state.d.ts.map +1 -0
- package/build/types/src/index.d.ts +25 -0
- package/build/types/src/index.d.ts.map +1 -0
- package/build/types/src/utils/clx.d.ts +3 -0
- package/build/types/src/utils/clx.d.ts.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { XMark } from '@medusajs/icons';
|
|
2
|
+
import * as Primitives from '@radix-ui/react-dialog';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clx } from '../../utils/clx.js';
|
|
5
|
+
import { Kbd } from '../kbd/kbd.js';
|
|
6
|
+
import { Button } from '../button/button.js';
|
|
7
|
+
|
|
8
|
+
const Root = Primitives.Root;
|
|
9
|
+
Root.displayName = "FocusModal.Root";
|
|
10
|
+
const Trigger = Primitives.Trigger;
|
|
11
|
+
Trigger.displayName = "FocusModal.Trigger";
|
|
12
|
+
const Portal = ({
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
return /*#__PURE__*/React.createElement(Primitives.DialogPortal, Object.assign({
|
|
17
|
+
className: clx(className)
|
|
18
|
+
}, props));
|
|
19
|
+
};
|
|
20
|
+
Portal.displayName = "FocusModal.Portal";
|
|
21
|
+
const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}, ref) => {
|
|
25
|
+
return /*#__PURE__*/React.createElement(Primitives.Overlay, Object.assign({
|
|
26
|
+
ref: ref,
|
|
27
|
+
className: clx("fixed inset-0 z-50",
|
|
28
|
+
// "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", // Re-enable when Admin UI has been cleaned up
|
|
29
|
+
className)
|
|
30
|
+
}, props));
|
|
31
|
+
});
|
|
32
|
+
Overlay.displayName = "FocusModal.Overlay";
|
|
33
|
+
const Content = /*#__PURE__*/React.forwardRef(({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Overlay, null), /*#__PURE__*/React.createElement(Primitives.Content, Object.assign({
|
|
38
|
+
ref: ref,
|
|
39
|
+
className: clx("bg-ui-bg-base shadow-elevation-modal fixed inset-2 z-50 flex flex-col rounded-lg border focus:outline-none",
|
|
40
|
+
// "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 duration-200", // Re-enable when Admin UI has been cleaned up
|
|
41
|
+
className)
|
|
42
|
+
}, props)));
|
|
43
|
+
});
|
|
44
|
+
Content.displayName = "FocusModal.Content";
|
|
45
|
+
const Header = ({
|
|
46
|
+
children,
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}) => {
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
51
|
+
className: clx("border-ui-border-base flex items-start justify-between gap-x-4 border-b p-4", className)
|
|
52
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "flex items-center gap-x-2"
|
|
54
|
+
}, /*#__PURE__*/React.createElement(Primitives.Close, {
|
|
55
|
+
asChild: true
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
57
|
+
variant: "transparent",
|
|
58
|
+
size: "sm",
|
|
59
|
+
format: "icon"
|
|
60
|
+
}, /*#__PURE__*/React.createElement(XMark, null))), /*#__PURE__*/React.createElement(Kbd, null, "esc")), /*#__PURE__*/React.createElement("div", null, children));
|
|
61
|
+
};
|
|
62
|
+
Header.displayName = "FocusModal.Header";
|
|
63
|
+
const Body = ({
|
|
64
|
+
className,
|
|
65
|
+
...props
|
|
66
|
+
}) => {
|
|
67
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
68
|
+
className: clx("flex-1", className)
|
|
69
|
+
}, props));
|
|
70
|
+
};
|
|
71
|
+
Body.displayName = "FocusModal.Body";
|
|
72
|
+
const FocusModal = {
|
|
73
|
+
Root,
|
|
74
|
+
Trigger,
|
|
75
|
+
Content,
|
|
76
|
+
Header,
|
|
77
|
+
Body
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { FocusModal };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clx } from '../../utils/clx.js';
|
|
4
|
+
|
|
5
|
+
const headingVariants = cva("font-sans font-medium", {
|
|
6
|
+
variants: {
|
|
7
|
+
level: {
|
|
8
|
+
h1: "text-xl leading-8",
|
|
9
|
+
h2: "text-base leading-6",
|
|
10
|
+
h3: "text-sm leading-5"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
level: "h1"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const Heading = ({
|
|
18
|
+
level,
|
|
19
|
+
className,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const Component = level ? level : "h1";
|
|
23
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({
|
|
24
|
+
className: clx(headingVariants({
|
|
25
|
+
level
|
|
26
|
+
}), className)
|
|
27
|
+
}, props));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Heading, headingVariants };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clx } from '../../utils/clx.js';
|
|
4
|
+
import { labelVariants } from '../label/label.js';
|
|
5
|
+
|
|
6
|
+
const inputVariants = cva("bg-ui-bg-subtle hover:bg-ui-bg-subtle-hover border-ui-border-loud-muted invalid:!border-ui-border-error invalid:focus:!shadow-borders-error disabled:text-ui-fg-disabled disabled:!bg-ui-bg-disabled disabled:!border-ui-border-base focus:border-ui-border-interactive focus:shadow-borders-active placeholder:text-ui-fg-muted text-ui-fg-base relative w-full rounded-md border outline-none transition-all disabled:cursor-not-allowed disabled:!shadow-none", {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
base: "h-10 px-3 py-[9px]",
|
|
10
|
+
small: "h-8"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const Input = /*#__PURE__*/React.forwardRef(({
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
}, ref) => {
|
|
18
|
+
return /*#__PURE__*/React.createElement("input", Object.assign({
|
|
19
|
+
ref: ref,
|
|
20
|
+
className: clx(inputVariants({
|
|
21
|
+
size: "base"
|
|
22
|
+
}), labelVariants({
|
|
23
|
+
size: "base"
|
|
24
|
+
}), className)
|
|
25
|
+
}, props));
|
|
26
|
+
});
|
|
27
|
+
Input.displayName = "Input";
|
|
28
|
+
|
|
29
|
+
export { Input };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clx } from '../../utils/clx.js';
|
|
3
|
+
import { labelVariants } from '../label/label.js';
|
|
4
|
+
|
|
5
|
+
const Kbd = ({
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}) => {
|
|
10
|
+
return /*#__PURE__*/React.createElement("kbd", Object.assign({}, props, {
|
|
11
|
+
className: clx("bg-ui-tag-neutral-bg text-ui-tag-neutral-text border-ui-tag-neutral-border min-w-5 inline-flex h-5 w-fit items-center justify-center rounded-md border px-1", labelVariants({
|
|
12
|
+
size: "xsmall",
|
|
13
|
+
weight: "plus"
|
|
14
|
+
}), className)
|
|
15
|
+
}), children);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Kbd };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Primitives from '@radix-ui/react-label';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clx } from '../../utils/clx.js';
|
|
5
|
+
|
|
6
|
+
const labelVariants = cva("font-sans", {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
xsmall: "text-xs leading-5",
|
|
10
|
+
small: "text-[13px] leading-5",
|
|
11
|
+
base: "text-sm leading-5",
|
|
12
|
+
large: "text-base leading-5"
|
|
13
|
+
},
|
|
14
|
+
weight: {
|
|
15
|
+
regular: "font-normal",
|
|
16
|
+
plus: "font-medium"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
size: "base",
|
|
21
|
+
weight: "regular"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const Label = /*#__PURE__*/React.forwardRef(({
|
|
25
|
+
className,
|
|
26
|
+
size = "base",
|
|
27
|
+
weight = "regular",
|
|
28
|
+
...props
|
|
29
|
+
}, ref) => {
|
|
30
|
+
return /*#__PURE__*/React.createElement(Primitives.Root, Object.assign({
|
|
31
|
+
ref: ref,
|
|
32
|
+
className: clx(labelVariants({
|
|
33
|
+
size,
|
|
34
|
+
weight
|
|
35
|
+
}), className)
|
|
36
|
+
}, props));
|
|
37
|
+
});
|
|
38
|
+
Label.displayName = "Label";
|
|
39
|
+
|
|
40
|
+
export { Label, labelVariants };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as Primitives from '@radix-ui/react-radio-group';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clx } from '../../utils/clx.js';
|
|
4
|
+
|
|
5
|
+
const Root = /*#__PURE__*/React.forwardRef(({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}, ref) => {
|
|
9
|
+
return /*#__PURE__*/React.createElement(Primitives.Root, Object.assign({
|
|
10
|
+
className: clx("grid gap-2", className)
|
|
11
|
+
}, props, {
|
|
12
|
+
ref: ref
|
|
13
|
+
}));
|
|
14
|
+
});
|
|
15
|
+
Root.displayName = "RadioGroup.Root";
|
|
16
|
+
const Item = /*#__PURE__*/React.forwardRef(({
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
21
|
+
return /*#__PURE__*/React.createElement(Primitives.Item, Object.assign({
|
|
22
|
+
ref: ref,
|
|
23
|
+
className: clx("group relative flex h-5 w-5 items-center justify-center outline-none", className)
|
|
24
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "shadow-borders-base-w-shadow group-hover:shadow-borders-strong-w-shadow bg-ui-bg-base group-data-[state=checked]:bg-ui-bg-interactive group-data-[state=checked]:shadow-borders-interactive group-focus:!shadow-borders-interactive-w-focus group-disabled:!bg-ui-bg-disabled group-disabled:!shadow-borders-base flex h-[14px] w-[14px] items-center justify-center rounded-full transition-all"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Primitives.Indicator, {
|
|
27
|
+
className: "flex items-center justify-center"
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: clx("bg-ui-bg-base shadow-details-contrast-on-bg-interactive group-disabled:bg-ui-fg-disabled h-1.5 w-1.5 rounded-full group-disabled:shadow-none")
|
|
30
|
+
}))));
|
|
31
|
+
});
|
|
32
|
+
Item.displayName = "RadioGroup.Item";
|
|
33
|
+
const RadioGroup = {
|
|
34
|
+
Root,
|
|
35
|
+
Item
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as Primitives from '@radix-ui/react-switch';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clx } from '../../utils/clx.js';
|
|
5
|
+
|
|
6
|
+
const switchVariants = cva("bg-ui-bg-toggle-off hover:bg-ui-bg-toggle-off-hover data-[state=unchecked]:hover:after:bg-toggle-off-hover-gradient before:shadow-details-switch-background focus:shadow-details-switch-background-focus data-[state=checked]:bg-ui-bg-interactive disabled:!bg-ui-bg-disabled group relative inline-flex items-center rounded-full outline-none transition-all before:absolute before:inset-0 before:rounded-full before:content-[''] after:absolute after:inset-0 after:rounded-full after:content-[''] disabled:cursor-not-allowed", {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
small: "h-[16px] w-[28px]",
|
|
10
|
+
base: "h-[18px] w-[32px]"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: "base"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const thumbVariants = cva("bg-ui-bg-base shadow-details-switch-thumb group-disabled:bg-ui-bg-disabled pointer-events-none z-10 h-[14px] w-[14px] rounded-full transition-all", {
|
|
18
|
+
variants: {
|
|
19
|
+
size: {
|
|
20
|
+
small: "h-[12px] w-[12px] data-[state=checked]:translate-x-3.5 data-[state=unchecked]:translate-x-0.5",
|
|
21
|
+
base: "h-[14px] w-[14px] data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0.5"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
size: "base"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const Switch = /*#__PURE__*/React.forwardRef(({
|
|
29
|
+
className,
|
|
30
|
+
size = "base",
|
|
31
|
+
...props
|
|
32
|
+
}, ref) => /*#__PURE__*/React.createElement(Primitives.Root, Object.assign({
|
|
33
|
+
className: clx(switchVariants({
|
|
34
|
+
size
|
|
35
|
+
}), className)
|
|
36
|
+
}, props, {
|
|
37
|
+
ref: ref
|
|
38
|
+
}), /*#__PURE__*/React.createElement(Primitives.Thumb, {
|
|
39
|
+
className: clx(thumbVariants({
|
|
40
|
+
size
|
|
41
|
+
}))
|
|
42
|
+
})));
|
|
43
|
+
Switch.displayName = "Switch";
|
|
44
|
+
|
|
45
|
+
export { Switch };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clx } from '../../utils/clx.js';
|
|
5
|
+
|
|
6
|
+
const textVariants = cva("", {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
base: "text-sm leading-6",
|
|
10
|
+
large: "text-base leading-7",
|
|
11
|
+
xlarge: "text-lg leading-8"
|
|
12
|
+
},
|
|
13
|
+
weight: {
|
|
14
|
+
regular: "font-normal",
|
|
15
|
+
plus: "font-medium"
|
|
16
|
+
},
|
|
17
|
+
family: {
|
|
18
|
+
sans: "font-sans",
|
|
19
|
+
mono: "font-mono"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
family: "sans",
|
|
24
|
+
size: "base",
|
|
25
|
+
weight: "regular"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const Text = /*#__PURE__*/React.forwardRef(({
|
|
29
|
+
className,
|
|
30
|
+
asChild = false,
|
|
31
|
+
size = "base",
|
|
32
|
+
weight = "regular",
|
|
33
|
+
family = "sans",
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
const Component = asChild ? Slot : "p";
|
|
38
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({
|
|
39
|
+
ref: ref,
|
|
40
|
+
className: clx(textVariants({
|
|
41
|
+
size,
|
|
42
|
+
weight,
|
|
43
|
+
family
|
|
44
|
+
}), className)
|
|
45
|
+
}, props), children);
|
|
46
|
+
});
|
|
47
|
+
Text.displayName = "Text";
|
|
48
|
+
|
|
49
|
+
export { Text, textVariants };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clx } from '../../utils/clx.js';
|
|
3
|
+
import { textVariants } from '../text/text.js';
|
|
4
|
+
|
|
5
|
+
const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
6
|
+
className,
|
|
7
|
+
...props
|
|
8
|
+
}, ref) => {
|
|
9
|
+
return /*#__PURE__*/React.createElement("textarea", Object.assign({
|
|
10
|
+
ref: ref,
|
|
11
|
+
className: clx(textVariants({
|
|
12
|
+
size: "base"
|
|
13
|
+
}), "bg-ui-bg-subtle focus:shadow-borders-active focus:border-ui-border-interactive border-ui-border-loud-muted shadow-buttons-secondary placeholder:text-ui-fg-muted min-h-[70px] w-full rounded-md border px-3 py-[7px] outline-none transition-colors", className)
|
|
14
|
+
}, props));
|
|
15
|
+
});
|
|
16
|
+
Textarea.displayName = "Textarea";
|
|
17
|
+
|
|
18
|
+
export { Textarea };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { InformationCircleSolid, Spinner, XCircleSolid, ExclamationCircleSolid, CheckCircleSolid } from '@medusajs/icons';
|
|
2
|
+
import * as Primitives from '@radix-ui/react-toast';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { clx } from '../../utils/clx.js';
|
|
5
|
+
import { labelVariants } from '../label/label.js';
|
|
6
|
+
|
|
7
|
+
const ToastProvider = Primitives.Provider;
|
|
8
|
+
ToastProvider.displayName = "ToastProvider";
|
|
9
|
+
const ToastViewport = /*#__PURE__*/React.forwardRef(({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) => /*#__PURE__*/React.createElement(Primitives.Viewport, Object.assign({
|
|
13
|
+
ref: ref,
|
|
14
|
+
className: clx("fixed right-0 top-0 z-[100] w-full p-6 md:max-w-[484px]", className)
|
|
15
|
+
}, props)));
|
|
16
|
+
ToastViewport.displayName = "ToastViewport";
|
|
17
|
+
const Toast = /*#__PURE__*/React.forwardRef(({
|
|
18
|
+
className,
|
|
19
|
+
variant,
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
action,
|
|
23
|
+
disableDismiss = false,
|
|
24
|
+
...props
|
|
25
|
+
}, ref) => {
|
|
26
|
+
let Icon = undefined;
|
|
27
|
+
switch (variant) {
|
|
28
|
+
case "success":
|
|
29
|
+
Icon = /*#__PURE__*/React.createElement(CheckCircleSolid, {
|
|
30
|
+
className: "text-ui-tag-green-icon"
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
case "warning":
|
|
34
|
+
Icon = /*#__PURE__*/React.createElement(ExclamationCircleSolid, {
|
|
35
|
+
className: "text-ui-tag-orange-icon"
|
|
36
|
+
});
|
|
37
|
+
break;
|
|
38
|
+
case "error":
|
|
39
|
+
Icon = /*#__PURE__*/React.createElement(XCircleSolid, {
|
|
40
|
+
className: "text-ui-tag-red-icon"
|
|
41
|
+
});
|
|
42
|
+
break;
|
|
43
|
+
case "loading":
|
|
44
|
+
Icon = /*#__PURE__*/React.createElement(Spinner, {
|
|
45
|
+
className: "text-ui-tag-blue-icon animate-spin"
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
Icon = /*#__PURE__*/React.createElement(InformationCircleSolid, {
|
|
50
|
+
className: "text-ui-fg-base"
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
if (action && !action.altText) {
|
|
55
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
56
|
+
if (process.env.NODE_ENV === "development") {
|
|
57
|
+
console.warn("Omitting `altText` from the action is not recommended. Please provide a description for screen readers.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return /*#__PURE__*/React.createElement(Primitives.Root, Object.assign({
|
|
61
|
+
ref: ref,
|
|
62
|
+
className: clx("bg-ui-bg-base shadow-elevation-flyout flex h-fit min-h-[74px] w-full overflow-hidden rounded-md md:max-w-[440px]", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none", className)
|
|
63
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "border-ui-border-base flex flex-1 items-start space-x-3 border-r p-4"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
66
|
+
"aria-hidden": true
|
|
67
|
+
}, Icon), /*#__PURE__*/React.createElement("div", null, title && /*#__PURE__*/React.createElement(Primitives.Title, {
|
|
68
|
+
className: clx(labelVariants({
|
|
69
|
+
size: "small",
|
|
70
|
+
weight: "plus"
|
|
71
|
+
}), "text-ui-fg-base")
|
|
72
|
+
}, title), description && /*#__PURE__*/React.createElement(Primitives.Description, {
|
|
73
|
+
className: clx(labelVariants({
|
|
74
|
+
size: "base"
|
|
75
|
+
}), "text-ui-fg-subtle")
|
|
76
|
+
}, description))), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: "flex flex-col"
|
|
78
|
+
}, action && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Primitives.Action, {
|
|
79
|
+
altText: action.altText,
|
|
80
|
+
className: clx("text-ui-fg-base bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex flex-1 items-center justify-center px-6 transition-colors", labelVariants({
|
|
81
|
+
size: "small",
|
|
82
|
+
weight: "plus"
|
|
83
|
+
}), {
|
|
84
|
+
"text-ui-fg-error": variant === "error"
|
|
85
|
+
}),
|
|
86
|
+
onClick: e => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
action.onClick();
|
|
89
|
+
},
|
|
90
|
+
type: "button"
|
|
91
|
+
}, action.label), /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: "bg-ui-border-base h-px w-full"
|
|
93
|
+
})), !disableDismiss && /*#__PURE__*/React.createElement(Primitives.Close, {
|
|
94
|
+
className: clx("text-ui-fg-subtle bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex flex-1 items-center justify-center px-6 transition-colors", labelVariants({
|
|
95
|
+
size: "small",
|
|
96
|
+
weight: "plus"
|
|
97
|
+
}), {
|
|
98
|
+
"h-1/2": action,
|
|
99
|
+
"h-full": !action
|
|
100
|
+
}),
|
|
101
|
+
"aria-label": "Close"
|
|
102
|
+
}, "Close")));
|
|
103
|
+
});
|
|
104
|
+
Toast.displayName = "Toast";
|
|
105
|
+
|
|
106
|
+
export { Toast, ToastProvider, ToastViewport };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useToast } from '../../hooks/use-toast/use-toast.js';
|
|
3
|
+
import { ToastProvider, Toast, ToastViewport } from '../toast/toast.js';
|
|
4
|
+
|
|
5
|
+
const Toaster = () => {
|
|
6
|
+
const {
|
|
7
|
+
toasts
|
|
8
|
+
} = useToast();
|
|
9
|
+
return /*#__PURE__*/React.createElement(ToastProvider, {
|
|
10
|
+
swipeDirection: "right"
|
|
11
|
+
}, toasts.map(({
|
|
12
|
+
id,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Toast, Object.assign({
|
|
16
|
+
key: id
|
|
17
|
+
}, props));
|
|
18
|
+
}), /*#__PURE__*/React.createElement(ToastViewport, null));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Toaster };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as Primitives from '@radix-ui/react-tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { clx } from '../../utils/clx.js';
|
|
4
|
+
import { labelVariants } from '../label/label.js';
|
|
5
|
+
|
|
6
|
+
const Tooltip = ({
|
|
7
|
+
children,
|
|
8
|
+
content,
|
|
9
|
+
open,
|
|
10
|
+
defaultOpen,
|
|
11
|
+
onOpenChange,
|
|
12
|
+
delayDuration,
|
|
13
|
+
maxWidth = 220,
|
|
14
|
+
className,
|
|
15
|
+
side,
|
|
16
|
+
sideOffset = 4,
|
|
17
|
+
onClick,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Primitives.Provider, {
|
|
21
|
+
delayDuration: 100
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Primitives.Root, {
|
|
23
|
+
open: open,
|
|
24
|
+
defaultOpen: defaultOpen,
|
|
25
|
+
onOpenChange: onOpenChange,
|
|
26
|
+
delayDuration: delayDuration
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Primitives.Trigger, {
|
|
28
|
+
onClick: onClick,
|
|
29
|
+
asChild: true
|
|
30
|
+
}, children), /*#__PURE__*/React.createElement(Primitives.Portal, null, /*#__PURE__*/React.createElement(Primitives.Content, Object.assign({
|
|
31
|
+
side: side,
|
|
32
|
+
sideOffset: sideOffset,
|
|
33
|
+
align: "center",
|
|
34
|
+
className: clx("text-ui-fg-subtle animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-ui-bg-base shadow-elevation-tooltip z-[999] rounded-lg px-3 py-2", labelVariants({
|
|
35
|
+
size: "xsmall",
|
|
36
|
+
weight: "plus"
|
|
37
|
+
}), className)
|
|
38
|
+
}, props, {
|
|
39
|
+
style: {
|
|
40
|
+
...props.style,
|
|
41
|
+
maxWidth
|
|
42
|
+
}
|
|
43
|
+
}), content))));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { Tooltip };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clx } from '../../utils/clx.js';
|
|
3
|
+
import { AlertDialog } from '../../components/alert-dialog/alert-dialog.js';
|
|
4
|
+
import { Label, labelVariants } from '../../components/label/label.js';
|
|
5
|
+
import { Input } from '../../components/input/input.js';
|
|
6
|
+
|
|
7
|
+
const Dialog = ({
|
|
8
|
+
open,
|
|
9
|
+
title,
|
|
10
|
+
description,
|
|
11
|
+
verificationText,
|
|
12
|
+
cancelText = "Cancel",
|
|
13
|
+
confirmText = "Confirm",
|
|
14
|
+
onConfirm,
|
|
15
|
+
onCancel
|
|
16
|
+
}) => {
|
|
17
|
+
const [userInput, setUserInput] = React.useState("");
|
|
18
|
+
const handleUserInput = event => {
|
|
19
|
+
setUserInput(event.target.value);
|
|
20
|
+
};
|
|
21
|
+
const validInput = React.useMemo(() => {
|
|
22
|
+
if (!verificationText) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return userInput === verificationText;
|
|
26
|
+
}, [userInput, verificationText]);
|
|
27
|
+
const handleFormSubmit = event => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
if (validInput) {
|
|
30
|
+
onConfirm();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
const handleEscape = event => {
|
|
35
|
+
if (event.key === "Escape" && open) {
|
|
36
|
+
onCancel();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
document.addEventListener("keydown", handleEscape);
|
|
40
|
+
return () => {
|
|
41
|
+
document.removeEventListener("keydown", handleEscape);
|
|
42
|
+
};
|
|
43
|
+
}, [onCancel, open]);
|
|
44
|
+
return /*#__PURE__*/React.createElement(AlertDialog, {
|
|
45
|
+
open: open
|
|
46
|
+
}, /*#__PURE__*/React.createElement(AlertDialog.Content, null, /*#__PURE__*/React.createElement(AlertDialog.Header, null, /*#__PURE__*/React.createElement(AlertDialog.Title, null, title), /*#__PURE__*/React.createElement(AlertDialog.Description, null, description)), verificationText && /*#__PURE__*/React.createElement("form", {
|
|
47
|
+
onSubmit: handleFormSubmit
|
|
48
|
+
}, /*#__PURE__*/React.createElement("fieldset", {
|
|
49
|
+
className: "border-ui-border-base mt-6 flex flex-col gap-y-4 border-y p-6"
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Label, {
|
|
51
|
+
htmlFor: "verificationText",
|
|
52
|
+
className: "text-subtle"
|
|
53
|
+
}, "Please type", " ", /*#__PURE__*/React.createElement("span", {
|
|
54
|
+
className: clx(labelVariants({
|
|
55
|
+
size: "base",
|
|
56
|
+
weight: "plus"
|
|
57
|
+
}), "text-ui-fg-base")
|
|
58
|
+
}, verificationText), " ", "to confirm."), /*#__PURE__*/React.createElement(Input, {
|
|
59
|
+
autoFocus: true,
|
|
60
|
+
autoComplete: "off",
|
|
61
|
+
id: "verificationText",
|
|
62
|
+
placeholder: verificationText,
|
|
63
|
+
onChange: handleUserInput
|
|
64
|
+
}))), /*#__PURE__*/React.createElement(AlertDialog.Footer, null, /*#__PURE__*/React.createElement(AlertDialog.Cancel, {
|
|
65
|
+
onClick: onCancel
|
|
66
|
+
}, cancelText), /*#__PURE__*/React.createElement(AlertDialog.Action, {
|
|
67
|
+
onClick: verificationText ? undefined : onConfirm,
|
|
68
|
+
disabled: !validInput,
|
|
69
|
+
type: verificationText ? "submit" : "button"
|
|
70
|
+
}, confirmText))));
|
|
71
|
+
};
|
|
72
|
+
var Dialog$1 = Dialog;
|
|
73
|
+
|
|
74
|
+
export { Dialog$1 as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import Dialog from './dialog.js';
|
|
4
|
+
|
|
5
|
+
const useAlertDialog = () => {
|
|
6
|
+
const dialog = async props => {
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
let open = true;
|
|
9
|
+
const onCancel = () => {
|
|
10
|
+
open = false;
|
|
11
|
+
render();
|
|
12
|
+
resolve(false);
|
|
13
|
+
};
|
|
14
|
+
const onConfirm = () => {
|
|
15
|
+
open = false;
|
|
16
|
+
resolve(true);
|
|
17
|
+
render();
|
|
18
|
+
};
|
|
19
|
+
const mountRoot = createRoot(document.createElement("div"));
|
|
20
|
+
const render = () => {
|
|
21
|
+
mountRoot.render( /*#__PURE__*/React.createElement(Dialog, Object.assign({
|
|
22
|
+
open: open,
|
|
23
|
+
onConfirm: onConfirm,
|
|
24
|
+
onCancel: onCancel
|
|
25
|
+
}, props)));
|
|
26
|
+
};
|
|
27
|
+
render();
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return dialog;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useAlertDialog };
|