@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,253 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { collection as combobox_collection, connect, machine } from "@zag-js/combobox";
|
|
3
|
+
import { Portal, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { useEffect, useId, useState } from "react";
|
|
5
|
+
import { Button } from "../atoms/button.js";
|
|
6
|
+
import { ErrorText } from "../atoms/error-text.js";
|
|
7
|
+
import { ExtraText } from "../atoms/extra-text.js";
|
|
8
|
+
import { Icon } from "../atoms/icon.js";
|
|
9
|
+
import { Input } from "../atoms/input.js";
|
|
10
|
+
import { Label } from "../atoms/label.js";
|
|
11
|
+
import { tv } from "../utils.js";
|
|
12
|
+
const comboboxVariants = tv({
|
|
13
|
+
slots: {
|
|
14
|
+
root: [
|
|
15
|
+
'flex flex-col relative w-full'
|
|
16
|
+
],
|
|
17
|
+
label: [
|
|
18
|
+
'block text-label-md font-label'
|
|
19
|
+
],
|
|
20
|
+
control: [
|
|
21
|
+
'flex items-center w-full relative',
|
|
22
|
+
'bg-combobox-bg border-(length:--border-width-combobox) border-combobox-border rounded-combobox',
|
|
23
|
+
'transition-colors duration-200 ease-in-out',
|
|
24
|
+
'hover:bg-combobox-bg-hover hover:border-combobox-border-hover',
|
|
25
|
+
'data-[focus]:bg-combobox-bg-focus data-[focus]:border-combobox-border-focus',
|
|
26
|
+
'data-[focus]:ring',
|
|
27
|
+
'data-[focus]:ring-combobox-ring',
|
|
28
|
+
'data-[disabled]:bg-combobox-bg-disabled data-[disabled]:border-combobox-border-disabled',
|
|
29
|
+
'data-[validation=error]:border-combobox-danger-fg',
|
|
30
|
+
'data-[validation=success]:border-combobox-success-fg',
|
|
31
|
+
'data-[validation=warning]:border-combobox-warning-fg'
|
|
32
|
+
],
|
|
33
|
+
input: [
|
|
34
|
+
'w-full relative border-none bg-combobox-input-bg',
|
|
35
|
+
'focus-visible:ring-0 hover:bg-combobox-input-bg-hover',
|
|
36
|
+
'focus:bg-combobox-input-bg-focused',
|
|
37
|
+
'placeholder:text-combobox-placeholder',
|
|
38
|
+
'data-[disabled]:text-combobox-fg-disabled',
|
|
39
|
+
'data-[disabled]:bg-combobox-bg-disabled'
|
|
40
|
+
],
|
|
41
|
+
clearTrigger: [
|
|
42
|
+
'absolute right-combobox-clear-right'
|
|
43
|
+
],
|
|
44
|
+
trigger: [
|
|
45
|
+
'flex items-center justify-center',
|
|
46
|
+
'p-combobox-trigger',
|
|
47
|
+
'transition-transform duration-200',
|
|
48
|
+
'data-[state=open]:rotate-180'
|
|
49
|
+
],
|
|
50
|
+
positioner: [
|
|
51
|
+
'z-(--z-index) w-full *:overflow-y-auto *:max-h-(--available-height)'
|
|
52
|
+
],
|
|
53
|
+
content: [
|
|
54
|
+
'flex flex-col overflow-clip',
|
|
55
|
+
'rounded-combobox shadow-md',
|
|
56
|
+
'bg-combobox-content-bg',
|
|
57
|
+
'border border-combobox-border z-(--z-combobox-content)'
|
|
58
|
+
],
|
|
59
|
+
item: [
|
|
60
|
+
'flex items-center',
|
|
61
|
+
'text-combobox-item-fg',
|
|
62
|
+
'cursor-pointer',
|
|
63
|
+
'data-[highlighted]:bg-combobox-item-bg-hover',
|
|
64
|
+
'data-[state=checked]:bg-combobox-item-bg-selected',
|
|
65
|
+
'data-[disabled]:text-combobox-fg-disabled data-[disabled]:cursor-not-allowed'
|
|
66
|
+
],
|
|
67
|
+
helper: [
|
|
68
|
+
'data-[validation=success]:text-combobox-success-fg',
|
|
69
|
+
'data-[validation=warning]:text-combobox-warning-fg'
|
|
70
|
+
],
|
|
71
|
+
multiple: []
|
|
72
|
+
},
|
|
73
|
+
compoundSlots: [
|
|
74
|
+
{
|
|
75
|
+
slots: [
|
|
76
|
+
'clearTrigger',
|
|
77
|
+
'trigger'
|
|
78
|
+
],
|
|
79
|
+
class: [
|
|
80
|
+
'focus-visible:ring-0',
|
|
81
|
+
'text-combobox-trigger text-combobox-trigger-size',
|
|
82
|
+
'hover:text-combobox-trigger-hover',
|
|
83
|
+
'px-combobox-trigger',
|
|
84
|
+
'hover:bg-combobox-trigger-bg-hover',
|
|
85
|
+
'focus-visible:outline-none',
|
|
86
|
+
'active:bg-combobox-trigger-bg-active'
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
variants: {
|
|
91
|
+
size: {
|
|
92
|
+
sm: {
|
|
93
|
+
root: 'gap-combobox-root-sm',
|
|
94
|
+
item: 'p-combobox-item-sm',
|
|
95
|
+
input: 'py-combobox-input-sm',
|
|
96
|
+
content: 'text-combobox-content-sm'
|
|
97
|
+
},
|
|
98
|
+
md: {
|
|
99
|
+
root: 'gap-combobox-root-md',
|
|
100
|
+
item: 'p-combobox-item-md',
|
|
101
|
+
input: 'py-combobox-input-md',
|
|
102
|
+
content: 'text-combobox-content-md'
|
|
103
|
+
},
|
|
104
|
+
lg: {
|
|
105
|
+
root: 'gap-combobox-root-lg',
|
|
106
|
+
item: 'p-combobox-item-lg',
|
|
107
|
+
input: 'py-combobox-input-lg',
|
|
108
|
+
content: 'text-combobox-content-lg'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
defaultVariants: {
|
|
113
|
+
size: 'md'
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
function Combobox({ id, name, label, size, placeholder = 'Select option', disabled = false, readOnly = false, required = false, items = [], value, defaultValue, inputValue, multiple = false, validationState = 'normal', error, helper, noResultsMessage = 'No results found for "{inputValue}"', clearable = true, selectionBehavior = 'replace', closeOnSelect = false, allowCustomValue = false, loopFocus = true, autoFocus = false, inputBehavior = 'autocomplete', onChange, onInputValueChange, onOpenChange }) {
|
|
117
|
+
const generatedId = useId();
|
|
118
|
+
const uniqueId = id || generatedId;
|
|
119
|
+
const [options, setOptions] = useState(items);
|
|
120
|
+
useEffect(()=>{
|
|
121
|
+
setOptions(items);
|
|
122
|
+
}, [
|
|
123
|
+
items
|
|
124
|
+
]);
|
|
125
|
+
const collection = combobox_collection({
|
|
126
|
+
items: options,
|
|
127
|
+
itemToString: (item)=>item.label,
|
|
128
|
+
itemToValue: (item)=>item.value,
|
|
129
|
+
isItemDisabled: (item)=>!!item.disabled
|
|
130
|
+
});
|
|
131
|
+
const service = useMachine(machine, {
|
|
132
|
+
id: uniqueId,
|
|
133
|
+
name,
|
|
134
|
+
collection,
|
|
135
|
+
disabled,
|
|
136
|
+
readOnly,
|
|
137
|
+
closeOnSelect,
|
|
138
|
+
selectionBehavior,
|
|
139
|
+
allowCustomValue,
|
|
140
|
+
autoFocus,
|
|
141
|
+
inputBehavior,
|
|
142
|
+
loopFocus,
|
|
143
|
+
ids: {
|
|
144
|
+
label: `${uniqueId}-label`,
|
|
145
|
+
input: `${uniqueId}-input`,
|
|
146
|
+
control: `${uniqueId}-control`
|
|
147
|
+
},
|
|
148
|
+
value: value,
|
|
149
|
+
defaultValue: defaultValue,
|
|
150
|
+
multiple,
|
|
151
|
+
inputValue,
|
|
152
|
+
onValueChange: ({ value: selectedValue })=>{
|
|
153
|
+
onChange?.(selectedValue);
|
|
154
|
+
},
|
|
155
|
+
onInputValueChange: ({ inputValue })=>{
|
|
156
|
+
const filtered = items.filter((item)=>item.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
157
|
+
setOptions(filtered);
|
|
158
|
+
onInputValueChange?.(inputValue);
|
|
159
|
+
},
|
|
160
|
+
onOpenChange: ({ open })=>{
|
|
161
|
+
setOptions(items);
|
|
162
|
+
onOpenChange?.(open);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const api = connect(service, normalizeProps);
|
|
166
|
+
const inputProps = api.getInputProps();
|
|
167
|
+
const { ...restInputProps } = inputProps;
|
|
168
|
+
const { root, label: labelStyles, control, input, trigger, positioner, content, clearTrigger, item: itemSlot, helper: helperSlot } = comboboxVariants({
|
|
169
|
+
size
|
|
170
|
+
});
|
|
171
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
172
|
+
className: root(),
|
|
173
|
+
children: [
|
|
174
|
+
label && /*#__PURE__*/ jsx(Label, {
|
|
175
|
+
className: labelStyles(),
|
|
176
|
+
size: size,
|
|
177
|
+
required: required,
|
|
178
|
+
...api.getLabelProps(),
|
|
179
|
+
children: label
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ jsxs("div", {
|
|
182
|
+
className: control(),
|
|
183
|
+
...api.getControlProps(),
|
|
184
|
+
"data-validation": validationState,
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ jsx(Input, {
|
|
187
|
+
className: input(),
|
|
188
|
+
...restInputProps,
|
|
189
|
+
placeholder: placeholder,
|
|
190
|
+
name: name,
|
|
191
|
+
required: required,
|
|
192
|
+
size: size
|
|
193
|
+
}),
|
|
194
|
+
clearable && api.value.length > 0 && /*#__PURE__*/ jsx(Button, {
|
|
195
|
+
className: clearTrigger(),
|
|
196
|
+
theme: "borderless",
|
|
197
|
+
size: size,
|
|
198
|
+
...api.getClearTriggerProps(),
|
|
199
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
200
|
+
icon: 'token-icon-combobox-clear',
|
|
201
|
+
size: "current"
|
|
202
|
+
})
|
|
203
|
+
}),
|
|
204
|
+
/*#__PURE__*/ jsx(Button, {
|
|
205
|
+
...api.getTriggerProps(),
|
|
206
|
+
theme: "borderless",
|
|
207
|
+
size: size,
|
|
208
|
+
className: trigger(),
|
|
209
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
210
|
+
icon: "token-icon-combobox-chevron"
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ jsx(Portal, {
|
|
216
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
217
|
+
...api.getPositionerProps(),
|
|
218
|
+
className: positioner(),
|
|
219
|
+
children: [
|
|
220
|
+
api.open && options.length > 0 && /*#__PURE__*/ jsx("ul", {
|
|
221
|
+
...api.getContentProps(),
|
|
222
|
+
className: content(),
|
|
223
|
+
children: options.map((item)=>/*#__PURE__*/ jsx("li", {
|
|
224
|
+
...api.getItemProps({
|
|
225
|
+
item
|
|
226
|
+
}),
|
|
227
|
+
className: itemSlot(),
|
|
228
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
229
|
+
className: "flex-1",
|
|
230
|
+
children: item.label
|
|
231
|
+
})
|
|
232
|
+
}, item.value))
|
|
233
|
+
}),
|
|
234
|
+
api.open && api.inputValue && 0 === options.length && /*#__PURE__*/ jsx("div", {
|
|
235
|
+
className: content(),
|
|
236
|
+
children: noResultsMessage.replace('{inputValue}', api.inputValue)
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
})
|
|
240
|
+
}),
|
|
241
|
+
helper && !error && /*#__PURE__*/ jsx(ExtraText, {
|
|
242
|
+
"data-validation": validationState,
|
|
243
|
+
size: size,
|
|
244
|
+
className: helperSlot(),
|
|
245
|
+
children: helper
|
|
246
|
+
}),
|
|
247
|
+
error && /*#__PURE__*/ jsx(ErrorText, {
|
|
248
|
+
children: error
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
export { Combobox };
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { connect, machine } from "@zag-js/dialog";
|
|
3
|
+
import { Portal, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { tv } from "tailwind-variants";
|
|
6
|
+
import { Button } from "../atoms/button.js";
|
|
7
|
+
const dialogVariants = tv({
|
|
8
|
+
slots: {
|
|
9
|
+
backdrop: [
|
|
10
|
+
'inset-0 z-(--z-dialog-backdrop)'
|
|
11
|
+
],
|
|
12
|
+
positioner: [
|
|
13
|
+
'inset-0 z-(--z-dialog-positioner) flex'
|
|
14
|
+
],
|
|
15
|
+
content: [
|
|
16
|
+
'relative flex flex-col p-dialog-content gap-dialog-content',
|
|
17
|
+
'bg-dialog-content-bg text-dialog-content-fg',
|
|
18
|
+
'border-(length:--border-width-dialog) border-dialog-content-border',
|
|
19
|
+
'shadow-dialog-content',
|
|
20
|
+
'overflow-y-auto',
|
|
21
|
+
'focus-visible:outline-none',
|
|
22
|
+
'focus-visible:ring',
|
|
23
|
+
'focus-visible:ring-dialog-ring'
|
|
24
|
+
],
|
|
25
|
+
title: [
|
|
26
|
+
'text-dialog-title-size font-dialog-title text-dialog-title-fg'
|
|
27
|
+
],
|
|
28
|
+
description: [
|
|
29
|
+
"text-dialog-description-size text-dialog-description-fg"
|
|
30
|
+
],
|
|
31
|
+
trigger: [],
|
|
32
|
+
closeTrigger: [
|
|
33
|
+
'absolute top-dialog-close-trigger-offset right-dialog-close-trigger-offset',
|
|
34
|
+
'flex items-center justify-center',
|
|
35
|
+
'p-dialog-close-trigger-padding rounded-dialog-close-trigger',
|
|
36
|
+
'text-dialog-close-trigger-fg',
|
|
37
|
+
'focus-visible:outline-none',
|
|
38
|
+
'focus-visible:ring',
|
|
39
|
+
'focus-visible:ring-dialog-ring'
|
|
40
|
+
],
|
|
41
|
+
actions: 'mt-auto flex shrink-0 justify-end gap-dialog-actions pt-dialog-actions'
|
|
42
|
+
},
|
|
43
|
+
variants: {
|
|
44
|
+
placement: {
|
|
45
|
+
center: {
|
|
46
|
+
positioner: 'items-center justify-center',
|
|
47
|
+
content: 'max-w-dialog-center-w-max max-h-dialog-center-h-max rounded-dialog-center'
|
|
48
|
+
},
|
|
49
|
+
left: {
|
|
50
|
+
positioner: 'items-stretch justify-start',
|
|
51
|
+
content: 'h-full rounded-dialog-left border-l-0'
|
|
52
|
+
},
|
|
53
|
+
right: {
|
|
54
|
+
positioner: 'items-stretch justify-end',
|
|
55
|
+
content: 'h-full rounded-dialog-right border-r-0'
|
|
56
|
+
},
|
|
57
|
+
top: {
|
|
58
|
+
positioner: 'items-start justify-stretch',
|
|
59
|
+
content: 'w-full rounded-dialog-top border-t-0'
|
|
60
|
+
},
|
|
61
|
+
bottom: {
|
|
62
|
+
positioner: 'items-end justify-stretch',
|
|
63
|
+
content: 'w-full rounded-dialog-bottom border-b-0'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
position: {
|
|
67
|
+
fixed: {
|
|
68
|
+
backdrop: 'fixed',
|
|
69
|
+
positioner: 'fixed'
|
|
70
|
+
},
|
|
71
|
+
absolute: {
|
|
72
|
+
backdrop: 'absolute',
|
|
73
|
+
positioner: 'absolute'
|
|
74
|
+
},
|
|
75
|
+
sticky: {
|
|
76
|
+
backdrop: 'sticky',
|
|
77
|
+
positioner: 'sticky'
|
|
78
|
+
},
|
|
79
|
+
relative: {
|
|
80
|
+
backdrop: 'relative',
|
|
81
|
+
positioner: 'relative'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
size: {
|
|
85
|
+
xs: {},
|
|
86
|
+
sm: {},
|
|
87
|
+
md: {},
|
|
88
|
+
lg: {},
|
|
89
|
+
xl: {},
|
|
90
|
+
full: {}
|
|
91
|
+
},
|
|
92
|
+
behavior: {
|
|
93
|
+
modal: {
|
|
94
|
+
backdrop: 'bg-dialog-backdrop-bg'
|
|
95
|
+
},
|
|
96
|
+
modeless: {
|
|
97
|
+
backdrop: 'bg-transparent',
|
|
98
|
+
positioner: 'pointer-events-none',
|
|
99
|
+
content: 'pointer-events-auto'
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
compoundVariants: [
|
|
104
|
+
{
|
|
105
|
+
placement: [
|
|
106
|
+
'left',
|
|
107
|
+
'right'
|
|
108
|
+
],
|
|
109
|
+
size: 'xs',
|
|
110
|
+
class: {
|
|
111
|
+
content: 'w-dialog-xs'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
placement: [
|
|
116
|
+
'left',
|
|
117
|
+
'right'
|
|
118
|
+
],
|
|
119
|
+
size: 'sm',
|
|
120
|
+
class: {
|
|
121
|
+
content: 'w-dialog-sm'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
placement: [
|
|
126
|
+
'left',
|
|
127
|
+
'right'
|
|
128
|
+
],
|
|
129
|
+
size: 'md',
|
|
130
|
+
class: {
|
|
131
|
+
content: 'w-dialog-md'
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
placement: [
|
|
136
|
+
'left',
|
|
137
|
+
'right'
|
|
138
|
+
],
|
|
139
|
+
size: 'lg',
|
|
140
|
+
class: {
|
|
141
|
+
content: 'w-dialog-lg'
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
placement: [
|
|
146
|
+
'left',
|
|
147
|
+
'right'
|
|
148
|
+
],
|
|
149
|
+
size: 'xl',
|
|
150
|
+
class: {
|
|
151
|
+
content: 'w-dialog-xl'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
placement: [
|
|
156
|
+
'left',
|
|
157
|
+
'right'
|
|
158
|
+
],
|
|
159
|
+
size: 'full',
|
|
160
|
+
class: {
|
|
161
|
+
content: 'w-full'
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
placement: [
|
|
166
|
+
'top',
|
|
167
|
+
'bottom'
|
|
168
|
+
],
|
|
169
|
+
size: 'xs',
|
|
170
|
+
class: {
|
|
171
|
+
content: 'h-dialog-xs'
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
placement: [
|
|
176
|
+
'top',
|
|
177
|
+
'bottom'
|
|
178
|
+
],
|
|
179
|
+
size: 'sm',
|
|
180
|
+
class: {
|
|
181
|
+
content: 'h-dialog-sm'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
placement: [
|
|
186
|
+
'top',
|
|
187
|
+
'bottom'
|
|
188
|
+
],
|
|
189
|
+
size: 'md',
|
|
190
|
+
class: {
|
|
191
|
+
content: 'h-dialog-md'
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
placement: [
|
|
196
|
+
'top',
|
|
197
|
+
'bottom'
|
|
198
|
+
],
|
|
199
|
+
size: 'lg',
|
|
200
|
+
class: {
|
|
201
|
+
content: 'h-dialog-lg'
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
placement: [
|
|
206
|
+
'top',
|
|
207
|
+
'bottom'
|
|
208
|
+
],
|
|
209
|
+
size: 'xl',
|
|
210
|
+
class: {
|
|
211
|
+
content: 'h-dialog-xl'
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
placement: [
|
|
216
|
+
'top',
|
|
217
|
+
'bottom'
|
|
218
|
+
],
|
|
219
|
+
size: 'full',
|
|
220
|
+
class: {
|
|
221
|
+
content: 'h-full'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
defaultVariants: {
|
|
226
|
+
placement: 'center',
|
|
227
|
+
behavior: 'modal',
|
|
228
|
+
size: 'md',
|
|
229
|
+
position: 'fixed'
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
function Dialog({ id, open, onOpenChange, initialFocusEl, finalFocusEl, role = 'dialog', placement = 'center', position = 'fixed', size = 'md', behavior = 'modal', closeOnEscape = true, closeOnInteractOutside = true, preventScroll = true, trapFocus = true, customTrigger = false, triggerText = 'Open', title, description, children, hideCloseButton = false, actions, className, modal = true, portal = true }) {
|
|
233
|
+
const generatedId = useId();
|
|
234
|
+
const uniqueId = id || generatedId;
|
|
235
|
+
const service = useMachine(machine, {
|
|
236
|
+
id: uniqueId,
|
|
237
|
+
onOpenChange,
|
|
238
|
+
role,
|
|
239
|
+
closeOnEscape,
|
|
240
|
+
closeOnInteractOutside,
|
|
241
|
+
preventScroll,
|
|
242
|
+
trapFocus,
|
|
243
|
+
initialFocusEl,
|
|
244
|
+
finalFocusEl,
|
|
245
|
+
modal,
|
|
246
|
+
...void 0 !== open && {
|
|
247
|
+
open
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
const api = connect(service, normalizeProps);
|
|
251
|
+
const { backdrop, positioner, content, trigger: triggerSlot, title: titleSlot, description: descriptionSlot, closeTrigger, actions: actionsSlot } = dialogVariants({
|
|
252
|
+
placement,
|
|
253
|
+
size,
|
|
254
|
+
behavior,
|
|
255
|
+
position
|
|
256
|
+
});
|
|
257
|
+
const dialogContent = ()=>/*#__PURE__*/ jsxs(Fragment, {
|
|
258
|
+
children: [
|
|
259
|
+
/*#__PURE__*/ jsx("div", {
|
|
260
|
+
className: backdrop(),
|
|
261
|
+
...api.getBackdropProps()
|
|
262
|
+
}),
|
|
263
|
+
/*#__PURE__*/ jsx("div", {
|
|
264
|
+
className: positioner(),
|
|
265
|
+
...api.getPositionerProps(),
|
|
266
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
267
|
+
className: content({
|
|
268
|
+
className
|
|
269
|
+
}),
|
|
270
|
+
...api.getContentProps(),
|
|
271
|
+
children: [
|
|
272
|
+
!hideCloseButton && /*#__PURE__*/ jsx(Button, {
|
|
273
|
+
theme: "borderless",
|
|
274
|
+
className: closeTrigger(),
|
|
275
|
+
...api.getCloseTriggerProps(),
|
|
276
|
+
icon: "token-icon-dialog-close"
|
|
277
|
+
}),
|
|
278
|
+
title && /*#__PURE__*/ jsx("h2", {
|
|
279
|
+
className: titleSlot(),
|
|
280
|
+
...api.getTitleProps(),
|
|
281
|
+
children: title
|
|
282
|
+
}),
|
|
283
|
+
description && /*#__PURE__*/ jsx("div", {
|
|
284
|
+
className: descriptionSlot(),
|
|
285
|
+
...api.getDescriptionProps(),
|
|
286
|
+
children: description
|
|
287
|
+
}),
|
|
288
|
+
children,
|
|
289
|
+
actions && /*#__PURE__*/ jsx("div", {
|
|
290
|
+
className: actionsSlot(),
|
|
291
|
+
children: actions
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
299
|
+
children: [
|
|
300
|
+
!customTrigger && /*#__PURE__*/ jsx(Button, {
|
|
301
|
+
size: "sm",
|
|
302
|
+
variant: "primary",
|
|
303
|
+
className: triggerSlot(),
|
|
304
|
+
...api.getTriggerProps(),
|
|
305
|
+
children: triggerText
|
|
306
|
+
}),
|
|
307
|
+
api.open && (portal ? /*#__PURE__*/ jsx(Portal, {
|
|
308
|
+
children: dialogContent()
|
|
309
|
+
}) : dialogContent())
|
|
310
|
+
]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
export { Dialog };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorText } from "../atoms/error-text.js";
|
|
3
|
+
import { ExtraText } from "../atoms/extra-text.js";
|
|
4
|
+
import { Label } from "../atoms/label.js";
|
|
5
|
+
import { Checkbox } from "./checkbox.js";
|
|
6
|
+
function FormCheckboxRaw({ id, label, validateStatus = 'default', helpText, extraText, size = 'md', required, disabled, ...props }) {
|
|
7
|
+
const extraTextId = extraText ? `${id}-extra` : void 0;
|
|
8
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
9
|
+
className: "flex gap-150",
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: "mt-2 flex items-start",
|
|
13
|
+
children: /*#__PURE__*/ jsx(Checkbox, {
|
|
14
|
+
id: id,
|
|
15
|
+
required: required,
|
|
16
|
+
disabled: disabled,
|
|
17
|
+
...props
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsxs("div", {
|
|
21
|
+
className: "flex flex-col",
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(Label, {
|
|
24
|
+
htmlFor: id,
|
|
25
|
+
size: size,
|
|
26
|
+
required: required,
|
|
27
|
+
disabled: disabled,
|
|
28
|
+
children: label
|
|
29
|
+
}),
|
|
30
|
+
helpText,
|
|
31
|
+
extraText && /*#__PURE__*/ jsx(ExtraText, {
|
|
32
|
+
id: extraTextId,
|
|
33
|
+
size: size,
|
|
34
|
+
children: extraText
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function FormCheckbox({ helpText, id, validateStatus, size, ...props }) {
|
|
42
|
+
const helpTextId = helpText ? `${id}-helper` : void 0;
|
|
43
|
+
return /*#__PURE__*/ jsx(FormCheckboxRaw, {
|
|
44
|
+
id: id,
|
|
45
|
+
size: size,
|
|
46
|
+
validateStatus: validateStatus,
|
|
47
|
+
helpText: 'error' === validateStatus ? /*#__PURE__*/ jsx(ErrorText, {
|
|
48
|
+
id: helpTextId,
|
|
49
|
+
size: size,
|
|
50
|
+
children: helpText
|
|
51
|
+
}) : helpText ?? /*#__PURE__*/ jsx(ExtraText, {
|
|
52
|
+
id: helpTextId,
|
|
53
|
+
size: size,
|
|
54
|
+
children: helpText
|
|
55
|
+
}),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export { FormCheckbox, FormCheckboxRaw };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorText } from "../atoms/error-text.js";
|
|
3
|
+
import { ExtraText } from "../atoms/extra-text.js";
|
|
4
|
+
import { Input } from "../atoms/input.js";
|
|
5
|
+
import { Label } from "../atoms/label.js";
|
|
6
|
+
function FormInputRaw({ id, label, validateStatus = 'default', helpText, extraText, size = 'md', required, disabled, ...props }) {
|
|
7
|
+
const extraTextId = extraText ? `${id}-extra` : void 0;
|
|
8
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
9
|
+
className: "flex flex-col gap-1",
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx(Label, {
|
|
12
|
+
htmlFor: id,
|
|
13
|
+
size: size,
|
|
14
|
+
required: required,
|
|
15
|
+
disabled: disabled,
|
|
16
|
+
children: label
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx(Input, {
|
|
19
|
+
id: id,
|
|
20
|
+
size: size,
|
|
21
|
+
required: required,
|
|
22
|
+
variant: validateStatus,
|
|
23
|
+
disabled: disabled,
|
|
24
|
+
...props,
|
|
25
|
+
className: "p-input-sm md:p-input-md"
|
|
26
|
+
}),
|
|
27
|
+
helpText,
|
|
28
|
+
extraText && /*#__PURE__*/ jsx(ExtraText, {
|
|
29
|
+
id: extraTextId,
|
|
30
|
+
size: size,
|
|
31
|
+
children: extraText
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function FormInput({ helpText, id, validateStatus, size, ...props }) {
|
|
37
|
+
const helpTextId = helpText ? `${id}-helper` : void 0;
|
|
38
|
+
return /*#__PURE__*/ jsx(FormInputRaw, {
|
|
39
|
+
id: id,
|
|
40
|
+
size: size,
|
|
41
|
+
validateStatus: validateStatus,
|
|
42
|
+
helpText: 'error' === validateStatus ? /*#__PURE__*/ jsx(ErrorText, {
|
|
43
|
+
id: helpTextId,
|
|
44
|
+
size: size,
|
|
45
|
+
showIcon: true,
|
|
46
|
+
children: helpText
|
|
47
|
+
}) : /*#__PURE__*/ jsx(ExtraText, {
|
|
48
|
+
id: helpTextId,
|
|
49
|
+
size: size,
|
|
50
|
+
children: helpText
|
|
51
|
+
}),
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { FormInput, FormInputRaw };
|