@strapi/design-system 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button/Button.cjs +2 -2
- package/dist/Button/Button.js +4 -4
- package/dist/Combobox/Combobox.cjs +3 -3
- package/dist/Combobox/Combobox.js +16 -16
- package/dist/DatePicker/DatePicker.cjs +14 -14
- package/dist/DatePicker/DatePicker.js +257 -223
- package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
- package/dist/DateTimePicker/DateTimePicker.js +69 -63
- package/dist/Grid/Grid.cjs +3 -3
- package/dist/Grid/Grid.js +6 -3
- package/dist/MainNav/MainNav.cjs +2 -2
- package/dist/MainNav/MainNav.js +9 -31
- package/dist/MainNav/MainNavContext.cjs +1 -1
- package/dist/MainNav/MainNavContext.js +1 -1
- package/dist/MainNav/NavBrand.cjs +3 -3
- package/dist/MainNav/NavBrand.js +12 -38
- package/dist/MainNav/NavCondense.cjs +2 -2
- package/dist/MainNav/NavCondense.js +15 -23
- package/dist/MainNav/NavFooter.cjs +1 -1
- package/dist/MainNav/NavFooter.js +4 -10
- package/dist/MainNav/NavLink.cjs +9 -9
- package/dist/MainNav/NavLink.js +13 -35
- package/dist/MainNav/NavSection.cjs +1 -1
- package/dist/MainNav/NavSection.js +9 -43
- package/dist/MainNav/NavSections.cjs +2 -2
- package/dist/MainNav/NavSections.js +7 -21
- package/dist/MainNav/NavUser.cjs +2 -2
- package/dist/MainNav/NavUser.js +13 -27
- package/dist/Popover/Popover.cjs +3 -3
- package/dist/Popover/Popover.js +52 -51
- package/dist/Select/MultiSelect.cjs +5 -5
- package/dist/Select/MultiSelect.js +41 -41
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +32 -32
- package/dist/SimpleMenu/SimpleMenu.cjs +9 -9
- package/dist/SimpleMenu/SimpleMenu.js +62 -151
- package/dist/SubNav/SubNav.cjs +5 -5
- package/dist/SubNav/SubNav.js +8 -13
- package/dist/SubNav/SubNavHeader.cjs +3 -3
- package/dist/SubNav/SubNavHeader.js +29 -76
- package/dist/SubNav/SubNavLink.cjs +13 -13
- package/dist/SubNav/SubNavLink.js +20 -52
- package/dist/SubNav/SubNavLinkSection.cjs +4 -4
- package/dist/SubNav/SubNavLinkSection.js +19 -35
- package/dist/SubNav/SubNavSection.cjs +2 -2
- package/dist/SubNav/SubNavSection.js +15 -55
- package/dist/SubNav/SubNavSectionLabel.cjs +3 -3
- package/dist/SubNav/SubNavSectionLabel.js +10 -38
- package/dist/SubNav/SubNavSections.cjs +1 -1
- package/dist/SubNav/SubNavSections.js +4 -18
- package/dist/ToggleInput/ToggleInput.cjs +20 -4
- package/dist/ToggleInput/ToggleInput.js +43 -18
- package/dist/Typography/Typography.cjs +1 -1
- package/dist/Typography/Typography.js +6 -6
- package/dist/Typography/utils.cjs +1 -1
- package/dist/Typography/utils.js +4 -5
- package/dist/v2/Breadcrumbs/Breadcrumbs.cjs +2 -2
- package/dist/v2/Breadcrumbs/Breadcrumbs.js +15 -23
- package/dist/v2/Breadcrumbs/Crumb.cjs +1 -1
- package/dist/v2/Breadcrumbs/Crumb.js +6 -25
- package/dist/v2/Breadcrumbs/CrumbLink.cjs +2 -2
- package/dist/v2/Breadcrumbs/CrumbLink.js +6 -15
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.cjs +4 -3
- package/dist/v2/Breadcrumbs/CrumbSimpleMenu.js +8 -14
- package/dist/v2/Breadcrumbs/Divider.cjs +1 -1
- package/dist/v2/Breadcrumbs/Divider.js +3 -4
- package/dist/v2/SimpleMenu/Menu.cjs +10 -10
- package/dist/v2/SimpleMenu/Menu.js +11 -11
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),x=require("./MainNavContext.cjs"),g=require("../Divider/Divider.cjs"),r=require("../Flex/Flex.cjs"),l=require("../Box/Box.cjs"),p=require("../VisuallyHidden/VisuallyHidden.cjs"),h=require("../Typography/Typography.cjs"),m=n=>n&&n.__esModule?n:{default:n},o=m(u),j=({label:n,children:a,spacing:d=2,horizontal:t=!1,...c})=>x.useMainNav()?e.jsxs(r.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[e.jsxs(l.Box,{paddingTop:1,paddingBottom:1,background:"neutral0",hasRadius:!0,as:"span",children:[e.jsx(g.Divider,{}),e.jsx(p.VisuallyHidden,{children:e.jsx("span",{children:n})})]}),e.jsx(r.Flex,{as:"ul",gap:d,direction:t?"row":"column",alignItems:t?"center":"stretch",...c,children:o.default.Children.map(a,(i,s)=>e.jsx("li",{children:i},s))})]}):e.jsxs(r.Flex,{direction:"column",alignItems:"stretch",gap:2,children:[e.jsx(l.Box,{paddingTop:1,paddingBottom:1,background:"neutral0",paddingRight:3,paddingLeft:3,hasRadius:!0,as:"span",children:e.jsx(h.Typography,{variant:"sigma",textColor:"neutral600",children:n})}),e.jsx(r.Flex,{as:"ul",gap:d,direction:t?"row":"column",alignItems:t?"center":"stretch",...c,children:o.default.Children.map(a,(i,s)=>e.jsx("li",{children:i},s))})]});exports.NavSection=j;
|
|
@@ -1,46 +1,12 @@
|
|
|
1
1
|
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import p from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const x = ({ label: o, children: a, spacing: s = 2, horizontal: e = !1, ...c }) => u() ? /* @__PURE__ */ d(i, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
11
|
-
/* @__PURE__ */ d(l, { paddingTop: 1, paddingBottom: 1, background: "neutral0", hasRadius: !0, as: "span", children: [
|
|
12
|
-
/* @__PURE__ */ r(g, {}),
|
|
13
|
-
/* @__PURE__ */ r(h, { children: /* @__PURE__ */ r("span", { children: o }) })
|
|
14
|
-
] }),
|
|
15
|
-
/* @__PURE__ */ r(
|
|
16
|
-
i,
|
|
17
|
-
{
|
|
18
|
-
as: "ul",
|
|
19
|
-
gap: s,
|
|
20
|
-
direction: e ? "row" : "column",
|
|
21
|
-
alignItems: e ? "center" : "stretch",
|
|
22
|
-
...c,
|
|
23
|
-
children: m.map(a, (n, t) => /* @__PURE__ */ r("li", { children: n }, t))
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
] }) : /* @__PURE__ */ d(i, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
27
|
-
/* @__PURE__ */ r(l, { paddingTop: 1, paddingBottom: 1, background: "neutral0", paddingRight: 3, paddingLeft: 3, hasRadius: !0, as: "span", children: /* @__PURE__ */ r(f, { variant: "sigma", textColor: "neutral600", children: o }) }),
|
|
28
|
-
/* @__PURE__ */ r(
|
|
29
|
-
i,
|
|
30
|
-
{
|
|
31
|
-
as: "ul",
|
|
32
|
-
gap: s,
|
|
33
|
-
direction: e ? "row" : "column",
|
|
34
|
-
alignItems: e ? "center" : "stretch",
|
|
35
|
-
...c,
|
|
36
|
-
children: m.map(a, (n, t) => /* @__PURE__ */ r("li", { children: n }, t))
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
] });
|
|
40
|
-
x.propTypes = {
|
|
41
|
-
children: p.node.isRequired,
|
|
42
|
-
label: p.string.isRequired
|
|
43
|
-
};
|
|
2
|
+
import l from "react";
|
|
3
|
+
import { useMainNav as p } from "./MainNavContext.js";
|
|
4
|
+
import { Divider as u } from "../Divider/Divider.js";
|
|
5
|
+
import { Flex as n } from "../Flex/Flex.js";
|
|
6
|
+
import { Box as s } from "../Box/Box.js";
|
|
7
|
+
import { VisuallyHidden as g } from "../VisuallyHidden/VisuallyHidden.js";
|
|
8
|
+
import { Typography as h } from "../Typography/Typography.js";
|
|
9
|
+
const j = ({ label: a, children: o, spacing: c = 2, horizontal: e = !1, ...m }) => p() ? d(n, { direction: "column", alignItems: "stretch", gap: 2, children: [d(s, { paddingTop: 1, paddingBottom: 1, background: "neutral0", hasRadius: !0, as: "span", children: [r(u, {}), r(g, { children: r("span", { children: a }) })] }), r(n, { as: "ul", gap: c, direction: e ? "row" : "column", alignItems: e ? "center" : "stretch", ...m, children: l.Children.map(o, (i, t) => r("li", { children: i }, t)) })] }) : d(n, { direction: "column", alignItems: "stretch", gap: 2, children: [r(s, { paddingTop: 1, paddingBottom: 1, background: "neutral0", paddingRight: 3, paddingLeft: 3, hasRadius: !0, as: "span", children: r(h, { variant: "sigma", textColor: "neutral600", children: a }) }), r(n, { as: "ul", gap: c, direction: e ? "row" : "column", alignItems: e ? "center" : "stretch", ...m, children: l.Children.map(o, (i, t) => r("li", { children: i }, t)) })] });
|
|
44
10
|
export {
|
|
45
|
-
|
|
11
|
+
j as NavSection
|
|
46
12
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),d=require("styled-components"),a=require("../Box/Box.cjs"),u=require("../Flex/Flex.cjs"),n=e=>e&&e.__esModule?e:{default:e},f=n(c),g=n(d),x=g.default(a.Box)`
|
|
2
2
|
flex-grow: 1;
|
|
3
3
|
overflow-y: auto;
|
|
4
|
-
`,
|
|
4
|
+
`,p=({children:e,spacing:r=4,horizontal:o=!1,...s})=>t.jsx(x,{paddingLeft:3,paddingRight:2,paddingTop:3,paddingBottom:8,children:t.jsx(u.Flex,{as:"ul",gap:r,direction:o?"row":"column",alignItems:o?"center":"stretch",...s,children:f.default.Children.map(e,(i,l)=>t.jsx("li",{children:i},l))})});exports.NavSections=p;
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import m from "prop-types";
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import m from "react";
|
|
4
3
|
import l from "styled-components";
|
|
5
|
-
import { Box as
|
|
6
|
-
import { Flex as
|
|
7
|
-
const
|
|
4
|
+
import { Box as p } from "../Box/Box.js";
|
|
5
|
+
import { Flex as a } from "../Flex/Flex.js";
|
|
6
|
+
const c = l(p)`
|
|
8
7
|
flex-grow: 1;
|
|
9
8
|
overflow-y: auto;
|
|
10
|
-
`,
|
|
11
|
-
c,
|
|
12
|
-
{
|
|
13
|
-
as: "ul",
|
|
14
|
-
gap: i,
|
|
15
|
-
direction: o ? "row" : "column",
|
|
16
|
-
alignItems: o ? "center" : "stretch",
|
|
17
|
-
...t,
|
|
18
|
-
children: d.map(e, (p, n) => /* @__PURE__ */ r("li", { children: p }, n))
|
|
19
|
-
}
|
|
20
|
-
) });
|
|
21
|
-
f.propTypes = {
|
|
22
|
-
children: m.node.isRequired
|
|
23
|
-
};
|
|
9
|
+
`, h = ({ children: t, spacing: e = 4, horizontal: r = !1, ...i }) => o(c, { paddingLeft: 3, paddingRight: 2, paddingTop: 3, paddingBottom: 8, children: o(a, { as: "ul", gap: e, direction: r ? "row" : "column", alignItems: r ? "center" : "stretch", ...i, children: m.Children.map(t, (n, d) => o("li", { children: n }, d)) }) });
|
|
24
10
|
export {
|
|
25
|
-
|
|
11
|
+
h as NavSections
|
|
26
12
|
};
|
package/dist/MainNav/NavUser.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),c=require("styled-components"),x=require("./MainNavContext.cjs"),s=require("../Avatar/Avatar.cjs"),i=require("../Box/Box.cjs"),p=require("../Flex/Flex.cjs"),f=require("../VisuallyHidden/VisuallyHidden.cjs"),h=require("../Typography/Typography.cjs"),o=e=>e&&e.__esModule?e:{default:e},j=o(u),y=o(c),g=y.default(i.Box)`
|
|
2
2
|
border-top: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
3
|
-
`,
|
|
3
|
+
`,q=j.default.forwardRef(({src:e,children:r,initials:a,...d},l)=>{const n=x.useMainNav();return t.jsx(g,{paddingTop:3,paddingBottom:3,paddingLeft:5,paddingRight:5,...d,children:t.jsxs(p.Flex,{as:"button",justifyContent:n?"center":void 0,ref:l,children:[e?t.jsx(s.Avatar,{src:e,alt:"","aria-hidden":!0}):t.jsx(s.Initials,{children:a}),n?t.jsx(f.VisuallyHidden,{children:t.jsx("span",{children:r})}):t.jsx(i.Box,{width:`${130/16}rem`,paddingLeft:2,as:"span",children:t.jsx(h.Typography,{ellipsis:!0,textColor:"neutral600",children:r})})]})})});exports.NavUser=q;
|
package/dist/MainNav/NavUser.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { VisuallyHidden as v } from "../VisuallyHidden/VisuallyHidden.js";
|
|
1
|
+
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import s from "react";
|
|
3
|
+
import l from "styled-components";
|
|
4
|
+
import { useMainNav as m } from "./MainNavContext.js";
|
|
5
|
+
import { Avatar as f, Initials as c } from "../Avatar/Avatar.js";
|
|
6
|
+
import { Box as i } from "../Box/Box.js";
|
|
7
|
+
import { Flex as u } from "../Flex/Flex.js";
|
|
8
|
+
import { VisuallyHidden as h } from "../VisuallyHidden/VisuallyHidden.js";
|
|
10
9
|
import { Typography as x } from "../Typography/Typography.js";
|
|
11
|
-
const
|
|
10
|
+
const g = l(i)`
|
|
12
11
|
border-top: 1px solid ${({ theme: o }) => o.colors.neutral150};
|
|
13
|
-
`,
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
o ? /* @__PURE__ */ r(u, { src: o, alt: "", "aria-hidden": !0 }) : /* @__PURE__ */ r(h, { children: a }),
|
|
17
|
-
d ? /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("span", { children: e }) }) : /* @__PURE__ */ r(n, { width: `${130 / 16}rem`, paddingLeft: 2, as: "span", children: /* @__PURE__ */ r(x, { ellipsis: !0, textColor: "neutral600", children: e }) })
|
|
18
|
-
] }) });
|
|
12
|
+
`, L = s.forwardRef(({ src: o, children: t, initials: n, ...d }, a) => {
|
|
13
|
+
const e = m();
|
|
14
|
+
return r(g, { paddingTop: 3, paddingBottom: 3, paddingLeft: 5, paddingRight: 5, ...d, children: p(u, { as: "button", justifyContent: e ? "center" : void 0, ref: a, children: [o ? r(f, { src: o, alt: "", "aria-hidden": !0 }) : r(c, { children: n }), e ? r(h, { children: r("span", { children: t }) }) : r(i, { width: `${130 / 16}rem`, paddingLeft: 2, as: "span", children: r(x, { ellipsis: !0, textColor: "neutral600", children: t }) })] }) });
|
|
19
15
|
});
|
|
20
|
-
t.displayName = "NavUser";
|
|
21
|
-
t.defaultProps = {
|
|
22
|
-
src: void 0,
|
|
23
|
-
initials: void 0
|
|
24
|
-
};
|
|
25
|
-
t.propTypes = {
|
|
26
|
-
children: i.node.isRequired,
|
|
27
|
-
initials: i.node,
|
|
28
|
-
src: i.string
|
|
29
|
-
};
|
|
30
16
|
export {
|
|
31
|
-
|
|
17
|
+
L as NavUser
|
|
32
18
|
};
|
package/dist/Popover/Popover.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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;
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as z } from "react/jsx-runtime";
|
|
2
2
|
import * as o from "react";
|
|
3
|
-
import { useFloating as
|
|
4
|
-
import { FocusScope as
|
|
5
|
-
import { useCallbackRef as
|
|
6
|
-
import { hideOthers as
|
|
7
|
-
import { RemoveScroll as
|
|
8
|
-
import
|
|
9
|
-
import { DismissibleLayer as
|
|
10
|
-
import { stripReactIdOfColon as
|
|
11
|
-
import { useComposedRefs as
|
|
12
|
-
import { useId as
|
|
13
|
-
import { useIntersection as
|
|
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
|
|
16
|
-
const
|
|
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
|
-
],
|
|
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
|
-
`,
|
|
34
|
-
const [m,
|
|
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
|
-
|
|
38
|
+
W({
|
|
39
39
|
mainAxis: n
|
|
40
40
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
A(),
|
|
42
|
+
K()
|
|
43
43
|
],
|
|
44
|
-
|
|
44
|
+
elements: {
|
|
45
|
+
reference: e.current
|
|
46
|
+
},
|
|
47
|
+
whileElementsMounted: j
|
|
45
48
|
});
|
|
46
49
|
o.useLayoutEffect(() => {
|
|
47
|
-
|
|
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
|
|
53
|
+
return U(m);
|
|
53
54
|
}, [m]);
|
|
54
|
-
const
|
|
55
|
+
const w = T(c);
|
|
55
56
|
o.useEffect(() => {
|
|
56
57
|
const t = () => {
|
|
57
|
-
|
|
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
|
-
}, [
|
|
63
|
-
const
|
|
64
|
-
return r(
|
|
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(
|
|
74
|
+
children: r(H, {
|
|
74
75
|
asChild: !0,
|
|
75
76
|
onEscapeKeyDown: d,
|
|
76
|
-
onPointerDownOutside:
|
|
77
|
-
const p = t.detail.originalEvent,
|
|
78
|
-
b.current =
|
|
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:
|
|
83
|
+
onFocusOutside: g(u, (t) => t.preventDefault(), {
|
|
83
84
|
checkForDefaultPrevented: !1
|
|
84
85
|
}),
|
|
85
86
|
onDismiss: c,
|
|
86
|
-
children: r(
|
|
87
|
-
left:
|
|
88
|
-
top:
|
|
89
|
-
position:
|
|
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, ...
|
|
92
|
+
}, hasRadius: !0, background: "neutral0", padding: 1, ...k, children: s })
|
|
92
93
|
})
|
|
93
94
|
}) });
|
|
94
|
-
}),
|
|
95
|
-
const l = o.useRef(null), a =
|
|
96
|
-
return
|
|
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: `#${
|
|
99
|
+
selectorToWatch: `#${v(a)}`,
|
|
99
100
|
skipWhen: !s || !n
|
|
100
|
-
}),
|
|
101
|
-
},
|
|
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
|
-
`,
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("react"),K=require("@strapi/icons"),b=require("styled-components"),o=require("./SelectParts.cjs"),Q=require("../BaseCheckbox/assets/checkmark.svg.cjs"),U=require("../helpers/strings.cjs"),C=require("../hooks/useId.cjs"),Z=require("../hooks/useIntersection.cjs"),ee=require("../Tag/Tag.cjs"),x=require("../Box/Box.cjs"),R=require("../Typography/Typography.cjs"),te=require("../Field/Field.cjs"),re=require("../Flex/Flex.cjs"),ne=require("../Field/FieldLabel.cjs"),ie=require("../Field/FieldHint.cjs"),oe=require("../Field/FieldError.cjs"),le=e=>e&&e.__esModule?e:{default:e};function se(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 d=se(J),ce=le(b),ae=({"aria-label":e,children:i,clearLabel:r="Clear",customizeContent:l,disabled:s,error:c,hint:u,id:j,label:g,labelAction:M,onChange:p,onClear:F,onReachEnd:y,placeholder:_,required:q,selectButtonTitle:he,startIcon:B,size:L="M",value:h,withTags:m,...P})=>{const $=d.useRef(null),[S,k]=d.useState(),[V,z]=d.useState(!1),f=C.useId(j),E=`${f}-hint`,G=`${f}-error`,A=n=>{p?p(n):k(n)},D=n=>()=>{const w=Array.isArray(h)?h.filter(I=>I!==n):(S??[]).filter(I=>I!==n);p?p(w):k(w)},H=n=>{z(n)},v=d.useRef(null),W=()=>{v.current.focus()},N=C.useId(),O=`intersection-${U.stripReactIdOfColon(N)}`,X=n=>{y&&y(n)};Z.useIntersection($,X,{selectorToWatch:`#${O}`,skipWhen:!V});const a=typeof h<"u"&&h!==null?h:S,Y=n=>n&&typeof n=="object"&&n.value?t.jsx(ee.Tag,{tabIndex:-1,disabled:s,icon:t.jsx(K.Cross,{}),onClick:D(n.value),children:n.textValue},n.value):null;return t.jsx(te.Field,{hint:u,error:c,id:f,required:q,children:t.jsxs(re.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[g?t.jsx(ne.FieldLabel,{onClick:W,action:M,children:g}):null,t.jsxs(o.Root,{onOpenChange:H,disabled:s,required:q,onValueChange:A,value:a,...P,multi:!0,children:[t.jsx(o.Trigger,{ref:v,"aria-label":g??e,"aria-describedby":`${E} ${G}`,id:f,startIcon:B,size:L,hasError:!!c,disabled:s,clearLabel:r,onClear:a?.length?F:void 0,paddingLeft:m&&a?.length?1:3,children:t.jsx(o.Value,{placeholder:_,textColor:a?.length?"neutral800":"neutral600",children:a?.length?m?Y:l?l(a):void 0:void 0})}),t.jsx(o.Portal,{children:t.jsx(o.Content,{position:"popper",sideOffset:4,children:t.jsxs(o.Viewport,{ref:$,children:[i,t.jsx(x.Box,{id:O,width:"100%",height:"1px"})]})})})]}),t.jsx(ie.FieldHint,{}),t.jsx(oe.FieldError,{})]})})},de=d.forwardRef(({value:e,children:i,startIcon:r,...l},s)=>t.jsxs(o.Item,{ref:s,value:e.toString(),...l,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:c,isIntermediate:u})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:u,$selected:c,zIndex:1,height:"18px",width:"18px"})}),t.jsx(R.Typography,{textColor:"neutral800",children:t.jsx(o.ItemText,{children:i})})]})),T=ce.default(x.Box)`
|
|
2
2
|
border: 1px solid
|
|
3
3
|
${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral300};
|
|
4
4
|
background-color: ${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral0};
|
|
5
5
|
|
|
6
|
-
${({theme:e,$indeterminate:i})=>i&&
|
|
6
|
+
${({theme:e,$indeterminate:i})=>i&&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&&
|
|
21
|
+
${({$selected:e})=>e&&b.css`
|
|
22
22
|
&::after {
|
|
23
23
|
content: '';
|
|
24
|
-
background: url(${
|
|
24
|
+
background: url(${Q}) no-repeat no-repeat center center;
|
|
25
25
|
width: 100%;
|
|
26
26
|
height: 100%;
|
|
27
27
|
position: absolute;
|
|
28
28
|
}
|
|
29
29
|
`}
|
|
30
|
-
`,
|
|
30
|
+
`,ue=d.forwardRef(({children:e,label:i,startIcon:r,values:l=[],...s},c)=>t.jsxs(o.Group,{ref:c,children:[t.jsxs(o.Item,{value:l,...s,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:u,isIntermediate:j})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:j,$selected:u,zIndex:1,height:"18px",width:"18px"})}),t.jsx(R.Typography,{textColor:"neutral800",children:i})]}),e]}));exports.MultiSelect=ae;exports.MultiSelectGroup=ue;exports.MultiSelectOption=de;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import * as d from "react";
|
|
3
|
-
import { Cross as
|
|
4
|
-
import
|
|
5
|
-
import { Item as
|
|
6
|
-
import
|
|
7
|
-
import { stripReactIdOfColon as
|
|
8
|
-
import { useId as
|
|
3
|
+
import { Cross as N } from "@strapi/icons";
|
|
4
|
+
import Q, { css as O } from "styled-components";
|
|
5
|
+
import { Item as F, ItemIndicator as M, ItemText as U, Group as Z, Root as ee, Trigger as re, Value as te, Portal as ne, Content as oe, Viewport as ie } from "./SelectParts.js";
|
|
6
|
+
import le from "../BaseCheckbox/assets/checkmark.svg.js";
|
|
7
|
+
import { stripReactIdOfColon as ae } from "../helpers/strings.js";
|
|
8
|
+
import { useId as S } from "../hooks/useId.js";
|
|
9
9
|
import { useIntersection as ce } from "../hooks/useIntersection.js";
|
|
10
10
|
import { Tag as de } from "../Tag/Tag.js";
|
|
11
|
-
import { Box as
|
|
12
|
-
import { Typography as
|
|
13
|
-
import { Field as
|
|
14
|
-
import { Flex as
|
|
15
|
-
import { FieldLabel as
|
|
16
|
-
import { FieldHint as
|
|
17
|
-
import { FieldError as
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
ce(
|
|
30
|
-
|
|
11
|
+
import { Box as m } from "../Box/Box.js";
|
|
12
|
+
import { Typography as B } from "../Typography/Typography.js";
|
|
13
|
+
import { Field as se } from "../Field/Field.js";
|
|
14
|
+
import { Flex as he } from "../Flex/Flex.js";
|
|
15
|
+
import { FieldLabel as ue } from "../Field/FieldLabel.js";
|
|
16
|
+
import { FieldHint as pe } from "../Field/FieldHint.js";
|
|
17
|
+
import { FieldError as fe } from "../Field/FieldError.js";
|
|
18
|
+
const Le = ({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeContent: l, disabled: i, error: a, hint: h, id: g, label: x, labelAction: V, onChange: p, onClear: j, onReachEnd: $, placeholder: E, required: b, selectButtonTitle: me, startIcon: z, size: A = "M", value: u, withTags: k, ...G }) => {
|
|
19
|
+
const C = d.useRef(null), [v, w] = d.useState(), [W, q] = d.useState(!1), f = S(g), H = `${f}-hint`, P = `${f}-error`, X = (r) => {
|
|
20
|
+
p ? p(r) : w(r);
|
|
21
|
+
}, Y = (r) => () => {
|
|
22
|
+
const T = Array.isArray(u) ? u.filter((I) => I !== r) : (v ?? []).filter((I) => I !== r);
|
|
23
|
+
p ? p(T) : w(T);
|
|
24
|
+
}, _ = (r) => {
|
|
25
|
+
q(r);
|
|
26
|
+
}, R = d.useRef(null), D = () => {
|
|
27
|
+
R.current.focus();
|
|
28
|
+
}, J = S(), y = `intersection-${ae(J)}`;
|
|
29
|
+
ce(C, (r) => {
|
|
30
|
+
$ && $(r);
|
|
31
31
|
}, {
|
|
32
|
-
selectorToWatch: `#${
|
|
32
|
+
selectorToWatch: `#${y}`,
|
|
33
33
|
/**
|
|
34
34
|
* We need to know when the select is open because only then will viewportRef
|
|
35
35
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
36
36
|
*/
|
|
37
|
-
skipWhen: !
|
|
37
|
+
skipWhen: !W
|
|
38
38
|
});
|
|
39
|
-
const c = typeof u < "u" && u !== null ? u :
|
|
40
|
-
return e(
|
|
41
|
-
},
|
|
39
|
+
const c = typeof u < "u" && u !== null ? u : v, K = (r) => r && typeof r == "object" && r.value ? e(de, { tabIndex: -1, disabled: i, icon: e(N, {}), onClick: Y(r.value), children: r.textValue }, r.value) : null;
|
|
40
|
+
return e(se, { hint: h, error: a, id: f, required: b, children: s(he, { direction: "column", alignItems: "stretch", gap: 1, children: [x ? e(ue, { onClick: D, action: V, children: x }) : null, s(ee, { onOpenChange: _, disabled: i, required: b, onValueChange: X, value: c, ...G, multi: !0, children: [e(re, { ref: R, "aria-label": x ?? t, "aria-describedby": `${H} ${P}`, id: f, startIcon: z, size: A, hasError: !!a, disabled: i, clearLabel: o, onClear: c?.length ? j : void 0, paddingLeft: k && c?.length ? 1 : 3, children: e(te, { placeholder: E, textColor: c?.length ? "neutral800" : "neutral600", children: c?.length ? k ? K : l ? l(c) : 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(pe, {}), e(fe, {})] }) });
|
|
41
|
+
}, Ve = d.forwardRef(({ value: t, children: n, startIcon: o, ...l }, i) => s(F, { ref: i, value: t.toString(), ...l, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: a, isIntermediate: h }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: h, $selected: a, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: e(U, { children: n }) })] })), L = Q(m)`
|
|
42
42
|
border: 1px solid
|
|
43
|
-
${({ theme: t, $selected:
|
|
44
|
-
background-color: ${({ theme: t, $selected:
|
|
43
|
+
${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral300};
|
|
44
|
+
background-color: ${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral0};
|
|
45
45
|
|
|
46
|
-
${({ theme: t, $indeterminate:
|
|
46
|
+
${({ theme: t, $indeterminate: n }) => n && O`
|
|
47
47
|
&::after {
|
|
48
48
|
content: '';
|
|
49
49
|
display: block;
|
|
@@ -58,18 +58,18 @@ const Be = ({ children: t, clearLabel: o = "Clear", customizeContent: n, disable
|
|
|
58
58
|
}
|
|
59
59
|
`}
|
|
60
60
|
|
|
61
|
-
${({ $selected: t }) => t &&
|
|
61
|
+
${({ $selected: t }) => t && O`
|
|
62
62
|
&::after {
|
|
63
63
|
content: '';
|
|
64
|
-
background: url(${
|
|
64
|
+
background: url(${le}) no-repeat no-repeat center center;
|
|
65
65
|
width: 100%;
|
|
66
66
|
height: 100%;
|
|
67
67
|
position: absolute;
|
|
68
68
|
}
|
|
69
69
|
`}
|
|
70
|
-
`,
|
|
70
|
+
`, je = d.forwardRef(({ children: t, label: n, startIcon: o, values: l = [], ...i }, a) => s(Z, { ref: a, children: [s(F, { value: l, ...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
71
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Le as MultiSelect,
|
|
73
|
+
je as MultiSelectGroup,
|
|
74
|
+
Ve as MultiSelectOption
|
|
75
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("react"),o=require("./SelectParts.cjs"),V=require("../helpers/strings.cjs"),b=require("../hooks/useId.cjs"),H=require("../hooks/useIntersection.cjs"),q=require("../Box/Box.cjs"),W=require("../Typography/Typography.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");function K(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const h=K(E),Q=({error:t,hint:n,id:r,label:i,labelAction:s,required:d,selectButtonTitle:x,...g})=>{const c=b.useId(r),u=h.useRef(null),f=()=>{u.current.focus()};return e.jsx(z.Field,{hint:n,error:t,id:c,required:d,children:e.jsxs(D.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[i?e.jsx(A.FieldLabel,{onClick:f,action:s,children:i}):null,e.jsx(O,{label:i,id:c,triggerRef:u,required:d,...g}),e.jsx(G.FieldHint,{}),e.jsx(J.FieldError,{})]})})},O=({"aria-label":t,id:n,children:r,clearLabel:i="Clear",customizeContent:s,disabled:d,error:x,label:g,onChange:c,onClear:u,onReachEnd:f,placeholder:m,required:y,selectButtonTitle:X,startIcon:F,size:R="M",value:p,triggerRef:T,...B})=>{const[C,j]=h.useState(),[_,$]=h.useState(!1),v=l=>{$(l)},w=l=>{u&&u(l),c||j("")},P=`${n}-hint`,k=`${n}-error`,L=l=>{c?c(typeof p=="number"?Number(l):l):j(l)},S=h.useRef(null),M=b.useId(),I=`intersection-${V.stripReactIdOfColon(M)}`,N=l=>{f&&f(l)};H.useIntersection(S,N,{selectorToWatch:`#${I}`,skipWhen:!_});const a=(typeof p<"u"&&p!==null?p.toString():C)??"";return e.jsxs(o.Root,{onOpenChange:v,disabled:d,required:y,onValueChange:L,value:a,...B,children:[e.jsx(o.Trigger,{ref:T,"aria-label":g??t,"aria-describedby":n?`${P} ${k}`:void 0,id:n,startIcon:F,size:R,hasError:!!x,disabled:d,clearLabel:i,onClear:a&&u?w:void 0,children:e.jsx(o.Value,{placeholder:m,textColor:a?"neutral800":"neutral600",children:a&&s?s(a):void 0})}),e.jsx(o.Portal,{children:e.jsx(o.Content,{position:"popper",sideOffset:4,children:e.jsxs(o.Viewport,{ref:S,children:[r,e.jsx(q.Box,{id:I,width:"100%",height:"1px"})]})})})]})},U=h.forwardRef(({value:t,startIcon:n,children:r,...i},s)=>e.jsxs(o.Item,{ref:s,value:t.toString(),...i,children:[n&&e.jsx(q.Box,{as:"span","aria-hidden":!0,children:n}),e.jsx(W.Typography,{textColor:"neutral800",children:e.jsx(o.ItemText,{children:r})})]}));exports.SingleSelect=Q;exports.SingleSelectInput=O;exports.SingleSelectOption=U;
|