@strapi/design-system 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseCheckbox/BaseCheckbox.cjs +4 -4
- package/dist/BaseCheckbox/BaseCheckbox.js +19 -18
- package/dist/CarouselInput/Carousel.cjs +4 -4
- package/dist/CarouselInput/Carousel.js +13 -13
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +14 -13
- package/dist/Checkbox/Checkbox.cjs +2 -2
- package/dist/Checkbox/Checkbox.js +22 -21
- package/dist/Combobox/Combobox.cjs +10 -10
- package/dist/Combobox/Combobox.js +56 -55
- package/dist/DatePicker/DatePicker.cjs +2 -2
- package/dist/DatePicker/DatePicker.js +2 -2
- package/dist/DateTimePicker/DateTimePicker.cjs +3 -3
- package/dist/DateTimePicker/DateTimePicker.js +46 -42
- package/dist/JSONInput/JSONInput.cjs +33 -1
- package/dist/JSONInput/JSONInput.js +85 -46
- package/dist/Select/MultiSelect.cjs +6 -6
- package/dist/Select/MultiSelect.js +35 -34
- package/dist/Select/SingleSelect.cjs +1 -1
- package/dist/Select/SingleSelect.js +31 -30
- package/dist/TextInput/TextInput.cjs +1 -1
- package/dist/TextInput/TextInput.js +15 -14
- package/dist/TimePicker/TimePicker.cjs +2 -2
- package/dist/TimePicker/TimePicker.js +38 -38
- package/dist/ToggleInput/ToggleInput.cjs +8 -8
- package/dist/ToggleInput/ToggleInput.js +26 -25
- package/dist/themes/utils.cjs +9 -9
- package/dist/themes/utils.js +9 -9
- package/package.json +5 -5
- package/dist/JSONInput/JSONInputContainer.cjs +0 -33
- package/dist/JSONInput/JSONInputContainer.js +0 -39
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
& > path {
|
|
30
30
|
fill: ${({theme:e})=>e.colors.neutral500};
|
|
31
31
|
}
|
|
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`
|
|
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};
|
|
@@ -85,4 +85,4 @@
|
|
|
85
85
|
color: ${({theme:e})=>e.colors.primary600};
|
|
86
86
|
}
|
|
87
87
|
}
|
|
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,
|
|
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,id:l,children:a.jsxs(B.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[a.jsx(Re.FieldLabel,{children:g}),a.jsx(le,{ref:r,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;
|
|
@@ -178,7 +178,7 @@ const je = 200, oe = 15, [He, L] = Ve("DatePicker"), Xe = c.forwardRef(({
|
|
|
178
178
|
}
|
|
179
179
|
}), m = d.find((p) => p.type === "literal")?.value ?? "";
|
|
180
180
|
return [o, m, h];
|
|
181
|
-
}, [y]), E = k.map((d) => `\\d${d.length}`).join(w);
|
|
181
|
+
}, [y]), E = k.map((d) => `\\d{${d.length}}`).join(`\\${w}`);
|
|
182
182
|
return i(lt, { role: "combobox", type: "text", inputMode: "numeric", ref: x, "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: E, placeholder: e ?? k.join(w), ...r, value: s ?? "", onBlur: N(r.onBlur, () => {
|
|
183
183
|
if (!t.textValue) {
|
|
184
184
|
t.onValueChange(void 0);
|
|
@@ -415,7 +415,7 @@ const lt = I.input`
|
|
|
415
415
|
}
|
|
416
416
|
`, wt = c.forwardRef((e, r) => {
|
|
417
417
|
const { error: n, hint: t, id: a, required: s, label: g, ...u } = e, l = ce(a);
|
|
418
|
-
return i(Ze, { error: n, hint: t, required: s,
|
|
418
|
+
return i(Ze, { error: n, hint: t, required: s, id: l, children: F(U, { direction: "column", alignItems: "stretch", gap: 1, children: [i(qe, { children: g }), i(Xe, { ref: r, id: l, error: n, required: s, ...u }), i(Ke, {}), i(Ge, {})] }) });
|
|
419
419
|
}), xt = Ye(console.warn), R = (e) => {
|
|
420
420
|
if (typeof e == "string") {
|
|
421
421
|
xt("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.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("react"),p=require("@internationalized/date"),G=require("styled-components"),J=require("../DatePicker/DatePicker.cjs"),K=require("../DesignSystemProvider.cjs"),Q=require("../helpers/deprecations.cjs"),W=require("../hooks/useComposeRefs.cjs"),X=require("../hooks/useControllableState.cjs"),Y=require("../hooks/useDateFormatter.cjs"),x=require("../hooks/useId.cjs"),ee=require("../TimePicker/TimePicker.cjs"),te=require("../Field/Field.cjs"),P=require("../Flex/Flex.cjs"),ne=require("../Field/FieldLabel.cjs"),j=require("../VisuallyHidden/VisuallyHidden.cjs"),re=require("../Field/FieldHint.cjs"),se=require("../Field/FieldError.cjs"),S=e=>e&&e.__esModule?e:{default:e},ie=S(w),_=S(G),ae=w.forwardRef(({ariaLabel:e,clearLabel:d="clear",dateLabel:h="Choose date",timeLabel:o="Choose time",disabled:l=!1,error:D,hint:L,id:R,label:V,labelAction:H,onChange:q,onClear:u,name:$,required:g=!1,selectButtonTitle:de,size:C="M",step:v,value:T,initialDate:I,...E},M)=>{const y=ie.default.useRef(null),[r,m]=X.useControllableState({defaultProp:I?a(I,!1):void 0,prop:T?a(T,!1):T??void 0,onChange(t){q&&q(t?.toDate(p.getLocalTimeZone()))}}),N=K.useDesignSystem("DateTimePicker"),O=Y.useDateFormatter(N.locale,{hour:"2-digit",minute:"2-digit",hour12:!1}),c=r?O.format(r.toDate(p.getLocalTimeZone())):"",U=t=>{let s=t?a(t):void 0;if(!(s&&r&&s.compare(r)===0)){if(c&&s){const[f,b]=c.split(":");s=s.set({hour:parseInt(f,10),minute:parseInt(b,10)})}m(s)}},z=t=>{if(!t)return;const[s,f]=t.split(":"),b=r?r.set({hour:parseInt(s,10),minute:parseInt(f,10)}):a(new Date).set({hour:parseInt(s,10),minute:parseInt(f,10)});m(b)},B=t=>{m(void 0),u&&u(t)},Z=()=>{const t=r?r.set({hour:0,minute:0}):a(new Date);m(t)},i=x.useId(R),F=x.useId(),k=x.useId(),A=W.useComposedRefs(y,M);return n.jsx(te.Field,{name:$,as:"fieldset",id:i,"aria-labelledby":i,hint:L,error:D,required:g,children:n.jsxs(P.Flex,{as:"span",direction:"column",alignItems:"stretch",gap:1,children:[n.jsx(ne.FieldLabel,{onClick:()=>{y.current.focus()},as:"legend",id:i,action:H,children:V}),n.jsxs(P.Flex,{flex:"1",gap:1,children:[n.jsx(j.VisuallyHidden,{as:"label",htmlFor:k,children:h}),n.jsx(le,{...E,selectedDate:r?.toDate("UTC"),onChange:U,error:typeof D=="string",required:g,size:C,onClear:u?B:void 0,clearLabel:`${d} date`,disabled:l,id:k,ref:A,"aria-describedby":`${i}-hint ${i}-error`}),n.jsx(j.VisuallyHidden,{as:"label",htmlFor:F,children:o}),n.jsx(ce,{size:C,error:typeof D=="string",value:c,onChange:z,onClear:u&&c!==void 0&&c!=="00:00"?Z:void 0,clearLabel:`${d} time`,required:g,disabled:l,step:v,id:F,"aria-describedby":`${i}-hint ${i}-error`})]}),n.jsx(re.FieldHint,{}),n.jsx(se.FieldError,{})]})})}),oe=Q.once(console.warn),a=(e,d=!0)=>{if(typeof e=="string"){oe("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 l=Date.parse(e);Number.isNaN(l)?e=new Date:e=new Date(l)}const h=e.toISOString();let o=p.parseAbsoluteToLocal(h);return d&&(o=o.set({hour:0,minute:0})),p.toCalendarDateTime(o)},le=_.default(J.DatePickerInput)`
|
|
2
2
|
flex: 1 1 70%;
|
|
3
3
|
min-width: 120px;
|
|
4
|
-
`,
|
|
4
|
+
`,ce=_.default(ee.TimePickerInput)`
|
|
5
5
|
flex: 1 1 30%;
|
|
6
6
|
min-width: 120px;
|
|
7
|
-
`;exports.DateTimePicker=
|
|
7
|
+
`;exports.DateTimePicker=ae;exports.convertUTCDateToCalendarDateTime=a;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { getLocalTimeZone as
|
|
1
|
+
import { jsx as o, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import v, { forwardRef as G } from "react";
|
|
3
|
+
import { getLocalTimeZone as P, parseAbsoluteToLocal as J, toCalendarDateTime as K } from "@internationalized/date";
|
|
4
4
|
import $ from "styled-components";
|
|
5
|
-
import { DatePickerInput as
|
|
6
|
-
import { useDesignSystem as
|
|
7
|
-
import { once as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
5
|
+
import { DatePickerInput as Q } from "../DatePicker/DatePicker.js";
|
|
6
|
+
import { useDesignSystem as W } from "../DesignSystemProvider.js";
|
|
7
|
+
import { once as X } from "../helpers/deprecations.js";
|
|
8
|
+
import { useComposedRefs as Y } from "../hooks/useComposeRefs.js";
|
|
9
|
+
import { useControllableState as ee } from "../hooks/useControllableState.js";
|
|
10
|
+
import { useDateFormatter as te } from "../hooks/useDateFormatter.js";
|
|
11
|
+
import { useId as b } from "../hooks/useId.js";
|
|
12
|
+
import { TimePickerInput as re } from "../TimePicker/TimePicker.js";
|
|
13
|
+
import { Field as oe } from "../Field/Field.js";
|
|
13
14
|
import { Flex as L } from "../Flex/Flex.js";
|
|
14
|
-
import { FieldLabel as
|
|
15
|
+
import { FieldLabel as ie } from "../Field/FieldLabel.js";
|
|
15
16
|
import { VisuallyHidden as S } from "../VisuallyHidden/VisuallyHidden.js";
|
|
16
|
-
import { FieldHint as
|
|
17
|
-
import { FieldError as
|
|
18
|
-
const
|
|
17
|
+
import { FieldHint as ne } from "../Field/FieldHint.js";
|
|
18
|
+
import { FieldError as ae } from "../Field/FieldError.js";
|
|
19
|
+
const Se = G(({
|
|
19
20
|
/**
|
|
20
21
|
* @preserve
|
|
21
22
|
* @deprecated This is no longer used.
|
|
@@ -26,11 +27,11 @@ const xe = ({
|
|
|
26
27
|
timeLabel: a = "Choose time",
|
|
27
28
|
disabled: s = !1,
|
|
28
29
|
error: h,
|
|
29
|
-
hint:
|
|
30
|
-
id:
|
|
31
|
-
label:
|
|
32
|
-
labelAction:
|
|
33
|
-
onChange:
|
|
30
|
+
hint: R,
|
|
31
|
+
id: V,
|
|
32
|
+
label: _,
|
|
33
|
+
labelAction: N,
|
|
34
|
+
onChange: I,
|
|
34
35
|
onClear: c,
|
|
35
36
|
name: j,
|
|
36
37
|
required: D = !1,
|
|
@@ -38,24 +39,24 @@ const xe = ({
|
|
|
38
39
|
* @preserve
|
|
39
40
|
* @deprecated This is no longer used.
|
|
40
41
|
*/
|
|
41
|
-
selectButtonTitle:
|
|
42
|
+
selectButtonTitle: de,
|
|
42
43
|
size: C = "M",
|
|
43
44
|
step: z,
|
|
44
45
|
value: g,
|
|
45
|
-
initialDate:
|
|
46
|
+
initialDate: k,
|
|
46
47
|
...B
|
|
47
|
-
}) => {
|
|
48
|
-
const
|
|
49
|
-
defaultProp:
|
|
48
|
+
}, E) => {
|
|
49
|
+
const w = v.useRef(null), [t, f] = ee({
|
|
50
|
+
defaultProp: k ? m(k, !1) : void 0,
|
|
50
51
|
prop: g ? m(g, !1) : g ?? void 0,
|
|
51
52
|
onChange(e) {
|
|
52
|
-
|
|
53
|
+
I && I(e?.toDate(P()));
|
|
53
54
|
}
|
|
54
|
-
}), H =
|
|
55
|
+
}), H = W("DateTimePicker"), O = te(H.locale, {
|
|
55
56
|
hour: "2-digit",
|
|
56
57
|
minute: "2-digit",
|
|
57
58
|
hour12: !1
|
|
58
|
-
}), l = t ? O.format(t.toDate(
|
|
59
|
+
}), l = t ? O.format(t.toDate(P())) : "", U = (e) => {
|
|
59
60
|
let r = e ? m(e) : void 0;
|
|
60
61
|
if (!(r && t && r.compare(t) === 0)) {
|
|
61
62
|
if (l && r) {
|
|
@@ -64,37 +65,40 @@ const xe = ({
|
|
|
64
65
|
}
|
|
65
66
|
f(r);
|
|
66
67
|
}
|
|
67
|
-
},
|
|
68
|
+
}, q = (e) => {
|
|
68
69
|
if (!e)
|
|
69
70
|
return;
|
|
70
|
-
const [r, u] = e.split(":"), T = t ? t.set({ hour: parseInt(r, 10), minute: parseInt(u, 10) }) : m(/* @__PURE__ */ new Date()).set({
|
|
71
|
+
const [r, u] = e.split(":"), T = t ? t.set({ hour: parseInt(r, 10), minute: parseInt(u, 10) }) : m(/* @__PURE__ */ new Date()).set({
|
|
72
|
+
hour: parseInt(r, 10),
|
|
73
|
+
minute: parseInt(u, 10)
|
|
74
|
+
});
|
|
71
75
|
f(T);
|
|
72
|
-
},
|
|
76
|
+
}, A = (e) => {
|
|
73
77
|
f(void 0), c && c(e);
|
|
74
78
|
}, M = () => {
|
|
75
79
|
const e = t ? t.set({ hour: 0, minute: 0 }) : m(/* @__PURE__ */ new Date());
|
|
76
80
|
f(e);
|
|
77
|
-
}, i =
|
|
78
|
-
return o(
|
|
79
|
-
|
|
80
|
-
}, as: "legend", id: i, action:
|
|
81
|
-
},
|
|
81
|
+
}, i = b(V), x = b(), y = b(), Z = Y(w, E);
|
|
82
|
+
return o(oe, { name: j, as: "fieldset", id: i, "aria-labelledby": i, hint: R, error: h, required: D, children: F(L, { as: "span", direction: "column", alignItems: "stretch", gap: 1, children: [o(ie, { onClick: () => {
|
|
83
|
+
w.current.focus();
|
|
84
|
+
}, as: "legend", id: i, action: N, children: _ }), F(L, { flex: "1", gap: 1, children: [o(S, { as: "label", htmlFor: y, children: p }), o(le, { ...B, selectedDate: t?.toDate("UTC"), onChange: U, error: typeof h == "string", required: D, size: C, onClear: c ? A : void 0, clearLabel: `${d} date`, disabled: s, id: y, ref: Z, "aria-describedby": `${i}-hint ${i}-error` }), o(S, { as: "label", htmlFor: x, children: a }), o(me, { size: C, error: typeof h == "string", value: l, onChange: q, onClear: c && l !== void 0 && l !== "00:00" ? M : void 0, clearLabel: `${d} time`, required: D, disabled: s, step: z, id: x, "aria-describedby": `${i}-hint ${i}-error` })] }), o(ne, {}), o(ae, {})] }) });
|
|
85
|
+
}), se = X(console.warn), m = (n, d = !0) => {
|
|
82
86
|
if (typeof n == "string") {
|
|
83
|
-
|
|
87
|
+
se("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.");
|
|
84
88
|
const s = Date.parse(n);
|
|
85
89
|
Number.isNaN(s) ? n = /* @__PURE__ */ new Date() : n = new Date(s);
|
|
86
90
|
}
|
|
87
91
|
const p = n.toISOString();
|
|
88
|
-
let a =
|
|
89
|
-
return d && (a = a.set({ hour: 0, minute: 0 })),
|
|
90
|
-
},
|
|
92
|
+
let a = J(p);
|
|
93
|
+
return d && (a = a.set({ hour: 0, minute: 0 })), K(a);
|
|
94
|
+
}, le = $(Q)`
|
|
91
95
|
flex: 1 1 70%;
|
|
92
96
|
min-width: 120px;
|
|
93
|
-
`,
|
|
97
|
+
`, me = $(re)`
|
|
94
98
|
flex: 1 1 30%;
|
|
95
99
|
min-width: 120px;
|
|
96
100
|
`;
|
|
97
101
|
export {
|
|
98
|
-
|
|
102
|
+
Se as DateTimePicker,
|
|
99
103
|
m as convertUTCDateToCalendarDateTime
|
|
100
104
|
};
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),p=require("@codemirror/lang-json"),J=require("@uiw/react-codemirror"),N=require("styled-components"),d=require("./utils/decorationExtension.cjs"),L=require("../hooks/useComposeRefs.cjs"),_=require("../Field/Field.cjs"),b=require("../Flex/Flex.cjs"),$=require("../Field/FieldLabel.cjs"),v=require("../Field/FieldError.cjs"),V=require("../Field/FieldHint.cjs"),z=require("../themes/utils.cjs"),A=e=>e&&e.__esModule?e:{default:e},B=A(N),P=i.forwardRef(({label:e,error:c,hint:S,labelAction:F,value:x="",required:q=!1,disabled:h=!1,onChange:E=()=>null,...C},R)=>{const f=i.useRef(),l=i.useRef(),u=i.useRef(),j=!!c,k=r=>{const t=l.current?.doc;if(t){const{text:a,to:n}=t.line(r),m=n-a.trimStart().length;n>m&&u.current?.dispatch({effects:d.addMarks.of([d.lineHighlightMark.range(m,n)])})}},I=()=>{const r=l.current?.doc;if(r){const t=r.length||0;u.current?.dispatch({effects:d.filterMarks.of((a,n)=>n<=0||a>=t)})}},g=({state:r,view:t})=>{u.current=t,l.current=r,I();const n=p.jsonParseLinter()(t);n.length&&k(r.doc.lineAt(n[0].from).number)},w=(r,t)=>{g(t),E(r)},H=(r,t)=>{u.current=r,l.current=t,g({view:r,state:t})},{setContainer:M,view:o}=J.useCodeMirror({value:x,onCreateEditor:H,container:f.current,editable:!h,extensions:[p.json(),d.markField],onChange:w,theme:"dark",basicSetup:{lineNumbers:!0,bracketMatching:!0,closeBrackets:!0,indentOnInput:!0,syntaxHighlighting:!0,highlightSelectionMatches:!0,tabSize:2}}),O=()=>{!h&&o&&o.focus()},y=L.useComposedRefs(f,M);return i.useImperativeHandle(R,()=>({...o?.dom,focus(){o&&o.focus()},scrollIntoView(r){o&&o.dom.scrollIntoView(r)}}),[o]),s.jsx(_.Field,{error:c,hint:S,required:q,children:s.jsxs(b.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[e&&s.jsx($.FieldLabel,{onClick:O,action:F,children:e}),s.jsx(D,{ref:y,hasError:j,alignItems:"stretch",fontSize:2,hasRadius:!0,...C}),s.jsx(v.FieldError,{}),s.jsx(V.FieldHint,{})]})})}),D=B.default(b.Flex)`
|
|
2
|
+
line-height: ${({theme:e})=>e.lineHeights[2]};
|
|
3
|
+
|
|
4
|
+
.cm-editor {
|
|
5
|
+
/**
|
|
6
|
+
* Hard coded since the color is the same between themes,
|
|
7
|
+
* theme.colors.neutral800 changes between themes
|
|
8
|
+
*/
|
|
9
|
+
background-color: #32324d;
|
|
10
|
+
width: 100%;
|
|
11
|
+
outline: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cm-scroller {
|
|
15
|
+
border: 1px solid ${({theme:e,hasError:c})=>c?e.colors.danger600:e.colors.neutral200};
|
|
16
|
+
/* inputFocusStyle will receive hasError prop */
|
|
17
|
+
${z.inputFocusStyle()}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cm-editor,
|
|
21
|
+
.cm-scroller {
|
|
22
|
+
border-radius: ${({theme:e})=>e.borderRadius};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cm-gutters,
|
|
26
|
+
.cm-activeLineGutter {
|
|
27
|
+
/**
|
|
28
|
+
* Hard coded since the color is the same between themes,
|
|
29
|
+
* theme.colors.neutral700 changes between themes
|
|
30
|
+
*/
|
|
31
|
+
background-color: #4a4a6a;
|
|
32
|
+
}
|
|
33
|
+
`;exports.JSONInput=P;
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { json as
|
|
4
|
-
import { useCodeMirror as
|
|
5
|
-
import
|
|
6
|
-
import { markField as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { jsx as i, jsxs as J } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j, useRef as d, useImperativeHandle as y } from "react";
|
|
3
|
+
import { json as L, jsonParseLinter as $ } from "@codemirror/lang-json";
|
|
4
|
+
import { useCodeMirror as V } from "@uiw/react-codemirror";
|
|
5
|
+
import v from "styled-components";
|
|
6
|
+
import { markField as z, addMarks as A, lineHighlightMark as B, filterMarks as q } from "./utils/decorationExtension.js";
|
|
7
|
+
import { useComposedRefs as G } from "../hooks/useComposeRefs.js";
|
|
8
|
+
import { Field as P } from "../Field/Field.js";
|
|
9
|
+
import { Flex as g } from "../Flex/Flex.js";
|
|
10
|
+
import { FieldLabel as D } from "../Field/FieldLabel.js";
|
|
11
|
+
import { FieldError as K } from "../Field/FieldError.js";
|
|
12
|
+
import { FieldHint as Q } from "../Field/FieldHint.js";
|
|
13
|
+
import { inputFocusStyle as T } from "../themes/utils.js";
|
|
14
|
+
const lr = j(({ label: t, error: c, hint: p, labelAction: b, value: S = "", required: E = !1, disabled: m = !1, onChange: k = () => null, ...F }, w) => {
|
|
15
|
+
const u = d(), s = d(), l = d(), C = !!c, I = (r) => {
|
|
16
|
+
const e = s.current?.doc;
|
|
17
|
+
if (e) {
|
|
18
|
+
const { text: a, to: n } = e.line(r), f = n - a.trimStart().length;
|
|
19
|
+
n > f && l.current?.dispatch({
|
|
20
|
+
effects: A.of([B.range(f, n)])
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
}, x = () => {
|
|
22
|
-
const r =
|
|
24
|
+
const r = s.current?.doc;
|
|
23
25
|
if (r) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
effects: q.of((
|
|
26
|
+
const e = r.length || 0;
|
|
27
|
+
l.current?.dispatch({
|
|
28
|
+
effects: q.of((a, n) => n <= 0 || a >= e)
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
}, { setContainer:
|
|
38
|
-
value:
|
|
39
|
-
onCreateEditor:
|
|
40
|
-
container:
|
|
41
|
-
editable: !
|
|
42
|
-
extensions: [
|
|
43
|
-
onChange:
|
|
31
|
+
}, h = ({ state: r, view: e }) => {
|
|
32
|
+
l.current = e, s.current = r, x();
|
|
33
|
+
const n = $()(e);
|
|
34
|
+
n.length && I(r.doc.lineAt(n[0].from).number);
|
|
35
|
+
}, H = (r, e) => {
|
|
36
|
+
h(e), k(r);
|
|
37
|
+
}, M = (r, e) => {
|
|
38
|
+
l.current = r, s.current = e, h({ view: r, state: e });
|
|
39
|
+
}, { setContainer: N, view: o } = V({
|
|
40
|
+
value: S,
|
|
41
|
+
onCreateEditor: M,
|
|
42
|
+
container: u.current,
|
|
43
|
+
editable: !m,
|
|
44
|
+
extensions: [L(), z],
|
|
45
|
+
onChange: H,
|
|
44
46
|
theme: "dark",
|
|
45
47
|
basicSetup: {
|
|
46
48
|
lineNumbers: !0,
|
|
@@ -51,14 +53,51 @@ const v = ({ label: a, error: d, hint: g, labelAction: p, value: E = "", require
|
|
|
51
53
|
highlightSelectionMatches: !0,
|
|
52
54
|
tabSize: 2
|
|
53
55
|
}
|
|
54
|
-
}),
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
56
|
+
}), O = () => {
|
|
57
|
+
!m && o && o.focus();
|
|
58
|
+
}, R = G(u, N);
|
|
59
|
+
return y(w, () => ({
|
|
60
|
+
...o?.dom,
|
|
61
|
+
focus() {
|
|
62
|
+
o && o.focus();
|
|
63
|
+
},
|
|
64
|
+
scrollIntoView(r) {
|
|
65
|
+
o && o.dom.scrollIntoView(r);
|
|
66
|
+
}
|
|
67
|
+
}), [o]), i(P, { error: c, hint: p, required: E, children: J(g, { direction: "column", alignItems: "stretch", gap: 1, children: [t && i(D, { onClick: O, action: b, children: t }), i(U, { ref: R, hasError: C, alignItems: "stretch", fontSize: 2, hasRadius: !0, ...F }), i(K, {}), i(Q, {})] }) });
|
|
68
|
+
}), U = v(g)`
|
|
69
|
+
line-height: ${({ theme: t }) => t.lineHeights[2]};
|
|
70
|
+
|
|
71
|
+
.cm-editor {
|
|
72
|
+
/**
|
|
73
|
+
* Hard coded since the color is the same between themes,
|
|
74
|
+
* theme.colors.neutral800 changes between themes
|
|
75
|
+
*/
|
|
76
|
+
background-color: #32324d;
|
|
77
|
+
width: 100%;
|
|
78
|
+
outline: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cm-scroller {
|
|
82
|
+
border: 1px solid ${({ theme: t, hasError: c }) => c ? t.colors.danger600 : t.colors.neutral200};
|
|
83
|
+
/* inputFocusStyle will receive hasError prop */
|
|
84
|
+
${T()}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.cm-editor,
|
|
88
|
+
.cm-scroller {
|
|
89
|
+
border-radius: ${({ theme: t }) => t.borderRadius};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.cm-gutters,
|
|
93
|
+
.cm-activeLineGutter {
|
|
94
|
+
/**
|
|
95
|
+
* Hard coded since the color is the same between themes,
|
|
96
|
+
* theme.colors.neutral700 changes between themes
|
|
97
|
+
*/
|
|
98
|
+
background-color: #4a4a6a;
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
62
101
|
export {
|
|
63
|
-
|
|
102
|
+
lr as JSONInput
|
|
64
103
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),Q=require("react"),U=require("@strapi/icons"),b=require("styled-components"),i=require("./SelectParts.cjs"),Z=require("../BaseCheckbox/assets/checkmark.svg.cjs"),ee=require("../helpers/strings.cjs"),te=require("../hooks/useComposeRefs.cjs"),w=require("../hooks/useId.cjs"),re=require("../hooks/useIntersection.cjs"),ne=require("../Tag/Tag.cjs"),oe=require("../Field/Field.cjs"),ie=require("../Flex/Flex.cjs"),le=require("../Field/FieldLabel.cjs"),x=require("../Box/Box.cjs"),se=require("../Field/FieldHint.cjs"),ce=require("../Field/FieldError.cjs"),O=require("../Typography/Typography.cjs"),ae=e=>e&&e.__esModule?e:{default:e};function de(e){if(e&&e.__esModule)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const c=de(Q),ue=ae(b),he=c.forwardRef(({"aria-label":e,children:o,clearLabel:r="Clear",customizeContent:l,disabled:s,error:a,hint:u,id:g,label:j,labelAction:M,onChange:p,onClear:F,onReachEnd:y,placeholder:_,required:m,selectButtonTitle:xe,startIcon:B,size:L="M",value:h,withTags:q,...P},V)=>{const R=c.useRef(null),[$,C]=c.useState(),[z,E]=c.useState(!1),f=w.useId(g),G=`${f}-hint`,A=`${f}-error`,D=n=>{p?p(n):C(n)},H=n=>()=>{const v=Array.isArray(h)?h.filter(I=>I!==n):($??[]).filter(I=>I!==n);p?p(v):C(v)},W=n=>{E(n)},S=c.useRef(null),N=()=>{S.current.focus()},X=w.useId(),k=`intersection-${ee.stripReactIdOfColon(X)}`,Y=n=>{y&&y(n)};re.useIntersection(R,Y,{selectorToWatch:`#${k}`,skipWhen:!z});const d=typeof h<"u"&&h!==null?h:$,J=n=>n&&typeof n=="object"&&n.value?t.jsx(ne.Tag,{tabIndex:-1,disabled:s,icon:t.jsx(U.Cross,{}),onClick:H(n.value),children:n.textValue},n.value):null,K=te.useComposedRefs(S,V);return t.jsx(oe.Field,{hint:u,error:a,id:f,required:m,children:t.jsxs(ie.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[j?t.jsx(le.FieldLabel,{onClick:N,action:M,children:j}):null,t.jsxs(i.Root,{onOpenChange:W,disabled:s,required:m,onValueChange:D,value:d,...P,multi:!0,children:[t.jsx(i.Trigger,{ref:K,"aria-label":j??e,"aria-describedby":`${G} ${A}`,id:f,startIcon:B,size:L,hasError:!!a,disabled:s,clearLabel:r,onClear:d?.length?F:void 0,paddingLeft:q&&d?.length?1:3,children:t.jsx(i.Value,{placeholder:_,textColor:d?.length?"neutral800":"neutral600",children:d?.length?q?J:l?l(d):void 0:void 0})}),t.jsx(i.Portal,{children:t.jsx(i.Content,{position:"popper",sideOffset:4,children:t.jsxs(i.Viewport,{ref:R,children:[o,t.jsx(x.Box,{id:k,width:"100%",height:"1px"})]})})})]}),t.jsx(se.FieldHint,{}),t.jsx(ce.FieldError,{})]})})}),pe=c.forwardRef(({value:e,children:o,startIcon:r,...l},s)=>t.jsxs(i.Item,{ref:s,value:e.toString(),...l,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(i.ItemIndicator,{children:({isSelected:a,isIntermediate:u})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:u,$selected:a,zIndex:1,height:"18px",width:"18px"})}),t.jsx(O.Typography,{textColor:"neutral800",children:t.jsx(i.ItemText,{children:o})})]})),T=ue.default(x.Box)`
|
|
2
2
|
border: 1px solid
|
|
3
|
-
${({theme:e,$selected:
|
|
4
|
-
background-color: ${({theme:e,$selected:
|
|
3
|
+
${({theme:e,$selected:o,$indeterminate:r})=>o||r?e.colors.primary600:e.colors.neutral300};
|
|
4
|
+
background-color: ${({theme:e,$selected:o,$indeterminate:r})=>o||r?e.colors.primary600:e.colors.neutral0};
|
|
5
5
|
|
|
6
|
-
${({theme:e,$indeterminate:
|
|
6
|
+
${({theme:e,$indeterminate:o})=>o&&b.css`
|
|
7
7
|
&::after {
|
|
8
8
|
content: '';
|
|
9
9
|
display: block;
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
${({$selected:e})=>e&&b.css`
|
|
22
22
|
&::after {
|
|
23
23
|
content: '';
|
|
24
|
-
background: url(${
|
|
24
|
+
background: url(${Z}) no-repeat no-repeat center center;
|
|
25
25
|
width: 100%;
|
|
26
26
|
height: 100%;
|
|
27
27
|
position: absolute;
|
|
28
28
|
}
|
|
29
29
|
`}
|
|
30
|
-
`,
|
|
30
|
+
`,fe=c.forwardRef(({children:e,label:o,startIcon:r,values:l=[],...s},a)=>t.jsxs(i.Group,{ref:a,children:[t.jsxs(i.Item,{value:l,...s,children:[r&&t.jsx(x.Box,{as:"span","aria-hidden":!0,children:r}),t.jsx(i.ItemIndicator,{children:({isSelected:u,isIntermediate:g})=>t.jsx(T,{hasRadius:!0,overflow:"hidden",position:"relative",$indeterminate:g,$selected:u,zIndex:1,height:"18px",width:"18px"})}),t.jsx(O.Typography,{textColor:"neutral800",children:o})]}),e]}));exports.MultiSelect=he;exports.MultiSelectGroup=fe;exports.MultiSelectOption=pe;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import { Cross as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { Cross as U } from "@strapi/icons";
|
|
4
|
+
import Z, { css as O } from "styled-components";
|
|
5
|
+
import { Root as ee, Trigger as re, Value as te, Portal as ne, Content as oe, Viewport as ie, Item as F, ItemIndicator as M, ItemText as le, Group as de } from "./SelectParts.js";
|
|
6
|
+
import ce from "../BaseCheckbox/assets/checkmark.svg.js";
|
|
7
7
|
import { stripReactIdOfColon as ae } from "../helpers/strings.js";
|
|
8
|
+
import { useComposedRefs as se } from "../hooks/useComposeRefs.js";
|
|
8
9
|
import { useId as S } from "../hooks/useId.js";
|
|
9
|
-
import { useIntersection as
|
|
10
|
-
import { Tag as
|
|
10
|
+
import { useIntersection as he } from "../hooks/useIntersection.js";
|
|
11
|
+
import { Tag as pe } from "../Tag/Tag.js";
|
|
12
|
+
import { Field as ue } from "../Field/Field.js";
|
|
13
|
+
import { Flex as fe } from "../Flex/Flex.js";
|
|
14
|
+
import { FieldLabel as me } from "../Field/FieldLabel.js";
|
|
11
15
|
import { Box as m } from "../Box/Box.js";
|
|
16
|
+
import { FieldHint as ge } from "../Field/FieldHint.js";
|
|
17
|
+
import { FieldError as xe } from "../Field/FieldError.js";
|
|
12
18
|
import { Typography as B } from "../Typography/Typography.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
q(r);
|
|
26
|
-
}, R = d.useRef(null), D = () => {
|
|
27
|
-
R.current.focus();
|
|
28
|
-
}, J = S(), y = `intersection-${ae(J)}`;
|
|
29
|
-
ce(C, (r) => {
|
|
19
|
+
const ze = l.forwardRef(({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeContent: d, disabled: i, error: c, hint: h, id: g, label: x, labelAction: V, onChange: u, onClear: j, onReachEnd: $, placeholder: E, required: R, selectButtonTitle: Ie, startIcon: z, size: A = "M", value: p, withTags: b, ...G }, W) => {
|
|
20
|
+
const C = l.useRef(null), [k, w] = l.useState(), [q, H] = l.useState(!1), f = S(g), P = `${f}-hint`, X = `${f}-error`, Y = (r) => {
|
|
21
|
+
u ? u(r) : w(r);
|
|
22
|
+
}, _ = (r) => () => {
|
|
23
|
+
const T = Array.isArray(p) ? p.filter((I) => I !== r) : (k ?? []).filter((I) => I !== r);
|
|
24
|
+
u ? u(T) : w(T);
|
|
25
|
+
}, D = (r) => {
|
|
26
|
+
H(r);
|
|
27
|
+
}, v = l.useRef(null), J = () => {
|
|
28
|
+
v.current.focus();
|
|
29
|
+
}, K = S(), y = `intersection-${ae(K)}`;
|
|
30
|
+
he(C, (r) => {
|
|
30
31
|
$ && $(r);
|
|
31
32
|
}, {
|
|
32
33
|
selectorToWatch: `#${y}`,
|
|
@@ -34,11 +35,11 @@ const Le = ({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeCo
|
|
|
34
35
|
* We need to know when the select is open because only then will viewportRef
|
|
35
36
|
* not be null. Because it uses a portal that (sensibly) is not mounted 24/7.
|
|
36
37
|
*/
|
|
37
|
-
skipWhen: !
|
|
38
|
+
skipWhen: !q
|
|
38
39
|
});
|
|
39
|
-
const
|
|
40
|
-
return e(
|
|
41
|
-
},
|
|
40
|
+
const a = typeof p < "u" && p !== null ? p : k, N = (r) => r && typeof r == "object" && r.value ? e(pe, { tabIndex: -1, disabled: i, icon: e(U, {}), onClick: _(r.value), children: r.textValue }, r.value) : null, Q = se(v, W);
|
|
41
|
+
return e(ue, { hint: h, error: c, id: f, required: R, children: s(fe, { direction: "column", alignItems: "stretch", gap: 1, children: [x ? e(me, { onClick: J, action: V, children: x }) : null, s(ee, { onOpenChange: D, disabled: i, required: R, onValueChange: Y, value: a, ...G, multi: !0, children: [e(re, { ref: Q, "aria-label": x ?? t, "aria-describedby": `${P} ${X}`, id: f, startIcon: z, size: A, hasError: !!c, disabled: i, clearLabel: o, onClear: a?.length ? j : void 0, paddingLeft: b && a?.length ? 1 : 3, children: e(te, { placeholder: E, textColor: a?.length ? "neutral800" : "neutral600", children: a?.length ? b ? N : d ? d(a) : void 0 : void 0 }) }), e(ne, { children: e(oe, { position: "popper", sideOffset: 4, children: s(ie, { ref: C, children: [n, e(m, { id: y, width: "100%", height: "1px" })] }) }) })] }), e(ge, {}), e(xe, {})] }) });
|
|
42
|
+
}), Ae = l.forwardRef(({ value: t, children: n, startIcon: o, ...d }, i) => s(F, { ref: i, value: t.toString(), ...d, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: c, isIntermediate: h }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: h, $selected: c, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: e(le, { children: n }) })] })), L = Z(m)`
|
|
42
43
|
border: 1px solid
|
|
43
44
|
${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral300};
|
|
44
45
|
background-color: ${({ theme: t, $selected: n, $indeterminate: o }) => n || o ? t.colors.primary600 : t.colors.neutral0};
|
|
@@ -61,15 +62,15 @@ const Le = ({ "aria-label": t, children: n, clearLabel: o = "Clear", customizeCo
|
|
|
61
62
|
${({ $selected: t }) => t && O`
|
|
62
63
|
&::after {
|
|
63
64
|
content: '';
|
|
64
|
-
background: url(${
|
|
65
|
+
background: url(${ce}) no-repeat no-repeat center center;
|
|
65
66
|
width: 100%;
|
|
66
67
|
height: 100%;
|
|
67
68
|
position: absolute;
|
|
68
69
|
}
|
|
69
70
|
`}
|
|
70
|
-
`,
|
|
71
|
+
`, Ge = l.forwardRef(({ children: t, label: n, startIcon: o, values: d = [], ...i }, c) => s(de, { ref: c, children: [s(F, { value: d, ...i, children: [o && e(m, { as: "span", "aria-hidden": !0, children: o }), e(M, { children: ({ isSelected: h, isIntermediate: g }) => e(L, { hasRadius: !0, overflow: "hidden", position: "relative", $indeterminate: g, $selected: h, zIndex: 1, height: "18px", width: "18px" }) }), e(B, { textColor: "neutral800", children: n })] }), t] }));
|
|
71
72
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
ze as MultiSelect,
|
|
74
|
+
Ge as MultiSelectGroup,
|
|
75
|
+
Ae as MultiSelectOption
|
|
75
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),E=require("react"),s=require("./SelectParts.cjs"),V=require("../helpers/strings.cjs"),H=require("../hooks/useComposeRefs.cjs"),q=require("../hooks/useId.cjs"),W=require("../hooks/useIntersection.cjs"),z=require("../Field/Field.cjs"),D=require("../Flex/Flex.cjs"),A=require("../Field/FieldLabel.cjs"),G=require("../Field/FieldHint.cjs"),J=require("../Field/FieldError.cjs"),O=require("../Box/Box.cjs"),K=require("../Typography/Typography.cjs");function Q(t){if(t&&t.__esModule)return t;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const l=Q(E),U=l.forwardRef(({error:t,hint:r,id:n,label:i,labelAction:c,required:u,selectButtonTitle:S,...g},a)=>{const d=q.useId(n),f=l.useRef(null),x=()=>{f.current.focus()},j=H.useComposedRefs(a,f);return e.jsx(z.Field,{hint:r,error:t,id:d,required:u,children:e.jsxs(D.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[i?e.jsx(A.FieldLabel,{onClick:x,action:c,children:i}):null,e.jsx(R,{label:i,id:d,ref:j,required:u,...g}),e.jsx(G.FieldHint,{}),e.jsx(J.FieldError,{})]})})}),R=l.forwardRef(({"aria-label":t,id:r,children:n,clearLabel:i="Clear",customizeContent:c,disabled:u,error:S,label:g,onChange:a,onClear:d,onReachEnd:f,placeholder:x,required:j,selectButtonTitle:Y,startIcon:y,size:T="M",value:p,...F},B)=>{const[C,I]=l.useState(),[w,_]=l.useState(!1),$=o=>{_(o)},v=o=>{d&&d(o),a||I("")},P=`${r}-hint`,k=`${r}-error`,L=o=>{a?a(typeof p=="number"?Number(o):o):I(o)},b=l.useRef(null),M=q.useId(),m=`intersection-${V.stripReactIdOfColon(M)}`,N=o=>{f&&f(o)};W.useIntersection(b,N,{selectorToWatch:`#${m}`,skipWhen:!w});const h=(typeof p<"u"&&p!==null?p.toString():C)??"";return e.jsxs(s.Root,{onOpenChange:$,disabled:u,required:j,onValueChange:L,value:h,...F,children:[e.jsx(s.Trigger,{ref:B,"aria-label":g??t,"aria-describedby":r?`${P} ${k}`:void 0,id:r,startIcon:y,size:T,hasError:!!S,disabled:u,clearLabel:i,onClear:h&&d?v:void 0,children:e.jsx(s.Value,{placeholder:x,textColor:h?"neutral800":"neutral600",children:h&&c?c(h):void 0})}),e.jsx(s.Portal,{children:e.jsx(s.Content,{position:"popper",sideOffset:4,children:e.jsxs(s.Viewport,{ref:b,children:[n,e.jsx(O.Box,{id:m,width:"100%",height:"1px"})]})})})]})}),X=l.forwardRef(({value:t,startIcon:r,children:n,...i},c)=>e.jsxs(s.Item,{ref:c,value:t.toString(),...i,children:[r&&e.jsx(O.Box,{as:"span","aria-hidden":!0,children:r}),e.jsx(K.Typography,{textColor:"neutral800",children:e.jsx(s.ItemText,{children:n})})]}));exports.SingleSelect=U;exports.SingleSelectInput=R;exports.SingleSelectOption=X;
|