@dev-dga/react 0.2.0 → 0.4.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/CHANGELOG.md +48 -0
- package/README.md +54 -6
- package/dist/index.cjs +906 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -5
- package/dist/index.d.ts +152 -5
- package/dist/index.js +878 -36
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -20,23 +20,59 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
Alert: () => Alert,
|
|
24
|
+
AlertDescription: () => AlertDescription,
|
|
25
|
+
AlertTitle: () => AlertTitle,
|
|
23
26
|
Button: () => Button,
|
|
24
27
|
Checkbox: () => Checkbox,
|
|
25
28
|
DgaProvider: () => DgaProvider,
|
|
29
|
+
FieldMessage: () => FieldMessage,
|
|
26
30
|
Input: () => Input,
|
|
31
|
+
Modal: () => Modal,
|
|
32
|
+
ModalClose: () => ModalClose,
|
|
33
|
+
ModalContent: () => ModalContent,
|
|
34
|
+
ModalDescription: () => ModalDescription,
|
|
35
|
+
ModalFooter: () => ModalFooter,
|
|
36
|
+
ModalHeader: () => ModalHeader,
|
|
37
|
+
ModalTitle: () => ModalTitle,
|
|
38
|
+
ModalTrigger: () => ModalTrigger,
|
|
39
|
+
Radio: () => Radio,
|
|
40
|
+
RadioGroup: () => RadioGroup,
|
|
41
|
+
Select: () => Select,
|
|
42
|
+
SelectItem: () => SelectItem,
|
|
43
|
+
Switch: () => Switch,
|
|
27
44
|
Textarea: () => Textarea,
|
|
45
|
+
Toaster: () => Toaster,
|
|
46
|
+
Tooltip: () => Tooltip,
|
|
47
|
+
TooltipContent: () => TooltipContent,
|
|
48
|
+
TooltipTrigger: () => TooltipTrigger,
|
|
49
|
+
alertVariants: () => alertVariants,
|
|
28
50
|
buttonVariants: () => buttonVariants,
|
|
29
51
|
checkboxVariants: () => checkboxVariants,
|
|
30
52
|
cn: () => cn,
|
|
53
|
+
createToast: () => createToast,
|
|
54
|
+
createToastStore: () => createToastStore,
|
|
31
55
|
inputVariants: () => inputVariants,
|
|
56
|
+
modalContentVariants: () => modalContentVariants,
|
|
57
|
+
radioGroupVariants: () => radioGroupVariants,
|
|
58
|
+
radioVariants: () => radioVariants,
|
|
59
|
+
selectTriggerVariants: () => selectTriggerVariants,
|
|
60
|
+
switchVariants: () => switchVariants,
|
|
32
61
|
textareaVariants: () => textareaVariants,
|
|
62
|
+
toast: () => toast,
|
|
63
|
+
toastStore: () => toastStore,
|
|
64
|
+
toastVariants: () => toastVariants,
|
|
65
|
+
toastViewportVariants: () => toastViewportVariants,
|
|
66
|
+
tooltipContentVariants: () => tooltipContentVariants,
|
|
33
67
|
useDga: () => useDga,
|
|
34
|
-
useDir: () => useDir
|
|
68
|
+
useDir: () => useDir,
|
|
69
|
+
useFieldA11y: () => useFieldA11y
|
|
35
70
|
});
|
|
36
71
|
module.exports = __toCommonJS(src_exports);
|
|
37
72
|
|
|
38
73
|
// src/components/Button/Button.tsx
|
|
39
74
|
var import_react = require("react");
|
|
75
|
+
var import_radix_ui = require("radix-ui");
|
|
40
76
|
var import_class_variance_authority = require("class-variance-authority");
|
|
41
77
|
|
|
42
78
|
// src/utils/cn.ts
|
|
@@ -102,6 +138,111 @@ function Minus(props) {
|
|
|
102
138
|
}
|
|
103
139
|
);
|
|
104
140
|
}
|
|
141
|
+
function Info(props) {
|
|
142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
143
|
+
"svg",
|
|
144
|
+
{
|
|
145
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
146
|
+
width: "1em",
|
|
147
|
+
height: "1em",
|
|
148
|
+
viewBox: "0 0 24 24",
|
|
149
|
+
fill: "none",
|
|
150
|
+
stroke: "currentColor",
|
|
151
|
+
strokeWidth: "2",
|
|
152
|
+
strokeLinecap: "round",
|
|
153
|
+
strokeLinejoin: "round",
|
|
154
|
+
...props,
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16v-4" }),
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 8h.01" })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function AlertTriangle(props) {
|
|
164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
165
|
+
"svg",
|
|
166
|
+
{
|
|
167
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
168
|
+
width: "1em",
|
|
169
|
+
height: "1em",
|
|
170
|
+
viewBox: "0 0 24 24",
|
|
171
|
+
fill: "none",
|
|
172
|
+
stroke: "currentColor",
|
|
173
|
+
strokeWidth: "2",
|
|
174
|
+
strokeLinecap: "round",
|
|
175
|
+
strokeLinejoin: "round",
|
|
176
|
+
...props,
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 9v4" }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 17h.01" })
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
function AlertCircle(props) {
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
187
|
+
"svg",
|
|
188
|
+
{
|
|
189
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
190
|
+
width: "1em",
|
|
191
|
+
height: "1em",
|
|
192
|
+
viewBox: "0 0 24 24",
|
|
193
|
+
fill: "none",
|
|
194
|
+
stroke: "currentColor",
|
|
195
|
+
strokeWidth: "2",
|
|
196
|
+
strokeLinecap: "round",
|
|
197
|
+
strokeLinejoin: "round",
|
|
198
|
+
...props,
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function Close(props) {
|
|
208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
209
|
+
"svg",
|
|
210
|
+
{
|
|
211
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
212
|
+
width: "1em",
|
|
213
|
+
height: "1em",
|
|
214
|
+
viewBox: "0 0 24 24",
|
|
215
|
+
fill: "none",
|
|
216
|
+
stroke: "currentColor",
|
|
217
|
+
strokeWidth: "2",
|
|
218
|
+
strokeLinecap: "round",
|
|
219
|
+
strokeLinejoin: "round",
|
|
220
|
+
...props,
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }),
|
|
223
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function ChevronDown(props) {
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
+
"svg",
|
|
231
|
+
{
|
|
232
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
233
|
+
width: "1em",
|
|
234
|
+
height: "1em",
|
|
235
|
+
viewBox: "0 0 24 24",
|
|
236
|
+
fill: "none",
|
|
237
|
+
stroke: "currentColor",
|
|
238
|
+
strokeWidth: "2",
|
|
239
|
+
strokeLinecap: "round",
|
|
240
|
+
strokeLinejoin: "round",
|
|
241
|
+
...props,
|
|
242
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}
|
|
105
246
|
|
|
106
247
|
// src/components/Button/Button.tsx
|
|
107
248
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -140,6 +281,7 @@ function Button({
|
|
|
140
281
|
startIcon,
|
|
141
282
|
endIcon,
|
|
142
283
|
iconFlip,
|
|
284
|
+
asChild,
|
|
143
285
|
className,
|
|
144
286
|
children,
|
|
145
287
|
type = "button",
|
|
@@ -153,11 +295,12 @@ function Button({
|
|
|
153
295
|
}
|
|
154
296
|
}
|
|
155
297
|
const isDisabled = disabled || loading;
|
|
298
|
+
const Comp = asChild ? import_radix_ui.Slot.Slot : "button";
|
|
156
299
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
157
|
-
|
|
300
|
+
Comp,
|
|
158
301
|
{
|
|
159
|
-
type,
|
|
160
|
-
|
|
302
|
+
...asChild ? {} : { type, disabled: isDisabled },
|
|
303
|
+
...asChild && isDisabled ? { tabIndex: -1 } : {},
|
|
161
304
|
"aria-disabled": isDisabled || void 0,
|
|
162
305
|
"aria-busy": loading || void 0,
|
|
163
306
|
"data-slot": "button",
|
|
@@ -170,7 +313,12 @@ function Button({
|
|
|
170
313
|
children: [
|
|
171
314
|
loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, { "aria-hidden": "true" }),
|
|
172
315
|
!loading && startIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: cn("ddga-button__icon", iconFlip && "ddga-icon-flip"), "aria-hidden": "true", children: startIcon }),
|
|
173
|
-
|
|
316
|
+
asChild ? (
|
|
317
|
+
// children IS the consumer's single element (e.g. <Link>). Slottable
|
|
318
|
+
// marks where THAT element's original children should land , without
|
|
319
|
+
// it the icons would replace the link text entirely.
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_radix_ui.Slot.Slottable, { children })
|
|
321
|
+
) : children != null && children !== "" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ddga-button__text", children }),
|
|
174
322
|
!loading && endIcon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: cn("ddga-button__icon", iconFlip && "ddga-icon-flip"), "aria-hidden": "true", children: endIcon })
|
|
175
323
|
]
|
|
176
324
|
}
|
|
@@ -180,7 +328,7 @@ function Button({
|
|
|
180
328
|
// src/components/Input/Input.tsx
|
|
181
329
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
182
330
|
|
|
183
|
-
// src/
|
|
331
|
+
// src/field/use-field-a11y.ts
|
|
184
332
|
var import_react2 = require("react");
|
|
185
333
|
function isPresent(value) {
|
|
186
334
|
return value != null && value !== "";
|
|
@@ -190,7 +338,7 @@ function useFieldA11y(options) {
|
|
|
190
338
|
const fieldId = options.id ?? generatedId;
|
|
191
339
|
const helperId = `${fieldId}-helper`;
|
|
192
340
|
const errorId = `${fieldId}-error`;
|
|
193
|
-
const hasError = !!options.error;
|
|
341
|
+
const hasError = !!options.error || isPresent(options.errorMessage);
|
|
194
342
|
const hasErrorMessage = hasError && isPresent(options.errorMessage);
|
|
195
343
|
const hasHelper = !hasErrorMessage && isPresent(options.helperText);
|
|
196
344
|
if (process.env.NODE_ENV === "development" && !options.label) {
|
|
@@ -215,7 +363,7 @@ function useFieldA11y(options) {
|
|
|
215
363
|
};
|
|
216
364
|
}
|
|
217
365
|
|
|
218
|
-
// src/
|
|
366
|
+
// src/field/FieldMessage.tsx
|
|
219
367
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
220
368
|
function FieldMessage({ id, variant, children }) {
|
|
221
369
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -385,7 +533,7 @@ function Textarea({
|
|
|
385
533
|
}
|
|
386
534
|
|
|
387
535
|
// src/components/Checkbox/Checkbox.tsx
|
|
388
|
-
var
|
|
536
|
+
var import_radix_ui2 = require("radix-ui");
|
|
389
537
|
var import_class_variance_authority4 = require("class-variance-authority");
|
|
390
538
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
391
539
|
var checkboxVariants = (0, import_class_variance_authority4.cva)("ddga-checkbox", {
|
|
@@ -426,7 +574,7 @@ function Checkbox({
|
|
|
426
574
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-slot": "checkbox-field", className: "ddga-field", children: [
|
|
427
575
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ddga-checkbox-row", children: [
|
|
428
576
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
429
|
-
|
|
577
|
+
import_radix_ui2.Checkbox.Root,
|
|
430
578
|
{
|
|
431
579
|
...props,
|
|
432
580
|
...controlProps,
|
|
@@ -434,7 +582,7 @@ function Checkbox({
|
|
|
434
582
|
required,
|
|
435
583
|
className: cn(checkboxVariants({ size, error: hasError }), className),
|
|
436
584
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
437
|
-
|
|
585
|
+
import_radix_ui2.Checkbox.Indicator,
|
|
438
586
|
{
|
|
439
587
|
"data-slot": "checkbox-indicator",
|
|
440
588
|
className: "ddga-checkbox__indicator",
|
|
@@ -456,52 +604,746 @@ function Checkbox({
|
|
|
456
604
|
] });
|
|
457
605
|
}
|
|
458
606
|
|
|
459
|
-
// src/
|
|
460
|
-
var
|
|
461
|
-
var
|
|
607
|
+
// src/components/Radio/Radio.tsx
|
|
608
|
+
var import_react3 = require("react");
|
|
609
|
+
var import_radix_ui3 = require("radix-ui");
|
|
610
|
+
var import_class_variance_authority5 = require("class-variance-authority");
|
|
611
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
612
|
+
var radioGroupVariants = (0, import_class_variance_authority5.cva)("ddga-radio-group", {
|
|
613
|
+
variants: {
|
|
614
|
+
size: {
|
|
615
|
+
sm: "ddga-radio-group--sm",
|
|
616
|
+
md: "ddga-radio-group--md"
|
|
617
|
+
},
|
|
618
|
+
orientation: {
|
|
619
|
+
vertical: "ddga-radio-group--vertical",
|
|
620
|
+
horizontal: "ddga-radio-group--horizontal"
|
|
621
|
+
},
|
|
622
|
+
error: {
|
|
623
|
+
true: "ddga-radio-group--error"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
defaultVariants: {
|
|
627
|
+
size: "md",
|
|
628
|
+
orientation: "vertical"
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
var radioVariants = (0, import_class_variance_authority5.cva)("ddga-radio");
|
|
632
|
+
function RadioGroup({
|
|
633
|
+
id: externalId,
|
|
634
|
+
label,
|
|
635
|
+
helperText,
|
|
636
|
+
errorMessage,
|
|
637
|
+
error,
|
|
638
|
+
size,
|
|
639
|
+
orientation,
|
|
640
|
+
required,
|
|
641
|
+
className,
|
|
642
|
+
children,
|
|
643
|
+
...props
|
|
644
|
+
}) {
|
|
645
|
+
const { errorId, helperId, hasError, hasErrorMessage, hasHelper, controlProps, fieldId } = useFieldA11y({
|
|
646
|
+
name: "RadioGroup",
|
|
647
|
+
id: externalId,
|
|
648
|
+
label,
|
|
649
|
+
error,
|
|
650
|
+
errorMessage,
|
|
651
|
+
helperText,
|
|
652
|
+
"aria-label": props["aria-label"],
|
|
653
|
+
"aria-labelledby": props["aria-labelledby"]
|
|
654
|
+
});
|
|
655
|
+
const labelId = `${fieldId}-label`;
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "radio-group-field", className: "ddga-field", children: [
|
|
657
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { id: labelId, className: "ddga-radio-group__label", children: [
|
|
658
|
+
label,
|
|
659
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: "ddga-radio-group__required", children: "*" })
|
|
660
|
+
] }),
|
|
661
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
662
|
+
import_radix_ui3.RadioGroup.Root,
|
|
663
|
+
{
|
|
664
|
+
...props,
|
|
665
|
+
"aria-invalid": controlProps["aria-invalid"],
|
|
666
|
+
"aria-describedby": controlProps["aria-describedby"],
|
|
667
|
+
"aria-labelledby": label ? labelId : props["aria-labelledby"],
|
|
668
|
+
orientation: orientation === "horizontal" ? "horizontal" : "vertical",
|
|
669
|
+
required,
|
|
670
|
+
"data-slot": "radio-group",
|
|
671
|
+
className: cn(radioGroupVariants({ size, orientation, error: hasError }), className),
|
|
672
|
+
children
|
|
673
|
+
}
|
|
674
|
+
),
|
|
675
|
+
hasErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldMessage, { id: errorId, variant: "error", children: errorMessage }),
|
|
676
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldMessage, { id: helperId, variant: "helper", children: helperText })
|
|
677
|
+
] });
|
|
678
|
+
}
|
|
679
|
+
function Radio({ id: externalId, label, className, ...props }) {
|
|
680
|
+
const generatedId = (0, import_react3.useId)();
|
|
681
|
+
const itemId = externalId ?? generatedId;
|
|
682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ddga-radio-row", children: [
|
|
683
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
684
|
+
import_radix_ui3.RadioGroup.Item,
|
|
685
|
+
{
|
|
686
|
+
...props,
|
|
687
|
+
id: itemId,
|
|
688
|
+
"data-slot": "radio",
|
|
689
|
+
className: cn(radioVariants(), className),
|
|
690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
691
|
+
import_radix_ui3.RadioGroup.Indicator,
|
|
692
|
+
{
|
|
693
|
+
"data-slot": "radio-indicator",
|
|
694
|
+
className: "ddga-radio__indicator",
|
|
695
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ddga-radio__dot", "aria-hidden": "true" })
|
|
696
|
+
}
|
|
697
|
+
)
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: itemId, className: "ddga-radio__label", children: label })
|
|
701
|
+
] });
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/components/Switch/Switch.tsx
|
|
705
|
+
var import_radix_ui4 = require("radix-ui");
|
|
706
|
+
var import_class_variance_authority6 = require("class-variance-authority");
|
|
707
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
708
|
+
var switchVariants = (0, import_class_variance_authority6.cva)("ddga-switch", {
|
|
709
|
+
variants: {
|
|
710
|
+
size: {
|
|
711
|
+
sm: "ddga-switch--sm",
|
|
712
|
+
md: "ddga-switch--md"
|
|
713
|
+
},
|
|
714
|
+
error: {
|
|
715
|
+
true: "ddga-switch--error"
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
defaultVariants: {
|
|
719
|
+
size: "md"
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
function Switch({
|
|
723
|
+
id: externalId,
|
|
724
|
+
label,
|
|
725
|
+
helperText,
|
|
726
|
+
errorMessage,
|
|
727
|
+
error,
|
|
728
|
+
size,
|
|
729
|
+
required,
|
|
730
|
+
className,
|
|
731
|
+
...props
|
|
732
|
+
}) {
|
|
733
|
+
const { fieldId, errorId, helperId, hasError, hasErrorMessage, hasHelper, controlProps } = useFieldA11y({
|
|
734
|
+
name: "Switch",
|
|
735
|
+
id: externalId,
|
|
736
|
+
label,
|
|
737
|
+
error,
|
|
738
|
+
errorMessage,
|
|
739
|
+
helperText,
|
|
740
|
+
"aria-label": props["aria-label"],
|
|
741
|
+
"aria-labelledby": props["aria-labelledby"]
|
|
742
|
+
});
|
|
743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "switch-field", className: "ddga-field", children: [
|
|
744
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ddga-switch-row", children: [
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
746
|
+
import_radix_ui4.Switch.Root,
|
|
747
|
+
{
|
|
748
|
+
...props,
|
|
749
|
+
...controlProps,
|
|
750
|
+
"data-slot": "switch",
|
|
751
|
+
required,
|
|
752
|
+
className: cn(switchVariants({ size, error: hasError }), className),
|
|
753
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui4.Switch.Thumb, { "data-slot": "switch-thumb", className: "ddga-switch__thumb" })
|
|
754
|
+
}
|
|
755
|
+
),
|
|
756
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { htmlFor: fieldId, className: "ddga-switch__label", children: [
|
|
757
|
+
label,
|
|
758
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", className: "ddga-switch__required", children: "*" })
|
|
759
|
+
] })
|
|
760
|
+
] }),
|
|
761
|
+
hasErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldMessage, { id: errorId, variant: "error", children: errorMessage }),
|
|
762
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldMessage, { id: helperId, variant: "helper", children: helperText })
|
|
763
|
+
] });
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// src/components/Select/Select.tsx
|
|
767
|
+
var import_react5 = require("react");
|
|
768
|
+
var import_radix_ui5 = require("radix-ui");
|
|
769
|
+
var import_class_variance_authority7 = require("class-variance-authority");
|
|
462
770
|
|
|
463
771
|
// src/providers/DgaContext.ts
|
|
464
|
-
var
|
|
465
|
-
var DgaContext = (0,
|
|
772
|
+
var import_react4 = require("react");
|
|
773
|
+
var DgaContext = (0, import_react4.createContext)(null);
|
|
466
774
|
function useDga() {
|
|
467
|
-
const ctx = (0,
|
|
775
|
+
const ctx = (0, import_react4.useContext)(DgaContext);
|
|
468
776
|
if (!ctx) {
|
|
469
777
|
throw new Error("useDga must be used within a <DgaProvider>");
|
|
470
778
|
}
|
|
471
779
|
return ctx;
|
|
472
780
|
}
|
|
473
781
|
|
|
782
|
+
// src/components/Select/Select.tsx
|
|
783
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
784
|
+
var selectTriggerVariants = (0, import_class_variance_authority7.cva)("ddga-select-trigger", {
|
|
785
|
+
variants: {
|
|
786
|
+
size: {
|
|
787
|
+
sm: "ddga-select-trigger--sm",
|
|
788
|
+
md: "ddga-select-trigger--md"
|
|
789
|
+
},
|
|
790
|
+
error: {
|
|
791
|
+
true: "ddga-select-trigger--error"
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
defaultVariants: {
|
|
795
|
+
size: "md"
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
function Select({
|
|
799
|
+
id: externalId,
|
|
800
|
+
label,
|
|
801
|
+
helperText,
|
|
802
|
+
errorMessage,
|
|
803
|
+
error,
|
|
804
|
+
size,
|
|
805
|
+
required,
|
|
806
|
+
placeholder,
|
|
807
|
+
className,
|
|
808
|
+
children,
|
|
809
|
+
...rootProps
|
|
810
|
+
}) {
|
|
811
|
+
const { fieldId, errorId, helperId, hasError, hasErrorMessage, hasHelper, controlProps } = useFieldA11y({
|
|
812
|
+
name: "Select",
|
|
813
|
+
id: externalId,
|
|
814
|
+
label,
|
|
815
|
+
error,
|
|
816
|
+
errorMessage,
|
|
817
|
+
helperText,
|
|
818
|
+
"aria-label": rootProps["aria-label"],
|
|
819
|
+
"aria-labelledby": rootProps["aria-labelledby"]
|
|
820
|
+
});
|
|
821
|
+
const ctx = (0, import_react5.useContext)(DgaContext);
|
|
822
|
+
const portalContainer = ctx?.rootEl ?? void 0;
|
|
823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { "data-slot": "select-field", className: "ddga-field", children: [
|
|
824
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { htmlFor: fieldId, className: "ddga-select__label", children: [
|
|
825
|
+
label,
|
|
826
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", className: "ddga-select__required", children: "*" })
|
|
827
|
+
] }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_radix_ui5.Select.Root, { required, ...rootProps, children: [
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
830
|
+
import_radix_ui5.Select.Trigger,
|
|
831
|
+
{
|
|
832
|
+
...controlProps,
|
|
833
|
+
"data-slot": "select-trigger",
|
|
834
|
+
className: cn(selectTriggerVariants({ size, error: hasError }), className),
|
|
835
|
+
children: [
|
|
836
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.Value, { placeholder }),
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.Icon, { asChild: true, className: "ddga-select__icon", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronDown, { "aria-hidden": "true" }) })
|
|
838
|
+
]
|
|
839
|
+
}
|
|
840
|
+
),
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
842
|
+
import_radix_ui5.Select.Content,
|
|
843
|
+
{
|
|
844
|
+
"data-slot": "select-content",
|
|
845
|
+
className: "ddga-select-content",
|
|
846
|
+
position: "popper",
|
|
847
|
+
sideOffset: 4,
|
|
848
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.Viewport, { className: "ddga-select-viewport", children })
|
|
849
|
+
}
|
|
850
|
+
) })
|
|
851
|
+
] }),
|
|
852
|
+
hasErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldMessage, { id: errorId, variant: "error", children: errorMessage }),
|
|
853
|
+
hasHelper && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldMessage, { id: helperId, variant: "helper", children: helperText })
|
|
854
|
+
] });
|
|
855
|
+
}
|
|
856
|
+
function SelectItem({ className, children, ...props }) {
|
|
857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
858
|
+
import_radix_ui5.Select.Item,
|
|
859
|
+
{
|
|
860
|
+
...props,
|
|
861
|
+
"data-slot": "select-item",
|
|
862
|
+
className: cn("ddga-select-item", className),
|
|
863
|
+
children: [
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.ItemText, { children }),
|
|
865
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui5.Select.ItemIndicator, { className: "ddga-select-item__indicator", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Check, { className: "ddga-select-item__check", "aria-hidden": "true" }) })
|
|
866
|
+
]
|
|
867
|
+
}
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// src/components/Tooltip/Tooltip.tsx
|
|
872
|
+
var import_react6 = require("react");
|
|
873
|
+
var import_radix_ui6 = require("radix-ui");
|
|
874
|
+
var import_class_variance_authority8 = require("class-variance-authority");
|
|
875
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
876
|
+
var tooltipContentVariants = (0, import_class_variance_authority8.cva)("ddga-tooltip", {
|
|
877
|
+
variants: {
|
|
878
|
+
size: {
|
|
879
|
+
sm: "ddga-tooltip--sm",
|
|
880
|
+
md: "ddga-tooltip--md"
|
|
881
|
+
}
|
|
882
|
+
},
|
|
883
|
+
defaultVariants: {
|
|
884
|
+
size: "md"
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
function Tooltip(props) {
|
|
888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_radix_ui6.Tooltip.Root, { ...props });
|
|
889
|
+
}
|
|
890
|
+
function TooltipTrigger({ className, ...props }) {
|
|
891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_radix_ui6.Tooltip.Trigger, { "data-slot": "tooltip-trigger", className, ...props });
|
|
892
|
+
}
|
|
893
|
+
function TooltipContent({
|
|
894
|
+
size,
|
|
895
|
+
arrow = true,
|
|
896
|
+
sideOffset = 6,
|
|
897
|
+
className,
|
|
898
|
+
children,
|
|
899
|
+
...props
|
|
900
|
+
}) {
|
|
901
|
+
const ctx = (0, import_react6.useContext)(DgaContext);
|
|
902
|
+
const portalContainer = ctx?.rootEl ?? void 0;
|
|
903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_radix_ui6.Tooltip.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
904
|
+
import_radix_ui6.Tooltip.Content,
|
|
905
|
+
{
|
|
906
|
+
"data-slot": "tooltip-content",
|
|
907
|
+
sideOffset,
|
|
908
|
+
className: cn(tooltipContentVariants({ size }), className),
|
|
909
|
+
...props,
|
|
910
|
+
children: [
|
|
911
|
+
children,
|
|
912
|
+
arrow ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_radix_ui6.Tooltip.Arrow, { className: "ddga-tooltip__arrow" }) : null
|
|
913
|
+
]
|
|
914
|
+
}
|
|
915
|
+
) });
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/components/Alert/Alert.tsx
|
|
919
|
+
var import_react7 = require("react");
|
|
920
|
+
var import_radix_ui7 = require("radix-ui");
|
|
921
|
+
var import_class_variance_authority9 = require("class-variance-authority");
|
|
922
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
923
|
+
var alertVariants = (0, import_class_variance_authority9.cva)("ddga-alert", {
|
|
924
|
+
variants: {
|
|
925
|
+
variant: {
|
|
926
|
+
info: "ddga-alert--info",
|
|
927
|
+
success: "ddga-alert--success",
|
|
928
|
+
warning: "ddga-alert--warning",
|
|
929
|
+
destructive: "ddga-alert--destructive"
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
defaultVariants: {
|
|
933
|
+
variant: "info"
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
var DEFAULT_ICONS = {
|
|
937
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Info, { "aria-hidden": "true" }),
|
|
938
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Check, { "aria-hidden": "true" }),
|
|
939
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AlertTriangle, { "aria-hidden": "true" }),
|
|
940
|
+
destructive: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AlertCircle, { "aria-hidden": "true" })
|
|
941
|
+
};
|
|
942
|
+
function Alert({
|
|
943
|
+
variant,
|
|
944
|
+
asChild,
|
|
945
|
+
icon,
|
|
946
|
+
dismissible,
|
|
947
|
+
open: controlledOpen,
|
|
948
|
+
onDismiss,
|
|
949
|
+
live,
|
|
950
|
+
closeLabel = "Dismiss",
|
|
951
|
+
className,
|
|
952
|
+
children,
|
|
953
|
+
...props
|
|
954
|
+
}) {
|
|
955
|
+
const [internalOpen, setInternalOpen] = (0, import_react7.useState)(true);
|
|
956
|
+
const isControlled = controlledOpen !== void 0;
|
|
957
|
+
const open = isControlled ? controlledOpen : internalOpen;
|
|
958
|
+
if (!open) return null;
|
|
959
|
+
const Comp = asChild ? import_radix_ui7.Slot.Slot : "div";
|
|
960
|
+
const resolvedIcon = icon === false ? null : icon !== void 0 ? icon : DEFAULT_ICONS[variant ?? "info"];
|
|
961
|
+
const liveProps = live === "assertive" ? { role: "alert", "aria-live": "assertive" } : live === "polite" ? { role: "status", "aria-live": "polite" } : {};
|
|
962
|
+
function handleDismiss() {
|
|
963
|
+
if (!isControlled) setInternalOpen(false);
|
|
964
|
+
onDismiss?.();
|
|
965
|
+
}
|
|
966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
967
|
+
Comp,
|
|
968
|
+
{
|
|
969
|
+
"data-slot": "alert",
|
|
970
|
+
"data-variant": variant ?? "info",
|
|
971
|
+
className: cn(alertVariants({ variant }), className),
|
|
972
|
+
...liveProps,
|
|
973
|
+
...props,
|
|
974
|
+
children: [
|
|
975
|
+
resolvedIcon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "ddga-alert__icon", children: resolvedIcon }) : null,
|
|
976
|
+
asChild ? (
|
|
977
|
+
// Slot mode: the consumer's element receives the children body.
|
|
978
|
+
// Title/description are nested by the consumer.
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_radix_ui7.Slot.Slottable, { children })
|
|
980
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "ddga-alert__body", children }),
|
|
981
|
+
dismissible ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
982
|
+
"button",
|
|
983
|
+
{
|
|
984
|
+
type: "button",
|
|
985
|
+
className: "ddga-alert__close",
|
|
986
|
+
"aria-label": closeLabel,
|
|
987
|
+
onClick: handleDismiss,
|
|
988
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Close, { "aria-hidden": "true" })
|
|
989
|
+
}
|
|
990
|
+
) : null
|
|
991
|
+
]
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
function AlertTitle({ asChild, className, ...props }) {
|
|
996
|
+
const Comp = asChild ? import_radix_ui7.Slot.Slot : "h5";
|
|
997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Comp, { "data-slot": "alert-title", className: cn("ddga-alert__title", className), ...props });
|
|
998
|
+
}
|
|
999
|
+
function AlertDescription({ asChild, className, ...props }) {
|
|
1000
|
+
const Comp = asChild ? import_radix_ui7.Slot.Slot : "p";
|
|
1001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1002
|
+
Comp,
|
|
1003
|
+
{
|
|
1004
|
+
"data-slot": "alert-description",
|
|
1005
|
+
className: cn("ddga-alert__description", className),
|
|
1006
|
+
...props
|
|
1007
|
+
}
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/components/Modal/Modal.tsx
|
|
1012
|
+
var import_react8 = require("react");
|
|
1013
|
+
var import_radix_ui8 = require("radix-ui");
|
|
1014
|
+
var import_class_variance_authority10 = require("class-variance-authority");
|
|
1015
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1016
|
+
var modalContentVariants = (0, import_class_variance_authority10.cva)("ddga-modal", {
|
|
1017
|
+
variants: {
|
|
1018
|
+
size: {
|
|
1019
|
+
sm: "ddga-modal--sm",
|
|
1020
|
+
md: "ddga-modal--md",
|
|
1021
|
+
lg: "ddga-modal--lg",
|
|
1022
|
+
xl: "ddga-modal--xl",
|
|
1023
|
+
full: "ddga-modal--full"
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
defaultVariants: {
|
|
1027
|
+
size: "md"
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
function Modal(props) {
|
|
1031
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radix_ui8.Dialog.Root, { ...props });
|
|
1032
|
+
}
|
|
1033
|
+
function ModalTrigger({ className, ...props }) {
|
|
1034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radix_ui8.Dialog.Trigger, { "data-slot": "modal-trigger", className, ...props });
|
|
1035
|
+
}
|
|
1036
|
+
function ModalContent({
|
|
1037
|
+
size,
|
|
1038
|
+
showCloseButton = true,
|
|
1039
|
+
closeLabel = "Close",
|
|
1040
|
+
className,
|
|
1041
|
+
children,
|
|
1042
|
+
...props
|
|
1043
|
+
}) {
|
|
1044
|
+
const ctx = (0, import_react8.useContext)(DgaContext);
|
|
1045
|
+
const portalContainer = ctx?.rootEl ?? void 0;
|
|
1046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_radix_ui8.Dialog.Portal, { container: portalContainer, children: [
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radix_ui8.Dialog.Overlay, { className: "ddga-modal__overlay", "data-slot": "modal-overlay" }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1049
|
+
import_radix_ui8.Dialog.Content,
|
|
1050
|
+
{
|
|
1051
|
+
"data-slot": "modal-content",
|
|
1052
|
+
className: cn(modalContentVariants({ size }), className),
|
|
1053
|
+
...props,
|
|
1054
|
+
children: [
|
|
1055
|
+
children,
|
|
1056
|
+
showCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1057
|
+
import_radix_ui8.Dialog.Close,
|
|
1058
|
+
{
|
|
1059
|
+
className: "ddga-modal__close",
|
|
1060
|
+
"aria-label": closeLabel,
|
|
1061
|
+
"data-slot": "modal-close-x",
|
|
1062
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Close, { "aria-hidden": "true" })
|
|
1063
|
+
}
|
|
1064
|
+
) : null
|
|
1065
|
+
]
|
|
1066
|
+
}
|
|
1067
|
+
)
|
|
1068
|
+
] });
|
|
1069
|
+
}
|
|
1070
|
+
function ModalHeader({ asChild, className, ...props }) {
|
|
1071
|
+
const Comp = asChild ? import_radix_ui8.Slot.Slot : "div";
|
|
1072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { "data-slot": "modal-header", className: cn("ddga-modal__header", className), ...props });
|
|
1073
|
+
}
|
|
1074
|
+
function ModalTitle({ asChild, className, ...props }) {
|
|
1075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1076
|
+
import_radix_ui8.Dialog.Title,
|
|
1077
|
+
{
|
|
1078
|
+
asChild,
|
|
1079
|
+
"data-slot": "modal-title",
|
|
1080
|
+
className: cn("ddga-modal__title", className),
|
|
1081
|
+
...props
|
|
1082
|
+
}
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
function ModalDescription({ asChild, className, ...props }) {
|
|
1086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1087
|
+
import_radix_ui8.Dialog.Description,
|
|
1088
|
+
{
|
|
1089
|
+
asChild,
|
|
1090
|
+
"data-slot": "modal-description",
|
|
1091
|
+
className: cn("ddga-modal__description", className),
|
|
1092
|
+
...props
|
|
1093
|
+
}
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
function ModalFooter({ asChild, className, ...props }) {
|
|
1097
|
+
const Comp = asChild ? import_radix_ui8.Slot.Slot : "div";
|
|
1098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Comp, { "data-slot": "modal-footer", className: cn("ddga-modal__footer", className), ...props });
|
|
1099
|
+
}
|
|
1100
|
+
function ModalClose({ className, ...props }) {
|
|
1101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_radix_ui8.Dialog.Close, { "data-slot": "modal-close", className, ...props });
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// src/components/Toast/Toast.tsx
|
|
1105
|
+
var import_react10 = require("react");
|
|
1106
|
+
var import_radix_ui9 = require("radix-ui");
|
|
1107
|
+
var import_class_variance_authority11 = require("class-variance-authority");
|
|
1108
|
+
|
|
1109
|
+
// src/components/Toast/toast-store.ts
|
|
1110
|
+
var import_react9 = require("react");
|
|
1111
|
+
var EXIT_ANIM_MS = 200;
|
|
1112
|
+
function createToastStore() {
|
|
1113
|
+
let toasts = [];
|
|
1114
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1115
|
+
let counter = 0;
|
|
1116
|
+
function emit() {
|
|
1117
|
+
for (const l of listeners) l();
|
|
1118
|
+
}
|
|
1119
|
+
function subscribe(listener) {
|
|
1120
|
+
listeners.add(listener);
|
|
1121
|
+
return () => {
|
|
1122
|
+
listeners.delete(listener);
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
function getSnapshot() {
|
|
1126
|
+
return toasts;
|
|
1127
|
+
}
|
|
1128
|
+
function nextId() {
|
|
1129
|
+
counter += 1;
|
|
1130
|
+
return `t${counter}`;
|
|
1131
|
+
}
|
|
1132
|
+
function add(variant, message, options = {}) {
|
|
1133
|
+
const id = options.id ?? nextId();
|
|
1134
|
+
const existing = toasts.findIndex((t) => t.id === id);
|
|
1135
|
+
const data = {
|
|
1136
|
+
id,
|
|
1137
|
+
variant,
|
|
1138
|
+
open: true,
|
|
1139
|
+
title: message,
|
|
1140
|
+
description: options.description,
|
|
1141
|
+
duration: options.duration,
|
|
1142
|
+
action: options.action,
|
|
1143
|
+
onDismiss: options.onDismiss
|
|
1144
|
+
};
|
|
1145
|
+
if (existing >= 0) {
|
|
1146
|
+
toasts = toasts.map((t, i) => i === existing ? data : t);
|
|
1147
|
+
} else {
|
|
1148
|
+
toasts = [...toasts, data];
|
|
1149
|
+
}
|
|
1150
|
+
emit();
|
|
1151
|
+
return id;
|
|
1152
|
+
}
|
|
1153
|
+
function dismiss(id) {
|
|
1154
|
+
if (id === void 0) {
|
|
1155
|
+
const ids = toasts.map((t) => t.id);
|
|
1156
|
+
toasts = toasts.map((t) => ({ ...t, open: false }));
|
|
1157
|
+
emit();
|
|
1158
|
+
setTimeout(() => {
|
|
1159
|
+
ids.forEach((id2) => remove(id2));
|
|
1160
|
+
}, EXIT_ANIM_MS);
|
|
1161
|
+
} else {
|
|
1162
|
+
toasts = toasts.map((t) => t.id === id ? { ...t, open: false } : t);
|
|
1163
|
+
emit();
|
|
1164
|
+
setTimeout(() => remove(id), EXIT_ANIM_MS);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function remove(id) {
|
|
1168
|
+
const target = toasts.find((t) => t.id === id);
|
|
1169
|
+
toasts = toasts.filter((t) => t.id !== id);
|
|
1170
|
+
emit();
|
|
1171
|
+
target?.onDismiss?.();
|
|
1172
|
+
}
|
|
1173
|
+
function __reset() {
|
|
1174
|
+
toasts = [];
|
|
1175
|
+
counter = 0;
|
|
1176
|
+
emit();
|
|
1177
|
+
}
|
|
1178
|
+
return { subscribe, getSnapshot, add, dismiss, remove, __reset };
|
|
1179
|
+
}
|
|
1180
|
+
var toastStore = createToastStore();
|
|
1181
|
+
function createToast(store) {
|
|
1182
|
+
const fn = ((message, options) => store.add("default", message, options));
|
|
1183
|
+
fn.default = (message, options) => store.add("default", message, options);
|
|
1184
|
+
fn.info = (message, options) => store.add("info", message, options);
|
|
1185
|
+
fn.success = (message, options) => store.add("success", message, options);
|
|
1186
|
+
fn.warning = (message, options) => store.add("warning", message, options);
|
|
1187
|
+
fn.error = (message, options) => store.add("destructive", message, options);
|
|
1188
|
+
fn.destructive = fn.error;
|
|
1189
|
+
fn.dismiss = (id) => store.dismiss(id);
|
|
1190
|
+
return fn;
|
|
1191
|
+
}
|
|
1192
|
+
var toast = createToast(toastStore);
|
|
1193
|
+
|
|
1194
|
+
// src/components/Toast/Toast.tsx
|
|
1195
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1196
|
+
var toastVariants = (0, import_class_variance_authority11.cva)("ddga-toast", {
|
|
1197
|
+
variants: {
|
|
1198
|
+
variant: {
|
|
1199
|
+
default: "ddga-toast--default",
|
|
1200
|
+
info: "ddga-toast--info",
|
|
1201
|
+
success: "ddga-toast--success",
|
|
1202
|
+
warning: "ddga-toast--warning",
|
|
1203
|
+
destructive: "ddga-toast--destructive"
|
|
1204
|
+
}
|
|
1205
|
+
},
|
|
1206
|
+
defaultVariants: {
|
|
1207
|
+
variant: "default"
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
var toastViewportVariants = (0, import_class_variance_authority11.cva)("ddga-toast-viewport", {
|
|
1211
|
+
variants: {
|
|
1212
|
+
position: {
|
|
1213
|
+
"top-start": "ddga-toast-viewport--top-start",
|
|
1214
|
+
"top-center": "ddga-toast-viewport--top-center",
|
|
1215
|
+
"top-end": "ddga-toast-viewport--top-end",
|
|
1216
|
+
"bottom-start": "ddga-toast-viewport--bottom-start",
|
|
1217
|
+
"bottom-center": "ddga-toast-viewport--bottom-center",
|
|
1218
|
+
"bottom-end": "ddga-toast-viewport--bottom-end"
|
|
1219
|
+
},
|
|
1220
|
+
containerized: {
|
|
1221
|
+
true: "ddga-toast-viewport--containerized"
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
defaultVariants: {
|
|
1225
|
+
position: "bottom-end"
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
var DEFAULT_ICONS2 = {
|
|
1229
|
+
default: null,
|
|
1230
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Info, { "aria-hidden": "true" }),
|
|
1231
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Check, { "aria-hidden": "true" }),
|
|
1232
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AlertTriangle, { "aria-hidden": "true" }),
|
|
1233
|
+
destructive: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AlertCircle, { "aria-hidden": "true" })
|
|
1234
|
+
};
|
|
1235
|
+
function Toaster({
|
|
1236
|
+
position = "bottom-end",
|
|
1237
|
+
containerized = false,
|
|
1238
|
+
duration = 4e3,
|
|
1239
|
+
closeButton = true,
|
|
1240
|
+
closeLabel = "Dismiss",
|
|
1241
|
+
hideIcon = false,
|
|
1242
|
+
className,
|
|
1243
|
+
swipeDirection,
|
|
1244
|
+
store = toastStore
|
|
1245
|
+
}) {
|
|
1246
|
+
const toasts = (0, import_react10.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1247
|
+
const resolvedSwipe = swipeDirection ?? (position.startsWith("top") ? "up" : "down");
|
|
1248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_radix_ui9.Toast.Provider, { duration, swipeDirection: resolvedSwipe, children: [
|
|
1249
|
+
toasts.map((t) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1250
|
+
ToastItem,
|
|
1251
|
+
{
|
|
1252
|
+
toast: t,
|
|
1253
|
+
store,
|
|
1254
|
+
closeButton,
|
|
1255
|
+
closeLabel,
|
|
1256
|
+
hideIcon
|
|
1257
|
+
},
|
|
1258
|
+
t.id
|
|
1259
|
+
)),
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1261
|
+
import_radix_ui9.Toast.Viewport,
|
|
1262
|
+
{
|
|
1263
|
+
"data-slot": "toast-viewport",
|
|
1264
|
+
"data-position": position,
|
|
1265
|
+
className: cn(toastViewportVariants({ position, containerized }), className)
|
|
1266
|
+
}
|
|
1267
|
+
)
|
|
1268
|
+
] });
|
|
1269
|
+
}
|
|
1270
|
+
function ToastItem({ toast: t, store, closeButton, closeLabel, hideIcon }) {
|
|
1271
|
+
const radixType = t.variant === "destructive" ? "foreground" : "background";
|
|
1272
|
+
const icon = hideIcon ? null : DEFAULT_ICONS2[t.variant];
|
|
1273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1274
|
+
import_radix_ui9.Toast.Root,
|
|
1275
|
+
{
|
|
1276
|
+
"data-slot": "toast",
|
|
1277
|
+
"data-variant": t.variant,
|
|
1278
|
+
className: toastVariants({ variant: t.variant }),
|
|
1279
|
+
open: t.open,
|
|
1280
|
+
type: radixType,
|
|
1281
|
+
duration: t.duration,
|
|
1282
|
+
onOpenChange: (open) => {
|
|
1283
|
+
if (!open) {
|
|
1284
|
+
store.dismiss(t.id);
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
children: [
|
|
1288
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "ddga-toast__icon", children: icon }) : null,
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "ddga-toast__body", children: [
|
|
1290
|
+
t.title ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_radix_ui9.Toast.Title, { className: "ddga-toast__title", children: t.title }) : null,
|
|
1291
|
+
t.description ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_radix_ui9.Toast.Description, { className: "ddga-toast__description", children: t.description }) : null,
|
|
1292
|
+
t.action ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1293
|
+
import_radix_ui9.Toast.Action,
|
|
1294
|
+
{
|
|
1295
|
+
className: "ddga-toast__action",
|
|
1296
|
+
altText: t.action.altText ?? (typeof t.action.label === "string" ? t.action.label : "Action"),
|
|
1297
|
+
onClick: () => {
|
|
1298
|
+
t.action?.onClick();
|
|
1299
|
+
store.dismiss(t.id);
|
|
1300
|
+
},
|
|
1301
|
+
children: t.action.label
|
|
1302
|
+
}
|
|
1303
|
+
) : null
|
|
1304
|
+
] }),
|
|
1305
|
+
closeButton ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_radix_ui9.Toast.Close, { className: "ddga-toast__close", "aria-label": closeLabel, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Close, { "aria-hidden": "true" }) }) : null
|
|
1306
|
+
]
|
|
1307
|
+
}
|
|
1308
|
+
);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
474
1311
|
// src/providers/DgaProvider.tsx
|
|
475
|
-
var
|
|
1312
|
+
var import_react11 = require("react");
|
|
1313
|
+
var import_radix_ui10 = require("radix-ui");
|
|
1314
|
+
var import_tokens = require("@dev-dga/tokens");
|
|
1315
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
476
1316
|
function DgaProvider({
|
|
477
1317
|
dir = "ltr",
|
|
478
1318
|
locale,
|
|
479
1319
|
mode = "light",
|
|
1320
|
+
theme,
|
|
480
1321
|
as: Component = "div",
|
|
481
1322
|
className,
|
|
482
1323
|
style: consumerStyle,
|
|
483
1324
|
children
|
|
484
1325
|
}) {
|
|
485
|
-
const parentCtx = (0,
|
|
1326
|
+
const parentCtx = (0, import_react11.useContext)(DgaContext);
|
|
486
1327
|
const isNested = parentCtx !== null;
|
|
487
|
-
const
|
|
1328
|
+
const [rootEl, setRootEl] = (0, import_react11.useState)(null);
|
|
488
1329
|
const resolvedLocale = locale ?? (dir === "rtl" ? "ar" : "en");
|
|
489
|
-
const ctxValue = (0,
|
|
490
|
-
() => ({ dir, locale: resolvedLocale, mode,
|
|
491
|
-
[dir, resolvedLocale, mode]
|
|
1330
|
+
const ctxValue = (0, import_react11.useMemo)(
|
|
1331
|
+
() => ({ dir, locale: resolvedLocale, mode, rootEl }),
|
|
1332
|
+
[dir, resolvedLocale, mode, rootEl]
|
|
492
1333
|
);
|
|
493
|
-
const
|
|
494
|
-
|
|
1334
|
+
const themeVars = (0, import_react11.useMemo)(() => theme ? (0, import_tokens.buildTheme)(theme) : null, [theme]);
|
|
1335
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_radix_ui10.Direction.Provider, { dir, children });
|
|
1336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DgaContext.Provider, { value: ctxValue, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
495
1337
|
Component,
|
|
496
1338
|
{
|
|
497
|
-
ref:
|
|
1339
|
+
ref: setRootEl,
|
|
498
1340
|
dir,
|
|
499
1341
|
lang: resolvedLocale,
|
|
500
1342
|
"data-slot": "dga-root",
|
|
501
1343
|
"data-theme": mode,
|
|
502
1344
|
className,
|
|
503
|
-
style: { colorScheme: mode, ...consumerStyle },
|
|
504
|
-
children: isNested ? inner : /* @__PURE__ */ (0,
|
|
1345
|
+
style: { colorScheme: mode, ...themeVars ?? {}, ...consumerStyle },
|
|
1346
|
+
children: isNested ? inner : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_radix_ui10.Tooltip.Provider, { delayDuration: 300, skipDelayDuration: 100, children: inner })
|
|
505
1347
|
}
|
|
506
1348
|
) });
|
|
507
1349
|
}
|
|
@@ -512,17 +1354,52 @@ function useDir() {
|
|
|
512
1354
|
}
|
|
513
1355
|
// Annotate the CommonJS export names for ESM import in node:
|
|
514
1356
|
0 && (module.exports = {
|
|
1357
|
+
Alert,
|
|
1358
|
+
AlertDescription,
|
|
1359
|
+
AlertTitle,
|
|
515
1360
|
Button,
|
|
516
1361
|
Checkbox,
|
|
517
1362
|
DgaProvider,
|
|
1363
|
+
FieldMessage,
|
|
518
1364
|
Input,
|
|
1365
|
+
Modal,
|
|
1366
|
+
ModalClose,
|
|
1367
|
+
ModalContent,
|
|
1368
|
+
ModalDescription,
|
|
1369
|
+
ModalFooter,
|
|
1370
|
+
ModalHeader,
|
|
1371
|
+
ModalTitle,
|
|
1372
|
+
ModalTrigger,
|
|
1373
|
+
Radio,
|
|
1374
|
+
RadioGroup,
|
|
1375
|
+
Select,
|
|
1376
|
+
SelectItem,
|
|
1377
|
+
Switch,
|
|
519
1378
|
Textarea,
|
|
1379
|
+
Toaster,
|
|
1380
|
+
Tooltip,
|
|
1381
|
+
TooltipContent,
|
|
1382
|
+
TooltipTrigger,
|
|
1383
|
+
alertVariants,
|
|
520
1384
|
buttonVariants,
|
|
521
1385
|
checkboxVariants,
|
|
522
1386
|
cn,
|
|
1387
|
+
createToast,
|
|
1388
|
+
createToastStore,
|
|
523
1389
|
inputVariants,
|
|
1390
|
+
modalContentVariants,
|
|
1391
|
+
radioGroupVariants,
|
|
1392
|
+
radioVariants,
|
|
1393
|
+
selectTriggerVariants,
|
|
1394
|
+
switchVariants,
|
|
524
1395
|
textareaVariants,
|
|
1396
|
+
toast,
|
|
1397
|
+
toastStore,
|
|
1398
|
+
toastVariants,
|
|
1399
|
+
toastViewportVariants,
|
|
1400
|
+
tooltipContentVariants,
|
|
525
1401
|
useDga,
|
|
526
|
-
useDir
|
|
1402
|
+
useDir,
|
|
1403
|
+
useFieldA11y
|
|
527
1404
|
});
|
|
528
1405
|
//# sourceMappingURL=index.cjs.map
|