@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
package/dist/Button/Button.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
`,w=g.default(v.Loader)`
|
|
9
9
|
animation: ${R} 2s infinite linear;
|
|
10
10
|
will-change: transform;
|
|
11
|
-
`,
|
|
11
|
+
`,y=g.default(j.BaseButton)`
|
|
12
12
|
height: ${({theme:e,size:n})=>e.sizes.button[n]};
|
|
13
13
|
|
|
14
14
|
svg {
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
${r.getVariantStyle}
|
|
36
|
-
`,
|
|
36
|
+
`,h=D.default.forwardRef(({variant:e=l.DEFAULT,startIcon:n,endIcon:s,disabled:b=!1,children:p,onClick:d,size:u=l.BUTTON_SIZES[0],loading:i=!1,fullWidth:a=!1,...m},B)=>{const o=b||i,x=q=>{!o&&d&&d(q)};return t.jsxs(y,{ref:B,"aria-disabled":o,disabled:o,size:u,variant:e,onClick:x,fullWidth:a,alignItems:"center",background:"buttonPrimary600",borderColor:"buttonPrimary600",gap:2,inline:a,justifyContent:a?"center":void 0,paddingLeft:4,paddingRight:4,width:a?"100%":void 0,...m,children:[(n||i)&&t.jsx(_.Box,{"aria-hidden":!0,children:i?t.jsx(w,{}):n}),t.jsx($.Typography,{variant:u==="S"?"pi":void 0,fontWeight:"bold",textColor:"buttonNeutral0",children:p}),s&&t.jsx(T.Flex,{"aria-hidden":!0,children:s})]})});h.displayName="Button";exports.Button=h;exports.ButtonWrapper=y;
|
package/dist/Button/Button.js
CHANGED
|
@@ -43,11 +43,11 @@ const j = v`
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
${C}
|
|
46
|
-
`, N = b.forwardRef(({ variant: i = $, startIcon: t, endIcon: n, disabled: l = !1, children: p, onClick: d, size: m = B[0], loading: o = !1, fullWidth: e = !1, ...c },
|
|
46
|
+
`, N = b.forwardRef(({ variant: i = $, startIcon: t, endIcon: n, disabled: l = !1, children: p, onClick: d, size: m = B[0], loading: o = !1, fullWidth: e = !1, ...c }, u) => {
|
|
47
47
|
const a = l || o;
|
|
48
|
-
return g(D, { ref:
|
|
49
|
-
!a && d && d(
|
|
50
|
-
}, fullWidth: e, alignItems: "center", background: "buttonPrimary600", borderColor: "buttonPrimary600", gap: 2, inline: e, justifyContent: e ? "center" : void 0, paddingLeft: 4, paddingRight: 4, width: e ? "100%" : void 0, ...c, children: [(t || o) && r(w, { "aria-hidden": !0, children: o ? r(A, {}) : t }), r(L, { variant: m === "S" ? "pi" : void 0, fontWeight: "bold",
|
|
48
|
+
return g(D, { ref: u, "aria-disabled": a, disabled: a, size: m, variant: i, onClick: (h) => {
|
|
49
|
+
!a && d && d(h);
|
|
50
|
+
}, fullWidth: e, alignItems: "center", background: "buttonPrimary600", borderColor: "buttonPrimary600", gap: 2, inline: e, justifyContent: e ? "center" : void 0, paddingLeft: 4, paddingRight: 4, width: e ? "100%" : void 0, ...c, children: [(t || o) && r(w, { "aria-hidden": !0, children: o ? r(A, {}) : t }), r(L, { variant: m === "S" ? "pi" : void 0, fontWeight: "bold", textColor: "buttonNeutral0", children: p }), n && r(T, { "aria-hidden": !0, children: n })] });
|
|
51
51
|
});
|
|
52
52
|
N.displayName = "Button";
|
|
53
53
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),me=require("react"),M=require("@strapi/icons"),n=require("@strapi/ui-primitives"),Ce=require("styled-components"),$e=require("../helpers/strings.cjs"),j=require("../hooks/useControllableState.cjs"),I=require("../hooks/useId.cjs"),je=require("../hooks/useIntersection.cjs"),N=require("../themes/utils.cjs"),Ie=require("../Loader/Loader.cjs"),y=require("../Box/Box.cjs"),u=require("../Typography/Typography.cjs"),b=require("../Flex/Flex.cjs"),ye=require("../Field/Field.cjs"),we=require("../Field/FieldLabel.cjs"),qe=require("../Field/FieldHint.cjs"),Fe=require("../Field/FieldError.cjs"),Te=e=>e&&e.__esModule?e:{default:e};function ve(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),me=require("react"),M=require("@strapi/icons"),n=require("@strapi/ui-primitives"),Ce=require("styled-components"),$e=require("../helpers/strings.cjs"),j=require("../hooks/useControllableState.cjs"),I=require("../hooks/useId.cjs"),je=require("../hooks/useIntersection.cjs"),N=require("../themes/utils.cjs"),Ie=require("../Loader/Loader.cjs"),y=require("../Box/Box.cjs"),u=require("../Typography/Typography.cjs"),b=require("../Flex/Flex.cjs"),ye=require("../Field/Field.cjs"),we=require("../Field/FieldLabel.cjs"),qe=require("../Field/FieldHint.cjs"),Fe=require("../Field/FieldError.cjs"),Te=e=>e&&e.__esModule?e:{default:e};function ve(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,l.get?l:{enumerable:!0,get:()=>e[s]})}}return r.default=e,Object.freeze(r)}const x=ve(me),a=Te(Ce),H=({allowCustomValue:e,autocomplete:r,children:s,className:l,clearLabel:d="clear",creatable:i=!1,createMessage:f=p=>`Create "${p}"`,defaultFilterValue:h,defaultTextValue:w,defaultOpen:W=!1,open:U,onOpenChange:A,disabled:m=!1,error:q,filterValue:G,hasMoreItems:J=!1,id:F,isPrintableCharacter:K,loading:C=!1,loadingMessage:Q="Loading content...",noOptionsMessage:X=()=>"No results found",onChange:T,onClear:$,onCreateOption:v,onFilterValueChange:Y,onInputChange:R,onTextValueChange:Z,onLoadMore:k,placeholder:ee="Select or enter a value",required:oe=!1,size:re="M",startIcon:O,textValue:te,value:V,...ne})=>{const[p,se]=j.useControllableState({prop:U,defaultProp:W,onChange:A}),[c,S]=j.useControllableState({prop:te,defaultProp:e&&!w?V:w,onChange:Z}),[le,B]=j.useControllableState({prop:G,defaultProp:h,onChange:Y}),P=x.useRef(null),_=x.useRef(null),ie=x.useRef(null),ae=t=>{$&&!m&&(S(""),B(""),$(t),_.current.focus())},de=t=>{se(t)},ce=t=>{S(t)},ue=t=>{B(t)},he=t=>{R&&R(t)},pe=t=>{T&&T(t)},be=t=>{k&&J&&!C&&k(t)},z=()=>{v&&c&&v(c)},E=I.useId(F),xe=I.useId(),D=`intersection-${$e.stripReactIdOfColon(xe)}`;je.useIntersection(P,be,{selectorToWatch:`#${D}`,skipWhen:!p});const ge=`${E}-hint`,fe=`${E}-error`;return o.jsxs(n.Combobox.Root,{autocomplete:r||(i?"list":"both"),onOpenChange:de,open:p,onTextValueChange:ce,textValue:c,allowCustomValue:i||e,disabled:m,required:oe,value:V,onValueChange:pe,filterValue:le,onFilterValueChange:ue,isPrintableCharacter:K,children:[o.jsxs(Oe,{$hasError:!!q,$size:re,className:l,children:[o.jsxs(b.Flex,{flex:"1",as:"span",gap:3,children:[O?o.jsx(y.Box,{as:"span","aria-hidden":!0,children:O}):null,o.jsx(Ve,{placeholder:ee,id:F,"aria-invalid":!!q,"aria-describedby":`${ge} ${fe}`,onChange:he,ref:_,...ne})]}),o.jsxs(b.Flex,{as:"span",gap:3,children:[c&&$?o.jsx(ke,{as:"button",hasRadius:!0,background:"transparent",type:"button",onClick:ae,"aria-disabled":m,"aria-label":d,title:d,ref:ie,children:o.jsx(M.Cross,{})}):null,o.jsx(Se,{children:o.jsx(M.CarretDown,{})})]})]}),o.jsx(n.Combobox.Portal,{children:o.jsx(Be,{sideOffset:4,children:o.jsxs(Pe,{ref:P,children:[s,i?o.jsx(n.Combobox.CreateItem,{onPointerUp:z,onClick:z,asChild:!0,children:o.jsx(g,{children:o.jsx(u.Typography,{children:f(c??"")})})}):null,!i&&!C?o.jsx(n.Combobox.NoValueFound,{asChild:!0,children:o.jsx(g,{$hasHover:!1,children:o.jsx(u.Typography,{children:X(c??"")})})}):null,C?o.jsx(b.Flex,{justifyContent:"center",alignItems:"center",paddingTop:2,paddingBottom:2,children:o.jsx(Ie.Loader,{small:!0,children:Q})}):null,o.jsx(y.Box,{id:D,width:"100%",height:"1px"})]})})})]})},L=({error:e,hint:r,id:s,label:l,labelAction:d,required:i=!1,...f})=>{const h=I.useId(s);return o.jsx(ye.Field,{hint:r,error:e,id:h,required:i,children:o.jsxs(b.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[l?o.jsx(we.FieldLabel,{action:d,children:l}):null,o.jsx(H,{id:h,error:e,required:i,...f}),o.jsx(qe.FieldHint,{}),o.jsx(Fe.FieldError,{})]})})},Re=e=>o.jsx(L,{...e,creatable:!0}),ke=a.default(y.Box)`
|
|
2
2
|
border: none;
|
|
3
3
|
|
|
4
4
|
svg {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
z-index: ${({theme:e})=>e.zIndices[1]};
|
|
74
74
|
`,Pe=a.default(n.Combobox.Viewport)`
|
|
75
75
|
padding: ${({theme:e})=>e.spaces[1]};
|
|
76
|
-
`,_e=
|
|
76
|
+
`,_e=x.forwardRef(({children:e,value:r,disabled:s,textValue:l,...d},i)=>o.jsx(n.Combobox.ComboboxItem,{asChild:!0,value:r,disabled:s,textValue:l,children:o.jsx(g,{ref:i,...d,children:o.jsx(n.Combobox.ItemText,{asChild:!0,children:o.jsx(u.Typography,{children:e})})})})),g=a.default.div`
|
|
77
77
|
width: 100%;
|
|
78
78
|
border: none;
|
|
79
79
|
text-align: left;
|
|
@@ -104,4 +104,4 @@
|
|
|
104
104
|
font-weight: bold;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
`;exports.Combobox=L;exports.ComboboxInput=H;exports.CreatableCombobox=Re;exports.Option=_e;exports.OptionBox=
|
|
107
|
+
`;exports.Combobox=L;exports.ComboboxInput=H;exports.CreatableCombobox=Re;exports.Option=_e;exports.OptionBox=g;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import * as m from "react";
|
|
3
3
|
import { Cross as me, CarretDown as ge } from "@strapi/icons";
|
|
4
4
|
import { Combobox as n } from "@strapi/ui-primitives";
|
|
5
5
|
import l from "styled-components";
|
|
@@ -11,17 +11,17 @@ import { getThemeSize as Ce, inputFocusStyle as xe } from "../themes/utils.js";
|
|
|
11
11
|
import { Loader as Ie } from "../Loader/Loader.js";
|
|
12
12
|
import { Box as R } from "../Box/Box.js";
|
|
13
13
|
import { Typography as h } from "../Typography/Typography.js";
|
|
14
|
-
import { Flex as
|
|
14
|
+
import { Flex as g } from "../Flex/Flex.js";
|
|
15
15
|
import { Field as we } from "../Field/Field.js";
|
|
16
16
|
import { FieldLabel as Re } from "../Field/FieldLabel.js";
|
|
17
17
|
import { FieldHint as ve } from "../Field/FieldHint.js";
|
|
18
18
|
import { FieldError as ye } from "../Field/FieldError.js";
|
|
19
|
-
const ke = ({ allowCustomValue: e, autocomplete: o, children:
|
|
20
|
-
const [
|
|
19
|
+
const ke = ({ allowCustomValue: e, autocomplete: o, children: u, className: a, clearLabel: s = "clear", creatable: i = !1, createMessage: b = (f) => `Create "${f}"`, defaultFilterValue: p, defaultTextValue: y, defaultOpen: W = !1, open: L, onOpenChange: U, disabled: $ = !1, error: k, filterValue: A, hasMoreItems: G = !1, id: V, isPrintableCharacter: J, loading: C = !1, loadingMessage: K = "Loading content...", noOptionsMessage: M = () => "No results found", onChange: T, onClear: x, onCreateOption: F, onFilterValueChange: Q, onInputChange: O, onTextValueChange: X, onLoadMore: z, placeholder: Y = "Select or enter a value", required: Z = !1, size: _ = "M", startIcon: B, textValue: ee, value: P, ...re }) => {
|
|
20
|
+
const [f, oe] = I({
|
|
21
21
|
prop: L,
|
|
22
22
|
defaultProp: W,
|
|
23
23
|
onChange: U
|
|
24
|
-
}), [
|
|
24
|
+
}), [d, S] = I({
|
|
25
25
|
prop: ee,
|
|
26
26
|
defaultProp: e && !y ? P : y,
|
|
27
27
|
onChange: X
|
|
@@ -29,8 +29,8 @@ const ke = ({ allowCustomValue: e, autocomplete: o, children: c, className: u, c
|
|
|
29
29
|
prop: A,
|
|
30
30
|
defaultProp: p,
|
|
31
31
|
onChange: Q
|
|
32
|
-
}), E =
|
|
33
|
-
|
|
32
|
+
}), E = m.useRef(null), q = m.useRef(null), ne = m.useRef(null), ie = (t) => {
|
|
33
|
+
x && !$ && (S(""), j(""), x(t), q.current.focus());
|
|
34
34
|
}, le = (t) => {
|
|
35
35
|
oe(t);
|
|
36
36
|
}, ae = (t) => {
|
|
@@ -42,9 +42,9 @@ const ke = ({ allowCustomValue: e, autocomplete: o, children: c, className: u, c
|
|
|
42
42
|
}, ce = (t) => {
|
|
43
43
|
T && T(t);
|
|
44
44
|
}, ue = (t) => {
|
|
45
|
-
z && G &&
|
|
45
|
+
z && G && !C && z(t);
|
|
46
46
|
}, N = () => {
|
|
47
|
-
F &&
|
|
47
|
+
F && d && F(d);
|
|
48
48
|
}, D = w(V), he = w(), H = `intersection-${be(he)}`;
|
|
49
49
|
$e(E, ue, {
|
|
50
50
|
selectorToWatch: `#${H}`,
|
|
@@ -52,13 +52,13 @@ const ke = ({ allowCustomValue: e, autocomplete: o, children: c, className: u, c
|
|
|
52
52
|
* We need to know when the select is open because only then will viewportRef
|
|
53
53
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
54
54
|
*/
|
|
55
|
-
skipWhen: !
|
|
55
|
+
skipWhen: !f
|
|
56
56
|
});
|
|
57
57
|
const pe = `${D}-hint`, fe = `${D}-error`;
|
|
58
|
-
return
|
|
59
|
-
}, Ve = ({ error: e, hint: o, id:
|
|
60
|
-
const p = w(
|
|
61
|
-
return r(we, { hint: o, error: e, id: p, required: i, children:
|
|
58
|
+
return c(n.Root, { autocomplete: o || (i ? "list" : "both"), onOpenChange: le, open: f, onTextValueChange: ae, textValue: d, allowCustomValue: i || e, disabled: $, required: Z, value: P, onValueChange: ce, filterValue: te, onFilterValueChange: se, isPrintableCharacter: J, children: [c(Fe, { $hasError: !!k, $size: _, className: a, children: [c(g, { flex: "1", as: "span", gap: 3, children: [B ? r(R, { as: "span", "aria-hidden": !0, children: B }) : null, r(Oe, { placeholder: Y, id: V, "aria-invalid": !!k, "aria-describedby": `${pe} ${fe}`, onChange: de, ref: q, ...re })] }), c(g, { as: "span", gap: 3, children: [d && x ? r(Te, { as: "button", hasRadius: !0, background: "transparent", type: "button", onClick: ie, "aria-disabled": $, "aria-label": s, title: s, ref: ne, children: r(me, {}) }) : null, r(ze, { children: r(ge, {}) })] })] }), r(n.Portal, { children: r(Be, { sideOffset: 4, children: c(Pe, { ref: E, children: [u, i ? r(n.CreateItem, { onPointerUp: N, onClick: N, asChild: !0, children: r(v, { children: r(h, { children: b(d ?? "") }) }) }) : null, !i && !C ? r(n.NoValueFound, { asChild: !0, children: r(v, { $hasHover: !1, children: r(h, { children: M(d ?? "") }) }) }) : null, C ? r(g, { justifyContent: "center", alignItems: "center", paddingTop: 2, paddingBottom: 2, children: r(Ie, { small: !0, children: K }) }) : null, r(R, { id: H, width: "100%", height: "1px" })] }) }) })] });
|
|
59
|
+
}, Ve = ({ error: e, hint: o, id: u, label: a, labelAction: s, required: i = !1, ...b }) => {
|
|
60
|
+
const p = w(u);
|
|
61
|
+
return r(we, { hint: o, error: e, id: p, required: i, children: c(g, { direction: "column", alignItems: "stretch", gap: 1, children: [a ? r(Re, { action: s, children: a }) : null, r(ke, { id: p, error: e, required: i, ...b }), r(ve, {}), r(ye, {})] }) });
|
|
62
62
|
}, Ye = (e) => r(Ve, { ...e, creatable: !0 }), Te = l(R)`
|
|
63
63
|
border: none;
|
|
64
64
|
|
|
@@ -134,7 +134,7 @@ const ke = ({ allowCustomValue: e, autocomplete: o, children: c, className: u, c
|
|
|
134
134
|
z-index: ${({ theme: e }) => e.zIndices[1]};
|
|
135
135
|
`, Pe = l(n.Viewport)`
|
|
136
136
|
padding: ${({ theme: e }) => e.spaces[1]};
|
|
137
|
-
`, Ze =
|
|
137
|
+
`, Ze = m.forwardRef(({ children: e, value: o, disabled: u, textValue: a, ...s }, i) => r(n.ComboboxItem, { asChild: !0, value: o, disabled: u, textValue: a, children: r(v, { ref: i, ...s, children: r(n.ItemText, { asChild: !0, children: r(h, { children: e }) }) }) })), v = l.div`
|
|
138
138
|
width: 100%;
|
|
139
139
|
border: none;
|
|
140
140
|
text-align: left;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),
|
|
2
|
-
border: 1px solid ${({theme:e,$hasError:
|
|
3
|
-
min-height: ${({theme:e,$size:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ye=require("react"),$=require("@floating-ui/react-dom"),D=require("@internationalized/date"),xe=require("@radix-ui/react-focus-guards"),Ce=require("@radix-ui/react-focus-scope"),oe=require("@strapi/icons"),q=require("@strapi/ui-primitives"),be=require("react-dom"),we=require("react-remove-scroll"),ke=require("styled-components"),Te=require("../DesignSystemProvider.cjs"),Pe=require("../DismissibleLayer/index.cjs"),Se=require("../helpers/context.cjs"),je=require("../helpers/deprecations.cjs"),J=require("../hooks/useComposeRefs.cjs"),Ee=require("../hooks/useControllableState.cjs"),R=require("../hooks/useDateFormatter.cjs"),se=require("../hooks/useId.cjs"),Y=require("../Select/SingleSelect.cjs"),Ie=require("../Portal/Portal.cjs"),B=require("../Flex/Flex.cjs"),ne=require("../themes/utils.cjs"),U=require("../Box/Box.cjs"),W=require("../Typography/Typography.cjs"),Fe=require("../Field/Field.cjs"),Re=require("../Field/FieldLabel.cjs"),ve=require("../Field/FieldHint.cjs"),Ae=require("../Field/FieldError.cjs"),Me=e=>e&&e.__esModule?e:{default:e};function qe(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const c=qe(ye),E=Me(ke),_e=200,re=15,[Oe,_]=Se.createContext("DatePicker"),le=c.forwardRef(({calendarLabel:e,className:r,initialDate:n,locale:t,maxDate:o,minDate:i,monthSelectLabel:g="Month",onChange:d,selectedDate:l,yearSelectLabel:b="Year",error:k,id:h,disabled:x=!1,placeholder:T,required:w=!1,onClear:S,clearLabel:j="Clear",size:u,ariaLabel:p,selectedDateLabel:s,...f},m)=>{const P=D.getLocalTimeZone(),v=Te.useDesignSystem("DatePicker"),A=t??v.locale,M=R.useDateFormatter(A,{day:"2-digit",month:"2-digit",year:"numeric"}),[O,H]=c.useState(!1),[Z,C]=c.useState(null),[I,G]=c.useState(null),[ce,ue]=c.useState(null),[V,N]=c.useState(),[L,Q]=Ee.useControllableState({defaultProp:n?F(n):void 0,prop:l?F(l):void 0,onChange(y){d&&d(y?.toDate(P))}}),[ee,te]=c.useMemo(()=>{const y=n?F(n):D.today("UTC"),z=i?F(i):y.set({day:1,month:1,year:y.year-_e});let X=o?F(o):y.set({day:31,month:12,year:y.year+re});return X.compare(z)<0&&(X=z.set({day:31,month:12,year:z.year+re})),[z,X]},[i,o,n]),[de,K]=c.useState(Ne({currentValue:L,minDate:ee,maxDate:te})),fe=se.useId(),he=c.useRef(null),me=y=>{S&&!x&&(N(""),Q(void 0),S(y),I?.focus())},pe=c.useCallback(y=>{y&&L&&K(L),H(y)},[L]);c.useLayoutEffect(()=>{if(l){const y=F(l);N(M.format(y.toDate(P))),K(y)}else N("")},[l,M,P]),c.useLayoutEffect(()=>{if(n&&V===void 0){const y=F(n);N(M.format(y.toDate(P)))}},[n,V,M,P]);const ge=`${h}-hint`,De=`${h}-error`;return a.jsxs(Oe,{calendarDate:de,content:ce,contentId:fe,disabled:x,locale:A,minDate:ee,maxDate:te,open:O,onCalendarDateChange:K,onContentChange:ue,onOpenChange:pe,onTextInputChange:G,onTextValueChange:N,onTriggerChange:C,onValueChange:Q,required:w,textInput:I,textValue:V,timeZone:P,trigger:Z,value:L,children:[a.jsxs($e,{className:r,size:u,hasError:!!k,children:[a.jsx(Ye,{"aria-hidden":!0}),a.jsx(Ue,{ref:m,placeholder:T,"aria-describedby":`${ge} ${De}`,id:h,...f}),V&&S?a.jsx(ze,{as:"button",hasRadius:!0,background:"transparent",type:"button",onClick:me,"aria-disabled":x,"aria-label":j,title:j,ref:he,children:a.jsx(oe.Cross,{})}):null]}),a.jsx(Ie.Portal,{children:a.jsx(Ge,{label:e,children:a.jsx(et,{monthSelectLabel:g,yearSelectLabel:b})})})]})}),ae=e=>!!e.match(/^[^a-zA-Z]*$/),Ne=({currentValue:e,minDate:r,maxDate:n})=>{const t=D.today("UTC");return e||(D.minDate(r,t)===r&&D.maxDate(n,t)===n?t:D.minDate(r,t)===t?r:D.maxDate(n,t)===t?n:t)},Le="DatePickerTrigger",$e=c.forwardRef(({hasError:e,size:r="M",...n},t)=>{const o=_(Le),i=J.useComposedRefs(t,d=>o.onTriggerChange(d)),g=()=>{o.disabled||o.onOpenChange(!0)};return a.jsx(Ce.FocusScope,{asChild:!0,trapped:o.open,onMountAutoFocus:d=>{d.preventDefault()},onUnmountAutoFocus:d=>{document.getSelection()?.empty(),d.preventDefault()},children:a.jsx(Ve,{ref:i,$hasError:e,$size:r,...n,paddingLeft:3,paddingRight:3,hasRadius:!0,gap:3,overflow:"hidden",background:o.disabled?"neutral150":"neutral0",onClick:q.composeEventHandlers(n.onClick,()=>{o.textInput?.focus()}),onPointerDown:q.composeEventHandlers(n.onPointerDown,d=>{const l=d.target;l.hasPointerCapture(d.pointerId)&&l.releasePointerCapture(d.pointerId),(l.closest("button")??l.closest("div"))===d.currentTarget&&d.button===0&&d.ctrlKey===!1&&(g(),o.textInput?.focus())})})})}),Ve=E.default(B.Flex)`
|
|
2
|
+
border: 1px solid ${({theme:e,$hasError:r})=>r?e.colors.danger600:e.colors.neutral200};
|
|
3
|
+
min-height: ${({theme:e,$size:r})=>ne.getThemeSize("input")({theme:e,size:r})};
|
|
4
4
|
|
|
5
5
|
&[data-disabled] {
|
|
6
6
|
color: ${({theme:e})=>e.colors.neutral600};
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
outline: none;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
${({theme:e,$hasError:
|
|
17
|
-
`,
|
|
16
|
+
${({theme:e,$hasError:r})=>ne.inputFocusStyle()({theme:e,hasError:r})};
|
|
17
|
+
`,ze=E.default(U.Box)`
|
|
18
18
|
border: none;
|
|
19
19
|
|
|
20
20
|
svg {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
svg path {
|
|
26
26
|
fill: ${({theme:e})=>e.colors.neutral600};
|
|
27
27
|
}
|
|
28
|
-
`,
|
|
28
|
+
`,Ye=E.default(oe.Calendar)`
|
|
29
29
|
& > path {
|
|
30
30
|
fill: ${({theme:e})=>e.colors.neutral500};
|
|
31
31
|
}
|
|
32
|
-
`,
|
|
32
|
+
`,Be="DatePickerTextInput",Ue=c.forwardRef(({placeholder:e,...r},n)=>{const t=_(Be),{onTextValueChange:o,textValue:i,onTextInputChange:g,onOpenChange:d,disabled:l,locale:b}=t,k=J.useComposedRefs(n,u=>g(u)),h=()=>{l||d(!0)},x=R.useDateFormatter(b,{year:"numeric",month:"2-digit",day:"2-digit"}),[T,w,S]=c.useMemo(()=>{const u=x.formatToParts(new Date),p=u.filter(m=>m.type==="year"||m.type==="month"||m.type==="day"),s=p.map(m=>{switch(m.type){case"day":return"DD";case"month":return"MM";case"year":return"YYYY";default:return""}}),f=u.find(m=>m.type==="literal")?.value??"";return[s,f,p]},[x]),j=T.map(u=>`\\d${u.length}`).join(w);return a.jsx(He,{role:"combobox",type:"text",inputMode:"numeric",ref:k,"aria-autocomplete":"none","aria-controls":t.contentId,"aria-disabled":t.disabled,"aria-expanded":t.open,"aria-required":t.required,"aria-haspopup":"dialog","data-state":t.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,pattern:j,placeholder:e??T.join(w),...r,value:i??"",onBlur:q.composeEventHandlers(r.onBlur,()=>{if(!t.textValue){t.onValueChange(void 0);return}t.onTextValueChange(x.format(t.calendarDate.toDate(t.timeZone))),t.onValueChange(t.calendarDate)}),onChange:q.composeEventHandlers(r.onChange,u=>{if(ae(u.target.value)){const p=u.target.value.split(w),[s,f,m]=S.map((C,I)=>{const G=p[I];return{...C,value:G}}).sort((C,I)=>C.type==="year"?1:I.type==="year"?-1:C.type==="month"?1:I.type==="month"?-1:0).map(C=>C.value),P=t.calendarDate.year;let v=t.calendarDate.year;if(m){let C=m.length===1?`0${m}`:m;v=m.length<3?Number(`${P}`.slice(0,4-C.length)+C):Number(C)}m&&m.length<3&&v>t.maxDate.year&&(v-=100);const A=t.calendarDate.set({year:v}),M=A.calendar.getMonthsInYear(A),O=A.set({month:f&&Number(f)<=M?Number(f):void 0}),H=O.calendar.getDaysInMonth(O),Z=O.set({day:s&&Number(s)<=H?Number(s):void 0});t.onCalendarDateChange(We(Z,t.minDate,t.maxDate)),t.onTextValueChange(u.target.value)}}),onKeyDown:q.composeEventHandlers(r.onKeyDown,u=>{if(!t.open&&(ae(u.key)||["ArrowDown","Backspace"].includes(u.key)))h();else if(["Tab"].includes(u.key)&&t.open)u.preventDefault();else if(["Escape"].includes(u.key))t.open?t.onOpenChange(!1):(t.onValueChange(void 0),t.onTextValueChange("")),u.preventDefault();else if(t.open&&["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(u.key))switch(u.preventDefault(),u.key){case"ArrowDown":{const p=t.calendarDate.add({weeks:1});if(t.maxDate&&p.compare(t.maxDate)>0)return;t.onCalendarDateChange(p);return}case"ArrowRight":{const p=t.calendarDate.add({days:1});if(t.maxDate&&p.compare(t.maxDate)>0)return;t.onCalendarDateChange(p);return}case"ArrowUp":{const p=t.calendarDate.subtract({weeks:1});if(t.minDate&&p.compare(t.minDate)<0)return;t.onCalendarDateChange(p);return}case"ArrowLeft":{const p=t.calendarDate.subtract({days:1});if(t.minDate&&p.compare(t.minDate)<0)return;t.onCalendarDateChange(p)}}else t.open&&["Enter"].includes(u.key)&&(u.preventDefault(),o(x.format(t.calendarDate.toDate(t.timeZone))),t.onValueChange(t.calendarDate),t.onOpenChange(!1))})})});function We(e,r,n){return r&&(e=D.maxDate(e,r)),n&&(e=D.minDate(e,n)),e}const He=E.default.input`
|
|
33
33
|
width: 100%;
|
|
34
34
|
font-size: ${14/16}rem;
|
|
35
35
|
color: ${({theme:e})=>e.colors.neutral800};
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
&[aria-disabled='true'] {
|
|
45
45
|
cursor: inherit;
|
|
46
46
|
}
|
|
47
|
-
`,
|
|
47
|
+
`,Ze="DatePickerContent",Ge=c.forwardRef((e,r)=>{const[n,t]=c.useState(),o=_(Ze);if(c.useLayoutEffect(()=>{t(new DocumentFragment)},[]),!o.open){const i=n;return i?be.createPortal(a.jsx("div",{children:e.children}),i):null}return a.jsx(Xe,{...e,ref:r})}),Ke="DatePickerContent",Xe=c.forwardRef((e,r)=>{const{label:n="Choose date",...t}=e,{onOpenChange:o,...i}=_(Ke),{x:g,y:d,refs:l,strategy:b}=$.useFloating({strategy:"fixed",placement:"bottom-start",middleware:[$.offset({mainAxis:4}),$.shift(),$.flip()],elements:{reference:i.trigger},whileElementsMounted:$.autoUpdate});c.useEffect(()=>{const h=()=>{o(!1)};return window.addEventListener("blur",h),window.addEventListener("resize",h),()=>{window.removeEventListener("blur",h),window.removeEventListener("resize",h)}},[o]);const k=J.useComposedRefs(r,h=>i.onContentChange(h),l.setFloating);return xe.useFocusGuards(),a.jsx(we.RemoveScroll,{allowPinchZoom:!0,children:a.jsx(Pe.DismissibleLayer,{asChild:!0,onFocusOutside:h=>{h.preventDefault()},onDismiss:()=>{o(!1)},children:a.jsx(Je,{ref:k,"data-state":i.open?"open":"closed",onContextMenu:h=>h.preventDefault(),id:i.contentId,role:"dialog","aria-modal":"true","aria-label":n,style:{left:g,top:d,position:b},hasRadius:!0,background:"neutral0",padding:1,...t})})})}),Je=E.default(U.Box)`
|
|
48
48
|
box-shadow: ${({theme:e})=>e.shadows.filterShadow};
|
|
49
49
|
z-index: ${({theme:e})=>e.zIndices[0]};
|
|
50
50
|
border: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
51
|
-
`,
|
|
51
|
+
`,Qe="DatePickerCalendar",et=c.forwardRef(({monthSelectLabel:e,yearSelectLabel:r,...n},t)=>{const{locale:o,timeZone:i,minDate:g,maxDate:d,calendarDate:l,onCalendarDateChange:b}=_(Qe),k=D.startOfMonth(l),h=c.useMemo(()=>{const s=g.year,f=d.year;return[...Array(f-s+1).keys()].map(m=>(s+m).toString())},[g,d]),x=R.useDateFormatter(o,{month:"long"}),T=c.useMemo(()=>[...Array(l.calendar.getMonthsInYear(l)).keys()].map(s=>x.format(l.set({month:s+1}).toDate(i))),[l,x,i]),w=R.useDateFormatter(o,{weekday:"short"}),S=c.useMemo(()=>{let s=D.startOfWeek(D.today(i),o);return[...new Array(7).keys()].map(f=>{let P=s.add({days:f}).toDate(i);return w.format(P)})},[i,o,w]),j=s=>{if(typeof s=="number")return;const f=l.set({month:T.indexOf(s)+1});b(f)},u=s=>{if(typeof s=="number")return;const f=l.set({year:parseInt(s,10)});b(f)},p=tt(k,o);return a.jsxs(B.Flex,{ref:t,direction:"column",alignItems:"stretch",padding:4,...n,children:[a.jsxs(nt,{justifyContent:"flex-start",paddingBottom:4,paddingLeft:2,paddingRight:2,gap:2,children:[a.jsx(Y.SingleSelectInput,{label:e,size:"S",value:T[l.month-1],onChange:j,children:T.map(s=>a.jsx(Y.SingleSelectOption,{value:s,children:s},s))}),a.jsx(Y.SingleSelectInput,{size:"S",value:l.year.toString(),label:r,onChange:u,children:h.map(s=>a.jsx(Y.SingleSelectOption,{value:s,children:s},s))})]}),a.jsxs("table",{role:"grid",children:[a.jsx("thead",{"aria-hidden":!0,children:a.jsx("tr",{"aria-rowindex":0,children:S.map((s,f)=>a.jsx(rt,{"aria-colindex":f,children:s},s))})}),a.jsx("tbody",{children:[...new Array(6).keys()].map(s=>a.jsx("tr",{"aria-rowindex":s+2,children:p(s).map((f,m)=>f?a.jsx(st,{"aria-colindex":m+1,date:f,startDate:k},f.toString()):a.jsx(ie,{"aria-colindex":m+1}))},s))})]})]})}),tt=(e,r)=>n=>{let t=e.add({weeks:n}),o=[];t=D.startOfWeek(t,r);let i=D.getDayOfWeek(t,r);for(let g=0;g<i;g++)o.push(null);for(;o.length<7;){o.push(t);let g=t.add({days:1});if(D.isSameDay(t,g))break;t=g}for(;o.length<7;)o.push(null);return o},nt=E.default(B.Flex)`
|
|
52
52
|
div[role='combobox'] {
|
|
53
53
|
border: 1px solid transparent;
|
|
54
54
|
background: transparent;
|
|
55
55
|
font-weight: ${e=>e.theme.fontWeights.bold};
|
|
56
56
|
|
|
57
|
-
${
|
|
57
|
+
${W.Typography} {
|
|
58
58
|
color: ${({theme:e})=>e.colors.neutral800};
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
background-color: ${({theme:e})=>e.colors.neutral100};
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`,rt=
|
|
72
|
+
`,rt=c.forwardRef(({children:e,...r},n)=>a.jsx(at,{as:"th",role:"gridcell",ref:n,...r,height:`${24/16}rem`,width:`${32/16}rem`,children:a.jsx(W.Typography,{variant:"pi",fontWeight:"bold",color:"neutral800",children:e.slice(0,2)})})),at=E.default(U.Box)`
|
|
73
73
|
border-radius: ${({theme:e})=>e.borderRadius};
|
|
74
74
|
text-transform: capitalize;
|
|
75
|
-
`,
|
|
75
|
+
`,ot="DatePickerCalendarCell",st=c.forwardRef(({date:e,startDate:r,...n},t)=>{const{timeZone:o,locale:i,calendarDate:g,onValueChange:d,onOpenChange:l,onTextValueChange:b,onCalendarDateChange:k}=_(ot),h=D.isSameDay(g,e),x=R.useDateFormatter(i,{weekday:"long",day:"numeric",month:"long",year:"numeric"}),T=c.useMemo(()=>x.format(e.toDate(o)),[x,e,o]),w=R.useDateFormatter(i,{day:"numeric",calendar:e.calendar.identifier}),S=c.useMemo(()=>w.formatToParts(e.toDate(o)).find(f=>f.type==="day").value,[w,e,o]),j=R.useDateFormatter(i,{day:"2-digit",month:"2-digit",year:"numeric"}),u=D.endOfMonth(r),p=e.compare(r)<0||e.compare(u)>0;let s="neutral900";return h?s="primary600":p&&(s="neutral600"),a.jsx(ie,{as:"td",role:"gridcell",ref:t,"aria-selected":h,...n,hasRadius:!0,"aria-label":T,tabIndex:h?0:-1,background:h?"primary100":"neutral0",cursor:"pointer",onPointerDown:q.composeEventHandlers(n.onPointerDown,f=>{f.preventDefault(),k(e),d(e),b(j.format(e.toDate(o))),l(!1)}),children:a.jsx(W.Typography,{variant:"pi",textColor:s,children:S})})}),ie=E.default(U.Box)`
|
|
76
76
|
text-align: center;
|
|
77
77
|
padding: ${7/16}rem;
|
|
78
78
|
// Trick to prevent the outline from overflowing because of the general outline-offset
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
&:hover {
|
|
82
82
|
background: ${({theme:e})=>e.colors.primary100};
|
|
83
83
|
|
|
84
|
-
& > ${
|
|
84
|
+
& > ${W.Typography} {
|
|
85
85
|
color: ${({theme:e})=>e.colors.primary600};
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
`,
|
|
88
|
+
`,lt=c.forwardRef((e,r)=>{const{error:n,hint:t,id:o,required:i,label:g,...d}=e,l=se.useId(o);return a.jsx(Fe.Field,{error:n,hint:t,required:i,ref:r,id:l,children:a.jsxs(B.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[a.jsx(Re.FieldLabel,{children:g}),a.jsx(le,{id:l,error:n,required:i,...d}),a.jsx(ve.FieldHint,{}),a.jsx(Ae.FieldError,{})]})})}),it=je.once(console.warn),F=e=>{if(typeof e=="string"){it("It looks like you're passing a string as representation of a Date to the DatePicker. This is deprecated, look to passing a Date instead.");const t=Date.parse(e);Number.isNaN(t)?e=new Date:e=new Date(t)}const r=e.toISOString(),n=D.parseAbsolute(r,"UTC");return D.toCalendarDate(n)},ct=lt;exports.DatePicker=ct;exports.DatePickerInput=le;
|