@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: ({ onChange, label, disabled, classNameWrapper, "data-testid": dataTestId, classNameInput, classNameLabel, }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
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 P } from "react/jsx-runtime";
3
- import { c as O } from "../../clsx-DB4S2d7J.js";
4
- import { a as k, _ as v } from "../../objectWithoutPropertiesLoose-D7Cp0Pg_.js";
5
- import * as N from "react";
6
- import { u as U, g as q, a as H, b as C, P as e, c as M, d as A } from "../../index-CqjC7P5Y.js";
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(c) {
9
+ function W(l) {
10
10
  const {
11
- checked: o,
12
- defaultChecked: i,
13
- disabled: n,
11
+ checked: s,
12
+ defaultChecked: p,
13
+ disabled: c,
14
14
  onBlur: a,
15
- onChange: d,
16
- onFocus: g,
17
- onFocusVisible: r,
18
- readOnly: s,
19
- required: V
20
- } = c, [S, x] = D({
21
- controlled: o,
22
- default: !!i,
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) => (l) => {
26
- var p;
27
- l.nativeEvent.defaultPrevented || (x(l.target.checked), d == null || d(l), (p = t.onChange) == null || p.call(t, l));
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: h,
29
+ isFocusVisibleRef: _,
30
30
  onBlur: w,
31
- onFocus: b,
32
- ref: _
33
- } = L(), [f, y] = N.useState(!1);
34
- n && f && y(!1), N.useEffect(() => {
35
- h.current = f;
36
- }, [f, h]);
37
- const m = N.useRef(null), R = (t) => (l) => {
38
- var p;
39
- m.current || (m.current = l.currentTarget), b(l), h.current === !0 && (y(!0), r == null || r(l)), g == null || g(l), (p = t.onFocus) == null || p.call(t, l);
40
- }, T = (t) => (l) => {
41
- var p;
42
- w(l), h.current === !1 && y(!1), a == null || a(l), (p = t.onBlur) == null || p.call(t, l);
43
- }, F = U(_, m);
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: !!n,
47
- focusVisible: f,
48
- getInputProps: (t = {}) => k({
49
- checked: o,
50
- defaultChecked: i,
51
- disabled: n,
52
- readOnly: s,
53
- ref: F,
54
- required: V,
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": o
57
+ "aria-checked": s
58
58
  }, t, {
59
59
  onChange: B(t),
60
60
  onFocus: R(t),
61
- onBlur: T(t)
61
+ onBlur: O(t)
62
62
  }),
63
- inputRef: F,
64
- readOnly: !!s
63
+ inputRef: C,
64
+ readOnly: !!n
65
65
  };
66
66
  }
67
67
  const $ = "Switch";
68
- function z(c) {
69
- return q($, c);
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 = (c) => {
72
+ const G = ["checked", "defaultChecked", "disabled", "onBlur", "onChange", "onFocus", "onFocusVisible", "readOnly", "required", "slotProps", "slots"], J = (l) => {
73
73
  const {
74
- checked: o,
75
- disabled: i,
76
- focusVisible: n,
74
+ checked: s,
75
+ disabled: p,
76
+ focusVisible: c,
77
77
  readOnly: a
78
- } = c;
78
+ } = l;
79
79
  return M({
80
- root: ["root", o && "checked", i && "disabled", n && "focusVisible", a && "readOnly"],
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__ */ N.forwardRef(function(o, i) {
86
- var n, a, d, g;
85
+ }, E = /* @__PURE__ */ V.forwardRef(function(s, p) {
86
+ var c, a, g, r;
87
87
  const {
88
- slotProps: r = {},
89
- slots: s = {}
90
- } = o, V = v(o, G), {
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: h,
94
+ focusVisible: _,
95
95
  readOnly: w
96
- } = W(o), b = k({}, o, {
96
+ } = W(s), f = y({}, s, {
97
97
  checked: x,
98
98
  disabled: B,
99
- focusVisible: h,
99
+ focusVisible: _,
100
100
  readOnly: w
101
- }), _ = J(b), f = (n = s.root) != null ? n : "span", y = C({
102
- elementType: f,
103
- externalSlotProps: r.root,
104
- externalForwardedProps: V,
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: i
106
+ ref: p
107
107
  },
108
- ownerState: b,
109
- className: _.root
110
- }), m = (a = s.thumb) != null ? a : "span", R = C({
111
- elementType: m,
112
- externalSlotProps: r.thumb,
113
- ownerState: b,
114
- className: _.thumb
115
- }), T = (d = s.input) != null ? d : "input", F = C({
116
- elementType: T,
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: r.input,
119
- ownerState: b,
120
- className: _.input
121
- }), j = s.track === null ? () => null : (g = s.track) != null ? g : "span", t = C({
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: r.track,
124
- ownerState: b,
125
- className: _.track
123
+ externalSlotProps: u.track,
124
+ ownerState: f,
125
+ className: m.track
126
126
  });
127
- return /* @__PURE__ */ I(f, k({}, y, {
128
- children: [/* @__PURE__ */ P(j, k({}, t)), /* @__PURE__ */ P(m, k({}, R)), /* @__PURE__ */ P(T, k({}, F))]
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", u = {
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
- onChange: c,
214
- label: o,
215
- disabled: i,
216
- classNameWrapper: n,
217
- "data-testid": a,
218
- classNameInput: d,
219
- classNameLabel: g
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 r = (s) => {
222
- c == null || c(s);
222
+ const n = (i) => {
223
+ r == null || r(i);
223
224
  };
224
- return /* @__PURE__ */ I("div", { className: O(u.toggle, n), "data-testid": a, children: [
225
- /* @__PURE__ */ P(
225
+ return /* @__PURE__ */ I("div", { className: F(d.toggle, c), "data-testid": g, children: [
226
+ /* @__PURE__ */ T(
226
227
  E,
227
228
  {
228
- disabled: i,
229
- onChange: r,
230
- autoFocus: !0,
231
- "aria-label": o,
229
+ checked: s === !0,
230
+ disabled: p,
231
+ onChange: n,
232
+ "aria-label": l,
232
233
  slotProps: {
233
- root: (s) => ({
234
- className: O(u["toggle__toggle-el-wrapper"], {
235
- [u["toggle--disabled"]]: s.disabled,
236
- [u["toggle--focus-visible"]]: s.focusVisible,
237
- [u["toggle--checked"]]: s.checked
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: O(u.input, d) },
241
- thumb: { className: u.thumb },
242
- track: { className: u.track }
241
+ input: { className: F(d.input, a) },
242
+ thumb: { className: d.thumb },
243
+ track: { className: d.track }
243
244
  }
244
245
  }
245
246
  ),
246
- o && /* @__PURE__ */ P("label", { className: O(u.toggle__label, g), children: o })
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: ({ onChange, label, disabled, classNameWrapper, "data-testid": dataTestId, classNameInput, classNameLabel, }: import('react').InputHTMLAttributes<HTMLInputElement> & {
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 { Toggle as e } from "./Toggle.js";
2
- const a = {
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: e,
6
+ component: c,
5
7
  tags: ["autodocs"],
6
8
  parameters: {
7
9
  layout: "padded"
8
10
  }
9
- }, o = {
10
- args: {}
11
- }, l = {
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
- args: {
14
- label: "Active"
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
- }, s = {
17
- args: {
18
- label: "Active",
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
- s as Disabled,
24
- o as Simple,
25
- l as WithLabel,
26
- a as default
29
+ g as Disabled,
30
+ h as Simple,
31
+ m as WithLabel,
32
+ l as default
27
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pismo/marola",
3
3
  "description": "CDX tribe component library",
4
- "version": "0.0.1-alpha.8",
4
+ "version": "0.0.1-alpha.9",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",