ics-ui-kit 0.1.0 → 0.1.2
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/{CheckboxField-B6ojieD7.js → CheckboxField-cX09-eBX.js} +2 -2
- package/dist/{CheckboxField-B6ojieD7.js.map → CheckboxField-cX09-eBX.js.map} +1 -1
- package/dist/{Field-CSvS9f_a.js → Field-CKl59qUB.js} +2 -2
- package/dist/{Field-CSvS9f_a.js.map → Field-CKl59qUB.js.map} +1 -1
- package/dist/{FieldLabel-BA0y5lhr.js → FieldLabel-QJ4rJFOi.js} +2 -2
- package/dist/{FieldLabel-BA0y5lhr.js.map → FieldLabel-QJ4rJFOi.js.map} +1 -1
- package/dist/{FormFooterTemplate-BPspyDbr.js → FormFooterTemplate-DPB6Dkxn.js} +2 -2
- package/dist/{FormFooterTemplate-BPspyDbr.js.map → FormFooterTemplate-DPB6Dkxn.js.map} +1 -1
- package/dist/{FormStack-DvlFQQiP.js → FormStack-B4QOuYgO.js} +3 -3
- package/dist/{FormStack-DvlFQQiP.js.map → FormStack-B4QOuYgO.js.map} +1 -1
- package/dist/IconTooltip-CKJKGHbk.js +11 -0
- package/dist/IconTooltip-CKJKGHbk.js.map +1 -0
- package/dist/blocks/auth/otp-form.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/form.js +3 -3
- package/dist/components/icon-tooltip.js +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/switch/Switch.d.ts +2 -1
- package/dist/components/switch.js +67 -52
- package/dist/components/switch.js.map +1 -1
- package/dist/lib/utils/variants.d.ts +1 -1
- package/dist/styles-scoped.css +413 -366
- package/dist/styles.css +413 -366
- package/package.json +183 -183
- package/tailwind.preset.js +4 -0
- package/dist/IconTooltip-DhkXc8Uy.js +0 -11
- package/dist/IconTooltip-DhkXc8Uy.js.map +0 -1
|
@@ -1,105 +1,106 @@
|
|
|
1
1
|
import { jsxs as y, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import * as l from "react";
|
|
3
3
|
import D, { useId as M } from "react";
|
|
4
|
-
import { P as
|
|
4
|
+
import { P as S, c as H } from "../index-CFaU3UXv.js";
|
|
5
5
|
import { u as C } from "../index-DLcqcWxM.js";
|
|
6
6
|
import { c as j } from "../index-DFZozV_h.js";
|
|
7
7
|
import { u as A } from "../index-437EL2iq.js";
|
|
8
8
|
import { u as L } from "../index-BZPx6jYI.js";
|
|
9
9
|
import { u as U } from "../index-BGQepRFJ.js";
|
|
10
10
|
import { T as N } from "../index-BVqs-uqP.js";
|
|
11
|
-
import {
|
|
11
|
+
import { u as V } from "../ComponentVariantProvider-B0SFUaXB.js";
|
|
12
|
+
import { F as W } from "../FieldLabel-QJ4rJFOi.js";
|
|
12
13
|
import { D as q } from "../Description-BTPMlTT-.js";
|
|
13
|
-
var
|
|
14
|
-
(t,
|
|
14
|
+
var g = "Switch", [O, ue] = j(g), [$, X] = O(g), P = l.forwardRef(
|
|
15
|
+
(t, n) => {
|
|
15
16
|
const {
|
|
16
17
|
__scopeSwitch: e,
|
|
17
18
|
name: o,
|
|
18
19
|
checked: r,
|
|
19
|
-
defaultChecked:
|
|
20
|
-
required:
|
|
20
|
+
defaultChecked: i,
|
|
21
|
+
required: c,
|
|
21
22
|
disabled: a,
|
|
22
23
|
value: u = "on",
|
|
23
24
|
onCheckedChange: f,
|
|
24
|
-
form:
|
|
25
|
+
form: d,
|
|
25
26
|
...b
|
|
26
|
-
} = t, [
|
|
27
|
+
} = t, [p, m] = l.useState(null), v = C(n, (x) => m(x)), h = l.useRef(!1), k = p ? d || !!p.closest("form") : !0, [w, B] = A({
|
|
27
28
|
prop: r,
|
|
28
|
-
defaultProp:
|
|
29
|
+
defaultProp: i ?? !1,
|
|
29
30
|
onChange: f,
|
|
30
|
-
caller:
|
|
31
|
+
caller: g
|
|
31
32
|
});
|
|
32
|
-
return /* @__PURE__ */ y(
|
|
33
|
+
return /* @__PURE__ */ y($, { scope: e, checked: w, disabled: a, children: [
|
|
33
34
|
/* @__PURE__ */ s(
|
|
34
|
-
|
|
35
|
+
S.button,
|
|
35
36
|
{
|
|
36
37
|
type: "button",
|
|
37
38
|
role: "switch",
|
|
38
|
-
"aria-checked":
|
|
39
|
-
"aria-required":
|
|
40
|
-
"data-state": I(
|
|
39
|
+
"aria-checked": w,
|
|
40
|
+
"aria-required": c,
|
|
41
|
+
"data-state": I(w),
|
|
41
42
|
"data-disabled": a ? "" : void 0,
|
|
42
43
|
disabled: a,
|
|
43
44
|
value: u,
|
|
44
45
|
...b,
|
|
45
|
-
ref:
|
|
46
|
+
ref: v,
|
|
46
47
|
onClick: H(t.onClick, (x) => {
|
|
47
|
-
B((z) => !z), k && (
|
|
48
|
+
B((z) => !z), k && (h.current = x.isPropagationStopped(), h.current || x.stopPropagation());
|
|
48
49
|
})
|
|
49
50
|
}
|
|
50
51
|
),
|
|
51
52
|
k && /* @__PURE__ */ s(
|
|
52
53
|
E,
|
|
53
54
|
{
|
|
54
|
-
control:
|
|
55
|
-
bubbles: !
|
|
55
|
+
control: p,
|
|
56
|
+
bubbles: !h.current,
|
|
56
57
|
name: o,
|
|
57
58
|
value: u,
|
|
58
|
-
checked:
|
|
59
|
-
required:
|
|
59
|
+
checked: w,
|
|
60
|
+
required: c,
|
|
60
61
|
disabled: a,
|
|
61
|
-
form:
|
|
62
|
+
form: d,
|
|
62
63
|
style: { transform: "translateX(-100%)" }
|
|
63
64
|
}
|
|
64
65
|
)
|
|
65
66
|
] });
|
|
66
67
|
}
|
|
67
68
|
);
|
|
68
|
-
P.displayName =
|
|
69
|
+
P.displayName = g;
|
|
69
70
|
var R = "SwitchThumb", _ = l.forwardRef(
|
|
70
|
-
(t,
|
|
71
|
-
const { __scopeSwitch: e, ...o } = t, r =
|
|
71
|
+
(t, n) => {
|
|
72
|
+
const { __scopeSwitch: e, ...o } = t, r = X(R, e);
|
|
72
73
|
return /* @__PURE__ */ s(
|
|
73
|
-
|
|
74
|
+
S.span,
|
|
74
75
|
{
|
|
75
76
|
"data-state": I(r.checked),
|
|
76
77
|
"data-disabled": r.disabled ? "" : void 0,
|
|
77
78
|
...o,
|
|
78
|
-
ref:
|
|
79
|
+
ref: n
|
|
79
80
|
}
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
);
|
|
83
84
|
_.displayName = R;
|
|
84
|
-
var
|
|
85
|
+
var G = "SwitchBubbleInput", E = l.forwardRef(
|
|
85
86
|
({
|
|
86
87
|
__scopeSwitch: t,
|
|
87
|
-
control:
|
|
88
|
+
control: n,
|
|
88
89
|
checked: e,
|
|
89
90
|
bubbles: o = !0,
|
|
90
91
|
...r
|
|
91
|
-
},
|
|
92
|
-
const
|
|
92
|
+
}, i) => {
|
|
93
|
+
const c = l.useRef(null), a = C(c, i), u = L(e), f = U(n);
|
|
93
94
|
return l.useEffect(() => {
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
95
|
+
const d = c.current;
|
|
96
|
+
if (!d) return;
|
|
96
97
|
const b = window.HTMLInputElement.prototype, m = Object.getOwnPropertyDescriptor(
|
|
97
98
|
b,
|
|
98
99
|
"checked"
|
|
99
100
|
).set;
|
|
100
101
|
if (u !== e && m) {
|
|
101
|
-
const
|
|
102
|
-
m.call(
|
|
102
|
+
const v = new Event("click", { bubbles: o });
|
|
103
|
+
m.call(d, e), d.dispatchEvent(v);
|
|
103
104
|
}
|
|
104
105
|
}, [u, e, o]), /* @__PURE__ */ s(
|
|
105
106
|
"input",
|
|
@@ -122,12 +123,12 @@ var X = "SwitchBubbleInput", E = l.forwardRef(
|
|
|
122
123
|
);
|
|
123
124
|
}
|
|
124
125
|
);
|
|
125
|
-
E.displayName =
|
|
126
|
+
E.displayName = G;
|
|
126
127
|
function I(t) {
|
|
127
128
|
return t ? "checked" : "unchecked";
|
|
128
129
|
}
|
|
129
|
-
var F = P,
|
|
130
|
-
const
|
|
130
|
+
var F = P, J = _;
|
|
131
|
+
const K = N({
|
|
131
132
|
slots: {
|
|
132
133
|
root: [
|
|
133
134
|
"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full",
|
|
@@ -142,6 +143,10 @@ const J = N({
|
|
|
142
143
|
},
|
|
143
144
|
variants: {
|
|
144
145
|
size: {
|
|
146
|
+
xs: {
|
|
147
|
+
root: "h-4 w-7",
|
|
148
|
+
thumb: "h-3 w-3 data-[state=checked]:translate-x-[14px] data-[state=unchecked]:translate-x-0.5"
|
|
149
|
+
},
|
|
145
150
|
sm: {
|
|
146
151
|
root: "h-5 w-9",
|
|
147
152
|
thumb: "h-4 w-4 data-[state=checked]:translate-x-[18px] data-[state=unchecked]:translate-x-0.5"
|
|
@@ -150,19 +155,29 @@ const J = N({
|
|
|
150
155
|
root: "h-6 w-11",
|
|
151
156
|
thumb: "h-5 w-5 data-[state=checked]:translate-x-[22px] data-[state=unchecked]:translate-x-0.5"
|
|
152
157
|
}
|
|
158
|
+
},
|
|
159
|
+
theme: {
|
|
160
|
+
inverse: {
|
|
161
|
+
root: [
|
|
162
|
+
"focus-visible:shadow-inverse-focus",
|
|
163
|
+
"data-[state=unchecked]:bg-inverse-active data-[state=unchecked]:hover:enabled:bg-inverse-muted",
|
|
164
|
+
"data-[state=checked]:bg-inverse-primary-fg data-[state=checked]:hover:enabled:bg-inverse-secondary-fg"
|
|
165
|
+
],
|
|
166
|
+
thumb: "bg-inverse-primary-bg"
|
|
167
|
+
}
|
|
153
168
|
}
|
|
154
169
|
},
|
|
155
170
|
defaultVariants: {
|
|
156
171
|
size: "md"
|
|
157
172
|
}
|
|
158
173
|
}), T = l.forwardRef(
|
|
159
|
-
({ className: t, size:
|
|
160
|
-
const {
|
|
161
|
-
return /* @__PURE__ */ s(F, { className:
|
|
174
|
+
({ className: t, size: n, ...e }, o) => {
|
|
175
|
+
const { variant: r } = V(), { root: i, thumb: c } = K({ size: n, theme: r });
|
|
176
|
+
return /* @__PURE__ */ s(F, { className: i({ className: t }), ...e, ref: o, children: /* @__PURE__ */ s(J, { className: c() }) });
|
|
162
177
|
}
|
|
163
178
|
);
|
|
164
179
|
T.displayName = F.displayName;
|
|
165
|
-
const
|
|
180
|
+
const Q = N({
|
|
166
181
|
slots: {
|
|
167
182
|
container: "flex cursor-pointer items-center gap-3",
|
|
168
183
|
textContainer: "flex flex-col gap-1",
|
|
@@ -199,26 +214,26 @@ const K = N({
|
|
|
199
214
|
defaultVariants: {
|
|
200
215
|
alignment: "left"
|
|
201
216
|
}
|
|
202
|
-
}),
|
|
203
|
-
({ className: t, id:
|
|
217
|
+
}), Y = D.forwardRef(
|
|
218
|
+
({ className: t, id: n, label: e, alignment: o, error: r, disabled: i, outline: c, description: a, ...u }, f) => {
|
|
204
219
|
const {
|
|
205
|
-
container:
|
|
220
|
+
container: d,
|
|
206
221
|
textContainer: b,
|
|
207
|
-
label:
|
|
222
|
+
label: p,
|
|
208
223
|
labelWrapper: m
|
|
209
|
-
} =
|
|
210
|
-
return /* @__PURE__ */ y("label", { htmlFor:
|
|
211
|
-
/* @__PURE__ */ s(T, { disabled:
|
|
224
|
+
} = Q({ alignment: o, error: r, disabled: i, outline: c, withDescription: !!a }), v = M(), h = n || `switch-${v}`;
|
|
225
|
+
return /* @__PURE__ */ y("label", { htmlFor: h, className: d({ class: t }), children: [
|
|
226
|
+
/* @__PURE__ */ s(T, { disabled: i, id: h, ...u, ref: f }),
|
|
212
227
|
(e || a) && /* @__PURE__ */ y("div", { className: b(), children: [
|
|
213
|
-
e && /* @__PURE__ */ s("div", { className: m(), children: /* @__PURE__ */ s(W, { htmlFor:
|
|
228
|
+
e && /* @__PURE__ */ s("div", { className: m(), children: /* @__PURE__ */ s(W, { htmlFor: h, className: p(), children: e }) }),
|
|
214
229
|
a && /* @__PURE__ */ s(q, { size: "xs", children: a })
|
|
215
230
|
] })
|
|
216
231
|
] });
|
|
217
232
|
}
|
|
218
233
|
);
|
|
219
|
-
|
|
234
|
+
Y.displayName = "SwitchField";
|
|
220
235
|
export {
|
|
221
236
|
T as Switch,
|
|
222
|
-
|
|
237
|
+
Y as SwitchField
|
|
223
238
|
};
|
|
224
239
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":["../../node_modules/.pnpm/@radix-ui+react-switch@1.2._f3fb04ca0cb9718d2dd2dba40e11ef1d/node_modules/@radix-ui/react-switch/dist/index.mjs","../../src/components/switch/Switch.tsx","../../src/components/switch/switch-field/SwitchField.tsx"],"sourcesContent":["\"use client\";\n\n// src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: SWITCH_NAME\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n SwitchBubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BUBBLE_INPUT_NAME = \"SwitchBubbleInput\";\nvar SwitchBubbleInput = React.forwardRef(\n ({\n __scopeSwitch,\n control,\n checked,\n bubbles = true,\n ...props\n }, forwardedRef) => {\n const ref = React.useRef(null);\n const composedRefs = useComposedRefs(ref, forwardedRef);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n if (!input) return;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n \"checked\"\n );\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...props,\n tabIndex: -1,\n ref: composedRefs,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n }\n);\nSwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\r\nimport * as SwitchPrimitives from \"@radix-ui/react-switch\";\r\nimport { tv } from \"tailwind-variants\";\r\nimport { VariantsConfig } from \"@/lib/utils/variants\";\r\n\r\nexport interface SwitchVariants {\r\n\tsize?: \"sm\" | \"md\";\r\n}\r\n\r\n/**\r\n * Варианты стилей для компонента Switch\r\n */\r\nconst switchStyles = tv({\r\n\tslots: {\r\n\t\troot: [\r\n\t\t\t\"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full\",\r\n\t\t\t\"transition-colors\",\r\n\t\t\t\"focus-visible:border-tertiary-accent focus-visible:shadow-focus focus-visible:outline-none\",\r\n\t\t\t\"disabled:cursor-not-allowed disabled:opacity-50\",\r\n\t\t\t\"data-[state=checked]:bg-primary-accent data-[state=unchecked]:bg-secondary-border\",\r\n\t\t\t\"data-[state=checked]:hover:enabled:bg-primary-accent-hover\",\r\n\t\t\t\"data-[state=unchecked]:hover:enabled:bg-primary-border\"\r\n\t\t],\r\n\t\tthumb: \"rounded-full bg-secondary-bg shadow-soft-base transition-transform\"\r\n\t},\r\n\tvariants: {\r\n\t\tsize: {\r\n\t\t\tsm: {\r\n\t\t\t\troot: \"h-5 w-9\",\r\n\t\t\t\tthumb: \"h-4 w-4 data-[state=checked]:translate-x-[18px] data-[state=unchecked]:translate-x-0.5\"\r\n\t\t\t},\r\n\t\t\tmd: {\r\n\t\t\t\troot: \"h-6 w-11\",\r\n\t\t\t\tthumb: \"h-5 w-5 data-[state=checked]:translate-x-[22px] data-[state=unchecked]:translate-x-0.5\"\r\n\t\t\t}\r\n\t\t}\r\n\t} satisfies VariantsConfig<SwitchVariants>,\r\n\tdefaultVariants: {\r\n\t\tsize: \"md\"\r\n\t}\r\n});\r\n\r\nexport type SwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> & SwitchVariants;\r\n\r\nconst Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, SwitchProps>(\r\n\t({ className, size, ...props }, ref) => {\r\n\t\tconst { root, thumb } = switchStyles({ size });\r\n\r\n\t\treturn (\r\n\t\t\t<SwitchPrimitives.Root className={root({ className })} {...props} ref={ref}>\r\n\t\t\t\t<SwitchPrimitives.Thumb className={thumb()} />\r\n\t\t\t</SwitchPrimitives.Root>\r\n\t\t);\r\n\t}\r\n);\r\nSwitch.displayName = SwitchPrimitives.Root.displayName;\r\n\r\nexport { Switch };\r\n","import * as SwitchPrimitives from \"@radix-ui/react-checkbox\";\r\nimport { tv } from \"tailwind-variants\";\r\nimport React, { useId } from \"react\";\r\nimport { FieldLabel } from \"@/components/label\";\r\nimport { Description } from \"@/components/description\";\r\nimport { Switch, SwitchProps } from \"../Switch\";\r\nimport { VariantsConfig } from \"@/lib/utils/variants\";\r\n\r\nexport interface SwitchFieldVariants {\r\n\toutline?: boolean;\r\n\talignment?: \"left\" | \"right\";\r\n\tdisabled?: boolean;\r\n\terror?: boolean;\r\n}\r\n\r\nconst switchFieldStyles = tv({\r\n\tslots: {\r\n\t\tcontainer: \"flex cursor-pointer items-center gap-3\",\r\n\t\ttextContainer: \"flex flex-col gap-1\",\r\n\t\tlabelWrapper: \"flex h-4 items-center\",\r\n\t\tlabel: \"cursor-pointer\"\r\n\t},\r\n\tvariants: {\r\n\t\toutline: {\r\n\t\t\ttrue: {\r\n\t\t\t\tcontainer: \"rounded-lg border border-secondary-border p-3 px-4\"\r\n\t\t\t}\r\n\t\t},\r\n\t\tdisabled: {\r\n\t\t\ttrue: {\r\n\t\t\t\tcontainer: \"cursor-default\",\r\n\t\t\t\ttextContainer: \"opacity-50\",\r\n\t\t\t\tlabel: \"cursor-default text-primary-fg\",\r\n\t\t\t\tdescription: \"text-muted\"\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: {\r\n\t\t\ttrue: {\r\n\t\t\t\tlabel: \"text-status-error\"\r\n\t\t\t}\r\n\t\t},\r\n\t\talignment: {\r\n\t\t\tleft: {},\r\n\t\t\tright: {\r\n\t\t\t\tcontainer: \"flex-row-reverse space-x-reverse\"\r\n\t\t\t}\r\n\t\t},\r\n\t\twithDescription: { true: { container: \"items-start\" } }\r\n\t} satisfies VariantsConfig<SwitchFieldVariants & { withDescription?: boolean }>,\r\n\tdefaultVariants: {\r\n\t\talignment: \"left\"\r\n\t}\r\n});\r\n\r\ntype SwitchFieldProps = SwitchProps &\r\n\tSwitchFieldVariants & {\r\n\t\tlabel?: string | React.ReactNode;\r\n\t\tdescription?: string;\r\n\t};\r\n\r\nconst SwitchField = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, SwitchFieldProps>(\r\n\t({ className, id, label, alignment: alignment, error, disabled, outline, description, ...props }, ref) => {\r\n\t\tconst {\r\n\t\t\tcontainer,\r\n\t\t\ttextContainer,\r\n\t\t\tlabel: labelStyles,\r\n\t\t\tlabelWrapper\r\n\t\t} = switchFieldStyles({ alignment, error, disabled, outline, withDescription: !!description });\r\n\r\n\t\tconst generatedId = useId();\r\n\t\tconst switchId = id || `switch-${generatedId}`;\r\n\r\n\t\treturn (\r\n\t\t\t<label htmlFor={switchId} className={container({ class: className })}>\r\n\t\t\t\t<Switch disabled={disabled} id={switchId} {...props} ref={ref} />\r\n\t\t\t\t{(label || description) && (\r\n\t\t\t\t\t<div className={textContainer()}>\r\n\t\t\t\t\t\t{label && (\r\n\t\t\t\t\t\t\t<div className={labelWrapper()}>\r\n\t\t\t\t\t\t\t\t<FieldLabel htmlFor={switchId} className={labelStyles()}>\r\n\t\t\t\t\t\t\t\t\t{label}\r\n\t\t\t\t\t\t\t\t</FieldLabel>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t{description && <Description size=\"xs\">{description}</Description>}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t)}\r\n\t\t\t</label>\r\n\t\t);\r\n\t}\r\n);\r\n\r\nSwitchField.displayName = \"SwitchField\";\r\n\r\nexport { SwitchField };\r\n"],"names":["SWITCH_NAME","createSwitchContext","createSwitchScope","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","SwitchBubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","BUBBLE_INPUT_NAME","control","bubbles","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","switchStyles","tv","className","size","root","thumb","SwitchPrimitives.Root","SwitchPrimitives.Thumb","switchFieldStyles","SwitchField","id","label","alignment","error","outline","description","container","textContainer","labelStyles","labelWrapper","generatedId","useId","switchId","FieldLabel","Description"],"mappings":";;;;;;;;;;;;AAYA,IAAIA,IAAc,UACd,CAACC,GAAqBC,EAAiB,IAAIC,EAAmBH,CAAW,GACzE,CAACI,GAAgBC,CAAgB,IAAIJ,EAAoBD,CAAW,GACpEM,IAASC,EAAM;AAAA,EACjB,CAACC,GAAOC,MAAiB;AACvB,UAAM;AAAA,MACJ,eAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAASC;AAAA,MACT,gBAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,iBAAAC;AAAA,MACA,MAA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,IAAI4D,GAAW,GAAGnE,GAAO,KAAAqC,GAAU;AAAA,OAC7DmB,KAASI,MACV,gBAAAtC,EAAC,OAAI,EAAA,WAAWwC,EACd,GAAA,UAAA;AAAA,QAAAN,KACC,gBAAAjC,EAAA,OAAA,EAAI,WAAWyC,EACf,GAAA,UAAA,gBAAAzC,EAAC6C,GAAW,EAAA,SAASD,GAAU,WAAWJ,EAAY,GACpD,YACF,CAAA,GACD;AAAA,QAEAH,KAAe,gBAAArC,EAAC8C,GAAY,EAAA,MAAK,MAAM,UAAYT,EAAA,CAAA;AAAA,MAAA,EACrD,CAAA;AAAA,IAAA,GAEF;AAAA,EAAA;AAGH;AAEAN,EAAY,cAAc;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"switch.js","sources":["../../node_modules/.pnpm/@radix-ui+react-switch@1.2._f3fb04ca0cb9718d2dd2dba40e11ef1d/node_modules/@radix-ui/react-switch/dist/index.mjs","../../src/components/switch/Switch.tsx","../../src/components/switch/switch-field/SwitchField.tsx"],"sourcesContent":["\"use client\";\n\n// src/switch.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar SWITCH_NAME = \"Switch\";\nvar [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\nvar [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);\nvar Switch = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked ?? false,\n onChange: onCheckedChange,\n caller: SWITCH_NAME\n });\n return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"switch\",\n \"aria-checked\": checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...switchProps,\n ref: composedRefs,\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n SwitchBubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" }\n }\n )\n ] });\n }\n);\nSwitch.displayName = SWITCH_NAME;\nvar THUMB_NAME = \"SwitchThumb\";\nvar SwitchThumb = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.checked),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...thumbProps,\n ref: forwardedRef\n }\n );\n }\n);\nSwitchThumb.displayName = THUMB_NAME;\nvar BUBBLE_INPUT_NAME = \"SwitchBubbleInput\";\nvar SwitchBubbleInput = React.forwardRef(\n ({\n __scopeSwitch,\n control,\n checked,\n bubbles = true,\n ...props\n }, forwardedRef) => {\n const ref = React.useRef(null);\n const composedRefs = useComposedRefs(ref, forwardedRef);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n if (!input) return;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n \"checked\"\n );\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: checked,\n ...props,\n tabIndex: -1,\n ref: composedRefs,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n }\n);\nSwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;\nfunction getState(checked) {\n return checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Switch;\nvar Thumb = SwitchThumb;\nexport {\n Root,\n Switch,\n SwitchThumb,\n Thumb,\n createSwitchScope\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\r\nimport * as SwitchPrimitives from \"@radix-ui/react-switch\";\r\nimport { tv } from \"tailwind-variants\";\r\nimport { VariantsConfig } from \"@/lib/utils/variants\";\r\nimport { useComponentVariant } from \"@/providers/component-variant-context\";\r\n\r\nexport interface SwitchVariants {\r\n\tsize?: \"xs\" | \"sm\" | \"md\";\r\n\ttheme?: \"inverse\";\r\n}\r\n\r\n/**\r\n * Варианты стилей для компонента Switch\r\n */\r\nconst switchStyles = tv({\r\n\tslots: {\r\n\t\troot: [\r\n\t\t\t\"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full\",\r\n\t\t\t\"transition-colors\",\r\n\t\t\t\"focus-visible:border-tertiary-accent focus-visible:shadow-focus focus-visible:outline-none\",\r\n\t\t\t\"disabled:cursor-not-allowed disabled:opacity-50\",\r\n\t\t\t\"data-[state=checked]:bg-primary-accent data-[state=unchecked]:bg-secondary-border\",\r\n\t\t\t\"data-[state=checked]:hover:enabled:bg-primary-accent-hover\",\r\n\t\t\t\"data-[state=unchecked]:hover:enabled:bg-primary-border\"\r\n\t\t],\r\n\t\tthumb: \"rounded-full bg-secondary-bg shadow-soft-base transition-transform\"\r\n\t},\r\n\tvariants: {\r\n\t\tsize: {\r\n\t\t\txs: {\r\n\t\t\t\troot: \"h-4 w-7\",\r\n\t\t\t\tthumb: \"h-3 w-3 data-[state=checked]:translate-x-[14px] data-[state=unchecked]:translate-x-0.5\"\r\n\t\t\t},\r\n\t\t\tsm: {\r\n\t\t\t\troot: \"h-5 w-9\",\r\n\t\t\t\tthumb: \"h-4 w-4 data-[state=checked]:translate-x-[18px] data-[state=unchecked]:translate-x-0.5\"\r\n\t\t\t},\r\n\t\t\tmd: {\r\n\t\t\t\troot: \"h-6 w-11\",\r\n\t\t\t\tthumb: \"h-5 w-5 data-[state=checked]:translate-x-[22px] data-[state=unchecked]:translate-x-0.5\"\r\n\t\t\t}\r\n\t\t},\r\n\t\ttheme: {\r\n\t\t\tinverse: {\r\n\t\t\t\troot: [\r\n\t\t\t\t\t\"focus-visible:shadow-inverse-focus\",\r\n\t\t\t\t\t\"data-[state=unchecked]:bg-inverse-active data-[state=unchecked]:hover:enabled:bg-inverse-muted\",\r\n\t\t\t\t\t\"data-[state=checked]:bg-inverse-primary-fg data-[state=checked]:hover:enabled:bg-inverse-secondary-fg\"\r\n\t\t\t\t],\r\n\t\t\t\tthumb: \"bg-inverse-primary-bg\"\r\n\t\t\t}\r\n\t\t}\r\n\t} satisfies VariantsConfig<SwitchVariants>,\r\n\tdefaultVariants: {\r\n\t\tsize: \"md\"\r\n\t}\r\n});\r\n\r\nexport type SwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> & SwitchVariants;\r\n\r\nconst Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, SwitchProps>(\r\n\t({ className, size, ...props }, ref) => {\r\n\t\tconst { variant: theme } = useComponentVariant();\r\n\t\tconst { root, thumb } = switchStyles({ size, theme });\r\n\r\n\t\treturn (\r\n\t\t\t<SwitchPrimitives.Root className={root({ className })} {...props} ref={ref}>\r\n\t\t\t\t<SwitchPrimitives.Thumb className={thumb()} />\r\n\t\t\t</SwitchPrimitives.Root>\r\n\t\t);\r\n\t}\r\n);\r\nSwitch.displayName = SwitchPrimitives.Root.displayName;\r\n\r\nexport { Switch };\r\n","import * as SwitchPrimitives from \"@radix-ui/react-checkbox\";\r\nimport { tv } from \"tailwind-variants\";\r\nimport React, { useId } from \"react\";\r\nimport { FieldLabel } from \"@/components/label\";\r\nimport { Description } from \"@/components/description\";\r\nimport { Switch, SwitchProps } from \"../Switch\";\r\nimport { VariantsConfig } from \"@/lib/utils/variants\";\r\n\r\nexport interface SwitchFieldVariants {\r\n\toutline?: boolean;\r\n\talignment?: \"left\" | \"right\";\r\n\tdisabled?: boolean;\r\n\terror?: boolean;\r\n}\r\n\r\nconst switchFieldStyles = tv({\r\n\tslots: {\r\n\t\tcontainer: \"flex cursor-pointer items-center gap-3\",\r\n\t\ttextContainer: \"flex flex-col gap-1\",\r\n\t\tlabelWrapper: \"flex h-4 items-center\",\r\n\t\tlabel: \"cursor-pointer\"\r\n\t},\r\n\tvariants: {\r\n\t\toutline: {\r\n\t\t\ttrue: {\r\n\t\t\t\tcontainer: \"rounded-lg border border-secondary-border p-3 px-4\"\r\n\t\t\t}\r\n\t\t},\r\n\t\tdisabled: {\r\n\t\t\ttrue: {\r\n\t\t\t\tcontainer: \"cursor-default\",\r\n\t\t\t\ttextContainer: \"opacity-50\",\r\n\t\t\t\tlabel: \"cursor-default text-primary-fg\",\r\n\t\t\t\tdescription: \"text-muted\"\r\n\t\t\t}\r\n\t\t},\r\n\t\terror: {\r\n\t\t\ttrue: {\r\n\t\t\t\tlabel: \"text-status-error\"\r\n\t\t\t}\r\n\t\t},\r\n\t\talignment: {\r\n\t\t\tleft: {},\r\n\t\t\tright: {\r\n\t\t\t\tcontainer: \"flex-row-reverse space-x-reverse\"\r\n\t\t\t}\r\n\t\t},\r\n\t\twithDescription: { true: { container: \"items-start\" } }\r\n\t} satisfies VariantsConfig<SwitchFieldVariants & { withDescription?: boolean }>,\r\n\tdefaultVariants: {\r\n\t\talignment: \"left\"\r\n\t}\r\n});\r\n\r\ntype SwitchFieldProps = SwitchProps &\r\n\tSwitchFieldVariants & {\r\n\t\tlabel?: string | React.ReactNode;\r\n\t\tdescription?: string;\r\n\t};\r\n\r\nconst SwitchField = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, SwitchFieldProps>(\r\n\t({ className, id, label, alignment: alignment, error, disabled, outline, description, ...props }, ref) => {\r\n\t\tconst {\r\n\t\t\tcontainer,\r\n\t\t\ttextContainer,\r\n\t\t\tlabel: labelStyles,\r\n\t\t\tlabelWrapper\r\n\t\t} = switchFieldStyles({ alignment, error, disabled, outline, withDescription: !!description });\r\n\r\n\t\tconst generatedId = useId();\r\n\t\tconst switchId = id || `switch-${generatedId}`;\r\n\r\n\t\treturn (\r\n\t\t\t<label htmlFor={switchId} className={container({ class: className })}>\r\n\t\t\t\t<Switch disabled={disabled} id={switchId} {...props} ref={ref} />\r\n\t\t\t\t{(label || description) && (\r\n\t\t\t\t\t<div className={textContainer()}>\r\n\t\t\t\t\t\t{label && (\r\n\t\t\t\t\t\t\t<div className={labelWrapper()}>\r\n\t\t\t\t\t\t\t\t<FieldLabel htmlFor={switchId} className={labelStyles()}>\r\n\t\t\t\t\t\t\t\t\t{label}\r\n\t\t\t\t\t\t\t\t</FieldLabel>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t{description && <Description size=\"xs\">{description}</Description>}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t)}\r\n\t\t\t</label>\r\n\t\t);\r\n\t}\r\n);\r\n\r\nSwitchField.displayName = \"SwitchField\";\r\n\r\nexport { SwitchField };\r\n"],"names":["SWITCH_NAME","createSwitchContext","createSwitchScope","createContextScope","SwitchProvider","useSwitchContext","Switch","React","props","forwardedRef","__scopeSwitch","name","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","form","switchProps","button","setButton","composedRefs","useComposedRefs","node","hasConsumerStoppedPropagationRef","isFormControl","checked","setChecked","useControllableState","jsxs","jsx","Primitive","getState","composeEventHandlers","event","prevChecked","SwitchBubbleInput","THUMB_NAME","SwitchThumb","thumbProps","context","BUBBLE_INPUT_NAME","control","bubbles","ref","usePrevious","controlSize","useSize","input","inputProto","Root","Thumb","switchStyles","tv","className","size","theme","useComponentVariant","root","thumb","SwitchPrimitives.Root","SwitchPrimitives.Thumb","switchFieldStyles","SwitchField","id","label","alignment","error","outline","description","container","textContainer","labelStyles","labelWrapper","generatedId","useId","switchId","FieldLabel","Description"],"mappings":";;;;;;;;;;;;;AAYA,IAAIA,IAAc,UACd,CAACC,GAAqBC,EAAiB,IAAIC,EAAmBH,CAAW,GACzE,CAACI,GAAgBC,CAAgB,IAAIJ,EAAoBD,CAAW,GACpEM,IAASC,EAAM;AAAA,EACjB,CAACC,GAAOC,MAAiB;AACvB,UAAM;AAAA,MACJ,eAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAASC;AAAA,MACT,gBAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,iBAAAC;AAAA,MACA,MAAAC;AAAA,MACA,GAAGC;AAAA,IACT,IAAQX,GACE,CAACY,GAAQC,CAAS,IAAId,EAAM,SAAS,IAAI,GACzCe,IAAeC,EAAgBd,GAAc,CAACe,MAASH,EAAUG,CAAI,CAAC,GACtEC,IAAmClB,EAAM,OAAO,EAAK,GACrDmB,IAAgBN,IAASF,KAAQ,CAAC,CAACE,EAAO,QAAQ,MAAM,IAAI,IAC5D,CAACO,GAASC,CAAU,IAAIC,EAAqB;AAAA,MACjD,MAAMjB;AAAA,MACN,aAAaC,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AAC,OAAI,EAAA,WAAW0C,EACd,GAAA,UAAA;AAAA,QAAAN,KACC,gBAAAnC,EAAA,OAAA,EAAI,WAAW2C,EACf,GAAA,UAAA,gBAAA3C,EAAC+C,GAAW,EAAA,SAASD,GAAU,WAAWJ,EAAY,GACpD,YACF,CAAA,GACD;AAAA,QAEAH,KAAe,gBAAAvC,EAACgD,GAAY,EAAA,MAAK,MAAM,UAAYT,EAAA,CAAA;AAAA,MAAA,EACrD,CAAA;AAAA,IAAA,GAEF;AAAA,EAAA;AAGH;AAEAN,EAAY,cAAc;","x_google_ignoreList":[0]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type ClassNameValue = string | string[] | Record<string, string> | null | undefined | 0 | 0n | false;
|
|
1
|
+
type ClassNameValue = string | string[] | Record<string, string | string[]> | null | undefined | 0 | 0n | false;
|
|
2
2
|
/**
|
|
3
3
|
* Строгая типизация для объекта variants в tailwind-variants tv()
|
|
4
4
|
*
|