@epilot/spark-ui 0.29.0 → 0.30.0
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.
- package/dist/calendar-lists-CTby2kR5.d.cts +27 -0
- package/dist/calendar-lists-DoloqsCN.d.ts +27 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +1 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/box.js +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.cjs +23 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +11 -2
- package/dist/components/calendar.d.ts +11 -2
- package/dist/components/calendar.js +23 -4
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +1 -1
- package/dist/components/card.js +2 -2
- package/dist/components/combobox.cjs +45 -15
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.d.cts +2 -0
- package/dist/components/combobox.d.ts +2 -0
- package/dist/components/combobox.js +46 -16
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +212 -0
- package/dist/components/input-date-time.cjs.map +1 -0
- package/dist/components/input-date-time.d.cts +38 -0
- package/dist/components/input-date-time.d.ts +38 -0
- package/dist/components/input-date-time.js +205 -0
- package/dist/components/input-date-time.js.map +1 -0
- package/dist/components/input-group.cjs +2 -2
- package/dist/components/input-group.js +2 -2
- package/dist/components/input-otp.cjs +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/select.cjs +2 -1
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.js +2 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toggle.cjs +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/lib/accent-theme.cjs +75 -17
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.d.cts +14 -1
- package/dist/lib/accent-theme.d.ts +14 -1
- package/dist/lib/accent-theme.js +74 -18
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-lists.cjs +222 -0
- package/dist/lib/calendar-lists.cjs.map +1 -0
- package/dist/lib/calendar-lists.d.cts +4 -0
- package/dist/lib/calendar-lists.d.ts +4 -0
- package/dist/lib/calendar-lists.js +217 -0
- package/dist/lib/calendar-lists.js.map +1 -0
- package/dist/lib/control-glyphs.cjs +37 -0
- package/dist/lib/control-glyphs.cjs.map +1 -0
- package/dist/lib/control-glyphs.d.cts +11 -0
- package/dist/lib/control-glyphs.d.ts +11 -0
- package/dist/lib/control-glyphs.js +35 -0
- package/dist/lib/control-glyphs.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +155 -0
- package/dist/lib/date-time-mask.cjs.map +1 -0
- package/dist/lib/date-time-mask.d.cts +56 -0
- package/dist/lib/date-time-mask.d.ts +56 -0
- package/dist/lib/date-time-mask.js +147 -0
- package/dist/lib/date-time-mask.js.map +1 -0
- package/dist/lib/input-date-parts.cjs +154 -0
- package/dist/lib/input-date-parts.cjs.map +1 -0
- package/dist/lib/input-date-parts.d.cts +53 -0
- package/dist/lib/input-date-parts.d.ts +53 -0
- package/dist/lib/input-date-parts.js +147 -0
- package/dist/lib/input-date-parts.js.map +1 -0
- package/dist/styles/spark-default.css +366 -24
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { apply, applyPaste, dateStatus, formatDate, isDateMaskKey, parseDate } from "ictus";
|
|
3
|
+
import { applyTime, applyTimePaste, formatTime, isTimeMaskKey, parseTime, timeStatus } from "ictus/time";
|
|
4
|
+
//#region src/lib/date-time-mask.ts
|
|
5
|
+
const DATE_LENGTH = 10;
|
|
6
|
+
const JOIN = ", ";
|
|
7
|
+
const TIME_START = 12;
|
|
8
|
+
const splitValue = (value) => ({
|
|
9
|
+
date: value.slice(0, DATE_LENGTH),
|
|
10
|
+
time: value.length > DATE_LENGTH ? value.slice(TIME_START) : ""
|
|
11
|
+
});
|
|
12
|
+
const join = (date, time) => time ? `${date}${JOIN}${time}` : date;
|
|
13
|
+
/** Keys the mask consumes; any other printable key is ignored. */
|
|
14
|
+
function isDateTimeMaskKey(key, withTime = false) {
|
|
15
|
+
return isDateMaskKey(key) || withTime && isTimeMaskKey(key);
|
|
16
|
+
}
|
|
17
|
+
function stepOverSeparators(value, caret, key) {
|
|
18
|
+
const isSeparator = (char) => char !== void 0 && !/\d/.test(char);
|
|
19
|
+
let at = caret;
|
|
20
|
+
if (key === "Backspace") while (at > 0 && isSeparator(value[at - 1])) at--;
|
|
21
|
+
if (key === "Delete") while (at < value.length && isSeparator(value[at])) at++;
|
|
22
|
+
return at;
|
|
23
|
+
}
|
|
24
|
+
function applyDate(value, caret, key, separator, selectionEnd) {
|
|
25
|
+
if (selectionEnd !== void 0 && selectionEnd !== caret) return apply({
|
|
26
|
+
value,
|
|
27
|
+
caret,
|
|
28
|
+
selectionEnd,
|
|
29
|
+
key,
|
|
30
|
+
separator
|
|
31
|
+
});
|
|
32
|
+
return apply({
|
|
33
|
+
value,
|
|
34
|
+
caret: stepOverSeparators(value, caret, key),
|
|
35
|
+
key,
|
|
36
|
+
separator
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** One keystroke through the date (and time) mask: the next value and caret. */
|
|
40
|
+
function applyDateTimeMask({ caret, key, selectionEnd, separator, value, withTime = false }) {
|
|
41
|
+
if (!withTime) return applyDate(value, caret, key, separator, selectionEnd);
|
|
42
|
+
const { date, time } = splitValue(value);
|
|
43
|
+
const end = selectionEnd ?? caret;
|
|
44
|
+
const dateComplete = date.length === DATE_LENGTH;
|
|
45
|
+
if (end !== caret && caret < DATE_LENGTH && end > DATE_LENGTH) return applyDate(date, caret, key, separator, DATE_LENGTH);
|
|
46
|
+
if (!(caret > DATE_LENGTH || caret === DATE_LENGTH && dateComplete && key !== "Backspace")) {
|
|
47
|
+
const next = applyDate(date, caret, key, separator, end !== caret ? end : void 0);
|
|
48
|
+
return {
|
|
49
|
+
value: join(next.value, time),
|
|
50
|
+
caret: next.caret
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return applyTimePart({
|
|
54
|
+
caret,
|
|
55
|
+
date,
|
|
56
|
+
end,
|
|
57
|
+
key,
|
|
58
|
+
separator,
|
|
59
|
+
time,
|
|
60
|
+
value
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function applyTimePart({ caret, date, end, key, separator, time, value }) {
|
|
64
|
+
if (!isTimeMaskKey(key)) return {
|
|
65
|
+
value,
|
|
66
|
+
caret
|
|
67
|
+
};
|
|
68
|
+
const timeCaret = Math.max(0, caret - TIME_START);
|
|
69
|
+
const timeEnd = Math.max(0, end - TIME_START);
|
|
70
|
+
const hasSelection = timeEnd !== timeCaret;
|
|
71
|
+
if (key === "Backspace" && !hasSelection && timeCaret === 0) {
|
|
72
|
+
const next = applyDate(date, DATE_LENGTH, key, separator);
|
|
73
|
+
return {
|
|
74
|
+
value: join(next.value, time),
|
|
75
|
+
caret: next.caret
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const next = applyTime({
|
|
79
|
+
value: time,
|
|
80
|
+
caret: hasSelection ? timeCaret : stepOverSeparators(time, timeCaret, key),
|
|
81
|
+
selectionEnd: hasSelection ? timeEnd : void 0,
|
|
82
|
+
key
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
value: join(date, next.value),
|
|
86
|
+
caret: TIME_START + next.caret
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Pasted text through the mask, e.g. `24.11.2026 14:30` or `24/11/2026`. */
|
|
90
|
+
function applyDateTimePaste({ caret, pasted, selectionEnd, separator, value, withTime = false }) {
|
|
91
|
+
const [datePart = "", timePart = ""] = pasted.trim().split(/[,\sT]+/);
|
|
92
|
+
if (!withTime || !timePart) return applyPaste({
|
|
93
|
+
value,
|
|
94
|
+
caret,
|
|
95
|
+
selectionEnd,
|
|
96
|
+
pasted: datePart,
|
|
97
|
+
separator
|
|
98
|
+
});
|
|
99
|
+
const date = applyPaste({
|
|
100
|
+
value: "",
|
|
101
|
+
caret: 0,
|
|
102
|
+
pasted: datePart,
|
|
103
|
+
separator
|
|
104
|
+
}).value;
|
|
105
|
+
const time = applyTimePaste({
|
|
106
|
+
value: "",
|
|
107
|
+
caret: 0,
|
|
108
|
+
pasted: timePart
|
|
109
|
+
}).value;
|
|
110
|
+
const next = join(date, time);
|
|
111
|
+
return {
|
|
112
|
+
value: next,
|
|
113
|
+
caret: next.length
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** `empty`, `incomplete`, `invalid` or `valid`, for the date and, with `withTime`, the time. */
|
|
117
|
+
function dateTimeStatus(text, withTime = false) {
|
|
118
|
+
const { date, time } = splitValue(text);
|
|
119
|
+
const dateState = dateStatus(date);
|
|
120
|
+
if (!withTime || dateState === "empty" || dateState === "invalid") return dateState;
|
|
121
|
+
if (dateState === "incomplete") return "incomplete";
|
|
122
|
+
const timeState = time ? timeStatus(time) : "incomplete";
|
|
123
|
+
return timeState === "empty" ? "incomplete" : timeState;
|
|
124
|
+
}
|
|
125
|
+
/** The date in the text, with its time when `withTime`; undefined until it is complete and real. */
|
|
126
|
+
function parseDateTime(text, withTime = false) {
|
|
127
|
+
if (dateTimeStatus(text, withTime) !== "valid") return void 0;
|
|
128
|
+
const { date, time } = splitValue(text);
|
|
129
|
+
const day = parseDate(date);
|
|
130
|
+
if (!day || !withTime) return day;
|
|
131
|
+
const clock = parseTime(time);
|
|
132
|
+
if (!clock) return void 0;
|
|
133
|
+
day.setHours(clock.hours, clock.minutes, 0, 0);
|
|
134
|
+
return day;
|
|
135
|
+
}
|
|
136
|
+
/** The day in the text, even while its time is still being typed. */
|
|
137
|
+
function parseDatePart(text) {
|
|
138
|
+
return parseDate(splitValue(text).date);
|
|
139
|
+
}
|
|
140
|
+
/** The masked text for a date: `24.11.2026` or `24.11.2026, 14:30`. */
|
|
141
|
+
function formatDateTime(date, separator, withTime = false) {
|
|
142
|
+
return join(formatDate(date, separator), withTime ? formatTime(date) : "");
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { applyDateTimeMask, applyDateTimePaste, dateTimeStatus, formatDateTime, formatTime, isDateTimeMaskKey, parseDatePart, parseDateTime };
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=date-time-mask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time-mask.js","names":[],"sources":["../../src/lib/date-time-mask.ts"],"sourcesContent":["import {\n apply,\n applyPaste,\n dateStatus,\n formatDate,\n isDateMaskKey,\n parseDate,\n} from 'ictus'\nimport {\n applyTime,\n applyTimePaste,\n formatTime,\n isTimeMaskKey,\n parseTime,\n timeStatus,\n} from 'ictus/time'\n\n// Fixed positions: `DD.MM.YYYY` then `, HH:MM`, i.e. day-month-year with a one-character\n// separator, the only layout Input Date Time types\nconst DATE_LENGTH = 10\nconst JOIN = ', '\nconst TIME_START = DATE_LENGTH + JOIN.length\n\ntype MaskOptions = { separator: string; withTime?: boolean }\n\nexport type DateTimeMaskInput = MaskOptions & {\n caret: number\n key: string\n selectionEnd?: number\n value: string\n}\n\nexport type DateTimeMaskResult = { caret: number; value: string }\n\nexport type DateTimeStatus = 'empty' | 'incomplete' | 'invalid' | 'valid'\n\nconst splitValue = (value: string) => ({\n date: value.slice(0, DATE_LENGTH),\n time: value.length > DATE_LENGTH ? value.slice(TIME_START) : '',\n})\n\nconst join = (date: string, time: string) =>\n time ? `${date}${JOIN}${time}` : date\n\n/** Keys the mask consumes; any other printable key is ignored. */\nexport function isDateTimeMaskKey(key: string, withTime = false) {\n return isDateMaskKey(key) || (withTime && isTimeMaskKey(key))\n}\n\n// Backspace right after a separator deletes the digit before it, Delete right before one the digit after\nfunction stepOverSeparators(value: string, caret: number, key: string) {\n const isSeparator = (char: string | undefined) =>\n char !== undefined && !/\\d/.test(char)\n let at = caret\n if (key === 'Backspace') while (at > 0 && isSeparator(value[at - 1])) at--\n if (key === 'Delete') while (at < value.length && isSeparator(value[at])) at++\n return at\n}\n\nfunction applyDate(\n value: string,\n caret: number,\n key: string,\n separator: string,\n selectionEnd?: number,\n): DateTimeMaskResult {\n if (selectionEnd !== undefined && selectionEnd !== caret)\n return apply({ value, caret, selectionEnd, key, separator })\n return apply({\n value,\n caret: stepOverSeparators(value, caret, key),\n key,\n separator,\n })\n}\n\n/** One keystroke through the date (and time) mask: the next value and caret. */\nexport function applyDateTimeMask({\n caret,\n key,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: DateTimeMaskInput): DateTimeMaskResult {\n if (!withTime) return applyDate(value, caret, key, separator, selectionEnd)\n\n const { date, time } = splitValue(value)\n const end = selectionEnd ?? caret\n const dateComplete = date.length === DATE_LENGTH\n\n // A selection reaching into the time drops the time; one inside it edits the time only\n if (end !== caret && caret < DATE_LENGTH && end > DATE_LENGTH)\n return applyDate(date, caret, key, separator, DATE_LENGTH)\n\n const inTime =\n caret > DATE_LENGTH ||\n (caret === DATE_LENGTH && dateComplete && key !== 'Backspace')\n if (!inTime) {\n const next = applyDate(\n date,\n caret,\n key,\n separator,\n end !== caret ? end : undefined,\n )\n return { value: join(next.value, time), caret: next.caret }\n }\n\n return applyTimePart({ caret, date, end, key, separator, time, value })\n}\n\nfunction applyTimePart({\n caret,\n date,\n end,\n key,\n separator,\n time,\n value,\n}: {\n caret: number\n date: string\n end: number\n key: string\n separator: string\n time: string\n value: string\n}): DateTimeMaskResult {\n if (!isTimeMaskKey(key)) return { value, caret }\n const timeCaret = Math.max(0, caret - TIME_START)\n const timeEnd = Math.max(0, end - TIME_START)\n const hasSelection = timeEnd !== timeCaret\n\n // Backspace at the start of the time steps back into the year\n if (key === 'Backspace' && !hasSelection && timeCaret === 0) {\n const next = applyDate(date, DATE_LENGTH, key, separator)\n return { value: join(next.value, time), caret: next.caret }\n }\n\n const next = applyTime({\n value: time,\n caret: hasSelection ? timeCaret : stepOverSeparators(time, timeCaret, key),\n selectionEnd: hasSelection ? timeEnd : undefined,\n key,\n })\n return { value: join(date, next.value), caret: TIME_START + next.caret }\n}\n\n/** Pasted text through the mask, e.g. `24.11.2026 14:30` or `24/11/2026`. */\nexport function applyDateTimePaste({\n caret,\n pasted,\n selectionEnd,\n separator,\n value,\n withTime = false,\n}: MaskOptions & {\n caret: number\n pasted: string\n selectionEnd?: number\n value: string\n}): DateTimeMaskResult {\n const [datePart = '', timePart = ''] = pasted.trim().split(/[,\\sT]+/)\n if (!withTime || !timePart)\n return applyPaste({\n value,\n caret,\n selectionEnd,\n pasted: datePart,\n separator,\n })\n\n const date = applyPaste({\n value: '',\n caret: 0,\n pasted: datePart,\n separator,\n }).value\n const time = applyTimePaste({ value: '', caret: 0, pasted: timePart }).value\n const next = join(date, time)\n return { value: next, caret: next.length }\n}\n\n/** `empty`, `incomplete`, `invalid` or `valid`, for the date and, with `withTime`, the time. */\nexport function dateTimeStatus(text: string, withTime = false): DateTimeStatus {\n const { date, time } = splitValue(text)\n const dateState = dateStatus(date)\n if (!withTime || dateState === 'empty' || dateState === 'invalid')\n return dateState\n if (dateState === 'incomplete') return 'incomplete'\n const timeState = time ? timeStatus(time) : 'incomplete'\n return timeState === 'empty' ? 'incomplete' : timeState\n}\n\n/** The date in the text, with its time when `withTime`; undefined until it is complete and real. */\nexport function parseDateTime(\n text: string,\n withTime = false,\n): Date | undefined {\n if (dateTimeStatus(text, withTime) !== 'valid') return undefined\n const { date, time } = splitValue(text)\n const day = parseDate(date)\n if (!day || !withTime) return day\n const clock = parseTime(time)\n if (!clock) return undefined\n day.setHours(clock.hours, clock.minutes, 0, 0)\n return day\n}\n\n/** The day in the text, even while its time is still being typed. */\nexport function parseDatePart(text: string) {\n return parseDate(splitValue(text).date)\n}\n\n/** The masked text for a date: `24.11.2026` or `24.11.2026, 14:30`. */\nexport function formatDateTime(\n date: Date,\n separator: string,\n withTime = false,\n) {\n return join(formatDate(date, separator), withTime ? formatTime(date) : '')\n}\n\nexport { formatTime }\n"],"mappings":";;;;AAmBA,MAAM,cAAc;AACpB,MAAM,OAAO;AACb,MAAM,aAAa;AAenB,MAAM,cAAc,WAAmB;CACrC,MAAM,MAAM,MAAM,GAAG,WAAW;CAChC,MAAM,MAAM,SAAS,cAAc,MAAM,MAAM,UAAU,IAAI;AAC/D;AAEA,MAAM,QAAQ,MAAc,SAC1B,OAAO,GAAG,OAAO,OAAO,SAAS;;AAGnC,SAAgB,kBAAkB,KAAa,WAAW,OAAO;CAC/D,OAAO,cAAc,GAAG,KAAM,YAAY,cAAc,GAAG;AAC7D;AAGA,SAAS,mBAAmB,OAAe,OAAe,KAAa;CACrE,MAAM,eAAe,SACnB,SAAS,KAAA,KAAa,CAAC,KAAK,KAAK,IAAI;CACvC,IAAI,KAAK;CACT,IAAI,QAAQ,aAAa,OAAO,KAAK,KAAK,YAAY,MAAM,KAAK,EAAE,GAAG;CACtE,IAAI,QAAQ,UAAU,OAAO,KAAK,MAAM,UAAU,YAAY,MAAM,GAAG,GAAG;CAC1E,OAAO;AACT;AAEA,SAAS,UACP,OACA,OACA,KACA,WACA,cACoB;CACpB,IAAI,iBAAiB,KAAA,KAAa,iBAAiB,OACjD,OAAO,MAAM;EAAE;EAAO;EAAO;EAAc;EAAK;CAAU,CAAC;CAC7D,OAAO,MAAM;EACX;EACA,OAAO,mBAAmB,OAAO,OAAO,GAAG;EAC3C;EACA;CACF,CAAC;AACH;;AAGA,SAAgB,kBAAkB,EAChC,OACA,KACA,cACA,WACA,OACA,WAAW,SAC6B;CACxC,IAAI,CAAC,UAAU,OAAO,UAAU,OAAO,OAAO,KAAK,WAAW,YAAY;CAE1E,MAAM,EAAE,MAAM,SAAS,WAAW,KAAK;CACvC,MAAM,M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bol.toStringTag, { value: "Module" });
|
|
4
|
+
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
+
const require_lib_date_time_mask = require("./date-time-mask.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_chunk.__toESM(react);
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let ictus_time = require("ictus/time");
|
|
10
|
+
let cn = require("cn");
|
|
11
|
+
//#region src/lib/input-date-parts.tsx
|
|
12
|
+
const MINUTES_PER_DAY = 1440;
|
|
13
|
+
const MIN_STEP = 5;
|
|
14
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
15
|
+
function timesOf(step, extra) {
|
|
16
|
+
const times = [];
|
|
17
|
+
for (let minutes = 0; minutes < MINUTES_PER_DAY; minutes += Math.max(MIN_STEP, step)) times.push((0, ictus_time.formatTime)({
|
|
18
|
+
hours: Math.floor(minutes / 60),
|
|
19
|
+
minutes: minutes % 60,
|
|
20
|
+
seconds: 0
|
|
21
|
+
}));
|
|
22
|
+
if (extra && !times.includes(extra)) {
|
|
23
|
+
const after = times.findIndex((time) => time > extra);
|
|
24
|
+
times.splice(after === -1 ? times.length : after, 0, extra);
|
|
25
|
+
}
|
|
26
|
+
return times;
|
|
27
|
+
}
|
|
28
|
+
function TimeList({ defaultTime, label, onPick, open, selectedTime, times }) {
|
|
29
|
+
const listRef = react.useRef(null);
|
|
30
|
+
react.useEffect(() => {
|
|
31
|
+
if (!open) return;
|
|
32
|
+
const frame = requestAnimationFrame(() => {
|
|
33
|
+
listRef.current?.querySelector("[aria-selected=\"true\"]")?.scrollIntoView?.({ block: "center" });
|
|
34
|
+
});
|
|
35
|
+
return () => cancelAnimationFrame(frame);
|
|
36
|
+
}, [open]);
|
|
37
|
+
const moveFocus = (event) => {
|
|
38
|
+
const options = Array.from(listRef.current?.querySelectorAll("[role=\"option\"]") ?? []);
|
|
39
|
+
const index = options.indexOf(document.activeElement);
|
|
40
|
+
const target = {
|
|
41
|
+
ArrowDown: index + 1,
|
|
42
|
+
ArrowUp: index - 1,
|
|
43
|
+
End: options.length - 1,
|
|
44
|
+
Home: 0
|
|
45
|
+
}[event.key];
|
|
46
|
+
if (target === void 0) return;
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
options[Math.max(0, Math.min(options.length - 1, target))]?.focus();
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
51
|
+
className: "relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l",
|
|
52
|
+
"data-slot": "input-date-times",
|
|
53
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
54
|
+
"aria-label": label,
|
|
55
|
+
className: "absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2",
|
|
56
|
+
onKeyDown: moveFocus,
|
|
57
|
+
ref: listRef,
|
|
58
|
+
role: "listbox",
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
children: times.map((time) => {
|
|
61
|
+
const isSelected = time === selectedTime;
|
|
62
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
63
|
+
"aria-selected": isSelected,
|
|
64
|
+
className: (0, cn.cn)("shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline", isSelected && "bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))"),
|
|
65
|
+
onClick: () => onPick(time),
|
|
66
|
+
role: "option",
|
|
67
|
+
tabIndex: isSelected || !selectedTime && time === defaultTime ? 0 : -1,
|
|
68
|
+
type: "button",
|
|
69
|
+
children: time
|
|
70
|
+
}, time);
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
76
|
+
function useMaskHandlers({ commit, inputRef, onKeyDown, onOpen, onPaste, onRejectedKey, pickerOnly, separator, withTime }) {
|
|
77
|
+
const placeCaret = (caret) => {
|
|
78
|
+
const input = inputRef.current;
|
|
79
|
+
requestAnimationFrame(() => {
|
|
80
|
+
input?.setSelectionRange(caret, caret);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const handleKeyDown = (event) => {
|
|
84
|
+
onKeyDown?.(event);
|
|
85
|
+
if (event.defaultPrevented) return;
|
|
86
|
+
if (event.key === "ArrowDown") {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
onOpen();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
92
|
+
if (!require_lib_date_time_mask.isDateTimeMaskKey(event.key, withTime)) {
|
|
93
|
+
if (event.key.length === 1) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
onRejectedKey();
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
const next = require_lib_date_time_mask.applyDateTimeMask({
|
|
101
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
102
|
+
key: event.key,
|
|
103
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
104
|
+
separator,
|
|
105
|
+
value: event.currentTarget.value,
|
|
106
|
+
withTime
|
|
107
|
+
});
|
|
108
|
+
commit(next.value);
|
|
109
|
+
placeCaret(next.caret);
|
|
110
|
+
};
|
|
111
|
+
const handlePaste = (event) => {
|
|
112
|
+
onPaste?.(event);
|
|
113
|
+
if (event.defaultPrevented || pickerOnly) return;
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
const next = require_lib_date_time_mask.applyDateTimePaste({
|
|
116
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
117
|
+
pasted: event.clipboardData.getData("text"),
|
|
118
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
119
|
+
separator,
|
|
120
|
+
value: event.currentTarget.value,
|
|
121
|
+
withTime
|
|
122
|
+
});
|
|
123
|
+
commit(next.value);
|
|
124
|
+
placeCaret(next.caret);
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
onKeyDown: handleKeyDown,
|
|
128
|
+
onPaste: handlePaste
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** A polite message that is read again when it repeats. */
|
|
132
|
+
function useAnnouncement() {
|
|
133
|
+
const [message, setMessage] = react.useState({
|
|
134
|
+
text: "",
|
|
135
|
+
count: 0
|
|
136
|
+
});
|
|
137
|
+
const announce = react.useCallback((text) => setMessage((current) => ({
|
|
138
|
+
text,
|
|
139
|
+
count: current.count + 1
|
|
140
|
+
})), []);
|
|
141
|
+
return [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
142
|
+
"aria-live": "polite",
|
|
143
|
+
className: "sr-only",
|
|
144
|
+
"data-slot": "input-date-status",
|
|
145
|
+
children: [message.text, message.count % 2 ? "\xA0" : ""]
|
|
146
|
+
}), announce];
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
exports.TimeList = TimeList;
|
|
150
|
+
exports.timesOf = timesOf;
|
|
151
|
+
exports.useAnnouncement = useAnnouncement;
|
|
152
|
+
exports.useMaskHandlers = useMaskHandlers;
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=input-date-parts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-date-parts.cjs","names":["React","isDateTimeMaskKey","applyDateTimeMask","applyDateTimePaste"],"sources":["../../src/lib/input-date-parts.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport {\n applyDateTimeMask,\n applyDateTimePaste,\n formatTime,\n isDateTimeMaskKey,\n} from './date-time-mask'\n\nconst MINUTES_PER_DAY = 24 * 60\n// a finer step would list hundreds of buttons; a typed off-grid time is still offered\nconst MIN_STEP = 5\n\n/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */\nexport function timesOf(step: number, extra?: string) {\n const times: string[] = []\n for (\n let minutes = 0;\n minutes < MINUTES_PER_DAY;\n minutes += Math.max(MIN_STEP, step)\n ) {\n times.push(\n formatTime({\n hours: Math.floor(minutes / 60),\n minutes: minutes % 60,\n seconds: 0,\n }),\n )\n }\n if (extra && !times.includes(extra)) {\n const after = times.findIndex((time) => time > extra)\n times.splice(after === -1 ? times.length : after, 0, extra)\n }\n return times\n}\n\nexport function TimeList({\n defaultTime,\n label,\n onPick,\n open,\n selectedTime,\n times,\n}: {\n defaultTime: string\n label?: string\n onPick: (time: string) => void\n open: boolean\n selectedTime?: string\n times: string[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the picked time scrolls into view when the popup opens; found in the DOM rather than with a ref per option\n React.useEffect(() => {\n if (!open) return\n const frame = requestAnimationFrame(() => {\n listRef.current\n ?.querySelector('[aria-selected=\"true\"]')\n ?.scrollIntoView?.({ block: 'center' })\n })\n return () => cancelAnimationFrame(frame)\n }, [open])\n\n const moveFocus = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const options = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"option\"]') ??\n [],\n )\n const index = options.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: options.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n options[Math.max(0, Math.min(options.length - 1, target))]?.focus()\n }\n\n return (\n // the column runs the calendar's full height and the list scrolls inside it\n <div\n className=\"relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l\"\n data-slot=\"input-date-times\"\n >\n <div\n aria-label={label}\n className=\"absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2\"\n onKeyDown={moveFocus}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {times.map((time) => {\n const isSelected = time === selectedTime\n return (\n <button\n aria-selected={isSelected}\n className={cn(\n 'shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n isSelected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n key={time}\n onClick={() => onPick(time)}\n role=\"option\"\n tabIndex={\n isSelected || (!selectedTime && time === defaultTime) ? 0 : -1\n }\n type=\"button\"\n >\n {time}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n\ntype MaskHandlers = {\n commit: (next: string) => void\n inputRef: React.RefObject<HTMLInputElement | null>\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n onOpen: () => void\n onPaste?: React.ClipboardEventHandler<HTMLInputElement>\n onRejectedKey: () => void\n pickerOnly: boolean\n separator: string\n withTime: boolean\n}\n\n/** Keystrokes and pastes through the date (and time) mask. */\nexport function useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen,\n onPaste,\n onRejectedKey,\n pickerOnly,\n separator,\n withTime,\n}: MaskHandlers) {\n const placeCaret = (caret: number) => {\n const input = inputRef.current\n requestAnimationFrame(() => {\n input?.setSelectionRange(caret, caret)\n })\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n onOpen()\n return\n }\n if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return\n if (!isDateTimeMaskKey(event.key, withTime)) {\n // a printable key the mask ignores: say why nothing appeared\n if (event.key.length === 1) {\n event.preventDefault()\n onRejectedKey()\n }\n return\n }\n event.preventDefault()\n const next = applyDateTimeMask({\n caret: event.currentTarget.selectionStart ?? 0,\n key: event.key,\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event)\n if (event.defaultPrevented || pickerOnly) return\n event.preventDefault()\n const next = applyDateTimePaste({\n caret: event.currentTarget.selectionStart ?? 0,\n pasted: event.clipboardData.getData('text'),\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n return { onKeyDown: handleKeyDown, onPaste: handlePaste }\n}\n\n/** A polite message that is read again when it repeats. */\nexport function useAnnouncement() {\n const [message, setMessage] = React.useState({ text: '', count: 0 })\n const announce = React.useCallback(\n (text: string) =>\n setMessage((current) => ({ text, count: current.count + 1 })),\n [],\n )\n // the trailing no-break space alternates, so a repeated message is new text and read again\n const region = (\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"input-date-status\">\n {message.text}\n {message.count % 2 ? ' ' : ''}\n </span>\n )\n return [region, announce] as const\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,kBAAkB;AAExB,MAAM,WAAW;;AAGjB,SAAgB,QAAQ,MAAc,OAAgB;CACpD,MAAM,QAAkB,CAAC;CACzB,KACE,IAAI,UAAU,GACd,UAAU,iBACV,WAAW,KAAK,IAAI,UAAU,IAAI,GAElC,MAAM,MAAA,GAAA,WAAA,YACO;EACT,OAAO,KAAK,MAAM,UAAU,EAAE;EAC9B,SAAS,UAAU;EACnB,SAAS;CACX,CAAC,CACH;CAEF,IAAI,SAAS,CAAC,MAAM,SAAS,KAAK,GAAG;EACnC,MAAM,QAAQ,MAAM,WAAW,SAAS,OAAO,KAAK;EACpD,MAAM,OAAO,UAAU,KAAK,MAAM,SAAS,OAAO,GAAG,KAAK;CAC5D;CACA,OAAO;AACT;AAEA,SAAgB,SAAS,EACvB,aACA,OACA,QACA,MACA,cACA,SAQC;CACD,MAAM,UAAUA,MAAM,OAAuB,IAAI;CAGjD,MAAM,gBAAgB;EACpB,IAAI,CAAC,M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AA,MALL,QAAD;EAAM,aAAU;EAAS,WAAU;EAAU,aAAU;YAAvD,CACG,QAAQ,MACR,QAAQ,QAAQ,IAAI,SAAM,EACvB;EAEK,GAAG,QAAQ;AAC1B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/input-date-parts.d.ts
|
|
6
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
7
|
+
declare function timesOf(step: number, extra?: string): string[];
|
|
8
|
+
declare function TimeList({
|
|
9
|
+
defaultTime,
|
|
10
|
+
label,
|
|
11
|
+
onPick,
|
|
12
|
+
open,
|
|
13
|
+
selectedTime,
|
|
14
|
+
times
|
|
15
|
+
}: {
|
|
16
|
+
defaultTime: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
onPick: (time: string) => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
selectedTime?: string;
|
|
21
|
+
times: string[];
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type MaskHandlers = {
|
|
24
|
+
commit: (next: string) => void;
|
|
25
|
+
inputRef: React$1.RefObject<HTMLInputElement | null>;
|
|
26
|
+
onKeyDown?: React$1.KeyboardEventHandler<HTMLInputElement>;
|
|
27
|
+
onOpen: () => void;
|
|
28
|
+
onPaste?: React$1.ClipboardEventHandler<HTMLInputElement>;
|
|
29
|
+
onRejectedKey: () => void;
|
|
30
|
+
pickerOnly: boolean;
|
|
31
|
+
separator: string;
|
|
32
|
+
withTime: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
35
|
+
declare function useMaskHandlers({
|
|
36
|
+
commit,
|
|
37
|
+
inputRef,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
onOpen,
|
|
40
|
+
onPaste,
|
|
41
|
+
onRejectedKey,
|
|
42
|
+
pickerOnly,
|
|
43
|
+
separator,
|
|
44
|
+
withTime
|
|
45
|
+
}: MaskHandlers): {
|
|
46
|
+
onKeyDown: (event: React$1.KeyboardEvent<HTMLInputElement>) => void;
|
|
47
|
+
onPaste: (event: React$1.ClipboardEvent<HTMLInputElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** A polite message that is read again when it repeats. */
|
|
50
|
+
declare function useAnnouncement(): readonly [import("react/jsx-runtime").JSX.Element, (text: string) => void];
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
53
|
+
//# sourceMappingURL=input-date-parts.d.cts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/input-date-parts.d.ts
|
|
6
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
7
|
+
declare function timesOf(step: number, extra?: string): string[];
|
|
8
|
+
declare function TimeList({
|
|
9
|
+
defaultTime,
|
|
10
|
+
label,
|
|
11
|
+
onPick,
|
|
12
|
+
open,
|
|
13
|
+
selectedTime,
|
|
14
|
+
times
|
|
15
|
+
}: {
|
|
16
|
+
defaultTime: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
onPick: (time: string) => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
selectedTime?: string;
|
|
21
|
+
times: string[];
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type MaskHandlers = {
|
|
24
|
+
commit: (next: string) => void;
|
|
25
|
+
inputRef: React$1.RefObject<HTMLInputElement | null>;
|
|
26
|
+
onKeyDown?: React$1.KeyboardEventHandler<HTMLInputElement>;
|
|
27
|
+
onOpen: () => void;
|
|
28
|
+
onPaste?: React$1.ClipboardEventHandler<HTMLInputElement>;
|
|
29
|
+
onRejectedKey: () => void;
|
|
30
|
+
pickerOnly: boolean;
|
|
31
|
+
separator: string;
|
|
32
|
+
withTime: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
35
|
+
declare function useMaskHandlers({
|
|
36
|
+
commit,
|
|
37
|
+
inputRef,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
onOpen,
|
|
40
|
+
onPaste,
|
|
41
|
+
onRejectedKey,
|
|
42
|
+
pickerOnly,
|
|
43
|
+
separator,
|
|
44
|
+
withTime
|
|
45
|
+
}: MaskHandlers): {
|
|
46
|
+
onKeyDown: (event: React$1.KeyboardEvent<HTMLInputElement>) => void;
|
|
47
|
+
onPaste: (event: React$1.ClipboardEvent<HTMLInputElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** A polite message that is read again when it repeats. */
|
|
50
|
+
declare function useAnnouncement(): readonly [import("react/jsx-runtime").JSX.Element, (text: string) => void];
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
53
|
+
//# sourceMappingURL=input-date-parts.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { applyDateTimeMask, applyDateTimePaste, formatTime, isDateTimeMaskKey } from "./date-time-mask.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/lib/input-date-parts.tsx
|
|
8
|
+
const MINUTES_PER_DAY = 1440;
|
|
9
|
+
const MIN_STEP = 5;
|
|
10
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
11
|
+
function timesOf(step, extra) {
|
|
12
|
+
const times = [];
|
|
13
|
+
for (let minutes = 0; minutes < MINUTES_PER_DAY; minutes += Math.max(MIN_STEP, step)) times.push(formatTime({
|
|
14
|
+
hours: Math.floor(minutes / 60),
|
|
15
|
+
minutes: minutes % 60,
|
|
16
|
+
seconds: 0
|
|
17
|
+
}));
|
|
18
|
+
if (extra && !times.includes(extra)) {
|
|
19
|
+
const after = times.findIndex((time) => time > extra);
|
|
20
|
+
times.splice(after === -1 ? times.length : after, 0, extra);
|
|
21
|
+
}
|
|
22
|
+
return times;
|
|
23
|
+
}
|
|
24
|
+
function TimeList({ defaultTime, label, onPick, open, selectedTime, times }) {
|
|
25
|
+
const listRef = React$1.useRef(null);
|
|
26
|
+
React$1.useEffect(() => {
|
|
27
|
+
if (!open) return;
|
|
28
|
+
const frame = requestAnimationFrame(() => {
|
|
29
|
+
listRef.current?.querySelector("[aria-selected=\"true\"]")?.scrollIntoView?.({ block: "center" });
|
|
30
|
+
});
|
|
31
|
+
return () => cancelAnimationFrame(frame);
|
|
32
|
+
}, [open]);
|
|
33
|
+
const moveFocus = (event) => {
|
|
34
|
+
const options = Array.from(listRef.current?.querySelectorAll("[role=\"option\"]") ?? []);
|
|
35
|
+
const index = options.indexOf(document.activeElement);
|
|
36
|
+
const target = {
|
|
37
|
+
ArrowDown: index + 1,
|
|
38
|
+
ArrowUp: index - 1,
|
|
39
|
+
End: options.length - 1,
|
|
40
|
+
Home: 0
|
|
41
|
+
}[event.key];
|
|
42
|
+
if (target === void 0) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
options[Math.max(0, Math.min(options.length - 1, target))]?.focus();
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l",
|
|
48
|
+
"data-slot": "input-date-times",
|
|
49
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
50
|
+
"aria-label": label,
|
|
51
|
+
className: "absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2",
|
|
52
|
+
onKeyDown: moveFocus,
|
|
53
|
+
ref: listRef,
|
|
54
|
+
role: "listbox",
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
children: times.map((time) => {
|
|
57
|
+
const isSelected = time === selectedTime;
|
|
58
|
+
return /* @__PURE__ */ jsx("button", {
|
|
59
|
+
"aria-selected": isSelected,
|
|
60
|
+
className: cn("shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline", isSelected && "bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))"),
|
|
61
|
+
onClick: () => onPick(time),
|
|
62
|
+
role: "option",
|
|
63
|
+
tabIndex: isSelected || !selectedTime && time === defaultTime ? 0 : -1,
|
|
64
|
+
type: "button",
|
|
65
|
+
children: time
|
|
66
|
+
}, time);
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
72
|
+
function useMaskHandlers({ commit, inputRef, onKeyDown, onOpen, onPaste, onRejectedKey, pickerOnly, separator, withTime }) {
|
|
73
|
+
const placeCaret = (caret) => {
|
|
74
|
+
const input = inputRef.current;
|
|
75
|
+
requestAnimationFrame(() => {
|
|
76
|
+
input?.setSelectionRange(caret, caret);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const handleKeyDown = (event) => {
|
|
80
|
+
onKeyDown?.(event);
|
|
81
|
+
if (event.defaultPrevented) return;
|
|
82
|
+
if (event.key === "ArrowDown") {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
onOpen();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
88
|
+
if (!isDateTimeMaskKey(event.key, withTime)) {
|
|
89
|
+
if (event.key.length === 1) {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
onRejectedKey();
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
const next = applyDateTimeMask({
|
|
97
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
98
|
+
key: event.key,
|
|
99
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
100
|
+
separator,
|
|
101
|
+
value: event.currentTarget.value,
|
|
102
|
+
withTime
|
|
103
|
+
});
|
|
104
|
+
commit(next.value);
|
|
105
|
+
placeCaret(next.caret);
|
|
106
|
+
};
|
|
107
|
+
const handlePaste = (event) => {
|
|
108
|
+
onPaste?.(event);
|
|
109
|
+
if (event.defaultPrevented || pickerOnly) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
const next = applyDateTimePaste({
|
|
112
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
113
|
+
pasted: event.clipboardData.getData("text"),
|
|
114
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
115
|
+
separator,
|
|
116
|
+
value: event.currentTarget.value,
|
|
117
|
+
withTime
|
|
118
|
+
});
|
|
119
|
+
commit(next.value);
|
|
120
|
+
placeCaret(next.caret);
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
onKeyDown: handleKeyDown,
|
|
124
|
+
onPaste: handlePaste
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** A polite message that is read again when it repeats. */
|
|
128
|
+
function useAnnouncement() {
|
|
129
|
+
const [message, setMessage] = React$1.useState({
|
|
130
|
+
text: "",
|
|
131
|
+
count: 0
|
|
132
|
+
});
|
|
133
|
+
const announce = React$1.useCallback((text) => setMessage((current) => ({
|
|
134
|
+
text,
|
|
135
|
+
count: current.count + 1
|
|
136
|
+
})), []);
|
|
137
|
+
return [/* @__PURE__ */ jsxs("span", {
|
|
138
|
+
"aria-live": "polite",
|
|
139
|
+
className: "sr-only",
|
|
140
|
+
"data-slot": "input-date-status",
|
|
141
|
+
children: [message.text, message.count % 2 ? "\xA0" : ""]
|
|
142
|
+
}), announce];
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=input-date-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-date-parts.js","names":["React"],"sources":["../../src/lib/input-date-parts.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport {\n applyDateTimeMask,\n applyDateTimePaste,\n formatTime,\n isDateTimeMaskKey,\n} from './date-time-mask'\n\nconst MINUTES_PER_DAY = 24 * 60\n// a finer step would list hundreds of buttons; a typed off-grid time is still offered\nconst MIN_STEP = 5\n\n/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */\nexport function timesOf(step: number, extra?: string) {\n const times: string[] = []\n for (\n let minutes = 0;\n minutes < MINUTES_PER_DAY;\n minutes += Math.max(MIN_STEP, step)\n ) {\n times.push(\n formatTime({\n hours: Math.floor(minutes / 60),\n minutes: minutes % 60,\n seconds: 0,\n }),\n )\n }\n if (extra && !times.includes(extra)) {\n const after = times.findIndex((time) => time > extra)\n times.splice(after === -1 ? times.length : after, 0, extra)\n }\n return times\n}\n\nexport function TimeList({\n defaultTime,\n label,\n onPick,\n open,\n selectedTime,\n times,\n}: {\n defaultTime: string\n label?: string\n onPick: (time: string) => void\n open: boolean\n selectedTime?: string\n times: string[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the picked time scrolls into view when the popup opens; found in the DOM rather than with a ref per option\n React.useEffect(() => {\n if (!open) return\n const frame = requestAnimationFrame(() => {\n listRef.current\n ?.querySelector('[aria-selected=\"true\"]')\n ?.scrollIntoView?.({ block: 'center' })\n })\n return () => cancelAnimationFrame(frame)\n }, [open])\n\n const moveFocus = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const options = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"option\"]') ??\n [],\n )\n const index = options.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: options.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n options[Math.max(0, Math.min(options.length - 1, target))]?.focus()\n }\n\n return (\n // the column runs the calendar's full height and the list scrolls inside it\n <div\n className=\"relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l\"\n data-slot=\"input-date-times\"\n >\n <div\n aria-label={label}\n className=\"absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2\"\n onKeyDown={moveFocus}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {times.map((time) => {\n const isSelected = time === selectedTime\n return (\n <button\n aria-selected={isSelected}\n className={cn(\n 'shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n isSelected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n key={time}\n onClick={() => onPick(time)}\n role=\"option\"\n tabIndex={\n isSelected || (!selectedTime && time === defaultTime) ? 0 : -1\n }\n type=\"button\"\n >\n {time}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n\ntype MaskHandlers = {\n commit: (next: string) => void\n inputRef: React.RefObject<HTMLInputElement | null>\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n onOpen: () => void\n onPaste?: React.ClipboardEventHandler<HTMLInputElement>\n onRejectedKey: () => void\n pickerOnly: boolean\n separator: string\n withTime: boolean\n}\n\n/** Keystrokes and pastes through the date (and time) mask. */\nexport function useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen,\n onPaste,\n onRejectedKey,\n pickerOnly,\n separator,\n withTime,\n}: MaskHandlers) {\n const placeCaret = (caret: number) => {\n const input = inputRef.current\n requestAnimationFrame(() => {\n input?.setSelectionRange(caret, caret)\n })\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n onOpen()\n return\n }\n if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return\n if (!isDateTimeMaskKey(event.key, withTime)) {\n // a printable key the mask ignores: say why nothing appeared\n if (event.key.length === 1) {\n event.preventDefault()\n onRejectedKey()\n }\n return\n }\n event.preventDefault()\n const next = applyDateTimeMask({\n caret: event.currentTarget.selectionStart ?? 0,\n key: event.key,\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event)\n if (event.defaultPrevented || pickerOnly) return\n event.preventDefault()\n const next = applyDateTimePaste({\n caret: event.currentTarget.selectionStart ?? 0,\n pasted: event.clipboardData.getData('text'),\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n return { onKeyDown: handleKeyDown, onPaste: handlePaste }\n}\n\n/** A polite message that is read again when it repeats. */\nexport function useAnnouncement() {\n const [message, setMessage] = React.useState({ text: '', count: 0 })\n const announce = React.useCallback(\n (text: string) =>\n setMessage((current) => ({ text, count: current.count + 1 })),\n [],\n )\n // the trailing no-break space alternates, so a repeated message is new text and read again\n const region = (\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"input-date-status\">\n {message.text}\n {message.count % 2 ? ' ' : ''}\n </span>\n )\n return [region, announce] as const\n}\n"],"mappings":";;;;;;;AAWA,MAAM,kBAAkB;AAExB,MAAM,WAAW;;AAGjB,SAAgB,QAAQ,MAAc,OAAgB;CACpD,MAAM,QAAkB,CAAC;CACzB,KACE,IAAI,UAAU,GACd,UAAU,iBACV,WAAW,KAAK,IAAI,UAAU,IAAI,GAElC,MAAM,KACJ,WAAW;EACT,OAAO,KAAK,MAAM,UAAU,EAAE;EAC9B,SAAS,U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