@techsio/ui-kit 0.0.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.
- package/README.md +165 -0
- package/dist/atoms/badge.js +66 -0
- package/dist/atoms/button.js +275 -0
- package/dist/atoms/error-text.js +38 -0
- package/dist/atoms/extra-text.js +27 -0
- package/dist/atoms/icon.js +42 -0
- package/dist/atoms/image.js +11 -0
- package/dist/atoms/input.js +83 -0
- package/dist/atoms/label.js +43 -0
- package/dist/atoms/link-button.js +51 -0
- package/dist/atoms/link.js +23 -0
- package/dist/atoms/numeric-input.js +221 -0
- package/dist/atoms/rating.js +117 -0
- package/dist/atoms/textarea.js +81 -0
- package/dist/atoms/tooltip.js +119 -0
- package/dist/molecules/accordion.js +245 -0
- package/dist/molecules/breadcrumb.js +168 -0
- package/dist/molecules/carousel.js +333 -0
- package/dist/molecules/checkbox.js +92 -0
- package/dist/molecules/color-select.js +159 -0
- package/dist/molecules/combobox.js +253 -0
- package/dist/molecules/dialog.js +313 -0
- package/dist/molecules/form-checkbox.js +59 -0
- package/dist/molecules/form-input.js +55 -0
- package/dist/molecules/form-numeric-input.js +47 -0
- package/dist/molecules/form-textarea.js +54 -0
- package/dist/molecules/menu.js +302 -0
- package/dist/molecules/pagination.js +184 -0
- package/dist/molecules/popover.js +152 -0
- package/dist/molecules/product-card.js +194 -0
- package/dist/molecules/search-form.js +106 -0
- package/dist/molecules/select.js +217 -0
- package/dist/molecules/slider.js +249 -0
- package/dist/molecules/steps.js +178 -0
- package/dist/molecules/switch.js +109 -0
- package/dist/molecules/tabs.js +211 -0
- package/dist/molecules/toast.js +126 -0
- package/dist/molecules/tree-view.js +451 -0
- package/dist/organisms/footer.js +209 -0
- package/dist/organisms/header.js +245 -0
- package/dist/organisms/table.js +233 -0
- package/dist/src/atoms/badge.d.ts +59 -0
- package/dist/src/atoms/badge.d.ts.map +1 -0
- package/dist/src/atoms/button.d.ts +97 -0
- package/dist/src/atoms/button.d.ts.map +1 -0
- package/dist/src/atoms/error-text.d.ts +29 -0
- package/dist/src/atoms/error-text.d.ts.map +1 -0
- package/dist/src/atoms/extra-text.d.ts +27 -0
- package/dist/src/atoms/extra-text.d.ts.map +1 -0
- package/dist/src/atoms/icon.d.ts +65 -0
- package/dist/src/atoms/icon.d.ts.map +1 -0
- package/dist/src/atoms/image.d.ts +17 -0
- package/dist/src/atoms/image.d.ts.map +1 -0
- package/dist/src/atoms/input.d.ts +78 -0
- package/dist/src/atoms/input.d.ts.map +1 -0
- package/dist/src/atoms/label.d.ts +41 -0
- package/dist/src/atoms/label.d.ts.map +1 -0
- package/dist/src/atoms/link-button.d.ts +129 -0
- package/dist/src/atoms/link-button.d.ts.map +1 -0
- package/dist/src/atoms/link.d.ts +17 -0
- package/dist/src/atoms/link.d.ts.map +1 -0
- package/dist/src/atoms/numeric-input.d.ts +64 -0
- package/dist/src/atoms/numeric-input.d.ts.map +1 -0
- package/dist/src/atoms/rating.d.ts +108 -0
- package/dist/src/atoms/rating.d.ts.map +1 -0
- package/dist/src/atoms/textarea.d.ts +81 -0
- package/dist/src/atoms/textarea.d.ts.map +1 -0
- package/dist/src/atoms/tooltip.d.ts +88 -0
- package/dist/src/atoms/tooltip.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +182 -0
- package/dist/src/molecules/accordion.d.ts.map +1 -0
- package/dist/src/molecules/breadcrumb.d.ts +117 -0
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -0
- package/dist/src/molecules/carousel.d.ts +261 -0
- package/dist/src/molecules/carousel.d.ts.map +1 -0
- package/dist/src/molecules/checkbox.d.ts +19 -0
- package/dist/src/molecules/checkbox.d.ts.map +1 -0
- package/dist/src/molecules/color-select.d.ts +20 -0
- package/dist/src/molecules/color-select.d.ts.map +1 -0
- package/dist/src/molecules/combobox.d.ts +141 -0
- package/dist/src/molecules/combobox.d.ts.map +1 -0
- package/dist/src/molecules/dialog.d.ts +234 -0
- package/dist/src/molecules/dialog.d.ts.map +1 -0
- package/dist/src/molecules/form-checkbox.d.ts +15 -0
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -0
- package/dist/src/molecules/form-input.d.ts +14 -0
- package/dist/src/molecules/form-input.d.ts.map +1 -0
- package/dist/src/molecules/form-numeric-input.d.ts +14 -0
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -0
- package/dist/src/molecules/form-textarea.d.ts +14 -0
- package/dist/src/molecules/form-textarea.d.ts.map +1 -0
- package/dist/src/molecules/menu.d.ts +153 -0
- package/dist/src/molecules/menu.d.ts.map +1 -0
- package/dist/src/molecules/pagination.d.ts +123 -0
- package/dist/src/molecules/pagination.d.ts.map +1 -0
- package/dist/src/molecules/popover.d.ts +124 -0
- package/dist/src/molecules/popover.d.ts.map +1 -0
- package/dist/src/molecules/product-card.d.ts +160 -0
- package/dist/src/molecules/product-card.d.ts.map +1 -0
- package/dist/src/molecules/search-form.d.ts +39 -0
- package/dist/src/molecules/search-form.d.ts.map +1 -0
- package/dist/src/molecules/select.d.ts +126 -0
- package/dist/src/molecules/select.d.ts.map +1 -0
- package/dist/src/molecules/slider.d.ts +120 -0
- package/dist/src/molecules/slider.d.ts.map +1 -0
- package/dist/src/molecules/steps.d.ts +96 -0
- package/dist/src/molecules/steps.d.ts.map +1 -0
- package/dist/src/molecules/switch.d.ts +71 -0
- package/dist/src/molecules/switch.d.ts.map +1 -0
- package/dist/src/molecules/tabs.d.ts +207 -0
- package/dist/src/molecules/tabs.d.ts.map +1 -0
- package/dist/src/molecules/toast.d.ts +83 -0
- package/dist/src/molecules/toast.d.ts.map +1 -0
- package/dist/src/molecules/tree-view.d.ts +202 -0
- package/dist/src/molecules/tree-view.d.ts.map +1 -0
- package/dist/src/organisms/footer.d.ts +254 -0
- package/dist/src/organisms/footer.d.ts.map +1 -0
- package/dist/src/organisms/header.d.ts +186 -0
- package/dist/src/organisms/header.d.ts.map +1 -0
- package/dist/src/organisms/table.d.ts +250 -0
- package/dist/src/organisms/table.d.ts.map +1 -0
- package/dist/src/templates/accordion.d.ts +15 -0
- package/dist/src/templates/accordion.d.ts.map +1 -0
- package/dist/src/templates/carousel.d.ts +13 -0
- package/dist/src/templates/carousel.d.ts.map +1 -0
- package/dist/src/templates/numeric-input.d.ts +14 -0
- package/dist/src/templates/numeric-input.d.ts.map +1 -0
- package/dist/src/templates/product-card.d.ts +33 -0
- package/dist/src/templates/product-card.d.ts.map +1 -0
- package/dist/src/templates/tabs.d.ts +16 -0
- package/dist/src/templates/tabs.d.ts.map +1 -0
- package/dist/src/types/zag.d.ts +19 -0
- package/dist/src/types/zag.d.ts.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/templates/accordion.js +37 -0
- package/dist/templates/carousel.js +55 -0
- package/dist/templates/numeric-input.js +49 -0
- package/dist/templates/product-card.js +92 -0
- package/dist/templates/tabs.js +34 -0
- package/dist/types/zag.js +0 -0
- package/dist/utils.js +20 -0
- package/package.json +126 -0
- package/src/tokens/_base.css +25 -0
- package/src/tokens/_colors.css +5 -0
- package/src/tokens/_layout.css +34 -0
- package/src/tokens/_semantic.css +360 -0
- package/src/tokens/_spacing.css +22 -0
- package/src/tokens/_typography.css +17 -0
- package/src/tokens/components/atoms/_badge.css +61 -0
- package/src/tokens/components/atoms/_button.css +215 -0
- package/src/tokens/components/atoms/_icon.css +122 -0
- package/src/tokens/components/atoms/_input.css +125 -0
- package/src/tokens/components/atoms/_numeric-input.css +57 -0
- package/src/tokens/components/atoms/_rating.css +33 -0
- package/src/tokens/components/atoms/_textarea.css +93 -0
- package/src/tokens/components/atoms/_tooltip.css +21 -0
- package/src/tokens/components/components.css +32 -0
- package/src/tokens/components/molecules/_accordion.css +85 -0
- package/src/tokens/components/molecules/_breadcrumb.css +44 -0
- package/src/tokens/components/molecules/_carousel.css +72 -0
- package/src/tokens/components/molecules/_checkbox.css +29 -0
- package/src/tokens/components/molecules/_color-select.css +61 -0
- package/src/tokens/components/molecules/_combobox.css +116 -0
- package/src/tokens/components/molecules/_dialog.css +75 -0
- package/src/tokens/components/molecules/_menu.css +48 -0
- package/src/tokens/components/molecules/_pagination.css +75 -0
- package/src/tokens/components/molecules/_popover.css +39 -0
- package/src/tokens/components/molecules/_product-card.css +85 -0
- package/src/tokens/components/molecules/_search-form.css +10 -0
- package/src/tokens/components/molecules/_select.css +88 -0
- package/src/tokens/components/molecules/_slider.css +75 -0
- package/src/tokens/components/molecules/_steps.css +54 -0
- package/src/tokens/components/molecules/_switch.css +62 -0
- package/src/tokens/components/molecules/_tabs.css +69 -0
- package/src/tokens/components/molecules/_toast.css +77 -0
- package/src/tokens/components/molecules/_tree-view.css +80 -0
- package/src/tokens/components/molecules/index.css +2 -0
- package/src/tokens/components/organisms/_footer.css +90 -0
- package/src/tokens/components/organisms/_header.css +86 -0
- package/src/tokens/components/organisms/_table.css +63 -0
- package/src/tokens/index.css +67 -0
- package/src/tokens/tokens-only.css +66 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
+
import { connect, machine } from "@zag-js/tabs";
|
|
4
|
+
import { createContext, useContext, useId } from "react";
|
|
5
|
+
import { Button } from "../atoms/button.js";
|
|
6
|
+
import { tv } from "../utils.js";
|
|
7
|
+
const tabsVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
root: [
|
|
10
|
+
'flex w-full',
|
|
11
|
+
'data-[orientation=horizontal]:flex-col',
|
|
12
|
+
'data-[orientation=vertical]:flex-row',
|
|
13
|
+
'bg-tabs-bg',
|
|
14
|
+
'rounded-tabs'
|
|
15
|
+
],
|
|
16
|
+
list: [
|
|
17
|
+
'relative flex',
|
|
18
|
+
'bg-tabs-list-bg',
|
|
19
|
+
'data-[orientation=horizontal]:flex-row',
|
|
20
|
+
'data-[orientation=vertical]:flex-col'
|
|
21
|
+
],
|
|
22
|
+
trigger: [
|
|
23
|
+
'relative flex items-center justify-center',
|
|
24
|
+
'text-tabs-trigger-fg',
|
|
25
|
+
'rounded-tabs-trigger',
|
|
26
|
+
'cursor-pointer',
|
|
27
|
+
'hover:bg-tabs-trigger-bg-hover',
|
|
28
|
+
'focus-visible:outline-none',
|
|
29
|
+
'focus-visible:ring',
|
|
30
|
+
'focus-visible:ring-tabs-ring',
|
|
31
|
+
'data-[selected]:text-tabs-trigger-fg-selected',
|
|
32
|
+
'data-[disabled]:opacity-tabs-disabled data-[disabled]:cursor-not-allowed'
|
|
33
|
+
],
|
|
34
|
+
indicator: [
|
|
35
|
+
'absolute bg-tabs-indicator-bg rounded-tabs-indicator',
|
|
36
|
+
'data-[orientation=vertical]:h-(--height) data-[orientation=horizontal]:w-(--width)',
|
|
37
|
+
'data-[orientation=vertical]:w-tabs-indicator data-[orientation=horizontal]:h-tabs-indicator',
|
|
38
|
+
'data-[orientation=vertical]:start-0 data-[orientation=horizontal]:bottom-0'
|
|
39
|
+
],
|
|
40
|
+
content: [
|
|
41
|
+
'text-tabs-content-fg',
|
|
42
|
+
'outline-none',
|
|
43
|
+
'focus-visible:ring',
|
|
44
|
+
'focus-visible:ring-tabs-ring'
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
variants: {
|
|
48
|
+
variant: {
|
|
49
|
+
default: {
|
|
50
|
+
list: '',
|
|
51
|
+
indicator: 'hidden'
|
|
52
|
+
},
|
|
53
|
+
line: {
|
|
54
|
+
list: 'border-b-(length:--border-width-tabs) border-tabs-border',
|
|
55
|
+
indicator: 'data-[orientation=horizontal]:-bottom-(--border-width-tabs)'
|
|
56
|
+
},
|
|
57
|
+
solid: {
|
|
58
|
+
trigger: 'data-[selected]:bg-tabs-trigger-bg-selected data-[selected]:text-tabs-trigger-solid-fg',
|
|
59
|
+
indicator: 'hidden'
|
|
60
|
+
},
|
|
61
|
+
outline: {
|
|
62
|
+
trigger: [
|
|
63
|
+
'border-(length:--border-width-tabs) border-transparent',
|
|
64
|
+
'data-[selected]:border-tabs-border-selected',
|
|
65
|
+
'data-[selected]:bg-tabs-trigger-bg-outline-selected'
|
|
66
|
+
],
|
|
67
|
+
indicator: 'hidden'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
size: {
|
|
71
|
+
sm: {
|
|
72
|
+
trigger: 'text-tabs-trigger-sm p-tabs-trigger-sm',
|
|
73
|
+
content: 'p-tabs-content-sm text-tabs-content-sm'
|
|
74
|
+
},
|
|
75
|
+
md: {
|
|
76
|
+
trigger: 'text-tabs-trigger-md p-tabs-trigger-md',
|
|
77
|
+
content: 'p-tabs-content-md text-tabs-content-md'
|
|
78
|
+
},
|
|
79
|
+
lg: {
|
|
80
|
+
trigger: 'text-tabs-trigger-lg p-tabs-trigger-lg',
|
|
81
|
+
content: 'p-tabs-content-lg text-tabs-content-lg'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
fitted: {
|
|
85
|
+
true: {
|
|
86
|
+
list: 'w-full',
|
|
87
|
+
trigger: 'flex-1'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
justify: {
|
|
91
|
+
start: {
|
|
92
|
+
list: 'justify-start'
|
|
93
|
+
},
|
|
94
|
+
center: {
|
|
95
|
+
list: 'justify-center'
|
|
96
|
+
},
|
|
97
|
+
end: {
|
|
98
|
+
list: 'justify-end'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
defaultVariants: {
|
|
103
|
+
variant: 'default',
|
|
104
|
+
size: 'md',
|
|
105
|
+
fitted: false
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const TabsContext = /*#__PURE__*/ createContext(null);
|
|
109
|
+
function useTabsContext() {
|
|
110
|
+
const context = useContext(TabsContext);
|
|
111
|
+
if (!context) throw new Error('Tabs components must be used within Tabs');
|
|
112
|
+
return context;
|
|
113
|
+
}
|
|
114
|
+
function Tabs({ id, defaultValue, value, orientation = 'horizontal', dir = 'ltr', activationMode = 'automatic', loopFocus = true, onValueChange, variant, size, fitted, justify, children, ref, className, ...props }) {
|
|
115
|
+
const generatedId = useId();
|
|
116
|
+
const uniqueId = id || generatedId;
|
|
117
|
+
const service = useMachine(machine, {
|
|
118
|
+
id: uniqueId,
|
|
119
|
+
value,
|
|
120
|
+
defaultValue,
|
|
121
|
+
orientation,
|
|
122
|
+
dir,
|
|
123
|
+
activationMode,
|
|
124
|
+
loopFocus,
|
|
125
|
+
onValueChange: ({ value })=>{
|
|
126
|
+
onValueChange?.(value);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const api = connect(service, normalizeProps);
|
|
130
|
+
const styles = tabsVariants({
|
|
131
|
+
variant,
|
|
132
|
+
size,
|
|
133
|
+
fitted,
|
|
134
|
+
justify
|
|
135
|
+
});
|
|
136
|
+
return /*#__PURE__*/ jsx(TabsContext.Provider, {
|
|
137
|
+
value: {
|
|
138
|
+
api,
|
|
139
|
+
variant,
|
|
140
|
+
size,
|
|
141
|
+
fitted,
|
|
142
|
+
justify,
|
|
143
|
+
styles
|
|
144
|
+
},
|
|
145
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
146
|
+
ref: ref,
|
|
147
|
+
className: styles.root({
|
|
148
|
+
className
|
|
149
|
+
}),
|
|
150
|
+
...api.getRootProps(),
|
|
151
|
+
...props,
|
|
152
|
+
children: children
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
Tabs.List = function({ children, ref, className, ...props }) {
|
|
157
|
+
const { api, styles } = useTabsContext();
|
|
158
|
+
return /*#__PURE__*/ jsx("div", {
|
|
159
|
+
ref: ref,
|
|
160
|
+
className: styles.list({
|
|
161
|
+
className
|
|
162
|
+
}),
|
|
163
|
+
...api.getListProps(),
|
|
164
|
+
...props,
|
|
165
|
+
children: children
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
Tabs.Trigger = function({ value, disabled, children, ref, className, ...props }) {
|
|
169
|
+
const { api, styles } = useTabsContext();
|
|
170
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
171
|
+
ref: ref,
|
|
172
|
+
theme: "borderless",
|
|
173
|
+
className: styles.trigger({
|
|
174
|
+
className
|
|
175
|
+
}),
|
|
176
|
+
...api.getTriggerProps({
|
|
177
|
+
value,
|
|
178
|
+
disabled
|
|
179
|
+
}),
|
|
180
|
+
"data-disabled": disabled || void 0,
|
|
181
|
+
...props,
|
|
182
|
+
children: children
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
Tabs.Content = function({ value, children, ref, className, ...props }) {
|
|
186
|
+
const { api, styles } = useTabsContext();
|
|
187
|
+
return /*#__PURE__*/ jsx("div", {
|
|
188
|
+
ref: ref,
|
|
189
|
+
className: styles.content({
|
|
190
|
+
className
|
|
191
|
+
}),
|
|
192
|
+
...api.getContentProps({
|
|
193
|
+
value
|
|
194
|
+
}),
|
|
195
|
+
...props,
|
|
196
|
+
children: children
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
Tabs.Indicator = function({ ref, className, ...props }) {
|
|
200
|
+
const { api, styles } = useTabsContext();
|
|
201
|
+
return /*#__PURE__*/ jsx("div", {
|
|
202
|
+
ref: ref,
|
|
203
|
+
className: styles.indicator({
|
|
204
|
+
className
|
|
205
|
+
}),
|
|
206
|
+
...api.getIndicatorProps(),
|
|
207
|
+
...props
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
Tabs.displayName = 'Tabs';
|
|
211
|
+
export { Tabs };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Portal, normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
+
import { connect, createStore, group as toast_group, machine } from "@zag-js/toast";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { Button } from "../atoms/button.js";
|
|
6
|
+
import { tv } from "../utils.js";
|
|
7
|
+
const toastVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
root: [
|
|
10
|
+
'flex flex-col relative rounded-toast-root',
|
|
11
|
+
'border-(length:--border-width-toast) bg-toast-bg shadow-lg',
|
|
12
|
+
'w-toast-width overflow-hidden p-toast-root',
|
|
13
|
+
'data-[type=error]:bg-toast-error-bg data-[type=error]:border-toast-error-border',
|
|
14
|
+
'data-[type=success]:bg-toast-success-bg data-[type=success]:border-toast-success-border',
|
|
15
|
+
'data-[type=info]:bg-toast-info-bg data-[type=info]:border-toast-info-border',
|
|
16
|
+
'data-[type=warning]:bg-toast-warning-bg data-[type=warning]:border-toast-warning-border',
|
|
17
|
+
'translate-x-[var(--x)] translate-y-[var(--y)]',
|
|
18
|
+
'scale-[var(--scale)] opacity-[var(--opacity)]',
|
|
19
|
+
'z-[var(--z-index)] h-[var(--height)]',
|
|
20
|
+
'will-change-[translate,opacity,scale]',
|
|
21
|
+
'transition-[translate,scale,opacity] duration-400'
|
|
22
|
+
],
|
|
23
|
+
group: 'flex flex-col relative',
|
|
24
|
+
header: 'flex relative items-center gap-toast-content',
|
|
25
|
+
icon: [
|
|
26
|
+
'flex-shrink-0 text-toast-icon-size',
|
|
27
|
+
'data-[type=error]:text-toast-error-icon data-[type=error]:token-icon-toast-error',
|
|
28
|
+
'data-[type=success]:text-toast-success-icon data-[type=success]:token-icon-toast-success',
|
|
29
|
+
'data-[type=info]:text-toast-info-icon data-[type=info]:token-icon-toast-info',
|
|
30
|
+
'data-[type=warning]:text-toast-warning-icon data-[type=warning]:token-icon-toast-warning'
|
|
31
|
+
],
|
|
32
|
+
title: [
|
|
33
|
+
'font-toast-title text-toast-title-size text-toast-fg',
|
|
34
|
+
'data-[type=error]:text-toast-error-title',
|
|
35
|
+
'data-[type=success]:text-toast-success-title',
|
|
36
|
+
'data-[type=info]:text-toast-info-title',
|
|
37
|
+
'data-[type=warning]:text-toast-warning-title'
|
|
38
|
+
],
|
|
39
|
+
description: [
|
|
40
|
+
"text-toast-description-size text-toast-fg mt-toast-description-gap"
|
|
41
|
+
],
|
|
42
|
+
closeButton: [
|
|
43
|
+
'grid place-items-center flex-shrink-0 ms-auto py-0 px-0',
|
|
44
|
+
'cursor-pointer',
|
|
45
|
+
'text-toast-close-fg hover:text-toast-close-fg-hover'
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function Toast({ actor, index, parent, placement }) {
|
|
50
|
+
const composedProps = {
|
|
51
|
+
...actor,
|
|
52
|
+
index,
|
|
53
|
+
parent,
|
|
54
|
+
placement
|
|
55
|
+
};
|
|
56
|
+
const service = useMachine(machine, composedProps);
|
|
57
|
+
const api = connect(service, normalizeProps);
|
|
58
|
+
const { root, header, icon, title, description, closeButton } = toastVariants();
|
|
59
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
60
|
+
className: root(),
|
|
61
|
+
...api.getRootProps(),
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsx("span", {
|
|
64
|
+
...api.getGhostBeforeProps()
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsxs("div", {
|
|
67
|
+
className: header(),
|
|
68
|
+
...api.getTitleProps(),
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ jsx("span", {
|
|
71
|
+
className: icon(),
|
|
72
|
+
"data-type": api.type
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ jsx("div", {
|
|
75
|
+
className: title(),
|
|
76
|
+
"data-type": api.type,
|
|
77
|
+
children: 'loading' === api.type ? 'loading...' : api.title
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsx(Button, {
|
|
80
|
+
theme: "borderless",
|
|
81
|
+
className: closeButton(),
|
|
82
|
+
...api.getCloseTriggerProps(),
|
|
83
|
+
icon: "token-icon-toast-close"
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ jsx("div", {
|
|
88
|
+
className: description(),
|
|
89
|
+
...api.getDescriptionProps(),
|
|
90
|
+
"data-type": api.type,
|
|
91
|
+
children: api.description
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ jsx("span", {
|
|
94
|
+
...api.getGhostAfterProps()
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const toaster = createStore({
|
|
100
|
+
placement: 'bottom-end',
|
|
101
|
+
gap: 16,
|
|
102
|
+
offsets: '24px'
|
|
103
|
+
});
|
|
104
|
+
function Toaster() {
|
|
105
|
+
const service = useMachine(toast_group.machine, {
|
|
106
|
+
id: useId(),
|
|
107
|
+
store: toaster
|
|
108
|
+
});
|
|
109
|
+
const api = toast_group.connect(service, normalizeProps);
|
|
110
|
+
const { group } = toastVariants();
|
|
111
|
+
return /*#__PURE__*/ jsx(Portal, {
|
|
112
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
113
|
+
className: group(),
|
|
114
|
+
...api.getGroupProps(),
|
|
115
|
+
children: api.getToasts().map((toast, index)=>/*#__PURE__*/ jsx(Toast, {
|
|
116
|
+
actor: toast,
|
|
117
|
+
index: index,
|
|
118
|
+
parent: service
|
|
119
|
+
}, toast.id))
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function useToast() {
|
|
124
|
+
return toaster;
|
|
125
|
+
}
|
|
126
|
+
export { Toast, Toaster, toaster, useToast };
|