@strapi/design-system 1.7.10 → 1.8.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.
- package/README.md +9 -17
- package/dist/Combobox/Combobox.cjs +14 -13
- package/dist/Combobox/Combobox.js +73 -68
- package/dist/DatePicker/DatePicker.cjs +82 -6
- package/dist/DatePicker/DatePicker.js +381 -55
- package/dist/DateTimePicker/DateTimePicker.cjs +7 -1
- package/dist/DateTimePicker/DateTimePicker.js +91 -53
- package/dist/DateTimePicker/index.cjs +1 -1
- package/dist/DateTimePicker/index.js +3 -2
- package/dist/DesignSystemProvider.cjs +1 -0
- package/dist/DesignSystemProvider.js +10 -0
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +40 -40
- package/dist/Popover/Popover.cjs +3 -4
- package/dist/Popover/Popover.js +46 -48
- package/dist/Popover/index.cjs +1 -1
- package/dist/Popover/index.js +5 -9
- package/dist/Popover/primitives.cjs +1 -0
- package/dist/Popover/primitives.js +5 -0
- package/dist/Searchbar/Searchbar.cjs +2 -2
- package/dist/Searchbar/Searchbar.js +5 -5
- package/dist/Select/SelectParts.cjs +1 -1
- package/dist/Select/SelectParts.js +1 -1
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +36 -32
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +5 -5
- package/dist/ThemeProvider/ThemeProvider.cjs +2 -2
- package/dist/ThemeProvider/ThemeProvider.js +4 -3
- package/dist/TimePicker/TimePicker.cjs +5 -7
- package/dist/TimePicker/TimePicker.js +79 -33
- package/dist/TimePicker/index.cjs +1 -1
- package/dist/TimePicker/index.js +3 -2
- package/dist/helpers/context.cjs +1 -0
- package/dist/helpers/context.js +21 -0
- package/dist/helpers/getDefaultLocale.cjs +4 -1
- package/dist/helpers/getDefaultLocale.js +7 -2
- package/dist/hooks/useDateFormatter.cjs +1 -0
- package/dist/hooks/useDateFormatter.js +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +309 -304
- package/package.json +6 -5
- package/dist/DatePicker/DatePickerCalendar.cjs +0 -1
- package/dist/DatePicker/DatePickerCalendar.js +0 -43
- package/dist/DatePicker/DatePickerTd.cjs +0 -19
- package/dist/DatePicker/DatePickerTd.js +0 -29
- package/dist/DatePicker/DatePickerTh.cjs +0 -9
- package/dist/DatePicker/DatePickerTh.js +0 -18
- package/dist/DatePicker/compareDates.cjs +0 -1
- package/dist/DatePicker/compareDates.js +0 -4
- package/dist/DatePicker/components.cjs +0 -39
- package/dist/DatePicker/components.js +0 -53
- package/dist/DatePicker/utils/formatDate.cjs +0 -1
- package/dist/DatePicker/utils/formatDate.js +0 -4
- package/dist/DatePicker/utils/generateWeeks.cjs +0 -1
- package/dist/DatePicker/utils/generateWeeks.js +0 -17
- package/dist/DatePicker/utils/getDayOfWeek.cjs +0 -1
- package/dist/DatePicker/utils/getDayOfWeek.js +0 -15
- package/dist/DatePicker/utils/getMonths.cjs +0 -1
- package/dist/DatePicker/utils/getMonths.js +0 -7
- package/dist/DatePicker/utils/getYears.cjs +0 -1
- package/dist/DatePicker/utils/getYears.js +0 -9
- package/dist/DatePicker/utils/index.cjs +0 -1
- package/dist/DatePicker/utils/index.js +0 -12
- package/dist/DateTimePicker/parseDate.cjs +0 -1
- package/dist/DateTimePicker/parseDate.js +0 -8
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as i } from "./helpers/context.js";
|
|
3
|
+
import { ThemeProvider as a } from "./ThemeProvider/ThemeProvider.js";
|
|
4
|
+
const r = "en-EN", t = () => typeof navigator > "u" ? r : navigator.language ? navigator.language : r, [s, l] = i("StrapiDesignSystem", {
|
|
5
|
+
locale: t()
|
|
6
|
+
}), u = ({ locale: o = t(), ...n }) => e(s, { locale: o, children: e(a, { ...n }) });
|
|
7
|
+
export {
|
|
8
|
+
u as DesignSystemProvider,
|
|
9
|
+
l as useDesignSystem
|
|
10
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),x=require("@internationalized/number"),g=require("@strapi/icons"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),x=require("@internationalized/number"),g=require("@strapi/icons"),M=require("styled-components"),B=require("../DesignSystemProvider.cjs"),h=require("../helpers/keyboardKeys.cjs"),E=require("../hooks/useControllableState.cjs"),U=require("../hooks/useId.cjs"),H=require("../Field/FieldInput.cjs"),O=require("../Field/Field.cjs"),T=require("../Flex/Flex.cjs"),z=require("../Field/FieldLabel.cjs"),y=require("../Icon/Icon.cjs"),W=require("../Field/FieldHint.cjs"),X=require("../Field/FieldError.cjs"),I=r=>r&&r.__esModule?r:{default:r},Y=I(l),G=I(M),N=G.default.button`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 1rem;
|
|
4
4
|
align-items: ${({reverse:r})=>r?"flex-end":"flex-start"};
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
height: ${4/16}rem;
|
|
10
10
|
transform: ${({reverse:r})=>r?"rotateX(180deg)":void 0};
|
|
11
11
|
}
|
|
12
|
-
`,
|
|
12
|
+
`,J="",Q=Y.default.forwardRef(({size:r="M",startAction:q,name:F,hint:w,error:j,label:d,labelAction:D,locale:C,id:V,onValueChange:S,value:m,step:o=1,required:A=!1,disabled:u=!1,...R},_)=>{const k=U.useId(V),K=B.useDesignSystem("NumberInput"),f=C||K.locale,i=l.useRef(new x.NumberParser(f,{style:"decimal"})),c=l.useRef(new x.NumberFormatter(f,{maximumFractionDigits:20})),[s,P]=E.useControllableState({prop(e){const n=String(m);return isNaN(Number(n))||n!==e&&e!==""?e:c.current.format(Number(m))},defaultProp:J,onChange(e){const n=i.current.parse(e??"");S(isNaN(n)?void 0:n)}}),a=e=>{P(String(e))},v=({target:{value:e}})=>{i.current.isValidPartialNumber(e)&&a(e)},b=()=>{if(!s){a(o);return}const e=i.current.parse(s),n=isNaN(e)?o:e+o;a(c.current.format(n))},p=()=>{if(!s){a(-o);return}const e=i.current.parse(s),n=isNaN(e)?-o:e-o;a(c.current.format(n))},$=e=>{if(!u)switch(e.key){case h.KeyboardKeys.DOWN:{e.preventDefault(),p();break}case h.KeyboardKeys.UP:{e.preventDefault(),b();break}}},L=()=>{if(s){const e=i.current.parse(s),n=isNaN(e)?"":c.current.format(e);a(n)}};return t.jsx(O.Field,{name:F,hint:w,error:j,id:k,required:A,children:t.jsxs(T.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[d&&t.jsx(z.FieldLabel,{action:D,children:d}),t.jsx(H.FieldInput,{ref:_,startAction:q,disabled:u,type:"text",inputMode:"decimal",onChange:v,onKeyDown:$,onBlur:L,value:s,size:r,endAction:t.jsxs(t.Fragment,{children:[t.jsx(N,{disabled:u,"aria-hidden":!0,reverse:!0,onClick:b,tabIndex:-1,type:"button","data-testid":"ArrowUp",children:t.jsx(y.Icon,{as:g.CarretDown,color:"neutral500"})}),t.jsx(N,{disabled:u,"aria-hidden":!0,onClick:p,tabIndex:-1,type:"button","data-testid":"ArrowDown",children:t.jsx(y.Icon,{as:g.CarretDown,color:"neutral500"})})]}),...R}),t.jsx(W.FieldHint,{}),t.jsx(X.FieldError,{})]})})});exports.NumberInput=Q;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as n, jsxs as h, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { NumberParser as
|
|
1
|
+
import { jsx as n, jsxs as h, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import j, { useRef as b } from "react";
|
|
3
|
+
import { NumberParser as E, NumberFormatter as M } from "@internationalized/number";
|
|
4
4
|
import { CarretDown as N } from "@strapi/icons";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import q from "styled-components";
|
|
6
|
+
import { useDesignSystem as z } from "../DesignSystemProvider.js";
|
|
7
7
|
import { KeyboardKeys as g } from "../helpers/keyboardKeys.js";
|
|
8
|
-
import { useControllableState as
|
|
9
|
-
import { useId as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
8
|
+
import { useControllableState as H } from "../hooks/useControllableState.js";
|
|
9
|
+
import { useId as O } from "../hooks/useId.js";
|
|
10
|
+
import { FieldInput as T } from "../Field/FieldInput.js";
|
|
11
|
+
import { Field as W } from "../Field/Field.js";
|
|
12
|
+
import { Flex as X } from "../Flex/Flex.js";
|
|
13
|
+
import { FieldLabel as Y } from "../Field/FieldLabel.js";
|
|
14
14
|
import { Icon as w } from "../Icon/Icon.js";
|
|
15
|
-
import { FieldHint as
|
|
16
|
-
import { FieldError as
|
|
17
|
-
const x =
|
|
15
|
+
import { FieldHint as G } from "../Field/FieldHint.js";
|
|
16
|
+
import { FieldError as J } from "../Field/FieldError.js";
|
|
17
|
+
const x = q.button`
|
|
18
18
|
display: flex;
|
|
19
19
|
height: 1rem;
|
|
20
20
|
align-items: ${({ reverse: t }) => t ? "flex-end" : "flex-start"};
|
|
@@ -25,55 +25,55 @@ const x = M.button`
|
|
|
25
25
|
height: ${4 / 16}rem;
|
|
26
26
|
transform: ${({ reverse: t }) => t ? "rotateX(180deg)" : void 0};
|
|
27
27
|
}
|
|
28
|
-
`,
|
|
29
|
-
const
|
|
30
|
-
prop(
|
|
31
|
-
const
|
|
32
|
-
return isNaN(Number(
|
|
28
|
+
`, Q = "", he = j.forwardRef(({ size: t = "M", startAction: y, name: I, hint: F, error: V, label: c, labelAction: D, locale: A, id: C, onValueChange: k, value: u, step: a = 1, required: P = !1, disabled: m = !1, ...R }, S) => {
|
|
29
|
+
const $ = O(C), K = z("NumberInput"), d = A || K.locale, s = b(new E(d, { style: "decimal" })), l = b(new M(d, { maximumFractionDigits: 20 })), [o, v] = H({
|
|
30
|
+
prop(e) {
|
|
31
|
+
const r = String(u);
|
|
32
|
+
return isNaN(Number(r)) || r !== e && e !== "" ? e : l.current.format(Number(u));
|
|
33
33
|
},
|
|
34
|
-
defaultProp:
|
|
35
|
-
onChange(
|
|
36
|
-
const
|
|
37
|
-
k(isNaN(
|
|
34
|
+
defaultProp: Q,
|
|
35
|
+
onChange(e) {
|
|
36
|
+
const r = s.current.parse(e ?? "");
|
|
37
|
+
k(isNaN(r) ? void 0 : r);
|
|
38
38
|
}
|
|
39
|
-
}), i = (
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
s.current.isValidPartialNumber(
|
|
39
|
+
}), i = (e) => {
|
|
40
|
+
v(String(e));
|
|
41
|
+
}, B = ({ target: { value: e } }) => {
|
|
42
|
+
s.current.isValidPartialNumber(e) && i(e);
|
|
43
43
|
}, f = () => {
|
|
44
44
|
if (!o) {
|
|
45
45
|
i(a);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
i(l.current.format(
|
|
48
|
+
const e = s.current.parse(o), r = isNaN(e) ? a : e + a;
|
|
49
|
+
i(l.current.format(r));
|
|
50
50
|
}, p = () => {
|
|
51
51
|
if (!o) {
|
|
52
52
|
i(-a);
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
i(l.current.format(
|
|
57
|
-
},
|
|
55
|
+
const e = s.current.parse(o), r = isNaN(e) ? -a : e - a;
|
|
56
|
+
i(l.current.format(r));
|
|
57
|
+
}, L = (e) => {
|
|
58
58
|
if (!m)
|
|
59
|
-
switch (
|
|
59
|
+
switch (e.key) {
|
|
60
60
|
case g.DOWN: {
|
|
61
|
-
|
|
61
|
+
e.preventDefault(), p();
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
64
|
case g.UP: {
|
|
65
|
-
|
|
65
|
+
e.preventDefault(), f();
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
},
|
|
69
|
+
}, U = () => {
|
|
70
70
|
if (o) {
|
|
71
|
-
const
|
|
72
|
-
i(
|
|
71
|
+
const e = s.current.parse(o), r = isNaN(e) ? "" : l.current.format(e);
|
|
72
|
+
i(r);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
return n(
|
|
75
|
+
return n(W, { name: I, hint: F, error: V, id: $, required: P, children: h(X, { direction: "column", alignItems: "stretch", gap: 1, children: [c && n(Y, { action: D, children: c }), n(T, { ref: S, startAction: y, disabled: m, type: "text", inputMode: "decimal", onChange: B, onKeyDown: L, onBlur: U, value: o, size: t, endAction: h(_, { children: [n(x, { disabled: m, "aria-hidden": !0, reverse: !0, onClick: f, tabIndex: -1, type: "button", "data-testid": "ArrowUp", children: n(w, { as: N, color: "neutral500" }) }), n(x, { disabled: m, "aria-hidden": !0, onClick: p, tabIndex: -1, type: "button", "data-testid": "ArrowDown", children: n(w, { as: N, color: "neutral500" }) })] }), ...R }), n(G, {}), n(J, {})] }) });
|
|
76
76
|
});
|
|
77
77
|
export {
|
|
78
|
-
|
|
78
|
+
he as NumberInput
|
|
79
79
|
};
|
package/dist/Popover/Popover.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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)`
|
|
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
|
-
|
|
6
|
-
`,R=({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})=>{const[h,k]=i.useState(null),v=i.useRef(!1),[S,j]=i.useState(void 0),{x:q,y:C,reference:w,floating:D,strategy:_}=u.useFloating({strategy:"fixed",placement:l?"bottom":c,middleware:[u.offset({mainAxis:t}),u.shift(),u.flip()],whileElementsMounted:u.autoUpdate});i.useLayoutEffect(()=>{w(e.current)},[e,w]),i.useLayoutEffect(()=>{n&&j(e.current.offsetWidth)},[n,e]),i.useEffect(()=>{if(h)return z.hideOthers(h)},[h]);const x=m.useCallbackRef(a);i.useEffect(()=>{const o=()=>{x()};return window.addEventListener("blur",o),window.addEventListener("resize",o),()=>{window.removeEventListener("blur",o),window.removeEventListener("resize",o)}},[x]);const L=B.useComposedRefs(o=>k(o),D);return s.jsx(T.RemoveScroll,{allowPinchZoom:!0,children:s.jsx(M.FocusScope,{asChild:!0,loop:!0,trapped:!0,onUnmountAutoFocus:o=>{o.preventDefault(),v.current||e.current?.focus({preventScroll:!0})},children:s.jsx(A.DismissibleLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:m.composeEventHandlers(f,o=>{const b=o.detail.originalEvent,$=b.button===0&&b.ctrlKey===!0,I=b.button===2||$;v.current=I},{checkForDefaultPrevented:!1}),onFocusOutside:m.composeEventHandlers(p,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:a,children:s.jsx(G,{ref:L,style:{left:q,top:C,position:_,width:S||void 0},hasRadius:!0,background:"neutral0",padding:1,...O,children:r})})})})},y=({children:e,intersectionId:r,onReachEnd:t,...n})=>{const c=i.useRef(null),l=H.useId();return K.useIntersection(c,t??(()=>{}),{selectorToWatch:`#${P.stripReactIdOfColon(l)}`,skipWhen:!r||!t}),s.jsxs(J,{ref:c,...n,children:[e,r&&t&&s.jsx(g.Box,{id:P.stripReactIdOfColon(l),width:"100%",height:"1px"})]})},J=E.default(g.Box)`
|
|
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)`
|
|
7
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
|
|
8
7
|
max-height: ${3*5}rem;
|
|
9
8
|
overflow-y: auto;
|
|
@@ -23,4 +22,4 @@
|
|
|
23
22
|
border-radius: ${({theme:e})=>e.borderRadius};
|
|
24
23
|
margin-right: 10px;
|
|
25
24
|
}
|
|
26
|
-
`,
|
|
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;
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as I } 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 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";
|
|
14
14
|
import { Box as h } from "../Box/Box.js";
|
|
15
|
-
import { Portal as
|
|
16
|
-
const
|
|
15
|
+
import { Portal as q } from "../Portal/Portal.js";
|
|
16
|
+
const me = [
|
|
17
17
|
"top",
|
|
18
18
|
"top-start",
|
|
19
19
|
"top-end",
|
|
@@ -26,33 +26,32 @@ const fe = [
|
|
|
26
26
|
"left",
|
|
27
27
|
"left-start",
|
|
28
28
|
"left-end"
|
|
29
|
-
],
|
|
29
|
+
], G = k(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
|
-
|
|
35
|
-
const [m, P] = o.useState(null), b = o.useRef(!1), [R, y] = o.useState(void 0), { x: C, y: D, reference: w, floating: L, strategy: O } = I({
|
|
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({
|
|
36
35
|
strategy: "fixed",
|
|
37
36
|
placement: a ? "bottom" : l,
|
|
38
37
|
middleware: [
|
|
39
|
-
|
|
38
|
+
A({
|
|
40
39
|
mainAxis: n
|
|
41
40
|
}),
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
K(),
|
|
42
|
+
j()
|
|
44
43
|
],
|
|
45
|
-
whileElementsMounted:
|
|
44
|
+
whileElementsMounted: M
|
|
46
45
|
});
|
|
47
46
|
o.useLayoutEffect(() => {
|
|
48
47
|
w(e.current);
|
|
49
48
|
}, [e, w]), o.useLayoutEffect(() => {
|
|
50
|
-
i &&
|
|
49
|
+
i && C(e.current.offsetWidth);
|
|
51
50
|
}, [i, e]), o.useEffect(() => {
|
|
52
51
|
if (m)
|
|
53
|
-
return
|
|
52
|
+
return B(m);
|
|
54
53
|
}, [m]);
|
|
55
|
-
const g =
|
|
54
|
+
const g = U(c);
|
|
56
55
|
o.useEffect(() => {
|
|
57
56
|
const t = () => {
|
|
58
57
|
g();
|
|
@@ -61,8 +60,8 @@ const fe = [
|
|
|
61
60
|
window.removeEventListener("blur", t), window.removeEventListener("resize", t);
|
|
62
61
|
};
|
|
63
62
|
}, [g]);
|
|
64
|
-
const
|
|
65
|
-
return r(
|
|
63
|
+
const $ = V(R, (t) => y(t), S);
|
|
64
|
+
return r(H, { allowPinchZoom: !0, children: r(T, {
|
|
66
65
|
asChild: !0,
|
|
67
66
|
loop: !0,
|
|
68
67
|
// we make sure we're not trapping once it's been closed
|
|
@@ -71,36 +70,35 @@ const fe = [
|
|
|
71
70
|
onUnmountAutoFocus: (t) => {
|
|
72
71
|
t.preventDefault(), b.current || e.current?.focus({ preventScroll: !0 });
|
|
73
72
|
},
|
|
74
|
-
children: r(
|
|
73
|
+
children: r(N, {
|
|
75
74
|
asChild: !0,
|
|
76
|
-
disableOutsidePointerEvents: !0,
|
|
77
75
|
onEscapeKeyDown: d,
|
|
78
|
-
onPointerDownOutside: v(
|
|
79
|
-
const p = t.detail.originalEvent,
|
|
80
|
-
b.current =
|
|
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;
|
|
81
79
|
}, { checkForDefaultPrevented: !1 }),
|
|
82
80
|
// When focus is trapped, a `focusout` event may still happen.
|
|
83
81
|
// We make sure we don't trigger our `onDismiss` in such case.
|
|
84
|
-
onFocusOutside: v(
|
|
82
|
+
onFocusOutside: v(u, (t) => t.preventDefault(), {
|
|
85
83
|
checkForDefaultPrevented: !1
|
|
86
84
|
}),
|
|
87
85
|
onDismiss: c,
|
|
88
|
-
children: r(
|
|
89
|
-
left:
|
|
90
|
-
top:
|
|
86
|
+
children: r(G, { ref: $, style: {
|
|
87
|
+
left: D,
|
|
88
|
+
top: L,
|
|
91
89
|
position: O,
|
|
92
|
-
width:
|
|
90
|
+
width: P || void 0
|
|
93
91
|
}, hasRadius: !0, background: "neutral0", padding: 1, ...E, children: s })
|
|
94
92
|
})
|
|
95
93
|
}) });
|
|
96
|
-
},
|
|
97
|
-
const l = o.useRef(null), a =
|
|
98
|
-
return
|
|
94
|
+
}), Q = ({ children: e, intersectionId: s, onReachEnd: n, ...i }) => {
|
|
95
|
+
const l = o.useRef(null), a = Z();
|
|
96
|
+
return _(l, n ?? (() => {
|
|
99
97
|
}), {
|
|
100
|
-
selectorToWatch: `#${
|
|
98
|
+
selectorToWatch: `#${x(a)}`,
|
|
101
99
|
skipWhen: !s || !n
|
|
102
|
-
}),
|
|
103
|
-
},
|
|
100
|
+
}), I(X, { ref: l, ...i, children: [e, s && n && r(h, { id: x(a), width: "100%", height: "1px" })] });
|
|
101
|
+
}, X = k(h)`
|
|
104
102
|
// 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
|
|
105
103
|
max-height: ${3 * 5}rem;
|
|
106
104
|
overflow-y: auto;
|
|
@@ -120,10 +118,10 @@ const fe = [
|
|
|
120
118
|
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
121
119
|
margin-right: 10px;
|
|
122
120
|
}
|
|
123
|
-
`,
|
|
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 }) }) });
|
|
124
122
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
J as Content,
|
|
124
|
+
me as POPOVER_PLACEMENTS,
|
|
125
|
+
pe as Popover,
|
|
126
|
+
Q as Scrolling
|
|
129
127
|
};
|
package/dist/Popover/index.cjs
CHANGED
|
@@ -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("./Popover.cjs"),o=require("./primitives.cjs");exports.POPOVER_PLACEMENTS=e.POPOVER_PLACEMENTS;exports.Popover=e.Popover;exports.PopoverPrimitives=o;
|
package/dist/Popover/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
const e = {
|
|
4
|
-
Content: o,
|
|
5
|
-
Scrolling: r
|
|
6
|
-
};
|
|
1
|
+
import { POPOVER_PLACEMENTS as e, Popover as p } from "./Popover.js";
|
|
2
|
+
import * as o from "./primitives.js";
|
|
7
3
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
e as POPOVER_PLACEMENTS,
|
|
5
|
+
p as Popover,
|
|
6
|
+
o as PopoverPrimitives
|
|
11
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Popover.cjs");exports.Content=e.Content;exports.Scrolling=e.Scrolling;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),l=require("@strapi/icons"),m=require("styled-components"),F=require("../hooks/useComposeRefs.cjs"),R=require("../themes/utils.cjs"),t=require("../Field/FieldInput.cjs"),S=require("../Field/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("react"),l=require("@strapi/icons"),m=require("styled-components"),F=require("../hooks/useComposeRefs.cjs"),R=require("../themes/utils.cjs"),t=require("../Field/FieldInput.cjs"),S=require("../Field/FieldAction.cjs"),y=require("../Field/Field.cjs"),$=require("../VisuallyHidden/VisuallyHidden.cjs"),C=require("../Field/FieldLabel.cjs"),I=e=>e&&e.__esModule?e:{default:e},s=I(m),w=s.default(l.Cross)`
|
|
2
2
|
font-size: 0.5rem;
|
|
3
3
|
path {
|
|
4
4
|
fill: ${({theme:e})=>e.colors.neutral400};
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
${R.inputFocusStyle(t.InputWrapper)}
|
|
28
|
-
`,g=i.forwardRef(({name:e,size:a="M",children:u,value:n="",onClear:d,clearLabel:f,...p},h)=>{const o=i.useRef(null),b=n.length>0,q=j=>{d(j),o.current.focus()},x=F.composeRefs(h,o);return r.jsx(_,{children:r.jsxs(
|
|
28
|
+
`,g=i.forwardRef(({name:e,size:a="M",children:u,value:n="",onClear:d,clearLabel:f,...p},h)=>{const o=i.useRef(null),b=n.length>0,q=j=>{d(j),o.current.focus()},x=F.composeRefs(h,o);return r.jsx(_,{children:r.jsxs(y.Field,{name:e,children:[r.jsx($.VisuallyHidden,{children:r.jsx(C.FieldLabel,{children:u})}),r.jsx(t.FieldInput,{ref:x,value:n,startAction:r.jsx(c,{"aria-hidden":!0}),size:a,endAction:b?r.jsx(S.FieldAction,{label:f,onClick:q,children:r.jsx(w,{})}):void 0,...p})]})})});exports.Searchbar=g;
|
|
@@ -5,10 +5,10 @@ import e from "styled-components";
|
|
|
5
5
|
import { composeRefs as C } from "../hooks/useComposeRefs.js";
|
|
6
6
|
import { inputFocusStyle as F } from "../themes/utils.js";
|
|
7
7
|
import { InputWrapper as n, FieldInput as y } from "../Field/FieldInput.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { FieldAction as I } from "../Field/FieldAction.js";
|
|
9
|
+
import { Field as z } from "../Field/Field.js";
|
|
10
|
+
import { VisuallyHidden as A } from "../VisuallyHidden/VisuallyHidden.js";
|
|
11
|
+
import { FieldLabel as g } from "../Field/FieldLabel.js";
|
|
12
12
|
const j = e(w)`
|
|
13
13
|
font-size: 0.5rem;
|
|
14
14
|
path {
|
|
@@ -40,7 +40,7 @@ const j = e(w)`
|
|
|
40
40
|
const i = S(null), f = t.length > 0, h = (b) => {
|
|
41
41
|
c(b), i.current.focus();
|
|
42
42
|
}, u = C(p, i);
|
|
43
|
-
return o(W, { children: $(
|
|
43
|
+
return o(W, { children: $(z, { name: r, children: [o(A, { children: o(g, { children: a }) }), o(y, { ref: u, value: t, startAction: o(l, { "aria-hidden": !0 }), size: s, endAction: f ? o(I, { label: d, onClick: h, children: o(j, {}) }) : void 0, ...m })] }) });
|
|
44
44
|
});
|
|
45
45
|
export {
|
|
46
46
|
J as Searchbar
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),R=require("react"),d=require("@strapi/icons"),o=require("@strapi/ui-primitives"),p=require("styled-components"),j=require("../hooks/useComposeRefs.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),R=require("react"),d=require("@strapi/icons"),o=require("@strapi/ui-primitives"),p=require("styled-components"),j=require("../hooks/useComposeRefs.cjs"),c=require("../Flex/Flex.cjs"),f=require("../Box/Box.cjs"),u=require("../themes/utils.cjs"),g=require("../Typography/Typography.cjs"),I=e=>e&&e.__esModule?e:{default:e};function T(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const a=T(R),l=I(p),v=a.forwardRef(({onClear:e,clearLabel:t="Clear",startIcon:s,disabled:n,hasError:h,size:m="M",children:x,...b},$)=>{const i=a.useRef(null),S=y=>{e&&!n&&(e(y),i.current.focus())},w=j.useComposedRefs(i,$);return r.jsx(o.Select.Trigger,{asChild:!0,children:r.jsxs(q,{"aria-disabled":n,$hasError:h,$size:m,ref:w,alignItems:"center",justifyContent:"space-between",position:"relative",overflow:"hidden",hasRadius:!0,background:n?"neutral150":"neutral0",paddingLeft:3,paddingRight:3,gap:4,cursor:"default",width:"100%",...b,children:[r.jsxs(c.Flex,{flex:"1",as:"span",gap:3,children:[s&&r.jsx(f.Box,{as:"span","aria-hidden":!0,children:s}),x]}),r.jsxs(c.Flex,{as:"span",gap:3,children:[e?r.jsx(C,{as:"button",hasRadius:!0,background:"transparent",role:"button",tabIndex:0,onClick:S,"aria-disabled":n,"aria-label":t,title:t,cursor:"pointer",children:r.jsx(d.Cross,{})}):null,r.jsx(k,{children:r.jsx(d.CarretDown,{})})]})]})})}),C=l.default(f.Box)`
|
|
2
2
|
border: none;
|
|
3
3
|
|
|
4
4
|
svg {
|
|
@@ -4,9 +4,9 @@ import { Cross as y, CarretDown as R } from "@strapi/icons";
|
|
|
4
4
|
import { Select as o } from "@strapi/ui-primitives";
|
|
5
5
|
import s, { css as I } from "styled-components";
|
|
6
6
|
import { useComposedRefs as S } from "../hooks/useComposeRefs.js";
|
|
7
|
-
import { getThemeSize as C, inputFocusStyle as T } from "../themes/utils.js";
|
|
8
7
|
import { Flex as c } from "../Flex/Flex.js";
|
|
9
8
|
import { Box as p } from "../Box/Box.js";
|
|
9
|
+
import { getThemeSize as C, inputFocusStyle as T } from "../themes/utils.js";
|
|
10
10
|
import { Typography as u } from "../Typography/Typography.js";
|
|
11
11
|
const k = a.forwardRef(({ onClear: e, clearLabel: r = "Clear", startIcon: i, disabled: n, hasError: m, size: h = "M", children: f, ...g }, $) => {
|
|
12
12
|
const d = a.useRef(null), w = (x) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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,40 +1,44 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { Item as
|
|
4
|
-
import { stripReactIdOfColon as
|
|
5
|
-
import { useId as
|
|
6
|
-
import { useIntersection as
|
|
7
|
-
import { Box as
|
|
8
|
-
import { Typography as
|
|
9
|
-
import { Field as
|
|
10
|
-
import { Flex as
|
|
11
|
-
import { FieldLabel as
|
|
12
|
-
import { FieldHint as
|
|
13
|
-
import { FieldError as
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { jsxs as p, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as u from "react";
|
|
3
|
+
import { Item as j, ItemText as q, Root as W, Trigger as _, Value as H, Portal as M, Content as P, Viewport as z } from "./SelectParts.js";
|
|
4
|
+
import { stripReactIdOfColon as A } from "../helpers/strings.js";
|
|
5
|
+
import { useId as R } from "../hooks/useId.js";
|
|
6
|
+
import { useIntersection as D } from "../hooks/useIntersection.js";
|
|
7
|
+
import { Box as x } from "../Box/Box.js";
|
|
8
|
+
import { Typography as G } from "../Typography/Typography.js";
|
|
9
|
+
import { Field as J } from "../Field/Field.js";
|
|
10
|
+
import { Flex as K } from "../Flex/Flex.js";
|
|
11
|
+
import { FieldLabel as Q } from "../Field/FieldLabel.js";
|
|
12
|
+
import { FieldHint as U } from "../Field/FieldHint.js";
|
|
13
|
+
import { FieldError as X } from "../Field/FieldError.js";
|
|
14
|
+
const pe = ({ error: r, hint: i, id: c, label: n, labelAction: o, required: f, selectButtonTitle: m, ...d }) => {
|
|
15
|
+
const l = R(c), a = u.useRef(null);
|
|
16
|
+
return e(J, { hint: i, error: r, id: l, required: f, children: p(K, { direction: "column", alignItems: "stretch", gap: 1, children: [e(Q, { onClick: () => {
|
|
17
|
+
a.current.focus();
|
|
18
|
+
}, action: o, children: n }), e(Y, { label: n, id: l, triggerRef: a, required: f, ...d }), e(U, {}), e(X, {})] }) });
|
|
19
|
+
}, Y = ({ id: r, children: i, clearLabel: c = "Clear", customizeContent: n, disabled: o, error: f, label: m, onChange: d, onClear: l, onReachEnd: a, placeholder: g, required: C, selectButtonTitle: Z, startIcon: B, size: O = "M", value: h, triggerRef: T, ...F }) => {
|
|
20
|
+
const [$, I] = u.useState(), [y, k] = u.useState(!1), w = (t) => {
|
|
21
|
+
k(t);
|
|
22
|
+
}, L = (t) => {
|
|
23
|
+
l && l(t), d || I("");
|
|
24
|
+
}, v = `${r}-hint`, E = `${r}-error`, N = (t) => {
|
|
25
|
+
d ? d(typeof h == "number" ? Number(t) : t) : I(t);
|
|
26
|
+
}, b = u.useRef(null), V = R(), S = `intersection-${A(V)}`;
|
|
27
|
+
D(b, (t) => {
|
|
28
|
+
a && a(t);
|
|
26
29
|
}, {
|
|
27
|
-
selectorToWatch: `#${
|
|
30
|
+
selectorToWatch: `#${S}`,
|
|
28
31
|
/**
|
|
29
32
|
* We need to know when the select is open because only then will viewportRef
|
|
30
33
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
31
34
|
*/
|
|
32
|
-
skipWhen: !
|
|
35
|
+
skipWhen: !y
|
|
33
36
|
});
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
},
|
|
37
|
+
const s = (typeof h < "u" && h !== null ? h.toString() : $) ?? "";
|
|
38
|
+
return p(W, { onOpenChange: w, disabled: o, required: C, onValueChange: N, value: s, ...F, children: [e(_, { ref: T, "aria-label": m, "aria-describedby": r ? `${v} ${E}` : void 0, id: r, startIcon: B, size: O, hasError: !!f, disabled: o, clearLabel: c, onClear: s && l ? L : void 0, children: e(H, { placeholder: g, textColor: s ? "neutral800" : "neutral600", children: s && n ? n(s) : void 0 }) }), e(M, { children: e(P, { position: "popper", sideOffset: 4, children: p(z, { ref: b, children: [i, e(x, { id: S, width: "100%", height: "1px" })] }) }) })] });
|
|
39
|
+
}, me = u.forwardRef(({ value: r, startIcon: i, children: c, ...n }, o) => p(j, { ref: o, value: r.toString(), ...n, children: [i && e(x, { as: "span", "aria-hidden": !0, children: i }), e(G, { textColor: "neutral800", children: e(q, { children: c }) })] }));
|
|
37
40
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
pe as SingleSelect,
|
|
42
|
+
Y as SingleSelectInput,
|
|
43
|
+
me as SingleSelectOption
|
|
40
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),F=require("../hooks/useId.cjs"),I=require("../Field/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),F=require("../hooks/useId.cjs"),I=require("../Field/Field.cjs"),q=require("../Flex/Flex.cjs"),j=require("../Field/FieldLabel.cjs"),h=require("../Field/FieldInput.cjs"),m=require("../Field/FieldHint.cjs"),f=require("../Field/FieldError.cjs"),s=t.forwardRef(({name:l,hint:d,error:o,label:r,labelAction:u,id:c,required:a,...i},p)=>{const x=F.useId(c),n=t.useRef(null);if(!r&&!i["aria-label"])throw new Error('The TextInput component needs a "label" or an "aria-label" props');return t.useImperativeHandle(p,()=>({inputWrapperRef:n})),e.jsx("div",{ref:n,children:e.jsx(I.Field,{name:l,hint:d,error:o,id:x,required:a,children:e.jsxs(q.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[r&&e.jsx(j.FieldLabel,{action:u,children:r}),e.jsx(h.FieldInput,{...i}),e.jsx(m.FieldHint,{}),e.jsx(f.FieldError,{})]})})})});s.displayName="TextInput";exports.TextInput=s;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as c, useRef as u, useImperativeHandle as h } from "react";
|
|
3
3
|
import { useId as I } from "../hooks/useId.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Field as x } from "../Field/Field.js";
|
|
5
|
+
import { Flex as F } from "../Flex/Flex.js";
|
|
6
|
+
import { FieldLabel as T } from "../Field/FieldLabel.js";
|
|
7
|
+
import { FieldInput as g } from "../Field/FieldInput.js";
|
|
8
8
|
import { FieldHint as w } from "../Field/FieldHint.js";
|
|
9
9
|
import { FieldError as R } from "../Field/FieldError.js";
|
|
10
10
|
const b = c(({ name: t, hint: n, error: m, label: e, labelAction: p, id: d, required: a, ...i }, l) => {
|
|
@@ -13,7 +13,7 @@ const b = c(({ name: t, hint: n, error: m, label: e, labelAction: p, id: d, requ
|
|
|
13
13
|
throw new Error('The TextInput component needs a "label" or an "aria-label" props');
|
|
14
14
|
return h(l, () => ({
|
|
15
15
|
inputWrapperRef: o
|
|
16
|
-
})), r("div", { ref: o, children: r(
|
|
16
|
+
})), r("div", { ref: o, children: r(x, { name: t, hint: n, error: m, id: f, required: a, children: s(F, { direction: "column", alignItems: "stretch", gap: 1, children: [e && r(T, { action: p, children: e }), r(g, { ...i }), r(w, {}), r(R, {})] }) }) });
|
|
17
17
|
});
|
|
18
18
|
b.displayName = "TextInput";
|
|
19
19
|
export {
|