@tedi-design-system/react 19.2.0-rc.5 → 19.2.0-rc.7
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/bundle-stats.html +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/package.json +1 -1
- package/src/tedi/components/content/carousel/components/carousel-indicators/carousel-indicators.cjs.js +1 -1
- package/src/tedi/components/content/carousel/components/carousel-indicators/carousel-indicators.es.js +18 -18
- package/src/tedi/components/content/carousel/use-carousel.cjs.js +1 -1
- package/src/tedi/components/content/carousel/use-carousel.d.ts +2 -1
- package/src/tedi/components/content/carousel/use-carousel.es.js +177 -163
- package/src/tedi/components/content/label/label.cjs.js +1 -1
- package/src/tedi/components/content/label/label.d.ts +22 -0
- package/src/tedi/components/content/label/label.es.js +30 -28
- package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.es.js +32 -30
- package/src/tedi/components/form/choice-group/choice-group.cjs.js +1 -1
- package/src/tedi/components/form/choice-group/choice-group.es.js +80 -69
- package/src/tedi/components/form/choice-input.types.d.ts +7 -0
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +5 -0
- package/src/tedi/components/form/date-field/date-field.es.js +187 -184
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
- package/src/tedi/components/form/date-time-field/date-time-field.d.ts +5 -0
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +103 -101
- package/src/tedi/components/form/form-label/form-label.cjs.js +1 -1
- package/src/tedi/components/form/form-label/form-label.d.ts +9 -0
- package/src/tedi/components/form/form-label/form-label.es.js +15 -14
- package/src/tedi/components/form/multi-value-field/multi-value-field.cjs.js +1 -1
- package/src/tedi/components/form/multi-value-field/multi-value-field.d.ts +7 -0
- package/src/tedi/components/form/multi-value-field/multi-value-field.es.js +41 -40
- package/src/tedi/components/form/number-field/number-field.cjs.js +1 -1
- package/src/tedi/components/form/number-field/number-field.es.js +54 -43
- package/src/tedi/components/form/radio/radio.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.es.js +30 -28
- package/src/tedi/components/form/select/select.cjs.js +1 -1
- package/src/tedi/components/form/select/select.es.js +79 -77
- package/src/tedi/components/form/slider/slider.cjs.js +1 -1
- package/src/tedi/components/form/slider/slider.d.ts +7 -0
- package/src/tedi/components/form/slider/slider.es.js +48 -47
- package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
- package/src/tedi/components/form/textfield/textfield.es.js +72 -61
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +5 -0
- package/src/tedi/components/form/time-field/time-field.es.js +87 -85
- package/src/tedi/components/form/toggle/toggle.cjs.js +1 -1
- package/src/tedi/components/form/toggle/toggle.d.ts +7 -0
- package/src/tedi/components/form/toggle/toggle.es.js +26 -24
|
@@ -1,73 +1,74 @@
|
|
|
1
1
|
import { jsx as n, jsxs as S } from "react/jsx-runtime";
|
|
2
2
|
import _ from "../../../../../external/classnames/index.es.js";
|
|
3
|
-
import y, { forwardRef as
|
|
3
|
+
import y, { forwardRef as Ie, useMemo as b, useCallback as w } from "react";
|
|
4
4
|
import { Icon as D } from "../../base/icon/icon.es.js";
|
|
5
|
-
import { ClosingButton as
|
|
6
|
-
import { Separator as
|
|
5
|
+
import { ClosingButton as ge } from "../../buttons/closing-button/closing-button.es.js";
|
|
6
|
+
import { Separator as Ne } from "../../misc/separator/separator.es.js";
|
|
7
7
|
import { FeedbackText as U } from "../feedback-text/feedback-text.es.js";
|
|
8
|
-
import { Field as
|
|
9
|
-
import { FormLabel as
|
|
10
|
-
import { useOptionalInputGroup as
|
|
8
|
+
import { Field as Ae } from "../field/field.es.js";
|
|
9
|
+
import { FormLabel as Ce } from "../form-label/form-label.es.js";
|
|
10
|
+
import { useOptionalInputGroup as ke } from "../input-group/input-group.es.js";
|
|
11
11
|
import r from "./textfield.module.scss.es.js";
|
|
12
|
-
import { useBreakpointProps as
|
|
13
|
-
import { useLabels as
|
|
14
|
-
const
|
|
12
|
+
import { useBreakpointProps as Se } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
13
|
+
import { useLabels as we } from "../../../providers/label-provider/use-labels.es.js";
|
|
14
|
+
const Be = {
|
|
15
15
|
large: 24,
|
|
16
16
|
default: 18
|
|
17
|
-
},
|
|
17
|
+
}, ze = Ie((I, J) => {
|
|
18
18
|
var M;
|
|
19
|
-
const { getCurrentBreakpointProps: Q } =
|
|
20
|
-
id:
|
|
19
|
+
const { getCurrentBreakpointProps: Q } = Se(I.defaultServerBreakpoint), {
|
|
20
|
+
id: Fe,
|
|
21
21
|
label: g,
|
|
22
22
|
className: W,
|
|
23
23
|
inputClassName: X,
|
|
24
24
|
disabled: d,
|
|
25
25
|
required: B,
|
|
26
26
|
hideLabel: z,
|
|
27
|
+
labelProps: Y,
|
|
27
28
|
invalid: f,
|
|
28
29
|
readOnly: F,
|
|
29
30
|
icon: i,
|
|
30
31
|
onIconClick: x,
|
|
31
32
|
iconButtonProps: p,
|
|
32
33
|
size: s = "default",
|
|
33
|
-
placeholder:
|
|
34
|
-
isArrowsHidden:
|
|
34
|
+
placeholder: Z,
|
|
35
|
+
isArrowsHidden: G = !0,
|
|
35
36
|
isClearable: R,
|
|
36
|
-
showClearOnInteraction:
|
|
37
|
+
showClearOnInteraction: ee,
|
|
37
38
|
onClear: v,
|
|
38
39
|
onChange: o,
|
|
39
|
-
onChangeEvent:
|
|
40
|
-
onKeyUp:
|
|
41
|
-
onKeyDown:
|
|
42
|
-
onKeyPress:
|
|
40
|
+
onChangeEvent: re,
|
|
41
|
+
onKeyUp: te,
|
|
42
|
+
onKeyDown: ae,
|
|
43
|
+
onKeyPress: ie,
|
|
43
44
|
defaultValue: $,
|
|
44
45
|
value: N,
|
|
45
46
|
onFocus: A,
|
|
46
47
|
onBlur: C,
|
|
47
|
-
onClick:
|
|
48
|
+
onClick: le,
|
|
48
49
|
helper: e,
|
|
49
50
|
input: a,
|
|
50
|
-
name:
|
|
51
|
-
isTextArea:
|
|
52
|
-
startSlot:
|
|
53
|
-
endSlot:
|
|
54
|
-
...
|
|
55
|
-
} = Q(I) || {}, { getLabel: L } =
|
|
51
|
+
name: ne,
|
|
52
|
+
isTextArea: se,
|
|
53
|
+
startSlot: oe,
|
|
54
|
+
endSlot: de,
|
|
55
|
+
...ce
|
|
56
|
+
} = Q(I) || {}, { getLabel: L } = we(), O = y.useRef(null), P = y.useRef(null), [fe, T] = y.useState(N ?? $ ?? ""), E = N ?? fe, c = !!(R && E && !F), m = (M = ke) == null ? void 0 : M(), me = y.useId(), ue = m == null ? void 0 : m.hasExternalLabel, u = I.id ?? (m == null ? void 0 : m.inputId) ?? me;
|
|
56
57
|
y.useImperativeHandle(J, () => ({
|
|
57
58
|
get input() {
|
|
58
|
-
return
|
|
59
|
+
return P.current;
|
|
59
60
|
},
|
|
60
61
|
get inner() {
|
|
61
62
|
return O.current;
|
|
62
63
|
}
|
|
63
64
|
}));
|
|
64
|
-
const V = b(() => Array.isArray(e) ? f || e.some((t) => t.type === "error") : f || (e == null ? void 0 : e.type) === "error", [f, e]),
|
|
65
|
+
const V = b(() => Array.isArray(e) ? f || e.some((t) => t.type === "error") : f || (e == null ? void 0 : e.type) === "error", [f, e]), pe = b(() => !e || Array.isArray(e) && e.length === 0 ? !1 : Array.isArray(e) ? !f && e.every((t) => t.type === "valid") : !f && e.type === "valid", [f, e]), ye = s === "large" ? "default" : s, h = N !== void 0, xe = w(
|
|
65
66
|
(t) => {
|
|
66
|
-
h ||
|
|
67
|
+
h || T(t), o == null || o(t);
|
|
67
68
|
},
|
|
68
69
|
[h, o]
|
|
69
70
|
), j = w(() => {
|
|
70
|
-
h ||
|
|
71
|
+
h || T(""), o == null || o(""), v == null || v();
|
|
71
72
|
}, [h, o, v]), H = w(() => {
|
|
72
73
|
if (!i) return null;
|
|
73
74
|
const k = {
|
|
@@ -86,35 +87,35 @@ const we = {
|
|
|
86
87
|
}
|
|
87
88
|
) : /* @__PURE__ */ n("div", { className: r["tedi-textfield__icon-wrapper"], "aria-hidden": "true", children: /* @__PURE__ */ n(D, { ...q }) });
|
|
88
89
|
}, [i, s, x, p, d]), K = b(() => c ? /* @__PURE__ */ n(
|
|
89
|
-
|
|
90
|
+
ge,
|
|
90
91
|
{
|
|
91
|
-
iconSize:
|
|
92
|
+
iconSize: Be[s === "large" ? "large" : "default"],
|
|
92
93
|
onClick: d ? void 0 : j,
|
|
93
94
|
disabled: d,
|
|
94
95
|
title: L("clear"),
|
|
95
96
|
className: r["tedi-textfield__clear-button"]
|
|
96
97
|
}
|
|
97
|
-
) : null, [c, s, d, j, L]),
|
|
98
|
+
) : null, [c, s, d, j, L]), ve = b(() => !c && !i ? null : /* @__PURE__ */ S("div", { className: r["tedi-textfield__right-area"], children: [
|
|
98
99
|
K,
|
|
99
|
-
c && i && /* @__PURE__ */ n(
|
|
100
|
+
c && i && /* @__PURE__ */ n(Ne, { color: "primary", axis: "vertical", className: r["tedi-textfield__separator"] }),
|
|
100
101
|
i && H()
|
|
101
|
-
] }), [c, i, K, H]),
|
|
102
|
-
|
|
102
|
+
] }), [c, i, K, H]), he = /* @__PURE__ */ n(
|
|
103
|
+
Ae,
|
|
103
104
|
{
|
|
104
105
|
...a,
|
|
105
106
|
id: u,
|
|
106
|
-
name:
|
|
107
|
-
value:
|
|
107
|
+
name: ne,
|
|
108
|
+
value: E,
|
|
108
109
|
defaultValue: $,
|
|
109
|
-
onChange:
|
|
110
|
-
onChangeEvent:
|
|
110
|
+
onChange: xe,
|
|
111
|
+
onChangeEvent: re,
|
|
111
112
|
disabled: d,
|
|
112
113
|
readOnly: F || (a == null ? void 0 : a.readOnly),
|
|
113
114
|
required: B,
|
|
114
115
|
invalid: V,
|
|
115
|
-
placeholder:
|
|
116
|
+
placeholder: Z,
|
|
116
117
|
className: _(r["tedi-textfield__input"], X, {
|
|
117
|
-
[r["tedi-textfield__input--hidden-arrows"]]:
|
|
118
|
+
[r["tedi-textfield__input--hidden-arrows"]]: G
|
|
118
119
|
}),
|
|
119
120
|
onFocus: (t) => {
|
|
120
121
|
var l;
|
|
@@ -124,45 +125,55 @@ const we = {
|
|
|
124
125
|
var l;
|
|
125
126
|
(l = a == null ? void 0 : a.onBlur) == null || l.call(a, t), C == null || C(t);
|
|
126
127
|
},
|
|
127
|
-
isTextArea:
|
|
128
|
+
isTextArea: se,
|
|
128
129
|
"aria-describedby": !e || Array.isArray(e) && e.length === 0 ? void 0 : Array.isArray(e) ? e.map((t, l) => `${u}-helper-${l}`).join(" ") : `${u}-helper`,
|
|
129
130
|
"aria-label": z && typeof g == "string" ? g : void 0,
|
|
130
|
-
ref:
|
|
131
|
+
ref: P
|
|
131
132
|
}
|
|
132
|
-
),
|
|
133
|
+
), _e = _(
|
|
133
134
|
r["tedi-textfield"],
|
|
134
135
|
{ [r[`tedi-textfield--${s}`]]: s },
|
|
135
136
|
{ [r["tedi-textfield--with-icon"]]: i },
|
|
136
137
|
{ [r["tedi-textfield--invalid"]]: V },
|
|
137
|
-
{ [r["tedi-textfield--valid"]]:
|
|
138
|
+
{ [r["tedi-textfield--valid"]]: pe },
|
|
138
139
|
{ [r["tedi-textfield--clearable"]]: c },
|
|
139
|
-
{ [r["tedi-textfield--clear-on-interaction"]]: c &&
|
|
140
|
+
{ [r["tedi-textfield--clear-on-interaction"]]: c && ee },
|
|
140
141
|
W
|
|
141
|
-
),
|
|
142
|
-
return /* @__PURE__ */ S("div", { "data-name": "textfield", ...
|
|
143
|
-
!
|
|
142
|
+
), be = () => !e || Array.isArray(e) && e.length === 0 ? null : /* @__PURE__ */ n("div", { className: r["tedi-textfield__feedback-wrapper"], children: Array.isArray(e) ? e.map((t, l) => /* @__PURE__ */ n(U, { ...t, id: `${u}-helper-${l}` }, l)) : /* @__PURE__ */ n(U, { ...e, id: `${u}-helper` }) });
|
|
143
|
+
return /* @__PURE__ */ S("div", { "data-name": "textfield", ...ce, className: _e, children: [
|
|
144
|
+
!ue && /* @__PURE__ */ n(
|
|
145
|
+
Ce,
|
|
146
|
+
{
|
|
147
|
+
id: u,
|
|
148
|
+
label: g,
|
|
149
|
+
required: B,
|
|
150
|
+
hideLabel: z,
|
|
151
|
+
size: ye,
|
|
152
|
+
labelProps: Y
|
|
153
|
+
}
|
|
154
|
+
),
|
|
144
155
|
/* @__PURE__ */ S(
|
|
145
156
|
"div",
|
|
146
157
|
{
|
|
147
158
|
className: r["tedi-textfield__inner"],
|
|
148
|
-
onKeyDown:
|
|
149
|
-
onKeyUp:
|
|
150
|
-
onKeyPress:
|
|
151
|
-
onClick:
|
|
159
|
+
onKeyDown: ae,
|
|
160
|
+
onKeyUp: te,
|
|
161
|
+
onKeyPress: ie,
|
|
162
|
+
onClick: le,
|
|
152
163
|
ref: O,
|
|
153
164
|
children: [
|
|
154
|
-
se,
|
|
155
|
-
ve,
|
|
156
165
|
oe,
|
|
157
|
-
|
|
166
|
+
he,
|
|
167
|
+
de,
|
|
168
|
+
(R || i) && ve
|
|
158
169
|
]
|
|
159
170
|
}
|
|
160
171
|
),
|
|
161
|
-
|
|
172
|
+
be()
|
|
162
173
|
] });
|
|
163
174
|
});
|
|
164
|
-
|
|
175
|
+
ze.displayName = "TextField";
|
|
165
176
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
ze as TextField,
|
|
178
|
+
ze as default
|
|
168
179
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),M=require("../../../../../external/classnames/index.cjs.js"),m=require("react"),J=require("../textfield/textfield.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),u=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),M=require("../../../../../external/classnames/index.cjs.js"),m=require("react"),J=require("../textfield/textfield.cjs.js"),Ce=require("../time-picker/time-picker.cjs.js"),c=require("./time-field.module.scss.cjs.js"),Q=require("./time-field-helpers.cjs.js"),_e=require("./time-picker-modal/time-picker-modal.cjs.js"),Te=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),je=require("../../../providers/label-provider/use-labels.cjs.js"),W=require("../../../helpers/hooks/use-breakpoint.cjs.js"),F=require("../../overlays/dropdown/dropdown.cjs.js"),qe=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),N=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),X=C=>{const{getCurrentBreakpointProps:Y}=Te.useBreakpointProps(C.defaultServerBreakpoint),{getLabel:Z}=je.useLabels(),{id:$,label:ee,labelProps:te,value:f,defaultValue:ie,onChange:_,readOnly:h=!1,disabled:s=!1,required:oe,placeholder:ne,inputProps:e,stepMinutes:R=1,className:D,availableTimes:a,modal:T=!1,modalProps:re}=C,{useNativePicker:le=!1,timePickerTrigger:j="button",showPicker:n=!0,availableTimesVariant:q="grid-buttons",clearable:se=!0}=Y(C),E=f!==void 0,[ae,S]=m.useState(f??ie??""),g=E?f:ae,[w,I]=m.useState(!1),[U,V]=m.useState(!1),p=j==="input",o=le,de=W.default(),d=!o&&n&&!h&&!s&&(T===!0||typeof T=="string"&&W.isBreakpointBelow(de,T)),ce=u.useFloating({open:w,onOpenChange:I,placement:p?"bottom-start":"bottom-end",middleware:[N.offset(Q.TIMEPICKER_OFFSET),N.flip(),N.shift()],whileElementsMounted:qe.autoUpdate}),{refs:B,context:P,x:ue,y:fe,strategy:pe}=ce,me=u.useClick(P),ge=u.useDismiss(P),xe=u.useRole(P,{role:"listbox"}),L=n&&p&&!h&&!s&&!o&&!d,z=u.useInteractions([...L?[me]:[],ge,xe]),x=t=>{const r=t.trim();E||S(r),_==null||_(r)},be=t=>{var v;const r=t.target.value??"";(v=e==null?void 0:e.onBlur)==null||v.call(e,t);const l=Q.normalizeTime(r);l!==null&&l!==r&&x(l)};m.useEffect(()=>{f!==void 0&&S(f)},[f]);const b=m.useRef(null);m.useEffect(()=>{var t;(t=b.current)!=null&&t.inner&&B.setReference(b.current.inner)},[B]);const ke=()=>{var r;const t=(r=b.current)==null?void 0:r.input;if(t){if(typeof t.showPicker=="function"){t.showPicker();return}t.focus()}},he=()=>I(t=>!t),A=()=>V(!0),Pe=()=>{!n||s||(o?ke():d?A():j==="button"&&he())},H=d&&p&&!h?()=>{A()}:void 0,y=!o&&n&&!s&&q==="dropdown"&&!!(a!=null&&a.length),K=d?"dialog":"listbox",G=d?U:w,ve=n&&!o&&!y&&(j==="button"||d),Fe=n&&p&&!o&&!y,O={...e,id:$,label:ee,labelProps:te??(e==null?void 0:e.labelProps),value:g,placeholder:ne,readOnly:h||!o&&p,disabled:s||(e==null?void 0:e.disabled),icon:n?"schedule":{name:"schedule",color:"inherit"},isClearable:se,required:oe,onIconClick:n?Pe:void 0,iconButtonProps:{"aria-label":Z("time-field.open-picker"),...ve&&{"aria-haspopup":K,"aria-expanded":G},...e==null?void 0:e.iconButtonProps},onChange:x,onBlur:be,className:M.default(c.default["tedi-time-field__textfield"],{[c.default["tedi-time-field__icon--disabled"]]:!n||s},{[c.default["tedi-time-field__textfield--disabled"]]:s||(e==null?void 0:e.disabled)},{[c.default["tedi-time-field--native"]]:o}),input:{...e==null?void 0:e.input,...o&&{type:"time"},...H&&{onClick:H},...Fe&&{role:"combobox","aria-haspopup":K,"aria-expanded":G}}};if(y){const t=a.indexOf(g),r=t>=0?t:0;return i.jsxs(F.Dropdown,{width:"trigger",defaultActiveIndex:r,children:[i.jsx(F.Dropdown.Trigger,{children:i.jsx("div",{role:"combobox",className:M.default(c.default["tedi-time-field__container"],D,{[c.default["tedi-time-field__container--native"]]:o}),children:i.jsx(J.TextField,{ref:b,...O,input:{...O.input,...!p&&{onClick:l=>l.stopPropagation()}}})})}),i.jsx(F.Dropdown.Content,{children:a.map((l,v)=>i.jsx(F.Dropdown.Item,{index:v,active:l===g,onClick:()=>x(l),children:l},l))})]})}const k={...L?z.getReferenceProps():{}};return delete k.role,delete k["aria-haspopup"],delete k["aria-expanded"],delete k["aria-controls"],i.jsxs(i.Fragment,{children:[i.jsx("div",{className:M.default(c.default["tedi-time-field__container"],D),...k,tabIndex:-1,children:i.jsx(J.TextField,{ref:b,...O})}),d&&i.jsx(_e.TimePickerModal,{open:U,onOpenChange:V,value:g,onConfirm:x,stepMinutes:R,availableTimes:a,gridVariant:q==="grid-radio"?"radio":"button",modalProps:re}),!o&&n&&!s&&!d&&i.jsx(u.FloatingPortal,{children:w&&i.jsx(u.FloatingFocusManager,{context:P,modal:!1,initialFocus:-1,children:i.jsx("div",{ref:B.setFloating,...z.getFloatingProps({style:{position:pe,top:fe??0,left:ue??0}}),children:i.jsx(Ce.TimePicker,{value:g,stepMinutes:R,availableTimes:a,onChange:t=>{x(t),a&&I(!1)},gridVariant:q==="grid-radio"?"radio":"button",className:c.default["tedi-time-field__picker-wrapper"]})})})})]})};X.displayName="TimeField";exports.TimeField=X;
|
|
@@ -47,6 +47,11 @@ export interface TimeFieldProps extends BreakpointSupport<TimeFieldBreakpointPro
|
|
|
47
47
|
* Label for the input field. Used for accessibility.
|
|
48
48
|
*/
|
|
49
49
|
label: string;
|
|
50
|
+
/**
|
|
51
|
+
* Props forwarded to the field's label (e.g. `{ modifiers: 'nowrap' }` to control
|
|
52
|
+
* how a long label wraps). Breakpoint keys are supported for responsive wrapping.
|
|
53
|
+
*/
|
|
54
|
+
labelProps?: TextFieldProps['labelProps'];
|
|
50
55
|
/**
|
|
51
56
|
* Current value of the time field (controlled).
|
|
52
57
|
*/
|
|
@@ -1,129 +1,131 @@
|
|
|
1
|
-
import { jsxs as G, jsx as
|
|
2
|
-
import { useFloating as
|
|
1
|
+
import { jsxs as G, jsx as o, Fragment as ve } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as Ce, useClick as Pe, useDismiss as _e, useRole as Fe, useInteractions as Ie, FloatingPortal as Te, FloatingFocusManager as we } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
3
|
import O from "../../../../../external/classnames/index.es.js";
|
|
4
|
-
import
|
|
4
|
+
import Be, { useState as M, useEffect as H } from "react";
|
|
5
5
|
import { TextField as J } from "../textfield/textfield.es.js";
|
|
6
|
-
import { TimePicker as
|
|
6
|
+
import { TimePicker as ye } from "../time-picker/time-picker.es.js";
|
|
7
7
|
import d from "./time-field.module.scss.es.js";
|
|
8
|
-
import { normalizeTime as
|
|
9
|
-
import { TimePickerModal as
|
|
10
|
-
import { useBreakpointProps as
|
|
11
|
-
import { useLabels as
|
|
12
|
-
import
|
|
8
|
+
import { normalizeTime as Ne, TIMEPICKER_OFFSET as Oe } from "./time-field-helpers.es.js";
|
|
9
|
+
import { TimePickerModal as Me } from "./time-picker-modal/time-picker-modal.es.js";
|
|
10
|
+
import { useBreakpointProps as Re } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
11
|
+
import { useLabels as Ve } from "../../../providers/label-provider/use-labels.es.js";
|
|
12
|
+
import Ee, { isBreakpointBelow as Ue } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
13
13
|
import { Dropdown as v } from "../../overlays/dropdown/dropdown.es.js";
|
|
14
|
-
import { autoUpdate as
|
|
15
|
-
import { offset as
|
|
16
|
-
const
|
|
17
|
-
const { getCurrentBreakpointProps: Q } =
|
|
14
|
+
import { autoUpdate as De } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
15
|
+
import { offset as Se, flip as je, shift as Le } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
16
|
+
const qe = (C) => {
|
|
17
|
+
const { getCurrentBreakpointProps: Q } = Re(C.defaultServerBreakpoint), { getLabel: W } = Ve(), {
|
|
18
18
|
id: X,
|
|
19
19
|
label: Y,
|
|
20
|
+
labelProps: Z,
|
|
20
21
|
value: m,
|
|
21
|
-
defaultValue:
|
|
22
|
-
onChange:
|
|
23
|
-
readOnly:
|
|
22
|
+
defaultValue: $,
|
|
23
|
+
onChange: P,
|
|
24
|
+
readOnly: h = !1,
|
|
24
25
|
disabled: l = !1,
|
|
25
|
-
required:
|
|
26
|
-
placeholder:
|
|
27
|
-
inputProps:
|
|
26
|
+
required: ee,
|
|
27
|
+
placeholder: te,
|
|
28
|
+
inputProps: e,
|
|
28
29
|
stepMinutes: R = 1,
|
|
29
30
|
className: V,
|
|
30
31
|
availableTimes: s,
|
|
31
|
-
modal:
|
|
32
|
-
modalProps:
|
|
32
|
+
modal: _ = !1,
|
|
33
|
+
modalProps: oe
|
|
33
34
|
} = C, {
|
|
34
35
|
useNativePicker: ie = !1,
|
|
35
|
-
timePickerTrigger:
|
|
36
|
+
timePickerTrigger: F = "button",
|
|
36
37
|
showPicker: n = !0,
|
|
37
38
|
availableTimesVariant: I = "grid-buttons",
|
|
38
|
-
clearable:
|
|
39
|
-
} = Q(C), E = m !== void 0, [
|
|
39
|
+
clearable: ne = !0
|
|
40
|
+
} = Q(C), E = m !== void 0, [re, U] = M(m ?? $ ?? ""), u = E ? m : re, [T, w] = M(!1), [D, S] = M(!1), f = F === "input", i = ie, ae = Ee(), c = !i && n && !h && !l && (_ === !0 || typeof _ == "string" && Ue(ae, _)), le = Ce({
|
|
40
41
|
open: T,
|
|
41
42
|
onOpenChange: w,
|
|
42
|
-
placement:
|
|
43
|
-
middleware: [
|
|
44
|
-
whileElementsMounted:
|
|
45
|
-
}), { refs: B, context:
|
|
46
|
-
const r =
|
|
47
|
-
E || U(r),
|
|
48
|
-
},
|
|
43
|
+
placement: f ? "bottom-start" : "bottom-end",
|
|
44
|
+
middleware: [Se(Oe), je(), Le()],
|
|
45
|
+
whileElementsMounted: De
|
|
46
|
+
}), { refs: B, context: k, x: se, y: ce, strategy: de } = le, me = Pe(k), fe = _e(k), ue = Fe(k, { role: "listbox" }), j = n && f && !h && !l && !i && !c, L = Ie([...j ? [me] : [], fe, ue]), p = (t) => {
|
|
47
|
+
const r = t.trim();
|
|
48
|
+
E || U(r), P == null || P(r);
|
|
49
|
+
}, pe = (t) => {
|
|
49
50
|
var x;
|
|
50
|
-
const r =
|
|
51
|
-
(x =
|
|
52
|
-
const a =
|
|
51
|
+
const r = t.target.value ?? "";
|
|
52
|
+
(x = e == null ? void 0 : e.onBlur) == null || x.call(e, t);
|
|
53
|
+
const a = Ne(r);
|
|
53
54
|
a !== null && a !== r && p(a);
|
|
54
55
|
};
|
|
55
56
|
H(() => {
|
|
56
57
|
m !== void 0 && U(m);
|
|
57
58
|
}, [m]);
|
|
58
|
-
const g =
|
|
59
|
+
const g = Be.useRef(null);
|
|
59
60
|
H(() => {
|
|
60
|
-
var
|
|
61
|
-
(
|
|
61
|
+
var t;
|
|
62
|
+
(t = g.current) != null && t.inner && B.setReference(g.current.inner);
|
|
62
63
|
}, [B]);
|
|
63
|
-
const
|
|
64
|
+
const ge = () => {
|
|
64
65
|
var r;
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
if (typeof
|
|
68
|
-
|
|
66
|
+
const t = (r = g.current) == null ? void 0 : r.input;
|
|
67
|
+
if (t) {
|
|
68
|
+
if (typeof t.showPicker == "function") {
|
|
69
|
+
t.showPicker();
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
t.focus();
|
|
72
73
|
}
|
|
73
|
-
},
|
|
74
|
-
!n || l || (
|
|
75
|
-
}, z = c &&
|
|
74
|
+
}, be = () => w((t) => !t), q = () => S(!0), he = () => {
|
|
75
|
+
!n || l || (i ? ge() : c ? q() : F === "button" && be());
|
|
76
|
+
}, z = c && f && !h ? () => {
|
|
76
77
|
q();
|
|
77
|
-
} : void 0, y = !
|
|
78
|
-
...
|
|
78
|
+
} : void 0, y = !i && n && !l && I === "dropdown" && !!(s != null && s.length), A = c ? "dialog" : "listbox", K = c ? D : T, ke = n && !i && !y && (F === "button" || c), xe = n && f && !i && !y, N = {
|
|
79
|
+
...e,
|
|
79
80
|
id: X,
|
|
80
81
|
label: Y,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
labelProps: Z ?? (e == null ? void 0 : e.labelProps),
|
|
83
|
+
value: u,
|
|
84
|
+
placeholder: te,
|
|
85
|
+
readOnly: h || !i && f,
|
|
86
|
+
disabled: l || (e == null ? void 0 : e.disabled),
|
|
85
87
|
icon: n ? "schedule" : { name: "schedule", color: "inherit" },
|
|
86
|
-
isClearable:
|
|
87
|
-
required:
|
|
88
|
+
isClearable: ne,
|
|
89
|
+
required: ee,
|
|
88
90
|
onIconClick: n ? he : void 0,
|
|
89
91
|
iconButtonProps: {
|
|
90
92
|
"aria-label": W("time-field.open-picker"),
|
|
91
93
|
...ke && { "aria-haspopup": A, "aria-expanded": K },
|
|
92
|
-
...
|
|
94
|
+
...e == null ? void 0 : e.iconButtonProps
|
|
93
95
|
},
|
|
94
96
|
onChange: p,
|
|
95
|
-
onBlur:
|
|
97
|
+
onBlur: pe,
|
|
96
98
|
className: O(
|
|
97
99
|
d["tedi-time-field__textfield"],
|
|
98
100
|
{ [d["tedi-time-field__icon--disabled"]]: !n || l },
|
|
99
|
-
{ [d["tedi-time-field__textfield--disabled"]]: l || (
|
|
100
|
-
{ [d["tedi-time-field--native"]]:
|
|
101
|
+
{ [d["tedi-time-field__textfield--disabled"]]: l || (e == null ? void 0 : e.disabled) },
|
|
102
|
+
{ [d["tedi-time-field--native"]]: i }
|
|
101
103
|
),
|
|
102
104
|
input: {
|
|
103
|
-
...
|
|
104
|
-
...
|
|
105
|
+
...e == null ? void 0 : e.input,
|
|
106
|
+
...i && { type: "time" },
|
|
105
107
|
...z && { onClick: z },
|
|
106
|
-
...
|
|
108
|
+
...xe && { role: "combobox", "aria-haspopup": A, "aria-expanded": K }
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
if (y) {
|
|
110
|
-
const
|
|
112
|
+
const t = s.indexOf(u), r = t >= 0 ? t : 0;
|
|
111
113
|
return /* @__PURE__ */ G(v, { width: "trigger", defaultActiveIndex: r, children: [
|
|
112
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ o(v.Trigger, { children: /* @__PURE__ */ o(
|
|
113
115
|
"div",
|
|
114
116
|
{
|
|
115
117
|
role: "combobox",
|
|
116
118
|
className: O(d["tedi-time-field__container"], V, {
|
|
117
|
-
[d["tedi-time-field__container--native"]]:
|
|
119
|
+
[d["tedi-time-field__container--native"]]: i
|
|
118
120
|
}),
|
|
119
|
-
children: /* @__PURE__ */
|
|
121
|
+
children: /* @__PURE__ */ o(
|
|
120
122
|
J,
|
|
121
123
|
{
|
|
122
124
|
ref: g,
|
|
123
125
|
...N,
|
|
124
126
|
input: {
|
|
125
127
|
...N.input,
|
|
126
|
-
...!
|
|
128
|
+
...!f && {
|
|
127
129
|
onClick: (a) => a.stopPropagation()
|
|
128
130
|
}
|
|
129
131
|
}
|
|
@@ -131,46 +133,46 @@ const Le = (C) => {
|
|
|
131
133
|
)
|
|
132
134
|
}
|
|
133
135
|
) }),
|
|
134
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ o(v.Content, { children: s.map((a, x) => /* @__PURE__ */ o(v.Item, { index: x, active: a === u, onClick: () => p(a), children: a }, a)) })
|
|
135
137
|
] });
|
|
136
138
|
}
|
|
137
|
-
const
|
|
139
|
+
const b = {
|
|
138
140
|
...j ? L.getReferenceProps() : {}
|
|
139
141
|
};
|
|
140
|
-
return delete
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
c && /* @__PURE__ */
|
|
143
|
-
|
|
142
|
+
return delete b.role, delete b["aria-haspopup"], delete b["aria-expanded"], delete b["aria-controls"], /* @__PURE__ */ G(ve, { children: [
|
|
143
|
+
/* @__PURE__ */ o("div", { className: O(d["tedi-time-field__container"], V), ...b, tabIndex: -1, children: /* @__PURE__ */ o(J, { ref: g, ...N }) }),
|
|
144
|
+
c && /* @__PURE__ */ o(
|
|
145
|
+
Me,
|
|
144
146
|
{
|
|
145
147
|
open: D,
|
|
146
148
|
onOpenChange: S,
|
|
147
|
-
value:
|
|
149
|
+
value: u,
|
|
148
150
|
onConfirm: p,
|
|
149
151
|
stepMinutes: R,
|
|
150
152
|
availableTimes: s,
|
|
151
153
|
gridVariant: I === "grid-radio" ? "radio" : "button",
|
|
152
|
-
modalProps:
|
|
154
|
+
modalProps: oe
|
|
153
155
|
}
|
|
154
156
|
),
|
|
155
|
-
!
|
|
157
|
+
!i && n && !l && !c && /* @__PURE__ */ o(Te, { children: T && /* @__PURE__ */ o(we, { context: k, modal: !1, initialFocus: -1, children: /* @__PURE__ */ o(
|
|
156
158
|
"div",
|
|
157
159
|
{
|
|
158
160
|
ref: B.setFloating,
|
|
159
161
|
...L.getFloatingProps({
|
|
160
162
|
style: {
|
|
161
|
-
position:
|
|
162
|
-
top:
|
|
163
|
-
left:
|
|
163
|
+
position: de,
|
|
164
|
+
top: ce ?? 0,
|
|
165
|
+
left: se ?? 0
|
|
164
166
|
}
|
|
165
167
|
}),
|
|
166
|
-
children: /* @__PURE__ */
|
|
167
|
-
|
|
168
|
+
children: /* @__PURE__ */ o(
|
|
169
|
+
ye,
|
|
168
170
|
{
|
|
169
|
-
value:
|
|
171
|
+
value: u,
|
|
170
172
|
stepMinutes: R,
|
|
171
173
|
availableTimes: s,
|
|
172
|
-
onChange: (
|
|
173
|
-
p(
|
|
174
|
+
onChange: (t) => {
|
|
175
|
+
p(t), s && w(!1);
|
|
174
176
|
},
|
|
175
177
|
gridVariant: I === "grid-radio" ? "radio" : "button",
|
|
176
178
|
className: d["tedi-time-field__picker-wrapper"]
|
|
@@ -180,7 +182,7 @@ const Le = (C) => {
|
|
|
180
182
|
) }) })
|
|
181
183
|
] });
|
|
182
184
|
};
|
|
183
|
-
|
|
185
|
+
qe.displayName = "TimeField";
|
|
184
186
|
export {
|
|
185
|
-
|
|
187
|
+
qe as TimeField
|
|
186
188
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),r=require("../../../../../external/classnames/index.cjs.js"),m=require("react"),R=require("../../base/icon/icon.cjs.js"),w=require("../../loaders/spinner/spinner.cjs.js"),M=require("../feedback-text/feedback-text.cjs.js"),O=require("../form-label/form-label.cjs.js"),e=require("./toggle.module.scss.cjs.js"),_=m.forwardRef((k,x)=>{const{id:i,label:t,hideLabel:j=!1,labelPosition:N="left",helper:a,className:y,checked:n,defaultChecked:g,onChange:d,size:C,color:q="primary",type:v="filled",icon:u,disabled:f=!1,isLoading:s=!1,tooltip:T,labelProps:$,...z}=k,h=a?`${i}-helper`:void 0,[S,L]=m.useState(g??!1),o=typeof n<"u",c=o?n:S,p=C||(u?"large":"default"),F=b=>{s||(o||L(b.target.checked),d==null||d(b.target.checked))},I=r.default(e.default["tedi-toggle"],e.default[`tedi-toggle--${p}`],e.default[`tedi-toggle--${q}-${v}`],{[e.default["tedi-toggle--active"]]:c,[e.default["tedi-toggle--disabled"]]:f||s},y),P=r.default(e.default["tedi-toggle__control"],e.default[`tedi-toggle__control--label-${N}`]);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:P,children:[t&&l.jsx(O.FormLabel,{id:i,className:e.default["tedi-toggle__label"],hideLabel:j,label:t,tooltip:T,labelProps:$}),l.jsxs("div",{className:I,children:[l.jsx("input",{...z,ref:x,id:i,type:"checkbox",role:"switch","aria-label":typeof t=="string"?t:void 0,"aria-describedby":h,className:e.default["tedi-toggle__input"],checked:o?c:void 0,defaultChecked:o?void 0:g,disabled:f||s,onChange:F}),l.jsx("span",{className:e.default["tedi-toggle__slider"],children:s?l.jsx(w.Spinner,{size:p==="large"?16:10,className:e.default["tedi-toggle__icon"]}):u?l.jsx(R.Icon,{name:c?"lock_open":"lock",size:16,color:"inherit"}):null})]})]}),a&&l.jsx(M.FeedbackText,{id:h,...a,className:r.default(e.default["tedi-toggle__helper"],a.className)})]})});_.displayName="Toggle";exports.Toggle=_;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { FeedbackTextProps } from '../feedback-text/feedback-text';
|
|
3
|
+
import { FormLabelProps } from '../form-label/form-label';
|
|
3
4
|
export interface ToggleProps {
|
|
4
5
|
/**
|
|
5
6
|
* Unique identifier for the toggle input.
|
|
@@ -87,6 +88,12 @@ export interface ToggleProps {
|
|
|
87
88
|
* Useful for providing extra explanation without cluttering the UI.
|
|
88
89
|
*/
|
|
89
90
|
tooltip?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Additional props forwarded to the underlying `Label` component.
|
|
93
|
+
* Use `modifiers` to control how the label text wraps or breaks
|
|
94
|
+
* (e.g. `{ modifiers: 'nowrap' }`).
|
|
95
|
+
*/
|
|
96
|
+
labelProps?: FormLabelProps['labelProps'];
|
|
90
97
|
}
|
|
91
98
|
export declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
|
|
92
99
|
export default Toggle;
|