@salt-ds/date-components 0.0.0-snapshot-20260330155807

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 (227) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +63 -0
  3. package/css/salt-date-components.css +633 -0
  4. package/dist-cjs/calendar/Calendar.css.js +6 -0
  5. package/dist-cjs/calendar/Calendar.css.js.map +1 -0
  6. package/dist-cjs/calendar/Calendar.js +154 -0
  7. package/dist-cjs/calendar/Calendar.js.map +1 -0
  8. package/dist-cjs/calendar/CalendarGrid.js +85 -0
  9. package/dist-cjs/calendar/CalendarGrid.js.map +1 -0
  10. package/dist-cjs/calendar/CalendarMonthHeader.css.js +6 -0
  11. package/dist-cjs/calendar/CalendarMonthHeader.css.js.map +1 -0
  12. package/dist-cjs/calendar/CalendarMonthHeader.js +41 -0
  13. package/dist-cjs/calendar/CalendarMonthHeader.js.map +1 -0
  14. package/dist-cjs/calendar/CalendarNavigation.css.js +6 -0
  15. package/dist-cjs/calendar/CalendarNavigation.css.js.map +1 -0
  16. package/dist-cjs/calendar/CalendarNavigation.js +334 -0
  17. package/dist-cjs/calendar/CalendarNavigation.js.map +1 -0
  18. package/dist-cjs/calendar/CalendarWeekHeader.css.js +6 -0
  19. package/dist-cjs/calendar/CalendarWeekHeader.css.js.map +1 -0
  20. package/dist-cjs/calendar/CalendarWeekHeader.js +46 -0
  21. package/dist-cjs/calendar/CalendarWeekHeader.js.map +1 -0
  22. package/dist-cjs/calendar/internal/CalendarContext.js +23 -0
  23. package/dist-cjs/calendar/internal/CalendarContext.js.map +1 -0
  24. package/dist-cjs/calendar/internal/CalendarDay.css.js +6 -0
  25. package/dist-cjs/calendar/internal/CalendarDay.css.js.map +1 -0
  26. package/dist-cjs/calendar/internal/CalendarDay.js +98 -0
  27. package/dist-cjs/calendar/internal/CalendarDay.js.map +1 -0
  28. package/dist-cjs/calendar/internal/CalendarMonth.css.js +6 -0
  29. package/dist-cjs/calendar/internal/CalendarMonth.css.js.map +1 -0
  30. package/dist-cjs/calendar/internal/CalendarMonth.js +81 -0
  31. package/dist-cjs/calendar/internal/CalendarMonth.js.map +1 -0
  32. package/dist-cjs/calendar/internal/createAnnouncement.js +90 -0
  33. package/dist-cjs/calendar/internal/createAnnouncement.js.map +1 -0
  34. package/dist-cjs/calendar/internal/useFocusManagement.js +66 -0
  35. package/dist-cjs/calendar/internal/useFocusManagement.js.map +1 -0
  36. package/dist-cjs/calendar/internal/utils.js +50 -0
  37. package/dist-cjs/calendar/internal/utils.js.map +1 -0
  38. package/dist-cjs/calendar/useCalendar.js +464 -0
  39. package/dist-cjs/calendar/useCalendar.js.map +1 -0
  40. package/dist-cjs/calendar/useCalendarDay.js +84 -0
  41. package/dist-cjs/calendar/useCalendarDay.js.map +1 -0
  42. package/dist-cjs/calendar/useCalendarSelection.js +353 -0
  43. package/dist-cjs/calendar/useCalendarSelection.js.map +1 -0
  44. package/dist-cjs/calendar/useDateSelectionAnnouncer.js +52 -0
  45. package/dist-cjs/calendar/useDateSelectionAnnouncer.js.map +1 -0
  46. package/dist-cjs/date-input/DateInput.css.js +6 -0
  47. package/dist-cjs/date-input/DateInput.css.js.map +1 -0
  48. package/dist-cjs/date-input/DateInputRange.js +353 -0
  49. package/dist-cjs/date-input/DateInputRange.js.map +1 -0
  50. package/dist-cjs/date-input/DateInputSingle.js +237 -0
  51. package/dist-cjs/date-input/DateInputSingle.js.map +1 -0
  52. package/dist-cjs/date-picker/DatePicker.js +83 -0
  53. package/dist-cjs/date-picker/DatePicker.js.map +1 -0
  54. package/dist-cjs/date-picker/DatePickerActions.css.js +6 -0
  55. package/dist-cjs/date-picker/DatePickerActions.css.js.map +1 -0
  56. package/dist-cjs/date-picker/DatePickerActions.js +119 -0
  57. package/dist-cjs/date-picker/DatePickerActions.js.map +1 -0
  58. package/dist-cjs/date-picker/DatePickerContext.js +36 -0
  59. package/dist-cjs/date-picker/DatePickerContext.js.map +1 -0
  60. package/dist-cjs/date-picker/DatePickerHelperText.css.js +6 -0
  61. package/dist-cjs/date-picker/DatePickerHelperText.css.js.map +1 -0
  62. package/dist-cjs/date-picker/DatePickerHelperText.js +36 -0
  63. package/dist-cjs/date-picker/DatePickerHelperText.js.map +1 -0
  64. package/dist-cjs/date-picker/DatePickerOverlay.css.js +6 -0
  65. package/dist-cjs/date-picker/DatePickerOverlay.css.js.map +1 -0
  66. package/dist-cjs/date-picker/DatePickerOverlay.js +49 -0
  67. package/dist-cjs/date-picker/DatePickerOverlay.js.map +1 -0
  68. package/dist-cjs/date-picker/DatePickerOverlayProvider.js +164 -0
  69. package/dist-cjs/date-picker/DatePickerOverlayProvider.js.map +1 -0
  70. package/dist-cjs/date-picker/DatePickerPanel.css.js +6 -0
  71. package/dist-cjs/date-picker/DatePickerPanel.css.js.map +1 -0
  72. package/dist-cjs/date-picker/DatePickerRangeGridPanel.js +250 -0
  73. package/dist-cjs/date-picker/DatePickerRangeGridPanel.js.map +1 -0
  74. package/dist-cjs/date-picker/DatePickerRangeInput.js +206 -0
  75. package/dist-cjs/date-picker/DatePickerRangeInput.js.map +1 -0
  76. package/dist-cjs/date-picker/DatePickerRangePanel.js +365 -0
  77. package/dist-cjs/date-picker/DatePickerRangePanel.js.map +1 -0
  78. package/dist-cjs/date-picker/DatePickerSingleGridPanel.js +262 -0
  79. package/dist-cjs/date-picker/DatePickerSingleGridPanel.js.map +1 -0
  80. package/dist-cjs/date-picker/DatePickerSingleInput.js +150 -0
  81. package/dist-cjs/date-picker/DatePickerSingleInput.js.map +1 -0
  82. package/dist-cjs/date-picker/DatePickerSinglePanel.js +20 -0
  83. package/dist-cjs/date-picker/DatePickerSinglePanel.js.map +1 -0
  84. package/dist-cjs/date-picker/DatePickerTrigger.js +32 -0
  85. package/dist-cjs/date-picker/DatePickerTrigger.js.map +1 -0
  86. package/dist-cjs/date-picker/useDatePicker.js +222 -0
  87. package/dist-cjs/date-picker/useDatePicker.js.map +1 -0
  88. package/dist-cjs/date-picker/useFocusOut.js +43 -0
  89. package/dist-cjs/date-picker/useFocusOut.js.map +1 -0
  90. package/dist-cjs/date-picker/useKeyboard.js +22 -0
  91. package/dist-cjs/date-picker/useKeyboard.js.map +1 -0
  92. package/dist-cjs/index.js +64 -0
  93. package/dist-cjs/index.js.map +1 -0
  94. package/dist-cjs/localization-provider/LocalizationProvider.js +51 -0
  95. package/dist-cjs/localization-provider/LocalizationProvider.js.map +1 -0
  96. package/dist-es/calendar/Calendar.css.js +4 -0
  97. package/dist-es/calendar/Calendar.css.js.map +1 -0
  98. package/dist-es/calendar/Calendar.js +152 -0
  99. package/dist-es/calendar/Calendar.js.map +1 -0
  100. package/dist-es/calendar/CalendarGrid.js +83 -0
  101. package/dist-es/calendar/CalendarGrid.js.map +1 -0
  102. package/dist-es/calendar/CalendarMonthHeader.css.js +4 -0
  103. package/dist-es/calendar/CalendarMonthHeader.css.js.map +1 -0
  104. package/dist-es/calendar/CalendarMonthHeader.js +39 -0
  105. package/dist-es/calendar/CalendarMonthHeader.js.map +1 -0
  106. package/dist-es/calendar/CalendarNavigation.css.js +4 -0
  107. package/dist-es/calendar/CalendarNavigation.css.js.map +1 -0
  108. package/dist-es/calendar/CalendarNavigation.js +332 -0
  109. package/dist-es/calendar/CalendarNavigation.js.map +1 -0
  110. package/dist-es/calendar/CalendarWeekHeader.css.js +4 -0
  111. package/dist-es/calendar/CalendarWeekHeader.css.js.map +1 -0
  112. package/dist-es/calendar/CalendarWeekHeader.js +44 -0
  113. package/dist-es/calendar/CalendarWeekHeader.js.map +1 -0
  114. package/dist-es/calendar/internal/CalendarContext.js +20 -0
  115. package/dist-es/calendar/internal/CalendarContext.js.map +1 -0
  116. package/dist-es/calendar/internal/CalendarDay.css.js +4 -0
  117. package/dist-es/calendar/internal/CalendarDay.css.js.map +1 -0
  118. package/dist-es/calendar/internal/CalendarDay.js +96 -0
  119. package/dist-es/calendar/internal/CalendarDay.js.map +1 -0
  120. package/dist-es/calendar/internal/CalendarMonth.css.js +4 -0
  121. package/dist-es/calendar/internal/CalendarMonth.css.js.map +1 -0
  122. package/dist-es/calendar/internal/CalendarMonth.js +79 -0
  123. package/dist-es/calendar/internal/CalendarMonth.js.map +1 -0
  124. package/dist-es/calendar/internal/createAnnouncement.js +87 -0
  125. package/dist-es/calendar/internal/createAnnouncement.js.map +1 -0
  126. package/dist-es/calendar/internal/useFocusManagement.js +64 -0
  127. package/dist-es/calendar/internal/useFocusManagement.js.map +1 -0
  128. package/dist-es/calendar/internal/utils.js +44 -0
  129. package/dist-es/calendar/internal/utils.js.map +1 -0
  130. package/dist-es/calendar/useCalendar.js +462 -0
  131. package/dist-es/calendar/useCalendar.js.map +1 -0
  132. package/dist-es/calendar/useCalendarDay.js +82 -0
  133. package/dist-es/calendar/useCalendarDay.js.map +1 -0
  134. package/dist-es/calendar/useCalendarSelection.js +349 -0
  135. package/dist-es/calendar/useCalendarSelection.js.map +1 -0
  136. package/dist-es/calendar/useDateSelectionAnnouncer.js +50 -0
  137. package/dist-es/calendar/useDateSelectionAnnouncer.js.map +1 -0
  138. package/dist-es/date-input/DateInput.css.js +4 -0
  139. package/dist-es/date-input/DateInput.css.js.map +1 -0
  140. package/dist-es/date-input/DateInputRange.js +350 -0
  141. package/dist-es/date-input/DateInputRange.js.map +1 -0
  142. package/dist-es/date-input/DateInputSingle.js +235 -0
  143. package/dist-es/date-input/DateInputSingle.js.map +1 -0
  144. package/dist-es/date-picker/DatePicker.js +80 -0
  145. package/dist-es/date-picker/DatePicker.js.map +1 -0
  146. package/dist-es/date-picker/DatePickerActions.css.js +4 -0
  147. package/dist-es/date-picker/DatePickerActions.css.js.map +1 -0
  148. package/dist-es/date-picker/DatePickerActions.js +117 -0
  149. package/dist-es/date-picker/DatePickerActions.js.map +1 -0
  150. package/dist-es/date-picker/DatePickerContext.js +32 -0
  151. package/dist-es/date-picker/DatePickerContext.js.map +1 -0
  152. package/dist-es/date-picker/DatePickerHelperText.css.js +4 -0
  153. package/dist-es/date-picker/DatePickerHelperText.css.js.map +1 -0
  154. package/dist-es/date-picker/DatePickerHelperText.js +34 -0
  155. package/dist-es/date-picker/DatePickerHelperText.js.map +1 -0
  156. package/dist-es/date-picker/DatePickerOverlay.css.js +4 -0
  157. package/dist-es/date-picker/DatePickerOverlay.css.js.map +1 -0
  158. package/dist-es/date-picker/DatePickerOverlay.js +47 -0
  159. package/dist-es/date-picker/DatePickerOverlay.js.map +1 -0
  160. package/dist-es/date-picker/DatePickerOverlayProvider.js +161 -0
  161. package/dist-es/date-picker/DatePickerOverlayProvider.js.map +1 -0
  162. package/dist-es/date-picker/DatePickerPanel.css.js +4 -0
  163. package/dist-es/date-picker/DatePickerPanel.css.js.map +1 -0
  164. package/dist-es/date-picker/DatePickerRangeGridPanel.js +248 -0
  165. package/dist-es/date-picker/DatePickerRangeGridPanel.js.map +1 -0
  166. package/dist-es/date-picker/DatePickerRangeInput.js +203 -0
  167. package/dist-es/date-picker/DatePickerRangeInput.js.map +1 -0
  168. package/dist-es/date-picker/DatePickerRangePanel.js +363 -0
  169. package/dist-es/date-picker/DatePickerRangePanel.js.map +1 -0
  170. package/dist-es/date-picker/DatePickerSingleGridPanel.js +260 -0
  171. package/dist-es/date-picker/DatePickerSingleGridPanel.js.map +1 -0
  172. package/dist-es/date-picker/DatePickerSingleInput.js +148 -0
  173. package/dist-es/date-picker/DatePickerSingleInput.js.map +1 -0
  174. package/dist-es/date-picker/DatePickerSinglePanel.js +18 -0
  175. package/dist-es/date-picker/DatePickerSinglePanel.js.map +1 -0
  176. package/dist-es/date-picker/DatePickerTrigger.js +30 -0
  177. package/dist-es/date-picker/DatePickerTrigger.js.map +1 -0
  178. package/dist-es/date-picker/useDatePicker.js +220 -0
  179. package/dist-es/date-picker/useDatePicker.js.map +1 -0
  180. package/dist-es/date-picker/useFocusOut.js +41 -0
  181. package/dist-es/date-picker/useFocusOut.js.map +1 -0
  182. package/dist-es/date-picker/useKeyboard.js +20 -0
  183. package/dist-es/date-picker/useKeyboard.js.map +1 -0
  184. package/dist-es/index.js +25 -0
  185. package/dist-es/index.js.map +1 -0
  186. package/dist-es/localization-provider/LocalizationProvider.js +47 -0
  187. package/dist-es/localization-provider/LocalizationProvider.js.map +1 -0
  188. package/dist-types/calendar/Calendar.d.ts +105 -0
  189. package/dist-types/calendar/CalendarGrid.d.ts +27 -0
  190. package/dist-types/calendar/CalendarMonthHeader.d.ts +17 -0
  191. package/dist-types/calendar/CalendarNavigation.d.ts +43 -0
  192. package/dist-types/calendar/CalendarWeekHeader.d.ts +6 -0
  193. package/dist-types/calendar/index.d.ts +9 -0
  194. package/dist-types/calendar/internal/CalendarContext.d.ts +6 -0
  195. package/dist-types/calendar/internal/CalendarDay.d.ts +33 -0
  196. package/dist-types/calendar/internal/CalendarMonth.d.ts +14 -0
  197. package/dist-types/calendar/internal/createAnnouncement.d.ts +24 -0
  198. package/dist-types/calendar/internal/useFocusManagement.d.ts +9 -0
  199. package/dist-types/calendar/internal/utils.d.ts +6 -0
  200. package/dist-types/calendar/useCalendar.d.ts +335 -0
  201. package/dist-types/calendar/useCalendarDay.d.ts +67 -0
  202. package/dist-types/calendar/useCalendarSelection.d.ts +145 -0
  203. package/dist-types/calendar/useDateSelectionAnnouncer.d.ts +6 -0
  204. package/dist-types/date-input/DateInputRange.d.ts +131 -0
  205. package/dist-types/date-input/DateInputSingle.d.ts +99 -0
  206. package/dist-types/date-input/index.d.ts +2 -0
  207. package/dist-types/date-picker/DatePicker.d.ts +52 -0
  208. package/dist-types/date-picker/DatePickerActions.d.ts +79 -0
  209. package/dist-types/date-picker/DatePickerContext.d.ts +172 -0
  210. package/dist-types/date-picker/DatePickerHelperText.d.ts +4 -0
  211. package/dist-types/date-picker/DatePickerOverlay.d.ts +11 -0
  212. package/dist-types/date-picker/DatePickerOverlayProvider.d.ts +106 -0
  213. package/dist-types/date-picker/DatePickerRangeGridPanel.d.ts +14 -0
  214. package/dist-types/date-picker/DatePickerRangeInput.d.ts +17 -0
  215. package/dist-types/date-picker/DatePickerRangePanel.d.ts +83 -0
  216. package/dist-types/date-picker/DatePickerSingleGridPanel.d.ts +63 -0
  217. package/dist-types/date-picker/DatePickerSingleInput.d.ts +15 -0
  218. package/dist-types/date-picker/DatePickerSinglePanel.d.ts +8 -0
  219. package/dist-types/date-picker/DatePickerTrigger.d.ts +9 -0
  220. package/dist-types/date-picker/index.d.ts +13 -0
  221. package/dist-types/date-picker/useDatePicker.d.ts +121 -0
  222. package/dist-types/date-picker/useFocusOut.d.ts +9 -0
  223. package/dist-types/date-picker/useKeyboard.d.ts +20 -0
  224. package/dist-types/index.d.ts +4 -0
  225. package/dist-types/localization-provider/LocalizationProvider.d.ts +62 -0
  226. package/dist-types/localization-provider/index.d.ts +1 -0
  227. package/package.json +60 -0
@@ -0,0 +1,131 @@
1
+ import { type InputProps } from "@salt-ds/core";
2
+ import type { DateDetail, ParserResult, Timezone } from "@salt-ds/date-adapters";
3
+ import { type ChangeEvent, type ComponentPropsWithoutRef, type InputHTMLAttributes, type ReactNode, type Ref, type SyntheticEvent } from "react";
4
+ import type { DateRangeSelection } from "../calendar";
5
+ /**
6
+ * DateInputRange raw value or null if no date is defined.
7
+ */
8
+ export type DateInputRangeValue = {
9
+ startDate?: string | null;
10
+ endDate?: string | null;
11
+ };
12
+ /**
13
+ * Details of parsing the date range
14
+ */
15
+ export type DateInputRangeDetails = {
16
+ /** Details of parsing the start date and applying any validation */
17
+ startDate?: DateDetail;
18
+ /** Details of parsing the end date and applying any validation */
19
+ endDate?: DateDetail;
20
+ };
21
+ /**
22
+ * Enum to identify the field being parsed
23
+ */
24
+ export declare enum DateParserField {
25
+ START = "start",
26
+ END = "end"
27
+ }
28
+ /**
29
+ * Props for the DateInputRange component.
30
+ */
31
+ export interface DateInputRangeProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "onChange">, Omit<InputProps, "defaultValue" | "inputRef" | "value" | "onChange"> {
32
+ /**
33
+ * Styling variant with full border. Defaults to false.
34
+ */
35
+ bordered?: boolean;
36
+ /**
37
+ * The marker to use in an empty read-only DateInput.
38
+ * Use `''` to disable this feature. Defaults to '—'.
39
+ */
40
+ emptyReadOnlyMarker?: string;
41
+ /**
42
+ * End adornment component.
43
+ */
44
+ endAdornment?: ReactNode;
45
+ /**
46
+ * Attributes applied to the start `input` element.
47
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dateInput#Attributes
48
+ */
49
+ startInputProps?: InputHTMLAttributes<HTMLInputElement>;
50
+ /**
51
+ * Attributes applied to the end `input` element.
52
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dateInput#Attributes
53
+ */
54
+ endInputProps?: InputHTMLAttributes<HTMLInputElement>;
55
+ /**
56
+ * If `true`, the component is read-only.
57
+ */
58
+ readOnly?: boolean;
59
+ /**
60
+ * Validation status.
61
+ */
62
+ validationStatus?: "error" | "warning" | "success";
63
+ /**
64
+ * Styling variant. Defaults to "primary".
65
+ */
66
+ variant?: "primary" | "secondary" | "tertiary";
67
+ /**
68
+ * Format string for date.
69
+ */
70
+ format?: string;
71
+ /**
72
+ * Optional ref for the start input component.
73
+ */
74
+ startInputRef?: Ref<HTMLInputElement>;
75
+ /**
76
+ * Optional ref for the end input component.
77
+ */
78
+ endInputRef?: Ref<HTMLInputElement>;
79
+ /**
80
+ * Parser callback, if not using the adapter's parser
81
+ * @param value - date string to parse
82
+ * @param field: DateParserField to identify value,
83
+ * @param format - format required
84
+ */
85
+ parse?: (value: string, field: DateParserField, format: string) => ParserResult;
86
+ /**
87
+ * Input value. Use when the input value is controlled.
88
+ */
89
+ value?: DateInputRangeValue;
90
+ /**
91
+ * The initial input value. Use when the component is uncontrolled.
92
+ */
93
+ defaultValue?: DateInputRangeValue;
94
+ /**
95
+ * The date value. Use when the component is controlled.
96
+ */
97
+ date?: DateRangeSelection | null;
98
+ /**
99
+ * The initial selected date value. Use when the component is uncontrolled.
100
+ */
101
+ defaultDate?: DateRangeSelection | null;
102
+ /**
103
+ * Callback fired when the input value changes.
104
+ * @param event - The change event.
105
+ * @param date - The new date input range value.
106
+ */
107
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
108
+ /**
109
+ * Callback fired when the selected date changes.
110
+ * @param event - The synthetic event.
111
+ * @param date - the selected date, invalid date if not a valid date or undefined (uncontrolled) or null (controlled) if not defined
112
+ * @param details - The details of date selection, either a valid date or error
113
+ */
114
+ onDateChange?: (event: SyntheticEvent, date: DateRangeSelection | null, details: DateInputRangeDetails) => void;
115
+ /**
116
+ * Called when input values change, either due to user interaction or programmatic formatting of valid dates.
117
+ * @param event - The synthetic event or null if a programmatic change.
118
+ * @param newValue - The new date input range value.
119
+ */
120
+ onDateValueChange?: (event: SyntheticEvent | null, newValue: DateInputRangeValue) => void;
121
+ /**
122
+ * Specifies the timezone behavior:
123
+ * - If undefined, the timezone will be derived from the passed date, or from `defaultSelectedDate`/`selectedDate`.
124
+ * - If set to "default", the default timezone of the date library will be used.
125
+ * - If set to "system", the local system's timezone will be applied.
126
+ * - If set to "UTC", the time will be returned in UTC.
127
+ * - If set to a valid IANA timezone identifier, the time will be returned for that specific timezone.
128
+ */
129
+ timezone?: Timezone;
130
+ }
131
+ export declare const DateInputRange: import("react").ForwardRefExoticComponent<DateInputRangeProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,99 @@
1
+ import type { DateDetail, DateFrameworkType, ParserResult, Timezone } from "@salt-ds/date-adapters";
2
+ import { type ComponentPropsWithoutRef, type InputHTMLAttributes, type ReactNode, type Ref, type SyntheticEvent } from "react";
3
+ import type { SingleDateSelection } from "../calendar";
4
+ /**
5
+ * Details of parsing the date
6
+ */
7
+ export type DateInputSingleDetails = DateDetail;
8
+ /**
9
+ * Props for the DateInputSingle component.
10
+ */
11
+ export interface DateInputSingleProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue">, Pick<ComponentPropsWithoutRef<"input">, "disabled" | "value" | "defaultValue" | "placeholder"> {
12
+ /**
13
+ * Styling variant with full border. Defaults to false.
14
+ */
15
+ bordered?: boolean;
16
+ /**
17
+ * The marker to use in an empty read-only DateInput.
18
+ * Use `''` to disable this feature. Defaults to '—'.
19
+ */
20
+ emptyReadOnlyMarker?: string;
21
+ /**
22
+ * End adornment component.
23
+ */
24
+ endAdornment?: ReactNode;
25
+ /**
26
+ * Attributes applied to the `input` element.
27
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dateInput#Attributes
28
+ */
29
+ inputProps?: InputHTMLAttributes<HTMLInputElement>;
30
+ /**
31
+ * If `true`, the component is read-only.
32
+ */
33
+ readOnly?: boolean;
34
+ /**
35
+ * Start adornment component
36
+ */
37
+ startAdornment?: ReactNode;
38
+ /**
39
+ * Validation status.
40
+ */
41
+ validationStatus?: "error" | "warning" | "success";
42
+ /**
43
+ * Styling variant. Defaults to "primary".
44
+ */
45
+ variant?: "primary" | "secondary" | "tertiary";
46
+ /**
47
+ * Format string for date.
48
+ */
49
+ format?: string;
50
+ /**
51
+ * Reference for the input.
52
+ */
53
+ inputRef?: Ref<HTMLInputElement>;
54
+ /**
55
+ * Parser callback, if not using the adapter's parser
56
+ * @param value - date string to parse
57
+ * @param format - format required
58
+ */
59
+ parse?: (value: string, format: string) => ParserResult;
60
+ /**
61
+ * Input value. Use when the input value is controlled.
62
+ */
63
+ value?: string;
64
+ /**
65
+ * The initial input value. Use when the component is uncontrolled.
66
+ */
67
+ defaultValue?: string;
68
+ /**
69
+ * The date value. Use when the component is controlled.
70
+ */
71
+ date?: DateFrameworkType | null;
72
+ /**
73
+ * The initial selected date value. Use when the component is uncontrolled.
74
+ */
75
+ defaultDate?: DateFrameworkType | null;
76
+ /**
77
+ * Callback fired when the selected date changes.
78
+ * @param event - The synthetic event.
79
+ * @param date - the selected date, invalid date if not a valid date or undefined (uncontrolled) or null (controlled) if not defined
80
+ * @param details - The details of date selection, either a valid date or error
81
+ */
82
+ onDateChange?: (event: SyntheticEvent, date: SingleDateSelection | null | undefined, details: DateInputSingleDetails) => void;
83
+ /**
84
+ * Called when input value changes, either due to user interaction or programmatic formatting of valid dates.
85
+ * @param event - The synthetic event or null if a programmatic change.
86
+ * @param newValue - The new date input value.
87
+ */
88
+ onDateValueChange?: (event: SyntheticEvent | null, newValue: string) => void;
89
+ /**
90
+ * Specifies the timezone behavior:
91
+ * - If undefined, the timezone will be derived from the passed date, or from `defaultSelectedDate`/`selectedDate`.
92
+ * - If set to "default", the default timezone of the date library will be used.
93
+ * - If set to "system", the local system's timezone will be applied.
94
+ * - If set to "UTC", the time will be returned in UTC.
95
+ * - If set to a valid IANA timezone identifier, the time will be returned for that specific timezone.
96
+ */
97
+ timezone?: Timezone;
98
+ }
99
+ export declare const DateInputSingle: import("react").ForwardRefExoticComponent<DateInputSingleProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export * from "./DateInputRange";
2
+ export * from "./DateInputSingle";
@@ -0,0 +1,52 @@
1
+ import type { Timezone } from "@salt-ds/date-adapters";
2
+ import { type ReactNode } from "react";
3
+ import { type DatePickerOpenChangeReason } from "./DatePickerOverlayProvider";
4
+ import { type UseDatePickerRangeProps, type UseDatePickerSingleProps } from "./useDatePicker";
5
+ /**
6
+ * Base props for DatePicker.
7
+ */
8
+ export interface DatePickerBaseProps {
9
+ className?: string;
10
+ children?: ReactNode;
11
+ /** the open/close state of the overlay. The open/close state will be controlled when this prop is provided. */
12
+ open?: boolean;
13
+ /** When `open` is uncontrolled, set this to `true` to open on click */
14
+ openOnClick?: boolean;
15
+ /**
16
+ * Handler for when open state changes
17
+ * @param newOpen - true when opened
18
+ * @param reason - reason for the the state change
19
+ */
20
+ onOpenChange?: (newOpen: boolean, reason?: DatePickerOpenChangeReason) => void;
21
+ /**
22
+ * the initial open/close state of the overlay, when the open/close state is un-controlled.
23
+ */
24
+ defaultOpen?: DatePickerBaseProps["open"];
25
+ /**
26
+ * Specifies the timezone behavior:
27
+ * - If undefined, the timezone will be derived from the passed date, or from `defaultSelectedDate`/`selectedDate`.
28
+ * - If set to "default", the default timezone of the date library will be used.
29
+ * - If set to "system", the local system's timezone will be applied.
30
+ * - If set to "UTC", the time will be returned in UTC.
31
+ * - If set to a valid IANA timezone identifier, the time will be returned for that specific timezone.
32
+ */
33
+ timezone?: Timezone;
34
+ }
35
+ /**
36
+ * Props for the DatePicker component, when `selectionVariant` is `single`.
37
+ */
38
+ export interface DatePickerSingleProps extends DatePickerBaseProps, UseDatePickerSingleProps {
39
+ selectionVariant: "single";
40
+ }
41
+ /**
42
+ * Props for the DatePicker component, when `selectionVariant` is `range`.
43
+ */
44
+ export interface DatePickerRangeProps extends DatePickerBaseProps, UseDatePickerRangeProps {
45
+ selectionVariant: "range";
46
+ }
47
+ /**
48
+ * Props for the DatePicker component.
49
+ */
50
+ export type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps;
51
+ export declare const DatePickerMain: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLDivElement>>;
52
+ export declare const DatePicker: import("react").ForwardRefExoticComponent<DatePickerProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,79 @@
1
+ import { type ButtonProps } from "@salt-ds/core";
2
+ import { type ComponentPropsWithoutRef, type Ref, type SyntheticEvent } from "react";
3
+ import type { DateRangeSelection, SingleDateSelection } from "../calendar";
4
+ /**
5
+ * Base props for DatePicker actions component.
6
+ */
7
+ export interface DatePickerActionsBaseProps extends ComponentPropsWithoutRef<"div"> {
8
+ /**
9
+ * Callback fired when the cancel action is triggered.
10
+ * @param _event - The synthetic event.
11
+ */
12
+ onCancel?: (_event: SyntheticEvent) => void;
13
+ /**
14
+ * Ref to apply button
15
+ */
16
+ applyButtonRef?: Ref<HTMLButtonElement>;
17
+ /**
18
+ * Props for the apply button.
19
+ */
20
+ ApplyButtonProps?: ButtonProps;
21
+ /**
22
+ * Props for the cancel button.
23
+ */
24
+ CancelButtonProps?: ButtonProps;
25
+ /**
26
+ * Ref to cancel button
27
+ */
28
+ cancelButtonRef?: Ref<HTMLButtonElement>;
29
+ }
30
+ /**
31
+ * Props for the DatePicker actions component.
32
+ * @template SelectionVariant - The selection variant, either "single" or "range".
33
+ */
34
+ export type DatePickerActionsProps<SelectionVariant extends "single" | "range"> = SelectionVariant extends "single" ? DatePickerActionsBaseProps & {
35
+ /**
36
+ * The selection variant, set to "single".
37
+ */
38
+ selectionVariant: "single";
39
+ /**
40
+ * Callback fired when the apply action is triggered.
41
+ * @param _event - The synthetic event.
42
+ * @param date - The selected single date or null.
43
+ */
44
+ onApply?: (_event: SyntheticEvent, date: SingleDateSelection | null) => void;
45
+ } : DatePickerActionsBaseProps & {
46
+ /**
47
+ * The selection variant, set to "range".
48
+ */
49
+ selectionVariant: "range";
50
+ /**
51
+ * Callback fired when the apply action is triggered.
52
+ * @param _event - The synthetic event.
53
+ * @param date - The selected date range or null.
54
+ */
55
+ onApply?: (_event: SyntheticEvent, date: DateRangeSelection | null) => void;
56
+ };
57
+ export declare const DatePickerActions: import("react").ForwardRefExoticComponent<((DatePickerActionsBaseProps & {
58
+ /**
59
+ * The selection variant, set to "single".
60
+ */
61
+ selectionVariant: "single";
62
+ /**
63
+ * Callback fired when the apply action is triggered.
64
+ * @param _event - The synthetic event.
65
+ * @param date - The selected single date or null.
66
+ */
67
+ onApply?: (_event: SyntheticEvent, date: SingleDateSelection | null) => void;
68
+ }) | (DatePickerActionsBaseProps & {
69
+ /**
70
+ * The selection variant, set to "range".
71
+ */
72
+ selectionVariant: "range";
73
+ /**
74
+ * Callback fired when the apply action is triggered.
75
+ * @param _event - The synthetic event.
76
+ * @param date - The selected date range or null.
77
+ */
78
+ onApply?: (_event: SyntheticEvent, date: DateRangeSelection | null) => void;
79
+ })) & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,172 @@
1
+ import type { DateFrameworkType, Timezone } from "@salt-ds/date-adapters";
2
+ import { type Context, type Ref, type SyntheticEvent } from "react";
3
+ import type { DateRangeSelection, SingleDateSelection } from "../calendar";
4
+ import type { DateInputRangeDetails, DateInputSingleDetails } from "../date-input";
5
+ /**
6
+ * Interface representing the base state for a DatePicker.
7
+ */
8
+ interface DatePickerBaseState {
9
+ /**
10
+ * The state properties of the DatePicker.
11
+ */
12
+ state: {
13
+ /**
14
+ * If `true`, the DatePicker is disabled.
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * If `true`, the DatePicker is read-only.
19
+ */
20
+ readOnly?: boolean;
21
+ /**
22
+ * If `true`, the DatePicker has been cancelled.
23
+ */
24
+ cancelled?: boolean;
25
+ /**
26
+ * If `true`, the apply action is enabled.
27
+ */
28
+ enableApply?: boolean;
29
+ /**
30
+ * The minimum selectable date.
31
+ */
32
+ minDate?: DateFrameworkType;
33
+ /**
34
+ * The maximum selectable date.
35
+ */
36
+ maxDate?: DateFrameworkType;
37
+ /**
38
+ * Reference to the container element.
39
+ */
40
+ containerRef: Ref<HTMLDivElement>;
41
+ /**
42
+ * Specifies the timezone behavior:
43
+ * - If undefined, the timezone will be derived from the passed date, or from `defaultSelectedDate`/`selectedDate`.
44
+ * - If set to "default", the default timezone of the date library will be used.
45
+ * - If set to "system", the local system's timezone will be applied.
46
+ * - If set to "UTC", the time will be returned in UTC.
47
+ * - If set to a valid IANA timezone identifier, the time will be returned for that specific timezone.
48
+ */
49
+ timezone?: Timezone;
50
+ };
51
+ /**
52
+ * Helper functions for managing the DatePicker state.
53
+ */
54
+ helpers: {
55
+ /**
56
+ * Cancels the DatePicker action.
57
+ * @param event - event that triggered the state change
58
+ */
59
+ cancel: (event?: Event) => void;
60
+ /**
61
+ * Function to determine if a day is highlighted.
62
+ * @param date - The date to check.
63
+ * @returns A string reason if the day is highlighted, otherwise `false` or `undefined`.
64
+ */
65
+ isDayHighlighted?: (date: DateFrameworkType) => string | false | undefined;
66
+ /**
67
+ * Function to determine if a day is unselectable.
68
+ * @param date - The date to check.
69
+ * @returns A string reason if the day is unselectable, otherwise `false` or `undefined`.
70
+ */
71
+ isDayUnselectable?: (date: DateFrameworkType) => string | false | undefined;
72
+ /**
73
+ * Sets the enableApply state.
74
+ * @param newEnableApply - The new value for enableApply.
75
+ */
76
+ setEnableApply: (newEnableApply: boolean) => void;
77
+ };
78
+ }
79
+ /**
80
+ * Interface representing the state for a single date picker.
81
+ */
82
+ export interface SingleDatePickerState extends DatePickerBaseState {
83
+ /**
84
+ * The state properties of the single date picker.
85
+ */
86
+ state: DatePickerBaseState["state"] & {
87
+ /**
88
+ * The selected date.
89
+ */
90
+ selectedDate: SingleDateSelection<DateFrameworkType> | null;
91
+ /**
92
+ * The default selected date.
93
+ */
94
+ defaultSelectedDate?: SingleDateSelection<DateFrameworkType>;
95
+ };
96
+ /**
97
+ * Helper functions for managing the single date picker state.
98
+ */
99
+ helpers: DatePickerBaseState["helpers"] & {
100
+ /**
101
+ * Apply the selected single date.
102
+ * @param event - The synthetic event.
103
+ * @param date - The new applied date.
104
+ */
105
+ apply: (event: SyntheticEvent, date: SingleDateSelection<DateFrameworkType> | null) => void;
106
+ /**
107
+ * Select a single date.
108
+ * @param event - The synthetic event.
109
+ * @param date - The selected date or null.
110
+ * @param details - Details of selection, such as errors and original value.
111
+ */
112
+ select: (event: SyntheticEvent, date: SingleDateSelection<DateFrameworkType> | null, details?: DateInputSingleDetails) => void;
113
+ };
114
+ }
115
+ /**
116
+ * Interface representing the state for a range date picker.
117
+ */
118
+ export interface RangeDatePickerState extends DatePickerBaseState {
119
+ /**
120
+ * The state properties of the range date picker.
121
+ */
122
+ state: DatePickerBaseState["state"] & {
123
+ /**
124
+ * The selected date range.
125
+ */
126
+ selectedDate: DateRangeSelection<DateFrameworkType> | null;
127
+ /**
128
+ * The default selected date range.
129
+ */
130
+ defaultSelectedDate?: DateRangeSelection<DateFrameworkType>;
131
+ };
132
+ /**
133
+ * Helper functions for managing the range date picker state.
134
+ */
135
+ helpers: DatePickerBaseState["helpers"] & {
136
+ /**
137
+ * Apply the selected date range.
138
+ * @param event - The synthetic event.
139
+ * @param date - The new applied date range
140
+ */
141
+ apply: (event: SyntheticEvent, date: DateRangeSelection<DateFrameworkType> | null) => void;
142
+ /**
143
+ * Select a date range.
144
+ * @param event - The synthetic event.
145
+ * @param date - The selected date.
146
+ * @param details - Details of selection, such as errors and original value. */
147
+ select: (event: SyntheticEvent, date: DateRangeSelection<DateFrameworkType> | null, details?: DateInputRangeDetails) => void;
148
+ };
149
+ }
150
+ /**
151
+ * Type representing the state of a date picker, either single or range.
152
+ */
153
+ export type DatePickerState = SingleDatePickerState | RangeDatePickerState;
154
+ /**
155
+ * Context for single date selection.
156
+ */
157
+ export declare const SingleDateSelectionContext: Context<SingleDatePickerState | undefined>;
158
+ /**
159
+ * Context for date range selection.
160
+ */
161
+ export declare const DateRangeSelectionContext: Context<RangeDatePickerState | undefined>;
162
+ /**
163
+ * Props for using the date picker context.
164
+ */
165
+ export interface UseDatePickerContextProps {
166
+ /**
167
+ * The selection variant, either "single" or "range".
168
+ */
169
+ selectionVariant: "single" | "range";
170
+ }
171
+ export declare function useDatePickerContext({ selectionVariant, }: UseDatePickerContextProps): DatePickerState;
172
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type FormFieldHelperTextProps } from "@salt-ds/core";
2
+ export interface DatePickerHelperTextProps extends FormFieldHelperTextProps {
3
+ }
4
+ export declare const DatePickerHelperText: import("react").ForwardRefExoticComponent<Omit<DatePickerHelperTextProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
@@ -0,0 +1,11 @@
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from "react";
2
+ /**
3
+ * Props for the DatePickerOverlay component.
4
+ */
5
+ export interface DatePickerOverlayProps extends ComponentPropsWithoutRef<"div"> {
6
+ /**
7
+ * The content to be rendered inside the overlay.
8
+ */
9
+ children: ReactNode;
10
+ }
11
+ export declare const DatePickerOverlay: import("react").ForwardRefExoticComponent<DatePickerOverlayProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,106 @@
1
+ import { type ElementProps, type FloatingContext, type OpenChangeReason as FloatingUIOpenChangeReason, useInteractions } from "@floating-ui/react";
2
+ import { useFloatingUI } from "@salt-ds/core";
3
+ import { type ReactNode } from "react";
4
+ /** Reason for overlay state change, can be a custom reason */
5
+ export type DatePickerOpenChangeReason = FloatingUIOpenChangeReason | "apply" | "cancel" | string;
6
+ /**
7
+ * Interface representing the state for a DatePicker overlay.
8
+ */
9
+ interface DatePickerOverlayState {
10
+ /**
11
+ * If `true`, the overlay is open.
12
+ */
13
+ open: boolean;
14
+ /**
15
+ * If `true`, the overlay contains the active element
16
+ */
17
+ focused: boolean;
18
+ /**
19
+ * The result of the floating UI calculations.
20
+ */
21
+ floatingUIResult: ReturnType<typeof useFloatingUI>;
22
+ /**
23
+ * Ref to attach to the initially focused element, when the overlay is opened.
24
+ */
25
+ initialFocusRef?: React.MutableRefObject<HTMLElement | null>;
26
+ }
27
+ /**
28
+ * Interface representing the helper functions for a DatePicker overlay.
29
+ */
30
+ interface DatePickerOverlayHelpers {
31
+ /**
32
+ * Function to get the props for the floating element.
33
+ */
34
+ getFloatingProps: ReturnType<typeof useInteractions>["getFloatingProps"];
35
+ /**
36
+ * Function to get the props for the reference element.
37
+ */
38
+ getReferenceProps: ReturnType<typeof useInteractions>["getReferenceProps"];
39
+ /**
40
+ * Sets the open state of the overlay.
41
+ * @param newOpen - The new value for the open state.
42
+ * @param event - event that triggered the state change
43
+ * @param reason - reason for the the state change
44
+ */
45
+ setOpen: (newOpen: boolean, event?: Event, reason?: DatePickerOpenChangeReason) => void;
46
+ /**~
47
+ * Register a callback for when onDismiss is called
48
+ * @param onDismissCallback
49
+ */
50
+ setOnDismiss: (onDismissCallback: (event?: Event) => void) => void;
51
+ }
52
+ /**
53
+ * Interface representing the context type for a DatePicker overlay.
54
+ */
55
+ interface DatePickerOverlayContextType {
56
+ /**
57
+ * The state of the DatePicker overlay.
58
+ */
59
+ state: DatePickerOverlayState;
60
+ /**
61
+ * The helper functions for the DatePicker overlay.
62
+ */
63
+ helpers: DatePickerOverlayHelpers;
64
+ }
65
+ /**
66
+ * Props for the DatePickerOverlayProvider component.
67
+ */
68
+ interface DatePickerOverlayProviderProps {
69
+ /**
70
+ * If `true`, the overlay is disabled.
71
+ */
72
+ disabled?: boolean;
73
+ /**
74
+ * If `true`, the overlay is open.
75
+ */
76
+ open?: boolean;
77
+ /**
78
+ * When `open` is uncontrolled, set this to `true` to open on click
79
+ */
80
+ openOnClick?: boolean;
81
+ /**
82
+ * Handler for when open state changes
83
+ * @param newOpen - true when opened
84
+ * @param reason - reason for the the state change
85
+ */
86
+ onOpenChange?: (newOpen: boolean, reason?: DatePickerOpenChangeReason) => void;
87
+ /**
88
+ * The default open state of the overlay.
89
+ */
90
+ defaultOpen?: boolean;
91
+ /**
92
+ * The content to be rendered inside the overlay provider.
93
+ */
94
+ children: ReactNode;
95
+ /**
96
+ * A factory method to create a set of interaction, if provided overrides the default interactions
97
+ */
98
+ interactions?: (context: FloatingContext) => Array<ElementProps>;
99
+ /**
100
+ * When true, shouldn't open the overlay.
101
+ */
102
+ readOnly?: boolean;
103
+ }
104
+ export declare const DatePickerOverlayProvider: React.FC<DatePickerOverlayProviderProps>;
105
+ export declare const useDatePickerOverlay: () => DatePickerOverlayContextType;
106
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type SyntheticEvent } from "react";
2
+ import { type CalendarRangeProps, type DateRangeSelection } from "../calendar";
3
+ import type { DatePickerPanelBaseProps } from "./DatePickerSingleGridPanel";
4
+ /**
5
+ * Props for the DatePickerRangeGridPanel component.
6
+ */
7
+ export type DatePickerRangeGridPanelProps = DatePickerPanelBaseProps & DateRangeSelection & {
8
+ onSelectionChange?: (event: SyntheticEvent, selectedDate?: DateRangeSelection | null) => void;
9
+ CalendarProps?: Partial<Omit<CalendarRangeProps, "selectionVariant" | "selectedDate" | "defaultSelectedDate" | "multiselect" | "onHoveredDateChange" | "onSelectionChange" | "onVisibleMonthChange">>;
10
+ };
11
+ export declare const DatePickerRangeGridPanel: import("react").ForwardRefExoticComponent<DatePickerPanelBaseProps & DateRangeSelection & {
12
+ onSelectionChange?: (event: SyntheticEvent, selectedDate?: DateRangeSelection | null) => void;
13
+ CalendarProps?: Partial<Omit<CalendarRangeProps, "selectionVariant" | "selectedDate" | "defaultSelectedDate" | "multiselect" | "onHoveredDateChange" | "onSelectionChange" | "onVisibleMonthChange">>;
14
+ } & import("react").RefAttributes<HTMLDivElement>>;