@strapi/design-system 1.7.6 → 1.7.7

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.
Files changed (75) hide show
  1. package/dist/BaseButton/BaseButton.cjs +3 -3
  2. package/dist/BaseButton/BaseButton.js +5 -5
  3. package/dist/CarouselInput/Carousel.cjs +6 -7
  4. package/dist/CarouselInput/Carousel.js +25 -79
  5. package/dist/CarouselInput/CarouselActions.cjs +1 -1
  6. package/dist/CarouselInput/CarouselActions.js +1 -14
  7. package/dist/CarouselInput/CarouselImage.cjs +3 -4
  8. package/dist/CarouselInput/CarouselImage.js +13 -23
  9. package/dist/CarouselInput/CarouselInput.cjs +1 -1
  10. package/dist/CarouselInput/CarouselInput.js +12 -75
  11. package/dist/CarouselInput/CarouselSlide.cjs +1 -3
  12. package/dist/CarouselInput/CarouselSlide.js +4 -29
  13. package/dist/Checkbox/Checkbox.cjs +3 -3
  14. package/dist/Checkbox/Checkbox.js +18 -40
  15. package/dist/Dialog/Dialog.cjs +5 -5
  16. package/dist/Dialog/Dialog.js +21 -49
  17. package/dist/Dialog/DialogBody.cjs +2 -2
  18. package/dist/Dialog/DialogBody.js +6 -19
  19. package/dist/Dialog/DialogFooter.cjs +2 -2
  20. package/dist/Dialog/DialogFooter.js +7 -21
  21. package/dist/ModalLayout/ModalBody.cjs +2 -2
  22. package/dist/ModalLayout/ModalBody.js +4 -5
  23. package/dist/ModalLayout/ModalContext.cjs +1 -1
  24. package/dist/ModalLayout/ModalContext.js +2 -1
  25. package/dist/ModalLayout/ModalFooter.cjs +2 -6
  26. package/dist/ModalLayout/ModalFooter.js +9 -26
  27. package/dist/ModalLayout/ModalHeader.cjs +2 -2
  28. package/dist/ModalLayout/ModalHeader.js +10 -22
  29. package/dist/ModalLayout/ModalLayout.cjs +3 -5
  30. package/dist/ModalLayout/ModalLayout.js +10 -30
  31. package/dist/NumberInput/NumberInput.cjs +2 -2
  32. package/dist/NumberInput/NumberInput.js +68 -168
  33. package/dist/Pagination/Pagination.cjs +1 -5
  34. package/dist/Pagination/Pagination.js +7 -21
  35. package/dist/Pagination/components.cjs +7 -10
  36. package/dist/Pagination/components.js +34 -81
  37. package/dist/Popover/Popover.cjs +3 -3
  38. package/dist/Popover/Popover.js +67 -66
  39. package/dist/ProgressBar/ProgressBar.cjs +5 -5
  40. package/dist/ProgressBar/ProgressBar.js +6 -37
  41. package/dist/Radio/Radio.cjs +1 -4
  42. package/dist/Radio/Radio.js +5 -18
  43. package/dist/Searchbar/SearchForm.cjs +1 -1
  44. package/dist/Searchbar/SearchForm.js +2 -3
  45. package/dist/Searchbar/Searchbar.cjs +10 -11
  46. package/dist/Searchbar/Searchbar.js +25 -54
  47. package/dist/Status/Status.cjs +6 -6
  48. package/dist/Status/Status.js +8 -46
  49. package/dist/Switch/Switch.cjs +5 -5
  50. package/dist/Switch/Switch.js +16 -52
  51. package/dist/Tabs/TabGroup.cjs +1 -1
  52. package/dist/Tabs/TabGroup.js +13 -37
  53. package/dist/Tabs/TabPanels.cjs +1 -1
  54. package/dist/Tabs/TabPanels.js +11 -22
  55. package/dist/Tabs/Tabs.cjs +2 -2
  56. package/dist/Tabs/Tabs.js +55 -110
  57. package/dist/Tabs/TabsContext.cjs +1 -1
  58. package/dist/Tabs/TabsContext.js +11 -4
  59. package/dist/Textarea/Textarea.cjs +14 -12
  60. package/dist/Textarea/Textarea.js +33 -55
  61. package/dist/ToggleCheckbox/ToggleCheckbox.cjs +8 -8
  62. package/dist/ToggleCheckbox/ToggleCheckbox.js +25 -121
  63. package/dist/ToggleInput/ToggleInput.cjs +3 -3
  64. package/dist/ToggleInput/ToggleInput.js +17 -70
  65. package/dist/Typography/Typography.cjs +1 -1
  66. package/dist/Typography/Typography.js +6 -6
  67. package/dist/hooks/useControllableState.cjs +1 -1
  68. package/dist/hooks/useControllableState.js +6 -6
  69. package/dist/themes/utils.cjs +2 -2
  70. package/dist/themes/utils.js +1 -1
  71. package/package.json +4 -4
  72. package/dist/Tabs/useTabsFocus.cjs +0 -1
  73. package/dist/Tabs/useTabsFocus.js +0 -17
  74. package/dist/Textarea/TextareaInput.cjs +0 -30
  75. package/dist/Textarea/TextareaInput.js +0 -65
package/dist/Tabs/Tabs.js CHANGED
@@ -1,131 +1,76 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { Children as C, cloneElement as D } from "react";
3
- import o from "prop-types";
4
- import k from "styled-components";
5
- import { DefaultTabsRow as w, SimpleTabBox as R, DefaultTabButton as B, DefaultTabBox as E } from "./components.js";
6
- import { useTabs as K } from "./TabsContext.js";
7
- import { useTabsFocus as P } from "./useTabsFocus.js";
8
- import { KeyboardKeys as T } from "../helpers/keyboardKeys.js";
9
- import { Typography as I } from "../Typography/Typography.js";
10
- const A = k.button`
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import { Children as T, cloneElement as I, useRef as g, useEffect as k } from "react";
3
+ import { useCallbackRef as w } from "@strapi/ui-primitives";
4
+ import R from "styled-components";
5
+ import { DefaultTabsRow as v, SimpleTabBox as B, DefaultTabButton as E, DefaultTabBox as K } from "./components.js";
6
+ import { useTabs as A } from "./TabsContext.js";
7
+ import { KeyboardKeys as y } from "../helpers/keyboardKeys.js";
8
+ import { Typography as C } from "../Typography/Typography.js";
9
+ const N = (s, b) => {
10
+ const i = g(null), l = g(!1), r = w(b);
11
+ return k(() => {
12
+ if (i.current) {
13
+ if (l.current) {
14
+ const d = i.current.querySelector('[tabindex="0"]');
15
+ d && (d.focus(), r(s));
16
+ }
17
+ l.current || (l.current = !0);
18
+ }
19
+ }, [s, r]), i;
20
+ }, $ = R.button`
11
21
  &[aria-disabled='true'] {
12
22
  cursor: not-allowed;
13
23
  }
14
- `, N = ({ children: b, ...p }) => {
15
- const { id: x, selectedTabIndex: c, selectTabIndex: i, label: f, variant: u, onTabChange: y } = K(), m = P(c, y), r = C.toArray(b).map(
16
- (n, s) => D(n, {
17
- id: `${x}-${s}`,
18
- index: s,
19
- selectedTabIndex: c,
20
- onTabClick: () => i(s),
21
- variant: u
22
- })
23
- ), h = (n) => {
24
- if (!r.every((a) => a.props.disabled))
25
- switch (n.key) {
26
- case T.RIGHT: {
27
- const a = c + 1, e = (t) => r[t].props.disabled ? t === r.length - 1 ? e(0) : e(t + 1) : t, d = e(a >= r.length ? 0 : a);
28
- i(d);
24
+ `, G = ({ children: s, ...b }) => {
25
+ const { id: i, selectedTabIndex: l, selectTabIndex: r, label: d, variant: h, onTabChange: x } = A(), p = N(l, x), n = T.toArray(s).map((t, u) => I(t, {
26
+ id: `${i}-${u}`,
27
+ index: u,
28
+ selectedTabIndex: l,
29
+ onTabClick: () => r(u),
30
+ variant: h
31
+ })), m = (t) => {
32
+ if (!n.every((a) => a.props.disabled))
33
+ switch (t.key) {
34
+ case y.RIGHT: {
35
+ const a = l + 1, e = (o) => n[o].props.disabled ? o === n.length - 1 ? e(0) : e(o + 1) : o, f = e(a >= n.length ? 0 : a);
36
+ r(f);
29
37
  break;
30
38
  }
31
- case T.LEFT: {
32
- const a = c - 1, e = (t) => r[t].props.disabled ? e(t === 0 ? r.length - 1 : t - 1) : t, d = e(a < 0 ? r.length - 1 : a);
33
- i(d);
39
+ case y.LEFT: {
40
+ const a = l - 1, e = (o) => n[o].props.disabled ? e(o === 0 ? n.length - 1 : o - 1) : o, f = e(a < 0 ? n.length - 1 : a);
41
+ r(f);
34
42
  break;
35
43
  }
36
- case T.HOME: {
37
- const a = r.findIndex((e) => !e.props.disabled);
38
- i(a);
44
+ case y.HOME: {
45
+ const a = n.findIndex((e) => !e.props.disabled);
46
+ r(a);
39
47
  break;
40
48
  }
41
- case T.END: {
42
- const e = r.map((d, t) => ({ isDisabled: d.props.disabled, index: t })).reverse().find(({ isDisabled: d }) => !d);
43
- e && i(e.index);
49
+ case y.END: {
50
+ const e = n.map((f, o) => ({ isDisabled: f.props.disabled, index: o })).reverse().find(({ isDisabled: f }) => !f);
51
+ e && r(e.index);
44
52
  break;
45
53
  }
46
54
  }
47
55
  };
48
- return u === "simple" ? (
56
+ return h === "simple" ? (
49
57
  // TODO: This needs to be reviewed how to handle correctly since it's supposed to have focus.
50
58
  // eslint-disable-next-line jsx-a11y/interactive-supports-focus
51
- /* @__PURE__ */ l("div", { ref: m, role: "tablist", "aria-label": f, onKeyDown: h, ...p, children: r })
52
- ) : /* @__PURE__ */ l(
53
- w,
54
- {
55
- ref: m,
56
- role: "tablist",
57
- alignItems: "flex-end",
58
- "aria-label": f,
59
- onKeyDown: h,
60
- ...p,
61
- children: r
62
- }
63
- );
64
- };
65
- N.propTypes = {
66
- children: o.node.isRequired
67
- };
68
- const v = ({ disabled: b, id: p, children: x, variant: c, hasError: i, index: f, selectedTabIndex: u, onTabClick: y, ...m }) => {
69
- const r = `${p}-tab`, h = `${p}-tabpanel`, n = f === u, s = () => {
70
- b || y();
59
+ c("div", { ref: p, role: "tablist", "aria-label": d, onKeyDown: m, ...b, children: n })
60
+ ) : c(v, { ref: p, role: "tablist", alignItems: "flex-end", "aria-label": d, onKeyDown: m, ...b, children: n });
61
+ }, L = ({ disabled: s = !1, id: b, children: i, variant: l, hasError: r = !1, index: d, selectedTabIndex: h, onTabClick: x, ...p }) => {
62
+ const n = `${b}-tab`, m = `${b}-tabpanel`, t = d === h, u = () => {
63
+ s || x && x();
71
64
  };
72
- if (c === "simple") {
65
+ if (l === "simple") {
73
66
  let e;
74
- return i ? e = "danger600" : n ? e = "primary600" : e = "neutral600", /* @__PURE__ */ l(
75
- A,
76
- {
77
- id: r,
78
- role: "tab",
79
- "aria-controls": n ? h : void 0,
80
- tabIndex: n ? 0 : -1,
81
- "aria-selected": n,
82
- type: "button",
83
- onClick: s,
84
- "aria-disabled": b,
85
- ...m,
86
- children: /* @__PURE__ */ l(R, { padding: 4, selected: n, hasError: i, children: /* @__PURE__ */ l(I, { variant: "sigma", textColor: e, children: x }) })
87
- }
88
- );
67
+ return r ? e = "danger600" : t ? e = "primary600" : e = "neutral600", c($, { id: n, role: "tab", "aria-controls": t ? m : void 0, tabIndex: t ? 0 : -1, "aria-selected": t, type: "button", onClick: u, "aria-disabled": s, ...p, children: c(B, { padding: 4, selected: t, hasError: r, children: c(C, { variant: "sigma", textColor: e, children: i }) }) });
89
68
  }
90
- i && console.warn('The "hasError" prop is only available for the "simple" variant.');
91
- const a = u - 1 === f;
92
- return /* @__PURE__ */ l(
93
- B,
94
- {
95
- id: r,
96
- role: "tab",
97
- type: "button",
98
- "aria-controls": n ? h : void 0,
99
- tabIndex: n ? 0 : -1,
100
- "aria-selected": n,
101
- onClick: s,
102
- "aria-disabled": b,
103
- showRightBorder: a,
104
- ...m,
105
- children: /* @__PURE__ */ l(E, { padding: n ? 4 : 3, background: n ? "neutral0" : "neutral100", selected: n, children: /* @__PURE__ */ l(I, { fontWeight: "bold", textColor: n ? "primary700" : "neutral600", children: x }) })
106
- }
107
- );
108
- };
109
- v.defaultProps = {
110
- disabled: !1,
111
- hasError: !1,
112
- id: void 0,
113
- index: void 0,
114
- onTabClick: void 0,
115
- selectedTabIndex: void 0,
116
- variant: void 0
117
- };
118
- v.propTypes = {
119
- children: o.node.isRequired,
120
- disabled: o.bool,
121
- hasError: o.bool,
122
- id: o.string,
123
- index: o.number,
124
- onTabClick: o.func,
125
- selectedTabIndex: o.number,
126
- variant: o.oneOf(["simple"])
69
+ r && console.warn('The "hasError" prop is only available for the "simple" variant.');
70
+ const a = h && h - 1 === d;
71
+ return c(E, { id: n, role: "tab", type: "button", "aria-controls": t ? m : void 0, tabIndex: t ? 0 : -1, "aria-selected": t, onClick: u, "aria-disabled": s, showRightBorder: !!a, ...p, children: c(K, { padding: t ? 4 : 3, background: t ? "neutral0" : "neutral100", selected: t, children: c(C, { fontWeight: "bold", textColor: t ? "primary700" : "neutral600", children: i }) }) });
127
72
  };
128
73
  export {
129
- v as Tab,
130
- N as Tabs
74
+ L as Tab,
75
+ G as Tabs
131
76
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext(),s=()=>e.useContext(t);exports.TabsContext=t;exports.useTabs=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext({id:"",label:"",selectedTabIndex:0,selectTabIndex(){throw new Error("TabsContext.selectTabIndex is not implemented.")}}),s=()=>e.useContext(t);exports.TabsContext=t;exports.useTabs=s;
@@ -1,6 +1,13 @@
1
- import { createContext as t, useContext as e } from "react";
2
- const o = t(), n = () => e(o);
1
+ import { createContext as e, useContext as t } from "react";
2
+ const n = e({
3
+ id: "",
4
+ label: "",
5
+ selectedTabIndex: 0,
6
+ selectTabIndex() {
7
+ throw new Error("TabsContext.selectTabIndex is not implemented.");
8
+ }
9
+ }), s = () => t(n);
3
10
  export {
4
- o as TabsContext,
5
- n as useTabs
11
+ n as TabsContext,
12
+ s as useTabs
6
13
  };
@@ -1,15 +1,17 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),g=require("react"),q=require("prop-types"),m=require("styled-components"),T=require("./TextareaInput.cjs"),v=require("../hooks/useId.cjs"),y=require("../Field/Field.cjs"),d=require("../Flex/Flex.cjs"),F=require("../Field/FieldLabel.cjs"),b=require("../Field/FieldHint.cjs"),j=require("../Field/FieldError.cjs"),l=t=>t&&t.__esModule?t:{default:t},_=l(g),e=l(q),I=l(m),O=I.default.div`
2
- & textarea {
3
- // TODO: remove when we'll have fonts in the theme
4
- height: ${80/16}rem;
5
- line-height: ${20/16}rem;
6
- }
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),g=require("styled-components"),j=require("../hooks/useId.cjs"),b=require("../themes/utils.cjs"),d=require("../Box/Box.cjs"),m=require("../Field/FieldContext.cjs"),y=require("../Field/Field.cjs"),R=require("../Flex/Flex.cjs"),_=require("../Field/FieldLabel.cjs"),$=require("../Field/FieldHint.cjs"),E=require("../Field/FieldError.cjs"),c=e=>e&&e.__esModule?e:{default:e},f=c(p),x=c(g),I=x.default(d.Box)`
2
+ ${b.inputFocusStyle()}
3
+ `,S=x.default(d.Box)`
4
+ border: none;
5
+ resize: none;
7
6
 
8
- & textarea::placeholder {
9
- font-weight: 400;
10
- font-size: ${14/16}rem;
11
- line-height: 1.43;
12
- color: ${({theme:t})=>t.colors.neutral500};
7
+ ::placeholder {
8
+ color: ${({theme:e})=>e.colors.neutral500};
9
+ font-size: ${({theme:e})=>e.fontSizes[2]};
10
+ color: ${({theme:e})=>e.colors.neutral500};
13
11
  opacity: 1;
14
12
  }
15
- `,i=_.default.forwardRef(({name:t,hint:n,error:o,label:a,children:s,labelAction:u,id:c,required:f,...h},x)=>{const p=v.useId(c);return r.jsx(O,{children:r.jsx(y.Field,{name:t,hint:n,error:o,id:p,required:f,children:r.jsxs(d.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[a&&r.jsx(d.Flex,{children:r.jsx(F.FieldLabel,{action:u,children:a})}),r.jsx(T.TextareaInput,{ref:x,as:"textarea",value:s,...h}),r.jsx(b.FieldHint,{}),r.jsx(j.FieldError,{})]})})})});i.displayName="Textarea";i.defaultProps={"aria-label":void 0,label:void 0,labelAction:void 0,error:void 0,hint:void 0,id:void 0,children:"",required:!1};i.propTypes={"aria-label":e.default.string,children:e.default.string,error:e.default.string,hint:e.default.oneOfType([e.default.string,e.default.node,e.default.arrayOf(e.default.node)]),id:e.default.string,label:e.default.string,labelAction:e.default.element,name:e.default.string.isRequired,required:e.default.bool};exports.Textarea=i;
13
+
14
+ &:focus-within {
15
+ outline: none;
16
+ }
17
+ `,T=f.default.forwardRef(({disabled:e,...a},s)=>{const{id:t,error:i,hint:l,required:u}=m.useField(),n=!!i;let o=l?`${t}-hint`:void 0;return i&&(o=`${t}-error`),r.jsx(I,{borderColor:n?"danger600":"neutral200",hasError:n,hasRadius:!0,children:r.jsx(S,{"aria-describedby":o,"aria-invalid":n,"aria-required":u,as:"textarea",background:e?"neutral150":"neutral0",color:e?"neutral600":"neutral800",disabled:e,fontSize:2,hasRadius:!0,height:`${105/16}rem`,id:t,ref:s,lineHeight:4,padding:4,width:"100%",...a})})}),w=f.default.forwardRef(({name:e,hint:a,error:s,label:t,labelAction:i,id:l,required:u=!1,children:n,value:o,...h},q)=>{const F=j.useId(l);return r.jsx(y.Field,{name:e,hint:a,error:s,id:F,required:u,children:r.jsxs(R.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t&&r.jsx(_.FieldLabel,{action:i,children:t}),r.jsx(T,{ref:q,value:n??o,...h}),r.jsx($.FieldHint,{}),r.jsx(E.FieldError,{})]})})});exports.Textarea=w;
@@ -1,61 +1,39 @@
1
- import { jsx as r, jsxs as g } from "react/jsx-runtime";
2
- import u from "react";
3
- import e from "prop-types";
4
- import x from "styled-components";
5
- import { TextareaInput as v } from "./TextareaInput.js";
6
- import { useId as T } from "../hooks/useId.js";
7
- import { Field as b } from "../Field/Field.js";
8
- import { Flex as a } from "../Flex/Flex.js";
9
- import { FieldLabel as y } from "../Field/FieldLabel.js";
10
- import { FieldHint as F } from "../Field/FieldHint.js";
11
- import { FieldError as w } from "../Field/FieldError.js";
12
- const I = x.div`
13
- & textarea {
14
- // TODO: remove when we'll have fonts in the theme
15
- height: ${80 / 16}rem;
16
- line-height: ${20 / 16}rem;
17
- }
1
+ import { jsx as e, jsxs as x } from "react/jsx-runtime";
2
+ import m from "react";
3
+ import c from "styled-components";
4
+ import { useId as g } from "../hooks/useId.js";
5
+ import { inputFocusStyle as F } from "../themes/utils.js";
6
+ import { Box as u } from "../Box/Box.js";
7
+ import { useField as $ } from "../Field/FieldContext.js";
8
+ import { Field as R } from "../Field/Field.js";
9
+ import { Flex as b } from "../Flex/Flex.js";
10
+ import { FieldLabel as w } from "../Field/FieldLabel.js";
11
+ import { FieldHint as y } from "../Field/FieldHint.js";
12
+ import { FieldError as z } from "../Field/FieldError.js";
13
+ const E = c(u)`
14
+ ${F()}
15
+ `, I = c(u)`
16
+ border: none;
17
+ resize: none;
18
18
 
19
- & textarea::placeholder {
20
- font-weight: 400;
21
- font-size: ${14 / 16}rem;
22
- line-height: 1.43;
23
- color: ${({ theme: i }) => i.colors.neutral500};
19
+ ::placeholder {
20
+ color: ${({ theme: r }) => r.colors.neutral500};
21
+ font-size: ${({ theme: r }) => r.fontSizes[2]};
22
+ color: ${({ theme: r }) => r.colors.neutral500};
24
23
  opacity: 1;
25
24
  }
26
- `, t = u.forwardRef(
27
- ({ name: i, hint: l, error: n, label: o, children: d, labelAction: m, id: s, required: p, ...h }, c) => {
28
- const f = T(s);
29
- return /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(b, { name: i, hint: l, error: n, id: f, required: p, children: /* @__PURE__ */ g(a, { direction: "column", alignItems: "stretch", gap: 1, children: [
30
- o && /* @__PURE__ */ r(a, { children: /* @__PURE__ */ r(y, { action: m, children: o }) }),
31
- /* @__PURE__ */ r(v, { ref: c, as: "textarea", value: d, ...h }),
32
- /* @__PURE__ */ r(F, {}),
33
- /* @__PURE__ */ r(w, {})
34
- ] }) }) });
25
+
26
+ &:focus-within {
27
+ outline: none;
35
28
  }
36
- );
37
- t.displayName = "Textarea";
38
- t.defaultProps = {
39
- "aria-label": void 0,
40
- label: void 0,
41
- labelAction: void 0,
42
- error: void 0,
43
- hint: void 0,
44
- id: void 0,
45
- children: "",
46
- required: !1
47
- };
48
- t.propTypes = {
49
- "aria-label": e.string,
50
- children: e.string,
51
- error: e.string,
52
- hint: e.oneOfType([e.string, e.node, e.arrayOf(e.node)]),
53
- id: e.string,
54
- label: e.string,
55
- labelAction: e.element,
56
- name: e.string.isRequired,
57
- required: e.bool
58
- };
29
+ `, q = m.forwardRef(({ disabled: r, ...a }, d) => {
30
+ const { id: o, error: i, hint: l, required: s } = $(), t = !!i;
31
+ let n = l ? `${o}-hint` : void 0;
32
+ return i && (n = `${o}-error`), e(E, { borderColor: t ? "danger600" : "neutral200", hasError: t, hasRadius: !0, children: e(I, { "aria-describedby": n, "aria-invalid": t, "aria-required": s, as: "textarea", background: r ? "neutral150" : "neutral0", color: r ? "neutral600" : "neutral800", disabled: r, fontSize: 2, hasRadius: !0, height: `${105 / 16}rem`, id: o, ref: d, lineHeight: 4, padding: 4, width: "100%", ...a }) });
33
+ }), A = m.forwardRef(({ name: r, hint: a, error: d, label: o, labelAction: i, id: l, required: s = !1, children: t, value: n, ...f }, p) => {
34
+ const h = g(l);
35
+ return e(R, { name: r, hint: a, error: d, id: h, required: s, children: x(b, { direction: "column", alignItems: "stretch", gap: 1, children: [o && e(w, { action: i, children: o }), e(q, { ref: p, value: t ?? n, ...f }), e(y, {}), e(z, {})] }) });
36
+ });
59
37
  export {
60
- t as Textarea
38
+ A as Textarea
61
39
  };
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),$=require("react"),_=require("prop-types"),L=require("styled-components"),m=require("../themes/sizes.cjs"),z=require("../themes/utils.cjs"),S=require("../Box/Box.cjs"),F=require("../Flex/Flex.cjs"),W=require("../Field/FieldContext.cjs"),B=require("../VisuallyHidden/VisuallyHidden.cjs"),h=require("../Typography/Typography.cjs"),c=e=>e&&e.__esModule?e:{default:e},M=c($),n=c(_),i=c(L),P=i.default.label`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),R=require("react"),k=require("styled-components"),m=require("../themes/utils.cjs"),_=require("../Box/Box.cjs"),S=require("../Flex/Flex.cjs"),B=require("../Field/FieldContext.cjs"),F=require("../VisuallyHidden/VisuallyHidden.cjs"),f=require("../Typography/Typography.cjs"),x=e=>e&&e.__esModule?e:{default:e},L=x(R),a=x(k),W=a.default.label`
2
2
  position: relative;
3
3
  display: inline-block;
4
4
  z-index: 0;
5
5
  width: 100%;
6
- `,I=i.default(S.Box)`
6
+ `,z=a.default(_.Box)`
7
7
  cursor: ${({disabled:e})=>e?"not-allowed":void 0};
8
8
  // Masks the background of each value
9
9
  overflow: hidden;
10
10
  flex-wrap: wrap;
11
11
 
12
- ${z.inputFocusStyle()}
13
- `,g=i.default(F.Flex).attrs({hasRadius:!0})`
14
- background-color: ${({theme:e,checked:l,disabled:a})=>l?a?e.colors.neutral200:e.colors.neutral0:"transparent"};
12
+ ${m.inputFocusStyle()}
13
+ `,h=a.default(S.Flex).attrs({hasRadius:!0})`
14
+ background-color: ${({theme:e,checked:o,disabled:l})=>o?l?e.colors.neutral200:e.colors.neutral0:"transparent"};
15
15
  border: 1px solid
16
- ${({theme:e,checked:l,disabled:a})=>l&&l!==null?a?e.colors.neutral300:e.colors.neutral200:a?e.colors.neutral150:e.colors.neutral100};
16
+ ${({theme:e,checked:o,disabled:l})=>o&&o!==null?l?e.colors.neutral300:e.colors.neutral200:l?e.colors.neutral150:e.colors.neutral100};
17
17
  position: relative;
18
18
  user-select: none;
19
19
  z-index: 2;
@@ -25,7 +25,7 @@
25
25
  */
26
26
  padding-top: ${({size:e})=>`${e==="S"?"2px":"6px"}`};
27
27
  padding-bottom: ${({size:e})=>`${e==="S"?"2px":"6px"}`};
28
- `,O=i.default.input`
28
+ `,M=a.default.input`
29
29
  height: 100%;
30
30
  left: 0;
31
31
  opacity: 0;
@@ -33,4 +33,4 @@
33
33
  top: 0;
34
34
  z-index: 1;
35
35
  width: 100%;
36
- `,s=M.default.forwardRef(({size:e,onLabel:l,offLabel:a,children:x,checked:t,disabled:r,onChange:b,...y},C)=>{const{error:q,hint:w,id:p,name:j,required:T}=W.useField(),f="neutral600";let v=!t&&t!==null?"danger700":f,R=t?"primary600":f;const k=d=>{r||b(d)};let u;return q?u=`${p}-error`:w&&(u=`${p}-hint`),o.jsxs(P,{children:[o.jsx(B.VisuallyHidden,{children:x}),o.jsxs(I,{hasRadius:!0,disabled:r,padding:1,display:"flex",background:r?"neutral150":"neutral100",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral200",children:[o.jsx(g,{size:e,paddingLeft:3,paddingRight:3,justifyContent:"center",alignItems:"center","aria-hidden":!0,checked:t===null?!1:!t,disabled:r,children:o.jsx(h.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:r?"neutral700":v,children:a})}),o.jsx(g,{size:e,paddingLeft:3,paddingRight:3,justifyContent:"center",alignItems:"center","aria-hidden":!0,checked:t===null?!1:t,disabled:r,children:o.jsx(h.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:r?"neutral700":R,children:l})}),o.jsx(O,{type:"checkbox","aria-disabled":r,"aria-describedby":u,onChange:d=>k(d),name:j,ref:C,"aria-required":T,...y,checked:!(t===null||!t)})]})]})});s.displayName="ToggleCheckbox";s.defaultProps={disabled:!1,checked:!1,onChange:void 0,size:"M"};s.propTypes={checked:n.default.bool,children:n.default.string.isRequired,disabled:n.default.bool,offLabel:n.default.string.isRequired,onChange:n.default.func,onLabel:n.default.string.isRequired,size:n.default.oneOf(Object.keys(m.sizes.input))};exports.ToggleCheckbox=s;
36
+ `,g=L.default.forwardRef(({size:e="M",onLabel:o,offLabel:l,children:b,checked:r=!1,disabled:t=!1,onChange:u,...y},C)=>{const{error:d,hint:w,id:c,name:j,required:q}=B.useField(),p="neutral600";let T=!r&&r!==null?"danger700":p,$=r?"primary600":p;const v=s=>{t||u&&u(s)};let i;return d?i=`${c}-error`:w&&(i=`${c}-hint`),n.jsxs(W,{children:[n.jsx(F.VisuallyHidden,{children:b}),n.jsxs(z,{hasRadius:!0,disabled:t,padding:1,display:"flex",background:t?"neutral150":"neutral100",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral200",hasError:!!d,children:[n.jsx(h,{size:e,paddingLeft:3,paddingRight:3,justifyContent:"center",alignItems:"center","aria-hidden":!0,checked:r===null?!1:!r,disabled:t,children:n.jsx(f.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:t?"neutral700":T,children:l})}),n.jsx(h,{size:e,paddingLeft:3,paddingRight:3,justifyContent:"center",alignItems:"center","aria-hidden":!0,checked:r===null?!1:r,disabled:t,children:n.jsx(f.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:t?"neutral700":$,children:o})}),n.jsx(M,{type:"checkbox","aria-disabled":t,"aria-describedby":i,onChange:s=>v(s),name:j,ref:C,"aria-required":q,...y,checked:!(r===null||!r)})]})]})});g.displayName="ToggleCheckbox";exports.ToggleCheckbox=g;
@@ -1,32 +1,30 @@
1
- import { jsxs as c, jsx as l } from "react/jsx-runtime";
2
- import L from "react";
3
- import t from "prop-types";
4
- import a from "styled-components";
5
- import { sizes as j } from "../themes/sizes.js";
6
- import { inputFocusStyle as q } from "../themes/utils.js";
7
- import { Box as z } from "../Box/Box.js";
1
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
+ import R from "react";
3
+ import i from "styled-components";
4
+ import { inputFocusStyle as T } from "../themes/utils.js";
5
+ import { Box as L } from "../Box/Box.js";
8
6
  import { Flex as W } from "../Flex/Flex.js";
9
- import { useField as S } from "../Field/FieldContext.js";
10
- import { VisuallyHidden as B } from "../VisuallyHidden/VisuallyHidden.js";
7
+ import { useField as j } from "../Field/FieldContext.js";
8
+ import { VisuallyHidden as z } from "../VisuallyHidden/VisuallyHidden.js";
11
9
  import { Typography as h } from "../Typography/Typography.js";
12
- const F = a.label`
10
+ const B = i.label`
13
11
  position: relative;
14
12
  display: inline-block;
15
13
  z-index: 0;
16
14
  width: 100%;
17
- `, I = a(z)`
15
+ `, S = i(L)`
18
16
  cursor: ${({ disabled: e }) => e ? "not-allowed" : void 0};
19
17
  // Masks the background of each value
20
18
  overflow: hidden;
21
19
  flex-wrap: wrap;
22
20
 
23
- ${q()}
24
- `, g = a(W).attrs({
21
+ ${T()}
22
+ `, g = i(W).attrs({
25
23
  hasRadius: !0
26
24
  })`
27
- background-color: ${({ theme: e, checked: n, disabled: i }) => n ? i ? e.colors.neutral200 : e.colors.neutral0 : "transparent"};
25
+ background-color: ${({ theme: e, checked: o, disabled: n }) => o ? n ? e.colors.neutral200 : e.colors.neutral0 : "transparent"};
28
26
  border: 1px solid
29
- ${({ theme: e, checked: n, disabled: i }) => n && n !== null ? i ? e.colors.neutral300 : e.colors.neutral200 : i ? e.colors.neutral150 : e.colors.neutral100};
27
+ ${({ theme: e, checked: o, disabled: n }) => o && o !== null ? n ? e.colors.neutral300 : e.colors.neutral200 : n ? e.colors.neutral150 : e.colors.neutral100};
30
28
  position: relative;
31
29
  user-select: none;
32
30
  z-index: 2;
@@ -38,7 +36,7 @@ const F = a.label`
38
36
  */
39
37
  padding-top: ${({ size: e }) => `${e === "S" ? "2px" : "6px"}`};
40
38
  padding-bottom: ${({ size: e }) => `${e === "S" ? "2px" : "6px"}`};
41
- `, M = a.input`
39
+ `, F = i.input`
42
40
  height: 100%;
43
41
  left: 0;
44
42
  opacity: 0;
@@ -46,110 +44,16 @@ const F = a.label`
46
44
  top: 0;
47
45
  z-index: 1;
48
46
  width: 100%;
49
- `, u = L.forwardRef(
50
- ({ size: e, onLabel: n, offLabel: i, children: b, checked: r, disabled: o, onChange: x, ...m }, y) => {
51
- const { error: C, hint: w, id: d, name: v, required: $ } = S(), f = "neutral600";
52
- let k = !r && r !== null ? "danger700" : f, R = r ? "primary600" : f;
53
- const T = (p) => {
54
- o || x(p);
55
- };
56
- let s;
57
- return C ? s = `${d}-error` : w && (s = `${d}-hint`), /* @__PURE__ */ c(F, { children: [
58
- /* @__PURE__ */ l(B, { children: b }),
59
- /* @__PURE__ */ c(
60
- I,
61
- {
62
- hasRadius: !0,
63
- disabled: o,
64
- padding: 1,
65
- display: "flex",
66
- background: o ? "neutral150" : "neutral100",
67
- borderStyle: "solid",
68
- borderWidth: "1px",
69
- borderColor: "neutral200",
70
- children: [
71
- /* @__PURE__ */ l(
72
- g,
73
- {
74
- size: e,
75
- paddingLeft: 3,
76
- paddingRight: 3,
77
- justifyContent: "center",
78
- alignItems: "center",
79
- "aria-hidden": !0,
80
- checked: r === null ? !1 : !r,
81
- disabled: o,
82
- children: /* @__PURE__ */ l(
83
- h,
84
- {
85
- variant: "pi",
86
- fontWeight: "bold",
87
- textTransform: "uppercase",
88
- textColor: o ? "neutral700" : k,
89
- children: i
90
- }
91
- )
92
- }
93
- ),
94
- /* @__PURE__ */ l(
95
- g,
96
- {
97
- size: e,
98
- paddingLeft: 3,
99
- paddingRight: 3,
100
- justifyContent: "center",
101
- alignItems: "center",
102
- "aria-hidden": !0,
103
- checked: r === null ? !1 : r,
104
- disabled: o,
105
- children: /* @__PURE__ */ l(
106
- h,
107
- {
108
- variant: "pi",
109
- fontWeight: "bold",
110
- textTransform: "uppercase",
111
- textColor: o ? "neutral700" : R,
112
- children: n
113
- }
114
- )
115
- }
116
- ),
117
- /* @__PURE__ */ l(
118
- M,
119
- {
120
- type: "checkbox",
121
- "aria-disabled": o,
122
- "aria-describedby": s,
123
- onChange: (p) => T(p),
124
- name: v,
125
- ref: y,
126
- "aria-required": $,
127
- ...m,
128
- checked: !(r === null || !r)
129
- }
130
- )
131
- ]
132
- }
133
- )
134
- ] });
135
- }
136
- );
137
- u.displayName = "ToggleCheckbox";
138
- u.defaultProps = {
139
- disabled: !1,
140
- checked: !1,
141
- onChange: void 0,
142
- size: "M"
143
- };
144
- u.propTypes = {
145
- checked: t.bool,
146
- children: t.string.isRequired,
147
- disabled: t.bool,
148
- offLabel: t.string.isRequired,
149
- onChange: t.func,
150
- onLabel: t.string.isRequired,
151
- size: t.oneOf(Object.keys(j.input))
152
- };
47
+ `, I = R.forwardRef(({ size: e = "M", onLabel: o, offLabel: n, children: x, checked: r = !1, disabled: t = !1, onChange: s, ...b }, m) => {
48
+ const { error: d, hint: y, id: p, name: w, required: C } = j(), f = "neutral600";
49
+ let $ = !r && r !== null ? "danger700" : f, v = r ? "primary600" : f;
50
+ const k = (u) => {
51
+ t || s && s(u);
52
+ };
53
+ let l;
54
+ return d ? l = `${p}-error` : y && (l = `${p}-hint`), c(B, { children: [a(z, { children: x }), c(S, { hasRadius: !0, disabled: t, padding: 1, display: "flex", background: t ? "neutral150" : "neutral100", borderStyle: "solid", borderWidth: "1px", borderColor: "neutral200", hasError: !!d, children: [a(g, { size: e, paddingLeft: 3, paddingRight: 3, justifyContent: "center", alignItems: "center", "aria-hidden": !0, checked: r === null ? !1 : !r, disabled: t, children: a(h, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: t ? "neutral700" : $, children: n }) }), a(g, { size: e, paddingLeft: 3, paddingRight: 3, justifyContent: "center", alignItems: "center", "aria-hidden": !0, checked: r === null ? !1 : r, disabled: t, children: a(h, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: t ? "neutral700" : v, children: o }) }), a(F, { type: "checkbox", "aria-disabled": t, "aria-describedby": l, onChange: (u) => k(u), name: w, ref: m, "aria-required": C, ...b, checked: !(r === null || !r) })] })] });
55
+ });
56
+ I.displayName = "ToggleCheckbox";
153
57
  export {
154
- u as ToggleCheckbox
58
+ I as ToggleCheckbox
155
59
  };
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");require("react");const T=require("prop-types"),j=require("styled-components"),y=require("../hooks/useId.cjs"),m=require("../themes/sizes.cjs"),v=require("../ToggleCheckbox/ToggleCheckbox.cjs"),I=require("../Field/Field.cjs"),_=require("../TextButton/TextButton.cjs"),u=require("../Flex/Flex.cjs"),k=require("../Field/FieldLabel.cjs"),C=require("../Field/FieldHint.cjs"),O=require("../Field/FieldError.cjs"),a=l=>l&&l.__esModule?l:{default:l},e=a(T),c=a(j),z=c.default(I.Field)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("styled-components"),p=require("../hooks/useId.cjs"),m=require("../ToggleCheckbox/ToggleCheckbox.cjs"),T=require("../Field/Field.cjs"),I=require("../TextButton/TextButton.cjs"),o=require("../Flex/Flex.cjs"),y=require("../Field/FieldLabel.cjs"),_=require("../Field/FieldHint.cjs"),b=require("../Field/FieldError.cjs"),k=t=>t&&t.__esModule?t:{default:t},d=k(j),B=d.default(T.Field)`
2
2
  max-width: 320px;
3
- `,P=c.default(_.TextButton)`
3
+ `,C=d.default(I.TextButton)`
4
4
  align-self: flex-end;
5
5
  margin-left: auto;
6
- `,r=({disabled:l,size:f,error:g,hint:p,label:i,name:x,labelAction:b,required:q,id:h,onClear:d,clearLabel:n,checked:o,...F})=>{const s=y.useId(h);return t.jsx(z,{name:x,hint:p,error:g,id:s,required:q,children:t.jsxs(u.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t.jsxs(u.Flex,{children:[t.jsx(k.FieldLabel,{action:b,children:i}),n&&d&&o!==null&&!l&&t.jsx(P,{onClick:d,children:n})]}),t.jsx(v.ToggleCheckbox,{id:s,size:f,checked:o,disabled:l,...F,children:i}),t.jsx(C.FieldHint,{}),t.jsx(O.FieldError,{})]})})};r.displayName="ToggleInput";r.defaultProps={checked:!1,clearLabel:void 0,disabled:!1,error:void 0,hint:void 0,id:void 0,label:"",labelAction:void 0,name:"",onClear:void 0,required:!1,size:"M"};r.propTypes={checked:e.default.bool,clearLabel:e.default.string,disabled:e.default.bool,error:e.default.string,hint:e.default.oneOfType([e.default.string,e.default.node,e.default.arrayOf(e.default.node)]),id:e.default.string,label:e.default.string,labelAction:e.default.node,name:e.default.string,onClear:e.default.func,required:e.default.bool,size:e.default.oneOf(Object.keys(m.sizes.input))};exports.ToggleInput=r;
6
+ `,u=({disabled:t=!1,size:c="M",error:a,hint:x,label:r,name:g,labelAction:f,required:F=!1,id:h,onClear:i,clearLabel:n,checked:l=!1,...q})=>{const s=p.useId(h);return e.jsx(B,{name:g,hint:x,error:a,id:s,required:F,children:e.jsxs(o.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[e.jsxs(o.Flex,{children:[e.jsx(y.FieldLabel,{action:f,children:r}),n&&i&&l!==null&&!t&&e.jsx(C,{onClick:i,children:n})]}),e.jsx(m.ToggleCheckbox,{id:s,size:c,checked:l,disabled:t,...q,children:r}),e.jsx(_.FieldHint,{}),e.jsx(b.FieldError,{})]})})};u.displayName="ToggleInput";exports.ToggleInput=u;