@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,44 +1,44 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as h, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import * as u from "react";
|
|
3
|
-
import { Item as
|
|
4
|
-
import { stripReactIdOfColon as
|
|
3
|
+
import { Item as q, ItemText as W, Root as _, Trigger as H, Value as M, Portal as P, Content as z, Viewport as A } from "./SelectParts.js";
|
|
4
|
+
import { stripReactIdOfColon as D } from "../helpers/strings.js";
|
|
5
5
|
import { useId as R } from "../hooks/useId.js";
|
|
6
|
-
import { useIntersection as
|
|
6
|
+
import { useIntersection as G } from "../hooks/useIntersection.js";
|
|
7
7
|
import { Box as x } from "../Box/Box.js";
|
|
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
|
-
return e(
|
|
17
|
-
|
|
18
|
-
}, action:
|
|
19
|
-
},
|
|
20
|
-
const [
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
l && l(
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
}, b = u.useRef(null),
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
import { Typography as J } from "../Typography/Typography.js";
|
|
9
|
+
import { Field as K } from "../Field/Field.js";
|
|
10
|
+
import { Flex as Q } from "../Flex/Flex.js";
|
|
11
|
+
import { FieldLabel as U } from "../Field/FieldLabel.js";
|
|
12
|
+
import { FieldHint as X } from "../Field/FieldHint.js";
|
|
13
|
+
import { FieldError as Y } from "../Field/FieldError.js";
|
|
14
|
+
const me = ({ error: c, hint: t, id: d, label: n, labelAction: i, required: a, selectButtonTitle: g, ...p }) => {
|
|
15
|
+
const o = R(d), l = u.useRef(null);
|
|
16
|
+
return e(K, { hint: t, error: c, id: o, required: a, children: h(Q, { direction: "column", alignItems: "stretch", gap: 1, children: [n ? e(U, { onClick: () => {
|
|
17
|
+
l.current.focus();
|
|
18
|
+
}, action: i, children: n }) : null, e(Z, { label: n, id: o, triggerRef: l, required: a, ...p }), e(X, {}), e(Y, {})] }) });
|
|
19
|
+
}, Z = ({ "aria-label": c, id: t, children: d, clearLabel: n = "Clear", customizeContent: i, disabled: a, error: g, label: p, onChange: o, onClear: l, onReachEnd: m, placeholder: C, required: B, selectButtonTitle: ee, startIcon: O, size: T = "M", value: f, triggerRef: F, ...$ }) => {
|
|
20
|
+
const [y, I] = u.useState(), [k, w] = u.useState(!1), L = (r) => {
|
|
21
|
+
w(r);
|
|
22
|
+
}, v = (r) => {
|
|
23
|
+
l && l(r), o || I("");
|
|
24
|
+
}, E = `${t}-hint`, N = `${t}-error`, V = (r) => {
|
|
25
|
+
o ? o(typeof f == "number" ? Number(r) : r) : I(r);
|
|
26
|
+
}, b = u.useRef(null), j = R(), S = `intersection-${D(j)}`;
|
|
27
|
+
G(b, (r) => {
|
|
28
|
+
m && m(r);
|
|
29
29
|
}, {
|
|
30
30
|
selectorToWatch: `#${S}`,
|
|
31
31
|
/**
|
|
32
32
|
* We need to know when the select is open because only then will viewportRef
|
|
33
33
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
34
34
|
*/
|
|
35
|
-
skipWhen: !
|
|
35
|
+
skipWhen: !k
|
|
36
36
|
});
|
|
37
|
-
const s = (typeof
|
|
38
|
-
return
|
|
39
|
-
},
|
|
37
|
+
const s = (typeof f < "u" && f !== null ? f.toString() : y) ?? "";
|
|
38
|
+
return h(_, { onOpenChange: L, disabled: a, required: B, onValueChange: V, value: s, ...$, children: [e(H, { ref: F, "aria-label": p ?? c, "aria-describedby": t ? `${E} ${N}` : void 0, id: t, startIcon: O, size: T, hasError: !!g, disabled: a, clearLabel: n, onClear: s && l ? v : void 0, children: e(M, { placeholder: C, textColor: s ? "neutral800" : "neutral600", children: s && i ? i(s) : void 0 }) }), e(P, { children: e(z, { position: "popper", sideOffset: 4, children: h(A, { ref: b, children: [d, e(x, { id: S, width: "100%", height: "1px" })] }) }) })] });
|
|
39
|
+
}, ge = u.forwardRef(({ value: c, startIcon: t, children: d, ...n }, i) => h(q, { ref: i, value: c.toString(), ...n, children: [t && e(x, { as: "span", "aria-hidden": !0, children: t }), e(J, { textColor: "neutral800", children: e(W, { children: d }) })] }));
|
|
40
40
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
me as SingleSelect,
|
|
42
|
+
Z as SingleSelectInput,
|
|
43
|
+
ge as SingleSelectOption
|
|
44
44
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),N=require("@strapi/icons"),C=require("@strapi/ui-primitives"),F=require("react-router-dom"),W=require("styled-components"),R=require("./utils.cjs"),s=require("../helpers/keyboardKeys.cjs"),H=require("../hooks/useId.cjs"),U=require("../Link/Link.cjs"),M=require("../Button/Button.cjs"),z=require("../Popover/Popover.cjs"),E=require("../Box/Box.cjs"),D=require("../Typography/Typography.cjs"),G=require("../Flex/Flex.cjs"),w=e=>e&&e.__esModule?e:{default:e},K=w(r),m=w(W),J=m.default.button`
|
|
2
2
|
border: none;
|
|
3
3
|
padding: 0;
|
|
4
4
|
background: transparent;
|
|
5
5
|
cursor: pointer;
|
|
6
|
-
${
|
|
7
|
-
`,
|
|
6
|
+
${R.getOptionStyle}
|
|
7
|
+
`,Q=m.default(F.NavLink)`
|
|
8
8
|
text-decoration: none;
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
9
|
+
${R.getOptionStyle}
|
|
10
|
+
`,X=m.default(U.Link)`
|
|
11
11
|
/* Removing Link hover effect */
|
|
12
12
|
&:hover {
|
|
13
13
|
color: currentColor;
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
${
|
|
26
|
-
`,
|
|
25
|
+
${R.getOptionStyle}
|
|
26
|
+
`,Y=m.default.span`
|
|
27
27
|
display: flex;
|
|
28
28
|
align-items: center;
|
|
29
29
|
svg {
|
|
30
30
|
height: 4px;
|
|
31
31
|
width: 6px;
|
|
32
32
|
}
|
|
33
|
-
`,
|
|
33
|
+
`,Z=m.default(M.Button)`
|
|
34
34
|
padding: ${({theme:e})=>`${e.spaces[1]} ${e.spaces[3]}`};
|
|
35
|
-
`,
|
|
35
|
+
`,ee=({children:e,onClick:h=()=>{},to:i,isFocused:u=!1,href:c,...j})=>{const a=r.useRef();r.useEffect(()=>{u&&a.current&&a.current.focus()},[u]);const l={tabIndex:u?0:-1,ref:a,role:"menuitem",...j},d=x=>{(x.key===s.KeyboardKeys.SPACE||x.key===s.KeyboardKeys.ENTER)&&h()};return i&&!c?o.jsx(Q,{to:i,...l,children:o.jsx(E.Box,{padding:2,children:o.jsx(D.Typography,{children:e})})}):c&&!i?o.jsx(X,{isExternal:!0,href:c,...l,children:o.jsx(E.Box,{padding:2,children:o.jsx(D.Typography,{children:e})})}):o.jsx(J,{onKeyDown:d,onMouseDown:h,type:"button",...l,children:o.jsx(E.Box,{padding:2,children:o.jsx(D.Typography,{children:e})})})},ne=({label:e,children:h,id:i,as:u,onOpen:c=()=>{},onClose:j=()=>{},size:a="M",popoverPlacement:l="bottom-start",onReachEnd:d,...x})=>{const f=r.useRef(void 0),k=H.useId(i),b=r.useRef(!1),[p,y]=r.useState(!1),[I,v]=r.useState(0),g=r.Children.toArray(h),P=a==="S"?Z:M.Button,T=u||P,q=!!d&&typeof d=="function";r.useEffect(()=>{if(["string","number"].includes(typeof e)){const n=g.findIndex(t=>K.default.isValidElement(t)&&t.props.children===e||t===e);n!==-1&&v(n)}},[e]);const S=C.useCallbackRef(c),B=C.useCallbackRef(j);r.useEffect(()=>{b?.current?p?S():B():b.current=!0},[b,B,S,p]),r.useEffect(()=>{K.default.isValidElement(e)&&I===-1&&f.current.focus()},[e,I]);const O=n=>{p&&(n.key===s.KeyboardKeys.ESCAPE&&(n.stopPropagation(),y(!1),f.current.focus()),n.key===s.KeyboardKeys.DOWN&&v(t=>t===g.length-1?0:t+1),n.key===s.KeyboardKeys.UP&&v(t=>t===0?g.length-1:t-1))},$=n=>{(n.key===s.KeyboardKeys.ENTER||n.key===s.KeyboardKeys.SPACE)&&y(t=>!t)},L=n=>{n.preventDefault(),n.currentTarget.contains(n.relatedTarget)||y(!1)},_=n=>{n.preventDefault(),y(t=>!t)},A=()=>{q&&d()},V=g.map((n,t)=>o.jsx(G.Flex,{as:"li",justifyContent:"center",role:"menuitem",children:K.default.isValidElement(n)?r.cloneElement(n,{onClick(){n.props.onClick(),y(!1),f.current.focus()},isFocused:I===t}):n},t));return o.jsxs("div",{onKeyDown:O,children:[o.jsx(T,{label:K.default.isValidElement(e)?null:e,"aria-haspopup":!0,"aria-expanded":p,"aria-controls":k,onKeyDown:$,onMouseDown:_,ref:f,type:"button",variant:"ghost",endIcon:o.jsx(Y,{children:o.jsx(N.CarretDown,{"aria-hidden":!0})}),...x,children:e}),p&&o.jsx(z.Popover,{onBlur:L,placement:l,source:f,onReachEnd:A,intersectionId:q?`popover-${k}`:void 0,spacing:4,children:o.jsx(E.Box,{role:"menu",as:"ul",padding:1,id:k,children:V})})]})};exports.MenuItem=ee;exports.SimpleMenu=ne;
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { CarretDown as
|
|
4
|
-
import { useCallbackRef as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import y from "styled-components";
|
|
1
|
+
import { jsx as t, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import x, { useRef as S, useEffect as E, useState as $, Children as _, cloneElement as H } from "react";
|
|
3
|
+
import { CarretDown as U } from "@strapi/icons";
|
|
4
|
+
import { useCallbackRef as P } from "@strapi/ui-primitives";
|
|
5
|
+
import { NavLink as q } from "react-router-dom";
|
|
6
|
+
import m from "styled-components";
|
|
8
7
|
import { getOptionStyle as b } from "./utils.js";
|
|
9
|
-
import { KeyboardKeys as
|
|
10
|
-
import { useId as
|
|
11
|
-
import { Link as
|
|
8
|
+
import { KeyboardKeys as r } from "../helpers/keyboardKeys.js";
|
|
9
|
+
import { useId as z } from "../hooks/useId.js";
|
|
10
|
+
import { Link as G } from "../Link/Link.js";
|
|
12
11
|
import { Button as L } from "../Button/Button.js";
|
|
13
|
-
import {
|
|
14
|
-
import { Box as
|
|
15
|
-
import { Typography as
|
|
16
|
-
import { Flex as
|
|
17
|
-
const
|
|
12
|
+
import { Popover as J } from "../Popover/Popover.js";
|
|
13
|
+
import { Box as k } from "../Box/Box.js";
|
|
14
|
+
import { Typography as R } from "../Typography/Typography.js";
|
|
15
|
+
import { Flex as Q } from "../Flex/Flex.js";
|
|
16
|
+
const X = m.button`
|
|
18
17
|
border: none;
|
|
19
18
|
padding: 0;
|
|
20
19
|
background: transparent;
|
|
21
20
|
cursor: pointer;
|
|
22
21
|
${b}
|
|
23
|
-
`,
|
|
22
|
+
`, Y = m(q)`
|
|
24
23
|
text-decoration: none;
|
|
25
24
|
${b}
|
|
26
|
-
`,
|
|
25
|
+
`, Z = m(G)`
|
|
27
26
|
/* Removing Link hover effect */
|
|
28
27
|
&:hover {
|
|
29
28
|
color: currentColor;
|
|
@@ -31,7 +30,7 @@ const ne = y.button`
|
|
|
31
30
|
|
|
32
31
|
&:focus-visible {
|
|
33
32
|
/* Removing Link focus-visible after properties and reset to global outline */
|
|
34
|
-
outline: 2px solid ${({ theme:
|
|
33
|
+
outline: 2px solid ${({ theme: n }) => n.colors.primary600};
|
|
35
34
|
outline-offset: 2px;
|
|
36
35
|
&:after {
|
|
37
36
|
content: none;
|
|
@@ -39,160 +38,72 @@ const ne = y.button`
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
${b}
|
|
42
|
-
`,
|
|
41
|
+
`, ee = m.span`
|
|
43
42
|
display: flex;
|
|
44
43
|
align-items: center;
|
|
45
44
|
svg {
|
|
46
45
|
height: 4px;
|
|
47
46
|
width: 6px;
|
|
48
47
|
}
|
|
49
|
-
`,
|
|
50
|
-
padding: ${({ theme:
|
|
51
|
-
`,
|
|
52
|
-
|
|
48
|
+
`, ne = m(L)`
|
|
49
|
+
padding: ${({ theme: n }) => `${n.spaces[1]} ${n.spaces[3]}`};
|
|
50
|
+
`, xe = ({ children: n, onClick: h = () => {
|
|
51
|
+
}, to: i, isFocused: s = !1, href: c, ...D }) => {
|
|
52
|
+
const a = S();
|
|
53
53
|
E(() => {
|
|
54
|
-
|
|
55
|
-
}, [
|
|
54
|
+
s && a.current && a.current.focus();
|
|
55
|
+
}, [s]);
|
|
56
56
|
const l = {
|
|
57
|
-
tabIndex:
|
|
58
|
-
ref:
|
|
57
|
+
tabIndex: s ? 0 : -1,
|
|
58
|
+
ref: a,
|
|
59
59
|
role: "menuitem",
|
|
60
|
-
...
|
|
61
|
-
},
|
|
62
|
-
(
|
|
60
|
+
...D
|
|
61
|
+
}, u = (y) => {
|
|
62
|
+
(y.key === r.SPACE || y.key === r.ENTER) && h();
|
|
63
63
|
};
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
isFocused: !1,
|
|
70
|
-
onClick() {
|
|
71
|
-
},
|
|
72
|
-
to: void 0
|
|
73
|
-
};
|
|
74
|
-
A.propTypes = {
|
|
75
|
-
as: e.elementType,
|
|
76
|
-
children: e.node.isRequired,
|
|
77
|
-
href: e.string,
|
|
78
|
-
isFocused: e.bool,
|
|
79
|
-
onClick: e.func,
|
|
80
|
-
to: e.string
|
|
81
|
-
};
|
|
82
|
-
const k = ({
|
|
83
|
-
label: o,
|
|
84
|
-
children: h,
|
|
85
|
-
id: s,
|
|
86
|
-
as: c,
|
|
87
|
-
onOpen: a = () => {
|
|
88
|
-
},
|
|
89
|
-
onClose: x = () => {
|
|
90
|
-
},
|
|
91
|
-
size: d,
|
|
92
|
-
popoverPlacement: l,
|
|
93
|
-
onReachEnd: p,
|
|
94
|
-
...g
|
|
95
|
-
}) => {
|
|
96
|
-
const u = T(), P = Q(s), R = T(!1), [f, m] = K(!1), [D, I] = K(0), v = H.toArray(h), N = c || (d === "S" ? ie : L), S = !!p && typeof p == "function";
|
|
64
|
+
return i && !c ? t(Y, { to: i, ...l, children: t(k, { padding: 2, children: t(R, { children: n }) }) }) : c && !i ? t(Z, { isExternal: !0, href: c, ...l, children: t(k, { padding: 2, children: t(R, { children: n }) }) }) : t(X, { onKeyDown: u, onMouseDown: h, type: "button", ...l, children: t(k, { padding: 2, children: t(R, { children: n }) }) });
|
|
65
|
+
}, Ee = ({ label: n, children: h, id: i, as: s, onOpen: c = () => {
|
|
66
|
+
}, onClose: D = () => {
|
|
67
|
+
}, size: a = "M", popoverPlacement: l = "bottom-start", onReachEnd: u, ...y }) => {
|
|
68
|
+
const d = S(void 0), I = z(i), C = S(!1), [f, p] = $(!1), [v, w] = $(0), g = _.toArray(h), O = s || (a === "S" ? ne : L), B = !!u && typeof u == "function";
|
|
97
69
|
E(() => {
|
|
98
|
-
if (["string", "number"].includes(typeof
|
|
99
|
-
const
|
|
100
|
-
|
|
70
|
+
if (["string", "number"].includes(typeof n)) {
|
|
71
|
+
const e = g.findIndex((o) => x.isValidElement(o) && o.props.children === n || o === n);
|
|
72
|
+
e !== -1 && w(e);
|
|
101
73
|
}
|
|
102
|
-
}, [
|
|
103
|
-
const
|
|
74
|
+
}, [n]);
|
|
75
|
+
const K = P(c), M = P(D);
|
|
104
76
|
E(() => {
|
|
105
|
-
|
|
106
|
-
}, [
|
|
107
|
-
|
|
108
|
-
}, [
|
|
109
|
-
const
|
|
110
|
-
f && (
|
|
111
|
-
},
|
|
112
|
-
(
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
},
|
|
77
|
+
C?.current ? f ? K() : M() : C.current = !0;
|
|
78
|
+
}, [C, M, K, f]), E(() => {
|
|
79
|
+
x.isValidElement(n) && v === -1 && d.current.focus();
|
|
80
|
+
}, [n, v]);
|
|
81
|
+
const T = (e) => {
|
|
82
|
+
f && (e.key === r.ESCAPE && (e.stopPropagation(), p(!1), d.current.focus()), e.key === r.DOWN && w((o) => o === g.length - 1 ? 0 : o + 1), e.key === r.UP && w((o) => o === 0 ? g.length - 1 : o - 1));
|
|
83
|
+
}, A = (e) => {
|
|
84
|
+
(e.key === r.ENTER || e.key === r.SPACE) && p((o) => !o);
|
|
85
|
+
}, V = (e) => {
|
|
86
|
+
e.preventDefault(), e.currentTarget.contains(e.relatedTarget) || p(!1);
|
|
87
|
+
}, N = (e) => {
|
|
88
|
+
e.preventDefault(), p((o) => !o);
|
|
89
|
+
}, j = () => {
|
|
90
|
+
B && u();
|
|
91
|
+
}, W = g.map((e, o) => (
|
|
120
92
|
// eslint-disable-next-line react/no-array-index-key
|
|
121
|
-
|
|
93
|
+
t(Q, { as: "li", justifyContent: "center", role: "menuitem", children: x.isValidElement(e) ? H(e, {
|
|
122
94
|
onClick() {
|
|
123
|
-
|
|
95
|
+
e.props.onClick(), p(!1), d.current.focus();
|
|
124
96
|
},
|
|
125
|
-
isFocused:
|
|
126
|
-
}) },
|
|
97
|
+
isFocused: v === o
|
|
98
|
+
}) : e }, o)
|
|
127
99
|
));
|
|
128
100
|
return (
|
|
129
101
|
// TODO: review why we need to eslint it and how to solve this issue.
|
|
130
102
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
131
|
-
|
|
132
|
-
/* @__PURE__ */ t(
|
|
133
|
-
N,
|
|
134
|
-
{
|
|
135
|
-
label: B.isValidElement(o) ? null : o,
|
|
136
|
-
"aria-haspopup": !0,
|
|
137
|
-
"aria-expanded": f,
|
|
138
|
-
"aria-controls": P,
|
|
139
|
-
onKeyDown: V,
|
|
140
|
-
onMouseDown: q,
|
|
141
|
-
ref: u,
|
|
142
|
-
type: "button",
|
|
143
|
-
variant: "ghost",
|
|
144
|
-
endIcon: /* @__PURE__ */ t(re, { children: /* @__PURE__ */ t(G, { "aria-hidden": !0 }) }),
|
|
145
|
-
...g,
|
|
146
|
-
children: o
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
f && /* @__PURE__ */ t(
|
|
150
|
-
Z,
|
|
151
|
-
{
|
|
152
|
-
onBlur: j,
|
|
153
|
-
placement: l,
|
|
154
|
-
source: u,
|
|
155
|
-
onReachEnd: W,
|
|
156
|
-
intersectionId: S ? `popover-${P}` : void 0,
|
|
157
|
-
spacing: 4,
|
|
158
|
-
children: /* @__PURE__ */ t(C, { role: "menu", as: "ul", padding: 1, id: P, children: _ })
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
] })
|
|
103
|
+
F("div", { onKeyDown: T, children: [t(O, { label: x.isValidElement(n) ? null : n, "aria-haspopup": !0, "aria-expanded": f, "aria-controls": I, onKeyDown: A, onMouseDown: N, ref: d, type: "button", variant: "ghost", endIcon: t(ee, { children: t(U, { "aria-hidden": !0 }) }), ...y, children: n }), f && t(J, { onBlur: V, placement: l, source: d, onReachEnd: j, intersectionId: B ? `popover-${I}` : void 0, spacing: 4, children: t(k, { role: "menu", as: "ul", padding: 1, id: I, children: W }) })] })
|
|
162
104
|
);
|
|
163
105
|
};
|
|
164
|
-
k.defaultProps = {
|
|
165
|
-
as: void 0
|
|
166
|
-
};
|
|
167
|
-
k.displayName = "SimpleMenu";
|
|
168
|
-
k.defaultProps = {
|
|
169
|
-
id: void 0,
|
|
170
|
-
onOpen: void 0,
|
|
171
|
-
onClose: void 0,
|
|
172
|
-
onReachEnd: void 0,
|
|
173
|
-
popoverPlacement: "bottom-start",
|
|
174
|
-
size: "M"
|
|
175
|
-
};
|
|
176
|
-
k.propTypes = {
|
|
177
|
-
as: e.any,
|
|
178
|
-
children: e.oneOfType([e.arrayOf(e.node), e.node]).isRequired,
|
|
179
|
-
id: e.string,
|
|
180
|
-
label: e.oneOfType([e.string, e.number, e.element]).isRequired,
|
|
181
|
-
onClose: e.func,
|
|
182
|
-
onOpen: e.func,
|
|
183
|
-
/**
|
|
184
|
-
* Callback function to be called when the popover reaches the end of the scrollable content
|
|
185
|
-
*/
|
|
186
|
-
onReachEnd: e.func,
|
|
187
|
-
popoverPlacement: e.oneOf(Y),
|
|
188
|
-
/**
|
|
189
|
-
* Size of the trigger button.
|
|
190
|
-
* Note: in case a custom component is passed through the "as"
|
|
191
|
-
* prop, the size prop is passed along too, but needs to be handled there
|
|
192
|
-
*/
|
|
193
|
-
size: e.oneOf(["S", "M"])
|
|
194
|
-
};
|
|
195
106
|
export {
|
|
196
|
-
|
|
197
|
-
|
|
107
|
+
xe as MenuItem,
|
|
108
|
+
Ee as SimpleMenu
|
|
198
109
|
};
|
package/dist/SubNav/SubNav.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
width: ${
|
|
3
|
-
background: ${({theme:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),s=require("styled-components"),u=require("../Grid/Grid.cjs"),a=t=>t&&t.__esModule?t:{default:t},i=a(s),e=`${232/16}rem`,n=i.default(u.Grid)`
|
|
2
|
+
width: ${e};
|
|
3
|
+
background: ${({theme:t})=>t.colors.neutral100};
|
|
4
4
|
position: sticky;
|
|
5
5
|
top: 0;
|
|
6
6
|
height: 100vh;
|
|
7
7
|
overflow-y: auto;
|
|
8
|
-
border-right: 1px solid ${({theme:
|
|
8
|
+
border-right: 1px solid ${({theme:t})=>t.colors.neutral200};
|
|
9
9
|
z-index: 1;
|
|
10
|
-
`,
|
|
10
|
+
`,l=({ariaLabel:t,...r})=>o.jsx(n,{"aria-label":t,as:"nav",...r});exports.SubNav=l;exports.subNavWidth=e;
|
package/dist/SubNav/SubNav.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import "
|
|
3
|
-
import i from "prop-types";
|
|
4
|
-
import e from "styled-components";
|
|
2
|
+
import i from "styled-components";
|
|
5
3
|
import { Grid as a } from "../Grid/Grid.js";
|
|
6
|
-
const
|
|
7
|
-
width: ${
|
|
8
|
-
background: ${({ theme:
|
|
4
|
+
const e = `${232 / 16}rem`, s = i(a)`
|
|
5
|
+
width: ${e};
|
|
6
|
+
background: ${({ theme: o }) => o.colors.neutral100};
|
|
9
7
|
position: sticky;
|
|
10
8
|
top: 0;
|
|
11
9
|
height: 100vh;
|
|
12
10
|
overflow-y: auto;
|
|
13
|
-
border-right: 1px solid ${({ theme:
|
|
11
|
+
border-right: 1px solid ${({ theme: o }) => o.colors.neutral200};
|
|
14
12
|
z-index: 1;
|
|
15
|
-
`,
|
|
16
|
-
n.propTypes = {
|
|
17
|
-
ariaLabel: i.string.isRequired
|
|
18
|
-
};
|
|
13
|
+
`, d = ({ ariaLabel: o, ...r }) => t(s, { "aria-label": o, as: "nav", ...r });
|
|
19
14
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
d as SubNav,
|
|
16
|
+
e as subNavWidth
|
|
22
17
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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"),s=require("react"),v=require("@strapi/icons"),C=require("styled-components"),R=require("../helpers/keyboardKeys.cjs"),T=require("../hooks/useId.cjs"),D=require("../hooks/usePrevious.cjs"),I=require("../Searchbar/SearchForm.cjs"),K=require("../Searchbar/Searchbar.cjs"),_=require("../Divider/Divider.cjs"),c=require("../Box/Box.cjs"),k=require("../Flex/Flex.cjs"),w=require("../Typography/Typography.cjs"),F=require("../IconButton/IconButton.cjs"),O=r=>r&&r.__esModule?r:{default:r},P=O(C),l=P.default(_.Divider)`
|
|
2
2
|
width: ${24/16}rem;
|
|
3
|
-
background-color: ${({theme:
|
|
4
|
-
`,
|
|
3
|
+
background-color: ${({theme:r})=>r.colors.neutral200};
|
|
4
|
+
`,E=({as:r="h2",label:f,searchLabel:u="",searchable:h,onChange:p=()=>{},value:g="",onClear:x=()=>{},onSubmit:S=()=>{},id:y})=>{const[t,a]=s.useState(!1),d=D.usePrevious(t),b=T.useId(y),o=s.useRef(null),i=s.useRef(null);s.useEffect(()=>{t&&o.current&&o.current.focus(),d&&!t&&i.current&&i.current.focus()},[t,d]);const j=()=>{a(n=>!n)},q=n=>{x(n),o?.current&&o.current.focus()},B=n=>{n.relatedTarget?.id!==b&&a(!1)},m=n=>{n.key===R.KeyboardKeys.ESCAPE&&a(!1)};return t?e.jsxs(c.Box,{paddingLeft:4,paddingTop:5,paddingBottom:2,paddingRight:4,children:[e.jsx(I.SearchForm,{children:e.jsx(K.Searchbar,{name:"searchbar",value:g,onChange:p,placeholder:"e.g: strapi-plugin-abcd",onKeyDown:m,ref:o,onBlur:B,onClear:q,onSubmit:S,clearLabel:"Clear",size:"S",children:u})}),e.jsx(c.Box,{paddingLeft:2,paddingTop:4,children:e.jsx(l,{})})]}):e.jsxs(c.Box,{paddingLeft:6,paddingTop:6,paddingBottom:2,paddingRight:4,children:[e.jsxs(k.Flex,{justifyContent:"space-between",alignItems:"flex-start",children:[e.jsx(w.Typography,{variant:"beta",as:r,children:f}),h&&e.jsx(F.IconButton,{ref:i,onClick:j,label:u,icon:e.jsx(v.Search,{})})]}),e.jsx(c.Box,{paddingTop:4,children:e.jsx(l,{})})]})};exports.SubNavHeader=E;
|
|
@@ -1,86 +1,39 @@
|
|
|
1
1
|
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Search as
|
|
4
|
-
import
|
|
5
|
-
import K from "
|
|
6
|
-
import { KeyboardKeys as P } from "../helpers/keyboardKeys.js";
|
|
2
|
+
import { useState as R, useRef as p, useEffect as w } from "react";
|
|
3
|
+
import { Search as D } from "@strapi/icons";
|
|
4
|
+
import I from "styled-components";
|
|
5
|
+
import { KeyboardKeys as K } from "../helpers/keyboardKeys.js";
|
|
7
6
|
import { useId as j } from "../hooks/useId.js";
|
|
8
7
|
import { usePrevious as k } from "../hooks/usePrevious.js";
|
|
9
8
|
import { SearchForm as E } from "../Searchbar/SearchForm.js";
|
|
10
|
-
import { Searchbar as
|
|
11
|
-
import { Divider as
|
|
12
|
-
import { Box as
|
|
13
|
-
import { Flex as
|
|
14
|
-
import { Typography as
|
|
15
|
-
import { IconButton as
|
|
16
|
-
const
|
|
9
|
+
import { Searchbar as L } from "../Searchbar/Searchbar.js";
|
|
10
|
+
import { Divider as O } from "../Divider/Divider.js";
|
|
11
|
+
import { Box as n } from "../Box/Box.js";
|
|
12
|
+
import { Flex as F } from "../Flex/Flex.js";
|
|
13
|
+
import { Typography as P } from "../Typography/Typography.js";
|
|
14
|
+
import { IconButton as $ } from "../IconButton/IconButton.js";
|
|
15
|
+
const f = I(O)`
|
|
17
16
|
width: ${24 / 16}rem;
|
|
18
17
|
background-color: ${({ theme: i }) => i.colors.neutral200};
|
|
19
|
-
`,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
`, Z = ({ as: i = "h2", label: m, searchLabel: l = "", searchable: u, onChange: h = () => {
|
|
19
|
+
}, value: g = "", onClear: S = () => {
|
|
20
|
+
}, onSubmit: b = () => {
|
|
21
|
+
}, id: y }) => {
|
|
22
|
+
const [o, a] = R(!1), s = k(o), B = j(y), t = p(null), c = p(null);
|
|
23
|
+
w(() => {
|
|
24
|
+
o && t.current && t.current.focus(), s && !o && c.current && c.current.focus();
|
|
25
|
+
}, [o, s]);
|
|
26
|
+
const C = () => {
|
|
27
|
+
a((r) => !r);
|
|
28
|
+
}, v = (r) => {
|
|
29
|
+
S(r), t?.current && t.current.focus();
|
|
30
|
+
}, x = (r) => {
|
|
31
|
+
r.relatedTarget?.id !== B && a(!1);
|
|
32
|
+
}, T = (r) => {
|
|
33
|
+
r.key === K.ESCAPE && a(!1);
|
|
32
34
|
};
|
|
33
|
-
return
|
|
34
|
-
/* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
|
|
35
|
-
O,
|
|
36
|
-
{
|
|
37
|
-
name: "searchbar",
|
|
38
|
-
value: S,
|
|
39
|
-
onChange: b,
|
|
40
|
-
placeholder: "e.g: strapi-plugin-abcd",
|
|
41
|
-
onKeyDown: L,
|
|
42
|
-
ref: t,
|
|
43
|
-
onBlur: R,
|
|
44
|
-
onClear: x,
|
|
45
|
-
onSubmit: C,
|
|
46
|
-
clearLabel: "Clear",
|
|
47
|
-
size: "S",
|
|
48
|
-
children: l
|
|
49
|
-
}
|
|
50
|
-
) }),
|
|
51
|
-
/* @__PURE__ */ e(a, { paddingLeft: 2, paddingTop: 4, children: /* @__PURE__ */ e(m, {}) })
|
|
52
|
-
] }) : /* @__PURE__ */ d(a, { paddingLeft: 6, paddingTop: 6, paddingBottom: 2, paddingRight: 4, children: [
|
|
53
|
-
/* @__PURE__ */ d($, { justifyContent: "space-between", alignItems: "flex-start", children: [
|
|
54
|
-
/* @__PURE__ */ e(q, { variant: "beta", as: i, children: h }),
|
|
55
|
-
g && /* @__PURE__ */ e(z, { ref: c, onClick: T, label: l, icon: /* @__PURE__ */ e(I, {}) })
|
|
56
|
-
] }),
|
|
57
|
-
/* @__PURE__ */ e(a, { paddingTop: 4, children: /* @__PURE__ */ e(m, {}) })
|
|
58
|
-
] });
|
|
59
|
-
};
|
|
60
|
-
u.defaultProps = {
|
|
61
|
-
as: "h2",
|
|
62
|
-
searchable: !1,
|
|
63
|
-
onChange() {
|
|
64
|
-
},
|
|
65
|
-
onClear() {
|
|
66
|
-
},
|
|
67
|
-
onSubmit() {
|
|
68
|
-
},
|
|
69
|
-
value: "",
|
|
70
|
-
searchLabel: "",
|
|
71
|
-
id: void 0
|
|
72
|
-
};
|
|
73
|
-
u.propTypes = {
|
|
74
|
-
as: r.string,
|
|
75
|
-
id: r.string,
|
|
76
|
-
label: r.string.isRequired,
|
|
77
|
-
onChange: r.func,
|
|
78
|
-
onClear: r.func,
|
|
79
|
-
onSubmit: r.func,
|
|
80
|
-
searchLabel: r.string,
|
|
81
|
-
searchable: r.bool,
|
|
82
|
-
value: r.string
|
|
35
|
+
return o ? d(n, { paddingLeft: 4, paddingTop: 5, paddingBottom: 2, paddingRight: 4, children: [e(E, { children: e(L, { name: "searchbar", value: g, onChange: h, placeholder: "e.g: strapi-plugin-abcd", onKeyDown: T, ref: t, onBlur: x, onClear: v, onSubmit: b, clearLabel: "Clear", size: "S", children: l }) }), e(n, { paddingLeft: 2, paddingTop: 4, children: e(f, {}) })] }) : d(n, { paddingLeft: 6, paddingTop: 6, paddingBottom: 2, paddingRight: 4, children: [d(F, { justifyContent: "space-between", alignItems: "flex-start", children: [e(P, { variant: "beta", as: i, children: m }), u && e($, { ref: c, onClick: C, label: l, icon: e(D, {}) })] }), e(n, { paddingTop: 4, children: e(f, {}) })] });
|
|
83
36
|
};
|
|
84
37
|
export {
|
|
85
|
-
|
|
38
|
+
Z as SubNavHeader
|
|
86
39
|
};
|