@strapi/design-system 1.6.6 → 1.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/BaseButton/BaseButton.cjs +1 -1
- package/dist/BaseButton/BaseButton.js +1 -1
- package/dist/BaseLink/BaseLink.cjs +1 -3
- package/dist/BaseLink/BaseLink.js +14 -14
- package/dist/Combobox/Combobox.cjs +104 -1
- package/dist/Combobox/Combobox.js +348 -278
- package/dist/Combobox/ComboboxList.cjs +1 -1
- package/dist/Combobox/ComboboxList.js +7 -6
- package/dist/Combobox/ComboboxOption.cjs +1 -1
- package/dist/Combobox/ComboboxOption.js +3 -29
- package/dist/DatePicker/DatePicker.cjs +6 -2
- package/dist/DatePicker/DatePicker.js +55 -49
- package/dist/DateTimePicker/parseDate.cjs +1 -0
- package/dist/DateTimePicker/parseDate.js +8 -0
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +31 -31
- package/dist/Select/MultiSelect.cjs +30 -0
- package/dist/Select/MultiSelect.js +239 -0
- package/dist/Select/MultiSelectNested.cjs +3 -1
- package/dist/Select/MultiSelectNested.js +25 -12
- package/dist/Select/OptGroup.cjs +1 -1
- package/dist/Select/OptGroup.js +3 -22
- package/dist/Select/Option.cjs +1 -45
- package/dist/Select/Option.js +12 -100
- package/dist/Select/Select.cjs +1 -3
- package/dist/Select/Select.js +9 -207
- package/dist/Select/SelectList.cjs +1 -1
- package/dist/Select/SelectList.js +98 -80
- package/dist/Select/SelectParts.cjs +79 -0
- package/dist/Select/SelectParts.js +221 -0
- package/dist/Select/SingleSelect.cjs +1 -0
- package/dist/Select/SingleSelect.js +129 -0
- package/dist/Select/index.cjs +1 -1
- package/dist/Select/index.js +15 -10
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +42 -40
- package/dist/helpers/objects.cjs +1 -1
- package/dist/helpers/objects.js +6 -22
- package/dist/hooks/useComposeRefs.cjs +1 -0
- package/dist/hooks/useComposeRefs.js +14 -0
- package/dist/hooks/useIntersection.cjs +1 -1
- package/dist/hooks/useIntersection.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +143 -138
- package/dist/themes/extendTheme.cjs +4 -4
- package/dist/themes/extendTheme.js +21 -13
- package/dist/themes/utils.cjs +6 -6
- package/dist/themes/utils.js +7 -6
- package/dist/v2/Link/Link.cjs +13 -11
- package/dist/v2/Link/Link.js +52 -37
- package/dist/v2/SimpleMenu/Menu.cjs +65 -0
- package/dist/v2/SimpleMenu/Menu.js +229 -0
- package/dist/v2/SimpleMenu/SimpleMenu.cjs +1 -33
- package/dist/v2/SimpleMenu/SimpleMenu.js +37 -176
- package/dist/v2/SimpleMenu/index.cjs +1 -1
- package/dist/v2/SimpleMenu/index.js +5 -3
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.js +53 -51
- package/package.json +6 -19
- package/dist/Combobox/components.cjs +0 -53
- package/dist/Combobox/components.js +0 -64
- package/dist/Combobox/utils.cjs +0 -1
- package/dist/Combobox/utils.js +0 -78
- package/dist/Select/SelectButton.cjs +0 -19
- package/dist/Select/SelectButton.js +0 -69
- package/dist/Select/SelectTags.cjs +0 -6
- package/dist/Select/SelectTags.js +0 -38
- package/dist/Select/components.cjs +0 -39
- package/dist/Select/components.js +0 -48
- package/dist/Select/constants.cjs +0 -1
- package/dist/Select/constants.js +0 -8
- package/dist/Select/hooks/useButtonRef.cjs +0 -1
- package/dist/Select/hooks/useButtonRef.js +0 -13
- package/dist/Select/hooks/useListRef.cjs +0 -1
- package/dist/Select/hooks/useListRef.js +0 -18
- package/dist/Select/utils.cjs +0 -1
- package/dist/Select/utils.js +0 -17
- package/dist/helpers/arrays.cjs +0 -1
- package/dist/helpers/arrays.js +0 -6
- package/dist/v2/SimpleMenu/utils.cjs +0 -12
- package/dist/v2/SimpleMenu/utils.js +0 -15
|
@@ -1,87 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import * as b from "react";
|
|
3
|
+
import S from "compute-scroll-into-view";
|
|
4
|
+
import { Flex as h } from "../Flex/Flex.js";
|
|
5
|
+
import { KeyboardKeys as l } from "../helpers/keyboardKeys.js";
|
|
6
|
+
const g = {
|
|
7
|
+
Keyboard: "down:keyboard",
|
|
8
|
+
Mouse: "down:mouse"
|
|
9
|
+
}, m = {
|
|
10
|
+
Keyboard: "up:keyboard",
|
|
11
|
+
Mouse: "up:mouse"
|
|
12
|
+
}, E = ({
|
|
13
|
+
labelledBy: r,
|
|
14
|
+
onSelectItem: e,
|
|
15
|
+
children: c,
|
|
16
|
+
multi: s = !1,
|
|
17
|
+
onEscape: t,
|
|
18
|
+
expanded: f
|
|
19
|
+
}) => {
|
|
20
|
+
const o = K(f);
|
|
21
|
+
return A(h, {
|
|
22
|
+
as: "ul",
|
|
23
|
+
gap: 1,
|
|
24
|
+
direction: "column",
|
|
25
|
+
alignItems: "stretch",
|
|
26
|
+
role: "listbox",
|
|
27
|
+
"aria-labelledby": r,
|
|
28
|
+
tabIndex: -1,
|
|
29
|
+
ref: o,
|
|
30
|
+
onKeyDown: (i) => {
|
|
31
|
+
switch (i.key) {
|
|
32
|
+
case l.ESCAPE: {
|
|
33
|
+
i.stopPropagation(), t();
|
|
34
|
+
break;
|
|
26
35
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
case l.DOWN: {
|
|
37
|
+
i.preventDefault();
|
|
38
|
+
const n = y(o.current);
|
|
39
|
+
if (!n)
|
|
40
|
+
return;
|
|
41
|
+
const a = n.nextSibling;
|
|
42
|
+
if (a)
|
|
43
|
+
u(o.current, a);
|
|
44
|
+
else {
|
|
45
|
+
const d = o.current.querySelectorAll('[role="option"]')[0];
|
|
46
|
+
u(o.current, d);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case l.UP: {
|
|
51
|
+
i.preventDefault();
|
|
52
|
+
const n = y(o.current);
|
|
53
|
+
if (!n)
|
|
54
|
+
return;
|
|
55
|
+
const a = n.previousSibling;
|
|
56
|
+
if (a)
|
|
57
|
+
u(o.current, a);
|
|
58
|
+
else {
|
|
59
|
+
const p = o.current.querySelectorAll('[role="option"]'), d = p[p.length - 1];
|
|
60
|
+
u(o.current, d);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case l.SPACE:
|
|
65
|
+
case l.ENTER: {
|
|
66
|
+
i.preventDefault();
|
|
67
|
+
const n = y(o.current);
|
|
68
|
+
n.getAttribute("data-opt-group") ? e(n.getAttribute("data-opt-group-children").split(","), n.getAttribute("data-opt-group")) : e(n.getAttribute("data-strapi-value")), s || t();
|
|
69
|
+
break;
|
|
40
70
|
}
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case i.SPACE:
|
|
44
|
-
case i.ENTER: {
|
|
45
|
-
o.preventDefault();
|
|
46
|
-
const t = u(e.current);
|
|
47
|
-
t.getAttribute("data-opt-group") ? p(
|
|
48
|
-
t.getAttribute("data-opt-group-children").split(","),
|
|
49
|
-
t.getAttribute("data-opt-group")
|
|
50
|
-
) : p(t.getAttribute("data-strapi-value")), d || a();
|
|
51
|
-
break;
|
|
52
71
|
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return /* @__PURE__ */ O.createElement(
|
|
56
|
-
v,
|
|
57
|
-
{
|
|
58
|
-
as: "ul",
|
|
59
|
-
gap: 1,
|
|
60
|
-
direction: "column",
|
|
61
|
-
alignItems: "stretch",
|
|
62
|
-
role: "listbox",
|
|
63
|
-
"aria-labelledby": g,
|
|
64
|
-
tabIndex: -1,
|
|
65
|
-
ref: e,
|
|
66
|
-
onKeyDown: D,
|
|
67
|
-
onBlur: a,
|
|
68
|
-
"aria-multiselectable": d
|
|
69
72
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
onBlur: t,
|
|
74
|
+
children: c
|
|
75
|
+
});
|
|
76
|
+
}, u = (r, e) => {
|
|
77
|
+
r.setAttribute("aria-activedescendant", e.getAttribute("id")), r.querySelectorAll('[role="option"]').forEach((t) => t.classList.remove("is-focused")), e.classList.add("is-focused"), S(e, {
|
|
78
|
+
scrollMode: "if-needed",
|
|
79
|
+
block: "nearest",
|
|
80
|
+
inline: "nearest"
|
|
81
|
+
}).forEach(({
|
|
82
|
+
el: t,
|
|
83
|
+
top: f,
|
|
84
|
+
left: o
|
|
85
|
+
}) => {
|
|
86
|
+
t.scrollTop = f, t.scrollLeft = o;
|
|
87
|
+
});
|
|
88
|
+
}, K = (r) => {
|
|
89
|
+
const e = b.useRef(null);
|
|
90
|
+
return b.useEffect(() => {
|
|
91
|
+
e.current.focus();
|
|
92
|
+
}, []), b.useEffect(() => {
|
|
93
|
+
if (!e.current)
|
|
94
|
+
return;
|
|
95
|
+
const c = e.current.querySelector('[aria-selected="true"]'), s = e.current.querySelectorAll('[role="option"]');
|
|
96
|
+
let t;
|
|
97
|
+
c ? t = c : r === m.Keyboard ? t = s[s.length - 1] : r === g.Keyboard && (t = s[0]), t && (r === m.Keyboard || r === g.Keyboard) && u(e.current, t);
|
|
98
|
+
}, []), e;
|
|
99
|
+
}, y = (r) => {
|
|
100
|
+
const e = r.getAttribute("aria-activedescendant");
|
|
101
|
+
return r.querySelector(`#${e}`);
|
|
84
102
|
};
|
|
85
103
|
export {
|
|
86
|
-
|
|
104
|
+
E as SelectList
|
|
87
105
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),w=require("react"),u=require("@strapi/icons"),o=require("@strapi/ui-primitives"),p=require("styled-components"),h=require("../Box/Box.cjs"),a=require("../Flex/Flex.cjs"),R=require("../hooks/useComposeRefs.cjs");require("../themes/lightTheme/index.cjs");require("../themes/darkTheme/index.cjs");require("lodash");const d=require("../themes/utils.cjs"),g=require("../Typography/Typography.cjs"),T=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function I(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const l=I(w),i=T(p),q=l.forwardRef(({onClear:e,clearLabel:t="Clear",startIcon:s,disabled:n,hasError:f,size:m="M",children:x,...b},y)=>{const c=l.useRef(null),S=j=>{e&&!n&&(e(j),c.current.focus())},$=R.useComposedRefs(c,y);return r.jsx(o.Select.Trigger,{asChild:!0,children:r.jsxs(C,{"aria-disabled":n,$hasError:f,$size:m,ref:$,alignItems:"center",justifyContent:"space-between",position:"relative",overflow:"hidden",hasRadius:!0,background:n?"neutral150":"neutral0",paddingLeft:3,paddingRight:3,gap:4,...b,children:[r.jsxs(a.Flex,{as:"span",gap:4,children:[s&&r.jsx(h.Box,{as:"span","aria-hidden":!0,children:s}),x]}),r.jsxs(a.Flex,{as:"span",gap:3,children:[e?r.jsx(v,{as:"button",hasRadius:!0,background:"transparent",role:"button",tabIndex:0,onClick:S,"aria-disabled":n,"aria-label":t,title:t,cursor:"pointer",children:r.jsx(u.Cross,{})}):null,r.jsx(k,{children:r.jsx(u.CarretDown,{})})]})]})})}),v=i.default(h.Box)`
|
|
2
|
+
border: none;
|
|
3
|
+
|
|
4
|
+
svg {
|
|
5
|
+
height: ${11/16}rem;
|
|
6
|
+
width: ${11/16}rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
svg path {
|
|
10
|
+
fill: ${({theme:e})=>e.colors.neutral600};
|
|
11
|
+
}
|
|
12
|
+
`,C=i.default(a.Flex)`
|
|
13
|
+
border: 1px solid ${({theme:e,$hasError:t})=>t?e.colors.danger600:e.colors.neutral200};
|
|
14
|
+
min-height: ${({theme:e,$size:t})=>d.getThemeSize("input")({theme:e,size:t})};
|
|
15
|
+
|
|
16
|
+
&[aria-disabled='true'] {
|
|
17
|
+
color: ${e=>e.theme.colors.neutral600};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Required to ensure the below inputFocusStyles are adhered too */
|
|
21
|
+
&:focus-visible {
|
|
22
|
+
outline: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${({theme:e,$hasError:t})=>d.inputFocusStyle()({theme:e,hasError:t})};
|
|
26
|
+
`,k=i.default(o.Select.Icon)`
|
|
27
|
+
& > svg {
|
|
28
|
+
width: ${6/16}rem;
|
|
29
|
+
|
|
30
|
+
& > path {
|
|
31
|
+
fill: ${({theme:e})=>e.colors.neutral600};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`,_=l.forwardRef(({children:e,placeholder:t,...s},n)=>r.jsx(g.Typography,{ref:n,ellipsis:!0,...s,children:r.jsx(V,{placeholder:t,children:e})})),V=i.default(o.Select.Value)`
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: ${({theme:e})=>e.spaces[1]};
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
`,F=i.default(o.Select.Content)`
|
|
39
|
+
background: ${({theme:e})=>e.colors.neutral0};
|
|
40
|
+
box-shadow: ${({theme:e})=>e.shadows.filterShadow};
|
|
41
|
+
border: 1px solid ${({theme:e})=>e.colors.neutral150};
|
|
42
|
+
border-radius: ${({theme:e})=>e.borderRadius};
|
|
43
|
+
min-width: var(--radix-select-trigger-width);
|
|
44
|
+
/* This is from the design-system figma file. */
|
|
45
|
+
max-height: 15rem;
|
|
46
|
+
`,P=i.default(o.Select.Viewport)`
|
|
47
|
+
padding: ${({theme:e})=>e.spaces[1]};
|
|
48
|
+
`,B=l.forwardRef((e,t)=>r.jsx(M,{ref:t,...e})),O=p.css`
|
|
49
|
+
width: 100%;
|
|
50
|
+
border: none;
|
|
51
|
+
text-align: left;
|
|
52
|
+
outline-offset: -3px;
|
|
53
|
+
border-radius: ${e=>e.theme.borderRadius};
|
|
54
|
+
padding: ${e=>`${e.theme.spaces[2]} ${e.theme.spaces[4]}`};
|
|
55
|
+
padding-left: ${({theme:e})=>e.spaces[4]};
|
|
56
|
+
background-color: ${({theme:e})=>e.colors.neutral0};
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: ${({theme:e})=>e.spaces[2]};
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
|
|
62
|
+
&:focus-visible {
|
|
63
|
+
outline: none;
|
|
64
|
+
background-color: ${({theme:e})=>e.colors.primary100};
|
|
65
|
+
}
|
|
66
|
+
`,M=i.default(o.Select.Item)`
|
|
67
|
+
${O}
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
background-color: ${({theme:e})=>e.colors.primary100};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&[data-state='checked'] {
|
|
74
|
+
${g.Typography} {
|
|
75
|
+
font-weight: bold;
|
|
76
|
+
color: ${({theme:e})=>e.colors.primary600};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`,z=o.Select.Root,D=q,G=_,E=o.Select.Portal,L=F,N=P,A=B,H=o.Select.ItemIndicator,J=o.Select.ItemText,K=o.Select.Group;exports.Content=L;exports.Group=K;exports.Item=A;exports.ItemIndicator=H;exports.ItemText=J;exports.Portal=E;exports.Root=z;exports.Trigger=D;exports.Value=G;exports.Viewport=N;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import * as a from "react";
|
|
3
|
+
import { Cross as y, CarretDown as R } from "@strapi/icons";
|
|
4
|
+
import { Select as o } from "@strapi/ui-primitives";
|
|
5
|
+
import s, { css as S } from "styled-components";
|
|
6
|
+
import { Box as p } from "../Box/Box.js";
|
|
7
|
+
import { Flex as c } from "../Flex/Flex.js";
|
|
8
|
+
import { useComposedRefs as I } from "../hooks/useComposeRefs.js";
|
|
9
|
+
import "../themes/lightTheme/index.js";
|
|
10
|
+
import "../themes/darkTheme/index.js";
|
|
11
|
+
import "lodash";
|
|
12
|
+
import { getThemeSize as C, inputFocusStyle as k } from "../themes/utils.js";
|
|
13
|
+
import { Typography as u } from "../Typography/Typography.js";
|
|
14
|
+
const v = a.forwardRef(({
|
|
15
|
+
onClear: e,
|
|
16
|
+
clearLabel: r = "Clear",
|
|
17
|
+
startIcon: n,
|
|
18
|
+
disabled: i,
|
|
19
|
+
hasError: m,
|
|
20
|
+
size: h = "M",
|
|
21
|
+
children: f,
|
|
22
|
+
...g
|
|
23
|
+
}, $) => {
|
|
24
|
+
const d = a.useRef(null), w = (x) => {
|
|
25
|
+
e && !i && (e(x), d.current.focus());
|
|
26
|
+
}, b = I(d, $);
|
|
27
|
+
return t(o.Trigger, {
|
|
28
|
+
asChild: !0,
|
|
29
|
+
children: l(V, {
|
|
30
|
+
"aria-disabled": i,
|
|
31
|
+
$hasError: m,
|
|
32
|
+
$size: h,
|
|
33
|
+
ref: b,
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
justifyContent: "space-between",
|
|
36
|
+
position: "relative",
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
hasRadius: !0,
|
|
39
|
+
background: i ? "neutral150" : "neutral0",
|
|
40
|
+
paddingLeft: 3,
|
|
41
|
+
paddingRight: 3,
|
|
42
|
+
gap: 4,
|
|
43
|
+
...g,
|
|
44
|
+
children: [l(c, {
|
|
45
|
+
as: "span",
|
|
46
|
+
gap: 4,
|
|
47
|
+
children: [n && t(p, {
|
|
48
|
+
as: "span",
|
|
49
|
+
"aria-hidden": !0,
|
|
50
|
+
children: n
|
|
51
|
+
}), f]
|
|
52
|
+
}), l(c, {
|
|
53
|
+
as: "span",
|
|
54
|
+
gap: 3,
|
|
55
|
+
children: [e ? t(T, {
|
|
56
|
+
as: "button",
|
|
57
|
+
hasRadius: !0,
|
|
58
|
+
background: "transparent",
|
|
59
|
+
role: "button",
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
onClick: w,
|
|
62
|
+
"aria-disabled": i,
|
|
63
|
+
"aria-label": r,
|
|
64
|
+
title: r,
|
|
65
|
+
cursor: "pointer",
|
|
66
|
+
children: t(y, {})
|
|
67
|
+
}) : null, t(j, {
|
|
68
|
+
children: t(R, {})
|
|
69
|
+
})]
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}), T = s(p)`
|
|
74
|
+
border: none;
|
|
75
|
+
|
|
76
|
+
svg {
|
|
77
|
+
height: ${11 / 16}rem;
|
|
78
|
+
width: ${11 / 16}rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
svg path {
|
|
82
|
+
fill: ${({
|
|
83
|
+
theme: e
|
|
84
|
+
}) => e.colors.neutral600};
|
|
85
|
+
}
|
|
86
|
+
`, V = s(c)`
|
|
87
|
+
border: 1px solid ${({
|
|
88
|
+
theme: e,
|
|
89
|
+
$hasError: r
|
|
90
|
+
}) => r ? e.colors.danger600 : e.colors.neutral200};
|
|
91
|
+
min-height: ${({
|
|
92
|
+
theme: e,
|
|
93
|
+
$size: r
|
|
94
|
+
}) => C("input")({
|
|
95
|
+
theme: e,
|
|
96
|
+
size: r
|
|
97
|
+
})};
|
|
98
|
+
|
|
99
|
+
&[aria-disabled='true'] {
|
|
100
|
+
color: ${(e) => e.theme.colors.neutral600};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Required to ensure the below inputFocusStyles are adhered too */
|
|
104
|
+
&:focus-visible {
|
|
105
|
+
outline: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
${({
|
|
109
|
+
theme: e,
|
|
110
|
+
$hasError: r
|
|
111
|
+
}) => k()({
|
|
112
|
+
theme: e,
|
|
113
|
+
hasError: r
|
|
114
|
+
})};
|
|
115
|
+
`, j = s(o.Icon)`
|
|
116
|
+
& > svg {
|
|
117
|
+
width: ${6 / 16}rem;
|
|
118
|
+
|
|
119
|
+
& > path {
|
|
120
|
+
fill: ${({
|
|
121
|
+
theme: e
|
|
122
|
+
}) => e.colors.neutral600};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`, z = a.forwardRef(({
|
|
126
|
+
children: e,
|
|
127
|
+
placeholder: r,
|
|
128
|
+
...n
|
|
129
|
+
}, i) => t(u, {
|
|
130
|
+
ref: i,
|
|
131
|
+
ellipsis: !0,
|
|
132
|
+
...n,
|
|
133
|
+
children: t(F, {
|
|
134
|
+
placeholder: r,
|
|
135
|
+
children: e
|
|
136
|
+
})
|
|
137
|
+
})), F = s(o.Value)`
|
|
138
|
+
display: flex;
|
|
139
|
+
gap: ${({
|
|
140
|
+
theme: e
|
|
141
|
+
}) => e.spaces[1]};
|
|
142
|
+
flex-wrap: wrap;
|
|
143
|
+
`, B = s(o.Content)`
|
|
144
|
+
background: ${({
|
|
145
|
+
theme: e
|
|
146
|
+
}) => e.colors.neutral0};
|
|
147
|
+
box-shadow: ${({
|
|
148
|
+
theme: e
|
|
149
|
+
}) => e.shadows.filterShadow};
|
|
150
|
+
border: 1px solid ${({
|
|
151
|
+
theme: e
|
|
152
|
+
}) => e.colors.neutral150};
|
|
153
|
+
border-radius: ${({
|
|
154
|
+
theme: e
|
|
155
|
+
}) => e.borderRadius};
|
|
156
|
+
min-width: var(--radix-select-trigger-width);
|
|
157
|
+
/* This is from the design-system figma file. */
|
|
158
|
+
max-height: 15rem;
|
|
159
|
+
`, D = s(o.Viewport)`
|
|
160
|
+
padding: ${({
|
|
161
|
+
theme: e
|
|
162
|
+
}) => e.spaces[1]};
|
|
163
|
+
`, E = a.forwardRef((e, r) => t(P, {
|
|
164
|
+
ref: r,
|
|
165
|
+
...e
|
|
166
|
+
})), G = S`
|
|
167
|
+
width: 100%;
|
|
168
|
+
border: none;
|
|
169
|
+
text-align: left;
|
|
170
|
+
outline-offset: -3px;
|
|
171
|
+
border-radius: ${(e) => e.theme.borderRadius};
|
|
172
|
+
padding: ${(e) => `${e.theme.spaces[2]} ${e.theme.spaces[4]}`};
|
|
173
|
+
padding-left: ${({
|
|
174
|
+
theme: e
|
|
175
|
+
}) => e.spaces[4]};
|
|
176
|
+
background-color: ${({
|
|
177
|
+
theme: e
|
|
178
|
+
}) => e.colors.neutral0};
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
gap: ${({
|
|
182
|
+
theme: e
|
|
183
|
+
}) => e.spaces[2]};
|
|
184
|
+
white-space: nowrap;
|
|
185
|
+
|
|
186
|
+
&:focus-visible {
|
|
187
|
+
outline: none;
|
|
188
|
+
background-color: ${({
|
|
189
|
+
theme: e
|
|
190
|
+
}) => e.colors.primary100};
|
|
191
|
+
}
|
|
192
|
+
`, P = s(o.Item)`
|
|
193
|
+
${G}
|
|
194
|
+
|
|
195
|
+
&:hover {
|
|
196
|
+
background-color: ${({
|
|
197
|
+
theme: e
|
|
198
|
+
}) => e.colors.primary100};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&[data-state='checked'] {
|
|
202
|
+
${u} {
|
|
203
|
+
font-weight: bold;
|
|
204
|
+
color: ${({
|
|
205
|
+
theme: e
|
|
206
|
+
}) => e.colors.primary600};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
`, X = o.Root, Y = v, Z = z, _ = o.Portal, ee = B, re = D, oe = E, te = o.ItemIndicator, se = o.ItemText, ie = o.Group;
|
|
210
|
+
export {
|
|
211
|
+
ee as Content,
|
|
212
|
+
ie as Group,
|
|
213
|
+
oe as Item,
|
|
214
|
+
te as ItemIndicator,
|
|
215
|
+
se as ItemText,
|
|
216
|
+
_ as Portal,
|
|
217
|
+
X as Root,
|
|
218
|
+
Y as Trigger,
|
|
219
|
+
Z as Value,
|
|
220
|
+
re as Viewport
|
|
221
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),N=require("react"),l=require("./SelectParts.cjs"),q=require("../Box/Box.cjs"),V=require("../Field/Field.cjs"),H=require("../Field/FieldLabel.cjs");require("../Field/FieldInput.cjs");const z=require("../Field/FieldHint.cjs"),W=require("../Field/FieldError.cjs");require("../Field/FieldContext.cjs");require("../Field/FieldAction.cjs");const A=require("../Flex/Flex.cjs"),D=require("../hooks/useId.cjs"),G=require("../hooks/useIntersection.cjs"),J=require("../Typography/Typography.cjs");function K(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>t[i]})}}return n.default=t,Object.freeze(n)}const d=K(N),Q=({children:t,clearLabel:n="Clear",customizeContent:i=p=>p?.toString()??"",disabled:s,error:u,hint:m,id:y,label:x,labelAction:O,onChange:a,onClear:h,onReachEnd:f,placeholder:T,required:g,selectButtonTitle:X,startIcon:B,size:C="M",value:j,...R})=>{const[p,F]=d.useState(),[_,k]=d.useState(!1),o=D.useId(y),v=`${o}-hint`,P=`${o}-error`,$=r=>{a?a(typeof j=="number"?Number(r):r):F(r)},w=r=>{k(r)},L=r=>{h&&h(r),a||F("")},b=d.useRef(null),M=()=>{b.current.focus()},S=d.useRef(null),I=`intersection-${o}`,E=r=>{f&&f(r)};G.useIntersection(S,E,{selectorToWatch:`#${I}`,skipWhen:!_});const c=(typeof j<"u"?j.toString():p)??"";return e.jsx(V.Field,{hint:m,error:u,id:o,required:g,children:e.jsxs(A.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[e.jsx(H.FieldLabel,{onClick:M,action:O,children:x}),e.jsxs(l.Root,{onOpenChange:w,disabled:s,required:g,onValueChange:$,value:c,...R,children:[e.jsx(l.Trigger,{ref:b,"aria-label":x,"aria-describedby":`${v} ${P}`,id:o,startIcon:B,size:C,hasError:Boolean(u),disabled:s,clearLabel:n,onClear:c&&h?L:void 0,children:e.jsx(l.Value,{placeholder:T,textColor:c?"neutral800":"neutral600",children:c?i(c):null})}),e.jsx(l.Portal,{children:e.jsx(l.Content,{position:"popper",sideOffset:4,children:e.jsxs(l.Viewport,{ref:S,children:[t,e.jsx(q.Box,{id:I,width:"100%",height:"1px"})]})})})]}),e.jsx(z.FieldHint,{}),e.jsx(W.FieldError,{})]})})},U=d.forwardRef(({value:t,startIcon:n,children:i,...s},u)=>e.jsxs(l.Item,{ref:u,value:t.toString(),...s,children:[n&&e.jsx(q.Box,{as:"span","aria-hidden":!0,children:n}),e.jsx(J.Typography,{textColor:"neutral800",children:e.jsx(l.ItemText,{children:i})})]}));exports.SingleSelect=Q;exports.SingleSelectOption=U;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
|
+
import { Item as q, ItemText as z, Root as H, Trigger as M, Value as P, Portal as _, Content as A, Viewport as D } from "./SelectParts.js";
|
|
4
|
+
import { Box as R } from "../Box/Box.js";
|
|
5
|
+
import { Field as G } from "../Field/Field.js";
|
|
6
|
+
import { FieldLabel as J } from "../Field/FieldLabel.js";
|
|
7
|
+
import "../Field/FieldInput.js";
|
|
8
|
+
import { FieldHint as K } from "../Field/FieldHint.js";
|
|
9
|
+
import { FieldError as Q } from "../Field/FieldError.js";
|
|
10
|
+
import "../Field/FieldContext.js";
|
|
11
|
+
import "../Field/FieldAction.js";
|
|
12
|
+
import { Flex as U } from "../Flex/Flex.js";
|
|
13
|
+
import { useId as X } from "../hooks/useId.js";
|
|
14
|
+
import { useIntersection as Y } from "../hooks/useIntersection.js";
|
|
15
|
+
import { Typography as Z } from "../Typography/Typography.js";
|
|
16
|
+
const Ie = ({
|
|
17
|
+
children: a,
|
|
18
|
+
clearLabel: i = "Clear",
|
|
19
|
+
customizeContent: s = (u) => u?.toString() ?? "",
|
|
20
|
+
disabled: l,
|
|
21
|
+
error: c,
|
|
22
|
+
hint: O,
|
|
23
|
+
id: B,
|
|
24
|
+
label: f,
|
|
25
|
+
labelAction: F,
|
|
26
|
+
onChange: h,
|
|
27
|
+
onClear: m,
|
|
28
|
+
onReachEnd: g,
|
|
29
|
+
placeholder: T,
|
|
30
|
+
required: I,
|
|
31
|
+
selectButtonTitle: ee,
|
|
32
|
+
startIcon: $,
|
|
33
|
+
size: y = "M",
|
|
34
|
+
value: p,
|
|
35
|
+
...w
|
|
36
|
+
}) => {
|
|
37
|
+
const [u, b] = o.useState(), [V, k] = o.useState(!1), t = X(B), v = `${t}-hint`, E = `${t}-error`, L = (r) => {
|
|
38
|
+
h ? h(typeof p == "number" ? Number(r) : r) : b(r);
|
|
39
|
+
}, N = (r) => {
|
|
40
|
+
k(r);
|
|
41
|
+
}, j = (r) => {
|
|
42
|
+
m && m(r), h || b("");
|
|
43
|
+
}, S = o.useRef(null), W = () => {
|
|
44
|
+
S.current.focus();
|
|
45
|
+
}, x = o.useRef(null), C = `intersection-${t}`;
|
|
46
|
+
Y(x, (r) => {
|
|
47
|
+
g && g(r);
|
|
48
|
+
}, {
|
|
49
|
+
selectorToWatch: `#${C}`,
|
|
50
|
+
skipWhen: !V
|
|
51
|
+
});
|
|
52
|
+
const n = (typeof p < "u" ? p.toString() : u) ?? "";
|
|
53
|
+
return e(G, {
|
|
54
|
+
hint: O,
|
|
55
|
+
error: c,
|
|
56
|
+
id: t,
|
|
57
|
+
required: I,
|
|
58
|
+
children: d(U, {
|
|
59
|
+
direction: "column",
|
|
60
|
+
alignItems: "stretch",
|
|
61
|
+
gap: 1,
|
|
62
|
+
children: [e(J, {
|
|
63
|
+
onClick: W,
|
|
64
|
+
action: F,
|
|
65
|
+
children: f
|
|
66
|
+
}), d(H, {
|
|
67
|
+
onOpenChange: N,
|
|
68
|
+
disabled: l,
|
|
69
|
+
required: I,
|
|
70
|
+
onValueChange: L,
|
|
71
|
+
value: n,
|
|
72
|
+
...w,
|
|
73
|
+
children: [e(M, {
|
|
74
|
+
ref: S,
|
|
75
|
+
"aria-label": f,
|
|
76
|
+
"aria-describedby": `${v} ${E}`,
|
|
77
|
+
id: t,
|
|
78
|
+
startIcon: $,
|
|
79
|
+
size: y,
|
|
80
|
+
hasError: Boolean(c),
|
|
81
|
+
disabled: l,
|
|
82
|
+
clearLabel: i,
|
|
83
|
+
onClear: n && m ? j : void 0,
|
|
84
|
+
children: e(P, {
|
|
85
|
+
placeholder: T,
|
|
86
|
+
textColor: n ? "neutral800" : "neutral600",
|
|
87
|
+
children: n ? s(n) : null
|
|
88
|
+
})
|
|
89
|
+
}), e(_, {
|
|
90
|
+
children: e(A, {
|
|
91
|
+
position: "popper",
|
|
92
|
+
sideOffset: 4,
|
|
93
|
+
children: d(D, {
|
|
94
|
+
ref: x,
|
|
95
|
+
children: [a, e(R, {
|
|
96
|
+
id: C,
|
|
97
|
+
width: "100%",
|
|
98
|
+
height: "1px"
|
|
99
|
+
})]
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
})]
|
|
103
|
+
}), e(K, {}), e(Q, {})]
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}, be = o.forwardRef(({
|
|
107
|
+
value: a,
|
|
108
|
+
startIcon: i,
|
|
109
|
+
children: s,
|
|
110
|
+
...l
|
|
111
|
+
}, c) => d(q, {
|
|
112
|
+
ref: c,
|
|
113
|
+
value: a.toString(),
|
|
114
|
+
...l,
|
|
115
|
+
children: [i && e(R, {
|
|
116
|
+
as: "span",
|
|
117
|
+
"aria-hidden": !0,
|
|
118
|
+
children: i
|
|
119
|
+
}), e(Z, {
|
|
120
|
+
textColor: "neutral800",
|
|
121
|
+
children: e(z, {
|
|
122
|
+
children: s
|
|
123
|
+
})
|
|
124
|
+
})]
|
|
125
|
+
}));
|
|
126
|
+
export {
|
|
127
|
+
Ie as SingleSelect,
|
|
128
|
+
be as SingleSelectOption
|
|
129
|
+
};
|
package/dist/Select/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./MultiSelectNested.cjs"),e=require("./MultiSelect.cjs"),t=require("./SingleSelect.cjs"),i=require("./Option.cjs"),c=require("./OptGroup.cjs"),u=require("./SelectList.cjs");exports.MultiSelectNested=l.MultiSelectNested;exports.MultiSelect=e.MultiSelect;exports.MultiSelectGroup=e.MultiSelectGroup;exports.MultiSelectOption=e.MultiSelectOption;exports.SingleSelect=t.SingleSelect;exports.SingleSelectOption=t.SingleSelectOption;exports.Option=i.Option;exports.OptGroup=c.OptGroup;exports.SelectList=u.SelectList;
|
package/dist/Select/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { MultiSelectNested as o } from "./MultiSelectNested.js";
|
|
2
|
+
import { MultiSelect as l, MultiSelectGroup as p, MultiSelectOption as i } from "./MultiSelect.js";
|
|
3
|
+
import { SingleSelect as c, SingleSelectOption as f } from "./SingleSelect.js";
|
|
4
|
+
import { Option as u } from "./Option.js";
|
|
5
|
+
import { OptGroup as n } from "./OptGroup.js";
|
|
6
|
+
import { SelectList as O } from "./SelectList.js";
|
|
6
7
|
export {
|
|
7
|
-
l as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
l as MultiSelect,
|
|
9
|
+
p as MultiSelectGroup,
|
|
10
|
+
o as MultiSelectNested,
|
|
11
|
+
i as MultiSelectOption,
|
|
12
|
+
n as OptGroup,
|
|
13
|
+
u as Option,
|
|
14
|
+
O as SelectList,
|
|
15
|
+
c as SingleSelect,
|
|
16
|
+
f as SingleSelectOption
|
|
12
17
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),b=require("@strapi/icons"),M=require("styled-components"),$=require("../Flex/Flex.cjs"),q=require("../hooks/useId.cjs"),d=require("../Select/SingleSelect.cjs"),y=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},I=y(M),v=({id:t,value:i,step:h=15,onChange:u,...p})=>{const g=q.useId(t),m=24,s=[];let n=0;for(let e=0;e<m;e++)for(n=0;n<60;)s.push(`${e<10?`0${e}`:e}:${n<10?`0${n}`:n}`),n+=h;const S=()=>{const[e,a]=i?.split(":")??[],j=s.reduce((l,r)=>{const[c]=r.split(":");return Math.abs(c-e)<Math.abs(l-e)?c:l},s[0].split(":")[0]),x=s.reduce((l,r)=>{const c=r.split(":")[1];return Math.abs(c-a)<Math.abs(l-a)?c:l},s[0].split(":")[1]);return`${j}:${x}`},f=e=>{u&&u(e.toString())};return o.jsx(d.SingleSelect,{id:g,placeholder:"--:--",value:i?S():void 0,startIcon:o.jsx(_,{as:"span",children:o.jsx(b.Clock,{})}),onChange:f,...p,children:s.map(e=>o.jsx(d.SingleSelectOption,{value:e,children:e},e))})},_=I.default($.Flex)`
|
|
2
2
|
& > svg {
|
|
3
3
|
height: 1rem;
|
|
4
4
|
width: 1rem;
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
& > svg path {
|
|
8
8
|
fill: ${({theme:t})=>t.colors.neutral500};
|
|
9
9
|
}
|
|
10
|
-
`;exports.TimePicker=
|
|
10
|
+
`;exports.TimePicker=v;
|