@exsto/ds 0.0.1-rc.13 → 0.0.1-rc.14

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 (185) hide show
  1. package/dist/date-picker.js +1 -344
  2. package/dist/index.js +75 -4513
  3. package/dist/rich-text-editor.js +3 -904
  4. package/dist/source-hash.txt +1 -1
  5. package/dist/styles.css +5 -19
  6. package/dist/theme.css +2 -1
  7. package/dist/ui/src/components/edyn/animated-number/animated-number.js +108 -0
  8. package/dist/ui/src/components/edyn/animated-number/animated-number.js.map +1 -0
  9. package/dist/ui/src/components/edyn/audio-player/audio-player.js +86 -0
  10. package/dist/ui/src/components/edyn/audio-player/audio-player.js.map +1 -0
  11. package/dist/ui/src/components/edyn/date-picker/date-picker.js +250 -0
  12. package/dist/ui/src/components/edyn/date-picker/date-picker.js.map +1 -0
  13. package/dist/ui/src/components/edyn/date-picker/date-text.js +105 -0
  14. package/dist/ui/src/components/edyn/date-picker/date-text.js.map +1 -0
  15. package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.js +59 -0
  16. package/dist/ui/src/components/edyn/date-range-picker/date-range-picker.js.map +1 -0
  17. package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.js +86 -0
  18. package/dist/ui/src/components/edyn/initials-avatar/initials-avatar.js.map +1 -0
  19. package/dist/ui/src/components/edyn/multi-select/multi-select.js +332 -0
  20. package/dist/ui/src/components/edyn/multi-select/multi-select.js.map +1 -0
  21. package/dist/ui/src/components/edyn/progress-line/progress-line.js +100 -0
  22. package/dist/ui/src/components/edyn/progress-line/progress-line.js.map +1 -0
  23. package/dist/ui/src/components/edyn/rich-text-content/allow-list.js +37 -0
  24. package/dist/ui/src/components/edyn/rich-text-content/allow-list.js.map +1 -0
  25. package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.js +124 -0
  26. package/dist/ui/src/components/edyn/rich-text-content/rich-text-content.js.map +1 -0
  27. package/dist/ui/src/components/edyn/rich-text-editor/extensions.js +124 -0
  28. package/dist/ui/src/components/edyn/rich-text-editor/extensions.js.map +1 -0
  29. package/dist/ui/src/components/edyn/rich-text-editor/mention-list.js +232 -0
  30. package/dist/ui/src/components/edyn/rich-text-editor/mention-list.js.map +1 -0
  31. package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.js +244 -0
  32. package/dist/ui/src/components/edyn/rich-text-editor/rich-text-editor.js.map +1 -0
  33. package/dist/ui/src/components/edyn/rich-text-editor/serialize.js +55 -0
  34. package/dist/ui/src/components/edyn/rich-text-editor/serialize.js.map +1 -0
  35. package/dist/ui/src/components/edyn/rich-text-editor/sync.js +34 -0
  36. package/dist/ui/src/components/edyn/rich-text-editor/sync.js.map +1 -0
  37. package/dist/ui/src/components/edyn/rich-text-editor/toolbar.js +235 -0
  38. package/dist/ui/src/components/edyn/rich-text-editor/toolbar.js.map +1 -0
  39. package/dist/ui/src/components/edyn/rich-text-editor/types.js +26 -0
  40. package/dist/ui/src/components/edyn/rich-text-editor/types.js.map +1 -0
  41. package/dist/ui/src/components/edyn/video-player/video-player.js +132 -0
  42. package/dist/ui/src/components/edyn/video-player/video-player.js.map +1 -0
  43. package/dist/ui/src/components/ui/accordion/accordion.js +83 -0
  44. package/dist/ui/src/components/ui/accordion/accordion.js.map +1 -0
  45. package/dist/ui/src/components/ui/alert/alert.js +47 -0
  46. package/dist/ui/src/components/ui/alert/alert.js.map +1 -0
  47. package/dist/ui/src/components/ui/alert-dialog/alert-dialog.js +95 -0
  48. package/dist/ui/src/components/ui/alert-dialog/alert-dialog.js.map +1 -0
  49. package/dist/ui/src/components/ui/aspect-ratio/aspect-ratio.js +15 -0
  50. package/dist/ui/src/components/ui/aspect-ratio/aspect-ratio.js.map +1 -0
  51. package/dist/ui/src/components/ui/attachment/attachment.js +105 -0
  52. package/dist/ui/src/components/ui/attachment/attachment.js.map +1 -0
  53. package/dist/ui/src/components/ui/avatar/avatar.js +51 -0
  54. package/dist/ui/src/components/ui/avatar/avatar.js.map +1 -0
  55. package/dist/ui/src/components/ui/badge/badge.js +47 -0
  56. package/dist/ui/src/components/ui/badge/badge.js.map +1 -0
  57. package/dist/ui/src/components/ui/breadcrumb/breadcrumb.js +73 -0
  58. package/dist/ui/src/components/ui/breadcrumb/breadcrumb.js.map +1 -0
  59. package/dist/ui/src/components/ui/bubble/bubble.js +74 -0
  60. package/dist/ui/src/components/ui/bubble/bubble.js.map +1 -0
  61. package/dist/{chunks/input-syWxjY2U.js → ui/src/components/ui/button/button.js} +3 -82
  62. package/dist/ui/src/components/ui/button/button.js.map +1 -0
  63. package/dist/ui/src/components/ui/button-group/button-group.js +37 -0
  64. package/dist/ui/src/components/ui/button-group/button-group.js.map +1 -0
  65. package/dist/{chunks/date-range-picker-CWVcHgy2.js → ui/src/components/ui/calendar/calendar.js} +6 -100
  66. package/dist/ui/src/components/ui/calendar/calendar.js.map +1 -0
  67. package/dist/ui/src/components/ui/card/card.js +57 -0
  68. package/dist/ui/src/components/ui/card/card.js.map +1 -0
  69. package/dist/ui/src/components/ui/carousel/carousel.js +136 -0
  70. package/dist/ui/src/components/ui/carousel/carousel.js.map +1 -0
  71. package/dist/ui/src/components/ui/chart/chart.js +168 -0
  72. package/dist/ui/src/components/ui/chart/chart.js.map +1 -0
  73. package/dist/ui/src/components/ui/checkbox/checkbox.js +21 -0
  74. package/dist/ui/src/components/ui/checkbox/checkbox.js.map +1 -0
  75. package/dist/ui/src/components/ui/collapsible/collapsible.js +26 -0
  76. package/dist/ui/src/components/ui/collapsible/collapsible.js.map +1 -0
  77. package/dist/ui/src/components/ui/combobox/combobox.js +85 -0
  78. package/dist/ui/src/components/ui/combobox/combobox.js.map +1 -0
  79. package/dist/ui/src/components/ui/command/command.js +118 -0
  80. package/dist/ui/src/components/ui/command/command.js.map +1 -0
  81. package/dist/ui/src/components/ui/context-menu/context-menu.js +134 -0
  82. package/dist/ui/src/components/ui/context-menu/context-menu.js.map +1 -0
  83. package/dist/ui/src/components/ui/dialog/dialog.js +92 -0
  84. package/dist/ui/src/components/ui/dialog/dialog.js.map +1 -0
  85. package/dist/ui/src/components/ui/direction/direction.js +2 -0
  86. package/dist/ui/src/components/ui/drawer/drawer.js +86 -0
  87. package/dist/ui/src/components/ui/drawer/drawer.js.map +1 -0
  88. package/dist/ui/src/components/ui/dropdown-menu/dropdown-menu.js +160 -0
  89. package/dist/ui/src/components/ui/dropdown-menu/dropdown-menu.js.map +1 -0
  90. package/dist/ui/src/components/ui/empty/empty.js +61 -0
  91. package/dist/ui/src/components/ui/empty/empty.js.map +1 -0
  92. package/dist/ui/src/components/ui/field/field.js +36 -0
  93. package/dist/ui/src/components/ui/field/field.js.map +1 -0
  94. package/dist/ui/src/components/ui/hover-card/hover-card.js +38 -0
  95. package/dist/ui/src/components/ui/hover-card/hover-card.js.map +1 -0
  96. package/dist/ui/src/components/ui/indicator/indicator.js +79 -0
  97. package/dist/ui/src/components/ui/indicator/indicator.js.map +1 -0
  98. package/dist/ui/src/components/ui/input/input.js +16 -0
  99. package/dist/ui/src/components/ui/input/input.js.map +1 -0
  100. package/dist/ui/src/components/ui/input-group/input-group.js +77 -0
  101. package/dist/ui/src/components/ui/input-group/input-group.js.map +1 -0
  102. package/dist/ui/src/components/ui/input-otp/input-otp.js +48 -0
  103. package/dist/ui/src/components/ui/input-otp/input-otp.js.map +1 -0
  104. package/dist/ui/src/components/ui/item/item.js +122 -0
  105. package/dist/ui/src/components/ui/item/item.js.map +1 -0
  106. package/dist/ui/src/components/ui/kbd/kbd.js +21 -0
  107. package/dist/ui/src/components/ui/kbd/kbd.js.map +1 -0
  108. package/dist/ui/src/components/ui/label/label.js +14 -0
  109. package/dist/ui/src/components/ui/label/label.js.map +1 -0
  110. package/dist/ui/src/components/ui/marker/marker.js +44 -0
  111. package/dist/ui/src/components/ui/marker/marker.js.map +1 -0
  112. package/dist/ui/src/components/ui/menubar/menubar.js +137 -0
  113. package/dist/ui/src/components/ui/menubar/menubar.js.map +1 -0
  114. package/dist/ui/src/components/ui/message/message.js +50 -0
  115. package/dist/ui/src/components/ui/message/message.js.map +1 -0
  116. package/dist/ui/src/components/ui/message-scroller/message-scroller.js +61 -0
  117. package/dist/ui/src/components/ui/message-scroller/message-scroller.js.map +1 -0
  118. package/dist/ui/src/components/ui/native-select/native-select.js +39 -0
  119. package/dist/ui/src/components/ui/native-select/native-select.js.map +1 -0
  120. package/dist/ui/src/components/ui/navigation-menu/navigation-menu.js +84 -0
  121. package/dist/ui/src/components/ui/navigation-menu/navigation-menu.js.map +1 -0
  122. package/dist/ui/src/components/ui/pagination/pagination.js +104 -0
  123. package/dist/ui/src/components/ui/pagination/pagination.js.map +1 -0
  124. package/dist/ui/src/components/ui/popover/popover.js +56 -0
  125. package/dist/ui/src/components/ui/popover/popover.js.map +1 -0
  126. package/dist/ui/src/components/ui/progress/progress.js +70 -0
  127. package/dist/ui/src/components/ui/progress/progress.js.map +1 -0
  128. package/dist/ui/src/components/ui/questionnaire/questionnaire.js +171 -0
  129. package/dist/ui/src/components/ui/questionnaire/questionnaire.js.map +1 -0
  130. package/dist/ui/src/components/ui/radio-group/radio-group.js +29 -0
  131. package/dist/ui/src/components/ui/radio-group/radio-group.js.map +1 -0
  132. package/dist/ui/src/components/ui/resizable/resizable.js +29 -0
  133. package/dist/ui/src/components/ui/resizable/resizable.js.map +1 -0
  134. package/dist/ui/src/components/ui/scroll-area/scroll-area.js +119 -0
  135. package/dist/ui/src/components/ui/scroll-area/scroll-area.js.map +1 -0
  136. package/dist/ui/src/components/ui/select/select.js +99 -0
  137. package/dist/ui/src/components/ui/select/select.js.map +1 -0
  138. package/dist/ui/src/components/ui/separator/separator.js +30 -0
  139. package/dist/ui/src/components/ui/separator/separator.js.map +1 -0
  140. package/dist/ui/src/components/ui/sheet/sheet.js +89 -0
  141. package/dist/ui/src/components/ui/sheet/sheet.js.map +1 -0
  142. package/dist/ui/src/components/ui/sidebar/sidebar.js +383 -0
  143. package/dist/ui/src/components/ui/sidebar/sidebar.js.map +1 -0
  144. package/dist/ui/src/components/ui/skeleton/skeleton.js +14 -0
  145. package/dist/ui/src/components/ui/skeleton/skeleton.js.map +1 -0
  146. package/dist/ui/src/components/ui/slider/slider.js +49 -0
  147. package/dist/ui/src/components/ui/slider/slider.js.map +1 -0
  148. package/dist/ui/src/components/ui/spinner/spinner.js +28 -0
  149. package/dist/ui/src/components/ui/spinner/spinner.js.map +1 -0
  150. package/dist/ui/src/components/ui/switch/switch.js +20 -0
  151. package/dist/ui/src/components/ui/switch/switch.js.map +1 -0
  152. package/dist/ui/src/components/ui/table/table.js +68 -0
  153. package/dist/ui/src/components/ui/table/table.js.map +1 -0
  154. package/dist/ui/src/components/ui/tabs/tabs.js +50 -0
  155. package/dist/ui/src/components/ui/tabs/tabs.js.map +1 -0
  156. package/dist/ui/src/components/ui/textarea/textarea.js +14 -0
  157. package/dist/ui/src/components/ui/textarea/textarea.js.map +1 -0
  158. package/dist/ui/src/components/ui/toast/toast.js +124 -0
  159. package/dist/ui/src/components/ui/toast/toast.js.map +1 -0
  160. package/dist/ui/src/components/ui/toggle/toggle.js +37 -0
  161. package/dist/ui/src/components/ui/toggle/toggle.js.map +1 -0
  162. package/dist/ui/src/components/ui/toggle-group/toggle-group.js +56 -0
  163. package/dist/ui/src/components/ui/toggle-group/toggle-group.js.map +1 -0
  164. package/dist/ui/src/components/ui/tooltip/tooltip.js +42 -0
  165. package/dist/ui/src/components/ui/tooltip/tooltip.js.map +1 -0
  166. package/dist/ui/src/hooks/use-media-player.js +140 -0
  167. package/dist/ui/src/hooks/use-media-player.js.map +1 -0
  168. package/dist/ui/src/hooks/use-merged-refs.js +18 -0
  169. package/dist/ui/src/hooks/use-merged-refs.js.map +1 -0
  170. package/dist/ui/src/hooks/use-mobile.js +20 -0
  171. package/dist/ui/src/hooks/use-mobile.js.map +1 -0
  172. package/dist/ui/src/lib/first-weekday.js +34 -0
  173. package/dist/ui/src/lib/first-weekday.js.map +1 -0
  174. package/dist/ui/src/lib/popup-list.js +26 -0
  175. package/dist/ui/src/lib/popup-list.js.map +1 -0
  176. package/dist/ui/src/lib/utils.js +21 -0
  177. package/dist/ui/src/lib/utils.js.map +1 -0
  178. package/package.json +1 -1
  179. package/dist/chunks/date-range-picker-CWVcHgy2.js.map +0 -1
  180. package/dist/chunks/input-syWxjY2U.js.map +0 -1
  181. package/dist/chunks/toggle-Bxg8P-61.js +0 -490
  182. package/dist/chunks/toggle-Bxg8P-61.js.map +0 -1
  183. package/dist/date-picker.js.map +0 -1
  184. package/dist/index.js.map +0 -1
  185. package/dist/rich-text-editor.js.map +0 -1
@@ -1,345 +1,2 @@
1
- import { c as Button, n as Popover, r as PopoverContent, s as PopoverTrigger, t as Input, u as cn } from "./chunks/input-syWxjY2U.js";
2
- import { i as firstWeekdayOf, n as dateToDay, o as Calendar, r as dayToDate } from "./chunks/date-range-picker-CWVcHgy2.js";
3
- import { useEffect, useId, useMemo, useRef, useState } from "react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- import { IconCalendar } from "@tabler/icons-react";
6
- //#region ../ui/src/components/edyn/date-picker/date-text.ts
7
- /**
8
- * Reading and writing a calendar day as the text a person types.
9
- *
10
- * A day is the string `yyyy-mm-dd` everywhere here, never a Date: a Date is an instant, and the instant for "5 March" is a
11
- * different calendar day in another time zone (local midnight serialised as UTC lands on the 4th east of Greenwich). The
12
- * string is also what `<input type="date">`, JSON and a .NET `DateOnly` use. Strings of that shape sort and compare as
13
- * days, so min, max and disabled days are compared as plain strings with no Date involved.
14
- */
15
- var SHAPE = {
16
- day: "2-digit",
17
- month: "2-digit",
18
- year: "numeric"
19
- };
20
- /** The order a locale writes day, month and year in: en-GB is day, month, year; en-US month, day, year; sv year first. */
21
- var datePartsOf = (locale) => new Intl.DateTimeFormat(locale, SHAPE).formatToParts(new Date(2e3, 0, 2, 12)).flatMap((part) => part.type === "day" || part.type === "month" || part.type === "year" ? [part.type] : []);
22
- /** What to type, written the locale's way: `DD/MM/YYYY` for en-GB. */
23
- var datePatternOf = (locale) => new Intl.DateTimeFormat(locale, SHAPE).formatToParts(new Date(2e3, 0, 2, 12)).map((part) => {
24
- if (part.type === "day") return "DD";
25
- if (part.type === "month") return "MM";
26
- return part.type === "year" ? "YYYY" : part.value;
27
- }).join("").trim();
28
- /** A day written the locale's way: `05/03/2026` for en-GB. */
29
- var formatDay = (day, locale) => {
30
- const date = dayToDate(day);
31
- return date === void 0 ? "" : new Intl.DateTimeFormat(locale, SHAPE).format(date);
32
- };
33
- var isRealDay = (year, month, dayOfMonth) => {
34
- if (year < 1e3 || month < 1 || month > 12 || dayOfMonth < 1) return false;
35
- const date = new Date(year, month - 1, dayOfMonth, 12);
36
- return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === dayOfMonth;
37
- };
38
- var toDay = (year, month, dayOfMonth) => dateToDay(new Date(year, month - 1, dayOfMonth, 12)) ?? "";
39
- /**
40
- * Reads typed text as a day. The locale's order decides which number is the day; a first number of four digits is always
41
- * a year (so `2026-03-05` is read the same everywhere); the separator can be anything that is not a digit, and eight
42
- * digits with none (`05032026`) are split by the order. A year must have four digits: `5/3/26` is refused, not guessed.
43
- */
44
- var parseDateText = (text, locale) => {
45
- const trimmed = text.trim();
46
- if (trimmed === "") return { kind: "empty" };
47
- if (!/^[\d\s./\-,]+$/.test(trimmed)) return {
48
- kind: "problem",
49
- problem: "format"
50
- };
51
- const order = datePartsOf(locale);
52
- let numbers = trimmed.match(/\d+/g) ?? [];
53
- let parts = order;
54
- if (numbers.length === 1 && numbers[0]?.length === 8) {
55
- const digits = numbers[0];
56
- numbers = order[0] === "year" ? [
57
- digits.slice(0, 4),
58
- digits.slice(4, 6),
59
- digits.slice(6)
60
- ] : [
61
- digits.slice(0, 2),
62
- digits.slice(2, 4),
63
- digits.slice(4)
64
- ];
65
- }
66
- if (numbers.length !== 3) return {
67
- kind: "problem",
68
- problem: "format"
69
- };
70
- if (numbers[0]?.length === 4) parts = [
71
- "year",
72
- "month",
73
- "day"
74
- ];
75
- const read = {
76
- day: "",
77
- month: "",
78
- year: ""
79
- };
80
- parts.forEach((part, index) => {
81
- read[part] = numbers[index] ?? "";
82
- });
83
- if (read.year.length !== 4 || read.day.length > 2 || read.month.length > 2) return {
84
- kind: "problem",
85
- problem: "format"
86
- };
87
- const [year, month, dayOfMonth] = [
88
- Number(read.year),
89
- Number(read.month),
90
- Number(read.day)
91
- ];
92
- return isRealDay(year, month, dayOfMonth) ? {
93
- kind: "day",
94
- day: toDay(year, month, dayOfMonth)
95
- } : {
96
- kind: "problem",
97
- problem: "notReal"
98
- };
99
- };
100
- /** Whether a day is allowed, and if not, which limit it breaks. */
101
- var dayProblem = (day, { min, max, disabledDates }) => {
102
- if (min !== void 0 && day < min) return "beforeMin";
103
- if (max !== void 0 && day > max) return "afterMax";
104
- return (typeof disabledDates === "function" ? disabledDates(day) : disabledDates?.includes(day) ?? false) ? "unavailable" : void 0;
105
- };
106
- //#endregion
107
- //#region ../ui/src/components/edyn/date-picker/date-picker.tsx
108
- var DEFAULT_DATE_PICKER_LABELS = {
109
- choose: "Choose date",
110
- format: (pattern) => `Enter a date as ${pattern}.`,
111
- notReal: "That date does not exist.",
112
- beforeMin: (min) => `Choose ${min} or later.`,
113
- afterMax: (max) => `Choose ${max} or earlier.`,
114
- unavailable: "That date is not available."
115
- };
116
- var problemText = (problem, labels, locale, limits, pattern) => {
117
- switch (problem) {
118
- case "format": return labels.format(pattern);
119
- case "notReal": return labels.notReal;
120
- case "beforeMin": return labels.beforeMin(limits.min === void 0 ? "" : formatDay(limits.min, locale));
121
- case "afterMax": return labels.afterMax(limits.max === void 0 ? "" : formatDay(limits.max, locale));
122
- default: return labels.unavailable;
123
- }
124
- };
125
- /**
126
- * One calendar day, typed or picked. The field takes the day in the locale's order (05/03/2026 in en-GB) and reads it
127
- * when it loses focus, saying inline what is wrong with it; the button, or Alt+ArrowDown in the field, opens a calendar.
128
- */
129
- var DatePicker = ({ id, value, onValueChange, min, max, disabledDates, disabled = false, locale = "en-GB", calendarLocale, placeholder, "aria-label": ariaLabel, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy, labels: labelOverrides, className }) => {
130
- const labels = useMemo(() => ({
131
- ...DEFAULT_DATE_PICKER_LABELS,
132
- ...labelOverrides
133
- }), [labelOverrides]);
134
- const pattern = useMemo(() => datePatternOf(locale), [locale]);
135
- const current = value === "" ? void 0 : value;
136
- const errorId = useId();
137
- const refField = useRef(null);
138
- const refInput = useRef(null);
139
- const refPointer = useRef(false);
140
- const refKnown = useRef(current);
141
- const refRefused = useRef(null);
142
- const [text, setText] = useState(current === void 0 ? "" : formatDay(current, locale));
143
- const [problem, setProblem] = useState(null);
144
- const [open, setOpen] = useState(false);
145
- useEffect(() => {
146
- if (current !== refKnown.current) {
147
- refKnown.current = current;
148
- refRefused.current = null;
149
- setText(current === void 0 ? "" : formatDay(current, locale));
150
- setProblem(null);
151
- }
152
- }, [current, locale]);
153
- const report = (day, state) => {
154
- refKnown.current = day;
155
- refRefused.current = state.kind === "refused" ? `${state.text}\u0000${state.problem}` : null;
156
- onValueChange(day, state);
157
- };
158
- /**
159
- * Reads the text: a day is reported and written back in full, anything else is said inline and reported as no day,
160
- * with the state saying whether the field is empty or holds text it refused.
161
- */
162
- const commit = (typed) => {
163
- const parsed = parseDateText(typed, locale);
164
- if (parsed.kind === "empty") {
165
- setProblem(null);
166
- if (current !== void 0 || refRefused.current !== null) report(void 0, { kind: "empty" });
167
- return;
168
- }
169
- const found = parsed.kind === "problem" ? parsed.problem : dayProblem(parsed.day, {
170
- min,
171
- max,
172
- disabledDates
173
- });
174
- if (found !== void 0) {
175
- setProblem(found);
176
- const message = problemText(found, labels, locale, {
177
- min,
178
- max
179
- }, pattern);
180
- if (current !== void 0 || refRefused.current !== `${typed}\u0000${message}`) report(void 0, {
181
- kind: "refused",
182
- text: typed,
183
- problem: message
184
- });
185
- return;
186
- }
187
- if (parsed.kind === "day") {
188
- setProblem(null);
189
- setText(formatDay(parsed.day, locale));
190
- if (parsed.day !== current || refRefused.current !== null) report(parsed.day, { kind: "day" });
191
- }
192
- };
193
- const pick = (date) => {
194
- const day = dateToDay(date);
195
- if (day === void 0) return;
196
- setProblem(null);
197
- setText(formatDay(day, locale));
198
- if (day !== current || refRefused.current !== null) report(day, { kind: "day" });
199
- setOpen(false);
200
- };
201
- /**
202
- * Text is read as the person leaves the field. A day (or nothing) is taken at once; a message about text that is not a
203
- * day is shown too, unless they are only on the way to the calendar: a press of the mouse on the button, or focus
204
- * going into the calendar that Alt+ArrowDown opened, with the text half typed. Leaving the picker for anywhere else
205
- * reads whatever is typed.
206
- */
207
- const handleBlur = (event) => {
208
- const next = event.relatedTarget;
209
- const intoCalendar = next?.closest("[data-slot=\"popover-content\"]") != null;
210
- const intoButton = next?.closest("[data-slot=\"date-picker-trigger\"]") != null;
211
- const typed = refInput.current?.value ?? "";
212
- if (!(intoCalendar || intoButton || next !== null && refField.current?.contains(next) === true)) {
213
- commit(typed);
214
- return;
215
- }
216
- if (event.target !== refInput.current) return;
217
- const onTheWay = intoCalendar || intoButton && refPointer.current;
218
- const parsed = parseDateText(typed, locale);
219
- if (parsed.kind === "empty" || parsed.kind === "day" && dayProblem(parsed.day, {
220
- min,
221
- max,
222
- disabledDates
223
- }) === void 0 || !onTheWay) commit(typed);
224
- };
225
- const handleKeyDown = (event) => {
226
- if (event.key === "ArrowDown" && event.altKey && !disabled) {
227
- event.preventDefault();
228
- setOpen(true);
229
- return;
230
- }
231
- if (event.key === "Escape" && open) {
232
- event.preventDefault();
233
- event.stopPropagation();
234
- setOpen(false);
235
- return;
236
- }
237
- if (event.key === "Enter") {
238
- const parsed = parseDateText(event.currentTarget.value, locale);
239
- if (parsed.kind !== "empty" && (parsed.kind === "problem" || dayProblem(parsed.day, {
240
- min,
241
- max,
242
- disabledDates
243
- }) !== void 0)) event.preventDefault();
244
- commit(event.currentTarget.value);
245
- }
246
- };
247
- const selected = dayToDate(current);
248
- const limits = {
249
- min,
250
- max
251
- };
252
- const invalid = problem !== null || ariaInvalid === true || ariaInvalid === "true";
253
- const describedBy = [ariaDescribedBy, problem === null ? void 0 : errorId].filter(Boolean).join(" ") || void 0;
254
- const isOff = (date) => {
255
- const day = dateToDay(date);
256
- return day !== void 0 && dayProblem(day, {
257
- min,
258
- max,
259
- disabledDates
260
- }) !== void 0;
261
- };
262
- const today = /* @__PURE__ */ new Date();
263
- const start = dayToDate(min);
264
- const end = dayToDate(max);
265
- const month = selected ?? (start !== void 0 && today < start ? start : end !== void 0 && today > end ? end : today);
266
- return /* @__PURE__ */ jsxs("div", {
267
- "data-slot": "date-picker",
268
- className: cn("flex flex-col gap-1.5", className),
269
- children: [/* @__PURE__ */ jsxs("div", {
270
- ref: refField,
271
- className: "relative",
272
- onPointerDownCapture: () => {
273
- refPointer.current = true;
274
- },
275
- onPointerUpCapture: () => {
276
- refPointer.current = false;
277
- },
278
- children: [/* @__PURE__ */ jsx(Input, {
279
- ref: refInput,
280
- id,
281
- type: "text",
282
- inputMode: "numeric",
283
- autoComplete: "off",
284
- "data-slot": "date-picker-input",
285
- value: text,
286
- placeholder: placeholder ?? pattern,
287
- disabled,
288
- "aria-label": ariaLabel,
289
- "aria-invalid": invalid ? true : void 0,
290
- "aria-describedby": describedBy,
291
- className: "pr-9",
292
- onChange: (event) => {
293
- setText(event.target.value);
294
- setProblem(null);
295
- },
296
- onBlur: handleBlur,
297
- onKeyDown: handleKeyDown
298
- }), /* @__PURE__ */ jsxs(Popover, {
299
- open,
300
- onOpenChange: setOpen,
301
- children: [/* @__PURE__ */ jsx(PopoverTrigger, {
302
- render: /* @__PURE__ */ jsx(Button, {
303
- variant: "ghost",
304
- size: "icon-sm",
305
- "data-slot": "date-picker-trigger",
306
- "aria-label": labels.choose,
307
- disabled,
308
- className: "absolute top-0.5 right-0.5",
309
- onBlur: handleBlur
310
- }),
311
- children: /* @__PURE__ */ jsx(IconCalendar, { "aria-hidden": "true" })
312
- }), /* @__PURE__ */ jsx(PopoverContent, {
313
- anchor: refField,
314
- align: "start",
315
- className: "w-auto p-0",
316
- finalFocus: refInput,
317
- onBlur: handleBlur,
318
- children: /* @__PURE__ */ jsx(Calendar, {
319
- mode: "single",
320
- required: true,
321
- autoFocus: true,
322
- locale: calendarLocale,
323
- weekStartsOn: firstWeekdayOf(locale),
324
- defaultMonth: month,
325
- startMonth: start,
326
- endMonth: end,
327
- selected,
328
- disabled: isOff,
329
- onSelect: pick
330
- })
331
- })]
332
- })]
333
- }), problem !== null && /* @__PURE__ */ jsx("p", {
334
- id: errorId,
335
- "data-slot": "date-picker-error",
336
- role: "alert",
337
- className: "text-sm text-destructive",
338
- children: problemText(problem, labels, locale, limits, pattern)
339
- })]
340
- });
341
- };
342
- //#endregion
1
+ import { DEFAULT_DATE_PICKER_LABELS, DatePicker } from "./ui/src/components/edyn/date-picker/date-picker.js";
343
2
  export { DEFAULT_DATE_PICKER_LABELS, DatePicker };
344
-
345
- //# sourceMappingURL=date-picker.js.map