@strapi/design-system 1.8.1 → 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/Combobox/Combobox.cjs +2 -2
- package/dist/Combobox/Combobox.js +9 -9
- package/dist/DatePicker/DatePicker.cjs +9 -9
- package/dist/DatePicker/DatePicker.js +66 -65
- 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/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/package.json +10 -10
package/dist/Popover/Popover.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as z } from "react/jsx-runtime";
|
|
2
2
|
import * as o from "react";
|
|
3
|
-
import { useFloating as
|
|
4
|
-
import { FocusScope as
|
|
5
|
-
import { useCallbackRef as
|
|
6
|
-
import { hideOthers as
|
|
7
|
-
import { RemoveScroll as
|
|
8
|
-
import
|
|
9
|
-
import { DismissibleLayer as
|
|
10
|
-
import { stripReactIdOfColon as
|
|
11
|
-
import { useComposedRefs as
|
|
12
|
-
import { useId as
|
|
13
|
-
import { useIntersection as
|
|
3
|
+
import { useFloating as I, offset as W, shift as A, flip as K, autoUpdate as j } from "@floating-ui/react-dom";
|
|
4
|
+
import { FocusScope as M } from "@radix-ui/react-focus-scope";
|
|
5
|
+
import { useCallbackRef as T, composeEventHandlers as g } from "@strapi/ui-primitives";
|
|
6
|
+
import { hideOthers as U } from "aria-hidden";
|
|
7
|
+
import { RemoveScroll as B } from "react-remove-scroll";
|
|
8
|
+
import x from "styled-components";
|
|
9
|
+
import { DismissibleLayer as H } from "../DismissibleLayer/index.js";
|
|
10
|
+
import { stripReactIdOfColon as v } from "../helpers/strings.js";
|
|
11
|
+
import { useComposedRefs as N } from "../hooks/useComposeRefs.js";
|
|
12
|
+
import { useId as V } from "../hooks/useId.js";
|
|
13
|
+
import { useIntersection as Z } from "../hooks/useIntersection.js";
|
|
14
14
|
import { Box as h } from "../Box/Box.js";
|
|
15
|
-
import { Portal as
|
|
16
|
-
const
|
|
15
|
+
import { Portal as _ } from "../Portal/Portal.js";
|
|
16
|
+
const ue = [
|
|
17
17
|
"top",
|
|
18
18
|
"top-start",
|
|
19
19
|
"top-end",
|
|
@@ -26,42 +26,43 @@ const me = [
|
|
|
26
26
|
"left",
|
|
27
27
|
"left-start",
|
|
28
28
|
"left-end"
|
|
29
|
-
],
|
|
29
|
+
], q = x(h)`
|
|
30
30
|
box-shadow: ${({ theme: e }) => e.shadows.filterShadow};
|
|
31
31
|
z-index: ${({ theme: e }) => e.zIndices[0]};
|
|
32
32
|
border: 1px solid ${({ theme: e }) => e.colors.neutral150};
|
|
33
|
-
`,
|
|
34
|
-
const [m,
|
|
33
|
+
`, G = o.forwardRef(({ source: e, children: s, spacing: n = 0, fullWidth: i = !1, placement: l = "bottom-start", centered: a = !1, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, onFocusOutside: u, ...k }, E) => {
|
|
34
|
+
const [m, R] = o.useState(null), [P, y] = o.useState(void 0), b = o.useRef(!1), { x: C, y: D, refs: S, strategy: L } = I({
|
|
35
35
|
strategy: "fixed",
|
|
36
36
|
placement: a ? "bottom" : l,
|
|
37
37
|
middleware: [
|
|
38
|
-
|
|
38
|
+
W({
|
|
39
39
|
mainAxis: n
|
|
40
40
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
A(),
|
|
42
|
+
K()
|
|
43
43
|
],
|
|
44
|
-
|
|
44
|
+
elements: {
|
|
45
|
+
reference: e.current
|
|
46
|
+
},
|
|
47
|
+
whileElementsMounted: j
|
|
45
48
|
});
|
|
46
49
|
o.useLayoutEffect(() => {
|
|
47
|
-
|
|
48
|
-
}, [e, w]), o.useLayoutEffect(() => {
|
|
49
|
-
i && C(e.current.offsetWidth);
|
|
50
|
+
i && y(e.current.offsetWidth);
|
|
50
51
|
}, [i, e]), o.useEffect(() => {
|
|
51
52
|
if (m)
|
|
52
|
-
return
|
|
53
|
+
return U(m);
|
|
53
54
|
}, [m]);
|
|
54
|
-
const
|
|
55
|
+
const w = T(c);
|
|
55
56
|
o.useEffect(() => {
|
|
56
57
|
const t = () => {
|
|
57
|
-
|
|
58
|
+
w();
|
|
58
59
|
};
|
|
59
60
|
return window.addEventListener("blur", t), window.addEventListener("resize", t), () => {
|
|
60
61
|
window.removeEventListener("blur", t), window.removeEventListener("resize", t);
|
|
61
62
|
};
|
|
62
|
-
}, [
|
|
63
|
-
const
|
|
64
|
-
return r(
|
|
63
|
+
}, [w]);
|
|
64
|
+
const O = N(E, (t) => R(t), S.setFloating);
|
|
65
|
+
return r(B, { allowPinchZoom: !0, children: r(M, {
|
|
65
66
|
asChild: !0,
|
|
66
67
|
loop: !0,
|
|
67
68
|
// we make sure we're not trapping once it's been closed
|
|
@@ -70,35 +71,35 @@ const me = [
|
|
|
70
71
|
onUnmountAutoFocus: (t) => {
|
|
71
72
|
t.preventDefault(), b.current || e.current?.focus({ preventScroll: !0 });
|
|
72
73
|
},
|
|
73
|
-
children: r(
|
|
74
|
+
children: r(H, {
|
|
74
75
|
asChild: !0,
|
|
75
76
|
onEscapeKeyDown: d,
|
|
76
|
-
onPointerDownOutside:
|
|
77
|
-
const p = t.detail.originalEvent,
|
|
78
|
-
b.current =
|
|
77
|
+
onPointerDownOutside: g(f, (t) => {
|
|
78
|
+
const p = t.detail.originalEvent, $ = p.button === 0 && p.ctrlKey === !0, F = p.button === 2 || $;
|
|
79
|
+
b.current = F;
|
|
79
80
|
}, { checkForDefaultPrevented: !1 }),
|
|
80
81
|
// When focus is trapped, a `focusout` event may still happen.
|
|
81
82
|
// We make sure we don't trigger our `onDismiss` in such case.
|
|
82
|
-
onFocusOutside:
|
|
83
|
+
onFocusOutside: g(u, (t) => t.preventDefault(), {
|
|
83
84
|
checkForDefaultPrevented: !1
|
|
84
85
|
}),
|
|
85
86
|
onDismiss: c,
|
|
86
|
-
children: r(
|
|
87
|
-
left:
|
|
88
|
-
top:
|
|
89
|
-
position:
|
|
87
|
+
children: r(q, { ref: O, style: {
|
|
88
|
+
left: C,
|
|
89
|
+
top: D,
|
|
90
|
+
position: L,
|
|
90
91
|
width: P || void 0
|
|
91
|
-
}, hasRadius: !0, background: "neutral0", padding: 1, ...
|
|
92
|
+
}, hasRadius: !0, background: "neutral0", padding: 1, ...k, children: s })
|
|
92
93
|
})
|
|
93
94
|
}) });
|
|
94
|
-
}),
|
|
95
|
-
const l = o.useRef(null), a =
|
|
96
|
-
return
|
|
95
|
+
}), J = ({ children: e, intersectionId: s, onReachEnd: n, ...i }) => {
|
|
96
|
+
const l = o.useRef(null), a = V();
|
|
97
|
+
return Z(l, n ?? (() => {
|
|
97
98
|
}), {
|
|
98
|
-
selectorToWatch: `#${
|
|
99
|
+
selectorToWatch: `#${v(a)}`,
|
|
99
100
|
skipWhen: !s || !n
|
|
100
|
-
}),
|
|
101
|
-
},
|
|
101
|
+
}), z(Q, { ref: l, ...i, children: [e, s && n && r(h, { id: v(a), width: "100%", height: "1px" })] });
|
|
102
|
+
}, Q = x(h)`
|
|
102
103
|
// 16 is base base size, 3 is the factor to get closer to 40px and 5 is the number of elements visible in the list
|
|
103
104
|
max-height: ${3 * 5}rem;
|
|
104
105
|
overflow-y: auto;
|
|
@@ -118,10 +119,10 @@ const me = [
|
|
|
118
119
|
border-radius: ${({ theme: e }) => e.borderRadius};
|
|
119
120
|
margin-right: 10px;
|
|
120
121
|
}
|
|
121
|
-
`,
|
|
122
|
+
`, me = ({ children: e, source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, ...u }) => r(_, { children: r(G, { source: s, spacing: n, fullWidth: i, placement: l, centered: a, onEscapeKeyDown: d, onPointerDownOutside: f, onDismiss: c, children: r(J, { ...u, children: e }) }) });
|
|
122
123
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
G as Content,
|
|
125
|
+
ue as POPOVER_PLACEMENTS,
|
|
126
|
+
me as Popover,
|
|
127
|
+
J as Scrolling
|
|
127
128
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("react"),K=require("@strapi/icons"),b=require("styled-components"),o=require("./SelectParts.cjs"),Q=require("../BaseCheckbox/assets/checkmark.svg.cjs"),U=require("../helpers/strings.cjs"),C=require("../hooks/useId.cjs"),Z=require("../hooks/useIntersection.cjs"),ee=require("../Tag/Tag.cjs"),x=require("../Box/Box.cjs"),R=require("../Typography/Typography.cjs"),te=require("../Field/Field.cjs"),re=require("../Flex/Flex.cjs"),ne=require("../Field/FieldLabel.cjs"),ie=require("../Field/FieldHint.cjs"),oe=require("../Field/FieldError.cjs"),le=e=>e&&e.__esModule?e:{default:e};function se(e){if(e&&e.__esModule)return e;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(i,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return i.default=e,Object.freeze(i)}const d=se(J),ce=le(b),ae=({"aria-label":e,children:i,clearLabel:r="Clear",customizeContent:l,disabled:s,error:c,hint:u,id:j,label:g,labelAction:M,onChange:p,onClear:F,onReachEnd:y,placeholder:_,required:q,selectButtonTitle:he,startIcon:B,size:L="M",value:h,withTags:m,...P})=>{const $=d.useRef(null),[S,k]=d.useState(),[V,z]=d.useState(!1),f=C.useId(j),E=`${f}-hint`,G=`${f}-error`,A=n=>{p?p(n):k(n)},D=n=>()=>{const w=Array.isArray(h)?h.filter(I=>I!==n):(S??[]).filter(I=>I!==n);p?p(w):k(w)},H=n=>{z(n)},v=d.useRef(null),W=()=>{v.current.focus()},N=C.useId(),O=`intersection-${U.stripReactIdOfColon(N)}`,X=n=>{y&&y(n)};Z.useIntersection($,X,{selectorToWatch:`#${O}`,skipWhen:!V});const a=typeof h<"u"&&h!==null?h:S,Y=n=>n&&typeof n=="object"&&n.value?t.jsx(ee.Tag,{tabIndex:-1,disabled:s,icon:t.jsx(K.Cross,{}),onClick:D(n.value),children:n.textValue},n.value):null;return t.jsx(te.Field,{hint:u,error:c,id:f,required:q,children:t.jsxs(re.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[g?t.jsx(ne.FieldLabel,{onClick:W,action:M,children:g}):null,t.jsxs(o.Root,{onOpenChange:H,disabled:s,required:q,onValueChange:A,value:a,...P,multi:!0,children:[t.jsx(o.Trigger,{ref:v,"aria-label":g??e,"aria-describedby":`${E} ${G}`,id:f,startIcon:B,size:L,hasError:!!c,disabled:s,clearLabel:r,onClear:a?.length?F:void 0,paddingLeft:m&&a?.length?1:3,children:t.jsx(o.Value,{placeholder:_,textColor:a?.length?"neutral800":"neutral600",children:a?.length?m?Y:l?l(a):void 0:void 0})}),t.jsx(o.Portal,{children:t.jsx(o.Content,{position:"popper",sideOffset:4,children:t.jsxs(o.Viewport,{ref:$,children:[i,t.jsx(x.Box,{id:O,width:"100%",height:"1px"})]})})})]}),t.jsx(ie.FieldHint,{}),t.jsx(oe.FieldError,{})]})})},de=d.forwardRef(({value:e,children:i,startIcon:r,...l},s)=>t.jsxs(o.Item,{ref:s,value:e.toString(),...l,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:c,isIntermediate:u})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:u,$selected:c,zIndex:1,height:"18px",width:"18px"})}),t.jsx(R.Typography,{textColor:"neutral800",children:t.jsx(o.ItemText,{children:i})})]})),T=ce.default(x.Box)`
|
|
2
2
|
border: 1px solid
|
|
3
3
|
${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral300};
|
|
4
4
|
background-color: ${({theme:e,$selected:i,$indeterminate:r})=>i||r?e.colors.primary600:e.colors.neutral0};
|
|
5
5
|
|
|
6
|
-
${({theme:e,$indeterminate:i})=>i&&
|
|
6
|
+
${({theme:e,$indeterminate:i})=>i&&b.css`
|
|
7
7
|
&::after {
|
|
8
8
|
content: '';
|
|
9
9
|
display: block;
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
}
|
|
19
19
|
`}
|
|
20
20
|
|
|
21
|
-
${({$selected:e})=>e&&
|
|
21
|
+
${({$selected:e})=>e&&b.css`
|
|
22
22
|
&::after {
|
|
23
23
|
content: '';
|
|
24
|
-
background: url(${
|
|
24
|
+
background: url(${Q}) no-repeat no-repeat center center;
|
|
25
25
|
width: 100%;
|
|
26
26
|
height: 100%;
|
|
27
27
|
position: absolute;
|
|
28
28
|
}
|
|
29
29
|
`}
|
|
30
|
-
`,
|
|
30
|
+
`,ue=d.forwardRef(({children:e,label:i,startIcon:r,values:l=[],...s},c)=>t.jsxs(o.Group,{ref:c,children:[t.jsxs(o.Item,{value:l,...s,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(o.ItemIndicator,{children:({isSelected:u,isIntermediate:j})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:j,$selected:u,zIndex:1,height:"18px",width:"18px"})}),t.jsx(R.Typography,{textColor:"neutral800",children:i})]}),e]}));exports.MultiSelect=ae;exports.MultiSelectGroup=ue;exports.MultiSelectOption=de;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import * as d from "react";
|
|
3
|
-
import { Cross as
|
|
4
|
-
import
|
|
5
|
-
import { Item as
|
|
6
|
-
import
|
|
7
|
-
import { stripReactIdOfColon as
|
|
8
|
-
import { useId as
|
|
3
|
+
import { Cross as N } from "@strapi/icons";
|
|
4
|
+
import Q, { css as O } from "styled-components";
|
|
5
|
+
import { Item as F, ItemIndicator as M, ItemText as U, Group as Z, Root as ee, Trigger as re, Value as te, Portal as ne, Content as oe, Viewport as ie } from "./SelectParts.js";
|
|
6
|
+
import le from "../BaseCheckbox/assets/checkmark.svg.js";
|
|
7
|
+
import { stripReactIdOfColon as ae } from "../helpers/strings.js";
|
|
8
|
+
import { useId as S } from "../hooks/useId.js";
|
|
9
9
|
import { useIntersection as ce } from "../hooks/useIntersection.js";
|
|
10
10
|
import { Tag as de } from "../Tag/Tag.js";
|
|
11
|
-
import { Box as
|
|
12
|
-
import { Typography as
|
|
13
|
-
import { Field as
|
|
14
|
-
import { Flex as
|
|
15
|
-
import { FieldLabel as
|
|
16
|
-
import { FieldHint as
|
|
17
|
-
import { FieldError as
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
ce(
|
|
30
|
-
|
|
11
|
+
import { Box as m } from "../Box/Box.js";
|
|
12
|
+
import { Typography as B } from "../Typography/Typography.js";
|
|
13
|
+
import { Field as se } from "../Field/Field.js";
|
|
14
|
+
import { Flex as he } from "../Flex/Flex.js";
|
|
15
|
+
import { FieldLabel as ue } from "../Field/FieldLabel.js";
|
|
16
|
+
import { FieldHint as pe } from "../Field/FieldHint.js";
|
|
17
|
+
import { FieldError as fe } from "../Field/FieldError.js";
|
|
18
|
+
const Le = ({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeContent: l, disabled: i, error: a, hint: h, id: g, label: x, labelAction: V, onChange: p, onClear: j, onReachEnd: $, placeholder: E, required: b, selectButtonTitle: me, startIcon: z, size: A = "M", value: u, withTags: k, ...G }) => {
|
|
19
|
+
const C = d.useRef(null), [v, w] = d.useState(), [W, q] = d.useState(!1), f = S(g), H = `${f}-hint`, P = `${f}-error`, X = (r) => {
|
|
20
|
+
p ? p(r) : w(r);
|
|
21
|
+
}, Y = (r) => () => {
|
|
22
|
+
const T = Array.isArray(u) ? u.filter((I) => I !== r) : (v ?? []).filter((I) => I !== r);
|
|
23
|
+
p ? p(T) : w(T);
|
|
24
|
+
}, _ = (r) => {
|
|
25
|
+
q(r);
|
|
26
|
+
}, R = d.useRef(null), D = () => {
|
|
27
|
+
R.current.focus();
|
|
28
|
+
}, J = S(), y = `intersection-${ae(J)}`;
|
|
29
|
+
ce(C, (r) => {
|
|
30
|
+
$ && $(r);
|
|
31
31
|
}, {
|
|
32
|
-
selectorToWatch: `#${
|
|
32
|
+
selectorToWatch: `#${y}`,
|
|
33
33
|
/**
|
|
34
34
|
* We need to know when the select is open because only then will viewportRef
|
|
35
35
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
36
36
|
*/
|
|
37
|
-
skipWhen: !
|
|
37
|
+
skipWhen: !W
|
|
38
38
|
});
|
|
39
|
-
const c = typeof u < "u" && u !== null ? u :
|
|
40
|
-
return e(
|
|
41
|
-
},
|
|
39
|
+
const c = typeof u < "u" && u !== null ? u : v, K = (r) => r && typeof r == "object" && r.value ? e(de, { tabIndex: -1, disabled: i, icon: e(N, {}), onClick: Y(r.value), children: r.textValue }, r.value) : null;
|
|
40
|
+
return e(se, { hint: h, error: a, id: f, required: b, children: s(he, { direction: "column", alignItems: "stretch", gap: 1, children: [x ? e(ue, { onClick: D, action: V, children: x }) : null, s(ee, { onOpenChange: _, disabled: i, required: b, onValueChange: X, value: c, ...G, multi: !0, children: [e(re, { ref: R, "aria-label": x ?? t, "aria-describedby": `${H} ${P}`, id: f, startIcon: z, size: A, hasError: !!a, disabled: i, clearLabel: o, onClear: c?.length ? j : void 0, paddingLeft: k && c?.length ? 1 : 3, children: e(te, { placeholder: E, textColor: c?.length ? "neutral800" : "neutral600", children: c?.length ? k ? K : l ? l(c) : void 0 : void 0 }) }), e(ne, { children: e(oe, { position: "popper", sideOffset: 4, children: s(ie, { ref: C, children: [n, e(m, { id: y, width: "100%", height: "1px" })] }) }) })] }), e(pe, {}), e(fe, {})] }) });
|
|
41
|
+
}, Ve = d.forwardRef(({ value: t, children: n, startIcon: o, ...l }, i) => s(F, { ref: i, value: t.toString(), ...l, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: a, isIntermediate: h }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: h, $selected: a, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: e(U, { children: n }) })] })), L = Q(m)`
|
|
42
42
|
border: 1px solid
|
|
43
|
-
${({ theme: t, $selected:
|
|
44
|
-
background-color: ${({ theme: t, $selected:
|
|
43
|
+
${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral300};
|
|
44
|
+
background-color: ${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral0};
|
|
45
45
|
|
|
46
|
-
${({ theme: t, $indeterminate:
|
|
46
|
+
${({ theme: t, $indeterminate: n }) => n && O`
|
|
47
47
|
&::after {
|
|
48
48
|
content: '';
|
|
49
49
|
display: block;
|
|
@@ -58,18 +58,18 @@ const Be = ({ children: t, clearLabel: o = "Clear", customizeContent: n, disable
|
|
|
58
58
|
}
|
|
59
59
|
`}
|
|
60
60
|
|
|
61
|
-
${({ $selected: t }) => t &&
|
|
61
|
+
${({ $selected: t }) => t && O`
|
|
62
62
|
&::after {
|
|
63
63
|
content: '';
|
|
64
|
-
background: url(${
|
|
64
|
+
background: url(${le}) no-repeat no-repeat center center;
|
|
65
65
|
width: 100%;
|
|
66
66
|
height: 100%;
|
|
67
67
|
position: absolute;
|
|
68
68
|
}
|
|
69
69
|
`}
|
|
70
|
-
`,
|
|
70
|
+
`, je = d.forwardRef(({ children: t, label: n, startIcon: o, values: l = [], ...i }, a) => s(Z, { ref: a, children: [s(F, { value: l, ...i, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: h, isIntermediate: g }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: g, $selected: h, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: n })] }), t] }));
|
|
71
71
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Le as MultiSelect,
|
|
73
|
+
je as MultiSelectGroup,
|
|
74
|
+
Ve as MultiSelectOption
|
|
75
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("react"),o=require("./SelectParts.cjs"),V=require("../helpers/strings.cjs"),b=require("../hooks/useId.cjs"),H=require("../hooks/useIntersection.cjs"),q=require("../Box/Box.cjs"),W=require("../Typography/Typography.cjs"),z=require("../Field/Field.cjs"),D=require("../Flex/Flex.cjs"),A=require("../Field/FieldLabel.cjs"),G=require("../Field/FieldHint.cjs"),J=require("../Field/FieldError.cjs");function K(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const h=K(E),Q=({error:t,hint:n,id:r,label:i,labelAction:s,required:d,selectButtonTitle:x,...g})=>{const c=b.useId(r),u=h.useRef(null),f=()=>{u.current.focus()};return e.jsx(z.Field,{hint:n,error:t,id:c,required:d,children:e.jsxs(D.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[i?e.jsx(A.FieldLabel,{onClick:f,action:s,children:i}):null,e.jsx(O,{label:i,id:c,triggerRef:u,required:d,...g}),e.jsx(G.FieldHint,{}),e.jsx(J.FieldError,{})]})})},O=({"aria-label":t,id:n,children:r,clearLabel:i="Clear",customizeContent:s,disabled:d,error:x,label:g,onChange:c,onClear:u,onReachEnd:f,placeholder:m,required:y,selectButtonTitle:X,startIcon:F,size:R="M",value:p,triggerRef:T,...B})=>{const[C,j]=h.useState(),[_,$]=h.useState(!1),v=l=>{$(l)},w=l=>{u&&u(l),c||j("")},P=`${n}-hint`,k=`${n}-error`,L=l=>{c?c(typeof p=="number"?Number(l):l):j(l)},S=h.useRef(null),M=b.useId(),I=`intersection-${V.stripReactIdOfColon(M)}`,N=l=>{f&&f(l)};H.useIntersection(S,N,{selectorToWatch:`#${I}`,skipWhen:!_});const a=(typeof p<"u"&&p!==null?p.toString():C)??"";return e.jsxs(o.Root,{onOpenChange:v,disabled:d,required:y,onValueChange:L,value:a,...B,children:[e.jsx(o.Trigger,{ref:T,"aria-label":g??t,"aria-describedby":n?`${P} ${k}`:void 0,id:n,startIcon:F,size:R,hasError:!!x,disabled:d,clearLabel:i,onClear:a&&u?w:void 0,children:e.jsx(o.Value,{placeholder:m,textColor:a?"neutral800":"neutral600",children:a&&s?s(a):void 0})}),e.jsx(o.Portal,{children:e.jsx(o.Content,{position:"popper",sideOffset:4,children:e.jsxs(o.Viewport,{ref:S,children:[r,e.jsx(q.Box,{id:I,width:"100%",height:"1px"})]})})})]})},U=h.forwardRef(({value:t,startIcon:n,children:r,...i},s)=>e.jsxs(o.Item,{ref:s,value:t.toString(),...i,children:[n&&e.jsx(q.Box,{as:"span","aria-hidden":!0,children:n}),e.jsx(W.Typography,{textColor:"neutral800",children:e.jsx(o.ItemText,{children:r})})]}));exports.SingleSelect=Q;exports.SingleSelectInput=O;exports.SingleSelectOption=U;
|
|
@@ -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,6 +1,22 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
|
|
3
|
-
`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),b=require("styled-components"),m=require("../hooks/useControllableState.cjs"),C=require("../hooks/useId.cjs"),d=require("../Flex/Flex.cjs"),k=require("../themes/utils.cjs"),w=require("../TextButton/TextButton.cjs"),I=require("../Field/Field.cjs"),$=require("../Field/FieldLabel.cjs"),S=require("../Field/FieldHint.cjs"),B=require("../Field/FieldError.cjs"),v=require("../Field/FieldContext.cjs"),j=require("../Typography/Typography.cjs"),R=r=>r&&r.__esModule?r:{default:r},c=R(b),W=({offLabel:r,onLabel:p,disabled:e,checked:a,onChange:h,size:l="M",...g})=>{const[n=!1,u]=m.useControllableState({prop:a}),{error:s,id:o,name:x,required:f}=v.useField(),i=n!==null&&!n,q=`${o}-hint`,T=`${o}-error`;return t.jsxs(_,{position:"relative",hasRadius:!0,padding:1,background:e?"neutral150":"neutral100",borderStyle:"solid",borderWidth:"1px",borderColor:"neutral200",wrap:"wrap",cursor:e?"not-allowed":"pointer",hasError:!!s,children:[t.jsx(F,{hasRadius:!0,flex:"1 1 50%",paddingTop:2,paddingBottom:2,paddingLeft:3,paddingRight:3,justifyContent:"center",background:e&&i?"neutral200":i?"neutral0":"transparent",borderColor:e&&i?"neutral300":i?"neutral200":e?"neutral150":"neutral100",size:l,children:t.jsx(j.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:e?"neutral700":i?"danger700":"neutral600",children:r})}),t.jsx(F,{hasRadius:!0,flex:"1 1 50%",paddingLeft:3,paddingRight:3,justifyContent:"center",background:e&&n?"neutral200":n?"neutral0":"transparent",borderColor:e&&n?"neutral300":n?"neutral200":e?"neutral150":"neutral100",size:l,children:t.jsx(j.Typography,{variant:"pi",fontWeight:"bold",textTransform:"uppercase",textColor:e?"neutral700":n?"primary600":"neutral600",children:p})}),t.jsx(E,{...g,onChange:y=>{u(y.currentTarget.checked),h?.(y)},type:"checkbox",id:o,name:x,"aria-required":f,disabled:e,"aria-disabled":e,"aria-describedby":o?`${q} ${T}`:void 0,checked:!!n})]})},_=c.default(d.Flex)`
|
|
2
|
+
${k.inputFocusStyle()}
|
|
3
|
+
`,F=c.default(d.Flex)`
|
|
4
|
+
/**
|
|
5
|
+
We declare the defined value because we want the height of the input when
|
|
6
|
+
the values are in a row to be 40px. But defining a height on the label
|
|
7
|
+
would break the input when it wraps.
|
|
8
|
+
*/
|
|
9
|
+
padding-top: ${({size:r})=>`${r==="S"?"2px":"6px"}`};
|
|
10
|
+
padding-bottom: ${({size:r})=>`${r==="S"?"2px":"6px"}`};
|
|
11
|
+
`,E=c.default.input`
|
|
12
|
+
height: 100%;
|
|
13
|
+
left: 0;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 0;
|
|
17
|
+
z-index: 0;
|
|
18
|
+
width: 100%;
|
|
19
|
+
`,L=({disabled:r=!1,error:p,hint:e,label:a,name:h,labelAction:l,required:g=!1,id:n,onClear:u,clearLabel:s,checked:o,...x})=>{const f=C.useId(n);return t.jsx(I.Field,{name:h,hint:e,error:p,id:f,required:g,maxWidth:"320px",children:t.jsxs(d.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t.jsxs(d.Flex,{children:[a?t.jsx($.FieldLabel,{action:l,children:a}):null,s&&u&&o!==null&&!r&&t.jsx(M,{onClick:u,children:s})]}),t.jsx(W,{checked:o,disabled:r,...x}),t.jsx(S.FieldHint,{}),t.jsx(B.FieldError,{})]})})},M=c.default(w.TextButton)`
|
|
4
20
|
align-self: flex-end;
|
|
5
21
|
margin-left: auto;
|
|
6
|
-
|
|
22
|
+
`;exports.ToggleInput=L;
|
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Field as T } from "../Field/Field.js";
|
|
6
|
-
import { TextButton as j } from "../TextButton/TextButton.js";
|
|
1
|
+
import { jsx as r, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import c from "styled-components";
|
|
3
|
+
import { useControllableState as T } from "../hooks/useControllableState.js";
|
|
4
|
+
import { useId as I } from "../hooks/useId.js";
|
|
7
5
|
import { Flex as d } from "../Flex/Flex.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
import { inputFocusStyle as $ } from "../themes/utils.js";
|
|
7
|
+
import { TextButton as F } from "../TextButton/TextButton.js";
|
|
8
|
+
import { Field as B } from "../Field/Field.js";
|
|
9
|
+
import { FieldLabel as W } from "../Field/FieldLabel.js";
|
|
10
|
+
import { FieldHint as v } from "../Field/FieldHint.js";
|
|
11
|
+
import { FieldError as R } from "../Field/FieldError.js";
|
|
12
|
+
import { useField as S } from "../Field/FieldContext.js";
|
|
13
|
+
import { Typography as y } from "../Typography/Typography.js";
|
|
14
|
+
const j = ({ offLabel: n, onLabel: h, disabled: e, checked: a, onChange: s, size: l = "M", ...m }) => {
|
|
15
|
+
const [t = !1, p] = T({
|
|
16
|
+
prop: a
|
|
17
|
+
}), { error: u, id: o, name: g, required: f } = S(), i = t !== null && !t, w = `${o}-hint`, b = `${o}-error`;
|
|
18
|
+
return x(q, { position: "relative", hasRadius: !0, padding: 1, background: e ? "neutral150" : "neutral100", borderStyle: "solid", borderWidth: "1px", borderColor: "neutral200", wrap: "wrap", cursor: e ? "not-allowed" : "pointer", hasError: !!u, children: [r(C, { hasRadius: !0, flex: "1 1 50%", paddingTop: 2, paddingBottom: 2, paddingLeft: 3, paddingRight: 3, justifyContent: "center", background: e && i ? "neutral200" : i ? "neutral0" : "transparent", borderColor: e && i ? "neutral300" : i ? "neutral200" : e ? "neutral150" : "neutral100", size: l, children: r(y, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: e ? "neutral700" : i ? "danger700" : "neutral600", children: n }) }), r(C, { hasRadius: !0, flex: "1 1 50%", paddingLeft: 3, paddingRight: 3, justifyContent: "center", background: e && t ? "neutral200" : t ? "neutral0" : "transparent", borderColor: e && t ? "neutral300" : t ? "neutral200" : e ? "neutral150" : "neutral100", size: l, children: r(y, { variant: "pi", fontWeight: "bold", textTransform: "uppercase", textColor: e ? "neutral700" : t ? "primary600" : "neutral600", children: h }) }), r(z, { ...m, onChange: (k) => {
|
|
19
|
+
p(k.currentTarget.checked), s?.(k);
|
|
20
|
+
}, type: "checkbox", id: o, name: g, "aria-required": f, disabled: e, "aria-disabled": e, "aria-describedby": o ? `${w} ${b}` : void 0, checked: !!t })] });
|
|
21
|
+
}, q = c(d)`
|
|
22
|
+
${$()}
|
|
23
|
+
`, C = c(d)`
|
|
24
|
+
/**
|
|
25
|
+
We declare the defined value because we want the height of the input when
|
|
26
|
+
the values are in a row to be 40px. But defining a height on the label
|
|
27
|
+
would break the input when it wraps.
|
|
28
|
+
*/
|
|
29
|
+
padding-top: ${({ size: n }) => `${n === "S" ? "2px" : "6px"}`};
|
|
30
|
+
padding-bottom: ${({ size: n }) => `${n === "S" ? "2px" : "6px"}`};
|
|
31
|
+
`, z = c.input`
|
|
32
|
+
height: 100%;
|
|
33
|
+
left: 0;
|
|
34
|
+
opacity: 0;
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 0;
|
|
37
|
+
z-index: 0;
|
|
38
|
+
width: 100%;
|
|
39
|
+
`, V = ({ disabled: n = !1, error: h, hint: e, label: a, name: s, labelAction: l, required: m = !1, id: t, onClear: p, clearLabel: u, checked: o, ...g }) => {
|
|
40
|
+
const f = I(t);
|
|
41
|
+
return r(B, { name: s, hint: e, error: h, id: f, required: m, maxWidth: "320px", children: x(d, { direction: "column", alignItems: "stretch", gap: 1, children: [x(d, { children: [a ? r(W, { action: l, children: a }) : null, u && p && o !== null && !n && r(E, { onClick: p, children: u })] }), r(j, { checked: o, disabled: n, ...g }), r(v, {}), r(R, {})] }) });
|
|
42
|
+
}, E = c(F)`
|
|
14
43
|
align-self: flex-end;
|
|
15
44
|
margin-left: auto;
|
|
16
|
-
|
|
17
|
-
const l = F(u);
|
|
18
|
-
return r(C, { name: a, hint: c, error: f, id: l, required: h, children: m(d, { direction: "column", alignItems: "stretch", gap: 1, children: [m(d, { children: [r(k, { action: g, children: o }), t && i && n !== null && !e && r(q, { onClick: i, children: t })] }), r(I, { id: l, size: s, checked: n, disabled: e, ...x, children: o }), r(y, {}), r(B, {})] }) });
|
|
19
|
-
};
|
|
20
|
-
w.displayName = "ToggleInput";
|
|
45
|
+
`;
|
|
21
46
|
export {
|
|
22
|
-
|
|
47
|
+
V as ToggleInput
|
|
23
48
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
font-weight: ${({theme:e,fontWeight:t})=>r.extractStyleFromTheme(e.fontWeights,t,void 0)};
|
|
8
8
|
font-size: ${({theme:e,fontSize:t})=>r.extractStyleFromTheme(e.fontSizes,t,void 0)};
|
|
9
9
|
line-height: ${({theme:e,lineHeight:t})=>r.extractStyleFromTheme(e.lineHeights,t,t)};
|
|
10
|
-
color: ${
|
|
10
|
+
color: ${({theme:e,textColor:t})=>e.colors[t||"neutral800"]};
|
|
11
11
|
text-align: ${({textAlign:e})=>e};
|
|
12
12
|
text-decoration: ${({textDecoration:e})=>e};
|
|
13
13
|
text-transform: ${({textTransform:e})=>e};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "styled-components";
|
|
2
|
-
import { variantStyle as i, ellipsisStyle as n
|
|
2
|
+
import { variantStyle as i, ellipsisStyle as n } from "./utils.js";
|
|
3
3
|
import { extractStyleFromTheme as o } from "../helpers/theme.js";
|
|
4
|
-
const
|
|
4
|
+
const a = {
|
|
5
5
|
fontSize: !0,
|
|
6
6
|
fontWeight: !0
|
|
7
|
-
},
|
|
8
|
-
shouldForwardProp: (t, e) => !
|
|
7
|
+
}, h = r.span.withConfig({
|
|
8
|
+
shouldForwardProp: (t, e) => !a[t] && e(t)
|
|
9
9
|
})`
|
|
10
10
|
${i}
|
|
11
11
|
${n}
|
|
@@ -15,11 +15,11 @@ const s = {
|
|
|
15
15
|
font-weight: ${({ theme: t, fontWeight: e }) => o(t.fontWeights, e, void 0)};
|
|
16
16
|
font-size: ${({ theme: t, fontSize: e }) => o(t.fontSizes, e, void 0)};
|
|
17
17
|
line-height: ${({ theme: t, lineHeight: e }) => o(t.lineHeights, e, e)};
|
|
18
|
-
color: ${
|
|
18
|
+
color: ${({ theme: t, textColor: e }) => t.colors[e || "neutral800"]};
|
|
19
19
|
text-align: ${({ textAlign: t }) => t};
|
|
20
20
|
text-decoration: ${({ textDecoration: t }) => t};
|
|
21
21
|
text-transform: ${({ textTransform: t }) => t};
|
|
22
22
|
`;
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
h as Typography
|
|
25
25
|
};
|