@tedi-design-system/react 19.2.0-rc.6 → 19.2.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 (98) hide show
  1. package/bundle-stats.html +1 -1
  2. package/component.manifest.json +8 -8
  3. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
  4. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
  5. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  6. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
  7. package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
  8. package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
  9. package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
  10. package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
  11. package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  12. package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
  13. package/external/prop-types/external/react-is/index.cjs.js +1 -1
  14. package/external/prop-types/external/react-is/index.es.js +1 -1
  15. package/index.css +1 -1
  16. package/package.json +1 -1
  17. package/src/community/components/map-components/map-layer/map-layer.cjs.js +1 -1
  18. package/src/community/components/map-components/map-layer/map-layer.es.js +1 -1
  19. package/src/tedi/components/content/label/label.cjs.js +1 -1
  20. package/src/tedi/components/content/label/label.d.ts +22 -0
  21. package/src/tedi/components/content/label/label.es.js +30 -28
  22. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.cjs.js +1 -0
  23. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.d.ts +20 -0
  24. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.es.js +5 -0
  25. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.cjs.js +1 -0
  26. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.d.ts +72 -0
  27. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.es.js +124 -0
  28. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.cjs.js +1 -0
  29. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.es.js +13 -0
  30. package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
  31. package/src/tedi/components/form/checkbox/checkbox.d.ts +8 -2
  32. package/src/tedi/components/form/checkbox/checkbox.es.js +146 -108
  33. package/src/tedi/components/form/checkbox/checkbox.module.scss.cjs.js +1 -1
  34. package/src/tedi/components/form/checkbox/checkbox.module.scss.es.js +11 -3
  35. package/src/tedi/components/form/checkbox/index.cjs.js +1 -0
  36. package/src/tedi/components/form/checkbox/index.d.ts +11 -0
  37. package/src/tedi/components/form/checkbox/index.es.js +7 -0
  38. package/src/tedi/components/form/choice-group/choice-group.cjs.js +1 -1
  39. package/src/tedi/components/form/choice-group/choice-group.d.ts +11 -0
  40. package/src/tedi/components/form/choice-group/choice-group.es.js +80 -69
  41. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
  42. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +15 -15
  43. package/src/tedi/components/form/choice-input.types.d.ts +46 -8
  44. package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
  45. package/src/tedi/components/form/date-field/date-field.d.ts +5 -0
  46. package/src/tedi/components/form/date-field/date-field.es.js +187 -184
  47. package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
  48. package/src/tedi/components/form/date-time-field/date-time-field.d.ts +5 -0
  49. package/src/tedi/components/form/date-time-field/date-time-field.es.js +103 -101
  50. package/src/tedi/components/form/form-label/form-label.cjs.js +1 -1
  51. package/src/tedi/components/form/form-label/form-label.d.ts +9 -0
  52. package/src/tedi/components/form/form-label/form-label.es.js +15 -14
  53. package/src/tedi/components/form/multi-value-field/multi-value-field.cjs.js +1 -1
  54. package/src/tedi/components/form/multi-value-field/multi-value-field.d.ts +7 -0
  55. package/src/tedi/components/form/multi-value-field/multi-value-field.es.js +41 -40
  56. package/src/tedi/components/form/number-field/number-field.cjs.js +1 -1
  57. package/src/tedi/components/form/number-field/number-field.es.js +54 -43
  58. package/src/tedi/components/form/radio/index.cjs.js +1 -0
  59. package/src/tedi/components/form/radio/index.d.ts +11 -0
  60. package/src/tedi/components/form/radio/index.es.js +7 -0
  61. package/src/tedi/components/form/radio/radio-group/radio-group-context.cjs.js +1 -0
  62. package/src/tedi/components/form/radio/radio-group/radio-group-context.d.ts +21 -0
  63. package/src/tedi/components/form/radio/radio-group/radio-group-context.es.js +5 -0
  64. package/src/tedi/components/form/radio/radio-group/radio-group.cjs.js +1 -0
  65. package/src/tedi/components/form/radio/radio-group/radio-group.d.ts +56 -0
  66. package/src/tedi/components/form/radio/radio-group/radio-group.es.js +78 -0
  67. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.cjs.js +1 -0
  68. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.es.js +13 -0
  69. package/src/tedi/components/form/radio/radio.cjs.js +1 -1
  70. package/src/tedi/components/form/radio/radio.d.ts +7 -2
  71. package/src/tedi/components/form/radio/radio.es.js +117 -77
  72. package/src/tedi/components/form/radio/radio.module.scss.cjs.js +1 -1
  73. package/src/tedi/components/form/radio/radio.module.scss.es.js +11 -3
  74. package/src/tedi/components/form/select/select.cjs.js +1 -1
  75. package/src/tedi/components/form/select/select.es.js +79 -77
  76. package/src/tedi/components/form/slider/slider.cjs.js +1 -1
  77. package/src/tedi/components/form/slider/slider.d.ts +7 -0
  78. package/src/tedi/components/form/slider/slider.es.js +48 -47
  79. package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
  80. package/src/tedi/components/form/textfield/textfield.es.js +72 -61
  81. package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
  82. package/src/tedi/components/form/time-field/time-field.d.ts +5 -0
  83. package/src/tedi/components/form/time-field/time-field.es.js +87 -85
  84. package/src/tedi/components/form/toggle/toggle.cjs.js +1 -1
  85. package/src/tedi/components/form/toggle/toggle.d.ts +7 -0
  86. package/src/tedi/components/form/toggle/toggle.es.js +26 -24
  87. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
  88. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.d.ts +12 -0
  89. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +57 -27
  90. package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
  91. package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +17 -0
  92. package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +65 -51
  93. package/src/tedi/index.d.ts +2 -2
  94. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  95. package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
  96. package/src/tedi/providers/label-provider/labels-map.es.js +25 -11
  97. package/tedi.cjs.js +1 -1
  98. package/tedi.es.js +298 -294
@@ -10,7 +10,7 @@ import { useBreakpointProps as V } from "../../../../../helpers/hooks/use-breakp
10
10
  import { Col as q } from "../../../../layout/grid/col.es.js";
11
11
  const te = (n) => {
12
12
  const { getCurrentBreakpointProps: x } = V(n.defaultServerBreakpoint), {
13
- id: o,
13
+ id: t,
14
14
  label: C,
15
15
  value: c,
16
16
  className: $,
@@ -19,7 +19,7 @@ const te = (n) => {
19
19
  colProps: B = u === "column" ? { width: 12 } : { width: "auto" },
20
20
  onChange: p,
21
21
  hideLabel: I,
22
- helper: t,
22
+ helper: i,
23
23
  tooltip: j,
24
24
  type: h = "radio",
25
25
  variant: l = "default",
@@ -27,8 +27,8 @@ const te = (n) => {
27
27
  layout: E,
28
28
  showIndicator: k,
29
29
  justifyContent: b = "start"
30
- } = x(n), { currentValue: a, name: y, onChange: f, inputType: F } = R.useContext(S), s = Array.isArray(a) ? a.includes(c) : c === a, G = a === void 0 ? n.defaultChecked : s, N = (i, g) => {
31
- f == null || f(i, g), p == null || p(i, g);
30
+ } = x(n), { currentValue: a, name: y, onChange: f, inputType: F } = R.useContext(S), s = Array.isArray(a) ? a.includes(c) : c === a, G = a === void 0 ? n.defaultChecked : s, N = (o, g) => {
31
+ f == null || f(o, g), p == null || p(o, g);
32
32
  }, P = m(
33
33
  e[`tedi-choice-group-item--${E === "separated" ? "separated" : "segmented"}`],
34
34
  u && e[`tedi-choice-group-item--${u}`]
@@ -42,13 +42,13 @@ const te = (n) => {
42
42
  { [e["tedi-choice-group-item--checked"]]: s },
43
43
  { [`justify-content-${b}`]: b }
44
44
  );
45
- return /* @__PURE__ */ d(q, { ...B, className: P, children: /* @__PURE__ */ d("div", { className: A, onClick: (i) => {
45
+ return /* @__PURE__ */ d(q, { ...B, className: P, children: /* @__PURE__ */ d("div", { className: A, onClick: (o) => {
46
46
  var _;
47
- r || l !== "card" || i.target.closest("input, label") || (_ = document.getElementById(o)) == null || _.click();
47
+ r || l !== "card" || o.target.closest("input, label") || t && ((_ = document.getElementById(t)) == null || _.click());
48
48
  }, "aria-disabled": r || void 0, children: l === "default" || k ? /* @__PURE__ */ d(
49
49
  h === "radio" ? L : T,
50
50
  {
51
- id: o,
51
+ id: t,
52
52
  label: C,
53
53
  value: c,
54
54
  name: y,
@@ -58,7 +58,7 @@ const te = (n) => {
58
58
  defaultChecked: G,
59
59
  onChange: N,
60
60
  hideLabel: I,
61
- helper: t ? { ...t, className: m(e["tedi-choice-group-item__feedback-text"], t.className) } : void 0,
61
+ helper: i ? { ...i, className: m(e["tedi-choice-group-item__feedback-text"], i.className) } : void 0,
62
62
  tooltip: j,
63
63
  "data-testid": "choice-group-item-indicator"
64
64
  }
@@ -66,26 +66,26 @@ const te = (n) => {
66
66
  /* @__PURE__ */ d(
67
67
  "input",
68
68
  {
69
- id: o,
69
+ id: t,
70
70
  value: c,
71
71
  name: y,
72
72
  type: F,
73
73
  disabled: r,
74
74
  checked: s,
75
75
  defaultChecked: a === void 0 ? n.defaultChecked : void 0,
76
- onChange: (i) => {
77
- N(c, i.target.checked);
76
+ onChange: (o) => {
77
+ N(c, o.target.checked);
78
78
  },
79
79
  className: "visually-hidden"
80
80
  }
81
81
  ),
82
- /* @__PURE__ */ v("label", { htmlFor: o, className: e["tedi-choice-group-item__label"], children: [
82
+ /* @__PURE__ */ v("label", { htmlFor: t, className: e["tedi-choice-group-item__label"], children: [
83
83
  C,
84
- t && /* @__PURE__ */ d(
84
+ i && /* @__PURE__ */ d(
85
85
  H,
86
86
  {
87
- ...t,
88
- id: t.id ?? `${o}-helper`,
87
+ ...i,
88
+ id: i.id ?? `${t}-helper`,
89
89
  className: e["tedi-choice-group-item__feedback-text"]
90
90
  }
91
91
  )
@@ -1,9 +1,12 @@
1
1
  import { FeedbackTextProps } from './feedback-text/feedback-text';
2
- export interface ChoiceInputProps {
2
+ import { FormLabelProps } from './form-label/form-label';
3
+ export type ChoiceInputVariant = 'default' | 'card';
4
+ export type ChoiceInputCardVariant = 'primary' | 'secondary';
5
+ interface ChoiceInputBaseProps {
3
6
  /**
4
- * ID property
7
+ * ID property. When omitted a stable id is generated (useful inside `Radio.Group` / `Checkbox.Group`).
5
8
  */
6
- id: string;
9
+ id?: string;
7
10
  /**
8
11
  * Label text
9
12
  */
@@ -17,9 +20,22 @@ export interface ChoiceInputProps {
17
20
  */
18
21
  value: string;
19
22
  /**
20
- * name of the input
23
+ * name of the input. Provided automatically when rendered inside `Radio.Group` / `Checkbox.Group`.
21
24
  */
22
- name: string;
25
+ name?: string;
26
+ /**
27
+ * Card colour variant. Only applies when `variant="card"`.
28
+ * @default primary
29
+ */
30
+ cardVariant?: ChoiceInputCardVariant;
31
+ /**
32
+ * Secondary description text shown under the label. Primarily used with `variant="card"`.
33
+ */
34
+ description?: React.ReactNode;
35
+ /**
36
+ * Leading icon (Material icon name) shown before the label. Primarily used with `variant="card"`.
37
+ */
38
+ icon?: string;
23
39
  /**
24
40
  * is the label hidden
25
41
  */
@@ -49,10 +65,11 @@ export interface ChoiceInputProps {
49
65
  */
50
66
  hover?: boolean;
51
67
  /**
52
- * Provide content for tooltip. Accepts rich content (e.g. bold text, links),
53
- * not just a plain string.
68
+ * Additional props forwarded to the underlying `Label` component.
69
+ * Use `modifiers` to control how the label text wraps or breaks
70
+ * (e.g. `{ modifiers: 'nowrap' }`).
54
71
  */
55
- tooltip?: React.ReactNode;
72
+ labelProps?: FormLabelProps['labelProps'];
56
73
  /**
57
74
  * Input size
58
75
  */
@@ -66,3 +83,24 @@ export interface ChoiceInputProps {
66
83
  */
67
84
  required?: boolean;
68
85
  }
86
+ export interface ChoiceInputProps extends ChoiceInputBaseProps {
87
+ /**
88
+ * Visual variant.
89
+ * - `default` — standard indicator + label.
90
+ * - `card` — the whole control renders as a selectable card (indicator, label, optional icon/description).
91
+ * @default default
92
+ */
93
+ variant?: ChoiceInputVariant;
94
+ /**
95
+ * Provide content for tooltip. Accepts rich content (e.g. bold text, links),
96
+ * not just a plain string.
97
+ *
98
+ * Mutually exclusive with `variant="card"` — the card carries supplementary
99
+ * content through its `description` slot instead. Passing both logs a dev-time
100
+ * warning and the tooltip is ignored. (This is enforced at runtime rather than
101
+ * in the types: a discriminated union would reject the dynamic prop-spreading
102
+ * that `Checkbox.Group` / `Radio.Group` / `Table` rely on.)
103
+ */
104
+ tooltip?: React.ReactNode;
105
+ }
106
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),A=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),I=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),At=require("../../content/calendar/calendar.cjs.js"),Ft=require("../multi-value-field/multi-value-field.cjs.js"),kt=require("../textfield/textfield.cjs.js"),D=require("./date-field.module.scss.cjs.js"),v=require("./date-field-helpers.cjs.js"),vt=require("./date-picker-modal/date-picker-modal.cjs.js"),Pt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),wt=require("../../../providers/label-provider/use-labels.cjs.js"),Nt=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),pe=require("../../../helpers/hooks/use-breakpoint.cjs.js"),Et=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),z=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Ot=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),He=a.forwardRef((P,w)=>{const{getCurrentBreakpointProps:Ye}=Pt.useBreakpointProps(P.defaultServerBreakpoint),{getLabel:X}=wt.useLabels(),{useNativePicker:Ue=!1,enableCalendar:g=!0,calendarTrigger:T="button",numberOfMonths:J,clearable:ge=!0}=Ye(P),{id:he,mode:s="single",label:be,selected:j,onSelect:i,disabled:N,disabledMatchers:E,placeholder:We,className:Ge,formatDate:c,required:S,showOutsideDays:ye=!0,parseDate:K,monthYearSelectType:De,minYear:_e,maxYear:xe,dayStatus:Me,tagsDirection:ze,showNavigation:Ce=!0,selectionLevel:O="days",initialView:L,locale:Ae=Nt.et,localeCode:$="et-EE",initialMonth:H,closeOnSelect:Xe,footer:Fe,defaultValue:Y,minDate:Q,maxDate:Z,disablePast:ke,disableFuture:ve,shouldDisableMonth:ee,shouldDisableYear:te,readOnly:R,availableDays:Pe,inputProps:n,modal:re=!1,modalProps:Je,modalTitle:Ke,disabledDateErrorMessage:Qe=X("dateField.disabledDateError"),invalidDateErrorMessage:Ze=X("dateField.invalidDateError"),useNativePicker:Rt,enableCalendar:Vt,calendarTrigger:qt,numberOfMonths:Bt,defaultServerBreakpoint:It,sm:Tt,md:jt,lg:St,xl:Lt,xxl:$t,...we}=P,f=Ue&&s==="single",Ne=pe.default(P.defaultServerBreakpoint),F=pe.isBreakpointBelow(Ne,"md"),[et,h]=a.useState(j??Y),[b,V]=a.useState(!1),[ae,Ee]=a.useState(!1),[tt,Oe]=a.useState(L??O),[ie,_]=a.useState(""),[Re,m]=a.useState(!1),[Ve,U]=a.useState(!1),y=g&&!f&&!R&&(re===!0||typeof re=="string"&&pe.isBreakpointBelow(Ne,re)),qe=F&&!y&&typeof J=="number"&&J>1?1:J,{current:u}=a.useRef("selected"in P),o=u?j:et,ne=a.useRef(null),Be=a.useRef(null),rt=a.useCallback(e=>{ne.current=e,typeof w=="function"?w(e):w&&(w.current=e)},[w]),at=e=>{if(!e)return"";const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${l}`},it=f&&o instanceof Date?at(o):"",se=a.useCallback((e,t)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((r,l)=>r.getTime()-l.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:t??new Date,[]),[nt,oe]=a.useState(()=>se(o,H));a.useEffect(()=>{b||oe(se(o,H))},[o,H,b,se]),a.useEffect(()=>{b&&Oe(L??O)},[b,O,L]),a.useEffect(()=>{u&&h(j)},[j,u]);const x=a.useMemo(()=>new Intl.DateTimeFormat($,{day:"2-digit",month:"2-digit",year:"numeric"}),[$]),M=a.useCallback(e=>{if(!e)return"";if(e instanceof Date)return x.format(e);if(Array.isArray(e))return e.map(t=>x.format(t)).join(", ");if(e.from){const t=x.format(e.from);return e.to?`${t} – ${x.format(e.to)}`:t}return""},[x]),le=Xe??s==="single",Ie=s==="multiple"&&Array.isArray(o)?o.map((e,t)=>({id:t,label:c?c(e):M(e),date:e})):[],W=a.useMemo(()=>{const e=[];return N&&(Array.isArray(N)?e.push(...N):e.push(N)),E&&(Array.isArray(E)?e.push(...E):e.push(E)),Q&&e.push({before:Q}),Z&&e.push({after:Z}),ke&&e.push({before:new Date}),ve&&e.push({after:new Date}),ee&&e.push(t=>ee(t)),te&&e.push(t=>te(t)),e},[N,E,Q,Z,ke,ve,ee,te]),k=a.useCallback(e=>Ot.dateMatchModifiers(e,W),[W]),st=(e,t,r,l)=>{const d=s==="range"?v.resolveRangeSelection(e,o,t):e;if(m(!1),u||h(d),i==null||i(d,t,r,l),d){const C=c?c(d):M(d);_(C)}else _("");le&&V(!1)},ot=e=>{if(k(e))return;const t=s==="range"?{from:e,to:void 0}:s==="multiple"?[...Array.isArray(o)?o:[],e]:e;m(!1),u||h(t),i==null||i(t,e,{},{});const r=c?c(t):M(t);_(r),le&&V(!1)},lt=a.useMemo(()=>{const e=v.getLocaleDateParts(x),t=new RegExp(`^${v.buildDateRegexSource(e)}$`),{fieldOrder:r}=e;return l=>{const d=l.match(t);if(!d)return;const C={};r.forEach((Mt,Ct)=>{C[Mt]=Number(d[Ct+1])});const{day:ce,month:fe,year:me}=C;if(ce===void 0||fe===void 0||me===void 0)return;const B=new Date(me,fe-1,ce);if(!(isNaN(B.getTime())||B.getFullYear()!==me||B.getMonth()!==fe-1||B.getDate()!==ce))return B}},[x]),Te=e=>(K??(s==="single"?lt:()=>{}))(e),je=e=>s==="single"&&e instanceof Date||s==="multiple"&&Array.isArray(e)||s==="range"&&!!e&&!Array.isArray(e)&&"from"in e,dt=e=>{if(_(e),U(!1),e.trim()===""){m(!1),o!==void 0&&(u||h(void 0),i==null||i(void 0,void 0,{},{}));return}const t=Te(e);if(!je(t)){m(!1);return}const l=t&&!Array.isArray(t)&&"from"in t?t:null;if(t instanceof Date&&k(t)||Array.isArray(t)&&t.some(C=>C instanceof Date&&k(C))||!!l&&(l.from&&k(l.from)||l.to&&k(l.to))){m(!0);return}m(!1),u||h(t),i==null||i(t,t,{},{}),t instanceof Date&&oe(t),le&&V(!1)},ut=()=>{if(ie.trim()===""){U(!1);return}if(!K&&s!=="single"){U(!1);return}U(!je(Te(ie)))};a.useEffect(()=>{if(u){const e=c?c(o):M(o);_(e)}},[o,u,c,M]),a.useEffect(()=>{if(!u&&Y){const e=c?c(Y):M(Y);_(e)}},[]);const ct=A.useFloating({open:b,onOpenChange:V,placement:T==="input"?"bottom-start":"bottom-end",middleware:[z.offset(v.CALENDAR_POPOVER_OFFSET),z.flip(),z.shift({padding:v.CALENDAR_POPOVER_PADDING}),z.size({padding:v.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){const r=t.floating;if(r.style.width="",r.style.maxWidth="",r.style.overflowX="",F)return;r.style.width="max-content",r.getBoundingClientRect().width>e&&(r.style.width="min-content",r.style.maxWidth=`${e}px`)}})],whileElementsMounted:Et.autoUpdate}),{refs:q,context:G,x:ft,y:mt,strategy:pt}=ct,gt=A.useClick(G),Se=A.useInteractions([...g&&!f&&T==="input"&&!y?[gt]:[],A.useDismiss(G,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),A.useRole(G,{role:"dialog"})]);a.useEffect(()=>{var t,r;const e=s==="multiple"?((t=Be.current)==null?void 0:t.wrapper)??null:((r=ne.current)==null?void 0:r.input)??null;q.setPositionReference(e??q.reference.current)},[s,b,q]);const ht=()=>{var t;const e=(t=ne.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function")try{e.showPicker();return}catch{}e.focus()}},de=()=>{!g||R||(f?ht():y?Ee(!0):V(e=>!e))},bt=e=>{if(m(!1),u||h(e),i==null||i(e,e,{},{}),e){const t=c?c(e):M(e);_(t)}else _("")},yt=e=>{if(!e){m(!1),u||h(void 0),i==null||i(void 0,void 0,{},{});return}const[t,r,l]=e.split("-").map(Number);if(!t||!r||!l)return;const d=new Date(t,r-1,l);if(!Number.isNaN(d.getTime())){if(k(d)){m(!0);return}m(!1),u||h(d),i==null||i(d,d,{},{})}},Dt=Se.getReferenceProps(y&&T==="input"?{onClick:()=>de()}:void 0),{role:Ht,"aria-expanded":Yt,"aria-haspopup":Ut,"aria-controls":_t,...xt}=Dt,Le=y?void 0:_t,ue=X("dateField.openCalendar"),$e={"aria-label":ue,"aria-expanded":y?ae:b,"aria-haspopup":"dialog","aria-controls":Le};return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:I.default(D.default["tedi-date-field__container"],Ge),...xt,ref:q.setReference,children:s==="multiple"?p.jsx(Ft.MultiValueField,{...n,ref:Be,id:he,label:be,tagsDirection:ze,values:Ie.map(e=>e.label),icon:"calendar_today",onIconClick:de,iconButtonProps:g?$e:{"aria-label":ue},isClearable:ge,required:S,onChange:e=>{if(!Array.isArray(o))return;const t=Ie.filter(r=>e.includes(r.label)).map(r=>r.date);u||h(t),i==null||i(t,{},{},{})},className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__icon--disabled"]]:!g||R})}):p.jsx(kt.TextField,{...n,ref:rt,id:he,label:be,readOnly:R,value:f?it:ie,placeholder:We,icon:"calendar_today",isClearable:ge,onIconClick:de,iconButtonProps:g&&!f?$e:{"aria-label":ue},onChange:e=>f?yt(e):dt(e),onBlur:e=>{var t;f||ut(),(t=n==null?void 0:n.onBlur)==null||t.call(n,e)},required:S,invalid:Re||Ve||(n==null?void 0:n.invalid),helper:(()=>{const e=n==null?void 0:n.helper,t=Re?Qe:Ve?Ze:null,r=t?{text:t,type:"error"}:null;return r?e?Array.isArray(e)?[...e,r]:[e,r]:r:e})(),className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__textfield--disabled"]]:n==null?void 0:n.disabled,[D.default["tedi-date-field__icon--disabled"]]:!g||R}),input:{...n==null?void 0:n.input,...!K&&s!=="single"&&{readOnly:!0},...f&&{type:"date"},...g&&!f&&T==="input"?{role:"combobox","aria-haspopup":"dialog","aria-expanded":y?ae:b,"aria-controls":Le}:{}}})}),y&&p.jsx(vt.DatePickerModal,{open:ae,onOpenChange:Ee,value:o,onConfirm:bt,mode:s,numberOfMonths:qe,locale:Ae,localeCode:$,showOutsideDays:ye,disabledMatchers:W,required:S,availableDays:Pe,footer:Fe,monthYearSelectType:De,minYear:_e,maxYear:xe,dayStatus:Me,showNavigation:Ce,selectionLevel:O,initialView:L,initialMonth:H,modalProps:Je,...we,title:Ke}),g&&!f&&!y&&p.jsx(A.FloatingPortal,{children:b&&p.jsx(A.FloatingFocusManager,{context:G,modal:!1,initialFocus:-1,children:p.jsx("div",{ref:q.setFloating,className:I.default({[D.default["tedi-date-field__calendar-popover--fullwidth"]]:F}),...Se.getFloatingProps({style:{position:pt,top:mt??0,left:F?0:ft??0,right:F?0:void 0}}),children:p.jsx(At.Calendar,{...we,numberOfMonths:qe,view:tt,selectionLevel:O,currentMonth:nt,setCurrentMonth:oe,setView:Oe,mode:s,value:o,locale:Ae,localeCode:$,showOutsideDays:ye,disabledMatchers:W,required:S,availableDays:Pe,footer:Fe,monthYearSelectType:De,minYear:_e,maxYear:xe,dayStatus:Me,showNavigation:Ce,handleSelect:st,applyValue:ot,className:I.default(D.default["tedi-date-field__calendar"],{[D.default["tedi-date-field__calendar--fullwidth"]]:F})})})})})]})});He.displayName="DateField";exports.DateField=He;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),A=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),I=require("../../../../../external/classnames/index.cjs.js"),i=require("react"),Ft=require("../../content/calendar/calendar.cjs.js"),kt=require("../multi-value-field/multi-value-field.cjs.js"),vt=require("../textfield/textfield.cjs.js"),D=require("./date-field.module.scss.cjs.js"),v=require("./date-field-helpers.cjs.js"),Pt=require("./date-picker-modal/date-picker-modal.cjs.js"),wt=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),Nt=require("../../../providers/label-provider/use-labels.cjs.js"),Et=require("../../../../../external/react-day-picker/dist/esm/locale/et.cjs.js"),pe=require("../../../helpers/hooks/use-breakpoint.cjs.js"),Ot=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),z=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),Rt=require("../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.cjs.js"),Ye=i.forwardRef((P,w)=>{const{getCurrentBreakpointProps:Ue}=wt.useBreakpointProps(P.defaultServerBreakpoint),{getLabel:X}=Nt.useLabels(),{useNativePicker:We=!1,enableCalendar:g=!0,calendarTrigger:T="button",numberOfMonths:J,clearable:ge=!0}=Ue(P),{id:he,mode:s="single",label:be,labelProps:ye,selected:j,onSelect:n,disabled:N,disabledMatchers:E,placeholder:Ge,className:ze,formatDate:c,required:S,showOutsideDays:De=!0,parseDate:K,monthYearSelectType:_e,minYear:xe,maxYear:Me,dayStatus:Ce,tagsDirection:Xe,showNavigation:Ae=!0,selectionLevel:O="days",initialView:L,locale:Fe=Et.et,localeCode:$="et-EE",initialMonth:H,closeOnSelect:Je,footer:ke,defaultValue:Y,minDate:Q,maxDate:Z,disablePast:ve,disableFuture:Pe,shouldDisableMonth:ee,shouldDisableYear:te,readOnly:R,availableDays:we,inputProps:r,modal:ae=!1,modalProps:Ke,modalTitle:Qe,disabledDateErrorMessage:Ze=X("dateField.disabledDateError"),invalidDateErrorMessage:et=X("dateField.invalidDateError"),useNativePicker:Vt,enableCalendar:qt,calendarTrigger:Bt,numberOfMonths:It,defaultServerBreakpoint:Tt,sm:jt,md:St,lg:Lt,xl:$t,xxl:Ht,...Ne}=P,f=We&&s==="single",Ee=pe.default(P.defaultServerBreakpoint),F=pe.isBreakpointBelow(Ee,"md"),[tt,h]=i.useState(j??Y),[b,V]=i.useState(!1),[re,Oe]=i.useState(!1),[at,Re]=i.useState(L??O),[ie,_]=i.useState(""),[Ve,m]=i.useState(!1),[qe,U]=i.useState(!1),y=g&&!f&&!R&&(ae===!0||typeof ae=="string"&&pe.isBreakpointBelow(Ee,ae)),Be=F&&!y&&typeof J=="number"&&J>1?1:J,{current:u}=i.useRef("selected"in P),o=u?j:tt,ne=i.useRef(null),Ie=i.useRef(null),rt=i.useCallback(e=>{ne.current=e,typeof w=="function"?w(e):w&&(w.current=e)},[w]),it=e=>{if(!e)return"";const t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${t}-${a}-${l}`},nt=f&&o instanceof Date?it(o):"",se=i.useCallback((e,t)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((a,l)=>a.getTime()-l.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:t??new Date,[]),[st,oe]=i.useState(()=>se(o,H));i.useEffect(()=>{b||oe(se(o,H))},[o,H,b,se]),i.useEffect(()=>{b&&Re(L??O)},[b,O,L]),i.useEffect(()=>{u&&h(j)},[j,u]);const x=i.useMemo(()=>new Intl.DateTimeFormat($,{day:"2-digit",month:"2-digit",year:"numeric"}),[$]),M=i.useCallback(e=>{if(!e)return"";if(e instanceof Date)return x.format(e);if(Array.isArray(e))return e.map(t=>x.format(t)).join(", ");if(e.from){const t=x.format(e.from);return e.to?`${t} – ${x.format(e.to)}`:t}return""},[x]),le=Je??s==="single",Te=s==="multiple"&&Array.isArray(o)?o.map((e,t)=>({id:t,label:c?c(e):M(e),date:e})):[],W=i.useMemo(()=>{const e=[];return N&&(Array.isArray(N)?e.push(...N):e.push(N)),E&&(Array.isArray(E)?e.push(...E):e.push(E)),Q&&e.push({before:Q}),Z&&e.push({after:Z}),ve&&e.push({before:new Date}),Pe&&e.push({after:new Date}),ee&&e.push(t=>ee(t)),te&&e.push(t=>te(t)),e},[N,E,Q,Z,ve,Pe,ee,te]),k=i.useCallback(e=>Rt.dateMatchModifiers(e,W),[W]),ot=(e,t,a,l)=>{const d=s==="range"?v.resolveRangeSelection(e,o,t):e;if(m(!1),u||h(d),n==null||n(d,t,a,l),d){const C=c?c(d):M(d);_(C)}else _("");le&&V(!1)},lt=e=>{if(k(e))return;const t=s==="range"?{from:e,to:void 0}:s==="multiple"?[...Array.isArray(o)?o:[],e]:e;m(!1),u||h(t),n==null||n(t,e,{},{});const a=c?c(t):M(t);_(a),le&&V(!1)},dt=i.useMemo(()=>{const e=v.getLocaleDateParts(x),t=new RegExp(`^${v.buildDateRegexSource(e)}$`),{fieldOrder:a}=e;return l=>{const d=l.match(t);if(!d)return;const C={};a.forEach((Ct,At)=>{C[Ct]=Number(d[At+1])});const{day:ce,month:fe,year:me}=C;if(ce===void 0||fe===void 0||me===void 0)return;const B=new Date(me,fe-1,ce);if(!(isNaN(B.getTime())||B.getFullYear()!==me||B.getMonth()!==fe-1||B.getDate()!==ce))return B}},[x]),je=e=>(K??(s==="single"?dt:()=>{}))(e),Se=e=>s==="single"&&e instanceof Date||s==="multiple"&&Array.isArray(e)||s==="range"&&!!e&&!Array.isArray(e)&&"from"in e,ut=e=>{if(_(e),U(!1),e.trim()===""){m(!1),o!==void 0&&(u||h(void 0),n==null||n(void 0,void 0,{},{}));return}const t=je(e);if(!Se(t)){m(!1);return}const l=t&&!Array.isArray(t)&&"from"in t?t:null;if(t instanceof Date&&k(t)||Array.isArray(t)&&t.some(C=>C instanceof Date&&k(C))||!!l&&(l.from&&k(l.from)||l.to&&k(l.to))){m(!0);return}m(!1),u||h(t),n==null||n(t,t,{},{}),t instanceof Date&&oe(t),le&&V(!1)},ct=()=>{if(ie.trim()===""){U(!1);return}if(!K&&s!=="single"){U(!1);return}U(!Se(je(ie)))};i.useEffect(()=>{if(u){const e=c?c(o):M(o);_(e)}},[o,u,c,M]),i.useEffect(()=>{if(!u&&Y){const e=c?c(Y):M(Y);_(e)}},[]);const ft=A.useFloating({open:b,onOpenChange:V,placement:T==="input"?"bottom-start":"bottom-end",middleware:[z.offset(v.CALENDAR_POPOVER_OFFSET),z.flip(),z.shift({padding:v.CALENDAR_POPOVER_PADDING}),z.size({padding:v.CALENDAR_POPOVER_PADDING,apply({availableWidth:e,elements:t}){const a=t.floating;if(a.style.width="",a.style.maxWidth="",a.style.overflowX="",F)return;a.style.width="max-content",a.getBoundingClientRect().width>e&&(a.style.width="min-content",a.style.maxWidth=`${e}px`)}})],whileElementsMounted:Ot.autoUpdate}),{refs:q,context:G,x:mt,y:pt,strategy:gt}=ft,ht=A.useClick(G),Le=A.useInteractions([...g&&!f&&T==="input"&&!y?[ht]:[],A.useDismiss(G,{outsidePress:e=>{const t=e.target;return!(t!=null&&t.closest('[role="menu"], [role="listbox"]'))}}),A.useRole(G,{role:"dialog"})]);i.useEffect(()=>{var t,a;const e=s==="multiple"?((t=Ie.current)==null?void 0:t.wrapper)??null:((a=ne.current)==null?void 0:a.input)??null;q.setPositionReference(e??q.reference.current)},[s,b,q]);const bt=()=>{var t;const e=(t=ne.current)==null?void 0:t.input;if(e){if(typeof e.showPicker=="function")try{e.showPicker();return}catch{}e.focus()}},de=()=>{!g||R||(f?bt():y?Oe(!0):V(e=>!e))},yt=e=>{if(m(!1),u||h(e),n==null||n(e,e,{},{}),e){const t=c?c(e):M(e);_(t)}else _("")},Dt=e=>{if(!e){m(!1),u||h(void 0),n==null||n(void 0,void 0,{},{});return}const[t,a,l]=e.split("-").map(Number);if(!t||!a||!l)return;const d=new Date(t,a-1,l);if(!Number.isNaN(d.getTime())){if(k(d)){m(!0);return}m(!1),u||h(d),n==null||n(d,d,{},{})}},_t=Le.getReferenceProps(y&&T==="input"?{onClick:()=>de()}:void 0),{role:Yt,"aria-expanded":Ut,"aria-haspopup":Wt,"aria-controls":xt,...Mt}=_t,$e=y?void 0:xt,ue=X("dateField.openCalendar"),He={"aria-label":ue,"aria-expanded":y?re:b,"aria-haspopup":"dialog","aria-controls":$e};return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:I.default(D.default["tedi-date-field__container"],ze),...Mt,ref:q.setReference,children:s==="multiple"?p.jsx(kt.MultiValueField,{...r,ref:Ie,id:he,label:be,labelProps:ye??(r==null?void 0:r.labelProps),tagsDirection:Xe,values:Te.map(e=>e.label),icon:"calendar_today",onIconClick:de,iconButtonProps:g?He:{"aria-label":ue},isClearable:ge,required:S,onChange:e=>{if(!Array.isArray(o))return;const t=Te.filter(a=>e.includes(a.label)).map(a=>a.date);u||h(t),n==null||n(t,{},{},{})},className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__icon--disabled"]]:!g||R})}):p.jsx(vt.TextField,{...r,ref:rt,id:he,label:be,labelProps:ye??(r==null?void 0:r.labelProps),readOnly:R,value:f?nt:ie,placeholder:Ge,icon:"calendar_today",isClearable:ge,onIconClick:de,iconButtonProps:g&&!f?He:{"aria-label":ue},onChange:e=>f?Dt(e):ut(e),onBlur:e=>{var t;f||ct(),(t=r==null?void 0:r.onBlur)==null||t.call(r,e)},required:S,invalid:Ve||qe||(r==null?void 0:r.invalid),helper:(()=>{const e=r==null?void 0:r.helper,t=Ve?Ze:qe?et:null,a=t?{text:t,type:"error"}:null;return a?e?Array.isArray(e)?[...e,a]:[e,a]:a:e})(),className:I.default(D.default["tedi-date-field__textfield"],{[D.default["tedi-date-field__textfield--disabled"]]:r==null?void 0:r.disabled,[D.default["tedi-date-field__icon--disabled"]]:!g||R}),input:{...r==null?void 0:r.input,...!K&&s!=="single"&&{readOnly:!0},...f&&{type:"date"},...g&&!f&&T==="input"?{role:"combobox","aria-haspopup":"dialog","aria-expanded":y?re:b,"aria-controls":$e}:{}}})}),y&&p.jsx(Pt.DatePickerModal,{open:re,onOpenChange:Oe,value:o,onConfirm:yt,mode:s,numberOfMonths:Be,locale:Fe,localeCode:$,showOutsideDays:De,disabledMatchers:W,required:S,availableDays:we,footer:ke,monthYearSelectType:_e,minYear:xe,maxYear:Me,dayStatus:Ce,showNavigation:Ae,selectionLevel:O,initialView:L,initialMonth:H,modalProps:Ke,...Ne,title:Qe}),g&&!f&&!y&&p.jsx(A.FloatingPortal,{children:b&&p.jsx(A.FloatingFocusManager,{context:G,modal:!1,initialFocus:-1,children:p.jsx("div",{ref:q.setFloating,className:I.default({[D.default["tedi-date-field__calendar-popover--fullwidth"]]:F}),...Le.getFloatingProps({style:{position:gt,top:pt??0,left:F?0:mt??0,right:F?0:void 0}}),children:p.jsx(Ft.Calendar,{...Ne,numberOfMonths:Be,view:at,selectionLevel:O,currentMonth:st,setCurrentMonth:oe,setView:Re,mode:s,value:o,locale:Fe,localeCode:$,showOutsideDays:De,disabledMatchers:W,required:S,availableDays:we,footer:ke,monthYearSelectType:_e,minYear:xe,maxYear:Me,dayStatus:Ce,showNavigation:Ae,handleSelect:ot,applyValue:lt,className:I.default(D.default["tedi-date-field__calendar"],{[D.default["tedi-date-field__calendar--fullwidth"]]:F})})})})})]})});Ye.displayName="DateField";exports.DateField=Ye;
@@ -54,6 +54,11 @@ export interface DateFieldProps extends BreakpointSupport<DateFieldBreakpointPro
54
54
  * Field label. Required for accessibility.
55
55
  */
56
56
  label: string;
57
+ /**
58
+ * Props forwarded to the field's label (e.g. `{ modifiers: 'nowrap' }` to control
59
+ * how a long label wraps). Breakpoint keys are supported for responsive wrapping.
60
+ */
61
+ labelProps?: TextFieldProps['labelProps'];
57
62
  /**
58
63
  * Determines the selection mode of the calendar.
59
64
  * - `'single'` (default) – only one date can be selected. The `selected` prop should be a `Date` object or `undefined`.