impact-nova 2.5.7 → 2.5.9

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 (159) hide show
  1. package/dist/components/data/ag-grid-react/ag-grid.types.d.ts +2 -2
  2. package/dist/components/data/ag-grid-react/headers/components/date-filter-picker.d.ts +4 -2
  3. package/dist/components/data/ag-grid-react/headers/header-search-input.js +65 -65
  4. package/dist/components/data/ag-grid-react/headers/utils/date-utils.js +55 -48
  5. package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +4 -2
  6. package/dist/components/data-display/calendar/calendar-apply-validation.js +80 -61
  7. package/dist/components/data-display/calendar/calendar-config.d.ts +13 -5
  8. package/dist/components/data-display/calendar/calendar-config.js +31 -20
  9. package/dist/components/data-display/calendar/calendar-day-button.js +43 -35
  10. package/dist/components/data-display/calendar/calendar-day-hover.d.ts +8 -0
  11. package/dist/components/data-display/calendar/calendar-day-hover.js +20 -0
  12. package/dist/components/data-display/calendar/calendar-day-picker-classnames.d.ts +8 -1
  13. package/dist/components/data-display/calendar/calendar-day-picker-classnames.js +40 -20
  14. package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +12 -1
  15. package/dist/components/data-display/calendar/calendar-day-picker-components.js +196 -102
  16. package/dist/components/data-display/calendar/calendar-day-picker-view.d.ts +11 -3
  17. package/dist/components/data-display/calendar/calendar-day-picker-view.js +136 -92
  18. package/dist/components/data-display/calendar/calendar-fiscal-labels.d.ts +38 -0
  19. package/dist/components/data-display/calendar/calendar-fiscal-labels.js +90 -0
  20. package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +16 -0
  21. package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +41 -0
  22. package/dist/components/data-display/calendar/calendar-footer-summary.d.ts +13 -4
  23. package/dist/components/data-display/calendar/calendar-footer-summary.js +101 -50
  24. package/dist/components/data-display/calendar/calendar-footer.d.ts +16 -7
  25. package/dist/components/data-display/calendar/calendar-footer.js +88 -66
  26. package/dist/components/data-display/calendar/calendar-gregorian-presets.d.ts +2 -0
  27. package/dist/components/data-display/calendar/calendar-gregorian-presets.js +26 -0
  28. package/dist/components/data-display/calendar/calendar-interval-caption.d.ts +1 -0
  29. package/dist/components/data-display/calendar/calendar-interval-caption.js +10 -0
  30. package/dist/components/data-display/calendar/calendar-interval-utils.d.ts +23 -0
  31. package/dist/components/data-display/calendar/calendar-interval-utils.js +154 -0
  32. package/dist/components/data-display/calendar/calendar-month-panes.d.ts +5 -1
  33. package/dist/components/data-display/calendar/calendar-month-panes.js +9 -7
  34. package/dist/components/data-display/calendar/calendar-month-picker-panel.d.ts +5 -1
  35. package/dist/components/data-display/calendar/calendar-month-picker-panel.js +76 -77
  36. package/dist/components/data-display/calendar/calendar-month-utils.d.ts +2 -0
  37. package/dist/components/data-display/calendar/calendar-month-utils.js +69 -60
  38. package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +15 -0
  39. package/dist/components/data-display/calendar/calendar-padding-week.utils.js +22 -3
  40. package/dist/components/data-display/calendar/calendar-panel-context.d.ts +1 -1
  41. package/dist/components/data-display/calendar/calendar-period-cell.d.ts +18 -0
  42. package/dist/components/data-display/calendar/calendar-period-cell.js +89 -0
  43. package/dist/components/data-display/calendar/calendar-period-keyboard.d.ts +2 -0
  44. package/dist/components/data-display/calendar/calendar-period-keyboard.js +18 -0
  45. package/dist/components/data-display/calendar/calendar-preset-strip.d.ts +6 -0
  46. package/dist/components/data-display/calendar/calendar-preset-strip.js +26 -0
  47. package/dist/components/data-display/calendar/calendar-quarter-panes.d.ts +24 -0
  48. package/dist/components/data-display/calendar/calendar-quarter-panes.js +115 -0
  49. package/dist/components/data-display/calendar/calendar-quarter-utils.d.ts +19 -0
  50. package/dist/components/data-display/calendar/calendar-quarter-utils.js +95 -0
  51. package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +38 -0
  52. package/dist/components/data-display/calendar/calendar-selection-appearance.js +72 -0
  53. package/dist/components/data-display/calendar/calendar-selection.d.ts +20 -0
  54. package/dist/components/data-display/calendar/calendar-selection.js +31 -0
  55. package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +6 -1
  56. package/dist/components/data-display/calendar/calendar-week-number-cell.js +53 -38
  57. package/dist/components/data-display/calendar/calendar-week-number-header.d.ts +4 -0
  58. package/dist/components/data-display/calendar/calendar-week-number-header.js +15 -0
  59. package/dist/components/data-display/calendar/calendar-week-utils.d.ts +11 -3
  60. package/dist/components/data-display/calendar/calendar-week-utils.js +49 -42
  61. package/dist/components/data-display/calendar/calendar-year-panes.d.ts +18 -0
  62. package/dist/components/data-display/calendar/calendar-year-panes.js +98 -0
  63. package/dist/components/data-display/calendar/calendar-year-utils.d.ts +17 -0
  64. package/dist/components/data-display/calendar/calendar-year-utils.js +75 -0
  65. package/dist/components/data-display/calendar/calendar.d.ts +1 -1
  66. package/dist/components/data-display/calendar/calendar.js +303 -181
  67. package/dist/components/data-display/calendar/calendar.types.d.ts +53 -16
  68. package/dist/components/data-display/calendar/fiscal-period-caption-select.d.ts +7 -0
  69. package/dist/components/data-display/calendar/fiscal-period-caption-select.js +63 -0
  70. package/dist/components/data-display/calendar/index.d.ts +1 -1
  71. package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +12 -2
  72. package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +92 -62
  73. package/dist/components/data-display/calendar/use-calendar-state.d.ts +31 -11
  74. package/dist/components/data-display/calendar/use-calendar-state.js +370 -163
  75. package/dist/components/data-display/calendar/use-fiscal-calendar.d.ts +5 -0
  76. package/dist/components/data-display/calendar/use-fiscal-calendar.js +25 -0
  77. package/dist/components/feedback/tooltip/overflow-tooltip.js +57 -57
  78. package/dist/components/forms/date-picker/date-input-behavior.d.ts +7 -0
  79. package/dist/components/forms/date-picker/date-input-behavior.js +28 -24
  80. package/dist/components/forms/date-picker/date-picker-shell.d.ts +13 -0
  81. package/dist/components/forms/date-picker/date-picker-shell.js +31 -0
  82. package/dist/components/forms/date-picker/date-picker.js +187 -167
  83. package/dist/components/forms/date-picker/date-picker.types.d.ts +90 -43
  84. package/dist/components/forms/date-picker/date-range-picker.js +273 -224
  85. package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +13 -0
  86. package/dist/components/forms/date-picker/fiscal-pass-through.js +17 -0
  87. package/dist/components/forms/date-picker/fiscal-period-format.d.ts +9 -0
  88. package/dist/components/forms/date-picker/fiscal-period-format.js +50 -0
  89. package/dist/components/forms/date-picker/index.d.ts +12 -0
  90. package/dist/components/forms/date-picker/index.js +19 -7
  91. package/dist/components/forms/date-picker/month-picker.js +225 -182
  92. package/dist/components/forms/date-picker/month-range-picker.js +134 -110
  93. package/dist/components/forms/date-picker/multi-date-picker.js +77 -56
  94. package/dist/components/forms/date-picker/multi-month-picker.js +78 -57
  95. package/dist/components/forms/date-picker/multi-quarter-picker.d.ts +3 -0
  96. package/dist/components/forms/date-picker/multi-quarter-picker.js +177 -0
  97. package/dist/components/forms/date-picker/multi-week-picker.js +81 -70
  98. package/dist/components/forms/date-picker/multi-year-picker.d.ts +3 -0
  99. package/dist/components/forms/date-picker/multi-year-picker.js +179 -0
  100. package/dist/components/forms/date-picker/quarter-picker.d.ts +3 -0
  101. package/dist/components/forms/date-picker/quarter-picker.js +176 -0
  102. package/dist/components/forms/date-picker/quarter-range-picker.d.ts +3 -0
  103. package/dist/components/forms/date-picker/quarter-range-picker.js +177 -0
  104. package/dist/components/forms/date-picker/week-picker.js +148 -137
  105. package/dist/components/forms/date-picker/week-range-picker.js +216 -205
  106. package/dist/components/forms/date-picker/year-picker.d.ts +3 -0
  107. package/dist/components/forms/date-picker/year-picker.js +176 -0
  108. package/dist/components/forms/date-picker/year-range-picker.d.ts +3 -0
  109. package/dist/components/forms/date-picker/year-range-picker.js +179 -0
  110. package/dist/components/forms/smart-input/smart-input.js +106 -85
  111. package/dist/components/forms/smart-input/smart-input.types.d.ts +5 -0
  112. package/dist/components/forms/textarea/textarea.js +29 -28
  113. package/dist/components/forms/textarea/textarea.types.d.ts +1 -0
  114. package/dist/form-react/Fields/DateInputField.js +63 -58
  115. package/dist/form-react/Fields/DateRangeField.js +42 -37
  116. package/dist/form-react/Fields/MonthRangeField.js +50 -45
  117. package/dist/form-react/Fields/MultiWeekPickerField.js +7 -7
  118. package/dist/form-react/Fields/TextField.js +25 -24
  119. package/dist/form-react/Fields/WeekRangePicker.js +44 -45
  120. package/dist/form-react/components/FieldRenderer.js +21 -23
  121. package/dist/form-react/registry/defaultFieldRegistrations.d.ts +9 -1
  122. package/dist/form-react/registry/defaultFieldRegistrations.js +27 -36
  123. package/dist/form-react/registry/resolveFieldComponent.d.ts +3 -2
  124. package/dist/form-react/registry/resolveFieldComponent.js +9 -133
  125. package/dist/form-react/types/fields.types.d.ts +25 -4
  126. package/dist/form-react/utils/date.utils.d.ts +1 -1
  127. package/dist/form-react/utils/date.utils.js +38 -38
  128. package/dist/i18n/defaultMessages.d.ts +19 -1
  129. package/dist/i18n/defaultMessages.js +37 -20
  130. package/dist/i18n/locales/de.js +18 -1
  131. package/dist/i18n/locales/es.js +18 -1
  132. package/dist/i18n/locales/hi.js +18 -1
  133. package/dist/i18n/locales/kn.js +18 -1
  134. package/dist/impact-nova-components.css +379 -3
  135. package/dist/impact-nova.css +1 -1
  136. package/dist/index.js +528 -516
  137. package/dist/lib/fiscal-calendar/build-year.d.ts +8 -0
  138. package/dist/lib/fiscal-calendar/build-year.js +173 -0
  139. package/dist/lib/fiscal-calendar/civil-date.d.ts +21 -0
  140. package/dist/lib/fiscal-calendar/civil-date.js +94 -0
  141. package/dist/lib/fiscal-calendar/index.d.ts +10 -0
  142. package/dist/lib/fiscal-calendar/index.js +40 -0
  143. package/dist/lib/fiscal-calendar/lookup.d.ts +4 -0
  144. package/dist/lib/fiscal-calendar/lookup.js +70 -0
  145. package/dist/lib/fiscal-calendar/presets.d.ts +8 -0
  146. package/dist/lib/fiscal-calendar/presets.js +99 -0
  147. package/dist/lib/fiscal-calendar/selection.d.ts +18 -0
  148. package/dist/lib/fiscal-calendar/selection.js +32 -0
  149. package/dist/lib/fiscal-calendar/types.d.ts +145 -0
  150. package/dist/lib/fiscal-calendar/types.js +10 -0
  151. package/dist/lib/fiscal-calendar/week-selection.d.ts +22 -0
  152. package/dist/lib/fiscal-calendar/week-selection.js +107 -0
  153. package/dist/llms/rules/best-practices.js +1 -1
  154. package/dist/llms/rules/installation.js +1 -1
  155. package/dist/llms/rules/real-world-patterns.js +1 -1
  156. package/dist/llms/rules/requirements.js +1 -1
  157. package/package.json +5 -1
  158. package/dist/lib/fiscal-calendar.d.ts +0 -62
  159. package/dist/lib/fiscal-calendar.js +0 -99
@@ -0,0 +1,176 @@
1
+ import { jsx as r, jsxs as y } from "react/jsx-runtime";
2
+ import * as t from "react";
3
+ import { Cross as W, CalendarMonth as X } from "impact-nova-icons";
4
+ import { cn as Z } from "../../../lib/utils.js";
5
+ import { Input as _ } from "../input/input.js";
6
+ import { Calendar as $ } from "../../data-display/calendar/calendar.js";
7
+ import { Tooltip as x, TooltipTrigger as R, TooltipContent as D } from "../../feedback/tooltip/tooltip.js";
8
+ import { useImpactNovaI18n as ee } from "../../../i18n/use-impact-nova-i18n.js";
9
+ import { buildDateBoundsMatcher as re } from "../../../lib/date-bounds-matcher.js";
10
+ import { fiscalCalendarPassThrough as te } from "./fiscal-pass-through.js";
11
+ import { DatePickerShell as ne } from "./date-picker-shell.js";
12
+ import { usePickerDismissActionsRef as oe, usePickerFooterDismissNudge as ae, handleReadonlyPickerKeyDown as ie, handlePickerSurfacePointerDown as ce } from "./date-input-behavior.js";
13
+ import { formatYearInput as se } from "../../data-display/calendar/calendar-fiscal-labels.js";
14
+ import { viewMonthFromYear as le } from "../../data-display/calendar/calendar-year-utils.js";
15
+ const pe = t.forwardRef(
16
+ ({
17
+ value: n,
18
+ onChange: d,
19
+ placeholder: Y,
20
+ minDate: v,
21
+ maxDate: N,
22
+ startMonth: S,
23
+ endMonth: A,
24
+ showFooter: s = !0,
25
+ disabled: o,
26
+ className: I,
27
+ calendarKind: O,
28
+ fiscalMode: T,
29
+ granularity: w,
30
+ fiscalMonthPattern: M,
31
+ fiscalYearStartMonth: K,
32
+ fiscalConfig: k,
33
+ showPresets: j,
34
+ showIntervalCaption: F = !1,
35
+ ...L
36
+ }, z) => {
37
+ const { t: a } = ee(), E = Y ?? a("datePicker.selectYear"), m = t.useRef(null), P = t.useRef(null);
38
+ t.useImperativeHandle(z, () => m.current);
39
+ const [i, c] = t.useState(!1), u = t.useRef(!1), g = oe(), { footerFlashKey: H, footerFlashTarget: V, popoverHandlers: B } = ae(s, i, g, P), [C, l] = t.useState(n), [q, G] = t.useState(le(n));
40
+ t.useEffect(() => {
41
+ i || l(n);
42
+ }, [i, n]);
43
+ const p = t.useCallback(() => c(!1), []), J = te({
44
+ calendarKind: O,
45
+ fiscalMode: T,
46
+ granularity: w,
47
+ fiscalMonthPattern: M,
48
+ fiscalYearStartMonth: K,
49
+ fiscalConfig: k,
50
+ showPresets: j
51
+ }), Q = (e) => {
52
+ const f = e && !Array.isArray(e) && !("from" in e) && !("to" in e) ? e : void 0;
53
+ l(f), s || (d?.(f), p());
54
+ }, U = () => {
55
+ d?.(C), p();
56
+ }, h = () => {
57
+ l(n), p();
58
+ }, b = () => {
59
+ l(void 0), d?.(void 0), s || p();
60
+ };
61
+ return t.useLayoutEffect(() => {
62
+ g.current = { onDismiss: h, resolveFlash: () => "cancel" };
63
+ }), /* @__PURE__ */ r(
64
+ ne,
65
+ {
66
+ open: i,
67
+ disabled: o,
68
+ ariaLabel: a("datePicker.selectYear"),
69
+ onOpenChange: (e) => {
70
+ o || c(e);
71
+ },
72
+ onOpenAutoFocus: (e) => {
73
+ u.current || e.preventDefault(), u.current = !1;
74
+ },
75
+ popoverHandlers: B,
76
+ trigger: /* @__PURE__ */ r(
77
+ "div",
78
+ {
79
+ ref: P,
80
+ "data-component": "year-picker",
81
+ "data-state": i ? "open" : "closed",
82
+ onPointerDown: (e) => ce({
83
+ disabled: o,
84
+ event: e,
85
+ onOpen: () => c(!0),
86
+ focusField: () => m.current?.focus()
87
+ }),
88
+ children: /* @__PURE__ */ r(
89
+ _,
90
+ {
91
+ ref: m,
92
+ value: n ? se(n, k?.fyLabel ?? "fy-long") : "",
93
+ readOnly: !0,
94
+ onKeyDown: (e) => ie(e, {
95
+ disabled: o,
96
+ open: i,
97
+ onOpen: () => c(!0),
98
+ onCancel: h,
99
+ onKeyboardOpen: () => {
100
+ u.current = !0;
101
+ }
102
+ }),
103
+ onClick: () => !o && c(!0),
104
+ placeholder: E,
105
+ disabled: o,
106
+ "data-form-control": "input",
107
+ className: Z("cursor-pointer", I),
108
+ suffix: /* @__PURE__ */ y("div", { className: "flex items-center gap-1", children: [
109
+ n && !o ? /* @__PURE__ */ y(x, { children: [
110
+ /* @__PURE__ */ r(R, { asChild: !0, children: /* @__PURE__ */ r(
111
+ "button",
112
+ {
113
+ type: "button",
114
+ tabIndex: 0,
115
+ "aria-label": a("calendar.clear"),
116
+ onClick: (e) => {
117
+ e.stopPropagation(), b();
118
+ },
119
+ className: "inline-flex size-4 items-center justify-center border-none bg-transparent p-0",
120
+ children: /* @__PURE__ */ r(W, { className: "size-3 hover:text-content" })
121
+ }
122
+ ) }),
123
+ /* @__PURE__ */ r(D, { variant: "tertiary", side: "top", children: a("calendar.clear") })
124
+ ] }) : null,
125
+ /* @__PURE__ */ y(x, { children: [
126
+ /* @__PURE__ */ r(R, { asChild: !0, children: /* @__PURE__ */ r(
127
+ "button",
128
+ {
129
+ type: "button",
130
+ tabIndex: 0,
131
+ "data-component": "calendar-trigger",
132
+ "aria-label": a("datePicker.selectYear"),
133
+ onClick: (e) => {
134
+ e.stopPropagation(), o || c((f) => !f);
135
+ },
136
+ className: "inline-flex items-center justify-center border-none bg-transparent p-0",
137
+ children: /* @__PURE__ */ r(X, { className: "h-4 w-4 text-secondary-foreground" })
138
+ }
139
+ ) }),
140
+ /* @__PURE__ */ r(D, { variant: "tertiary", side: "top", children: a("datePicker.selectYear") })
141
+ ] })
142
+ ] }),
143
+ ...L
144
+ }
145
+ )
146
+ }
147
+ ),
148
+ children: /* @__PURE__ */ r(
149
+ $,
150
+ {
151
+ pickerType: "year",
152
+ selectedYear: C,
153
+ footerFlashKey: H,
154
+ footerFlashTarget: V,
155
+ onYearSelect: Q,
156
+ month: q,
157
+ onMonthChange: G,
158
+ disabled: re(v, N),
159
+ startMonth: S,
160
+ endMonth: A,
161
+ showFooter: s,
162
+ onApply: U,
163
+ onCancel: h,
164
+ onClear: b,
165
+ showIntervalCaption: F,
166
+ ...J
167
+ }
168
+ )
169
+ }
170
+ );
171
+ }
172
+ );
173
+ pe.displayName = "YearPicker";
174
+ export {
175
+ pe as YearPicker
176
+ };
@@ -0,0 +1,3 @@
1
+ import { YearRangePickerProps } from './date-picker.types';
2
+ import * as React from "react";
3
+ export declare const YearRangePicker: React.ForwardRefExoticComponent<YearRangePickerProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,179 @@
1
+ import { jsx as r, jsxs as g } from "react/jsx-runtime";
2
+ import * as t from "react";
3
+ import { Cross as Z, CalendarMonth as _ } from "impact-nova-icons";
4
+ import { cn as ee } from "../../../lib/utils.js";
5
+ import { Input as re } from "../input/input.js";
6
+ import { Calendar as te } from "../../data-display/calendar/calendar.js";
7
+ import { Tooltip as x, TooltipTrigger as D, TooltipContent as Y } from "../../feedback/tooltip/tooltip.js";
8
+ import { useImpactNovaI18n as ne } from "../../../i18n/use-impact-nova-i18n.js";
9
+ import { buildDateBoundsMatcher as oe } from "../../../lib/date-bounds-matcher.js";
10
+ import { fiscalCalendarPassThrough as ae } from "./fiscal-pass-through.js";
11
+ import { DatePickerShell as ie } from "./date-picker-shell.js";
12
+ import { usePickerDismissActionsRef as ce, usePickerFooterDismissNudge as se, handleReadonlyPickerKeyDown as le, handlePickerSurfacePointerDown as fe } from "./date-input-behavior.js";
13
+ import { formatYearInput as N } from "../../data-display/calendar/calendar-fiscal-labels.js";
14
+ import { viewMonthFromYear as pe } from "../../data-display/calendar/calendar-year-utils.js";
15
+ const de = t.forwardRef(
16
+ ({
17
+ value: n,
18
+ onChange: d,
19
+ placeholder: S,
20
+ minDate: v,
21
+ maxDate: A,
22
+ startMonth: I,
23
+ endMonth: M,
24
+ showFooter: l = !0,
25
+ disabled: o,
26
+ className: O,
27
+ calendarKind: T,
28
+ fiscalMode: w,
29
+ granularity: K,
30
+ fiscalMonthPattern: j,
31
+ fiscalYearStartMonth: F,
32
+ fiscalConfig: y,
33
+ showPresets: L,
34
+ showIntervalCaption: $ = !1,
35
+ ...z
36
+ }, E) => {
37
+ const { t: a } = ne(), H = S ?? a("datePicker.selectYearRange"), k = y?.fyLabel ?? "fy-long", m = t.useRef(null), P = t.useRef(null);
38
+ t.useImperativeHandle(E, () => m.current);
39
+ const [i, c] = t.useState(!1), u = t.useRef(!1), R = ce(), { footerFlashKey: V, footerFlashTarget: B, popoverHandlers: q } = se(l, i, R, P), [C, f] = t.useState(n), [G, J] = t.useState(pe(n?.from));
40
+ t.useEffect(() => {
41
+ i || f(n);
42
+ }, [i, n]);
43
+ const p = t.useCallback(() => c(!1), []), Q = ae({
44
+ calendarKind: T,
45
+ fiscalMode: w,
46
+ granularity: K,
47
+ fiscalMonthPattern: j,
48
+ fiscalYearStartMonth: F,
49
+ fiscalConfig: y,
50
+ showPresets: L
51
+ }), U = (e) => {
52
+ const s = e && !Array.isArray(e) && ("from" in e || "to" in e) ? e : void 0;
53
+ f(s), l || (d?.(s), s?.to && p());
54
+ }, W = () => {
55
+ d?.(C), p();
56
+ }, h = () => {
57
+ f(n), p();
58
+ }, b = () => {
59
+ f(void 0), d?.(void 0), l || p();
60
+ };
61
+ t.useLayoutEffect(() => {
62
+ R.current = { onDismiss: h, resolveFlash: () => "cancel" };
63
+ });
64
+ const X = n?.from ? `${N(n.from, k)}${n.to ? ` – ${N(n.to, k)}` : ""}` : "";
65
+ return /* @__PURE__ */ r(
66
+ ie,
67
+ {
68
+ open: i,
69
+ disabled: o,
70
+ ariaLabel: a("datePicker.selectYearRange"),
71
+ onOpenChange: (e) => {
72
+ o || c(e);
73
+ },
74
+ onOpenAutoFocus: (e) => {
75
+ u.current || e.preventDefault(), u.current = !1;
76
+ },
77
+ popoverHandlers: q,
78
+ trigger: /* @__PURE__ */ r(
79
+ "div",
80
+ {
81
+ ref: P,
82
+ "data-component": "year-range-picker",
83
+ "data-state": i ? "open" : "closed",
84
+ onPointerDown: (e) => fe({
85
+ disabled: o,
86
+ event: e,
87
+ onOpen: () => c(!0),
88
+ focusField: () => m.current?.focus()
89
+ }),
90
+ children: /* @__PURE__ */ r(
91
+ re,
92
+ {
93
+ ref: m,
94
+ value: X,
95
+ readOnly: !0,
96
+ onKeyDown: (e) => le(e, {
97
+ disabled: o,
98
+ open: i,
99
+ onOpen: () => c(!0),
100
+ onCancel: h,
101
+ onKeyboardOpen: () => {
102
+ u.current = !0;
103
+ }
104
+ }),
105
+ onClick: () => !o && c(!0),
106
+ placeholder: H,
107
+ disabled: o,
108
+ "data-form-control": "input",
109
+ className: ee("cursor-pointer", O),
110
+ suffix: /* @__PURE__ */ g("div", { className: "flex items-center gap-1", children: [
111
+ n?.from && !o ? /* @__PURE__ */ g(x, { children: [
112
+ /* @__PURE__ */ r(D, { asChild: !0, children: /* @__PURE__ */ r(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ tabIndex: 0,
117
+ "aria-label": a("calendar.clear"),
118
+ onClick: (e) => {
119
+ e.stopPropagation(), b();
120
+ },
121
+ className: "inline-flex size-4 items-center justify-center border-none bg-transparent p-0",
122
+ children: /* @__PURE__ */ r(Z, { className: "size-3 hover:text-content" })
123
+ }
124
+ ) }),
125
+ /* @__PURE__ */ r(Y, { variant: "tertiary", side: "top", children: a("calendar.clear") })
126
+ ] }) : null,
127
+ /* @__PURE__ */ g(x, { children: [
128
+ /* @__PURE__ */ r(D, { asChild: !0, children: /* @__PURE__ */ r(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ tabIndex: 0,
133
+ "data-component": "calendar-trigger",
134
+ "aria-label": a("datePicker.selectYearRange"),
135
+ onClick: (e) => {
136
+ e.stopPropagation(), o || c((s) => !s);
137
+ },
138
+ className: "inline-flex items-center justify-center border-none bg-transparent p-0",
139
+ children: /* @__PURE__ */ r(_, { className: "h-4 w-4 text-secondary-foreground" })
140
+ }
141
+ ) }),
142
+ /* @__PURE__ */ r(Y, { variant: "tertiary", side: "top", children: a("datePicker.selectYearRange") })
143
+ ] })
144
+ ] }),
145
+ ...z
146
+ }
147
+ )
148
+ }
149
+ ),
150
+ children: /* @__PURE__ */ r(
151
+ te,
152
+ {
153
+ pickerType: "year",
154
+ yearMode: "range",
155
+ selectedYear: C,
156
+ footerFlashKey: V,
157
+ footerFlashTarget: B,
158
+ onYearSelect: U,
159
+ month: G,
160
+ onMonthChange: J,
161
+ disabled: oe(v, A),
162
+ startMonth: I,
163
+ endMonth: M,
164
+ showFooter: l,
165
+ onApply: W,
166
+ onCancel: h,
167
+ onClear: b,
168
+ showIntervalCaption: $,
169
+ ...Q
170
+ }
171
+ )
172
+ }
173
+ );
174
+ }
175
+ );
176
+ de.displayName = "YearRangePicker";
177
+ export {
178
+ de as YearRangePicker
179
+ };
@@ -1,34 +1,50 @@
1
- import { jsx as P } from "react/jsx-runtime";
2
- import { useState as E } from "react";
3
- import { createComponent as x } from "../../../lib/primitives/create-component.js";
4
- import { Input as L } from "../input/input.js";
5
- const le = x("SmartInput", function({
6
- value: M,
7
- type: S = "text",
8
- onChange: v,
9
- onBlur: b,
10
- onFocus: z,
11
- allowNegative: D = !0,
1
+ import { jsx as R } from "react/jsx-runtime";
2
+ import { useState as ee } from "react";
3
+ import { createComponent as te } from "../../../lib/primitives/create-component.js";
4
+ import { Input as re } from "../input/input.js";
5
+ const ne = /* @__PURE__ */ new Set([
6
+ "email",
7
+ "password",
8
+ "url",
9
+ "tel"
10
+ ]);
11
+ function se(d, v) {
12
+ return d !== void 0 ? d : ne.has(v ?? "");
13
+ }
14
+ function ue(d) {
15
+ return d.replace(/[^\p{L}\p{N}\s]/gu, "");
16
+ }
17
+ const he = te("SmartInput", function({
18
+ value: v,
19
+ type: C = "text",
20
+ onChange: I,
21
+ onBlur: T,
22
+ onFocus: _,
23
+ allowNegative: m = !0,
12
24
  min: s,
13
25
  max: u,
14
- minOperator: F,
15
- maxOperator: K,
16
- min_operator: O = ">=",
17
- max_operator: W = "<=",
18
- maxIntegerDigits: V,
19
- decimalPlaces: o,
20
- enforceDecimal: j = !1,
21
- allowDecimal: B = !0,
22
- maxLength: i,
23
- trimLeadingSpaces: y = !0,
24
- customValidator: N,
26
+ minOperator: b,
27
+ maxOperator: E,
28
+ min_operator: F = ">=",
29
+ max_operator: K = "<=",
30
+ maxIntegerDigits: D,
31
+ decimalPlaces: a,
32
+ enforceDecimal: O = !1,
33
+ allowDecimal: N = !0,
34
+ allowSpecialCharacters: U,
35
+ maxLength: c,
36
+ trimLeadingSpaces: P = !0,
37
+ customValidator: B,
25
38
  onValidationError: p,
26
- disabled: h = !1,
27
- ...k
28
- }, T) {
29
- const $ = M !== void 0, [U, m] = E(""), a = $ ? String(M ?? "") : U, c = S === "number", g = F ?? O, w = K ?? W, q = (t) => {
39
+ disabled: S = !1,
40
+ ...W
41
+ }, j) {
42
+ const $ = v !== void 0, [k, g] = ee(""), i = $ ? String(v ?? "") : k, l = C === "number", A = se(
43
+ U,
44
+ C
45
+ ), V = b ?? F, w = E ?? K, z = (t) => {
30
46
  if (s === void 0) return !0;
31
- switch (g) {
47
+ switch (V) {
32
48
  case ">":
33
49
  return t > s;
34
50
  case ">=":
@@ -40,7 +56,7 @@ const le = x("SmartInput", function({
40
56
  default:
41
57
  return !0;
42
58
  }
43
- }, A = (t) => {
59
+ }, G = (t) => {
44
60
  if (u === void 0) return !0;
45
61
  switch (w) {
46
62
  case ">":
@@ -54,10 +70,10 @@ const le = x("SmartInput", function({
54
70
  default:
55
71
  return !0;
56
72
  }
57
- }, G = (t) => {
73
+ }, H = (t) => {
58
74
  let e = t;
59
75
  if (s !== void 0) {
60
- const r = g === ">" ? s + 0.01 : s;
76
+ const r = V === ">" ? s + 0.01 : s;
61
77
  e = Math.max(e, r);
62
78
  }
63
79
  if (u !== void 0) {
@@ -65,124 +81,129 @@ const le = x("SmartInput", function({
65
81
  e = Math.min(e, r);
66
82
  }
67
83
  return e;
68
- }, H = (t) => {
69
- const e = D ? /[^0-9.-]/g : /[^0-9.]/g;
84
+ }, Q = (t) => {
85
+ const e = m ? /[^0-9.-]/g : /[^0-9.]/g;
70
86
  return t.replace(e, "");
71
- }, J = (t) => {
87
+ }, Y = (t) => {
72
88
  const e = t.split(".");
73
89
  return e.length > 2 ? e[0] + "." + e.slice(1).join("") : t;
74
- }, Q = (t, e) => {
75
- if (!D) return t;
90
+ }, q = (t, e) => {
91
+ if (!m) return t;
76
92
  if ((t.match(/-/g) || []).length > 1) {
77
93
  let n = t.replace(/-/g, "");
78
94
  return e.startsWith("-") && (n = "-" + n), n;
79
95
  } else if (t.includes("-") && !t.startsWith("-"))
80
96
  return t.replace("-", "");
81
97
  return t;
82
- }, R = (t) => {
83
- if (o === void 0 || !t.includes(".")) return t;
98
+ }, J = (t) => {
99
+ if (a === void 0 || !t.includes(".")) return t;
84
100
  const [e, r] = t.split(".");
85
- return r && r.length > o ? `${e}.${r.slice(0, o)}` : t;
101
+ return r && r.length > a ? `${e}.${r.slice(0, a)}` : t;
86
102
  }, X = (t) => {
87
- if (V === void 0) return t;
103
+ if (D === void 0) return t;
88
104
  const [e, r] = t.split("."), n = e.replace("-", "");
89
- if (n.length > V) {
90
- const f = n.slice(0, V), d = e.startsWith("-") ? "-" : "";
91
- return r !== void 0 ? `${d}${f}.${r}` : `${d}${f}`;
105
+ if (n.length > D) {
106
+ const o = n.slice(0, D), f = e.startsWith("-") ? "-" : "";
107
+ return r !== void 0 ? `${f}${o}.${r}` : `${f}${o}`;
92
108
  }
93
109
  return t;
94
- }, C = (t) => {
95
- if (!c) return t;
110
+ }, Z = (t) => {
111
+ if (!l) return t;
96
112
  let e = String(t ?? "");
97
- return y && (e = e.replace(/^\s+/, "")), e = H(e), e = J(e), e = Q(e, t), e = R(e), e = X(e), B || (e = e.replace(".", "")), e;
98
- }, Y = (t) => {
99
- if (!c || !t || t === "-") return t;
113
+ return P && (e = e.replace(/^\s+/, "")), e = Q(e), e = Y(e), e = q(e, t), e = J(e), e = X(e), N || (e = e.replace(".", "")), e;
114
+ }, y = (t) => {
115
+ if (l) return Z(t);
116
+ let e = String(t ?? "");
117
+ return P && (e = e.replace(/^\s+/, "")), A || (e = ue(e)), e;
118
+ }, x = (t) => {
119
+ if (!l || !t || t === "-") return t;
100
120
  let e = t;
101
121
  const r = parseFloat(e);
102
122
  if (isNaN(r)) return "";
103
- const n = G(r);
104
- if (j && o !== void 0)
105
- e = n.toFixed(o);
106
- else if (o !== void 0 && e.includes(".")) {
107
- const [f, d = ""] = e.split("."), I = d.padEnd(o, "0");
108
- e = `${f}.${I}`;
123
+ const n = H(r);
124
+ if (O && a !== void 0)
125
+ e = n.toFixed(a);
126
+ else if (a !== void 0 && e.includes(".")) {
127
+ const [o, f = ""] = e.split("."), M = f.padEnd(a, "0");
128
+ e = `${o}.${M}`;
109
129
  } else
110
130
  e = String(n);
111
131
  return e;
112
- }, Z = (t) => {
132
+ }, L = (t) => {
113
133
  if (!t) return !0;
114
- if (N && !N(t))
134
+ if (B && !B(t))
115
135
  return p?.("Custom validation failed"), !1;
116
- if (c) {
136
+ if (l) {
117
137
  const e = parseFloat(t);
118
138
  if (isNaN(e))
119
139
  return p?.("Invalid number"), !1;
120
- if (!q(e))
121
- return p?.(`Value must be ${g} ${s}`), !1;
122
- if (!A(e))
140
+ if (!z(e))
141
+ return p?.(`Value must be ${V} ${s}`), !1;
142
+ if (!G(e))
123
143
  return p?.(`Value must be ${w} ${u}`), !1;
124
144
  }
125
- return i && t.length > i ? (p?.(`Maximum length is ${i}`), !1) : !0;
145
+ return c && t.length > c ? (p?.(`Maximum length is ${c}`), !1) : !0;
126
146
  };
127
- return /* @__PURE__ */ P(
147
+ return /* @__PURE__ */ R(
128
148
  "div",
129
149
  {
130
150
  "data-component": "smart-input",
131
151
  className: "w-full",
132
- "data-numeric": c || void 0,
133
- "data-decimal-places": o,
152
+ "data-numeric": l || void 0,
153
+ "data-allow-special-characters": A || void 0,
154
+ "data-decimal-places": a,
134
155
  "data-min": s,
135
156
  "data-max": u,
136
- children: /* @__PURE__ */ P(
137
- L,
157
+ children: /* @__PURE__ */ R(
158
+ re,
138
159
  {
139
- ...k,
140
- type: S,
141
- value: a,
160
+ ...W,
161
+ type: C,
162
+ value: i,
142
163
  onChange: (t) => {
143
- if (h) return;
144
- let r = t.target.value;
145
- c ? r = C(r) : y && (r = r.replace(/^\s+/, "")), i && r.length > i && (r = r.slice(0, i)), $ || m(r), v?.(r, t);
164
+ if (S) return;
165
+ let e = y(t.target.value);
166
+ c && e.length > c && (e = e.slice(0, c)), $ || g(e), I?.(e, t);
146
167
  },
147
168
  onBlur: (t) => {
148
- let e = a;
149
- c && e && (e = Y(e), Z(e) && ($ || m(e), e !== a && v?.(e))), b?.(t);
169
+ let e = i;
170
+ l && e && (e = x(e), L(e) && ($ || g(e), e !== i && I?.(e))), T?.(t);
150
171
  },
151
- onFocus: z,
172
+ onFocus: _,
152
173
  onKeyDown: (t) => {
153
- if (h || !c) return;
174
+ if (S || !l) return;
154
175
  const e = t.key;
155
176
  if (e === "e" || e === "E") {
156
177
  t.preventDefault();
157
178
  return;
158
179
  }
159
- if (e === "-" && !D) {
180
+ if (e === "-" && !m) {
160
181
  t.preventDefault();
161
182
  return;
162
183
  }
163
- if (e === "-" && a.includes("-")) {
184
+ if (e === "-" && i.includes("-")) {
164
185
  t.preventDefault();
165
186
  return;
166
187
  }
167
- if (e === "." && (!B || a.includes("."))) {
188
+ if (e === "." && (!N || i.includes("."))) {
168
189
  t.preventDefault();
169
190
  return;
170
191
  }
171
192
  },
172
193
  onPaste: (t) => {
173
- if (h) return;
194
+ if (S) return;
174
195
  t.preventDefault();
175
- const e = t.clipboardData.getData("text"), r = c ? C(e) : e, n = t.target, f = n.selectionStart || 0, d = n.selectionEnd || 0, I = a.slice(0, f), _ = a.slice(d);
176
- let l = I + r + _;
177
- c && (l = C(l)), i && l.length > i && (l = l.slice(0, i)), $ || m(l), v?.(l);
196
+ const e = t.clipboardData.getData("text"), r = t.target, n = r.selectionStart || 0, o = r.selectionEnd || 0, f = i.slice(0, n), M = i.slice(o);
197
+ let h = y(f + e + M);
198
+ c && h.length > c && (h = h.slice(0, c)), $ || g(h), I?.(h);
178
199
  },
179
- disabled: h,
180
- ref: T
200
+ disabled: S,
201
+ ref: j
181
202
  }
182
203
  )
183
204
  }
184
205
  );
185
206
  });
186
207
  export {
187
- le as SmartInput
208
+ he as SmartInput
188
209
  };
@@ -21,6 +21,11 @@ export interface SmartInputProps extends Omit<InputProps, "onChange" | "value" |
21
21
  decimalPlaces?: number;
22
22
  enforceDecimal?: boolean;
23
23
  allowDecimal?: boolean;
24
+ /**
25
+ * When false (default), only letters, numbers, and spaces are kept.
26
+ * `email` / `password` / `url` / `tel` default to true.
27
+ */
28
+ allowSpecialCharacters?: boolean;
24
29
  maxLength?: number;
25
30
  trimLeadingSpaces?: boolean;
26
31
  customValidator?: (value: string) => boolean;