@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.
- package/dist/BaseCheckbox/BaseCheckbox.cjs +4 -4
- package/dist/BaseCheckbox/BaseCheckbox.js +19 -18
- package/dist/CarouselInput/Carousel.cjs +4 -4
- package/dist/CarouselInput/Carousel.js +13 -13
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +14 -13
- package/dist/Checkbox/Checkbox.cjs +2 -2
- package/dist/Checkbox/Checkbox.js +22 -21
- package/dist/Combobox/Combobox.cjs +10 -10
- package/dist/Combobox/Combobox.js +57 -56
- package/dist/DatePicker/DatePicker.cjs +9 -9
- package/dist/DatePicker/DatePicker.js +67 -66
- package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
- package/dist/DateTimePicker/DateTimePicker.js +46 -42
- package/dist/JSONInput/JSONInput.cjs +33 -1
- package/dist/JSONInput/JSONInput.js +85 -46
- package/dist/Popover/Popover.cjs +3 -3
- package/dist/Popover/Popover.js +52 -51
- package/dist/Select/MultiSelect.cjs +7 -7
- package/dist/Select/MultiSelect.js +45 -44
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +35 -34
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +15 -14
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +38 -38
- package/dist/ToggleInput/ToggleInput.cjs +20 -4
- package/dist/ToggleInput/ToggleInput.js +44 -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/themes/utils.cjs +9 -9
- package/dist/themes/utils.js +9 -9
- package/package.json +10 -10
- package/dist/JSONInput/JSONInputContainer.cjs +0 -33
- package/dist/JSONInput/JSONInputContainer.js +0 -39
|
@@ -1 +1,33 @@
|
|
|
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"),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
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { json as
|
|
4
|
-
import { useCodeMirror as
|
|
5
|
-
import
|
|
6
|
-
import { markField as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 =
|
|
24
|
+
const r = s.current?.doc;
|
|
23
25
|
if (r) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
effects: q.of((
|
|
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
|
-
},
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
}, { setContainer:
|
|
38
|
-
value:
|
|
39
|
-
onCreateEditor:
|
|
40
|
-
container:
|
|
41
|
-
editable: !
|
|
42
|
-
extensions: [
|
|
43
|
-
onChange:
|
|
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
|
-
}),
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
102
|
+
lr as JSONInput
|
|
64
103
|
};
|
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"),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:
|
|
4
|
-
background-color: ${({theme:e,$selected:
|
|
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:
|
|
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&&
|
|
21
|
+
${({$selected:e})=>e&&b.css`
|
|
22
22
|
&::after {
|
|
23
23
|
content: '';
|
|
24
|
-
background: url(${
|
|
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
|
-
`,
|
|
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 {
|
|
2
|
-
import * as
|
|
3
|
-
import { Cross as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { stripReactIdOfColon as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { FieldHint as
|
|
17
|
-
import { FieldError as
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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: `#${
|
|
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: !
|
|
38
|
+
skipWhen: !q
|
|
38
39
|
});
|
|
39
|
-
const
|
|
40
|
-
return e(
|
|
41
|
-
},
|
|
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:
|
|
44
|
-
background-color: ${({ theme: t, $selected:
|
|
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:
|
|
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 &&
|
|
62
|
+
${({ $selected: t }) => t && O`
|
|
62
63
|
&::after {
|
|
63
64
|
content: '';
|
|
64
|
-
background: url(${
|
|
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
|
-
`,
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
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;
|