@strapi/design-system 1.8.1 → 1.9.0

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 (37) hide show
  1. package/dist/BaseCheckbox/BaseCheckbox.cjs +4 -4
  2. package/dist/BaseCheckbox/BaseCheckbox.js +19 -18
  3. package/dist/CarouselInput/Carousel.cjs +4 -4
  4. package/dist/CarouselInput/Carousel.js +13 -13
  5. package/dist/CarouselInput/CarouselInput.cjs +1 -1
  6. package/dist/CarouselInput/CarouselInput.js +14 -13
  7. package/dist/Checkbox/Checkbox.cjs +2 -2
  8. package/dist/Checkbox/Checkbox.js +22 -21
  9. package/dist/Combobox/Combobox.cjs +10 -10
  10. package/dist/Combobox/Combobox.js +57 -56
  11. package/dist/DatePicker/DatePicker.cjs +9 -9
  12. package/dist/DatePicker/DatePicker.js +67 -66
  13. package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
  14. package/dist/DateTimePicker/DateTimePicker.js +46 -42
  15. package/dist/JSONInput/JSONInput.cjs +33 -1
  16. package/dist/JSONInput/JSONInput.js +85 -46
  17. package/dist/Popover/Popover.cjs +3 -3
  18. package/dist/Popover/Popover.js +52 -51
  19. package/dist/Select/MultiSelect.cjs +7 -7
  20. package/dist/Select/MultiSelect.js +45 -44
  21. package/dist/Select/SingleSelect.cjs +1 -1
  22. package/dist/Select/SingleSelect.js +35 -34
  23. package/dist/TextInput/TextInput.cjs +1 -1
  24. package/dist/TextInput/TextInput.js +15 -14
  25. package/dist/TimePicker/TimePicker.cjs +2 -2
  26. package/dist/TimePicker/TimePicker.js +38 -38
  27. package/dist/ToggleInput/ToggleInput.cjs +20 -4
  28. package/dist/ToggleInput/ToggleInput.js +44 -18
  29. package/dist/Typography/Typography.cjs +1 -1
  30. package/dist/Typography/Typography.js +6 -6
  31. package/dist/Typography/utils.cjs +1 -1
  32. package/dist/Typography/utils.js +4 -5
  33. package/dist/themes/utils.cjs +9 -9
  34. package/dist/themes/utils.js +9 -9
  35. package/package.json +10 -10
  36. package/dist/JSONInput/JSONInputContainer.cjs +0 -33
  37. package/dist/JSONInput/JSONInputContainer.js +0 -39
@@ -1 +1,33 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("react"),S=require("@codemirror/lang-json"),M=require("@uiw/react-codemirror"),N=require("./JSONInputContainer.cjs"),l=require("./utils/decorationExtension.cjs"),R=require("../Field/Field.cjs"),H=require("../Flex/Flex.cjs"),L=require("../Field/FieldLabel.cjs"),y=require("../Field/FieldError.cjs"),z=require("../Field/FieldHint.cjs"),A=({label:a,error:d,hint:x,labelAction:F,value:m="",required:q=!1,disabled:h=!1,onChange:p=()=>null,...b})=>{const i=u.useRef(),o=u.useRef(),c=u.useRef(),j=!!d,C=e=>{const r=o.current?.doc;if(r){const{text:s,to:t}=r.line(e),E=t-s.trimStart().length;t>E&&c.current?.dispatch({effects:l.addMarks.of([l.lineHighlightMark.range(E,t)])})}},O=()=>{const e=o.current?.doc;if(e){const r=e.length||0;c.current?.dispatch({effects:l.filterMarks.of((s,t)=>t<=0||s>=r)})}},f=({state:e,view:r})=>{c.current=r,o.current=e,O();const t=S.jsonParseLinter()(r);t.length&&C(e.doc.lineAt(t[0].from).number)},k=(e,r)=>{f(r),p(e)},I=(e,r)=>{c.current=e,o.current=r,f({view:e,state:r})},{setContainer:g}=M.useCodeMirror({value:m,onCreateEditor:I,container:i.current,editable:!h,extensions:[S.json(),l.markField],onChange:k,theme:"dark",basicSetup:{lineNumbers:!0,bracketMatching:!0,closeBrackets:!0,indentOnInput:!0,syntaxHighlighting:!0,highlightSelectionMatches:!0,tabSize:2}}),J=()=>{h||i.current?.children[0].children[1].children[1]?.focus()};return u.useEffect(()=>{const e=i.current;e&&g(e)},[g]),n.jsx(R.Field,{error:d,hint:x,required:q,children:n.jsxs(H.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[a&&n.jsx(L.FieldLabel,{onClick:J,action:F,children:a}),n.jsx(N.JSONInputContainer,{ref:i,hasError:j,alignItems:"stretch",fontSize:2,hasRadius:!0,...b}),n.jsx(y.FieldError,{}),n.jsx(z.FieldHint,{})]})})};exports.JSONInput=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),p=require("@codemirror/lang-json"),J=require("@uiw/react-codemirror"),N=require("styled-components"),d=require("./utils/decorationExtension.cjs"),L=require("../hooks/useComposeRefs.cjs"),_=require("../Field/Field.cjs"),b=require("../Flex/Flex.cjs"),$=require("../Field/FieldLabel.cjs"),v=require("../Field/FieldError.cjs"),V=require("../Field/FieldHint.cjs"),z=require("../themes/utils.cjs"),A=e=>e&&e.__esModule?e:{default:e},B=A(N),P=i.forwardRef(({label:e,error:c,hint:S,labelAction:F,value:x="",required:q=!1,disabled:h=!1,onChange:E=()=>null,...C},R)=>{const f=i.useRef(),l=i.useRef(),u=i.useRef(),j=!!c,k=r=>{const t=l.current?.doc;if(t){const{text:a,to:n}=t.line(r),m=n-a.trimStart().length;n>m&&u.current?.dispatch({effects:d.addMarks.of([d.lineHighlightMark.range(m,n)])})}},I=()=>{const r=l.current?.doc;if(r){const t=r.length||0;u.current?.dispatch({effects:d.filterMarks.of((a,n)=>n<=0||a>=t)})}},g=({state:r,view:t})=>{u.current=t,l.current=r,I();const n=p.jsonParseLinter()(t);n.length&&k(r.doc.lineAt(n[0].from).number)},w=(r,t)=>{g(t),E(r)},H=(r,t)=>{u.current=r,l.current=t,g({view:r,state:t})},{setContainer:M,view:o}=J.useCodeMirror({value:x,onCreateEditor:H,container:f.current,editable:!h,extensions:[p.json(),d.markField],onChange:w,theme:"dark",basicSetup:{lineNumbers:!0,bracketMatching:!0,closeBrackets:!0,indentOnInput:!0,syntaxHighlighting:!0,highlightSelectionMatches:!0,tabSize:2}}),O=()=>{!h&&o&&o.focus()},y=L.useComposedRefs(f,M);return i.useImperativeHandle(R,()=>({...o?.dom,focus(){o&&o.focus()},scrollIntoView(r){o&&o.dom.scrollIntoView(r)}}),[o]),s.jsx(_.Field,{error:c,hint:S,required:q,children:s.jsxs(b.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[e&&s.jsx($.FieldLabel,{onClick:O,action:F,children:e}),s.jsx(D,{ref:y,hasError:j,alignItems:"stretch",fontSize:2,hasRadius:!0,...C}),s.jsx(v.FieldError,{}),s.jsx(V.FieldHint,{})]})})}),D=B.default(b.Flex)`
2
+ line-height: ${({theme:e})=>e.lineHeights[2]};
3
+
4
+ .cm-editor {
5
+ /**
6
+ * Hard coded since the color is the same between themes,
7
+ * theme.colors.neutral800 changes between themes
8
+ */
9
+ background-color: #32324d;
10
+ width: 100%;
11
+ outline: none;
12
+ }
13
+
14
+ .cm-scroller {
15
+ border: 1px solid ${({theme:e,hasError:c})=>c?e.colors.danger600:e.colors.neutral200};
16
+ /* inputFocusStyle will receive hasError prop */
17
+ ${z.inputFocusStyle()}
18
+ }
19
+
20
+ .cm-editor,
21
+ .cm-scroller {
22
+ border-radius: ${({theme:e})=>e.borderRadius};
23
+ }
24
+
25
+ .cm-gutters,
26
+ .cm-activeLineGutter {
27
+ /**
28
+ * Hard coded since the color is the same between themes,
29
+ * theme.colors.neutral700 changes between themes
30
+ */
31
+ background-color: #4a4a6a;
32
+ }
33
+ `;exports.JSONInput=P;
@@ -1,46 +1,48 @@
1
- import { jsx as n, jsxs as O } from "react/jsx-runtime";
2
- import { useRef as l, useEffect as J } from "react";
3
- import { json as j, jsonParseLinter as H } from "@codemirror/lang-json";
4
- import { useCodeMirror as L } from "@uiw/react-codemirror";
5
- import { JSONInputContainer as z } from "./JSONInputContainer.js";
6
- import { markField as A, addMarks as B, lineHighlightMark as R, filterMarks as q } from "./utils/decorationExtension.js";
7
- import { Field as y } from "../Field/Field.js";
8
- import { Flex as P } from "../Flex/Flex.js";
9
- import { FieldLabel as V } from "../Field/FieldLabel.js";
10
- import { FieldError as D } from "../Field/FieldError.js";
11
- import { FieldHint as G } from "../Field/FieldHint.js";
12
- const v = ({ label: a, error: d, hint: g, labelAction: p, value: E = "", required: S = !1, disabled: u = !1, onChange: k = () => null, ...C }) => {
13
- const o = l(), i = l(), c = l(), F = !!d, b = (r) => {
14
- const t = i.current?.doc;
15
- if (t) {
16
- const { text: s, to: e } = t.line(r), m = e - s.trimStart().length;
17
- e > m && c.current?.dispatch({
18
- effects: B.of([R.range(m, e)])
1
+ import { jsx as i, jsxs as J } from "react/jsx-runtime";
2
+ import { forwardRef as j, useRef as d, useImperativeHandle as y } from "react";
3
+ import { json as L, jsonParseLinter as $ } from "@codemirror/lang-json";
4
+ import { useCodeMirror as V } from "@uiw/react-codemirror";
5
+ import v from "styled-components";
6
+ import { markField as z, addMarks as A, lineHighlightMark as B, filterMarks as q } from "./utils/decorationExtension.js";
7
+ import { useComposedRefs as G } from "../hooks/useComposeRefs.js";
8
+ import { Field as P } from "../Field/Field.js";
9
+ import { Flex as g } from "../Flex/Flex.js";
10
+ import { FieldLabel as D } from "../Field/FieldLabel.js";
11
+ import { FieldError as K } from "../Field/FieldError.js";
12
+ import { FieldHint as Q } from "../Field/FieldHint.js";
13
+ import { inputFocusStyle as T } from "../themes/utils.js";
14
+ const lr = j(({ label: t, error: c, hint: p, labelAction: b, value: S = "", required: E = !1, disabled: m = !1, onChange: k = () => null, ...F }, w) => {
15
+ const u = d(), s = d(), l = d(), C = !!c, I = (r) => {
16
+ const e = s.current?.doc;
17
+ if (e) {
18
+ const { text: a, to: n } = e.line(r), f = n - a.trimStart().length;
19
+ n > f && l.current?.dispatch({
20
+ effects: A.of([B.range(f, n)])
19
21
  });
20
22
  }
21
23
  }, x = () => {
22
- const r = i.current?.doc;
24
+ const r = s.current?.doc;
23
25
  if (r) {
24
- const t = r.length || 0;
25
- c.current?.dispatch({
26
- effects: q.of((s, e) => e <= 0 || s >= t)
26
+ const e = r.length || 0;
27
+ l.current?.dispatch({
28
+ effects: q.of((a, n) => n <= 0 || a >= e)
27
29
  });
28
30
  }
29
- }, f = ({ state: r, view: t }) => {
30
- c.current = t, i.current = r, x();
31
- const e = H()(t);
32
- e.length && b(r.doc.lineAt(e[0].from).number);
33
- }, M = (r, t) => {
34
- f(t), k(r);
35
- }, I = (r, t) => {
36
- c.current = r, i.current = t, f({ view: r, state: t });
37
- }, { setContainer: h } = L({
38
- value: E,
39
- onCreateEditor: I,
40
- container: o.current,
41
- editable: !u,
42
- extensions: [j(), A],
43
- onChange: M,
31
+ }, h = ({ state: r, view: e }) => {
32
+ l.current = e, s.current = r, x();
33
+ const n = $()(e);
34
+ n.length && I(r.doc.lineAt(n[0].from).number);
35
+ }, H = (r, e) => {
36
+ h(e), k(r);
37
+ }, M = (r, e) => {
38
+ l.current = r, s.current = e, h({ view: r, state: e });
39
+ }, { setContainer: N, view: o } = V({
40
+ value: S,
41
+ onCreateEditor: M,
42
+ container: u.current,
43
+ editable: !m,
44
+ extensions: [L(), z],
45
+ onChange: H,
44
46
  theme: "dark",
45
47
  basicSetup: {
46
48
  lineNumbers: !0,
@@ -51,14 +53,51 @@ const v = ({ label: a, error: d, hint: g, labelAction: p, value: E = "", require
51
53
  highlightSelectionMatches: !0,
52
54
  tabSize: 2
53
55
  }
54
- }), N = () => {
55
- u || o.current?.children[0].children[1].children[1]?.focus();
56
- };
57
- return J(() => {
58
- const r = o.current;
59
- r && h(r);
60
- }, [h]), n(y, { error: d, hint: g, required: S, children: O(P, { direction: "column", alignItems: "stretch", gap: 1, children: [a && n(V, { onClick: N, action: p, children: a }), n(z, { ref: o, hasError: F, alignItems: "stretch", fontSize: 2, hasRadius: !0, ...C }), n(D, {}), n(G, {})] }) });
61
- };
56
+ }), O = () => {
57
+ !m && o && o.focus();
58
+ }, R = G(u, N);
59
+ return y(w, () => ({
60
+ ...o?.dom,
61
+ focus() {
62
+ o && o.focus();
63
+ },
64
+ scrollIntoView(r) {
65
+ o && o.dom.scrollIntoView(r);
66
+ }
67
+ }), [o]), i(P, { error: c, hint: p, required: E, children: J(g, { direction: "column", alignItems: "stretch", gap: 1, children: [t && i(D, { onClick: O, action: b, children: t }), i(U, { ref: R, hasError: C, alignItems: "stretch", fontSize: 2, hasRadius: !0, ...F }), i(K, {}), i(Q, {})] }) });
68
+ }), U = v(g)`
69
+ line-height: ${({ theme: t }) => t.lineHeights[2]};
70
+
71
+ .cm-editor {
72
+ /**
73
+ * Hard coded since the color is the same between themes,
74
+ * theme.colors.neutral800 changes between themes
75
+ */
76
+ background-color: #32324d;
77
+ width: 100%;
78
+ outline: none;
79
+ }
80
+
81
+ .cm-scroller {
82
+ border: 1px solid ${({ theme: t, hasError: c }) => c ? t.colors.danger600 : t.colors.neutral200};
83
+ /* inputFocusStyle will receive hasError prop */
84
+ ${T()}
85
+ }
86
+
87
+ .cm-editor,
88
+ .cm-scroller {
89
+ border-radius: ${({ theme: t }) => t.borderRadius};
90
+ }
91
+
92
+ .cm-gutters,
93
+ .cm-activeLineGutter {
94
+ /**
95
+ * Hard coded since the color is the same between themes,
96
+ * theme.colors.neutral700 changes between themes
97
+ */
98
+ background-color: #4a4a6a;
99
+ }
100
+ `;
62
101
  export {
63
- v as JSONInput
102
+ lr as JSONInput
64
103
  };
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),M=require("react"),u=require("@floating-ui/react-dom"),z=require("@radix-ui/react-focus-scope"),m=require("@strapi/ui-primitives"),T=require("aria-hidden"),W=require("react-remove-scroll"),A=require("styled-components"),B=require("../DismissibleLayer/index.cjs"),P=require("../helpers/strings.cjs"),H=require("../hooks/useComposeRefs.cjs"),K=require("../hooks/useId.cjs"),N=require("../hooks/useIntersection.cjs"),g=require("../Box/Box.cjs"),U=require("../Portal/Portal.cjs"),V=e=>e&&e.__esModule?e:{default:e};function Z(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const s=Z(M),R=V(A),G=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],J=R.default(g.Box)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),$=require("react"),u=require("@floating-ui/react-dom"),M=require("@radix-ui/react-focus-scope"),m=require("@strapi/ui-primitives"),z=require("aria-hidden"),T=require("react-remove-scroll"),W=require("styled-components"),A=require("../DismissibleLayer/index.cjs"),x=require("../helpers/strings.cjs"),B=require("../hooks/useComposeRefs.cjs"),H=require("../hooks/useId.cjs"),K=require("../hooks/useIntersection.cjs"),g=require("../Box/Box.cjs"),N=require("../Portal/Portal.cjs"),U=e=>e&&e.__esModule?e:{default:e};function V(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const i=V($),P=U(W),Z=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],G=P.default(g.Box)`
2
2
  box-shadow: ${({theme:e})=>e.shadows.filterShadow};
3
3
  z-index: ${({theme:e})=>e.zIndices[0]};
4
4
  border: 1px solid ${({theme:e})=>e.colors.neutral150};
5
- `,E=s.forwardRef(({source:e,children:r,spacing:t=0,fullWidth:n=!1,placement:c="bottom-start",centered:l=!1,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,onFocusOutside:p,...O},S)=>{const[h,k]=s.useState(null),[j,q]=s.useState(void 0),w=s.useRef(!1),{x:C,y:D,reference:v,floating:_,strategy:L}=u.useFloating({strategy:"fixed",placement:l?"bottom":c,middleware:[u.offset({mainAxis:t}),u.shift(),u.flip()],whileElementsMounted:u.autoUpdate});s.useLayoutEffect(()=>{v(e.current)},[e,v]),s.useLayoutEffect(()=>{n&&q(e.current.offsetWidth)},[n,e]),s.useEffect(()=>{if(h)return T.hideOthers(h)},[h]);const x=m.useCallbackRef(a);s.useEffect(()=>{const o=()=>{x()};return window.addEventListener("blur",o),window.addEventListener("resize",o),()=>{window.removeEventListener("blur",o),window.removeEventListener("resize",o)}},[x]);const I=H.useComposedRefs(S,o=>k(o),_);return i.jsx(W.RemoveScroll,{allowPinchZoom:!0,children:i.jsx(z.FocusScope,{asChild:!0,loop:!0,trapped:!0,onUnmountAutoFocus:o=>{o.preventDefault(),w.current||e.current?.focus({preventScroll:!0})},children:i.jsx(B.DismissibleLayer,{asChild:!0,onEscapeKeyDown:d,onPointerDownOutside:m.composeEventHandlers(f,o=>{const b=o.detail.originalEvent,$=b.button===0&&b.ctrlKey===!0,F=b.button===2||$;w.current=F},{checkForDefaultPrevented:!1}),onFocusOutside:m.composeEventHandlers(p,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:a,children:i.jsx(J,{ref:I,style:{left:C,top:D,position:L,width:j||void 0},hasRadius:!0,background:"neutral0",padding:1,...O,children:r})})})})}),y=({children:e,intersectionId:r,onReachEnd:t,...n})=>{const c=s.useRef(null),l=K.useId();return N.useIntersection(c,t??(()=>{}),{selectorToWatch:`#${P.stripReactIdOfColon(l)}`,skipWhen:!r||!t}),i.jsxs(Q,{ref:c,...n,children:[e,r&&t&&i.jsx(g.Box,{id:P.stripReactIdOfColon(l),width:"100%",height:"1px"})]})},Q=R.default(g.Box)`
5
+ `,R=i.forwardRef(({source:e,children:o,spacing:t=0,fullWidth:n=!1,placement:c="bottom-start",centered:l=!1,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,onFocusOutside:p,...y},O)=>{const[h,S]=i.useState(null),[k,j]=i.useState(void 0),w=i.useRef(!1),{x:q,y:C,refs:D,strategy:_}=u.useFloating({strategy:"fixed",placement:l?"bottom":c,middleware:[u.offset({mainAxis:t}),u.shift(),u.flip()],elements:{reference:e.current},whileElementsMounted:u.autoUpdate});i.useLayoutEffect(()=>{n&&j(e.current.offsetWidth)},[n,e]),i.useEffect(()=>{if(h)return z.hideOthers(h)},[h]);const v=m.useCallbackRef(a);i.useEffect(()=>{const r=()=>{v()};return window.addEventListener("blur",r),window.addEventListener("resize",r),()=>{window.removeEventListener("blur",r),window.removeEventListener("resize",r)}},[v]);const L=B.useComposedRefs(O,r=>S(r),D.setFloating);return s.jsx(T.RemoveScroll,{allowPinchZoom:!0,children:s.jsx(M.FocusScope,{asChild:!0,loop:!0,trapped:!0,onUnmountAutoFocus:r=>{r.preventDefault(),w.current||e.current?.focus({preventScroll:!0})},children:s.jsx(A.DismissibleLayer,{asChild:!0,onEscapeKeyDown:d,onPointerDownOutside:m.composeEventHandlers(f,r=>{const b=r.detail.originalEvent,F=b.button===0&&b.ctrlKey===!0,I=b.button===2||F;w.current=I},{checkForDefaultPrevented:!1}),onFocusOutside:m.composeEventHandlers(p,r=>r.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:a,children:s.jsx(G,{ref:L,style:{left:q,top:C,position:_,width:k||void 0},hasRadius:!0,background:"neutral0",padding:1,...y,children:o})})})})}),E=({children:e,intersectionId:o,onReachEnd:t,...n})=>{const c=i.useRef(null),l=H.useId();return K.useIntersection(c,t??(()=>{}),{selectorToWatch:`#${x.stripReactIdOfColon(l)}`,skipWhen:!o||!t}),s.jsxs(J,{ref:c,...n,children:[e,o&&t&&s.jsx(g.Box,{id:x.stripReactIdOfColon(l),width:"100%",height:"1px"})]})},J=P.default(g.Box)`
6
6
  // 16 is base base size, 3 is the factor to get closer to 40px and 5 is the number of elements visible in the list
7
7
  max-height: ${3*5}rem;
8
8
  overflow-y: auto;
@@ -22,4 +22,4 @@
22
22
  border-radius: ${({theme:e})=>e.borderRadius};
23
23
  margin-right: 10px;
24
24
  }
25
- `,X=({children:e,source:r,spacing:t,fullWidth:n,placement:c,centered:l,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,...p})=>i.jsx(U.Portal,{children:i.jsx(E,{source:r,spacing:t,fullWidth:n,placement:c,centered:l,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,children:i.jsx(y,{...p,children:e})})});exports.Content=E;exports.POPOVER_PLACEMENTS=G;exports.Popover=X;exports.Scrolling=y;
25
+ `,Q=({children:e,source:o,spacing:t,fullWidth:n,placement:c,centered:l,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,...p})=>s.jsx(N.Portal,{children:s.jsx(R,{source:o,spacing:t,fullWidth:n,placement:c,centered:l,onEscapeKeyDown:d,onPointerDownOutside:f,onDismiss:a,children:s.jsx(E,{...p,children:e})})});exports.Content=R;exports.POPOVER_PLACEMENTS=Z;exports.Popover=Q;exports.Scrolling=E;
@@ -1,19 +1,19 @@
1
- import { jsx as r, jsxs as I } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as z } from "react/jsx-runtime";
2
2
  import * as o from "react";
3
- import { useFloating as W, offset as A, shift as K, flip as j, autoUpdate as M } from "@floating-ui/react-dom";
4
- import { FocusScope as T } from "@radix-ui/react-focus-scope";
5
- import { useCallbackRef as U, composeEventHandlers as v } from "@strapi/ui-primitives";
6
- import { hideOthers as B } from "aria-hidden";
7
- import { RemoveScroll as H } from "react-remove-scroll";
8
- import k from "styled-components";
9
- import { DismissibleLayer as N } from "../DismissibleLayer/index.js";
10
- import { stripReactIdOfColon as x } from "../helpers/strings.js";
11
- import { useComposedRefs as V } from "../hooks/useComposeRefs.js";
12
- import { useId as Z } from "../hooks/useId.js";
13
- import { useIntersection as _ } from "../hooks/useIntersection.js";
3
+ import { useFloating as I, offset as W, shift as A, flip as K, autoUpdate as j } from "@floating-ui/react-dom";
4
+ import { FocusScope as M } from "@radix-ui/react-focus-scope";
5
+ import { useCallbackRef as T, composeEventHandlers as g } from "@strapi/ui-primitives";
6
+ import { hideOthers as U } from "aria-hidden";
7
+ import { RemoveScroll as B } from "react-remove-scroll";
8
+ import x from "styled-components";
9
+ import { DismissibleLayer as H } from "../DismissibleLayer/index.js";
10
+ import { stripReactIdOfColon as v } from "../helpers/strings.js";
11
+ import { useComposedRefs as N } from "../hooks/useComposeRefs.js";
12
+ import { useId as V } from "../hooks/useId.js";
13
+ import { useIntersection as Z } from "../hooks/useIntersection.js";
14
14
  import { Box as h } from "../Box/Box.js";
15
- import { Portal as q } from "../Portal/Portal.js";
16
- const me = [
15
+ import { Portal as _ } from "../Portal/Portal.js";
16
+ const ue = [
17
17
  "top",
18
18
  "top-start",
19
19
  "top-end",
@@ -26,42 +26,43 @@ const me = [
26
26
  "left",
27
27
  "left-start",
28
28
  "left-end"
29
- ], G = k(h)`
29
+ ], q = x(h)`
30
30
  box-shadow: ${({ theme: e }) => e.shadows.filterShadow};
31
31
  z-index: ${({ theme: e }) => e.zIndices[0]};
32
32
  border: 1px solid ${({ theme: e }) => e.colors.neutral150};
33
- `, J = o.forwardRef(({ source: e, children: s, spacing: n = 0, fullWidth: i = !1, placement: l = "bottom-start", centered: a = !1, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, onFocusOutside: u, ...E }, R) => {
34
- const [m, y] = o.useState(null), [P, C] = o.useState(void 0), b = o.useRef(!1), { x: D, y: L, reference: w, floating: S, strategy: O } = W({
33
+ `, G = o.forwardRef(({ source: e, children: s, spacing: n = 0, fullWidth: i = !1, placement: l = "bottom-start", centered: a = !1, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, onFocusOutside: u, ...k }, E) => {
34
+ const [m, R] = o.useState(null), [P, y] = o.useState(void 0), b = o.useRef(!1), { x: C, y: D, refs: S, strategy: L } = I({
35
35
  strategy: "fixed",
36
36
  placement: a ? "bottom" : l,
37
37
  middleware: [
38
- A({
38
+ W({
39
39
  mainAxis: n
40
40
  }),
41
- K(),
42
- j()
41
+ A(),
42
+ K()
43
43
  ],
44
- whileElementsMounted: M
44
+ elements: {
45
+ reference: e.current
46
+ },
47
+ whileElementsMounted: j
45
48
  });
46
49
  o.useLayoutEffect(() => {
47
- w(e.current);
48
- }, [e, w]), o.useLayoutEffect(() => {
49
- i && C(e.current.offsetWidth);
50
+ i && y(e.current.offsetWidth);
50
51
  }, [i, e]), o.useEffect(() => {
51
52
  if (m)
52
- return B(m);
53
+ return U(m);
53
54
  }, [m]);
54
- const g = U(c);
55
+ const w = T(c);
55
56
  o.useEffect(() => {
56
57
  const t = () => {
57
- g();
58
+ w();
58
59
  };
59
60
  return window.addEventListener("blur", t), window.addEventListener("resize", t), () => {
60
61
  window.removeEventListener("blur", t), window.removeEventListener("resize", t);
61
62
  };
62
- }, [g]);
63
- const $ = V(R, (t) => y(t), S);
64
- return r(H, { allowPinchZoom: !0, children: r(T, {
63
+ }, [w]);
64
+ const O = N(E, (t) => R(t), S.setFloating);
65
+ return r(B, { allowPinchZoom: !0, children: r(M, {
65
66
  asChild: !0,
66
67
  loop: !0,
67
68
  // we make sure we're not trapping once it's been closed
@@ -70,35 +71,35 @@ const me = [
70
71
  onUnmountAutoFocus: (t) => {
71
72
  t.preventDefault(), b.current || e.current?.focus({ preventScroll: !0 });
72
73
  },
73
- children: r(N, {
74
+ children: r(H, {
74
75
  asChild: !0,
75
76
  onEscapeKeyDown: d,
76
- onPointerDownOutside: v(f, (t) => {
77
- const p = t.detail.originalEvent, F = p.button === 0 && p.ctrlKey === !0, z = p.button === 2 || F;
78
- b.current = z;
77
+ onPointerDownOutside: g(f, (t) => {
78
+ const p = t.detail.originalEvent, $ = p.button === 0 && p.ctrlKey === !0, F = p.button === 2 || $;
79
+ b.current = F;
79
80
  }, { checkForDefaultPrevented: !1 }),
80
81
  // When focus is trapped, a `focusout` event may still happen.
81
82
  // We make sure we don't trigger our `onDismiss` in such case.
82
- onFocusOutside: v(u, (t) => t.preventDefault(), {
83
+ onFocusOutside: g(u, (t) => t.preventDefault(), {
83
84
  checkForDefaultPrevented: !1
84
85
  }),
85
86
  onDismiss: c,
86
- children: r(G, { ref: $, style: {
87
- left: D,
88
- top: L,
89
- position: O,
87
+ children: r(q, { ref: O, style: {
88
+ left: C,
89
+ top: D,
90
+ position: L,
90
91
  width: P || void 0
91
- }, hasRadius: !0, background: "neutral0", padding: 1, ...E, children: s })
92
+ }, hasRadius: !0, background: "neutral0", padding: 1, ...k, children: s })
92
93
  })
93
94
  }) });
94
- }), Q = ({ children: e, intersectionId: s, onReachEnd: n, ...i }) => {
95
- const l = o.useRef(null), a = Z();
96
- return _(l, n ?? (() => {
95
+ }), J = ({ children: e, intersectionId: s, onReachEnd: n, ...i }) => {
96
+ const l = o.useRef(null), a = V();
97
+ return Z(l, n ?? (() => {
97
98
  }), {
98
- selectorToWatch: `#${x(a)}`,
99
+ selectorToWatch: `#${v(a)}`,
99
100
  skipWhen: !s || !n
100
- }), I(X, { ref: l, ...i, children: [e, s && n && r(h, { id: x(a), width: "100%", height: "1px" })] });
101
- }, X = k(h)`
101
+ }), z(Q, { ref: l, ...i, children: [e, s && n && r(h, { id: v(a), width: "100%", height: "1px" })] });
102
+ }, Q = x(h)`
102
103
  // 16 is base base size, 3 is the factor to get closer to 40px and 5 is the number of elements visible in the list
103
104
  max-height: ${3 * 5}rem;
104
105
  overflow-y: auto;
@@ -118,10 +119,10 @@ const me = [
118
119
  border-radius: ${({ theme: e }) => e.borderRadius};
119
120
  margin-right: 10px;
120
121
  }
121
- `, pe = ({ children: e, source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, ...u }) => r(q, { children: r(J, { source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, children: r(Q, { ...u, children: e }) }) });
122
+ `, me = ({ children: e, source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, ...u }) => r(_, { children: r(G, { source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, children: r(J, { ...u, children: e }) }) });
122
123
  export {
123
- J as Content,
124
- me as POPOVER_PLACEMENTS,
125
- pe as Popover,
126
- Q as Scrolling
124
+ G as Content,
125
+ ue as POPOVER_PLACEMENTS,
126
+ me as Popover,
127
+ J as Scrolling
127
128
  };
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),Y=require("react"),J=require("@strapi/icons"),I=require("styled-components"),o=require("./SelectParts.cjs"),K=require("../BaseCheckbox/assets/checkmark.svg.cjs"),Q=require("../helpers/strings.cjs"),w=require("../hooks/useId.cjs"),U=require("../hooks/useIntersection.cjs"),Z=require("../Tag/Tag.cjs"),j=require("../Box/Box.cjs"),C=require("../Typography/Typography.cjs"),ee=require("../Field/Field.cjs"),te=require("../Flex/Flex.cjs"),re=require("../Field/FieldLabel.cjs"),ne=require("../Field/FieldHint.cjs"),ie=require("../Field/FieldError.cjs"),oe=e=>e&&e.__esModule?e:{default:e};function le(e){if(e&&e.__esModule)return e;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(i,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return i.default=e,Object.freeze(i)}const a=le(Y),se=oe(I),ce=({children:e,clearLabel:i="Clear",customizeContent:r,disabled:l,error:s,hint:d,id:u,label:p,labelAction:T,onChange:f,onClear:M,onReachEnd:b,placeholder:F,required:y,selectButtonTitle:ue,startIcon:_,size:B="M",value:h,withTags:q,...L})=>{const m=a.useRef(null),[$,S]=a.useState(),[P,V]=a.useState(!1),x=w.useId(u),z=`${x}-hint`,E=`${x}-error`,G=n=>{f?f(n):S(n)},A=n=>()=>{const O=Array.isArray(h)?h.filter(g=>g!==n):($??[]).filter(g=>g!==n);f?f(O):S(O)},D=n=>{V(n)},k=a.useRef(null),H=()=>{k.current.focus()},W=w.useId(),v=`intersection-${Q.stripReactIdOfColon(W)}`,N=n=>{b&&b(n)};U.useIntersection(m,N,{selectorToWatch:`#${v}`,skipWhen:!P});const c=typeof h<"u"&&h!==null?h:$,X=n=>n&&typeof n=="object"&&n.value?t.jsx(Z.Tag,{tabIndex:-1,disabled:l,icon:t.jsx(J.Cross,{}),onClick:A(n.value),children:n.textValue},n.value):null;return t.jsx(ee.Field,{hint:d,error:s,id:x,required:y,children:t.jsxs(te.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t.jsx(re.FieldLabel,{onClick:H,action:T,children:p}),t.jsxs(o.Root,{onOpenChange:D,disabled:l,required:y,onValueChange:G,value:c,...L,multi:!0,children:[t.jsx(o.Trigger,{ref:k,"aria-label":p,"aria-describedby":`${z} ${E}`,id:x,startIcon:_,size:B,hasError:!!s,disabled:l,clearLabel:i,onClear:c?.length?M:void 0,paddingLeft:q&&c?.length?1:3,children:t.jsx(o.Value,{placeholder:F,textColor:c?.length?"neutral800":"neutral600",children:c?.length?q?X:r?r(c):void 0:void 0})}),t.jsx(o.Portal,{children:t.jsx(o.Content,{position:"popper",sideOffset:4,children:t.jsxs(o.Viewport,{ref:m,children:[e,t.jsx(j.Box,{id:v,width:"100%",height:"1px"})]})})})]}),t.jsx(ne.FieldHint,{}),t.jsx(ie.FieldError,{})]})})},ae=a.forwardRef(({value:e,children:i,startIcon:r,...l},s)=>t.jsxs(o.Item,{ref:s,value:e.toString(),...l,children:[r&&t.jsx(j.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:d,isIntermediate:u})=>t.jsx(R,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:u,$selected:d,zIndex:1,height:"18px",width:"18px"})}),t.jsx(C.Typography,{textColor:"neutral800",children:t.jsx(o.ItemText,{children:i})})]})),R=se.default(j.Box)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),Q=require("react"),U=require("@strapi/icons"),b=require("styled-components"),i=require("./SelectParts.cjs"),Z=require("../BaseCheckbox/assets/checkmark.svg.cjs"),ee=require("../helpers/strings.cjs"),te=require("../hooks/useComposeRefs.cjs"),w=require("../hooks/useId.cjs"),re=require("../hooks/useIntersection.cjs"),ne=require("../Tag/Tag.cjs"),oe=require("../Field/Field.cjs"),ie=require("../Flex/Flex.cjs"),le=require("../Field/FieldLabel.cjs"),x=require("../Box/Box.cjs"),se=require("../Field/FieldHint.cjs"),ce=require("../Field/FieldError.cjs"),O=require("../Typography/Typography.cjs"),ae=e=>e&&e.__esModule?e:{default:e};function de(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const c=de(Q),ue=ae(b),he=c.forwardRef(({"aria-label":e,children:o,clearLabel:r="Clear",customizeContent:l,disabled:s,error:a,hint:u,id:g,label:j,labelAction:M,onChange:p,onClear:F,onReachEnd:y,placeholder:_,required:m,selectButtonTitle:xe,startIcon:B,size:L="M",value:h,withTags:q,...P},V)=>{const R=c.useRef(null),[$,C]=c.useState(),[z,E]=c.useState(!1),f=w.useId(g),G=`${f}-hint`,A=`${f}-error`,D=n=>{p?p(n):C(n)},H=n=>()=>{const v=Array.isArray(h)?h.filter(I=>I!==n):($??[]).filter(I=>I!==n);p?p(v):C(v)},W=n=>{E(n)},S=c.useRef(null),N=()=>{S.current.focus()},X=w.useId(),k=`intersection-${ee.stripReactIdOfColon(X)}`,Y=n=>{y&&y(n)};re.useIntersection(R,Y,{selectorToWatch:`#${k}`,skipWhen:!z});const d=typeof h<"u"&&h!==null?h:$,J=n=>n&&typeof n=="object"&&n.value?t.jsx(ne.Tag,{tabIndex:-1,disabled:s,icon:t.jsx(U.Cross,{}),onClick:H(n.value),children:n.textValue},n.value):null,K=te.useComposedRefs(S,V);return t.jsx(oe.Field,{hint:u,error:a,id:f,required:m,children:t.jsxs(ie.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[j?t.jsx(le.FieldLabel,{onClick:N,action:M,children:j}):null,t.jsxs(i.Root,{onOpenChange:W,disabled:s,required:m,onValueChange:D,value:d,...P,multi:!0,children:[t.jsx(i.Trigger,{ref:K,"aria-label":j??e,"aria-describedby":`${G} ${A}`,id:f,startIcon:B,size:L,hasError:!!a,disabled:s,clearLabel:r,onClear:d?.length?F:void 0,paddingLeft:q&&d?.length?1:3,children:t.jsx(i.Value,{placeholder:_,textColor:d?.length?"neutral800":"neutral600",children:d?.length?q?J:l?l(d):void 0:void 0})}),t.jsx(i.Portal,{children:t.jsx(i.Content,{position:"popper",sideOffset:4,children:t.jsxs(i.Viewport,{ref:R,children:[o,t.jsx(x.Box,{id:k,width:"100%",height:"1px"})]})})})]}),t.jsx(se.FieldHint,{}),t.jsx(ce.FieldError,{})]})})}),pe=c.forwardRef(({value:e,children:o,startIcon:r,...l},s)=>t.jsxs(i.Item,{ref:s,value:e.toString(),...l,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(i.ItemIndicator,{children:({isSelected:a,isIntermediate:u})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:u,$selected:a,zIndex:1,height:"18px",width:"18px"})}),t.jsx(O.Typography,{textColor:"neutral800",children:t.jsx(i.ItemText,{children:o})})]})),T=ue.default(x.Box)`
2
2
  border: 1px solid
3
- ${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral300};
4
- background-color: ${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral0};
3
+ ${({theme:e,$selected:o,$indeterminate:r})=>o||r?e.colors.primary600:e.colors.neutral300};
4
+ background-color: ${({theme:e,$selected:o,$indeterminate:r})=>o||r?e.colors.primary600:e.colors.neutral0};
5
5
 
6
- ${({theme:e,$indeterminate:i})=>i&&I.css`
6
+ ${({theme:e,$indeterminate:o})=>o&&b.css`
7
7
  &::after {
8
8
  content: '';
9
9
  display: block;
@@ -18,13 +18,13 @@
18
18
  }
19
19
  `}
20
20
 
21
- ${({$selected:e})=>e&&I.css`
21
+ ${({$selected:e})=>e&&b.css`
22
22
  &::after {
23
23
  content: '';
24
- background: url(${K}) no-repeat no-repeat center center;
24
+ background: url(${Z}) no-repeat no-repeat center center;
25
25
  width: 100%;
26
26
  height: 100%;
27
27
  position: absolute;
28
28
  }
29
29
  `}
30
- `,de=a.forwardRef(({children:e,label:i,startIcon:r,values:l=[],...s},d)=>t.jsxs(o.Group,{ref:d,children:[t.jsxs(o.Item,{value:l,...s,children:[r&&t.jsx(j.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:u,isIntermediate:p})=>t.jsx(R,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:p,$selected:u,zIndex:1,height:"18px",width:"18px"})}),t.jsx(C.Typography,{textColor:"neutral800",children:i})]}),e]}));exports.MultiSelect=ce;exports.MultiSelectGroup=de;exports.MultiSelectOption=ae;
30
+ `,fe=c.forwardRef(({children:e,label:o,startIcon:r,values:l=[],...s},a)=>t.jsxs(i.Group,{ref:a,children:[t.jsxs(i.Item,{value:l,...s,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(i.ItemIndicator,{children:({isSelected:u,isIntermediate:g})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:g,$selected:u,zIndex:1,height:"18px",width:"18px"})}),t.jsx(O.Typography,{textColor:"neutral800",children:o})]}),e]}));exports.MultiSelect=he;exports.MultiSelectGroup=fe;exports.MultiSelectOption=pe;
@@ -1,49 +1,50 @@
1
- import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import { Cross as K } from "@strapi/icons";
4
- import N, { css as T } from "styled-components";
5
- import { Item as S, ItemIndicator as F, ItemText as Q, Group as U, Root as Z, Trigger as ee, Value as re, Portal as te, Content as ne, Viewport as oe } from "./SelectParts.js";
6
- import ie from "../BaseCheckbox/assets/checkmark.svg.js";
7
- import { stripReactIdOfColon as le } from "../helpers/strings.js";
8
- import { useId as O } from "../hooks/useId.js";
9
- import { useIntersection as ce } from "../hooks/useIntersection.js";
10
- import { Tag as de } from "../Tag/Tag.js";
11
- import { Box as g } from "../Box/Box.js";
12
- import { Typography as M } from "../Typography/Typography.js";
13
- import { Field as ae } from "../Field/Field.js";
14
- import { Flex as se } from "../Flex/Flex.js";
15
- import { FieldLabel as he } from "../Field/FieldLabel.js";
16
- import { FieldHint as ue } from "../Field/FieldHint.js";
17
- import { FieldError as pe } from "../Field/FieldError.js";
18
- const Be = ({ children: t, clearLabel: o = "Clear", customizeContent: n, disabled: i, error: l, hint: s, id: h, label: p, labelAction: L, onChange: f, onClear: V, onReachEnd: I, placeholder: j, required: $, selectButtonTitle: fe, startIcon: E, size: z = "M", value: u, withTags: b, ...A }) => {
19
- const k = d.useRef(null), [C, v] = d.useState(), [G, W] = d.useState(!1), m = O(h), q = `${m}-hint`, H = `${m}-error`, P = (r) => {
20
- f ? f(r) : v(r);
21
- }, X = (r) => () => {
22
- const y = Array.isArray(u) ? u.filter((x) => x !== r) : (C ?? []).filter((x) => x !== r);
23
- f ? f(y) : v(y);
24
- }, Y = (r) => {
25
- W(r);
26
- }, w = d.useRef(null), _ = () => {
27
- w.current.focus();
28
- }, D = O(), R = `intersection-${le(D)}`;
29
- ce(k, (r) => {
30
- I && I(r);
1
+ import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import { Cross as U } from "@strapi/icons";
4
+ import Z, { css as O } from "styled-components";
5
+ import { Root as ee, Trigger as re, Value as te, Portal as ne, Content as oe, Viewport as ie, Item as F, ItemIndicator as M, ItemText as le, Group as de } from "./SelectParts.js";
6
+ import ce from "../BaseCheckbox/assets/checkmark.svg.js";
7
+ import { stripReactIdOfColon as ae } from "../helpers/strings.js";
8
+ import { useComposedRefs as se } from "../hooks/useComposeRefs.js";
9
+ import { useId as S } from "../hooks/useId.js";
10
+ import { useIntersection as he } from "../hooks/useIntersection.js";
11
+ import { Tag as pe } from "../Tag/Tag.js";
12
+ import { Field as ue } from "../Field/Field.js";
13
+ import { Flex as fe } from "../Flex/Flex.js";
14
+ import { FieldLabel as me } from "../Field/FieldLabel.js";
15
+ import { Box as m } from "../Box/Box.js";
16
+ import { FieldHint as ge } from "../Field/FieldHint.js";
17
+ import { FieldError as xe } from "../Field/FieldError.js";
18
+ import { Typography as B } from "../Typography/Typography.js";
19
+ const ze = l.forwardRef(({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeContent: d, disabled: i, error: c, hint: h, id: g, label: x, labelAction: V, onChange: u, onClear: j, onReachEnd: $, placeholder: E, required: R, selectButtonTitle: Ie, startIcon: z, size: A = "M", value: p, withTags: b, ...G }, W) => {
20
+ const C = l.useRef(null), [k, w] = l.useState(), [q, H] = l.useState(!1), f = S(g), P = `${f}-hint`, X = `${f}-error`, Y = (r) => {
21
+ u ? u(r) : w(r);
22
+ }, _ = (r) => () => {
23
+ const T = Array.isArray(p) ? p.filter((I) => I !== r) : (k ?? []).filter((I) => I !== r);
24
+ u ? u(T) : w(T);
25
+ }, D = (r) => {
26
+ H(r);
27
+ }, v = l.useRef(null), J = () => {
28
+ v.current.focus();
29
+ }, K = S(), y = `intersection-${ae(K)}`;
30
+ he(C, (r) => {
31
+ $ && $(r);
31
32
  }, {
32
- selectorToWatch: `#${R}`,
33
+ selectorToWatch: `#${y}`,
33
34
  /**
34
35
  * We need to know when the select is open because only then will viewportRef
35
36
  * not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
36
37
  */
37
- skipWhen: !G
38
+ skipWhen: !q
38
39
  });
39
- const c = typeof u < "u" && u !== null ? u : C, J = (r) => r && typeof r == "object" && r.value ? e(de, { tabIndex: -1, disabled: i, icon: e(K, {}), onClick: X(r.value), children: r.textValue }, r.value) : null;
40
- return e(ae, { hint: s, error: l, id: m, required: $, children: a(se, { direction: "column", alignItems: "stretch", gap: 1, children: [e(he, { onClick: _, action: L, children: p }), a(Z, { onOpenChange: Y, disabled: i, required: $, onValueChange: P, value: c, ...A, multi: !0, children: [e(ee, { ref: w, "aria-label": p, "aria-describedby": `${q} ${H}`, id: m, startIcon: E, size: z, hasError: !!l, disabled: i, clearLabel: o, onClear: c?.length ? V : void 0, paddingLeft: b && c?.length ? 1 : 3, children: e(re, { placeholder: j, textColor: c?.length ? "neutral800" : "neutral600", children: c?.length ? b ? J : n ? n(c) : void 0 : void 0 }) }), e(te, { children: e(ne, { position: "popper", sideOffset: 4, children: a(oe, { ref: k, children: [t, e(g, { id: R, width: "100%", height: "1px" })] }) }) })] }), e(ue, {}), e(pe, {})] }) });
41
- }, Le = d.forwardRef(({ value: t, children: o, startIcon: n, ...i }, l) => a(S, { ref: l, value: t.toString(), ...i, children: [n && e(g, { as: "span", "aria-hidden": !0, children: n }), e(F, { children: ({ isSelected: s, isIntermediate: h }) => e(B, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: h, $selected: s, zIndex: 1, height: "18px", width: "18px" }) }), e(M, { textColor: "neutral800", children: e(Q, { children: o }) })] })), B = N(g)`
40
+ const a = typeof p < "u" && p !== null ? p : k, N = (r) => r && typeof r == "object" && r.value ? e(pe, { tabIndex: -1, disabled: i, icon: e(U, {}), onClick: _(r.value), children: r.textValue }, r.value) : null, Q = se(v, W);
41
+ return e(ue, { hint: h, error: c, id: f, required: R, children: s(fe, { direction: "column", alignItems: "stretch", gap: 1, children: [x ? e(me, { onClick: J, action: V, children: x }) : null, s(ee, { onOpenChange: D, disabled: i, required: R, onValueChange: Y, value: a, ...G, multi: !0, children: [e(re, { ref: Q, "aria-label": x ?? t, "aria-describedby": `${P} ${X}`, id: f, startIcon: z, size: A, hasError: !!c, disabled: i, clearLabel: o, onClear: a?.length ? j : void 0, paddingLeft: b && a?.length ? 1 : 3, children: e(te, { placeholder: E, textColor: a?.length ? "neutral800" : "neutral600", children: a?.length ? b ? N : d ? d(a) : void 0 : void 0 }) }), e(ne, { children: e(oe, { position: "popper", sideOffset: 4, children: s(ie, { ref: C, children: [n, e(m, { id: y, width: "100%", height: "1px" })] }) }) })] }), e(ge, {}), e(xe, {})] }) });
42
+ }), Ae = l.forwardRef(({ value: t, children: n, startIcon: o, ...d }, i) => s(F, { ref: i, value: t.toString(), ...d, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: c, isIntermediate: h }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: h, $selected: c, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: e(le, { children: n }) })] })), L = Z(m)`
42
43
  border: 1px solid
43
- ${({ theme: t, $selected: o, $indeterminate: n }) => o || n ? t.colors.primary600 : t.colors.neutral300};
44
- background-color: ${({ theme: t, $selected: o, $indeterminate: n }) => o || n ? t.colors.primary600 : t.colors.neutral0};
44
+ ${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral300};
45
+ background-color: ${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral0};
45
46
 
46
- ${({ theme: t, $indeterminate: o }) => o && T`
47
+ ${({ theme: t, $indeterminate: n }) => n && O`
47
48
  &::after {
48
49
  content: '';
49
50
  display: block;
@@ -58,18 +59,18 @@ const Be = ({ children: t, clearLabel: o = "Clear", customizeContent: n, disable
58
59
  }
59
60
  `}
60
61
 
61
- ${({ $selected: t }) => t && T`
62
+ ${({ $selected: t }) => t && O`
62
63
  &::after {
63
64
  content: '';
64
- background: url(${ie}) no-repeat no-repeat center center;
65
+ background: url(${ce}) no-repeat no-repeat center center;
65
66
  width: 100%;
66
67
  height: 100%;
67
68
  position: absolute;
68
69
  }
69
70
  `}
70
- `, Ve = d.forwardRef(({ children: t, label: o, startIcon: n, values: i = [], ...l }, s) => a(U, { ref: s, children: [a(S, { value: i, ...l, children: [n && e(g, { as: "span", "aria-hidden": !0, children: n }), e(F, { children: ({ isSelected: h, isIntermediate: p }) => e(B, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: p, $selected: h, zIndex: 1, height: "18px", width: "18px" }) }), e(M, { textColor: "neutral800", children: o })] }), t] }));
71
+ `, Ge = l.forwardRef(({ children: t, label: n, startIcon: o, values: d = [], ...i }, c) => s(de, { ref: c, children: [s(F, { value: d, ...i, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: h, isIntermediate: g }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: g, $selected: h, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: n })] }), t] }));
71
72
  export {
72
- Be as MultiSelect,
73
- Ve as MultiSelectGroup,
74
- Le as MultiSelectOption
73
+ ze as MultiSelect,
74
+ Ge as MultiSelectGroup,
75
+ Ae as MultiSelectOption
75
76
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),N=require("react"),o=require("./SelectParts.cjs"),E=require("../helpers/strings.cjs"),b=require("../hooks/useId.cjs"),V=require("../hooks/useIntersection.cjs"),q=require("../Box/Box.cjs"),H=require("../Typography/Typography.cjs"),W=require("../Field/Field.cjs"),z=require("../Flex/Flex.cjs"),D=require("../Field/FieldLabel.cjs"),A=require("../Field/FieldHint.cjs"),G=require("../Field/FieldError.cjs");function J(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const h=J(N),K=({error:e,hint:n,id:r,label:i,labelAction:s,required:f,selectButtonTitle:x,...d})=>{const c=b.useId(r),u=h.useRef(null),g=()=>{u.current.focus()};return t.jsx(W.Field,{hint:n,error:e,id:c,required:f,children:t.jsxs(z.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t.jsx(D.FieldLabel,{onClick:g,action:s,children:i}),t.jsx(O,{label:i,id:c,triggerRef:u,required:f,...d}),t.jsx(A.FieldHint,{}),t.jsx(G.FieldError,{})]})})},O=({id:e,children:n,clearLabel:r="Clear",customizeContent:i,disabled:s,error:f,label:x,onChange:d,onClear:c,onReachEnd:u,placeholder:g,required:m,selectButtonTitle:U,startIcon:y,size:F="M",value:p,triggerRef:R,...T})=>{const[B,j]=h.useState(),[C,_]=h.useState(!1),$=l=>{_(l)},v=l=>{c&&c(l),d||j("")},w=`${e}-hint`,P=`${e}-error`,k=l=>{d?d(typeof p=="number"?Number(l):l):j(l)},S=h.useRef(null),L=b.useId(),I=`intersection-${E.stripReactIdOfColon(L)}`,M=l=>{u&&u(l)};V.useIntersection(S,M,{selectorToWatch:`#${I}`,skipWhen:!C});const a=(typeof p<"u"&&p!==null?p.toString():B)??"";return t.jsxs(o.Root,{onOpenChange:$,disabled:s,required:m,onValueChange:k,value:a,...T,children:[t.jsx(o.Trigger,{ref:R,"aria-label":x,"aria-describedby":e?`${w} ${P}`:void 0,id:e,startIcon:y,size:F,hasError:!!f,disabled:s,clearLabel:r,onClear:a&&c?v:void 0,children:t.jsx(o.Value,{placeholder:g,textColor:a?"neutral800":"neutral600",children:a&&i?i(a):void 0})}),t.jsx(o.Portal,{children:t.jsx(o.Content,{position:"popper",sideOffset:4,children:t.jsxs(o.Viewport,{ref:S,children:[n,t.jsx(q.Box,{id:I,width:"100%",height:"1px"})]})})})]})},Q=h.forwardRef(({value:e,startIcon:n,children:r,...i},s)=>t.jsxs(o.Item,{ref:s,value:e.toString(),...i,children:[n&&t.jsx(q.Box,{as:"span","aria-hidden":!0,children:n}),t.jsx(H.Typography,{textColor:"neutral800",children:t.jsx(o.ItemText,{children:r})})]}));exports.SingleSelect=K;exports.SingleSelectInput=O;exports.SingleSelectOption=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("react"),s=require("./SelectParts.cjs"),V=require("../helpers/strings.cjs"),H=require("../hooks/useComposeRefs.cjs"),q=require("../hooks/useId.cjs"),W=require("../hooks/useIntersection.cjs"),z=require("../Field/Field.cjs"),D=require("../Flex/Flex.cjs"),A=require("../Field/FieldLabel.cjs"),G=require("../Field/FieldHint.cjs"),J=require("../Field/FieldError.cjs"),O=require("../Box/Box.cjs"),K=require("../Typography/Typography.cjs");function Q(t){if(t&&t.__esModule)return t;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const l=Q(E),U=l.forwardRef(({error:t,hint:r,id:n,label:i,labelAction:c,required:u,selectButtonTitle:S,...g},a)=>{const d=q.useId(n),f=l.useRef(null),x=()=>{f.current.focus()},j=H.useComposedRefs(a,f);return e.jsx(z.Field,{hint:r,error:t,id:d,required:u,children:e.jsxs(D.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[i?e.jsx(A.FieldLabel,{onClick:x,action:c,children:i}):null,e.jsx(R,{label:i,id:d,ref:j,required:u,...g}),e.jsx(G.FieldHint,{}),e.jsx(J.FieldError,{})]})})}),R=l.forwardRef(({"aria-label":t,id:r,children:n,clearLabel:i="Clear",customizeContent:c,disabled:u,error:S,label:g,onChange:a,onClear:d,onReachEnd:f,placeholder:x,required:j,selectButtonTitle:Y,startIcon:y,size:T="M",value:p,...F},B)=>{const[C,I]=l.useState(),[w,_]=l.useState(!1),$=o=>{_(o)},v=o=>{d&&d(o),a||I("")},P=`${r}-hint`,k=`${r}-error`,L=o=>{a?a(typeof p=="number"?Number(o):o):I(o)},b=l.useRef(null),M=q.useId(),m=`intersection-${V.stripReactIdOfColon(M)}`,N=o=>{f&&f(o)};W.useIntersection(b,N,{selectorToWatch:`#${m}`,skipWhen:!w});const h=(typeof p<"u"&&p!==null?p.toString():C)??"";return e.jsxs(s.Root,{onOpenChange:$,disabled:u,required:j,onValueChange:L,value:h,...F,children:[e.jsx(s.Trigger,{ref:B,"aria-label":g??t,"aria-describedby":r?`${P} ${k}`:void 0,id:r,startIcon:y,size:T,hasError:!!S,disabled:u,clearLabel:i,onClear:h&&d?v:void 0,children:e.jsx(s.Value,{placeholder:x,textColor:h?"neutral800":"neutral600",children:h&&c?c(h):void 0})}),e.jsx(s.Portal,{children:e.jsx(s.Content,{position:"popper",sideOffset:4,children:e.jsxs(s.Viewport,{ref:b,children:[n,e.jsx(O.Box,{id:m,width:"100%",height:"1px"})]})})})]})}),X=l.forwardRef(({value:t,startIcon:r,children:n,...i},c)=>e.jsxs(s.Item,{ref:c,value:t.toString(),...i,children:[r&&e.jsx(O.Box,{as:"span","aria-hidden":!0,children:r}),e.jsx(K.Typography,{textColor:"neutral800",children:e.jsx(s.ItemText,{children:n})})]}));exports.SingleSelect=U;exports.SingleSelectInput=R;exports.SingleSelectOption=X;