@tedi-design-system/react 18.0.0-rc.15 → 18.0.0-rc.16
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/index.css +1 -1
- package/package.json +1 -1
- package/src/tedi/components/form/time-field/time-field-helpers.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field-helpers.d.ts +1 -1
- package/src/tedi/components/form/time-field/time-field-helpers.es.js +1 -1
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.d.ts +23 -1
- package/src/tedi/components/form/time-field/time-field.es.js +126 -94
- package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.cjs.js +1 -0
- package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.d.ts +30 -0
- package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.es.js +59 -0
- package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.module.scss.es.js +10 -0
- package/src/tedi/components/form/time-picker/components/time-grid/time-grid.cjs.js +1 -1
- package/src/tedi/components/form/time-picker/components/time-grid/time-grid.d.ts +5 -1
- package/src/tedi/components/form/time-picker/components/time-grid/time-grid.es.js +47 -64
- package/src/tedi/components/form/time-picker/components/time-wheel/time-wheel.cjs.js +1 -1
- package/src/tedi/components/form/time-picker/components/time-wheel/time-wheel.es.js +1 -1
- package/src/tedi/components/form/time-picker/time-picker.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/time-picker/time-picker.module.scss.es.js +1 -2
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +21 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +21 -0
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=40,u=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=40,u=2,d=()=>Array.from({length:24},(e,t)=>t.toString().padStart(2,"0")),m=e=>{const t=Math.max(1,e??1),r=[];for(let n=0;n<60;n+=t)r.push(n.toString().padStart(2,"0"));return r},T=(e,t)=>{if(!t.length)return"00";const r=Number(e);return isNaN(r)?t[0]:t.reduce((n,s)=>{const o=Math.abs(Number(s)-r),i=Math.abs(Number(n)-r);return o<i||o===i&&Number(s)>Number(n)?s:n},t[0])},p=e=>{if(!e.includes(":"))return{hour:"00",minute:"00"};const[t,r]=e.split(":");return{hour:t.padStart(2,"0"),minute:r.padStart(2,"0")}},f=(e,t)=>{const r=Math.round(e/c);return Math.max(0,Math.min(r,t-1))},l=e=>e*c,S=(e,t,r=1)=>Math.abs(e-t)>r,g=(e,t,r="auto")=>{e.scrollTo({top:l(t),behavior:r})},h=e=>{e&&clearTimeout(e)},a=e=>e?/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e.trim()):!1,I=e=>{const t=e.trim();if(!t)return"";if(a(t))return t;const r=t.replace(/[^0-9]/g,"");if(r.length===3){const n=r.slice(0,1).padStart(2,"0"),s=r.slice(1),o=`${n}:${s}`;return a(o)?o:null}if(r.length===4){const n=r.slice(0,2),s=r.slice(2),o=`${n}:${s}`;return a(o)?o:null}if(t.includes(":")){const[n,s]=t.split(":"),o=parseInt(n,10),i=parseInt(s,10);if(!isNaN(o)&&!isNaN(i)&&o>=0&&o<=23&&i>=0&&i<=59)return`${o.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}return null};exports.ITEM_HEIGHT=c;exports.TIMEPICKER_OFFSET=u;exports.clearScrollTimeout=h;exports.findClosestMinute=T;exports.generateHours=d;exports.generateMinutes=m;exports.getScrollTopForIndex=l;exports.isValidTime=a;exports.needsScrollCorrection=S;exports.normalizeTime=I;exports.parseTime=p;exports.scrollToIndex=g;exports.snapToNearestItem=f;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const u = 40, l =
|
|
1
|
+
const u = 40, l = 2, d = () => Array.from({ length: 24 }, (n, t) => t.toString().padStart(2, "0")), m = (n) => {
|
|
2
2
|
const t = Math.max(1, n ?? 1), r = [];
|
|
3
3
|
for (let e = 0; e < 60; e += t)
|
|
4
4
|
r.push(e.toString().padStart(2, "0"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),c=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),c=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),y=require("../../../../../external/classnames/index.cjs.js"),f=require("react"),A=require("../textfield/textfield.cjs.js"),pe=require("../time-picker/time-picker.cjs.js"),d=require("./time-field.module.scss.cjs.js"),H=require("./time-field-helpers.cjs.js"),ge=require("./time-picker-modal/time-picker-modal.cjs.js"),ke=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),B=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),xe=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),K=require("../../../helpers/hooks/use-breakpoint.cjs.js"),F=require("../../overlays/dropdown/dropdown.cjs.js"),G=_=>{const{getCurrentBreakpointProps:J}=xe.useBreakpointProps(_.defaultServerBreakpoint),{id:L,label:Q,value:u,defaultValue:W,onChange:C,readOnly:h=!1,disabled:l=!1,required:X,placeholder:Y,inputProps:t,stepMinutes:M=1,className:O,availableTimes:a,modal:P=!1,modalProps:Z}=_,{useNativePicker:$=!1,timePickerTrigger:N="button",showPicker:n=!0,availableTimesVariant:w="grid-buttons"}=J(_),D=u!==void 0,[ee,R]=f.useState(u??W??""),m=D?u:ee,[T,j]=f.useState(!1),[te,U]=f.useState(!1),p=N==="input",s=$,ie=K.useBreakpoint(),g=!s&&n&&!h&&!l&&(P===!0||typeof P=="string"&&K.isBreakpointBelow(ie,P)),ne=c.useFloating({open:T,onOpenChange:j,placement:p?"bottom-start":"bottom-end",middleware:[B.offset(H.TIMEPICKER_OFFSET),B.flip(),B.shift()],whileElementsMounted:ke.autoUpdate}),{refs:q,context:v,x:oe,y:re,strategy:se}=ne,le=c.useClick(v),ae=c.useDismiss(v),de=c.useRole(v,{role:"listbox"}),S=n&&p&&!h&&!l&&!s&&!g,V=c.useInteractions([...S?[le]:[],ae,de]),k=e=>{const o=e.trim();D||R(o),C==null||C(o)},ce=e=>{var b;const o=e.target.value??"";(b=t==null?void 0:t.onBlur)==null||b.call(t,e);const r=H.normalizeTime(o);r!==null&&r!==o&&k(r)};f.useEffect(()=>{u!==void 0&&R(u)},[u]);const x=f.useRef(null);f.useEffect(()=>{var e;(e=x.current)!=null&&e.inner&&q.setReference(x.current.inner)},[q]);const ue=()=>{var o;const e=(o=x.current)==null?void 0:o.input;if(e){if(typeof e.showPicker=="function"){e.showPicker();return}e.focus()}},fe=()=>j(e=>!e),E=()=>U(!0),me=()=>{!n||l||(s?ue():g?E():N==="button"&&fe())},z=g&&p&&!h?()=>{E()}:void 0,I={...t,id:L,label:Q,value:m,placeholder:Y,readOnly:h||!s&&p,disabled:l||(t==null?void 0:t.disabled),icon:n?"schedule":{name:"schedule",color:"inherit"},isClearable:!0,required:X,onIconClick:n?me:void 0,onChange:k,onBlur:ce,className:y.default(d.default["tedi-time-field__textfield"],{[d.default["tedi-time-field__icon--disabled"]]:!n||l},{[d.default["tedi-time-field__textfield--disabled"]]:l||(t==null?void 0:t.disabled)},{[d.default["tedi-time-field--native"]]:s}),input:{...t==null?void 0:t.input,...s&&{type:"time"},...z&&{onClick:z}}};if(!s&&n&&!l&&w==="dropdown"&&!!(a!=null&&a.length)){const e=a.indexOf(m),o=e>=0?e:0;return i.jsxs(F.Dropdown,{width:"trigger",defaultActiveIndex:o,children:[i.jsx(F.Dropdown.Trigger,{children:i.jsx("div",{className:y.default(d.default["tedi-time-field__container"],O,{[d.default["tedi-time-field__container--native"]]:s}),children:i.jsx(A.TextField,{ref:x,...I,input:{...I.input,...!p&&{onClick:r=>r.stopPropagation()}}})})}),i.jsx(F.Dropdown.Content,{children:a.map((r,b)=>i.jsx(F.Dropdown.Item,{index:b,active:r===m,onClick:()=>k(r),children:r},r))})]})}return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:y.default(d.default["tedi-time-field__container"],O),...S?V.getReferenceProps():{},"aria-haspopup":n?"listbox":void 0,tabIndex:-1,children:i.jsx(A.TextField,{ref:x,"aria-expanded":n?T:void 0,...I})}),g&&i.jsx(ge.TimePickerModal,{open:te,onOpenChange:U,value:m,onConfirm:k,stepMinutes:M,availableTimes:a,gridVariant:w==="grid-radio"?"radio":"button",modalProps:Z}),!s&&n&&!l&&!g&&i.jsx(c.FloatingPortal,{children:T&&i.jsx(c.FloatingFocusManager,{context:v,modal:!1,initialFocus:-1,children:i.jsx("div",{ref:q.setFloating,...V.getFloatingProps({style:{position:se,top:re??0,left:oe??0}}),children:i.jsx(pe.TimePicker,{value:m,stepMinutes:M,availableTimes:a,onChange:e=>{k(e),a&&j(!1)},gridVariant:w==="grid-radio"?"radio":"button",className:d.default["tedi-time-field__picker-wrapper"]})})})})]})};G.displayName="TimeField";exports.TimeField=G;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { BreakpointSupport } from '../../../helpers';
|
|
2
|
+
import { Breakpoint, BreakpointSupport } from '../../../helpers';
|
|
3
|
+
import { ModalContentProps } from '../../overlays/modal/modal-content/modal-content';
|
|
3
4
|
import { TextFieldProps } from '../textfield/textfield';
|
|
5
|
+
export type TimeFieldModal = boolean | Exclude<Breakpoint, 'xs'>;
|
|
4
6
|
type TimeFieldBreakpointProps = {
|
|
5
7
|
/**
|
|
6
8
|
* If `true`, the field swaps the custom time-picker popover for the
|
|
@@ -91,6 +93,26 @@ export interface TimeFieldProps extends BreakpointSupport<TimeFieldBreakpointPro
|
|
|
91
93
|
* Array of available times to show in the picker or dropdown.
|
|
92
94
|
*/
|
|
93
95
|
availableTimes?: string[];
|
|
96
|
+
/**
|
|
97
|
+
* Open the picker inside a modal instead of a floating popover. Useful on
|
|
98
|
+
* narrow viewports where a popover overlaps the input itself.
|
|
99
|
+
*
|
|
100
|
+
* - `true` always opens in a modal
|
|
101
|
+
* - `false` (default) always uses the popover
|
|
102
|
+
* - A breakpoint name (e.g. `'md'`) opens in a modal *below* that breakpoint
|
|
103
|
+
* and falls back to the popover from that breakpoint up
|
|
104
|
+
*
|
|
105
|
+
* Ignored when `useNativePicker` resolves to `true`.
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
modal?: TimeFieldModal;
|
|
109
|
+
/**
|
|
110
|
+
* Extra props forwarded to the picker modal's `Modal.Content` — e.g. `size`, `width`, `maxWidth`,
|
|
111
|
+
* `position`, `fullscreen`, and per-breakpoint overrides. Lets the consumer tune the modal beyond
|
|
112
|
+
* its `size="small"` / `width="xs"` (capped to 312px) defaults. `className` is merged with the component's own (so
|
|
113
|
+
* the internal padding reset is preserved). Only applies when the picker opens as a modal.
|
|
114
|
+
*/
|
|
115
|
+
modalProps?: Omit<ModalContentProps, 'children'>;
|
|
94
116
|
}
|
|
95
117
|
export declare const TimeField: React.FC<TimeFieldProps>;
|
|
96
118
|
export {};
|
|
@@ -1,62 +1,66 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { TextField as
|
|
6
|
-
import { TimePicker as
|
|
7
|
-
import
|
|
8
|
-
import { normalizeTime as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsxs as q, jsx as i, Fragment as fe } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as me, useClick as ue, useDismiss as pe, useRole as ge, useInteractions as he, FloatingPortal as ke, FloatingFocusManager as ve } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
|
+
import y from "../../../../../external/classnames/index.es.js";
|
|
4
|
+
import be, { useState as N, useEffect as z } from "react";
|
|
5
|
+
import { TextField as A } from "../textfield/textfield.es.js";
|
|
6
|
+
import { TimePicker as Ce } from "../time-picker/time-picker.es.js";
|
|
7
|
+
import d from "./time-field.module.scss.es.js";
|
|
8
|
+
import { normalizeTime as xe, TIMEPICKER_OFFSET as _e } from "./time-field-helpers.es.js";
|
|
9
|
+
import { TimePickerModal as Fe } from "./time-picker-modal/time-picker-modal.es.js";
|
|
10
|
+
import { autoUpdate as Pe } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
11
|
+
import { offset as Te, flip as we, shift as Ie } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
12
|
+
import { useBreakpointProps as ye } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
13
|
+
import { useBreakpoint as Ne, isBreakpointBelow as Be } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
14
|
+
import { Dropdown as b } from "../../overlays/dropdown/dropdown.es.js";
|
|
15
|
+
const Oe = (C) => {
|
|
16
|
+
const { getCurrentBreakpointProps: K } = ye(C.defaultServerBreakpoint), {
|
|
17
|
+
id: G,
|
|
18
|
+
label: H,
|
|
17
19
|
value: c,
|
|
18
|
-
defaultValue:
|
|
19
|
-
onChange:
|
|
20
|
-
readOnly:
|
|
20
|
+
defaultValue: J,
|
|
21
|
+
onChange: x,
|
|
22
|
+
readOnly: h = !1,
|
|
21
23
|
disabled: s = !1,
|
|
22
|
-
required:
|
|
23
|
-
placeholder:
|
|
24
|
+
required: L,
|
|
25
|
+
placeholder: Q,
|
|
24
26
|
inputProps: t,
|
|
25
|
-
stepMinutes:
|
|
26
|
-
className:
|
|
27
|
-
availableTimes: a
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
stepMinutes: B = 1,
|
|
28
|
+
className: O,
|
|
29
|
+
availableTimes: a,
|
|
30
|
+
modal: _ = !1,
|
|
31
|
+
modalProps: W
|
|
32
|
+
} = C, {
|
|
33
|
+
useNativePicker: X = !1,
|
|
34
|
+
timePickerTrigger: M = "button",
|
|
35
|
+
showPicker: o = !0,
|
|
36
|
+
availableTimesVariant: F = "grid-buttons"
|
|
37
|
+
} = K(C), R = c !== void 0, [Y, V] = N(c ?? J ?? ""), f = R ? c : Y, [P, T] = N(!1), [Z, E] = N(!1), m = M === "input", l = X, $ = Ne(), u = !l && o && !h && !s && (_ === !0 || typeof _ == "string" && Be($, _)), ee = me({
|
|
38
|
+
open: P,
|
|
39
|
+
onOpenChange: T,
|
|
40
|
+
placement: m ? "bottom-start" : "bottom-end",
|
|
41
|
+
middleware: [Te(_e), we(), Ie()],
|
|
42
|
+
whileElementsMounted: Pe
|
|
43
|
+
}), { refs: w, context: k, x: te, y: ie, strategy: oe } = ee, ne = ue(k), re = pe(k), le = ge(k, { role: "listbox" }), U = o && m && !h && !s && !l && !u, D = he([...U ? [ne] : [], re, le]), p = (e) => {
|
|
40
44
|
const n = e.trim();
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
var
|
|
45
|
+
R || V(n), x == null || x(n);
|
|
46
|
+
}, se = (e) => {
|
|
47
|
+
var v;
|
|
44
48
|
const n = e.target.value ?? "";
|
|
45
|
-
(
|
|
46
|
-
const r =
|
|
49
|
+
(v = t == null ? void 0 : t.onBlur) == null || v.call(t, e);
|
|
50
|
+
const r = xe(n);
|
|
47
51
|
r !== null && r !== n && p(r);
|
|
48
52
|
};
|
|
49
|
-
|
|
50
|
-
c !== void 0 &&
|
|
53
|
+
z(() => {
|
|
54
|
+
c !== void 0 && V(c);
|
|
51
55
|
}, [c]);
|
|
52
|
-
const
|
|
53
|
-
|
|
56
|
+
const g = be.useRef(null);
|
|
57
|
+
z(() => {
|
|
54
58
|
var e;
|
|
55
|
-
(e =
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
59
|
+
(e = g.current) != null && e.inner && w.setReference(g.current.inner);
|
|
60
|
+
}, [w]);
|
|
61
|
+
const ae = () => {
|
|
58
62
|
var n;
|
|
59
|
-
const e = (n =
|
|
63
|
+
const e = (n = g.current) == null ? void 0 : n.input;
|
|
60
64
|
if (e) {
|
|
61
65
|
if (typeof e.showPicker == "function") {
|
|
62
66
|
e.showPicker();
|
|
@@ -64,88 +68,116 @@ const xe = (k) => {
|
|
|
64
68
|
}
|
|
65
69
|
e.focus();
|
|
66
70
|
}
|
|
67
|
-
},
|
|
68
|
-
!
|
|
69
|
-
},
|
|
71
|
+
}, de = () => T((e) => !e), S = () => E(!0), ce = () => {
|
|
72
|
+
!o || s || (l ? ae() : u ? S() : M === "button" && de());
|
|
73
|
+
}, j = u && m && !h ? () => {
|
|
74
|
+
S();
|
|
75
|
+
} : void 0, I = {
|
|
70
76
|
...t,
|
|
71
|
-
id:
|
|
72
|
-
label:
|
|
73
|
-
value:
|
|
74
|
-
placeholder:
|
|
75
|
-
readOnly:
|
|
77
|
+
id: G,
|
|
78
|
+
label: H,
|
|
79
|
+
value: f,
|
|
80
|
+
placeholder: Q,
|
|
81
|
+
readOnly: h || !l && m,
|
|
76
82
|
disabled: s || (t == null ? void 0 : t.disabled),
|
|
77
|
-
icon: "schedule",
|
|
83
|
+
icon: o ? "schedule" : { name: "schedule", color: "inherit" },
|
|
78
84
|
isClearable: !0,
|
|
79
|
-
required:
|
|
80
|
-
onIconClick:
|
|
85
|
+
required: L,
|
|
86
|
+
onIconClick: o ? ce : void 0,
|
|
81
87
|
onChange: p,
|
|
82
|
-
onBlur:
|
|
83
|
-
className:
|
|
84
|
-
|
|
85
|
-
{ [
|
|
86
|
-
{ [
|
|
87
|
-
{ [
|
|
88
|
+
onBlur: se,
|
|
89
|
+
className: y(
|
|
90
|
+
d["tedi-time-field__textfield"],
|
|
91
|
+
{ [d["tedi-time-field__icon--disabled"]]: !o || s },
|
|
92
|
+
{ [d["tedi-time-field__textfield--disabled"]]: s || (t == null ? void 0 : t.disabled) },
|
|
93
|
+
{ [d["tedi-time-field--native"]]: l }
|
|
88
94
|
),
|
|
89
95
|
input: {
|
|
90
96
|
...t == null ? void 0 : t.input,
|
|
91
|
-
...
|
|
97
|
+
...l && { type: "time" },
|
|
98
|
+
...j && { onClick: j }
|
|
92
99
|
}
|
|
93
100
|
};
|
|
94
|
-
if (!
|
|
95
|
-
const e = a.indexOf(
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */ i(
|
|
101
|
+
if (!l && o && !s && F === "dropdown" && !!(a != null && a.length)) {
|
|
102
|
+
const e = a.indexOf(f), n = e >= 0 ? e : 0;
|
|
103
|
+
return /* @__PURE__ */ q(b, { width: "trigger", defaultActiveIndex: n, children: [
|
|
104
|
+
/* @__PURE__ */ i(b.Trigger, { children: /* @__PURE__ */ i(
|
|
98
105
|
"div",
|
|
99
106
|
{
|
|
100
|
-
className:
|
|
101
|
-
[
|
|
107
|
+
className: y(d["tedi-time-field__container"], O, {
|
|
108
|
+
[d["tedi-time-field__container--native"]]: l
|
|
102
109
|
}),
|
|
103
|
-
children: /* @__PURE__ */ i(
|
|
110
|
+
children: /* @__PURE__ */ i(
|
|
111
|
+
A,
|
|
112
|
+
{
|
|
113
|
+
ref: g,
|
|
114
|
+
...I,
|
|
115
|
+
input: {
|
|
116
|
+
...I.input,
|
|
117
|
+
...!m && {
|
|
118
|
+
onClick: (r) => r.stopPropagation()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
)
|
|
104
123
|
}
|
|
105
124
|
) }),
|
|
106
|
-
/* @__PURE__ */ i(
|
|
125
|
+
/* @__PURE__ */ i(b.Content, { children: a.map((r, v) => /* @__PURE__ */ i(b.Item, { index: v, active: r === f, onClick: () => p(r), children: r }, r)) })
|
|
107
126
|
] });
|
|
108
127
|
}
|
|
109
|
-
return /* @__PURE__ */
|
|
128
|
+
return /* @__PURE__ */ q(fe, { children: [
|
|
110
129
|
/* @__PURE__ */ i(
|
|
111
130
|
"div",
|
|
112
131
|
{
|
|
113
|
-
className:
|
|
114
|
-
...
|
|
115
|
-
"aria-haspopup":
|
|
132
|
+
className: y(d["tedi-time-field__container"], O),
|
|
133
|
+
...U ? D.getReferenceProps() : {},
|
|
134
|
+
"aria-haspopup": o ? "listbox" : void 0,
|
|
116
135
|
tabIndex: -1,
|
|
117
|
-
children: /* @__PURE__ */ i(
|
|
136
|
+
children: /* @__PURE__ */ i(A, { ref: g, "aria-expanded": o ? P : void 0, ...I })
|
|
118
137
|
}
|
|
119
138
|
),
|
|
120
|
-
|
|
139
|
+
u && /* @__PURE__ */ i(
|
|
140
|
+
Fe,
|
|
141
|
+
{
|
|
142
|
+
open: Z,
|
|
143
|
+
onOpenChange: E,
|
|
144
|
+
value: f,
|
|
145
|
+
onConfirm: p,
|
|
146
|
+
stepMinutes: B,
|
|
147
|
+
availableTimes: a,
|
|
148
|
+
gridVariant: F === "grid-radio" ? "radio" : "button",
|
|
149
|
+
modalProps: W
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
!l && o && !s && !u && /* @__PURE__ */ i(ke, { children: P && /* @__PURE__ */ i(ve, { context: k, modal: !1, initialFocus: -1, children: /* @__PURE__ */ i(
|
|
121
153
|
"div",
|
|
122
154
|
{
|
|
123
|
-
ref:
|
|
124
|
-
...
|
|
155
|
+
ref: w.setFloating,
|
|
156
|
+
...D.getFloatingProps({
|
|
125
157
|
style: {
|
|
126
|
-
position:
|
|
127
|
-
top:
|
|
128
|
-
left:
|
|
158
|
+
position: oe,
|
|
159
|
+
top: ie ?? 0,
|
|
160
|
+
left: te ?? 0
|
|
129
161
|
}
|
|
130
162
|
}),
|
|
131
163
|
children: /* @__PURE__ */ i(
|
|
132
|
-
|
|
164
|
+
Ce,
|
|
133
165
|
{
|
|
134
|
-
value:
|
|
135
|
-
stepMinutes:
|
|
166
|
+
value: f,
|
|
167
|
+
stepMinutes: B,
|
|
136
168
|
availableTimes: a,
|
|
137
169
|
onChange: (e) => {
|
|
138
|
-
p(e), a &&
|
|
170
|
+
p(e), a && T(!1);
|
|
139
171
|
},
|
|
140
|
-
gridVariant:
|
|
141
|
-
className:
|
|
172
|
+
gridVariant: F === "grid-radio" ? "radio" : "button",
|
|
173
|
+
className: d["tedi-time-field__picker-wrapper"]
|
|
142
174
|
}
|
|
143
175
|
)
|
|
144
176
|
}
|
|
145
177
|
) }) })
|
|
146
178
|
] });
|
|
147
179
|
};
|
|
148
|
-
|
|
180
|
+
Oe.displayName = "TimeField";
|
|
149
181
|
export {
|
|
150
|
-
|
|
182
|
+
Oe as TimeField
|
|
151
183
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),q=require("../../../../../../external/classnames/index.cjs.js"),m=require("react"),C=require("../../../base/typography/heading/heading.cjs.js"),f=require("../../../buttons/button/button.cjs.js"),_=require("../../../buttons/closing-button/closing-button.cjs.js"),b=require("../../time-picker/time-picker.cjs.js"),s=require("./time-picker-modal.module.scss.cjs.js"),l=require("../../../overlays/modal/modal.cjs.js"),T=require("../../../overlays/modal/modal-context.cjs.js"),v=require("../../../../providers/label-provider/use-labels.cjs.js"),N=({title:o})=>{const{labelId:i,onOpenChange:t}=T.useModal();return e.jsxs("div",{className:s.default["tedi-time-picker-modal__header"],children:[e.jsx(C.Heading,{element:"h2",modifiers:"h4",id:i,className:s.default["tedi-time-picker-modal__title"],children:o}),e.jsx(_.ClosingButton,{size:"small",onClick:()=>t(!1)})]})},c=o=>{const{open:i,onOpenChange:t,value:n,onConfirm:h,stepMinutes:k,availableTimes:x,gridVariant:j,modalProps:a,title:M}=o,{getLabel:r}=v.useLabels(),g=M??r("time-field.modal-title"),[d,u]=m.useState(n??"");m.useEffect(()=>{i&&u(n??"")},[i,n]);const p=()=>{d&&h(d),t(!1)};return e.jsx(l.Modal,{open:i,onToggle:t,children:e.jsxs(l.Modal.Content,{size:"small",width:"xs",...a,className:q.default(s.default["tedi-time-picker-modal"],a==null?void 0:a.className),children:[e.jsx(l.Modal.Header,{children:e.jsx(N,{title:g})}),e.jsx(l.Modal.Body,{className:s.default["tedi-time-picker-modal__body"],children:e.jsx(b.TimePicker,{value:d,stepMinutes:k,availableTimes:x,gridVariant:j,onChange:u,bordered:!1,className:s.default["tedi-time-picker-modal__picker"]})}),e.jsxs(l.Modal.Footer,{children:[e.jsx(f.Button,{visualType:"secondary",onClick:()=>t(!1),children:r("time-field.cancel")}),e.jsx(f.Button,{onClick:p,children:r("time-field.confirm")})]})]})})};c.displayName="TimePickerModal";exports.TimePickerModal=c;exports.default=c;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ModalContentProps } from '../../../overlays/modal';
|
|
2
|
+
import { TimePickerProps } from '../../time-picker/time-picker';
|
|
3
|
+
export interface TimePickerModalProps {
|
|
4
|
+
/** Whether the modal is open. Pair with `onOpenChange`. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Fires when the modal opens or closes (e.g. dismiss via backdrop or Escape). */
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
/** Current committed value (HH:mm). Used to seed the draft when the modal opens. */
|
|
9
|
+
value?: string;
|
|
10
|
+
/** Fires with the chosen value when the user clicks "Confirm". Cancel/dismiss do nothing. */
|
|
11
|
+
onConfirm: (value: string) => void;
|
|
12
|
+
/** Forwarded to the inner `TimePicker`. */
|
|
13
|
+
stepMinutes?: TimePickerProps['stepMinutes'];
|
|
14
|
+
/** Forwarded to the inner `TimePicker`. */
|
|
15
|
+
availableTimes?: TimePickerProps['availableTimes'];
|
|
16
|
+
/** Forwarded to the inner `TimePicker`. */
|
|
17
|
+
gridVariant?: TimePickerProps['gridVariant'];
|
|
18
|
+
/**
|
|
19
|
+
* Extra props spread onto `Modal.Content`, overriding the `size="small"` / `width="xs"` (capped to 312px)
|
|
20
|
+
* defaults (including `fullscreen`). `className` is merged, not replaced, so the internal padding reset survives.
|
|
21
|
+
*/
|
|
22
|
+
modalProps?: Omit<ModalContentProps, 'children'>;
|
|
23
|
+
/** Modal title text. Falls back to the `time-field.modal-title` i18n key. */
|
|
24
|
+
title?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const TimePickerModal: {
|
|
27
|
+
(props: TimePickerModalProps): JSX.Element;
|
|
28
|
+
displayName: string;
|
|
29
|
+
};
|
|
30
|
+
export default TimePickerModal;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import T from "../../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { useState as _, useEffect as b } from "react";
|
|
4
|
+
import { Heading as v } from "../../../base/typography/heading/heading.es.js";
|
|
5
|
+
import { Button as f } from "../../../buttons/button/button.es.js";
|
|
6
|
+
import { ClosingButton as y } from "../../../buttons/closing-button/closing-button.es.js";
|
|
7
|
+
import { TimePicker as M } from "../../time-picker/time-picker.es.js";
|
|
8
|
+
import l from "./time-picker-modal.module.scss.es.js";
|
|
9
|
+
import { Modal as t } from "../../../overlays/modal/modal.es.js";
|
|
10
|
+
import { useModal as x } from "../../../overlays/modal/modal-context.es.js";
|
|
11
|
+
import { useLabels as B } from "../../../../providers/label-provider/use-labels.es.js";
|
|
12
|
+
const H = ({ title: a }) => {
|
|
13
|
+
const { labelId: i, onOpenChange: o } = x();
|
|
14
|
+
return /* @__PURE__ */ d("div", { className: l["tedi-time-picker-modal__header"], children: [
|
|
15
|
+
/* @__PURE__ */ e(v, { element: "h2", modifiers: "h4", id: i, className: l["tedi-time-picker-modal__title"], children: a }),
|
|
16
|
+
/* @__PURE__ */ e(y, { size: "small", onClick: () => o(!1) })
|
|
17
|
+
] });
|
|
18
|
+
}, P = (a) => {
|
|
19
|
+
const { open: i, onOpenChange: o, value: m, onConfirm: p, stepMinutes: h, availableTimes: k, gridVariant: u, modalProps: r, title: C } = a, { getLabel: s } = B(), g = C ?? s("time-field.modal-title"), [n, c] = _(m ?? "");
|
|
20
|
+
b(() => {
|
|
21
|
+
i && c(m ?? "");
|
|
22
|
+
}, [i, m]);
|
|
23
|
+
const N = () => {
|
|
24
|
+
n && p(n), o(!1);
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ e(t, { open: i, onToggle: o, children: /* @__PURE__ */ d(
|
|
27
|
+
t.Content,
|
|
28
|
+
{
|
|
29
|
+
size: "small",
|
|
30
|
+
width: "xs",
|
|
31
|
+
...r,
|
|
32
|
+
className: T(l["tedi-time-picker-modal"], r == null ? void 0 : r.className),
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ e(t.Header, { children: /* @__PURE__ */ e(H, { title: g }) }),
|
|
35
|
+
/* @__PURE__ */ e(t.Body, { className: l["tedi-time-picker-modal__body"], children: /* @__PURE__ */ e(
|
|
36
|
+
M,
|
|
37
|
+
{
|
|
38
|
+
value: n,
|
|
39
|
+
stepMinutes: h,
|
|
40
|
+
availableTimes: k,
|
|
41
|
+
gridVariant: u,
|
|
42
|
+
onChange: c,
|
|
43
|
+
bordered: !1,
|
|
44
|
+
className: l["tedi-time-picker-modal__picker"]
|
|
45
|
+
}
|
|
46
|
+
) }),
|
|
47
|
+
/* @__PURE__ */ d(t.Footer, { children: [
|
|
48
|
+
/* @__PURE__ */ e(f, { visualType: "secondary", onClick: () => o(!1), children: s("time-field.cancel") }),
|
|
49
|
+
/* @__PURE__ */ e(f, { onClick: N, children: s("time-field.confirm") })
|
|
50
|
+
] })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
) });
|
|
54
|
+
};
|
|
55
|
+
P.displayName = "TimePickerModal";
|
|
56
|
+
export {
|
|
57
|
+
P as TimePickerModal,
|
|
58
|
+
P as default
|
|
59
|
+
};
|
package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.module.scss.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-time-picker-modal":"tedi-time-picker-modal-10d7ab34","tedi-time-picker-modal__header":"tedi-time-picker-modal__header-8331c682","tedi-time-picker-modal__title":"tedi-time-picker-modal__title-2c759f1e","tedi-time-picker-modal__body":"tedi-time-picker-modal__body-6b342637","tedi-time-picker-modal__picker":"tedi-time-picker-modal__picker-c4de3136"};exports.default=e;
|
package/src/tedi/components/form/time-field/time-picker-modal/time-picker-modal.module.scss.es.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
"tedi-time-picker-modal": "tedi-time-picker-modal-10d7ab34",
|
|
3
|
+
"tedi-time-picker-modal__header": "tedi-time-picker-modal__header-8331c682",
|
|
4
|
+
"tedi-time-picker-modal__title": "tedi-time-picker-modal__title-2c759f1e",
|
|
5
|
+
"tedi-time-picker-modal__body": "tedi-time-picker-modal__body-6b342637",
|
|
6
|
+
"tedi-time-picker-modal__picker": "tedi-time-picker-modal__picker-c4de3136"
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
e as default
|
|
10
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),j=require("../../../../../../../external/classnames/index.cjs.js"),d=require("react"),A=require("../../../choice-group/choice-group.cjs.js"),l=require("../../time-picker.module.scss.cjs.js"),G=require("../../../../../providers/label-provider/use-labels.cjs.js"),f=({times:b,value:n,onSelect:y,className:h,colWidth:s={xs:6,md:4},variant:m="button",bordered:g=!0})=>{const c=d.useId(),{getLabel:k}=G.useLabels(),a=d.useRef(null);d.useEffect(()=>{if(!n)return;const e=a.current;if(!e)return;const r=e.querySelector(`input[type="radio"][value="${n}"]`);r==null||r.focus({preventScroll:!0})},[]);const w=e=>{var p;const r=a.current;if(!r)return;const t=Array.from(r.querySelectorAll('input[type="radio"]:not([disabled])'));if(t.length===0)return;const o=t.findIndex(_=>_===document.activeElement);let i;switch(e.key){case"ArrowDown":case"ArrowRight":i=o<0||o===t.length-1?0:o+1;break;case"ArrowUp":case"ArrowLeft":i=o<=0?t.length-1:o-1;break;case"Home":i=0;break;case"End":i=t.length-1;break;default:return}e.preventDefault(),(p=t[i])==null||p.focus()},x=j.default(l.default["tedi-time-picker__grid"],{[l.default["tedi-time-picker__grid--borderless"]]:!g},h),q=typeof s=="object"?s:{width:s};return u.jsx("div",{ref:a,className:x,onKeyDown:w,children:u.jsx(A.ChoiceGroup,{id:`time-picker-group-${c}`,label:k("timePicker.pickTime"),inputType:"radio",name:`time-grid-${c}`,value:n,onChange:e=>y(e),items:b.map(e=>({id:`time-${c}-${e}`,label:m==="button"?u.jsx("span",{className:l.default["tedi-time-picker__slot-label"],children:e}):e,value:e,colProps:q})),direction:"row",variant:"card",showIndicator:m==="radio",color:"secondary",hideLabel:!0})})};f.displayName="TimeGrid";exports.TimeGrid=f;
|
|
@@ -25,7 +25,11 @@ export interface TimeGridProps {
|
|
|
25
25
|
*/
|
|
26
26
|
colWidth?: ColSize | Pick<ColProps, 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'>;
|
|
27
27
|
/**
|
|
28
|
-
* Display mode
|
|
28
|
+
* Display mode. Both variants render the same `ChoiceGroup` card radio
|
|
29
|
+
* underneath — the only difference is the leading radio indicator:
|
|
30
|
+
*
|
|
31
|
+
* - `'button'` (default) — card with the label only, no dot.
|
|
32
|
+
* - `'radio'` — card with the radio dot before the label.
|
|
29
33
|
*/
|
|
30
34
|
variant?: 'button' | 'radio';
|
|
31
35
|
className?: string;
|