fina-react-ds 1.0.0 → 1.0.1
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/components/calendar.js +206 -0
- package/dist/components/date-picker.js +61 -0
- package/dist/components/separator.js +29 -0
- package/dist/components/sheet.js +17 -5
- package/dist/components/sidebar.js +620 -0
- package/dist/components/simple-tooltip.js +17 -0
- package/dist/components/skeleton.js +18 -0
- package/dist/components/sonner.js +24 -0
- package/dist/components/switch.js +34 -0
- package/dist/components/textarea.js +23 -0
- package/dist/components/tooltip.js +61 -0
- package/dist/hooks/use-mobile.js +17 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +140 -93
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +12 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +21 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchFn.js +36 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +18 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/formatDistance.js +72 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/formatLong.js +33 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/formatRelative.js +13 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/localize.js +123 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/match.js +112 -0
- package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr.js +21 -0
- package/dist/node_modules/@radix-ui/react-separator/dist/index.js +27 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +47 -40
- package/dist/node_modules/@radix-ui/react-switch/dist/index.js +136 -0
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +348 -0
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +32 -0
- package/package.json +1 -1
package/dist/node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/locale/fr/_lib/localize.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var o = Object.defineProperty;
|
|
2
|
+
var t = (n, e) => o(n, "name", { value: e, configurable: !0 });
|
|
3
|
+
import { buildLocalizeFn as r } from "../../_lib/buildLocalizeFn.js";
|
|
4
|
+
const u = {
|
|
5
|
+
narrow: ["av. J.-C", "ap. J.-C"],
|
|
6
|
+
abbreviated: ["av. J.-C", "ap. J.-C"],
|
|
7
|
+
wide: ["avant Jésus-Christ", "après Jésus-Christ"]
|
|
8
|
+
}, s = {
|
|
9
|
+
narrow: ["T1", "T2", "T3", "T4"],
|
|
10
|
+
abbreviated: ["1er trim.", "2ème trim.", "3ème trim.", "4ème trim."],
|
|
11
|
+
wide: ["1er trimestre", "2ème trimestre", "3ème trimestre", "4ème trimestre"]
|
|
12
|
+
}, l = {
|
|
13
|
+
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
|
|
14
|
+
abbreviated: [
|
|
15
|
+
"janv.",
|
|
16
|
+
"févr.",
|
|
17
|
+
"mars",
|
|
18
|
+
"avr.",
|
|
19
|
+
"mai",
|
|
20
|
+
"juin",
|
|
21
|
+
"juil.",
|
|
22
|
+
"août",
|
|
23
|
+
"sept.",
|
|
24
|
+
"oct.",
|
|
25
|
+
"nov.",
|
|
26
|
+
"déc."
|
|
27
|
+
],
|
|
28
|
+
wide: [
|
|
29
|
+
"janvier",
|
|
30
|
+
"février",
|
|
31
|
+
"mars",
|
|
32
|
+
"avril",
|
|
33
|
+
"mai",
|
|
34
|
+
"juin",
|
|
35
|
+
"juillet",
|
|
36
|
+
"août",
|
|
37
|
+
"septembre",
|
|
38
|
+
"octobre",
|
|
39
|
+
"novembre",
|
|
40
|
+
"décembre"
|
|
41
|
+
]
|
|
42
|
+
}, v = {
|
|
43
|
+
narrow: ["D", "L", "M", "M", "J", "V", "S"],
|
|
44
|
+
short: ["di", "lu", "ma", "me", "je", "ve", "sa"],
|
|
45
|
+
abbreviated: ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."],
|
|
46
|
+
wide: [
|
|
47
|
+
"dimanche",
|
|
48
|
+
"lundi",
|
|
49
|
+
"mardi",
|
|
50
|
+
"mercredi",
|
|
51
|
+
"jeudi",
|
|
52
|
+
"vendredi",
|
|
53
|
+
"samedi"
|
|
54
|
+
]
|
|
55
|
+
}, c = {
|
|
56
|
+
narrow: {
|
|
57
|
+
am: "AM",
|
|
58
|
+
pm: "PM",
|
|
59
|
+
midnight: "minuit",
|
|
60
|
+
noon: "midi",
|
|
61
|
+
morning: "mat.",
|
|
62
|
+
afternoon: "ap.m.",
|
|
63
|
+
evening: "soir",
|
|
64
|
+
night: "mat."
|
|
65
|
+
},
|
|
66
|
+
abbreviated: {
|
|
67
|
+
am: "AM",
|
|
68
|
+
pm: "PM",
|
|
69
|
+
midnight: "minuit",
|
|
70
|
+
noon: "midi",
|
|
71
|
+
morning: "matin",
|
|
72
|
+
afternoon: "après-midi",
|
|
73
|
+
evening: "soir",
|
|
74
|
+
night: "matin"
|
|
75
|
+
},
|
|
76
|
+
wide: {
|
|
77
|
+
am: "AM",
|
|
78
|
+
pm: "PM",
|
|
79
|
+
midnight: "minuit",
|
|
80
|
+
noon: "midi",
|
|
81
|
+
morning: "du matin",
|
|
82
|
+
afternoon: "de l’après-midi",
|
|
83
|
+
evening: "du soir",
|
|
84
|
+
night: "du matin"
|
|
85
|
+
}
|
|
86
|
+
}, h = /* @__PURE__ */ t((n, e) => {
|
|
87
|
+
const a = Number(n), i = e == null ? void 0 : e.unit;
|
|
88
|
+
if (a === 0) return "0";
|
|
89
|
+
const d = ["year", "week", "hour", "minute", "second"];
|
|
90
|
+
let m;
|
|
91
|
+
return a === 1 ? m = i && d.includes(i) ? "ère" : "er" : m = "ème", a + m;
|
|
92
|
+
}, "ordinalNumber"), M = ["MMM", "MMMM"], g = {
|
|
93
|
+
preprocessor: /* @__PURE__ */ t((n, e) => n.getDate() === 1 || !e.some(
|
|
94
|
+
(i) => i.isToken && M.includes(i.value)
|
|
95
|
+
) ? e : e.map(
|
|
96
|
+
(i) => i.isToken && i.value === "do" ? { isToken: !0, value: "d" } : i
|
|
97
|
+
), "preprocessor"),
|
|
98
|
+
ordinalNumber: h,
|
|
99
|
+
era: r({
|
|
100
|
+
values: u,
|
|
101
|
+
defaultWidth: "wide"
|
|
102
|
+
}),
|
|
103
|
+
quarter: r({
|
|
104
|
+
values: s,
|
|
105
|
+
defaultWidth: "wide",
|
|
106
|
+
argumentCallback: /* @__PURE__ */ t((n) => n - 1, "argumentCallback")
|
|
107
|
+
}),
|
|
108
|
+
month: r({
|
|
109
|
+
values: l,
|
|
110
|
+
defaultWidth: "wide"
|
|
111
|
+
}),
|
|
112
|
+
day: r({
|
|
113
|
+
values: v,
|
|
114
|
+
defaultWidth: "wide"
|
|
115
|
+
}),
|
|
116
|
+
dayPeriod: r({
|
|
117
|
+
values: c,
|
|
118
|
+
defaultWidth: "wide"
|
|
119
|
+
})
|
|
120
|
+
};
|
|
121
|
+
export {
|
|
122
|
+
g as localize
|
|
123
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var r = Object.defineProperty;
|
|
2
|
+
var t = (a, e) => r(a, "name", { value: e, configurable: !0 });
|
|
3
|
+
import { buildMatchFn as i } from "../../_lib/buildMatchFn.js";
|
|
4
|
+
import { buildMatchPatternFn as n } from "../../_lib/buildMatchPatternFn.js";
|
|
5
|
+
const s = /^(\d+)(ième|ère|ème|er|e)?/i, d = /\d+/i, m = {
|
|
6
|
+
narrow: /^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i,
|
|
7
|
+
abbreviated: /^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,
|
|
8
|
+
wide: /^(avant Jésus-Christ|après Jésus-Christ)/i
|
|
9
|
+
}, o = {
|
|
10
|
+
any: [/^av/i, /^ap/i]
|
|
11
|
+
}, c = {
|
|
12
|
+
narrow: /^T?[1234]/i,
|
|
13
|
+
abbreviated: /^[1234](er|ème|e)? trim\.?/i,
|
|
14
|
+
wide: /^[1234](er|ème|e)? trimestre/i
|
|
15
|
+
}, u = {
|
|
16
|
+
any: [/1/i, /2/i, /3/i, /4/i]
|
|
17
|
+
}, h = {
|
|
18
|
+
narrow: /^[jfmasond]/i,
|
|
19
|
+
abbreviated: /^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)\.?/i,
|
|
20
|
+
wide: /^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i
|
|
21
|
+
}, l = {
|
|
22
|
+
narrow: [
|
|
23
|
+
/^j/i,
|
|
24
|
+
/^f/i,
|
|
25
|
+
/^m/i,
|
|
26
|
+
/^a/i,
|
|
27
|
+
/^m/i,
|
|
28
|
+
/^j/i,
|
|
29
|
+
/^j/i,
|
|
30
|
+
/^a/i,
|
|
31
|
+
/^s/i,
|
|
32
|
+
/^o/i,
|
|
33
|
+
/^n/i,
|
|
34
|
+
/^d/i
|
|
35
|
+
],
|
|
36
|
+
any: [
|
|
37
|
+
/^ja/i,
|
|
38
|
+
/^f/i,
|
|
39
|
+
/^mar/i,
|
|
40
|
+
/^av/i,
|
|
41
|
+
/^ma/i,
|
|
42
|
+
/^juin/i,
|
|
43
|
+
/^juil/i,
|
|
44
|
+
/^ao/i,
|
|
45
|
+
/^s/i,
|
|
46
|
+
/^o/i,
|
|
47
|
+
/^n/i,
|
|
48
|
+
/^d/i
|
|
49
|
+
]
|
|
50
|
+
}, P = {
|
|
51
|
+
narrow: /^[lmjvsd]/i,
|
|
52
|
+
short: /^(di|lu|ma|me|je|ve|sa)/i,
|
|
53
|
+
abbreviated: /^(dim|lun|mar|mer|jeu|ven|sam)\.?/i,
|
|
54
|
+
wide: /^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i
|
|
55
|
+
}, p = {
|
|
56
|
+
narrow: [/^d/i, /^l/i, /^m/i, /^m/i, /^j/i, /^v/i, /^s/i],
|
|
57
|
+
any: [/^di/i, /^lu/i, /^ma/i, /^me/i, /^je/i, /^ve/i, /^sa/i]
|
|
58
|
+
}, v = {
|
|
59
|
+
narrow: /^(a|p|minuit|midi|mat\.?|ap\.?m\.?|soir|nuit)/i,
|
|
60
|
+
any: /^([ap]\.?\s?m\.?|du matin|de l'après[-\s]midi|du soir|de la nuit)/i
|
|
61
|
+
}, j = {
|
|
62
|
+
any: {
|
|
63
|
+
am: /^a/i,
|
|
64
|
+
pm: /^p/i,
|
|
65
|
+
midnight: /^min/i,
|
|
66
|
+
noon: /^mid/i,
|
|
67
|
+
morning: /mat/i,
|
|
68
|
+
afternoon: /ap/i,
|
|
69
|
+
evening: /soir/i,
|
|
70
|
+
night: /nuit/i
|
|
71
|
+
}
|
|
72
|
+
}, w = {
|
|
73
|
+
ordinalNumber: n({
|
|
74
|
+
matchPattern: s,
|
|
75
|
+
parsePattern: d,
|
|
76
|
+
valueCallback: /* @__PURE__ */ t((a) => parseInt(a), "valueCallback")
|
|
77
|
+
}),
|
|
78
|
+
era: i({
|
|
79
|
+
matchPatterns: m,
|
|
80
|
+
defaultMatchWidth: "wide",
|
|
81
|
+
parsePatterns: o,
|
|
82
|
+
defaultParseWidth: "any"
|
|
83
|
+
}),
|
|
84
|
+
quarter: i({
|
|
85
|
+
matchPatterns: c,
|
|
86
|
+
defaultMatchWidth: "wide",
|
|
87
|
+
parsePatterns: u,
|
|
88
|
+
defaultParseWidth: "any",
|
|
89
|
+
valueCallback: /* @__PURE__ */ t((a) => a + 1, "valueCallback")
|
|
90
|
+
}),
|
|
91
|
+
month: i({
|
|
92
|
+
matchPatterns: h,
|
|
93
|
+
defaultMatchWidth: "wide",
|
|
94
|
+
parsePatterns: l,
|
|
95
|
+
defaultParseWidth: "any"
|
|
96
|
+
}),
|
|
97
|
+
day: i({
|
|
98
|
+
matchPatterns: P,
|
|
99
|
+
defaultMatchWidth: "wide",
|
|
100
|
+
parsePatterns: p,
|
|
101
|
+
defaultParseWidth: "any"
|
|
102
|
+
}),
|
|
103
|
+
dayPeriod: i({
|
|
104
|
+
matchPatterns: v,
|
|
105
|
+
defaultMatchWidth: "any",
|
|
106
|
+
parsePatterns: j,
|
|
107
|
+
defaultParseWidth: "any"
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
export {
|
|
111
|
+
w as match
|
|
112
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { formatDistance as o } from "./fr/_lib/formatDistance.js";
|
|
2
|
+
import { formatLong as t } from "./fr/_lib/formatLong.js";
|
|
3
|
+
import { formatRelative as r } from "./fr/_lib/formatRelative.js";
|
|
4
|
+
import { localize as a } from "./fr/_lib/localize.js";
|
|
5
|
+
import { match as m } from "./fr/_lib/match.js";
|
|
6
|
+
const s = {
|
|
7
|
+
code: "fr",
|
|
8
|
+
formatDistance: o,
|
|
9
|
+
formatLong: t,
|
|
10
|
+
formatRelative: r,
|
|
11
|
+
localize: a,
|
|
12
|
+
match: m,
|
|
13
|
+
options: {
|
|
14
|
+
weekStartsOn: 1,
|
|
15
|
+
firstWeekContainsDate: 4
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
s as default,
|
|
20
|
+
s as fr
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var i = (r, o) => v(r, "name", { value: o, configurable: !0 });
|
|
3
|
+
import * as m from "react";
|
|
4
|
+
import { Primitive as d } from "../../react-primitive/dist/index.js";
|
|
5
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
6
|
+
var f = "Separator", n = "horizontal", O = ["horizontal", "vertical"], e = m.forwardRef((r, o) => {
|
|
7
|
+
const { decorative: s, orientation: a = n, ...c } = r, t = N(a) ? a : n, p = s ? { role: "none" } : { "aria-orientation": t === "vertical" ? t : void 0, role: "separator" };
|
|
8
|
+
return /* @__PURE__ */ l(
|
|
9
|
+
d.div,
|
|
10
|
+
{
|
|
11
|
+
"data-orientation": t,
|
|
12
|
+
...p,
|
|
13
|
+
...c,
|
|
14
|
+
ref: o
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
e.displayName = f;
|
|
19
|
+
function N(r) {
|
|
20
|
+
return O.includes(r);
|
|
21
|
+
}
|
|
22
|
+
i(N, "isValidOrientation");
|
|
23
|
+
var E = e;
|
|
24
|
+
export {
|
|
25
|
+
E as Root,
|
|
26
|
+
e as Separator
|
|
27
|
+
};
|
|
@@ -1,60 +1,67 @@
|
|
|
1
|
-
var
|
|
2
|
-
var a = (e,
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var a = (e, t) => S(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
import * as l from "react";
|
|
4
|
-
import { composeRefs as
|
|
5
|
-
import { jsx as
|
|
4
|
+
import { composeRefs as g } from "../../react-compose-refs/dist/index.js";
|
|
5
|
+
import { jsx as u, Fragment as E } from "react/jsx-runtime";
|
|
6
6
|
// @__NO_SIDE_EFFECTS__
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
const { children: i, ...c } = n, s = l.Children.toArray(i), f = s.find(
|
|
7
|
+
function C(e) {
|
|
8
|
+
const t = /* @__PURE__ */ R(e), o = l.forwardRef((n, r) => {
|
|
9
|
+
const { children: i, ...c } = n, s = l.Children.toArray(i), f = s.find(b);
|
|
10
10
|
if (f) {
|
|
11
|
-
const p = f.props.children,
|
|
12
|
-
return /* @__PURE__ */
|
|
11
|
+
const p = f.props.children, y = s.map((d) => d === f ? l.Children.count(p) > 1 ? l.Children.only(null) : l.isValidElement(p) ? p.props.children : null : d);
|
|
12
|
+
return /* @__PURE__ */ u(t, { ...c, ref: r, children: l.isValidElement(p) ? l.cloneElement(p, void 0, y) : null });
|
|
13
13
|
}
|
|
14
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ u(t, { ...c, ref: r, children: i });
|
|
15
15
|
});
|
|
16
16
|
return o.displayName = `${e}.Slot`, o;
|
|
17
17
|
}
|
|
18
|
-
a(
|
|
19
|
-
var
|
|
18
|
+
a(C, "createSlot");
|
|
19
|
+
var N = /* @__PURE__ */ C("Slot");
|
|
20
20
|
// @__NO_SIDE_EFFECTS__
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
const { children:
|
|
24
|
-
if (l.isValidElement(
|
|
25
|
-
const c =
|
|
26
|
-
return
|
|
21
|
+
function R(e) {
|
|
22
|
+
const t = l.forwardRef((o, n) => {
|
|
23
|
+
const { children: r, ...i } = o;
|
|
24
|
+
if (l.isValidElement(r)) {
|
|
25
|
+
const c = _(r), s = h(i, r.props);
|
|
26
|
+
return r.type !== l.Fragment && (s.ref = n ? g(n, c) : c), l.cloneElement(r, s);
|
|
27
27
|
}
|
|
28
|
-
return l.Children.count(
|
|
28
|
+
return l.Children.count(r) > 1 ? l.Children.only(null) : null;
|
|
29
29
|
});
|
|
30
|
-
return
|
|
30
|
+
return t.displayName = `${e}.SlotClone`, t;
|
|
31
31
|
}
|
|
32
|
-
a(
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
a(R, "createSlotClone");
|
|
33
|
+
var m = Symbol("radix.slottable");
|
|
34
|
+
// @__NO_SIDE_EFFECTS__
|
|
35
|
+
function O(e) {
|
|
36
|
+
const t = /* @__PURE__ */ a(({ children: o }) => /* @__PURE__ */ u(E, { children: o }), "Slottable2");
|
|
37
|
+
return t.displayName = `${e}.Slottable`, t.__radixId = m, t;
|
|
36
38
|
}
|
|
37
|
-
a(
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
a(O, "createSlottable");
|
|
40
|
+
function b(e) {
|
|
41
|
+
return l.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === m;
|
|
42
|
+
}
|
|
43
|
+
a(b, "isSlottable");
|
|
44
|
+
function h(e, t) {
|
|
45
|
+
const o = { ...t };
|
|
46
|
+
for (const n in t) {
|
|
47
|
+
const r = e[n], i = t[n];
|
|
48
|
+
/^on[A-Z]/.test(n) ? r && i ? o[n] = (...s) => {
|
|
43
49
|
const f = i(...s);
|
|
44
|
-
return
|
|
45
|
-
} :
|
|
50
|
+
return r(...s), f;
|
|
51
|
+
} : r && (o[n] = r) : n === "style" ? o[n] = { ...r, ...i } : n === "className" && (o[n] = [r, i].filter(Boolean).join(" "));
|
|
46
52
|
}
|
|
47
53
|
return { ...e, ...o };
|
|
48
54
|
}
|
|
49
55
|
a(h, "mergeProps");
|
|
50
|
-
function
|
|
51
|
-
var n,
|
|
52
|
-
let
|
|
53
|
-
return o ? e.ref : (
|
|
56
|
+
function _(e) {
|
|
57
|
+
var n, r;
|
|
58
|
+
let t = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = t && "isReactWarning" in t && t.isReactWarning;
|
|
59
|
+
return o ? e.ref : (t = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
|
|
54
60
|
}
|
|
55
|
-
a(
|
|
61
|
+
a(_, "getElementRef");
|
|
56
62
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
N as Root,
|
|
64
|
+
N as Slot,
|
|
65
|
+
C as createSlot,
|
|
66
|
+
O as createSlottable
|
|
60
67
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var P = (e, o) => I(e, "name", { value: o, configurable: !0 });
|
|
3
|
+
import * as c from "react";
|
|
4
|
+
import { composeEventHandlers as M } from "../../primitive/dist/index.js";
|
|
5
|
+
import { useComposedRefs as y } from "../../react-compose-refs/dist/index.js";
|
|
6
|
+
import { createContextScope as H } from "../../react-context/dist/index.js";
|
|
7
|
+
import { useControllableState as j } from "../../react-use-controllable-state/dist/index.js";
|
|
8
|
+
import { usePrevious as A } from "../../react-use-previous/dist/index.js";
|
|
9
|
+
import { useSize as U } from "../../react-use-size/dist/index.js";
|
|
10
|
+
import { Primitive as R } from "../../react-primitive/dist/index.js";
|
|
11
|
+
import { jsxs as q, jsx as m } from "react/jsx-runtime";
|
|
12
|
+
var h = "Switch", [z, Z] = H(h), [L, O] = z(h), E = c.forwardRef(
|
|
13
|
+
(e, o) => {
|
|
14
|
+
const {
|
|
15
|
+
__scopeSwitch: t,
|
|
16
|
+
name: n,
|
|
17
|
+
checked: r,
|
|
18
|
+
defaultChecked: S,
|
|
19
|
+
required: i,
|
|
20
|
+
disabled: s,
|
|
21
|
+
value: p = "on",
|
|
22
|
+
onCheckedChange: w,
|
|
23
|
+
form: a,
|
|
24
|
+
...v
|
|
25
|
+
} = e, [d, u] = c.useState(null), b = y(o, (f) => u(f)), C = c.useRef(!1), k = d ? a || !!d.closest("form") : !0, [l, N] = j({
|
|
26
|
+
prop: r,
|
|
27
|
+
defaultProp: S ?? !1,
|
|
28
|
+
onChange: w,
|
|
29
|
+
caller: h
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ q(L, { scope: t, checked: l, disabled: s, children: [
|
|
32
|
+
/* @__PURE__ */ m(
|
|
33
|
+
R.button,
|
|
34
|
+
{
|
|
35
|
+
type: "button",
|
|
36
|
+
role: "switch",
|
|
37
|
+
"aria-checked": l,
|
|
38
|
+
"aria-required": i,
|
|
39
|
+
"data-state": B(l),
|
|
40
|
+
"data-disabled": s ? "" : void 0,
|
|
41
|
+
disabled: s,
|
|
42
|
+
value: p,
|
|
43
|
+
...v,
|
|
44
|
+
ref: b,
|
|
45
|
+
onClick: M(e.onClick, (f) => {
|
|
46
|
+
N((T) => !T), k && (C.current = f.isPropagationStopped(), C.current || f.stopPropagation());
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
k && /* @__PURE__ */ m(
|
|
51
|
+
g,
|
|
52
|
+
{
|
|
53
|
+
control: d,
|
|
54
|
+
bubbles: !C.current,
|
|
55
|
+
name: n,
|
|
56
|
+
value: p,
|
|
57
|
+
checked: l,
|
|
58
|
+
required: i,
|
|
59
|
+
disabled: s,
|
|
60
|
+
form: a,
|
|
61
|
+
style: { transform: "translateX(-100%)" }
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
E.displayName = h;
|
|
68
|
+
var _ = "SwitchThumb", x = c.forwardRef(
|
|
69
|
+
(e, o) => {
|
|
70
|
+
const { __scopeSwitch: t, ...n } = e, r = O(_, t);
|
|
71
|
+
return /* @__PURE__ */ m(
|
|
72
|
+
R.span,
|
|
73
|
+
{
|
|
74
|
+
"data-state": B(r.checked),
|
|
75
|
+
"data-disabled": r.disabled ? "" : void 0,
|
|
76
|
+
...n,
|
|
77
|
+
ref: o
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
x.displayName = _;
|
|
83
|
+
var D = "SwitchBubbleInput", g = c.forwardRef(
|
|
84
|
+
({
|
|
85
|
+
__scopeSwitch: e,
|
|
86
|
+
control: o,
|
|
87
|
+
checked: t,
|
|
88
|
+
bubbles: n = !0,
|
|
89
|
+
...r
|
|
90
|
+
}, S) => {
|
|
91
|
+
const i = c.useRef(null), s = y(i, S), p = A(t), w = U(o);
|
|
92
|
+
return c.useEffect(() => {
|
|
93
|
+
const a = i.current;
|
|
94
|
+
if (!a) return;
|
|
95
|
+
const v = window.HTMLInputElement.prototype, u = Object.getOwnPropertyDescriptor(
|
|
96
|
+
v,
|
|
97
|
+
"checked"
|
|
98
|
+
).set;
|
|
99
|
+
if (p !== t && u) {
|
|
100
|
+
const b = new Event("click", { bubbles: n });
|
|
101
|
+
u.call(a, t), a.dispatchEvent(b);
|
|
102
|
+
}
|
|
103
|
+
}, [p, t, n]), /* @__PURE__ */ m(
|
|
104
|
+
"input",
|
|
105
|
+
{
|
|
106
|
+
type: "checkbox",
|
|
107
|
+
"aria-hidden": !0,
|
|
108
|
+
defaultChecked: t,
|
|
109
|
+
...r,
|
|
110
|
+
tabIndex: -1,
|
|
111
|
+
ref: s,
|
|
112
|
+
style: {
|
|
113
|
+
...r.style,
|
|
114
|
+
...w,
|
|
115
|
+
position: "absolute",
|
|
116
|
+
pointerEvents: "none",
|
|
117
|
+
opacity: 0,
|
|
118
|
+
margin: 0
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
g.displayName = D;
|
|
125
|
+
function B(e) {
|
|
126
|
+
return e ? "checked" : "unchecked";
|
|
127
|
+
}
|
|
128
|
+
P(B, "getState");
|
|
129
|
+
var $ = E, ee = x;
|
|
130
|
+
export {
|
|
131
|
+
$ as Root,
|
|
132
|
+
E as Switch,
|
|
133
|
+
x as SwitchThumb,
|
|
134
|
+
ee as Thumb,
|
|
135
|
+
Z as createSwitchScope
|
|
136
|
+
};
|