@pismo/marola 0.0.1-alpha.8 → 0.0.1-alpha.9
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.
|
@@ -2,11 +2,10 @@ import { InputHTMLAttributes } from 'react';
|
|
|
2
2
|
|
|
3
3
|
type ToggleProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
4
4
|
label?: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
'data-testid'?: string;
|
|
7
5
|
classNameWrapper?: string;
|
|
8
6
|
classNameInput?: string;
|
|
9
7
|
classNameLabel?: string;
|
|
8
|
+
'data-testid'?: string;
|
|
10
9
|
};
|
|
11
|
-
export declare const Toggle: ({
|
|
10
|
+
export declare const Toggle: ({ label, checked, disabled, classNameWrapper, classNameInput, "data-testid": dataTestId, onChange, classNameLabel, }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export {};
|
|
@@ -1,131 +1,131 @@
|
|
|
1
1
|
import '../../assets/Toggle.css';
|
|
2
|
-
import { jsxs as I, jsx as
|
|
3
|
-
import { c as
|
|
4
|
-
import { a as
|
|
5
|
-
import * as
|
|
6
|
-
import { u as U, g as q, a as H, b as
|
|
2
|
+
import { jsxs as I, jsx as T } from "react/jsx-runtime";
|
|
3
|
+
import { c as F } from "../../clsx-DB4S2d7J.js";
|
|
4
|
+
import { a as y, _ as v } from "../../objectWithoutPropertiesLoose-D7Cp0Pg_.js";
|
|
5
|
+
import * as V from "react";
|
|
6
|
+
import { u as U, g as q, a as H, b as N, P as e, c as M, d as A } from "../../index-CqjC7P5Y.js";
|
|
7
7
|
import { u as D } from "../../useControlled-CCMYYdCM.js";
|
|
8
8
|
import { u as L } from "../../useIsFocusVisible-BH4IAdcw.js";
|
|
9
|
-
function W(
|
|
9
|
+
function W(l) {
|
|
10
10
|
const {
|
|
11
|
-
checked:
|
|
12
|
-
defaultChecked:
|
|
13
|
-
disabled:
|
|
11
|
+
checked: s,
|
|
12
|
+
defaultChecked: p,
|
|
13
|
+
disabled: c,
|
|
14
14
|
onBlur: a,
|
|
15
|
-
onChange:
|
|
16
|
-
onFocus:
|
|
17
|
-
onFocusVisible:
|
|
18
|
-
readOnly:
|
|
19
|
-
required:
|
|
20
|
-
} =
|
|
21
|
-
controlled:
|
|
22
|
-
default: !!
|
|
15
|
+
onChange: g,
|
|
16
|
+
onFocus: r,
|
|
17
|
+
onFocusVisible: u,
|
|
18
|
+
readOnly: n,
|
|
19
|
+
required: i
|
|
20
|
+
} = l, [S, x] = D({
|
|
21
|
+
controlled: s,
|
|
22
|
+
default: !!p,
|
|
23
23
|
name: "Switch",
|
|
24
24
|
state: "checked"
|
|
25
|
-
}), B = (t) => (
|
|
26
|
-
var
|
|
27
|
-
|
|
25
|
+
}), B = (t) => (o) => {
|
|
26
|
+
var b;
|
|
27
|
+
o.nativeEvent.defaultPrevented || (x(o.target.checked), g == null || g(o), (b = t.onChange) == null || b.call(t, o));
|
|
28
28
|
}, {
|
|
29
|
-
isFocusVisibleRef:
|
|
29
|
+
isFocusVisibleRef: _,
|
|
30
30
|
onBlur: w,
|
|
31
|
-
onFocus:
|
|
32
|
-
ref:
|
|
33
|
-
} = L(), [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
const
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
var
|
|
42
|
-
w(
|
|
43
|
-
},
|
|
31
|
+
onFocus: f,
|
|
32
|
+
ref: m
|
|
33
|
+
} = L(), [h, P] = V.useState(!1);
|
|
34
|
+
c && h && P(!1), V.useEffect(() => {
|
|
35
|
+
_.current = h;
|
|
36
|
+
}, [h, _]);
|
|
37
|
+
const k = V.useRef(null), R = (t) => (o) => {
|
|
38
|
+
var b;
|
|
39
|
+
k.current || (k.current = o.currentTarget), f(o), _.current === !0 && (P(!0), u == null || u(o)), r == null || r(o), (b = t.onFocus) == null || b.call(t, o);
|
|
40
|
+
}, O = (t) => (o) => {
|
|
41
|
+
var b;
|
|
42
|
+
w(o), _.current === !1 && P(!1), a == null || a(o), (b = t.onBlur) == null || b.call(t, o);
|
|
43
|
+
}, C = U(m, k);
|
|
44
44
|
return {
|
|
45
45
|
checked: S,
|
|
46
|
-
disabled: !!
|
|
47
|
-
focusVisible:
|
|
48
|
-
getInputProps: (t = {}) =>
|
|
49
|
-
checked:
|
|
50
|
-
defaultChecked:
|
|
51
|
-
disabled:
|
|
52
|
-
readOnly:
|
|
53
|
-
ref:
|
|
54
|
-
required:
|
|
46
|
+
disabled: !!c,
|
|
47
|
+
focusVisible: h,
|
|
48
|
+
getInputProps: (t = {}) => y({
|
|
49
|
+
checked: s,
|
|
50
|
+
defaultChecked: p,
|
|
51
|
+
disabled: c,
|
|
52
|
+
readOnly: n,
|
|
53
|
+
ref: C,
|
|
54
|
+
required: i,
|
|
55
55
|
type: "checkbox",
|
|
56
56
|
role: "switch",
|
|
57
|
-
"aria-checked":
|
|
57
|
+
"aria-checked": s
|
|
58
58
|
}, t, {
|
|
59
59
|
onChange: B(t),
|
|
60
60
|
onFocus: R(t),
|
|
61
|
-
onBlur:
|
|
61
|
+
onBlur: O(t)
|
|
62
62
|
}),
|
|
63
|
-
inputRef:
|
|
64
|
-
readOnly: !!
|
|
63
|
+
inputRef: C,
|
|
64
|
+
readOnly: !!n
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
const $ = "Switch";
|
|
68
|
-
function z(
|
|
69
|
-
return q($,
|
|
68
|
+
function z(l) {
|
|
69
|
+
return q($, l);
|
|
70
70
|
}
|
|
71
71
|
H($, ["root", "input", "track", "thumb", "checked", "disabled", "focusVisible", "readOnly"]);
|
|
72
|
-
const G = ["checked", "defaultChecked", "disabled", "onBlur", "onChange", "onFocus", "onFocusVisible", "readOnly", "required", "slotProps", "slots"], J = (
|
|
72
|
+
const G = ["checked", "defaultChecked", "disabled", "onBlur", "onChange", "onFocus", "onFocusVisible", "readOnly", "required", "slotProps", "slots"], J = (l) => {
|
|
73
73
|
const {
|
|
74
|
-
checked:
|
|
75
|
-
disabled:
|
|
76
|
-
focusVisible:
|
|
74
|
+
checked: s,
|
|
75
|
+
disabled: p,
|
|
76
|
+
focusVisible: c,
|
|
77
77
|
readOnly: a
|
|
78
|
-
} =
|
|
78
|
+
} = l;
|
|
79
79
|
return M({
|
|
80
|
-
root: ["root",
|
|
80
|
+
root: ["root", s && "checked", p && "disabled", c && "focusVisible", a && "readOnly"],
|
|
81
81
|
thumb: ["thumb"],
|
|
82
82
|
input: ["input"],
|
|
83
83
|
track: ["track"]
|
|
84
84
|
}, A(z));
|
|
85
|
-
}, E = /* @__PURE__ */
|
|
86
|
-
var
|
|
85
|
+
}, E = /* @__PURE__ */ V.forwardRef(function(s, p) {
|
|
86
|
+
var c, a, g, r;
|
|
87
87
|
const {
|
|
88
|
-
slotProps:
|
|
89
|
-
slots:
|
|
90
|
-
} =
|
|
88
|
+
slotProps: u = {},
|
|
89
|
+
slots: n = {}
|
|
90
|
+
} = s, i = v(s, G), {
|
|
91
91
|
getInputProps: S,
|
|
92
92
|
checked: x,
|
|
93
93
|
disabled: B,
|
|
94
|
-
focusVisible:
|
|
94
|
+
focusVisible: _,
|
|
95
95
|
readOnly: w
|
|
96
|
-
} = W(
|
|
96
|
+
} = W(s), f = y({}, s, {
|
|
97
97
|
checked: x,
|
|
98
98
|
disabled: B,
|
|
99
|
-
focusVisible:
|
|
99
|
+
focusVisible: _,
|
|
100
100
|
readOnly: w
|
|
101
|
-
}),
|
|
102
|
-
elementType:
|
|
103
|
-
externalSlotProps:
|
|
104
|
-
externalForwardedProps:
|
|
101
|
+
}), m = J(f), h = (c = n.root) != null ? c : "span", P = N({
|
|
102
|
+
elementType: h,
|
|
103
|
+
externalSlotProps: u.root,
|
|
104
|
+
externalForwardedProps: i,
|
|
105
105
|
additionalProps: {
|
|
106
|
-
ref:
|
|
106
|
+
ref: p
|
|
107
107
|
},
|
|
108
|
-
ownerState:
|
|
109
|
-
className:
|
|
110
|
-
}),
|
|
111
|
-
elementType:
|
|
112
|
-
externalSlotProps:
|
|
113
|
-
ownerState:
|
|
114
|
-
className:
|
|
115
|
-
}),
|
|
116
|
-
elementType:
|
|
108
|
+
ownerState: f,
|
|
109
|
+
className: m.root
|
|
110
|
+
}), k = (a = n.thumb) != null ? a : "span", R = N({
|
|
111
|
+
elementType: k,
|
|
112
|
+
externalSlotProps: u.thumb,
|
|
113
|
+
ownerState: f,
|
|
114
|
+
className: m.thumb
|
|
115
|
+
}), O = (g = n.input) != null ? g : "input", C = N({
|
|
116
|
+
elementType: O,
|
|
117
117
|
getSlotProps: S,
|
|
118
|
-
externalSlotProps:
|
|
119
|
-
ownerState:
|
|
120
|
-
className:
|
|
121
|
-
}), j =
|
|
118
|
+
externalSlotProps: u.input,
|
|
119
|
+
ownerState: f,
|
|
120
|
+
className: m.input
|
|
121
|
+
}), j = n.track === null ? () => null : (r = n.track) != null ? r : "span", t = N({
|
|
122
122
|
elementType: j,
|
|
123
|
-
externalSlotProps:
|
|
124
|
-
ownerState:
|
|
125
|
-
className:
|
|
123
|
+
externalSlotProps: u.track,
|
|
124
|
+
ownerState: f,
|
|
125
|
+
className: m.track
|
|
126
126
|
});
|
|
127
|
-
return /* @__PURE__ */ I(
|
|
128
|
-
children: [/* @__PURE__ */
|
|
127
|
+
return /* @__PURE__ */ I(h, y({}, P, {
|
|
128
|
+
children: [/* @__PURE__ */ T(j, y({}, t)), /* @__PURE__ */ T(k, y({}, R)), /* @__PURE__ */ T(O, y({}, C))]
|
|
129
129
|
}));
|
|
130
130
|
});
|
|
131
131
|
process.env.NODE_ENV !== "production" && (E.propTypes = {
|
|
@@ -199,7 +199,7 @@ process.env.NODE_ENV !== "production" && (E.propTypes = {
|
|
|
199
199
|
track: e.oneOfType([e.elementType, e.oneOf([null])])
|
|
200
200
|
})
|
|
201
201
|
});
|
|
202
|
-
const K = "_toggle_11c3l_1", Q = "_input_11c3l_12", X = "_thumb_11c3l_23", Y = "_track_11c3l_37", Z = "_toggle__label_11c3l_61",
|
|
202
|
+
const K = "_toggle_11c3l_1", Q = "_input_11c3l_12", X = "_thumb_11c3l_23", Y = "_track_11c3l_37", Z = "_toggle__label_11c3l_61", d = {
|
|
203
203
|
toggle: K,
|
|
204
204
|
"toggle__toggle-el-wrapper": "_toggle__toggle-el-wrapper_11c3l_8",
|
|
205
205
|
input: Q,
|
|
@@ -210,40 +210,41 @@ const K = "_toggle_11c3l_1", Q = "_input_11c3l_12", X = "_thumb_11c3l_23", Y = "
|
|
|
210
210
|
toggle__label: Z,
|
|
211
211
|
"toggle--disabled": "_toggle--disabled_11c3l_66"
|
|
212
212
|
}, ne = ({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
disabled:
|
|
216
|
-
classNameWrapper:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
label: l,
|
|
214
|
+
checked: s,
|
|
215
|
+
disabled: p,
|
|
216
|
+
classNameWrapper: c,
|
|
217
|
+
classNameInput: a,
|
|
218
|
+
"data-testid": g,
|
|
219
|
+
onChange: r,
|
|
220
|
+
classNameLabel: u
|
|
220
221
|
}) => {
|
|
221
|
-
const
|
|
222
|
-
|
|
222
|
+
const n = (i) => {
|
|
223
|
+
r == null || r(i);
|
|
223
224
|
};
|
|
224
|
-
return /* @__PURE__ */ I("div", { className:
|
|
225
|
-
/* @__PURE__ */
|
|
225
|
+
return /* @__PURE__ */ I("div", { className: F(d.toggle, c), "data-testid": g, children: [
|
|
226
|
+
/* @__PURE__ */ T(
|
|
226
227
|
E,
|
|
227
228
|
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"aria-label":
|
|
229
|
+
checked: s === !0,
|
|
230
|
+
disabled: p,
|
|
231
|
+
onChange: n,
|
|
232
|
+
"aria-label": l,
|
|
232
233
|
slotProps: {
|
|
233
|
-
root: (
|
|
234
|
-
className:
|
|
235
|
-
[
|
|
236
|
-
[
|
|
237
|
-
[
|
|
234
|
+
root: (i) => ({
|
|
235
|
+
className: F(d["toggle__toggle-el-wrapper"], {
|
|
236
|
+
[d["toggle--disabled"]]: i.disabled,
|
|
237
|
+
[d["toggle--focus-visible"]]: i.focusVisible,
|
|
238
|
+
[d["toggle--checked"]]: i.checked
|
|
238
239
|
})
|
|
239
240
|
}),
|
|
240
|
-
input: { className:
|
|
241
|
-
thumb: { className:
|
|
242
|
-
track: { className:
|
|
241
|
+
input: { className: F(d.input, a) },
|
|
242
|
+
thumb: { className: d.thumb },
|
|
243
|
+
track: { className: d.track }
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
246
|
),
|
|
246
|
-
|
|
247
|
+
l && /* @__PURE__ */ T("label", { className: F(d.toggle__label, u), children: l })
|
|
247
248
|
] });
|
|
248
249
|
};
|
|
249
250
|
export {
|
|
@@ -2,13 +2,12 @@ import { StoryObj } from '@storybook/react';
|
|
|
2
2
|
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({
|
|
5
|
+
component: ({ label, checked, disabled, classNameWrapper, classNameInput, "data-testid": dataTestId, onChange, classNameLabel, }: import('react').InputHTMLAttributes<HTMLInputElement> & {
|
|
6
6
|
label?: string | undefined;
|
|
7
|
-
disabled?: boolean | undefined;
|
|
8
|
-
'data-testid'?: string | undefined;
|
|
9
7
|
classNameWrapper?: string | undefined;
|
|
10
8
|
classNameInput?: string | undefined;
|
|
11
9
|
classNameLabel?: string | undefined;
|
|
10
|
+
'data-testid'?: string | undefined;
|
|
12
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
tags: string[];
|
|
14
13
|
parameters: {
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r } from "react";
|
|
3
|
+
import { Toggle as c } from "./Toggle.js";
|
|
4
|
+
const l = {
|
|
3
5
|
title: "Components/Toggle",
|
|
4
|
-
component:
|
|
6
|
+
component: c,
|
|
5
7
|
tags: ["autodocs"],
|
|
6
8
|
parameters: {
|
|
7
9
|
layout: "padded"
|
|
8
10
|
}
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}, h = {
|
|
12
|
+
render: () => {
|
|
13
|
+
const [e, t] = r(!1);
|
|
14
|
+
return /* @__PURE__ */ o(c, { checked: e, onChange: (a) => t(a.target.checked) });
|
|
15
|
+
}
|
|
16
|
+
}, m = {
|
|
12
17
|
name: "With label",
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
render: () => {
|
|
19
|
+
const [e, t] = r(!1);
|
|
20
|
+
return /* @__PURE__ */ o(c, { label: "Active", checked: e, onChange: (a) => t(a.target.checked) });
|
|
15
21
|
}
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
disabled: !0
|
|
22
|
+
}, g = {
|
|
23
|
+
render: () => {
|
|
24
|
+
const [e, t] = r(!1);
|
|
25
|
+
return /* @__PURE__ */ o(c, { label: "Active", disabled: !0, checked: e, onChange: (a) => t(a.target.checked) });
|
|
20
26
|
}
|
|
21
27
|
};
|
|
22
28
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
g as Disabled,
|
|
30
|
+
h as Simple,
|
|
31
|
+
m as WithLabel,
|
|
32
|
+
l as default
|
|
27
33
|
};
|