@tedi-design-system/react 17.1.0-rc.7 → 17.1.0-rc.8

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.
Files changed (35) hide show
  1. package/bundle-stats.html +1 -1
  2. package/index.css +1 -1
  3. package/package.json +1 -1
  4. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
  5. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +70 -70
  6. package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
  7. package/src/tedi/components/form/textfield/textfield.es.js +110 -110
  8. package/src/tedi/components/form/time-field/time-field-helpers.cjs.js +1 -0
  9. package/src/tedi/components/form/time-field/time-field-helpers.d.ts +51 -0
  10. package/src/tedi/components/form/time-field/time-field-helpers.es.js +65 -0
  11. package/src/tedi/components/form/time-field/time-field.cjs.js +1 -0
  12. package/src/tedi/components/form/time-field/time-field.d.ts +87 -0
  13. package/src/tedi/components/form/time-field/time-field.es.js +149 -0
  14. package/src/tedi/components/form/time-field/time-field.module.scss.cjs.js +1 -0
  15. package/src/tedi/components/form/time-field/time-field.module.scss.es.js +10 -0
  16. package/src/tedi/components/form/time-picker/components/time-grid/time-grid.cjs.js +1 -0
  17. package/src/tedi/components/form/time-picker/components/time-grid/time-grid.d.ts +38 -0
  18. package/src/tedi/components/form/time-picker/components/time-grid/time-grid.es.js +101 -0
  19. package/src/tedi/components/form/time-picker/components/time-wheel/time-wheel.cjs.js +1 -0
  20. package/src/tedi/components/form/time-picker/components/time-wheel/time-wheel.d.ts +40 -0
  21. package/src/tedi/components/form/time-picker/components/time-wheel/time-wheel.es.js +184 -0
  22. package/src/tedi/components/form/time-picker/time-picker.cjs.js +1 -0
  23. package/src/tedi/components/form/time-picker/time-picker.d.ts +60 -0
  24. package/src/tedi/components/form/time-picker/time-picker.es.js +45 -0
  25. package/src/tedi/components/form/time-picker/time-picker.module.scss.cjs.js +1 -0
  26. package/src/tedi/components/form/time-picker/time-picker.module.scss.es.js +14 -0
  27. package/src/tedi/components/overlays/dropdown/dropdown.cjs.js +1 -1
  28. package/src/tedi/components/overlays/dropdown/dropdown.d.ts +9 -0
  29. package/src/tedi/components/overlays/dropdown/dropdown.es.js +98 -88
  30. package/src/tedi/index.d.ts +2 -0
  31. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  32. package/src/tedi/providers/label-provider/labels-map.d.ts +7 -0
  33. package/src/tedi/providers/label-provider/labels-map.es.js +9 -2
  34. package/tedi.cjs.js +1 -1
  35. package/tedi.es.js +170 -166
@@ -0,0 +1,184 @@
1
+ import { jsxs as Q, jsx as y } from "react/jsx-runtime";
2
+ import F from "../../../../../../../external/classnames/index.es.js";
3
+ import M, { useRef as l, useLayoutEffect as X, useEffect as j } from "react";
4
+ import { clearScrollTimeout as d, snapToNearestItem as A, needsScrollCorrection as C, scrollToIndex as D, getScrollTopForIndex as P } from "../../../time-field/time-field-helpers.es.js";
5
+ import p from "../../time-picker.module.scss.es.js";
6
+ const Y = ({
7
+ hours: t,
8
+ minutes: n,
9
+ selectedHour: u,
10
+ selectedMinute: i,
11
+ onChange: k,
12
+ className: H,
13
+ bordered: U = !0
14
+ }) => {
15
+ const g = M.useId(), a = l(null), s = l(null), m = l(!1), f = l(!1), v = l(), S = l(), w = l(-1), _ = l(-1), [W, E] = M.useState(null), [V, $] = M.useState(null), N = (r, e) => Math.max(0, Math.min(e - 1, r)), R = (r, e, c) => {
16
+ const h = r.current;
17
+ if (!h || e < 0) return;
18
+ const I = P(e);
19
+ c ? m.current = !0 : f.current = !0, h.scrollTo({ top: I, behavior: "instant" }), requestAnimationFrame(() => {
20
+ c ? m.current = !1 : f.current = !1;
21
+ });
22
+ };
23
+ X(() => {
24
+ const r = t.indexOf(u), e = n.indexOf(i);
25
+ r !== w.current && (w.current = r, R(a, r, !0)), e !== _.current && (_.current = e, R(s, e, !1)), E(r), $(e);
26
+ }, [t, n, u, i]);
27
+ const O = l(() => {
28
+ });
29
+ O.current = () => {
30
+ const r = a.current;
31
+ if (!r || m.current) return;
32
+ d(v.current);
33
+ const e = N(A(r.scrollTop, t.length), t.length);
34
+ E(e);
35
+ const c = P(e);
36
+ C(r.scrollTop, c, 8) && (m.current = !0, D(r, e, "instant"), requestAnimationFrame(() => {
37
+ m.current = !1;
38
+ })), e !== w.current && (w.current = e, k(t[e], i));
39
+ };
40
+ const L = l(() => {
41
+ });
42
+ L.current = () => {
43
+ const r = s.current;
44
+ if (!r || f.current) return;
45
+ d(S.current);
46
+ const e = N(A(r.scrollTop, n.length), n.length);
47
+ $(e);
48
+ const c = P(e);
49
+ C(r.scrollTop, c, 8) && (f.current = !0, D(r, e, "instant"), requestAnimationFrame(() => {
50
+ f.current = !1;
51
+ })), e !== _.current && (_.current = e, k(u, n[e]));
52
+ }, j(() => {
53
+ const r = a.current, e = s.current;
54
+ if (!r || !e) return;
55
+ const c = () => O.current(), h = () => L.current();
56
+ return r.addEventListener("scrollend", c), e.addEventListener("scrollend", h), () => {
57
+ r.removeEventListener("scrollend", c), e.removeEventListener("scrollend", h);
58
+ };
59
+ }, []);
60
+ const z = () => {
61
+ if (!a.current || m.current) return;
62
+ const r = N(A(a.current.scrollTop, t.length), t.length);
63
+ E(r), d(v.current), v.current = setTimeout(() => O.current(), 150);
64
+ }, B = () => {
65
+ if (!s.current || f.current) return;
66
+ const r = N(A(s.current.scrollTop, n.length), n.length);
67
+ $(r), d(S.current), S.current = setTimeout(() => L.current(), 150);
68
+ }, G = (r) => {
69
+ const e = t[r];
70
+ !e || !a.current || (d(v.current), w.current = r, E(r), k(e, i), m.current = !0, D(a.current, r, "smooth"), setTimeout(() => {
71
+ m.current = !1;
72
+ }, 300));
73
+ }, J = (r) => {
74
+ const e = n[r];
75
+ !e || !s.current || (d(S.current), _.current = r, $(r), k(u, e), f.current = !0, D(s.current, r, "smooth"), setTimeout(() => {
76
+ f.current = !1;
77
+ }, 300));
78
+ }, K = (r, e, c, h) => (I) => {
79
+ const o = e.indexOf(c);
80
+ if (o === -1) return;
81
+ let x = -1, b = !1;
82
+ switch (I.key) {
83
+ case "ArrowDown":
84
+ x = (o + 1) % e.length, b = o === e.length - 1;
85
+ break;
86
+ case "ArrowUp":
87
+ x = (o - 1 + e.length) % e.length, b = o === 0;
88
+ break;
89
+ case "Home":
90
+ x = 0;
91
+ break;
92
+ case "End":
93
+ x = e.length - 1;
94
+ break;
95
+ case "PageDown":
96
+ x = (o + 5) % e.length, b = o + 5 >= e.length;
97
+ break;
98
+ case "PageUp":
99
+ x = (o - 5 + e.length) % e.length, b = o - 5 < 0;
100
+ break;
101
+ case "Enter":
102
+ case " ":
103
+ I.preventDefault(), h(e[o]);
104
+ return;
105
+ default:
106
+ return;
107
+ }
108
+ I.preventDefault();
109
+ const q = r === "hour" ? a.current : s.current, T = q == null ? void 0 : q.querySelector(`#${CSS.escape(`${g}-${r}-${x}`)}`);
110
+ T == null || T.focus(), T == null || T.scrollIntoView({ block: "center", behavior: b ? "auto" : "smooth" });
111
+ };
112
+ return j(() => () => {
113
+ d(v.current), d(S.current);
114
+ }, []), /* @__PURE__ */ Q(
115
+ "div",
116
+ {
117
+ className: F(
118
+ p["tedi-time-picker__wheel"],
119
+ { [p["tedi-time-picker__wheel--borderless"]]: !U },
120
+ H
121
+ ),
122
+ children: [
123
+ /* @__PURE__ */ y(
124
+ "div",
125
+ {
126
+ ref: a,
127
+ role: "listbox",
128
+ "aria-label": "Hours",
129
+ tabIndex: 0,
130
+ "aria-activedescendant": `${g}-hour-${t.indexOf(u)}`,
131
+ className: p["tedi-time-picker__wheel-column"],
132
+ onScroll: z,
133
+ onKeyDown: K("hour", t, u, (r) => k(r, i)),
134
+ children: t.map((r, e) => /* @__PURE__ */ y(
135
+ "div",
136
+ {
137
+ className: F(p["tedi-time-picker__wheel-item"], {
138
+ [p["tedi-time-picker__wheel-item--selected"]]: e === (W ?? t.indexOf(u))
139
+ }),
140
+ onClick: () => G(e),
141
+ id: `${g}-hour-${e}`,
142
+ role: "option",
143
+ "aria-selected": r === u,
144
+ children: r
145
+ },
146
+ r
147
+ ))
148
+ }
149
+ ),
150
+ /* @__PURE__ */ y(
151
+ "div",
152
+ {
153
+ ref: s,
154
+ role: "listbox",
155
+ className: p["tedi-time-picker__wheel-column"],
156
+ onScroll: B,
157
+ "aria-label": "Minutes",
158
+ tabIndex: 0,
159
+ "aria-activedescendant": `${g}-minute-${n.indexOf(i)}`,
160
+ onKeyDown: K("minute", n, i, (r) => k(u, r)),
161
+ children: n.map((r, e) => /* @__PURE__ */ y(
162
+ "div",
163
+ {
164
+ className: F(p["tedi-time-picker__wheel-item"], {
165
+ [p["tedi-time-picker__wheel-item--selected"]]: e === (V ?? n.indexOf(i))
166
+ }),
167
+ onClick: () => J(e),
168
+ id: `${g}-minute-${e}`,
169
+ role: "option",
170
+ "aria-selected": r === i,
171
+ children: r
172
+ },
173
+ r
174
+ ))
175
+ }
176
+ )
177
+ ]
178
+ }
179
+ );
180
+ };
181
+ Y.displayName = "TimeWheel";
182
+ export {
183
+ Y as TimeWheel
184
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),n=require("react"),t=require("../time-field/time-field-helpers.cjs.js"),H=require("./components/time-grid/time-grid.cjs.js"),x=require("./components/time-wheel/time-wheel.cjs.js"),T=({value:s,defaultValue:f="",onChange:r,stepMinutes:o=1,availableTimes:i,gridVariant:h="button",className:u,bordered:c=!0})=>{const[j,P]=n.useState(f),l=s!==void 0,m=l?s:j,d=e=>{l||P(e),r==null||r(e)},a=n.useMemo(t.generateHours,[]),q=n.useMemo(()=>t.generateMinutes(o),[o]),{hour:y,minute:S}=t.parseTime(m||"12:00"),g=a.includes(y)?y:"12",k=t.findClosestMinute(S,q);return Array.isArray(i)&&i.length>0?M.jsx(H.TimeGrid,{times:i,value:m,variant:h,onSelect:d,className:u,bordered:c}):M.jsx(x.TimeWheel,{hours:a,minutes:q,selectedHour:g,selectedMinute:k,onChange:(e,p)=>d(`${e}:${p}`),className:u,bordered:c})};T.displayName="TimePicker";exports.TimePicker=T;
@@ -0,0 +1,60 @@
1
+ import { default as React } from 'react';
2
+ export interface TimePickerProps {
3
+ /**
4
+ * Currently selected time in "HH:mm" format (24-hour).
5
+ *
6
+ * @example "14:30"
7
+ * @default ""
8
+ */
9
+ value?: string;
10
+ /**
11
+ * Initial time value for uncontrolled mode. Should be in "HH:mm" format.
12
+ * @example "09:00"
13
+ * @default ""
14
+ */
15
+ defaultValue?: string;
16
+ /**
17
+ * Callback fired when the user selects a new time.
18
+ * Returns the selected time in "HH:mm" format.
19
+ *
20
+ * @param time - Selected time as "HH:mm" string
21
+ */
22
+ onChange?: (time: string) => void;
23
+ /**
24
+ * Minute step interval for the minute wheel.
25
+ * Determines which minute values are shown (e.g. 00, 05, 10, ..., 55).
26
+ *
27
+ * @default 1
28
+ */
29
+ stepMinutes?: number;
30
+ /**
31
+ * When provided, the component switches from wheel mode to grid mode.
32
+ * Displays a list/grid of predefined time slots instead of scrollable wheels.
33
+ *
34
+ * Each string must be in "HH:mm" format.
35
+ *
36
+ * @example ["09:00", "09:30", "10:00", "14:00", "15:30"]
37
+ */
38
+ availableTimes?: string[];
39
+ /**
40
+ * Variant of the grid rendered when `availableTimes` is provided:
41
+ * - 'buttons' – buttons grid
42
+ * - 'radio' – radio buttons grid
43
+ * @default button
44
+ */
45
+ gridVariant?: 'button' | 'radio';
46
+ /**
47
+ * Additional CSS class name to apply to the root element.
48
+ * Useful for custom styling and layout overrides.
49
+ */
50
+ className?: string;
51
+ /**
52
+ * Whether to render the surrounding card (border, background, radius).
53
+ * Set to `false` when embedding inside a parent that already provides
54
+ * its own surface — e.g. alongside a calendar inside `DateTimeField`.
55
+ * The inner gradient masks and column separators are preserved either way.
56
+ * @default true
57
+ */
58
+ bordered?: boolean;
59
+ }
60
+ export declare const TimePicker: React.FC<TimePickerProps>;
@@ -0,0 +1,45 @@
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import S, { useMemo as a } from "react";
3
+ import { generateHours as _, generateMinutes as $, parseTime as g, findClosestMinute as j } from "../time-field/time-field-helpers.es.js";
4
+ import { TimeGrid as x } from "./components/time-grid/time-grid.es.js";
5
+ import { TimeWheel as G } from "./components/time-wheel/time-wheel.es.js";
6
+ const I = ({
7
+ value: o,
8
+ defaultValue: h = "",
9
+ onChange: e,
10
+ stepMinutes: n = 1,
11
+ availableTimes: r,
12
+ gridVariant: y = "button",
13
+ className: i,
14
+ bordered: s = !0
15
+ }) => {
16
+ const [M, T] = S.useState(h), c = o !== void 0, m = c ? o : M, u = (t) => {
17
+ c || T(t), e == null || e(t);
18
+ }, f = a(_, []), l = a(() => $(n), [n]), { hour: d, minute: k } = g(m || "12:00"), A = f.includes(d) ? d : "12", H = j(k, l);
19
+ return Array.isArray(r) && r.length > 0 ? /* @__PURE__ */ p(
20
+ x,
21
+ {
22
+ times: r,
23
+ value: m,
24
+ variant: y,
25
+ onSelect: u,
26
+ className: i,
27
+ bordered: s
28
+ }
29
+ ) : /* @__PURE__ */ p(
30
+ G,
31
+ {
32
+ hours: f,
33
+ minutes: l,
34
+ selectedHour: A,
35
+ selectedMinute: H,
36
+ onChange: (t, P) => u(`${t}:${P}`),
37
+ className: i,
38
+ bordered: s
39
+ }
40
+ );
41
+ };
42
+ I.displayName = "TimePicker";
43
+ export {
44
+ I as TimePicker
45
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-time-picker__wheel":"tedi-time-picker__wheel-3c73e157","tedi-time-picker__wheel--borderless":"tedi-time-picker__wheel--borderless-42e8669c","tedi-time-picker__wheel-column":"tedi-time-picker__wheel-column-02048315","tedi-time-picker__wheel-item":"tedi-time-picker__wheel-item-78600fe1","tedi-time-picker__wheel-item--selected":"tedi-time-picker__wheel-item--selected-cc3c7194","tedi-time-picker__grid":"tedi-time-picker__grid-5cf42402","tedi-time-picker__grid--borderless":"tedi-time-picker__grid--borderless-805d6413","tedi-time-picker__grid-item":"tedi-time-picker__grid-item-53c9d41d","tedi-time-picker__grid-item--selected":"tedi-time-picker__grid-item--selected-32fb5e5d"};exports.default=e;
@@ -0,0 +1,14 @@
1
+ const e = {
2
+ "tedi-time-picker__wheel": "tedi-time-picker__wheel-3c73e157",
3
+ "tedi-time-picker__wheel--borderless": "tedi-time-picker__wheel--borderless-42e8669c",
4
+ "tedi-time-picker__wheel-column": "tedi-time-picker__wheel-column-02048315",
5
+ "tedi-time-picker__wheel-item": "tedi-time-picker__wheel-item-78600fe1",
6
+ "tedi-time-picker__wheel-item--selected": "tedi-time-picker__wheel-item--selected-cc3c7194",
7
+ "tedi-time-picker__grid": "tedi-time-picker__grid-5cf42402",
8
+ "tedi-time-picker__grid--borderless": "tedi-time-picker__grid--borderless-805d6413",
9
+ "tedi-time-picker__grid-item": "tedi-time-picker__grid-item-53c9d41d",
10
+ "tedi-time-picker__grid-item--selected": "tedi-time-picker__grid-item--selected-32fb5e5d"
11
+ };
12
+ export {
13
+ e as default
14
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),H=require("../../../../../external/classnames/index.cjs.js"),t=require("react"),S=require("./dropdown.module.scss.cjs.js"),$=require("./dropdown-content/dropdown-content.cjs.js"),A=require("./dropdown-context.cjs.js"),z=require("./dropdown-helpers.cjs.js"),G=require("./dropdown-item/dropdown-item.cjs.js"),J=require("./dropdown-separator/dropdown-separator.cjs.js"),K=require("./dropdown-trigger/dropdown-trigger.cjs.js"),Q=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),f=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),V=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),X=require("../../../providers/label-provider/use-labels.cjs.js"),Y=4,s=g=>{var x;const{getCurrentBreakpointProps:F}=V.useBreakpointProps(g.defaultServerBreakpoint),{children:I,modal:w=!1,divided:O=!1,width:P="auto",variant:l="default",open:u,defaultOpen:R=!1,onOpenChange:i,placement:p="bottom-start",className:b}=F(g),{getLabel:j}=X.useLabels(),k=e.useFloatingNodeId(),m=t.useRef([]),[a,v]=t.useState(null),[q,y]=t.useState(null),[B,N]=t.useState(R),d=u??B,h=t.useCallback(r=>{u===void 0&&N(r),i==null||i(r)},[u,i]),T=e.useFloating({nodeId:k,open:d,placement:p,onOpenChange:h,middleware:[f.offset(Y),f.flip(),f.shift()],whileElementsMounted:Q.autoUpdate}),{context:o,refs:n,x:U,y:_,strategy:L}=T,D=e.useInteractions([e.useClick(o),e.useRole(o,{role:"menu"}),e.useDismiss(o),e.useListNavigation(o,{listRef:m,activeIndex:a,onNavigate:v,loop:!0})]),M={open:d,setOpen:h,refs:n,listItemsRef:m,activeIndex:a,setActiveIndex:v,placement:p,content:q,setContent:y,divided:O,variant:l,...D},W=(x=n.reference.current)==null?void 0:x.getBoundingClientRect().width,E=t.useMemo(()=>{const r=n.reference.current;if(!r)return;const C=r.offsetParent;if(C)return C.getBoundingClientRect().width},[n.reference.current]);return c.jsxs(A.DropdownContext.Provider,{value:M,children:[I,c.jsx(e.FloatingPortal,{children:d&&c.jsx(e.FloatingFocusManager,{context:o,modal:w,visuallyHiddenDismiss:w?j("close"):!1,children:c.jsx("div",{...D.getFloatingProps({ref:n.setFloating,className:H.default(S.default["tedi-dropdown"],{[S.default[`tedi-dropdown--${l}`]]:l==="tree"},b),style:{position:L,left:U??0,top:_??0,width:z.resolveDropdownWidth(P,W,E)},role:"menu","aria-orientation":"vertical","aria-activedescendant":a!==null?`dropdown-item-${a}`:void 0}),"data-placement":p,"data-state":d?"open":"closed",children:q})})})]})};s.Trigger=K.DropdownTrigger;s.Content=$.DropdownContent;s.Item=G.DropdownItem;s.Separator=J.DropdownSeparator;exports.Dropdown=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),H=require("../../../../../external/classnames/index.cjs.js"),t=require("react"),O=require("./dropdown.module.scss.cjs.js"),$=require("./dropdown-content/dropdown-content.cjs.js"),z=require("./dropdown-context.cjs.js"),G=require("./dropdown-helpers.cjs.js"),J=require("./dropdown-item/dropdown-item.cjs.js"),K=require("./dropdown-separator/dropdown-separator.cjs.js"),Q=require("./dropdown-trigger/dropdown-trigger.cjs.js"),V=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),m=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),X=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),Y=require("../../../providers/label-provider/use-labels.cjs.js"),Z=4,d=w=>{var I;const{getCurrentBreakpointProps:S}=X.useBreakpointProps(w.defaultServerBreakpoint),{children:F,modal:v=!1,divided:P=!1,width:R="auto",variant:u="default",open:p,defaultOpen:b=!1,onOpenChange:a,defaultActiveIndex:o,placement:f="bottom-start",className:j}=S(w),{getLabel:k}=Y.useLabels(),y=e.useFloatingNodeId(),q=t.useRef([]),[l,g]=t.useState(o??null),[h,B]=t.useState(null),[N,T]=t.useState(b),n=p??N;t.useEffect(()=>{n||g(o??null)},[n,o]);const x=t.useCallback(i=>{p===void 0&&T(i),a==null||a(i)},[p,a]),U=e.useFloating({nodeId:y,open:n,placement:f,onOpenChange:x,middleware:[m.offset(Z),m.flip(),m.shift()],whileElementsMounted:V.autoUpdate}),{context:r,refs:s,x:_,y:L,strategy:M}=U,D=e.useInteractions([e.useClick(r),e.useRole(r,{role:"menu"}),e.useDismiss(r),e.useListNavigation(r,{listRef:q,activeIndex:l,onNavigate:g,loop:!0,selectedIndex:o??null,focusItemOnOpen:o!==null?!0:"auto"})]),W={open:n,setOpen:x,refs:s,listItemsRef:q,activeIndex:l,setActiveIndex:g,placement:f,content:h,setContent:B,divided:P,variant:u,...D},E=(I=s.reference.current)==null?void 0:I.getBoundingClientRect().width,A=t.useMemo(()=>{const i=s.reference.current;if(!i)return;const C=i.offsetParent;if(C)return C.getBoundingClientRect().width},[s.reference.current]);return c.jsxs(z.DropdownContext.Provider,{value:W,children:[F,c.jsx(e.FloatingPortal,{children:n&&c.jsx(e.FloatingFocusManager,{context:r,modal:v,visuallyHiddenDismiss:v?k("close"):!1,children:c.jsx("div",{...D.getFloatingProps({ref:s.setFloating,className:H.default(O.default["tedi-dropdown"],{[O.default[`tedi-dropdown--${u}`]]:u==="tree"},j),style:{position:M,left:_??0,top:L??0,width:G.resolveDropdownWidth(R,E,A)},role:"menu","aria-orientation":"vertical","aria-activedescendant":l!==null?`dropdown-item-${l}`:void 0}),"data-placement":f,"data-state":n?"open":"closed",children:h})})})]})};d.Trigger=Q.DropdownTrigger;d.Content=$.DropdownContent;d.Item=J.DropdownItem;d.Separator=K.DropdownSeparator;exports.Dropdown=d;
@@ -61,6 +61,15 @@ export interface DropdownProps extends BreakpointSupport<DropdownBreakpointProps
61
61
  * Change handler (fires for both modes)
62
62
  */
63
63
  onOpenChange?: (open: boolean) => void;
64
+ /**
65
+ * Index of the item that should be focused when the dropdown opens.
66
+ *
67
+ * Pass the index of the "current selection" so the user can arrow-key or
68
+ * Enter/Space to reconfirm without first pressing an arrow. Omit (or pass
69
+ * `undefined`) to keep the default behaviour — no item is pre-focused and
70
+ * the user has to press an arrow key to start navigating.
71
+ */
72
+ defaultActiveIndex?: number;
64
73
  className?: string;
65
74
  }
66
75
  export declare const Dropdown: {
@@ -1,114 +1,124 @@
1
- import { jsxs as U, jsx as m } from "react/jsx-runtime";
2
- import { useFloatingNodeId as $, useFloating as A, useInteractions as H, useClick as q, useRole as z, useDismiss as G, useListNavigation as J, FloatingPortal as K, FloatingFocusManager as Q } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
3
- import V from "../../../../../external/classnames/index.es.js";
1
+ import { jsxs as U, jsx as f } from "react/jsx-runtime";
2
+ import { useFloatingNodeId as $, useFloating as H, useInteractions as q, useClick as z, useRole as G, useDismiss as J, useListNavigation as K, FloatingPortal as Q, FloatingFocusManager as V } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
3
+ import X from "../../../../../external/classnames/index.es.js";
4
4
  import e from "react";
5
- import F from "./dropdown.module.scss.es.js";
6
- import { DropdownContent as X } from "./dropdown-content/dropdown-content.es.js";
7
- import { DropdownContext as Y } from "./dropdown-context.es.js";
8
- import { resolveDropdownWidth as Z } from "./dropdown-helpers.es.js";
9
- import { DropdownItem as ee } from "./dropdown-item/dropdown-item.es.js";
10
- import { DropdownSeparator as te } from "./dropdown-separator/dropdown-separator.es.js";
11
- import { DropdownTrigger as oe } from "./dropdown-trigger/dropdown-trigger.es.js";
12
- import { autoUpdate as ne } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
13
- import { offset as re, flip as ie, shift as se } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
14
- import { useBreakpointProps as ae } from "../../../helpers/hooks/use-breakpoint-props.es.js";
15
- import { useLabels as le } from "../../../providers/label-provider/use-labels.es.js";
16
- const de = 4, a = (p) => {
17
- var D;
18
- const { getCurrentBreakpointProps: I } = ae(p.defaultServerBreakpoint), {
19
- children: O,
20
- modal: f = !1,
5
+ import x from "./dropdown.module.scss.es.js";
6
+ import { DropdownContent as Y } from "./dropdown-content/dropdown-content.es.js";
7
+ import { DropdownContext as Z } from "./dropdown-context.es.js";
8
+ import { resolveDropdownWidth as ee } from "./dropdown-helpers.es.js";
9
+ import { DropdownItem as te } from "./dropdown-item/dropdown-item.es.js";
10
+ import { DropdownSeparator as oe } from "./dropdown-separator/dropdown-separator.es.js";
11
+ import { DropdownTrigger as ne } from "./dropdown-trigger/dropdown-trigger.es.js";
12
+ import { autoUpdate as re } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
13
+ import { offset as ie, flip as se, shift as ae } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
14
+ import { useBreakpointProps as le } from "../../../helpers/hooks/use-breakpoint-props.es.js";
15
+ import { useLabels as de } from "../../../providers/label-provider/use-labels.es.js";
16
+ const ce = 4, l = (p) => {
17
+ var I;
18
+ const { getCurrentBreakpointProps: C } = le(p.defaultServerBreakpoint), {
19
+ children: F,
20
+ modal: g = !1,
21
21
  divided: R = !1,
22
- width: x = "auto",
23
- variant: l = "default",
24
- open: d,
25
- defaultOpen: N = !1,
26
- onOpenChange: r,
27
- placement: c = "bottom-start",
28
- className: P
29
- } = I(p), { getLabel: S } = le(), k = $(), u = e.useRef([]), [i, g] = e.useState(null), [v, y] = e.useState(null), [B, b] = e.useState(N), s = d ?? B, w = e.useCallback(
30
- (n) => {
31
- d === void 0 && b(n), r == null || r(n);
22
+ width: N = "auto",
23
+ variant: d = "default",
24
+ open: c,
25
+ defaultOpen: P = !1,
26
+ onOpenChange: s,
27
+ defaultActiveIndex: o,
28
+ placement: u = "bottom-start",
29
+ className: S
30
+ } = C(p), { getLabel: k } = de(), y = $(), v = e.useRef([]), [a, m] = e.useState(o ?? null), [w, B] = e.useState(null), [b, W] = e.useState(P), t = c ?? b;
31
+ e.useEffect(() => {
32
+ t || m(o ?? null);
33
+ }, [t, o]);
34
+ const h = e.useCallback(
35
+ (i) => {
36
+ c === void 0 && W(i), s == null || s(i);
32
37
  },
33
- [d, r]
34
- ), W = A({
35
- nodeId: k,
36
- open: s,
37
- placement: c,
38
- onOpenChange: w,
39
- middleware: [re(de), ie(), se()],
40
- whileElementsMounted: ne
41
- }), { context: t, refs: o, x: L, y: M, strategy: T } = W, h = H([
42
- q(t),
43
- z(t, { role: "menu" }),
44
- G(t),
45
- J(t, {
46
- listRef: u,
47
- activeIndex: i,
48
- onNavigate: g,
49
- loop: !0
38
+ [c, s]
39
+ ), E = H({
40
+ nodeId: y,
41
+ open: t,
42
+ placement: u,
43
+ onOpenChange: h,
44
+ middleware: [ie(ce), se(), ae()],
45
+ whileElementsMounted: re
46
+ }), { context: n, refs: r, x: L, y: M, strategy: T } = E, D = q([
47
+ z(n),
48
+ G(n, { role: "menu" }),
49
+ J(n),
50
+ K(n, {
51
+ listRef: v,
52
+ activeIndex: a,
53
+ onNavigate: m,
54
+ loop: !0,
55
+ // When the caller passes `defaultActiveIndex`, treat that item as the
56
+ // current selection and force focus to land on it when the dropdown
57
+ // opens — regardless of whether it was opened via click or keyboard.
58
+ selectedIndex: o ?? null,
59
+ focusItemOnOpen: o !== null ? !0 : "auto"
50
60
  })
51
61
  ]), _ = {
52
- open: s,
53
- setOpen: w,
54
- refs: o,
55
- listItemsRef: u,
56
- activeIndex: i,
57
- setActiveIndex: g,
58
- placement: c,
59
- content: v,
60
- setContent: y,
62
+ open: t,
63
+ setOpen: h,
64
+ refs: r,
65
+ listItemsRef: v,
66
+ activeIndex: a,
67
+ setActiveIndex: m,
68
+ placement: u,
69
+ content: w,
70
+ setContent: B,
61
71
  divided: R,
62
- variant: l,
63
- ...h
64
- }, j = (D = o.reference.current) == null ? void 0 : D.getBoundingClientRect().width, E = e.useMemo(() => {
65
- const n = o.reference.current;
66
- if (!n) return;
67
- const C = n.offsetParent;
68
- if (C)
69
- return C.getBoundingClientRect().width;
70
- }, [o.reference.current]);
71
- return /* @__PURE__ */ U(Y.Provider, { value: _, children: [
72
- O,
73
- /* @__PURE__ */ m(K, { children: s && /* @__PURE__ */ m(
74
- Q,
72
+ variant: d,
73
+ ...D
74
+ }, j = (I = r.reference.current) == null ? void 0 : I.getBoundingClientRect().width, A = e.useMemo(() => {
75
+ const i = r.reference.current;
76
+ if (!i) return;
77
+ const O = i.offsetParent;
78
+ if (O)
79
+ return O.getBoundingClientRect().width;
80
+ }, [r.reference.current]);
81
+ return /* @__PURE__ */ U(Z.Provider, { value: _, children: [
82
+ F,
83
+ /* @__PURE__ */ f(Q, { children: t && /* @__PURE__ */ f(
84
+ V,
75
85
  {
76
- context: t,
77
- modal: f,
78
- visuallyHiddenDismiss: f ? S("close") : !1,
79
- children: /* @__PURE__ */ m(
86
+ context: n,
87
+ modal: g,
88
+ visuallyHiddenDismiss: g ? k("close") : !1,
89
+ children: /* @__PURE__ */ f(
80
90
  "div",
81
91
  {
82
- ...h.getFloatingProps({
83
- ref: o.setFloating,
84
- className: V(
85
- F["tedi-dropdown"],
86
- { [F[`tedi-dropdown--${l}`]]: l === "tree" },
87
- P
92
+ ...D.getFloatingProps({
93
+ ref: r.setFloating,
94
+ className: X(
95
+ x["tedi-dropdown"],
96
+ { [x[`tedi-dropdown--${d}`]]: d === "tree" },
97
+ S
88
98
  ),
89
99
  style: {
90
100
  position: T,
91
101
  left: L ?? 0,
92
102
  top: M ?? 0,
93
- width: Z(x, j, E)
103
+ width: ee(N, j, A)
94
104
  },
95
105
  role: "menu",
96
106
  "aria-orientation": "vertical",
97
- "aria-activedescendant": i !== null ? `dropdown-item-${i}` : void 0
107
+ "aria-activedescendant": a !== null ? `dropdown-item-${a}` : void 0
98
108
  }),
99
- "data-placement": c,
100
- "data-state": s ? "open" : "closed",
101
- children: v
109
+ "data-placement": u,
110
+ "data-state": t ? "open" : "closed",
111
+ children: w
102
112
  }
103
113
  )
104
114
  }
105
115
  ) })
106
116
  ] });
107
117
  };
108
- a.Trigger = oe;
109
- a.Content = X;
110
- a.Item = ee;
111
- a.Separator = te;
118
+ l.Trigger = ne;
119
+ l.Content = Y;
120
+ l.Item = te;
121
+ l.Separator = oe;
112
122
  export {
113
- a as Dropdown
123
+ l as Dropdown
114
124
  };
@@ -40,6 +40,8 @@ export * from './components/form/choice-group';
40
40
  export * from './components/form/file-upload/file-upload';
41
41
  export * from './components/form/file-dropzone/file-dropzone';
42
42
  export * from './components/form/select/select';
43
+ export * from './components/form/time-field/time-field';
44
+ export * from './components/form/time-picker/time-picker';
43
45
  export * from './components/form/checkbox/checkbox';
44
46
  export * from './components/form/slider/slider';
45
47
  export * from './components/form/date-field/date-field';