@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,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var clx = require('../../utils/clx.js');
|
|
5
|
+
var text = require('../text/text.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
const Textarea = /*#__PURE__*/React__namespace.forwardRef(({
|
|
27
|
+
className,
|
|
28
|
+
...props
|
|
29
|
+
}, ref) => {
|
|
30
|
+
return /*#__PURE__*/React__namespace.createElement("textarea", Object.assign({
|
|
31
|
+
ref: ref,
|
|
32
|
+
className: clx.clx(text.textVariants({
|
|
33
|
+
size: "base"
|
|
34
|
+
}), "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)
|
|
35
|
+
}, props));
|
|
36
|
+
});
|
|
37
|
+
Textarea.displayName = "Textarea";
|
|
38
|
+
|
|
39
|
+
exports.Textarea = Textarea;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var icons = require('@medusajs/icons');
|
|
4
|
+
var Primitives = require('@radix-ui/react-toast');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var clx = require('../../utils/clx.js');
|
|
7
|
+
var label = require('../label/label.js');
|
|
8
|
+
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var Primitives__namespace = /*#__PURE__*/_interopNamespaceDefault(Primitives);
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
|
+
|
|
29
|
+
const ToastProvider = Primitives__namespace.Provider;
|
|
30
|
+
ToastProvider.displayName = "ToastProvider";
|
|
31
|
+
const ToastViewport = /*#__PURE__*/React__namespace.forwardRef(({
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}, ref) => /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Viewport, Object.assign({
|
|
35
|
+
ref: ref,
|
|
36
|
+
className: clx.clx("fixed right-0 top-0 z-[100] w-full p-6 md:max-w-[484px]", className)
|
|
37
|
+
}, props)));
|
|
38
|
+
ToastViewport.displayName = "ToastViewport";
|
|
39
|
+
const Toast = /*#__PURE__*/React__namespace.forwardRef(({
|
|
40
|
+
className,
|
|
41
|
+
variant,
|
|
42
|
+
title,
|
|
43
|
+
description,
|
|
44
|
+
action,
|
|
45
|
+
disableDismiss = false,
|
|
46
|
+
...props
|
|
47
|
+
}, ref) => {
|
|
48
|
+
let Icon = undefined;
|
|
49
|
+
switch (variant) {
|
|
50
|
+
case "success":
|
|
51
|
+
Icon = /*#__PURE__*/React__namespace.createElement(icons.CheckCircleSolid, {
|
|
52
|
+
className: "text-ui-tag-green-icon"
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
case "warning":
|
|
56
|
+
Icon = /*#__PURE__*/React__namespace.createElement(icons.ExclamationCircleSolid, {
|
|
57
|
+
className: "text-ui-tag-orange-icon"
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "error":
|
|
61
|
+
Icon = /*#__PURE__*/React__namespace.createElement(icons.XCircleSolid, {
|
|
62
|
+
className: "text-ui-tag-red-icon"
|
|
63
|
+
});
|
|
64
|
+
break;
|
|
65
|
+
case "loading":
|
|
66
|
+
Icon = /*#__PURE__*/React__namespace.createElement(icons.Spinner, {
|
|
67
|
+
className: "text-ui-tag-blue-icon animate-spin"
|
|
68
|
+
});
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
Icon = /*#__PURE__*/React__namespace.createElement(icons.InformationCircleSolid, {
|
|
72
|
+
className: "text-ui-fg-base"
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
if (action && !action.altText) {
|
|
77
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
78
|
+
if (process.env.NODE_ENV === "development") {
|
|
79
|
+
console.warn("Omitting `altText` from the action is not recommended. Please provide a description for screen readers.");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Root, Object.assign({
|
|
83
|
+
ref: ref,
|
|
84
|
+
className: clx.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)
|
|
85
|
+
}, props), /*#__PURE__*/React__namespace.createElement("div", {
|
|
86
|
+
className: "border-ui-border-base flex flex-1 items-start space-x-3 border-r p-4"
|
|
87
|
+
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
88
|
+
"aria-hidden": true
|
|
89
|
+
}, Icon), /*#__PURE__*/React__namespace.createElement("div", null, title && /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Title, {
|
|
90
|
+
className: clx.clx(label.labelVariants({
|
|
91
|
+
size: "small",
|
|
92
|
+
weight: "plus"
|
|
93
|
+
}), "text-ui-fg-base")
|
|
94
|
+
}, title), description && /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Description, {
|
|
95
|
+
className: clx.clx(label.labelVariants({
|
|
96
|
+
size: "base"
|
|
97
|
+
}), "text-ui-fg-subtle")
|
|
98
|
+
}, description))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
99
|
+
className: "flex flex-col"
|
|
100
|
+
}, action && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Action, {
|
|
101
|
+
altText: action.altText,
|
|
102
|
+
className: clx.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", label.labelVariants({
|
|
103
|
+
size: "small",
|
|
104
|
+
weight: "plus"
|
|
105
|
+
}), {
|
|
106
|
+
"text-ui-fg-error": variant === "error"
|
|
107
|
+
}),
|
|
108
|
+
onClick: e => {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
action.onClick();
|
|
111
|
+
},
|
|
112
|
+
type: "button"
|
|
113
|
+
}, action.label), /*#__PURE__*/React__namespace.createElement("div", {
|
|
114
|
+
className: "bg-ui-border-base h-px w-full"
|
|
115
|
+
})), !disableDismiss && /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Close, {
|
|
116
|
+
className: clx.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", label.labelVariants({
|
|
117
|
+
size: "small",
|
|
118
|
+
weight: "plus"
|
|
119
|
+
}), {
|
|
120
|
+
"h-1/2": action,
|
|
121
|
+
"h-full": !action
|
|
122
|
+
}),
|
|
123
|
+
"aria-label": "Close"
|
|
124
|
+
}, "Close")));
|
|
125
|
+
});
|
|
126
|
+
Toast.displayName = "Toast";
|
|
127
|
+
|
|
128
|
+
exports.Toast = Toast;
|
|
129
|
+
exports.ToastProvider = ToastProvider;
|
|
130
|
+
exports.ToastViewport = ToastViewport;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var useToast = require('../../hooks/use-toast/use-toast.js');
|
|
5
|
+
var toast = require('../toast/toast.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
const Toaster = () => {
|
|
27
|
+
const {
|
|
28
|
+
toasts
|
|
29
|
+
} = useToast.useToast();
|
|
30
|
+
return /*#__PURE__*/React__namespace.createElement(toast.ToastProvider, {
|
|
31
|
+
swipeDirection: "right"
|
|
32
|
+
}, toasts.map(({
|
|
33
|
+
id,
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
return /*#__PURE__*/React__namespace.createElement(toast.Toast, Object.assign({
|
|
37
|
+
key: id
|
|
38
|
+
}, props));
|
|
39
|
+
}), /*#__PURE__*/React__namespace.createElement(toast.ToastViewport, null));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.Toaster = Toaster;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Primitives = require('@radix-ui/react-tooltip');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var clx = require('../../utils/clx.js');
|
|
6
|
+
var label = require('../label/label.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var Primitives__namespace = /*#__PURE__*/_interopNamespaceDefault(Primitives);
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
|
+
|
|
28
|
+
const Tooltip = ({
|
|
29
|
+
children,
|
|
30
|
+
content,
|
|
31
|
+
open,
|
|
32
|
+
defaultOpen,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
delayDuration,
|
|
35
|
+
maxWidth = 220,
|
|
36
|
+
className,
|
|
37
|
+
side,
|
|
38
|
+
sideOffset = 4,
|
|
39
|
+
onClick,
|
|
40
|
+
...props
|
|
41
|
+
}) => {
|
|
42
|
+
return /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Provider, {
|
|
43
|
+
delayDuration: 100
|
|
44
|
+
}, /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Root, {
|
|
45
|
+
open: open,
|
|
46
|
+
defaultOpen: defaultOpen,
|
|
47
|
+
onOpenChange: onOpenChange,
|
|
48
|
+
delayDuration: delayDuration
|
|
49
|
+
}, /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Trigger, {
|
|
50
|
+
onClick: onClick,
|
|
51
|
+
asChild: true
|
|
52
|
+
}, children), /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Portal, null, /*#__PURE__*/React__namespace.createElement(Primitives__namespace.Content, Object.assign({
|
|
53
|
+
side: side,
|
|
54
|
+
sideOffset: sideOffset,
|
|
55
|
+
align: "center",
|
|
56
|
+
className: clx.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", label.labelVariants({
|
|
57
|
+
size: "xsmall",
|
|
58
|
+
weight: "plus"
|
|
59
|
+
}), className)
|
|
60
|
+
}, props, {
|
|
61
|
+
style: {
|
|
62
|
+
...props.style,
|
|
63
|
+
maxWidth
|
|
64
|
+
}
|
|
65
|
+
}), content))));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.Tooltip = Tooltip;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var clx = require('../../utils/clx.js');
|
|
7
|
+
var alertDialog = require('../../components/alert-dialog/alert-dialog.js');
|
|
8
|
+
var label = require('../../components/label/label.js');
|
|
9
|
+
var input = require('../../components/input/input.js');
|
|
10
|
+
|
|
11
|
+
function _interopNamespaceDefault(e) {
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
29
|
+
|
|
30
|
+
const Dialog = ({
|
|
31
|
+
open,
|
|
32
|
+
title,
|
|
33
|
+
description,
|
|
34
|
+
verificationText,
|
|
35
|
+
cancelText = "Cancel",
|
|
36
|
+
confirmText = "Confirm",
|
|
37
|
+
onConfirm,
|
|
38
|
+
onCancel
|
|
39
|
+
}) => {
|
|
40
|
+
const [userInput, setUserInput] = React__namespace.useState("");
|
|
41
|
+
const handleUserInput = event => {
|
|
42
|
+
setUserInput(event.target.value);
|
|
43
|
+
};
|
|
44
|
+
const validInput = React__namespace.useMemo(() => {
|
|
45
|
+
if (!verificationText) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return userInput === verificationText;
|
|
49
|
+
}, [userInput, verificationText]);
|
|
50
|
+
const handleFormSubmit = event => {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
if (validInput) {
|
|
53
|
+
onConfirm();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
React__namespace.useEffect(() => {
|
|
57
|
+
const handleEscape = event => {
|
|
58
|
+
if (event.key === "Escape" && open) {
|
|
59
|
+
onCancel();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
document.addEventListener("keydown", handleEscape);
|
|
63
|
+
return () => {
|
|
64
|
+
document.removeEventListener("keydown", handleEscape);
|
|
65
|
+
};
|
|
66
|
+
}, [onCancel, open]);
|
|
67
|
+
return /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog, {
|
|
68
|
+
open: open
|
|
69
|
+
}, /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Content, null, /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Header, null, /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Title, null, title), /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Description, null, description)), verificationText && /*#__PURE__*/React__namespace.createElement("form", {
|
|
70
|
+
onSubmit: handleFormSubmit
|
|
71
|
+
}, /*#__PURE__*/React__namespace.createElement("fieldset", {
|
|
72
|
+
className: "border-ui-border-base mt-6 flex flex-col gap-y-4 border-y p-6"
|
|
73
|
+
}, /*#__PURE__*/React__namespace.createElement(label.Label, {
|
|
74
|
+
htmlFor: "verificationText",
|
|
75
|
+
className: "text-subtle"
|
|
76
|
+
}, "Please type", " ", /*#__PURE__*/React__namespace.createElement("span", {
|
|
77
|
+
className: clx.clx(label.labelVariants({
|
|
78
|
+
size: "base",
|
|
79
|
+
weight: "plus"
|
|
80
|
+
}), "text-ui-fg-base")
|
|
81
|
+
}, verificationText), " ", "to confirm."), /*#__PURE__*/React__namespace.createElement(input.Input, {
|
|
82
|
+
autoFocus: true,
|
|
83
|
+
autoComplete: "off",
|
|
84
|
+
id: "verificationText",
|
|
85
|
+
placeholder: verificationText,
|
|
86
|
+
onChange: handleUserInput
|
|
87
|
+
}))), /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Footer, null, /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Cancel, {
|
|
88
|
+
onClick: onCancel
|
|
89
|
+
}, cancelText), /*#__PURE__*/React__namespace.createElement(alertDialog.AlertDialog.Action, {
|
|
90
|
+
onClick: verificationText ? undefined : onConfirm,
|
|
91
|
+
disabled: !validInput,
|
|
92
|
+
type: verificationText ? "submit" : "button"
|
|
93
|
+
}, confirmText))));
|
|
94
|
+
};
|
|
95
|
+
var Dialog$1 = Dialog;
|
|
96
|
+
|
|
97
|
+
exports.default = Dialog$1;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var client = require('react-dom/client');
|
|
5
|
+
var dialog = require('./dialog.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
const useAlertDialog = () => {
|
|
27
|
+
const dialog$1 = async props => {
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
let open = true;
|
|
30
|
+
const onCancel = () => {
|
|
31
|
+
open = false;
|
|
32
|
+
render();
|
|
33
|
+
resolve(false);
|
|
34
|
+
};
|
|
35
|
+
const onConfirm = () => {
|
|
36
|
+
open = false;
|
|
37
|
+
resolve(true);
|
|
38
|
+
render();
|
|
39
|
+
};
|
|
40
|
+
const mountRoot = client.createRoot(document.createElement("div"));
|
|
41
|
+
const render = () => {
|
|
42
|
+
mountRoot.render( /*#__PURE__*/React__namespace.createElement(dialog.default, Object.assign({
|
|
43
|
+
open: open,
|
|
44
|
+
onConfirm: onConfirm,
|
|
45
|
+
onCancel: onCancel
|
|
46
|
+
}, props)));
|
|
47
|
+
};
|
|
48
|
+
render();
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return dialog$1;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.useAlertDialog = useAlertDialog;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
// import * as React from "react"
|
|
25
|
+
|
|
26
|
+
const TOAST_LIMIT = 1;
|
|
27
|
+
const TOAST_REMOVE_DELAY = 1000000;
|
|
28
|
+
let count = 0;
|
|
29
|
+
function genId() {
|
|
30
|
+
count = (count + 1) % Number.MAX_VALUE;
|
|
31
|
+
return count.toString();
|
|
32
|
+
}
|
|
33
|
+
const toastTimeouts = new Map();
|
|
34
|
+
const addToRemoveQueue = toastId => {
|
|
35
|
+
if (toastTimeouts.has(toastId)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const timeout = setTimeout(() => {
|
|
39
|
+
toastTimeouts.delete(toastId);
|
|
40
|
+
dispatch({
|
|
41
|
+
type: "REMOVE_TOAST",
|
|
42
|
+
toastId: toastId
|
|
43
|
+
});
|
|
44
|
+
}, TOAST_REMOVE_DELAY);
|
|
45
|
+
toastTimeouts.set(toastId, timeout);
|
|
46
|
+
};
|
|
47
|
+
const reducer = (state, action) => {
|
|
48
|
+
switch (action.type) {
|
|
49
|
+
case "ADD_TOAST":
|
|
50
|
+
return {
|
|
51
|
+
...state,
|
|
52
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
|
|
53
|
+
};
|
|
54
|
+
case "UPDATE_TOAST":
|
|
55
|
+
return {
|
|
56
|
+
...state,
|
|
57
|
+
toasts: state.toasts.map(t => t.id === action.toast.id ? {
|
|
58
|
+
...t,
|
|
59
|
+
...action.toast
|
|
60
|
+
} : t)
|
|
61
|
+
};
|
|
62
|
+
case "DISMISS_TOAST":
|
|
63
|
+
{
|
|
64
|
+
const {
|
|
65
|
+
toastId
|
|
66
|
+
} = action;
|
|
67
|
+
|
|
68
|
+
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
69
|
+
// but I'll keep it here for simplicity
|
|
70
|
+
if (toastId) {
|
|
71
|
+
addToRemoveQueue(toastId);
|
|
72
|
+
} else {
|
|
73
|
+
state.toasts.forEach(toast => {
|
|
74
|
+
addToRemoveQueue(toast.id);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...state,
|
|
79
|
+
toasts: state.toasts.map(t => t.id === toastId || toastId === undefined ? {
|
|
80
|
+
...t,
|
|
81
|
+
open: false
|
|
82
|
+
} : t)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
case "REMOVE_TOAST":
|
|
86
|
+
if (action.toastId === undefined) {
|
|
87
|
+
return {
|
|
88
|
+
...state,
|
|
89
|
+
toasts: []
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
toasts: state.toasts.filter(t => t.id !== action.toastId)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const listeners = [];
|
|
99
|
+
let memoryState = {
|
|
100
|
+
toasts: []
|
|
101
|
+
};
|
|
102
|
+
function dispatch(action) {
|
|
103
|
+
memoryState = reducer(memoryState, action);
|
|
104
|
+
listeners.forEach(listener => {
|
|
105
|
+
listener(memoryState);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function toast({
|
|
109
|
+
...props
|
|
110
|
+
}) {
|
|
111
|
+
const id = genId();
|
|
112
|
+
const update = props => dispatch({
|
|
113
|
+
type: "UPDATE_TOAST",
|
|
114
|
+
toast: {
|
|
115
|
+
...props,
|
|
116
|
+
id
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const dismiss = () => dispatch({
|
|
120
|
+
type: "DISMISS_TOAST",
|
|
121
|
+
toastId: id
|
|
122
|
+
});
|
|
123
|
+
dispatch({
|
|
124
|
+
type: "ADD_TOAST",
|
|
125
|
+
toast: {
|
|
126
|
+
...props,
|
|
127
|
+
id,
|
|
128
|
+
open: true,
|
|
129
|
+
onOpenChange: open => {
|
|
130
|
+
if (!open) dismiss();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
id: id,
|
|
136
|
+
dismiss,
|
|
137
|
+
update
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function useToast() {
|
|
141
|
+
const [state, setState] = React__namespace.useState(memoryState);
|
|
142
|
+
React__namespace.useEffect(() => {
|
|
143
|
+
listeners.push(setState);
|
|
144
|
+
return () => {
|
|
145
|
+
const index = listeners.indexOf(setState);
|
|
146
|
+
if (index > -1) {
|
|
147
|
+
listeners.splice(index, 1);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}, [state]);
|
|
151
|
+
return {
|
|
152
|
+
...state,
|
|
153
|
+
toast,
|
|
154
|
+
dismiss: toastId => dispatch({
|
|
155
|
+
type: "DISMISS_TOAST",
|
|
156
|
+
toastId
|
|
157
|
+
})
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
exports.reducer = reducer;
|
|
162
|
+
exports.toast = toast;
|
|
163
|
+
exports.useToast = useToast;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
23
|
+
|
|
24
|
+
const useToggleState = (initial = false) => {
|
|
25
|
+
const [state, setState] = React__namespace.useState(initial);
|
|
26
|
+
const close = () => {
|
|
27
|
+
setState(false);
|
|
28
|
+
};
|
|
29
|
+
const open = () => {
|
|
30
|
+
setState(true);
|
|
31
|
+
};
|
|
32
|
+
const toggle = () => {
|
|
33
|
+
setState(state => !state);
|
|
34
|
+
};
|
|
35
|
+
const hookData = [state, open, close, toggle];
|
|
36
|
+
hookData.state = state;
|
|
37
|
+
hookData.open = open;
|
|
38
|
+
hookData.close = close;
|
|
39
|
+
hookData.toggle = toggle;
|
|
40
|
+
return hookData;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.useToggleState = useToggleState;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clx = require('./utils/clx.js');
|
|
4
|
+
var alertDialog = require('./components/alert-dialog/alert-dialog.js');
|
|
5
|
+
var avatar = require('./components/avatar/avatar.js');
|
|
6
|
+
var badge = require('./components/badge/badge.js');
|
|
7
|
+
var button = require('./components/button/button.js');
|
|
8
|
+
var checkbox = require('./components/checkbox/checkbox.js');
|
|
9
|
+
var container = require('./components/container/container.js');
|
|
10
|
+
var drawer = require('./components/drawer/drawer.js');
|
|
11
|
+
var dropdownMenu = require('./components/dropdown-menu/dropdown-menu.js');
|
|
12
|
+
var focusModal = require('./components/focus-modal/focus-modal.js');
|
|
13
|
+
var heading = require('./components/heading/heading.js');
|
|
14
|
+
var input = require('./components/input/input.js');
|
|
15
|
+
var kbd = require('./components/kbd/kbd.js');
|
|
16
|
+
var label = require('./components/label/label.js');
|
|
17
|
+
var radioGroup = require('./components/radio-group/radio-group.js');
|
|
18
|
+
var _switch = require('./components/switch/switch.js');
|
|
19
|
+
var text = require('./components/text/text.js');
|
|
20
|
+
var textarea = require('./components/textarea/textarea.js');
|
|
21
|
+
var toast = require('./components/toast/toast.js');
|
|
22
|
+
var toaster = require('./components/toaster/toaster.js');
|
|
23
|
+
var tooltip = require('./components/tooltip/tooltip.js');
|
|
24
|
+
var useAlertDialog = require('./hooks/use-alert-dialog/use-alert-dialog.js');
|
|
25
|
+
var useToast = require('./hooks/use-toast/use-toast.js');
|
|
26
|
+
var useToggleState = require('./hooks/use-toggle-state/use-toggle-state.js');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.clx = clx.clx;
|
|
31
|
+
exports.AlertDialog = alertDialog.AlertDialog;
|
|
32
|
+
exports.Avatar = avatar.Avatar;
|
|
33
|
+
exports.Badge = badge.Badge;
|
|
34
|
+
exports.Button = button.Button;
|
|
35
|
+
exports.Checkbox = checkbox.Checkbox;
|
|
36
|
+
exports.Container = container.Container;
|
|
37
|
+
exports.Drawer = drawer.Drawer;
|
|
38
|
+
exports.DropdownMenu = dropdownMenu.DropdownMenu;
|
|
39
|
+
exports.FocusModal = focusModal.FocusModal;
|
|
40
|
+
exports.Heading = heading.Heading;
|
|
41
|
+
exports.Input = input.Input;
|
|
42
|
+
exports.Kbd = kbd.Kbd;
|
|
43
|
+
exports.Label = label.Label;
|
|
44
|
+
exports.RadioGroup = radioGroup.RadioGroup;
|
|
45
|
+
exports.Switch = _switch.Switch;
|
|
46
|
+
exports.Text = text.Text;
|
|
47
|
+
exports.Textarea = textarea.Textarea;
|
|
48
|
+
exports.Toast = toast.Toast;
|
|
49
|
+
exports.Toaster = toaster.Toaster;
|
|
50
|
+
exports.Tooltip = tooltip.Tooltip;
|
|
51
|
+
exports.useAlertDialog = useAlertDialog.useAlertDialog;
|
|
52
|
+
exports.useToast = useToast.useToast;
|
|
53
|
+
exports.useToggleState = useToggleState.useToggleState;
|