@spark-ui/components 17.2.3 → 17.2.4
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/dist/DialogContent.styles-BSxCCi-u.mjs +62 -0
- package/dist/DialogContent.styles-BSxCCi-u.mjs.map +1 -0
- package/dist/DialogContent.styles-CAhJtUud.js +2 -0
- package/dist/DialogContent.styles-CAhJtUud.js.map +1 -0
- package/dist/FormFieldRequiredIndicator-CtgkvPZo.js +2 -0
- package/dist/FormFieldRequiredIndicator-CtgkvPZo.js.map +1 -0
- package/dist/FormFieldRequiredIndicator-DOGQ_HxO.mjs +14 -0
- package/dist/FormFieldRequiredIndicator-DOGQ_HxO.mjs.map +1 -0
- package/dist/accordion/index.js +2 -2
- package/dist/accordion/index.js.map +1 -1
- package/dist/accordion/index.mjs +99 -161
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert-dialog/index.js +2 -2
- package/dist/alert-dialog/index.js.map +1 -1
- package/dist/alert-dialog/index.mjs +169 -235
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.js +2 -2
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar/index.mjs +187 -224
- package/dist/avatar/index.mjs.map +1 -1
- package/dist/badge/index.js +2 -2
- package/dist/badge/index.js.map +1 -1
- package/dist/badge/index.mjs +115 -81
- package/dist/badge/index.mjs.map +1 -1
- package/dist/breadcrumb/index.js +2 -2
- package/dist/breadcrumb/index.js.map +1 -1
- package/dist/breadcrumb/index.mjs +73 -106
- package/dist/breadcrumb/index.mjs.map +1 -1
- package/dist/button/index.js +1 -2
- package/dist/button/index.mjs +2 -5
- package/dist/button-BTDRzvpB.js +2 -0
- package/dist/button-BTDRzvpB.js.map +1 -0
- package/dist/button-_YZ_4J42.mjs +643 -0
- package/dist/button-_YZ_4J42.mjs.map +1 -0
- package/dist/card/index.js +2 -2
- package/dist/card/index.js.map +1 -1
- package/dist/card/index.mjs +327 -394
- package/dist/card/index.mjs.map +1 -1
- package/dist/carousel/index.js +2 -2
- package/dist/carousel/index.js.map +1 -1
- package/dist/carousel/index.mjs +515 -618
- package/dist/carousel/index.mjs.map +1 -1
- package/dist/checkbox/index.js +2 -2
- package/dist/checkbox/index.js.map +1 -1
- package/dist/checkbox/index.mjs +213 -246
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/chip/index.js +2 -2
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/index.mjs +601 -652
- package/dist/chip/index.mjs.map +1 -1
- package/dist/chunk-C91j1N6u.js +1 -0
- package/dist/circular-meter/index.js +2 -2
- package/dist/circular-meter/index.js.map +1 -1
- package/dist/circular-meter/index.mjs +354 -309
- package/dist/circular-meter/index.mjs.map +1 -1
- package/dist/collapsible/index.js +2 -2
- package/dist/collapsible/index.js.map +1 -1
- package/dist/collapsible/index.mjs +53 -53
- package/dist/collapsible/index.mjs.map +1 -1
- package/dist/combobox/index.js +2 -2
- package/dist/combobox/index.js.map +1 -1
- package/dist/combobox/index.mjs +721 -876
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/dialog/index.js +2 -2
- package/dist/dialog/index.js.map +1 -1
- package/dist/dialog/index.mjs +181 -206
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/divider/index.js +2 -2
- package/dist/divider/index.js.map +1 -1
- package/dist/divider/index.mjs +178 -183
- package/dist/divider/index.mjs.map +1 -1
- package/dist/drawer/index.js +2 -2
- package/dist/drawer/index.js.map +1 -1
- package/dist/drawer/index.mjs +277 -309
- package/dist/drawer/index.mjs.map +1 -1
- package/dist/dropdown/index.js +2 -2
- package/dist/dropdown/index.js.map +1 -1
- package/dist/dropdown/index.mjs +429 -492
- package/dist/dropdown/index.mjs.map +1 -1
- package/dist/file-upload/index.js +2 -2
- package/dist/file-upload/index.js.map +1 -1
- package/dist/file-upload/index.mjs +540 -677
- package/dist/file-upload/index.mjs.map +1 -1
- package/dist/form-field/index.js +1 -2
- package/dist/form-field/index.mjs +2 -284
- package/dist/form-field-B8QzM655.mjs +231 -0
- package/dist/form-field-B8QzM655.mjs.map +1 -0
- package/dist/form-field-Bu_0E9tb.js +2 -0
- package/dist/form-field-Bu_0E9tb.js.map +1 -0
- package/dist/icon/index.js +1 -2
- package/dist/icon/index.mjs +2 -5
- package/dist/icon-CRPcdgYp.js +2 -0
- package/dist/icon-CRPcdgYp.js.map +1 -0
- package/dist/icon-D05Uqh8_.mjs +41 -0
- package/dist/icon-D05Uqh8_.mjs.map +1 -0
- package/dist/icon-button/index.js +1 -2
- package/dist/icon-button/index.mjs +2 -5
- package/dist/icon-button-6p3O7NIm.mjs +28 -0
- package/dist/icon-button-6p3O7NIm.mjs.map +1 -0
- package/dist/icon-button-CykysbgJ.js +2 -0
- package/dist/icon-button-CykysbgJ.js.map +1 -0
- package/dist/input/index.js +1 -2
- package/dist/input/index.mjs +2 -455
- package/dist/input-CmYeHYWQ.mjs +355 -0
- package/dist/input-CmYeHYWQ.mjs.map +1 -0
- package/dist/input-DNr40G2Z.js +2 -0
- package/dist/input-DNr40G2Z.js.map +1 -0
- package/dist/input-otp/index.js +2 -2
- package/dist/input-otp/index.js.map +1 -1
- package/dist/input-otp/index.mjs +344 -407
- package/dist/input-otp/index.mjs.map +1 -1
- package/dist/kbd/index.js +2 -2
- package/dist/kbd/index.js.map +1 -1
- package/dist/kbd/index.mjs +12 -17
- package/dist/kbd/index.mjs.map +1 -1
- package/dist/label/index.js +1 -2
- package/dist/label/index.mjs +2 -40
- package/dist/label-BqRlrca0.mjs +31 -0
- package/dist/label-BqRlrca0.mjs.map +1 -0
- package/dist/label-DU0p0d-f.js +2 -0
- package/dist/label-DU0p0d-f.js.map +1 -0
- package/dist/link-box/index.js +2 -2
- package/dist/link-box/index.js.map +1 -1
- package/dist/link-box/index.mjs +36 -34
- package/dist/link-box/index.mjs.map +1 -1
- package/dist/meter/index.js +2 -2
- package/dist/meter/index.js.map +1 -1
- package/dist/meter/index.mjs +149 -171
- package/dist/meter/index.mjs.map +1 -1
- package/dist/pagination/index.js +2 -2
- package/dist/pagination/index.js.map +1 -1
- package/dist/pagination/index.mjs +253 -214
- package/dist/pagination/index.mjs.map +1 -1
- package/dist/popover/index.js +1 -2
- package/dist/popover/index.mjs +2 -239
- package/dist/popover-CxZAQmw6.mjs +211 -0
- package/dist/popover-CxZAQmw6.mjs.map +1 -0
- package/dist/popover-GOovJ27J.js +2 -0
- package/dist/popover-GOovJ27J.js.map +1 -0
- package/dist/portal/index.js +2 -2
- package/dist/portal/index.js.map +1 -1
- package/dist/portal/index.mjs +8 -7
- package/dist/portal/index.mjs.map +1 -1
- package/dist/progress/index.js +1 -2
- package/dist/progress/index.mjs +2 -178
- package/dist/progress-cEf3tFbn.mjs +132 -0
- package/dist/progress-cEf3tFbn.mjs.map +1 -0
- package/dist/progress-rJZcPJsZ.js +2 -0
- package/dist/progress-rJZcPJsZ.js.map +1 -0
- package/dist/progress-tracker/index.js +2 -2
- package/dist/progress-tracker/index.js.map +1 -1
- package/dist/progress-tracker/index.mjs +303 -380
- package/dist/progress-tracker/index.mjs.map +1 -1
- package/dist/radio-group/index.js +2 -2
- package/dist/radio-group/index.js.map +1 -1
- package/dist/radio-group/index.mjs +204 -213
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/rating/index.js +2 -2
- package/dist/rating/index.js.map +1 -1
- package/dist/rating/index.mjs +189 -244
- package/dist/rating/index.mjs.map +1 -1
- package/dist/rating-display/index.js +2 -2
- package/dist/rating-display/index.js.map +1 -1
- package/dist/rating-display/index.mjs +165 -166
- package/dist/rating-display/index.mjs.map +1 -1
- package/dist/scrolling-list/index.js +2 -2
- package/dist/scrolling-list/index.js.map +1 -1
- package/dist/scrolling-list/index.mjs +216 -273
- package/dist/scrolling-list/index.mjs.map +1 -1
- package/dist/segmented-control/index.js +2 -2
- package/dist/segmented-control/index.js.map +1 -1
- package/dist/segmented-control/index.mjs +146 -180
- package/dist/segmented-control/index.mjs.map +1 -1
- package/dist/segmented-gauge/index.js +2 -2
- package/dist/segmented-gauge/index.js.map +1 -1
- package/dist/segmented-gauge/index.mjs +146 -195
- package/dist/segmented-gauge/index.mjs.map +1 -1
- package/dist/select/index.js +2 -2
- package/dist/select/index.js.map +1 -1
- package/dist/select/index.mjs +279 -327
- package/dist/select/index.mjs.map +1 -1
- package/dist/skeleton/index.js +2 -2
- package/dist/skeleton/index.js.map +1 -1
- package/dist/skeleton/index.mjs +92 -114
- package/dist/skeleton/index.mjs.map +1 -1
- package/dist/slider/index.js +2 -2
- package/dist/slider/index.js.map +1 -1
- package/dist/slider/index.mjs +259 -326
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slot/index.js +2 -2
- package/dist/slot/index.js.map +1 -1
- package/dist/slot/index.mjs +12 -7
- package/dist/slot/index.mjs.map +1 -1
- package/dist/snackbar/index.js +2 -2
- package/dist/snackbar/index.js.map +1 -1
- package/dist/snackbar/index.mjs +404 -529
- package/dist/snackbar/index.mjs.map +1 -1
- package/dist/spinner/index.js +1 -2
- package/dist/spinner/index.mjs +2 -5
- package/dist/spinner-DFUoYvmm.js +2 -0
- package/dist/spinner-DFUoYvmm.js.map +1 -0
- package/dist/spinner-DULLiM6a.mjs +56 -0
- package/dist/spinner-DULLiM6a.mjs.map +1 -0
- package/dist/src/avatar/index.d.mts +2 -2
- package/dist/src/avatar/index.d.ts +2 -2
- package/dist/src/file-upload/index.d.mts +1 -1
- package/dist/src/file-upload/index.d.ts +1 -1
- package/dist/stepper/index.js +2 -2
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/index.mjs +139 -176
- package/dist/stepper/index.mjs.map +1 -1
- package/dist/switch/index.js +2 -2
- package/dist/switch/index.js.map +1 -1
- package/dist/switch/index.mjs +194 -197
- package/dist/switch/index.mjs.map +1 -1
- package/dist/tabs/index.js +2 -2
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +337 -389
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tag/index.js +2 -2
- package/dist/tag/index.js.map +1 -1
- package/dist/tag/index.mjs +192 -211
- package/dist/tag/index.mjs.map +1 -1
- package/dist/text-link/index.js +2 -2
- package/dist/text-link/index.js.map +1 -1
- package/dist/text-link/index.mjs +44 -5
- package/dist/text-link/index.mjs.map +1 -1
- package/dist/textarea/index.js +2 -2
- package/dist/textarea/index.js.map +1 -1
- package/dist/textarea/index.mjs +51 -50
- package/dist/textarea/index.mjs.map +1 -1
- package/dist/toast/index.js +2 -2
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/index.mjs +314 -367
- package/dist/toast/index.mjs.map +1 -1
- package/dist/useRenderSlot-DP4fYerF.mjs +11 -0
- package/dist/useRenderSlot-DP4fYerF.mjs.map +1 -0
- package/dist/useRenderSlot-Xxf_s88b.js +2 -0
- package/dist/useRenderSlot-Xxf_s88b.js.map +1 -0
- package/dist/visually-hidden/index.js +2 -2
- package/dist/visually-hidden/index.js.map +1 -1
- package/dist/visually-hidden/index.mjs +25 -5
- package/dist/visually-hidden/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/Button-1M9DcZl0.mjs +0 -704
- package/dist/Button-1M9DcZl0.mjs.map +0 -1
- package/dist/Button-FZceRWG2.js +0 -2
- package/dist/Button-FZceRWG2.js.map +0 -1
- package/dist/DialogContent.styles-CziMQtYr.js +0 -2
- package/dist/DialogContent.styles-CziMQtYr.js.map +0 -1
- package/dist/DialogContent.styles-Du7_Dkde.mjs +0 -60
- package/dist/DialogContent.styles-Du7_Dkde.mjs.map +0 -1
- package/dist/FormFieldRequiredIndicator-CHfcoT2y.js +0 -2
- package/dist/FormFieldRequiredIndicator-CHfcoT2y.js.map +0 -1
- package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs +0 -13
- package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs.map +0 -1
- package/dist/Icon-BO327oHU.mjs +0 -57
- package/dist/Icon-BO327oHU.mjs.map +0 -1
- package/dist/Icon-C-cNTnzd.js +0 -2
- package/dist/Icon-C-cNTnzd.js.map +0 -1
- package/dist/IconButton-BR1bJSQA.js +0 -2
- package/dist/IconButton-BR1bJSQA.js.map +0 -1
- package/dist/IconButton-DdB3Pq13.mjs +0 -43
- package/dist/IconButton-DdB3Pq13.mjs.map +0 -1
- package/dist/Slot-DLY1rJrG.mjs +0 -14
- package/dist/Slot-DLY1rJrG.mjs.map +0 -1
- package/dist/Slot-DQ8z2zsy.js +0 -2
- package/dist/Slot-DQ8z2zsy.js.map +0 -1
- package/dist/Spinner-Br4Rp9V2.js +0 -2
- package/dist/Spinner-Br4Rp9V2.js.map +0 -1
- package/dist/Spinner-Co3AjkQV.mjs +0 -68
- package/dist/Spinner-Co3AjkQV.mjs.map +0 -1
- package/dist/TextLink-5MvP0P8D.js +0 -2
- package/dist/TextLink-5MvP0P8D.js.map +0 -1
- package/dist/TextLink-Cc_LeVcx.mjs +0 -57
- package/dist/TextLink-Cc_LeVcx.mjs.map +0 -1
- package/dist/VisuallyHidden-CB6Nx76j.js +0 -2
- package/dist/VisuallyHidden-CB6Nx76j.js.map +0 -1
- package/dist/VisuallyHidden-DjlV0-CW.mjs +0 -28
- package/dist/VisuallyHidden-DjlV0-CW.mjs.map +0 -1
- package/dist/button/index.js.map +0 -1
- package/dist/button/index.mjs.map +0 -1
- package/dist/form-field/index.js.map +0 -1
- package/dist/form-field/index.mjs.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/icon/index.mjs.map +0 -1
- package/dist/icon-button/index.js.map +0 -1
- package/dist/icon-button/index.mjs.map +0 -1
- package/dist/input/index.js.map +0 -1
- package/dist/input/index.mjs.map +0 -1
- package/dist/label/index.js.map +0 -1
- package/dist/label/index.mjs.map +0 -1
- package/dist/popover/index.js.map +0 -1
- package/dist/popover/index.mjs.map +0 -1
- package/dist/progress/index.js.map +0 -1
- package/dist/progress/index.mjs.map +0 -1
- package/dist/spinner/index.js.map +0 -1
- package/dist/spinner/index.mjs.map +0 -1
- package/dist/useRenderSlot-Bta2kdp4.mjs +0 -10
- package/dist/useRenderSlot-Bta2kdp4.mjs.map +0 -1
- package/dist/useRenderSlot-DATwjgpo.js +0 -2
- package/dist/useRenderSlot-DATwjgpo.js.map +0 -1
|
@@ -1,216 +1,207 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
disabled: {
|
|
117
|
-
true: ["text-neutral/dim-2", "cursor-not-allowed"],
|
|
118
|
-
false: ["cursor-pointer"]
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
defaultVariants: {
|
|
122
|
-
disabled: !1
|
|
123
|
-
}
|
|
124
|
-
}), $ = ({ disabled: r, ...e }) => /* @__PURE__ */ o(
|
|
125
|
-
q.Root,
|
|
126
|
-
{
|
|
127
|
-
"data-spark-component": "radio-label",
|
|
128
|
-
className: D({ disabled: r }),
|
|
129
|
-
...e
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
$.displayName = "RadioGroup.RadioLabel";
|
|
133
|
-
const k = ":radio", R = ({
|
|
134
|
-
className: r,
|
|
135
|
-
children: e,
|
|
136
|
-
id: a,
|
|
137
|
-
disabled: t,
|
|
138
|
-
ref: n,
|
|
139
|
-
...i
|
|
140
|
-
}) => {
|
|
141
|
-
const s = `${k}-input-${x()}`, d = `${k}-label-${x()}`, { intent: p, disabled: b, reverse: f } = S(), c = e && /* @__PURE__ */ o($, { disabled: t || b, htmlFor: a || s, id: d, children: e }), l = /* @__PURE__ */ o(
|
|
142
|
-
L,
|
|
143
|
-
{
|
|
144
|
-
ref: n,
|
|
145
|
-
id: a || s,
|
|
146
|
-
intent: p,
|
|
147
|
-
"aria-labelledby": e ? d : void 0,
|
|
148
|
-
...i,
|
|
149
|
-
disabled: t
|
|
150
|
-
}
|
|
151
|
-
), m = f ? /* @__PURE__ */ g(G, { children: [
|
|
152
|
-
c,
|
|
153
|
-
l
|
|
154
|
-
] }) : /* @__PURE__ */ g(G, { children: [
|
|
155
|
-
l,
|
|
156
|
-
c
|
|
157
|
-
] });
|
|
158
|
-
return /* @__PURE__ */ o("span", { className: F("gap-md text-body-1 flex items-start", r), children: m });
|
|
159
|
-
};
|
|
160
|
-
R.displayName = "RadioGroup.Radio";
|
|
161
|
-
const O = u(["flex"], {
|
|
162
|
-
variants: {
|
|
163
|
-
orientation: {
|
|
164
|
-
vertical: ["flex-col", "gap-lg"],
|
|
165
|
-
horizontal: ["flex-row", "gap-xl"]
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}), P = ({
|
|
169
|
-
intent: r,
|
|
170
|
-
disabled: e,
|
|
171
|
-
reverse: a,
|
|
172
|
-
children: t
|
|
173
|
-
}) => {
|
|
174
|
-
const n = C(() => ({ intent: r, disabled: e, reverse: a }), [r, e, a]);
|
|
175
|
-
return /* @__PURE__ */ o(N.Provider, { value: n, children: t });
|
|
176
|
-
}, z = ({
|
|
177
|
-
orientation: r = "vertical",
|
|
178
|
-
loop: e = !0,
|
|
179
|
-
intent: a = "support",
|
|
180
|
-
disabled: t,
|
|
181
|
-
className: n,
|
|
182
|
-
required: i,
|
|
183
|
-
reverse: s = !1,
|
|
184
|
-
ref: d,
|
|
185
|
-
...p
|
|
186
|
-
}) => {
|
|
187
|
-
const { labelId: b, isInvalid: f, isRequired: c, description: l, name: m } = y(), v = i !== void 0 ? i : c;
|
|
188
|
-
return /* @__PURE__ */ o(P, { reverse: s, intent: a, disabled: t, children: /* @__PURE__ */ o(
|
|
189
|
-
h.RadioGroup,
|
|
190
|
-
{
|
|
191
|
-
"data-spark-component": "radio-group",
|
|
192
|
-
className: O({ orientation: r, className: n }),
|
|
193
|
-
name: m,
|
|
194
|
-
ref: d,
|
|
195
|
-
disabled: t,
|
|
196
|
-
orientation: r,
|
|
197
|
-
loop: e,
|
|
198
|
-
required: v,
|
|
199
|
-
"aria-labelledby": b,
|
|
200
|
-
"aria-invalid": f,
|
|
201
|
-
"aria-required": v,
|
|
202
|
-
"aria-describedby": l,
|
|
203
|
-
...p
|
|
204
|
-
}
|
|
205
|
-
) });
|
|
1
|
+
import { cva as e, cx as t } from "class-variance-authority";
|
|
2
|
+
import { createContext as n, useContext as r, useId as i, useMemo as a } from "react";
|
|
3
|
+
import { Label as o, RadioGroup as s } from "radix-ui";
|
|
4
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
+
import { makeVariants as d } from "@spark-ui/internal-utils";
|
|
6
|
+
import { useFormFieldControl as f } from "@spark-ui/components/form-field";
|
|
7
|
+
//#region src/radio-group/RadioGroupContext.tsx
|
|
8
|
+
var p = n(null), m = () => {
|
|
9
|
+
let e = r(p);
|
|
10
|
+
if (!e) throw Error("useRadioGroup must be used within a RadioGroup provider");
|
|
11
|
+
return e;
|
|
12
|
+
}, h = e([
|
|
13
|
+
"relative block",
|
|
14
|
+
"size-3/5",
|
|
15
|
+
"after:absolute",
|
|
16
|
+
"after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2",
|
|
17
|
+
"after:h-0",
|
|
18
|
+
"after:w-0",
|
|
19
|
+
"after:block",
|
|
20
|
+
"after:rounded-[50%]",
|
|
21
|
+
"after:content-['']",
|
|
22
|
+
"after:transition-all",
|
|
23
|
+
"data-[state=checked]:after:size-full"
|
|
24
|
+
], {
|
|
25
|
+
variants: { intent: d({
|
|
26
|
+
main: ["after:bg-main"],
|
|
27
|
+
support: ["after:bg-support"],
|
|
28
|
+
accent: ["after:bg-accent"],
|
|
29
|
+
neutral: ["after:bg-neutral"],
|
|
30
|
+
success: ["after:bg-success"],
|
|
31
|
+
alert: ["after:bg-alert"],
|
|
32
|
+
error: ["after:bg-error"],
|
|
33
|
+
info: ["after:bg-info"]
|
|
34
|
+
}) },
|
|
35
|
+
defaultVariants: { intent: "support" }
|
|
36
|
+
}), g = ({ intent: e, className: t, ref: n, ...r }) => /* @__PURE__ */ l(s.Indicator, {
|
|
37
|
+
ref: n,
|
|
38
|
+
className: h({
|
|
39
|
+
intent: e,
|
|
40
|
+
className: t
|
|
41
|
+
}),
|
|
42
|
+
...r
|
|
43
|
+
});
|
|
44
|
+
g.displayName = "RadioGroup.RadioIndicator";
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/radio-group/RadioInput.styles.ts
|
|
47
|
+
var _ = e([
|
|
48
|
+
"flex shrink-0 items-center justify-center",
|
|
49
|
+
"rounded-full",
|
|
50
|
+
"border-md",
|
|
51
|
+
"outline-hidden",
|
|
52
|
+
"hover:ring-4",
|
|
53
|
+
"focus-visible:u-outline",
|
|
54
|
+
"disabled:cursor-not-allowed disabled:border-outline/dim-2 disabled:hover:ring-transparent",
|
|
55
|
+
"u-shadow-border-transition",
|
|
56
|
+
"size-sz-24"
|
|
57
|
+
], {
|
|
58
|
+
variants: { intent: d({
|
|
59
|
+
main: [
|
|
60
|
+
"border-outline",
|
|
61
|
+
"data-[state=checked]:border-main",
|
|
62
|
+
"hover:ring-main-container"
|
|
63
|
+
],
|
|
64
|
+
support: [
|
|
65
|
+
"border-outline",
|
|
66
|
+
"data-[state=checked]:border-support",
|
|
67
|
+
"hover:ring-support-container"
|
|
68
|
+
],
|
|
69
|
+
accent: [
|
|
70
|
+
"border-outline",
|
|
71
|
+
"data-[state=checked]:border-accent",
|
|
72
|
+
"hover:ring-accent-container"
|
|
73
|
+
],
|
|
74
|
+
neutral: [
|
|
75
|
+
"border-outline",
|
|
76
|
+
"data-[state=checked]:border-neutral",
|
|
77
|
+
"hover:ring-neutral-container"
|
|
78
|
+
],
|
|
79
|
+
info: [
|
|
80
|
+
"border-info",
|
|
81
|
+
"data-[state=checked]:border-info",
|
|
82
|
+
"hover:ring-info-container"
|
|
83
|
+
],
|
|
84
|
+
success: [
|
|
85
|
+
"border-success",
|
|
86
|
+
"data-[state=checked]:border-success",
|
|
87
|
+
"hover:ring-success-container"
|
|
88
|
+
],
|
|
89
|
+
alert: [
|
|
90
|
+
"border-alert",
|
|
91
|
+
"data-[state=checked]:border-alert",
|
|
92
|
+
"hover:ring-alert-container"
|
|
93
|
+
],
|
|
94
|
+
error: [
|
|
95
|
+
"border-error",
|
|
96
|
+
"data-[state=checked]:border-error",
|
|
97
|
+
"hover:ring-error-container"
|
|
98
|
+
]
|
|
99
|
+
}) },
|
|
100
|
+
defaultVariants: { intent: "support" }
|
|
101
|
+
}), v = ({ intent: e, className: t, ref: n, ...r }) => {
|
|
102
|
+
let { state: i } = f(), a = i ?? e;
|
|
103
|
+
return /* @__PURE__ */ l(s.RadioGroupItem, {
|
|
104
|
+
"data-spark-component": "radio-input",
|
|
105
|
+
ref: n,
|
|
106
|
+
className: _({
|
|
107
|
+
intent: a,
|
|
108
|
+
className: t
|
|
109
|
+
}),
|
|
110
|
+
...r,
|
|
111
|
+
children: /* @__PURE__ */ l(g, {
|
|
112
|
+
intent: a,
|
|
113
|
+
forceMount: !0
|
|
114
|
+
})
|
|
115
|
+
});
|
|
206
116
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
117
|
+
v.displayName = "RadioGroup.RadioInput";
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/radio-group/RadioLabel.styles.tsx
|
|
120
|
+
var y = e("grow", {
|
|
121
|
+
variants: { disabled: {
|
|
122
|
+
true: ["text-neutral/dim-2", "cursor-not-allowed"],
|
|
123
|
+
false: ["cursor-pointer"]
|
|
124
|
+
} },
|
|
125
|
+
defaultVariants: { disabled: !1 }
|
|
126
|
+
}), b = ({ disabled: e, ...t }) => /* @__PURE__ */ l(o.Root, {
|
|
127
|
+
"data-spark-component": "radio-label",
|
|
128
|
+
className: y({ disabled: e }),
|
|
129
|
+
...t
|
|
210
130
|
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
131
|
+
b.displayName = "RadioGroup.RadioLabel";
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/radio-group/Radio.tsx
|
|
134
|
+
var x = ":radio", S = ({ className: e, children: n, id: r, disabled: a, ref: o, ...s }) => {
|
|
135
|
+
let d = `${x}-input-${i()}`, f = `${x}-label-${i()}`, { intent: p, disabled: h, reverse: g } = m(), _ = n && /* @__PURE__ */ l(b, {
|
|
136
|
+
disabled: a || h,
|
|
137
|
+
htmlFor: r || d,
|
|
138
|
+
id: f,
|
|
139
|
+
children: n
|
|
140
|
+
}), y = /* @__PURE__ */ l(v, {
|
|
141
|
+
ref: o,
|
|
142
|
+
id: r || d,
|
|
143
|
+
intent: p,
|
|
144
|
+
"aria-labelledby": n ? f : void 0,
|
|
145
|
+
...s,
|
|
146
|
+
disabled: a
|
|
147
|
+
}), S = g ? /* @__PURE__ */ u(c, { children: [_, y] }) : /* @__PURE__ */ u(c, { children: [y, _] });
|
|
148
|
+
return /* @__PURE__ */ l("span", {
|
|
149
|
+
className: t("gap-md text-body-1 flex items-start", e),
|
|
150
|
+
children: S
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
S.displayName = "RadioGroup.Radio";
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/radio-group/RadioGroup.styles.ts
|
|
156
|
+
var C = e(["flex"], { variants: { orientation: {
|
|
157
|
+
vertical: ["flex-col", "gap-lg"],
|
|
158
|
+
horizontal: ["flex-row", "gap-xl"]
|
|
159
|
+
} } }), w = ({ intent: e, disabled: t, reverse: n, children: r }) => {
|
|
160
|
+
let i = a(() => ({
|
|
161
|
+
intent: e,
|
|
162
|
+
disabled: t,
|
|
163
|
+
reverse: n
|
|
164
|
+
}), [
|
|
165
|
+
e,
|
|
166
|
+
t,
|
|
167
|
+
n
|
|
168
|
+
]);
|
|
169
|
+
return /* @__PURE__ */ l(p.Provider, {
|
|
170
|
+
value: i,
|
|
171
|
+
children: r
|
|
172
|
+
});
|
|
173
|
+
}, T = ({ orientation: e = "vertical", loop: t = !0, intent: n = "support", disabled: r, className: i, required: a, reverse: o = !1, ref: c, ...u }) => {
|
|
174
|
+
let { labelId: d, isInvalid: p, isRequired: m, description: h, name: g } = f(), _ = a === void 0 ? m : a;
|
|
175
|
+
return /* @__PURE__ */ l(w, {
|
|
176
|
+
reverse: o,
|
|
177
|
+
intent: n,
|
|
178
|
+
disabled: r,
|
|
179
|
+
children: /* @__PURE__ */ l(s.RadioGroup, {
|
|
180
|
+
"data-spark-component": "radio-group",
|
|
181
|
+
className: C({
|
|
182
|
+
orientation: e,
|
|
183
|
+
className: i
|
|
184
|
+
}),
|
|
185
|
+
name: g,
|
|
186
|
+
ref: c,
|
|
187
|
+
disabled: r,
|
|
188
|
+
orientation: e,
|
|
189
|
+
loop: t,
|
|
190
|
+
required: _,
|
|
191
|
+
"aria-labelledby": d,
|
|
192
|
+
"aria-invalid": p,
|
|
193
|
+
"aria-required": _,
|
|
194
|
+
"aria-describedby": h,
|
|
195
|
+
...u
|
|
196
|
+
})
|
|
197
|
+
});
|
|
215
198
|
};
|
|
216
|
-
|
|
199
|
+
T.displayName = "RadioGroup";
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/radio-group/index.ts
|
|
202
|
+
var E = Object.assign(T, { Radio: S });
|
|
203
|
+
E.displayName = "RadioGroup", S.displayName = "RadioGroup.Radio";
|
|
204
|
+
//#endregion
|
|
205
|
+
export { E as RadioGroup };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/radio-group/RadioGroupContext.tsx","../../src/radio-group/RadioIndicator.styles.ts","../../src/radio-group/RadioIndicator.tsx","../../src/radio-group/RadioInput.styles.ts","../../src/radio-group/RadioInput.tsx","../../src/radio-group/RadioLabel.styles.tsx","../../src/radio-group/RadioLabel.tsx","../../src/radio-group/Radio.tsx","../../src/radio-group/RadioGroup.styles.ts","../../src/radio-group/RadioGroupProvider.tsx","../../src/radio-group/RadioGroup.tsx","../../src/radio-group/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nimport type { RadioGroupProps } from './RadioGroup'\nimport type { RadioInputProps } from './RadioInput'\n\nexport type RadioGroupContextState = Pick<RadioInputProps, 'intent' | 'disabled'> &\n Pick<RadioGroupProps, 'reverse'>\n\nexport const RadioGroupContext = createContext<RadioGroupContextState | null>(null)\n\nexport const useRadioGroup = () => {\n const context = useContext(RadioGroupContext)\n\n if (!context) {\n throw Error('useRadioGroup must be used within a RadioGroup provider')\n }\n\n return context\n}\n","import { makeVariants } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioIndicatorStyles = cva(\n [\n 'relative block',\n 'size-3/5',\n 'after:absolute',\n 'after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2',\n 'after:h-0',\n 'after:w-0',\n 'after:block',\n 'after:rounded-[50%]',\n \"after:content-['']\",\n 'after:transition-all',\n 'data-[state=checked]:after:size-full',\n ],\n {\n variants: {\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['after:bg-main'],\n support: ['after:bg-support'],\n accent: ['after:bg-accent'],\n neutral: ['after:bg-neutral'],\n success: ['after:bg-success'],\n alert: ['after:bg-alert'],\n error: ['after:bg-error'],\n info: ['after:bg-info'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type RadioIndicatorStylesProps = VariantProps<typeof radioIndicatorStyles>\n","import { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { Ref } from 'react'\n\nimport { radioIndicatorStyles, RadioIndicatorStylesProps } from './RadioIndicator.styles'\n\nexport interface RadioIndicatorProps extends RadioIndicatorStylesProps {\n className?: string\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.\n */\n forceMount?: true | undefined\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const RadioIndicator = ({ intent, className, ref, ...others }: RadioIndicatorProps) => {\n return (\n <RadixRadioGroup.Indicator\n ref={ref}\n className={radioIndicatorStyles({ intent, className })}\n {...others}\n />\n )\n}\n\nRadioIndicator.displayName = 'RadioGroup.RadioIndicator'\n","import { makeVariants } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioInputVariants = cva(\n [\n 'flex shrink-0 items-center justify-center',\n 'rounded-full',\n 'border-md',\n 'outline-hidden',\n 'hover:ring-4',\n 'focus-visible:u-outline',\n 'disabled:cursor-not-allowed disabled:border-outline/dim-2 disabled:hover:ring-transparent',\n 'u-shadow-border-transition',\n 'size-sz-24',\n ],\n {\n variants: {\n /**\n * Color scheme of the radio input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['border-outline', 'data-[state=checked]:border-main', 'hover:ring-main-container'],\n support: [\n 'border-outline',\n 'data-[state=checked]:border-support',\n 'hover:ring-support-container',\n ],\n accent: [\n 'border-outline',\n 'data-[state=checked]:border-accent',\n 'hover:ring-accent-container',\n ],\n neutral: [\n 'border-outline',\n 'data-[state=checked]:border-neutral',\n 'hover:ring-neutral-container',\n ],\n info: ['border-info', 'data-[state=checked]:border-info', 'hover:ring-info-container'],\n success: [\n 'border-success',\n 'data-[state=checked]:border-success',\n 'hover:ring-success-container',\n ],\n alert: ['border-alert', 'data-[state=checked]:border-alert', 'hover:ring-alert-container'],\n error: ['border-error', 'data-[state=checked]:border-error', 'hover:ring-error-container'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type RadioInputVariantsProps = VariantProps<typeof radioInputVariants>\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { ButtonHTMLAttributes, Ref } from 'react'\n\nimport { RadioIndicator } from './RadioIndicator'\nimport { radioInputVariants, RadioInputVariantsProps } from './RadioInput.styles'\n\nexport interface RadioInputProps\n extends RadioInputVariantsProps,\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onChange'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The value given as data when submitted with a name.\n */\n value: string\n /**\n * When true, prevents the user from interacting with the radio item.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the radio item before the owning form can be submitted.\n */\n required?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const RadioInput = ({ intent: intentProp, className, ref, ...others }: RadioInputProps) => {\n const { state } = useFormFieldControl()\n\n const intent = state ?? intentProp\n\n return (\n <RadixRadioGroup.RadioGroupItem\n data-spark-component=\"radio-input\"\n ref={ref}\n className={radioInputVariants({ intent, className })}\n {...others}\n >\n <RadioIndicator intent={intent} forceMount />\n </RadixRadioGroup.RadioGroupItem>\n )\n}\n\nRadioInput.displayName = 'RadioGroup.RadioInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioLabelStyles = cva('grow', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type RadioLabelStylesProps = VariantProps<typeof radioLabelStyles>\n","import { Label } from 'radix-ui'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\nimport { radioLabelStyles, RadioLabelStylesProps } from './RadioLabel.styles'\n\nexport interface RadioLabelProps\n extends RadioLabelStylesProps,\n PropsWithChildren<HTMLAttributes<HTMLLabelElement>> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the radio item.\n */\n disabled?: boolean\n}\n\nexport const RadioLabel = ({ disabled, ...others }: RadioLabelProps) => {\n return (\n <Label.Root\n data-spark-component=\"radio-label\"\n className={radioLabelStyles({ disabled })}\n {...others}\n />\n )\n}\n\nRadioLabel.displayName = 'RadioGroup.RadioLabel'\n","import { cx } from 'class-variance-authority'\nimport { Ref, useId } from 'react'\n\nimport { useRadioGroup } from './RadioGroupContext'\nimport { RadioInput, RadioInputProps } from './RadioInput'\nimport { RadioLabel } from './RadioLabel'\n\nexport type RadioProps = RadioInputProps & {\n ref?: Ref<HTMLButtonElement>\n}\n\nconst ID_PREFIX = ':radio'\n\nexport const Radio = ({\n className,\n children,\n id,\n disabled: disabledProp,\n ref,\n ...others\n}: RadioProps) => {\n const innerId = `${ID_PREFIX}-input-${useId()}`\n const innerLabelId = `${ID_PREFIX}-label-${useId()}`\n\n const { intent, disabled, reverse } = useRadioGroup()\n\n const radioLabel = children && (\n <RadioLabel disabled={disabledProp || disabled} htmlFor={id || innerId} id={innerLabelId}>\n {children}\n </RadioLabel>\n )\n\n const radioInput = (\n <RadioInput\n ref={ref}\n id={id || innerId}\n intent={intent}\n aria-labelledby={children ? innerLabelId : undefined}\n {...others}\n disabled={disabledProp}\n />\n )\n\n const content = reverse ? (\n <>\n {radioLabel}\n {radioInput}\n </>\n ) : (\n <>\n {radioInput}\n {radioLabel}\n </>\n )\n\n return <span className={cx('gap-md text-body-1 flex items-start', className)}>{content}</span>\n}\n\nRadio.displayName = 'RadioGroup.Radio'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioGroupStyles = cva(['flex'], {\n variants: {\n orientation: {\n vertical: ['flex-col', 'gap-lg'],\n horizontal: ['flex-row', 'gap-xl'],\n },\n },\n})\n\nexport type RadioGroupVariantsProps = VariantProps<typeof radioGroupStyles>\n","import { ReactNode, useMemo } from 'react'\n\nimport type { RadioGroupProps } from './RadioGroup'\nimport { RadioGroupContext } from './RadioGroupContext'\nimport type { RadioInputProps } from './RadioInput'\n\nexport interface RadioGroupProviderProps\n extends Pick<RadioInputProps, 'intent' | 'disabled'>,\n Pick<RadioGroupProps, 'reverse'> {\n children: ReactNode\n}\n\nexport const RadioGroupProvider = ({\n intent,\n disabled,\n reverse,\n children,\n}: RadioGroupProviderProps) => {\n const value = useMemo(() => ({ intent, disabled, reverse }), [intent, disabled, reverse])\n\n return <RadioGroupContext.Provider value={value}>{children}</RadioGroupContext.Provider>\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { HTMLAttributes, Ref } from 'react'\n\nimport { radioGroupStyles, RadioGroupVariantsProps } from './RadioGroup.styles'\nimport { RadioGroupProvider } from './RadioGroupProvider'\nimport { RadioInputVariantsProps } from './RadioInput.styles'\n\nexport interface RadioGroupProps\n extends RadioGroupVariantsProps,\n Pick<RadioInputVariantsProps, 'intent'>,\n Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'dir' | 'onChange'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The value of the radio item that should be checked when initially rendered. Use when you do not need to control the state of the radio items.\n */\n defaultValue?: string\n /**\n * The controlled value of the radio item to check. Should be used in conjunction with onValueChange.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n /**\n * When true, prevents the user from interacting with radio items.\n */\n disabled?: boolean\n /**\n * The name of the group. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * When true, indicates that the user must check a radio item before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The orientation of the component.\n */\n orientation?: 'horizontal' | 'vertical'\n /**\n * The reading direction of the radio group.\n */\n dir?: 'ltr' | 'rtl'\n /**\n * When true, keyboard navigation will loop from last item to first, and vice versa.\n */\n loop?: boolean\n /**\n * When true, the label will be placed on the left side of the Radio\n */\n reverse?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const RadioGroup = ({\n orientation = 'vertical',\n loop = true,\n intent = 'support',\n disabled,\n className,\n required: requiredProp,\n reverse = false,\n ref,\n ...others\n}: RadioGroupProps) => {\n const { labelId, isInvalid, isRequired, description, name } = useFormFieldControl()\n const required = requiredProp !== undefined ? requiredProp : isRequired\n\n return (\n <RadioGroupProvider reverse={reverse} intent={intent} disabled={disabled}>\n <RadixRadioGroup.RadioGroup\n data-spark-component=\"radio-group\"\n className={radioGroupStyles({ orientation, className })}\n name={name}\n ref={ref}\n disabled={disabled}\n orientation={orientation}\n loop={loop}\n required={required}\n aria-labelledby={labelId}\n aria-invalid={isInvalid}\n aria-required={required}\n aria-describedby={description}\n {...others}\n />\n </RadioGroupProvider>\n )\n}\n\nRadioGroup.displayName = 'RadioGroup'\n","import { Radio } from './Radio'\nimport { RadioGroup as Root } from './RadioGroup'\n\nexport const RadioGroup: typeof Root & {\n Radio: typeof Radio\n} = Object.assign(Root, {\n Radio,\n})\n\nRadioGroup.displayName = 'RadioGroup'\nRadio.displayName = 'RadioGroup.Radio'\n\nexport { type RadioGroupProps } from './RadioGroup'\nexport { type RadioProps } from './Radio'\n"],"names":["RadioGroupContext","createContext","useRadioGroup","context","useContext","radioIndicatorStyles","cva","makeVariants","RadioIndicator","intent","className","ref","others","jsx","RadixRadioGroup","radioInputVariants","RadioInput","intentProp","state","useFormFieldControl","radioLabelStyles","RadioLabel","disabled","Label","ID_PREFIX","Radio","children","id","disabledProp","innerId","useId","innerLabelId","reverse","radioLabel","radioInput","content","jsxs","Fragment","cx","radioGroupStyles","RadioGroupProvider","value","useMemo","RadioGroup","orientation","loop","requiredProp","labelId","isInvalid","isRequired","description","name","required","Root"],"mappings":";;;;;;AAQO,MAAMA,IAAoBC,EAA6C,IAAI,GAErEC,IAAgB,MAAM;AACjC,QAAMC,IAAUC,EAAWJ,CAAiB;AAE5C,MAAI,CAACG;AACH,UAAM,MAAM,yDAAyD;AAGvE,SAAOA;AACT,GCfaE,IAAuBC;AAAA,EAClC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,QAAQC,EAGN;AAAA,QACA,MAAM,CAAC,eAAe;AAAA,QACtB,SAAS,CAAC,kBAAkB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AAC,IAAc;AAAA,EACd,MAAAC,IAAO;AAAA,EACP,QAAApC,IAAS;AAAA,EACT,UAAAa;AAAA,EACA,WAAAZ;AAAA,EACA,UAAUoC;AAAA,EACV,SAAAd,IAAU;AAAA,EACV,KAAArB;AAAA,EACA,GAAGC;AACL,MAAuB;AACrB,QAAM,EAAE,SAAAmC,GAAS,WAAAC,GAAW,YAAAC,GAAY,aAAAC,GAAa,MAAAC,EAAA,IAAShC,EAAA,GACxDiC,IAAWN,MAAiB,SAAYA,IAAeG;AAE7D,SACE,gBAAApC,EAAC2B,GAAA,EAAmB,SAAAR,GAAkB,QAAAvB,GAAgB,UAAAa,GACpD,UAAA,gBAAAT;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,wBAAqB;AAAA,MACrB,WAAWyB,EAAiB,EAAE,aAAAK,GAAa,WAAAlC,GAAW;AAAA,MACtD,MAAAyC;AAAA,MACA,KAAAxC;AAAA,MACA,UAAAW;AAAA,MACA,aAAAsB;AAAA,MACA,MAAAC;AAAA,MACA,UAAAO;AAAA,MACA,mBAAiBL;AAAA,MACjB,gBAAcC;AAAA,MACd,iBAAeI;AAAA,MACf,oBAAkBF;AAAA,MACjB,GAAGtC;AAAA,IAAA;AAAA,EAAA,GAER;AAEJ;AAEA+B,EAAW,cAAc;AC3FlB,MAAMA,IAET,OAAO,OAAOU,GAAM;AAAA,EACtB,OAAA5B;AACF,CAAC;AAEDkB,EAAW,cAAc;AACzBlB,EAAM,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/radio-group/RadioGroupContext.tsx","../../src/radio-group/RadioIndicator.styles.ts","../../src/radio-group/RadioIndicator.tsx","../../src/radio-group/RadioInput.styles.ts","../../src/radio-group/RadioInput.tsx","../../src/radio-group/RadioLabel.styles.tsx","../../src/radio-group/RadioLabel.tsx","../../src/radio-group/Radio.tsx","../../src/radio-group/RadioGroup.styles.ts","../../src/radio-group/RadioGroupProvider.tsx","../../src/radio-group/RadioGroup.tsx","../../src/radio-group/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nimport type { RadioGroupProps } from './RadioGroup'\nimport type { RadioInputProps } from './RadioInput'\n\nexport type RadioGroupContextState = Pick<RadioInputProps, 'intent' | 'disabled'> &\n Pick<RadioGroupProps, 'reverse'>\n\nexport const RadioGroupContext = createContext<RadioGroupContextState | null>(null)\n\nexport const useRadioGroup = () => {\n const context = useContext(RadioGroupContext)\n\n if (!context) {\n throw Error('useRadioGroup must be used within a RadioGroup provider')\n }\n\n return context\n}\n","import { makeVariants } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioIndicatorStyles = cva(\n [\n 'relative block',\n 'size-3/5',\n 'after:absolute',\n 'after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2',\n 'after:h-0',\n 'after:w-0',\n 'after:block',\n 'after:rounded-[50%]',\n \"after:content-['']\",\n 'after:transition-all',\n 'data-[state=checked]:after:size-full',\n ],\n {\n variants: {\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['after:bg-main'],\n support: ['after:bg-support'],\n accent: ['after:bg-accent'],\n neutral: ['after:bg-neutral'],\n success: ['after:bg-success'],\n alert: ['after:bg-alert'],\n error: ['after:bg-error'],\n info: ['after:bg-info'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type RadioIndicatorStylesProps = VariantProps<typeof radioIndicatorStyles>\n","import { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { Ref } from 'react'\n\nimport { radioIndicatorStyles, RadioIndicatorStylesProps } from './RadioIndicator.styles'\n\nexport interface RadioIndicatorProps extends RadioIndicatorStylesProps {\n className?: string\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.\n */\n forceMount?: true | undefined\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const RadioIndicator = ({ intent, className, ref, ...others }: RadioIndicatorProps) => {\n return (\n <RadixRadioGroup.Indicator\n ref={ref}\n className={radioIndicatorStyles({ intent, className })}\n {...others}\n />\n )\n}\n\nRadioIndicator.displayName = 'RadioGroup.RadioIndicator'\n","import { makeVariants } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioInputVariants = cva(\n [\n 'flex shrink-0 items-center justify-center',\n 'rounded-full',\n 'border-md',\n 'outline-hidden',\n 'hover:ring-4',\n 'focus-visible:u-outline',\n 'disabled:cursor-not-allowed disabled:border-outline/dim-2 disabled:hover:ring-transparent',\n 'u-shadow-border-transition',\n 'size-sz-24',\n ],\n {\n variants: {\n /**\n * Color scheme of the radio input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['border-outline', 'data-[state=checked]:border-main', 'hover:ring-main-container'],\n support: [\n 'border-outline',\n 'data-[state=checked]:border-support',\n 'hover:ring-support-container',\n ],\n accent: [\n 'border-outline',\n 'data-[state=checked]:border-accent',\n 'hover:ring-accent-container',\n ],\n neutral: [\n 'border-outline',\n 'data-[state=checked]:border-neutral',\n 'hover:ring-neutral-container',\n ],\n info: ['border-info', 'data-[state=checked]:border-info', 'hover:ring-info-container'],\n success: [\n 'border-success',\n 'data-[state=checked]:border-success',\n 'hover:ring-success-container',\n ],\n alert: ['border-alert', 'data-[state=checked]:border-alert', 'hover:ring-alert-container'],\n error: ['border-error', 'data-[state=checked]:border-error', 'hover:ring-error-container'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n },\n }\n)\n\nexport type RadioInputVariantsProps = VariantProps<typeof radioInputVariants>\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { ButtonHTMLAttributes, Ref } from 'react'\n\nimport { RadioIndicator } from './RadioIndicator'\nimport { radioInputVariants, RadioInputVariantsProps } from './RadioInput.styles'\n\nexport interface RadioInputProps\n extends\n RadioInputVariantsProps,\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onChange'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The value given as data when submitted with a name.\n */\n value: string\n /**\n * When true, prevents the user from interacting with the radio item.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the radio item before the owning form can be submitted.\n */\n required?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\nexport const RadioInput = ({ intent: intentProp, className, ref, ...others }: RadioInputProps) => {\n const { state } = useFormFieldControl()\n\n const intent = state ?? intentProp\n\n return (\n <RadixRadioGroup.RadioGroupItem\n data-spark-component=\"radio-input\"\n ref={ref}\n className={radioInputVariants({ intent, className })}\n {...others}\n >\n <RadioIndicator intent={intent} forceMount />\n </RadixRadioGroup.RadioGroupItem>\n )\n}\n\nRadioInput.displayName = 'RadioGroup.RadioInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioLabelStyles = cva('grow', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type RadioLabelStylesProps = VariantProps<typeof radioLabelStyles>\n","import { Label } from 'radix-ui'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\nimport { radioLabelStyles, RadioLabelStylesProps } from './RadioLabel.styles'\n\nexport interface RadioLabelProps\n extends RadioLabelStylesProps, PropsWithChildren<HTMLAttributes<HTMLLabelElement>> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the radio item.\n */\n disabled?: boolean\n}\n\nexport const RadioLabel = ({ disabled, ...others }: RadioLabelProps) => {\n return (\n <Label.Root\n data-spark-component=\"radio-label\"\n className={radioLabelStyles({ disabled })}\n {...others}\n />\n )\n}\n\nRadioLabel.displayName = 'RadioGroup.RadioLabel'\n","import { cx } from 'class-variance-authority'\nimport { Ref, useId } from 'react'\n\nimport { useRadioGroup } from './RadioGroupContext'\nimport { RadioInput, RadioInputProps } from './RadioInput'\nimport { RadioLabel } from './RadioLabel'\n\nexport type RadioProps = RadioInputProps & {\n ref?: Ref<HTMLButtonElement>\n}\n\nconst ID_PREFIX = ':radio'\n\nexport const Radio = ({\n className,\n children,\n id,\n disabled: disabledProp,\n ref,\n ...others\n}: RadioProps) => {\n const innerId = `${ID_PREFIX}-input-${useId()}`\n const innerLabelId = `${ID_PREFIX}-label-${useId()}`\n\n const { intent, disabled, reverse } = useRadioGroup()\n\n const radioLabel = children && (\n <RadioLabel disabled={disabledProp || disabled} htmlFor={id || innerId} id={innerLabelId}>\n {children}\n </RadioLabel>\n )\n\n const radioInput = (\n <RadioInput\n ref={ref}\n id={id || innerId}\n intent={intent}\n aria-labelledby={children ? innerLabelId : undefined}\n {...others}\n disabled={disabledProp}\n />\n )\n\n const content = reverse ? (\n <>\n {radioLabel}\n {radioInput}\n </>\n ) : (\n <>\n {radioInput}\n {radioLabel}\n </>\n )\n\n return <span className={cx('gap-md text-body-1 flex items-start', className)}>{content}</span>\n}\n\nRadio.displayName = 'RadioGroup.Radio'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const radioGroupStyles = cva(['flex'], {\n variants: {\n orientation: {\n vertical: ['flex-col', 'gap-lg'],\n horizontal: ['flex-row', 'gap-xl'],\n },\n },\n})\n\nexport type RadioGroupVariantsProps = VariantProps<typeof radioGroupStyles>\n","import { ReactNode, useMemo } from 'react'\n\nimport type { RadioGroupProps } from './RadioGroup'\nimport { RadioGroupContext } from './RadioGroupContext'\nimport type { RadioInputProps } from './RadioInput'\n\nexport interface RadioGroupProviderProps\n extends Pick<RadioInputProps, 'intent' | 'disabled'>, Pick<RadioGroupProps, 'reverse'> {\n children: ReactNode\n}\n\nexport const RadioGroupProvider = ({\n intent,\n disabled,\n reverse,\n children,\n}: RadioGroupProviderProps) => {\n const value = useMemo(() => ({ intent, disabled, reverse }), [intent, disabled, reverse])\n\n return <RadioGroupContext.Provider value={value}>{children}</RadioGroupContext.Provider>\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { RadioGroup as RadixRadioGroup } from 'radix-ui'\nimport { HTMLAttributes, Ref } from 'react'\n\nimport { radioGroupStyles, RadioGroupVariantsProps } from './RadioGroup.styles'\nimport { RadioGroupProvider } from './RadioGroupProvider'\nimport { RadioInputVariantsProps } from './RadioInput.styles'\n\nexport interface RadioGroupProps\n extends\n RadioGroupVariantsProps,\n Pick<RadioInputVariantsProps, 'intent'>,\n Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'dir' | 'onChange'> {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The value of the radio item that should be checked when initially rendered. Use when you do not need to control the state of the radio items.\n */\n defaultValue?: string\n /**\n * The controlled value of the radio item to check. Should be used in conjunction with onValueChange.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n /**\n * When true, prevents the user from interacting with radio items.\n */\n disabled?: boolean\n /**\n * The name of the group. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * When true, indicates that the user must check a radio item before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The orientation of the component.\n */\n orientation?: 'horizontal' | 'vertical'\n /**\n * The reading direction of the radio group.\n */\n dir?: 'ltr' | 'rtl'\n /**\n * When true, keyboard navigation will loop from last item to first, and vice versa.\n */\n loop?: boolean\n /**\n * When true, the label will be placed on the left side of the Radio\n */\n reverse?: boolean\n ref?: Ref<HTMLDivElement>\n}\n\nexport const RadioGroup = ({\n orientation = 'vertical',\n loop = true,\n intent = 'support',\n disabled,\n className,\n required: requiredProp,\n reverse = false,\n ref,\n ...others\n}: RadioGroupProps) => {\n const { labelId, isInvalid, isRequired, description, name } = useFormFieldControl()\n const required = requiredProp !== undefined ? requiredProp : isRequired\n\n return (\n <RadioGroupProvider reverse={reverse} intent={intent} disabled={disabled}>\n <RadixRadioGroup.RadioGroup\n data-spark-component=\"radio-group\"\n className={radioGroupStyles({ orientation, className })}\n name={name}\n ref={ref}\n disabled={disabled}\n orientation={orientation}\n loop={loop}\n required={required}\n aria-labelledby={labelId}\n aria-invalid={isInvalid}\n aria-required={required}\n aria-describedby={description}\n {...others}\n />\n </RadioGroupProvider>\n )\n}\n\nRadioGroup.displayName = 'RadioGroup'\n","import { Radio } from './Radio'\nimport { RadioGroup as Root } from './RadioGroup'\n\nexport const RadioGroup: typeof Root & {\n Radio: typeof Radio\n} = Object.assign(Root, {\n Radio,\n})\n\nRadioGroup.displayName = 'RadioGroup'\nRadio.displayName = 'RadioGroup.Radio'\n\nexport { type RadioGroupProps } from './RadioGroup'\nexport { type RadioProps } from './Radio'\n"],"mappings":";;;;;;;AAQA,IAAa,IAAoB,EAA6C,KAAK,EAEtE,UAAsB;CACjC,IAAM,IAAU,EAAW,EAAkB;AAE7C,KAAI,CAAC,EACH,OAAM,MAAM,0DAA0D;AAGxE,QAAO;GCdI,IAAuB,EAClC;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EACD;CACE,UAAU,EACR,QAAQ,EAGN;EACA,MAAM,CAAC,gBAAgB;EACvB,SAAS,CAAC,mBAAmB;EAC7B,QAAQ,CAAC,kBAAkB;EAC3B,SAAS,CAAC,mBAAmB;EAC7B,SAAS,CAAC,mBAAmB;EAC7B,OAAO,CAAC,iBAAiB;EACzB,OAAO,CAAC,iBAAiB;EACzB,MAAM,CAAC,gBAAgB;EACxB,CAAC,EACH;CACD,iBAAiB,EACf,QAAQ,WACT;CACF,CACF,ECnBY,KAAkB,EAAE,WAAQ,cAAW,QAAK,GAAG,QAExD,kBAAC,EAAgB,WAAjB;CACO;CACL,WAAW,EAAqB;EAAE;EAAQ;EAAW,CAAC;CACtD,GAAI;CACJ,CAAA;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;GACd,iBAAe;GACf,oBAAkB;GAClB,GAAI;GACJ,CAAA;EACiB,CAAA;;AAIzB,EAAW,cAAc;;;AC5FzB,IAAa,IAET,OAAO,OAAO,GAAM,EACtB,UACD,CAAC;AAEF,EAAW,cAAc,cACzB,EAAM,cAAc"}
|
package/dist/rating/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../icon-CRPcdgYp.js`),t=require(`../form-field-Bu_0E9tb.js`);let n=require(`class-variance-authority`),r=require(`react`),i=require(`react/jsx-runtime`),a=require(`@spark-ui/hooks/use-combined-state`),o=require(`@spark-ui/icons/StarFill`),s=require(`@spark-ui/icons/StarOutline`);var c=(0,n.cva)([`peer after:inset-0 group relative after:block after:absolute`],{variants:{disabled:{true:`opacity-dim-3`,false:``},readOnly:{true:``,false:``},gap:{sm:[`after:w-[calc(100%+(var(--spacing-sm)))]`,`last-of-type:after:content-none`],md:[`after:w-[calc(100%+(var(--spacing-md)))]`,`last-of-type:after:content-none`]}},compoundVariants:[{readOnly:!1,disabled:!1,className:(0,n.cx)((0,n.cx)(`[&_>_div]:peer-hover:w-0!`),`cursor-pointer transition-all duration-200 scale-100`,`hover:scale-150 focus-visible:scale-150`,`[&[data-suppress-scale]]:hover:scale-100 [&[data-suppress-scale]]:focus-visible:scale-100`)}],defaultVariants:{disabled:!1,readOnly:!1,gap:`sm`}}),l=(0,n.cva)(``,{variants:{size:{sm:`text-caption-link`,md:`text-body-1`,lg:`text-display-1`},design:{filled:[`text-main-variant`,`group-[[data-part=star][data-hovered]]:text-main-variant-hovered`],outlined:[`text-on-surface/dim-3`]}}}),u=({value:t,size:a,disabled:u,readOnly:d,checked:f=!1,ariaLabel:p,ariaLabelledBy:m,tabIndex:h,onClick:g,onKeyDown:_,onMouseEnter:v,children:y,ref:b})=>{let x=!u&&!d,[S,C]=(0,r.useState)(!1),w=e=>{g?.(e),x&&C(!0)},T=()=>C(!1);return(0,i.jsxs)(`div`,{ref:b,role:`radio`,"aria-checked":f,"aria-label":p,"aria-labelledby":m,tabIndex:h,"data-spark-component":`rating-star`,"data-part":`star`,...x&&S&&{"data-suppress-scale":``},className:c({gap:a===`lg`?`md`:`sm`,disabled:u,readOnly:d}),onClick:w,onKeyDown:_,onMouseEnter:v,onMouseLeave:T,onMouseMove:T,children:[(0,i.jsx)(`div`,{className:(0,n.cx)(`z-raised absolute overflow-hidden`,`group-[[data-part=star][data-hovered]]:overflow-visible`),style:{width:t*100+`%`},children:(0,i.jsx)(e.t,{className:l({size:a,design:`filled`}),children:(0,i.jsx)(o.StarFill,{})})}),(0,i.jsx)(e.t,{className:l({size:a,design:`outlined`}),children:(0,i.jsx)(s.StarOutline,{})}),y]})};function d({value:e,index:t}){return e===void 0?0:e>=t+1?1:0}function f(e,t){return[e.slice(0,t),e.slice(t)]}var p=e=>e===void 0||!Number.isInteger(e)||e<1?0:Math.min(5,Math.max(1,e));function m(e,t,n,r){return i=>{if(r)switch(i.key){case`ArrowRight`:case`ArrowDown`:i.preventDefault();let r=Math.min(4,e+1);n(r+1),t.current[r]?.focus();break;case`ArrowLeft`:case`ArrowUp`:i.preventDefault();let a=Math.max(0,e-1);n(a+1),t.current[a]?.focus();break;case` `:i.preventDefault(),n(e+1);break;default:break}}}function h(e,t){return t>=1?t-1===e?0:-1:e===0?0:-1}var g=({defaultValue:e,value:o,onValueChange:s,disabled:c,readOnly:l,required:g,name:_,id:v,"aria-label":y,getStarLabel:b,ref:x,...S})=>{let{labelId:C,isInvalid:w,isRequired:T,description:E,name:D,disabled:O,readOnly:k}=t.n(),A=(0,r.useRef)([]),j=(0,r.useId)(),[M,N]=(0,r.useState)(null),[P,F]=(0,a.useCombinedState)(o,e,s),I=p(P??0),L=c??O,R=l??k,z=g===void 0?T:g,B=_??D,V=!(L||R),H=b!==void 0||y!==void 0,U=M===null?I:M+1;function W(e){V&&(F(e+1),A.current[e]?.focus())}let G=(0,r.useCallback)(e=>m(e,A,F,V),[V,F]);function K({currentTarget:e}){let t=A.current.findIndex(t=>t===e);N(t>=0?t:null);let[n,r]=f(A.current,t+1);n.forEach(e=>e?.setAttribute(`data-hovered`,``)),r.forEach(e=>e?.removeAttribute(`data-hovered`))}let q=(0,r.useCallback)(e=>t=>{A.current[e]=t},[]);function J(){N(null),A.current.forEach(e=>e?.removeAttribute(`data-hovered`))}return(0,i.jsxs)(`div`,{ref:x,id:v,role:`radiogroup`,"aria-label":y,"aria-labelledby":C,"aria-invalid":w,"aria-required":z,"aria-describedby":E,className:`relative inline-flex`,"data-spark-component":`rating`,...S,onMouseLeave:J,children:[B!==void 0&&(0,i.jsx)(`input`,{type:`hidden`,name:B,value:I,"aria-hidden":!0,"data-part":`input`}),(0,i.jsx)(`div`,{className:(0,n.cx)(`gap-x-md`,`flex`),children:Array.from({length:5}).map((e,t)=>(0,i.jsx)(u,{ref:q(t),disabled:L,readOnly:R,size:`lg`,value:d({index:t,value:U}),checked:I===t+1,ariaLabel:H?b?.(t)??`${y} ${t+1}`:void 0,ariaLabelledBy:!H&&C?`${C} ${j}-star-${t+1}`:void 0,tabIndex:V?h(t,I):-1,onClick:()=>W(t),onKeyDown:G(t),onMouseEnter:e=>V&&K(e),children:!H&&(0,i.jsx)(`span`,{id:`${j}-star-${t+1}`,className:`sr-only`,children:t+1})},t))})]})};exports.Rating=g;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|