@tensor_1/react 2.46.0 → 2.48.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/README.md +509 -1
- package/dist/{SchedulingCalendar-B6TakO2h.d.ts → SchedulingCalendar-WWyFL3Eo.d.ts} +51 -2
- package/dist/announce.d.ts +10 -0
- package/dist/announce.js +30 -0
- package/dist/chart-analytic.cjs +33 -25
- package/dist/chart-preset.cjs +23 -15
- package/dist/chart.cjs +23 -15
- package/dist/combobox-model.d.ts +10 -1
- package/dist/combobox-model.js +15 -0
- package/dist/command-palette-model.d.ts +44 -0
- package/dist/command-palette-model.js +36 -0
- package/dist/components/AccountMenu.d.ts +44 -0
- package/dist/components/AccountMenu.js +43 -0
- package/dist/components/AppShell.d.ts +45 -2
- package/dist/components/AppShell.js +116 -5
- package/dist/components/AuditLog.d.ts +128 -0
- package/dist/components/AuditLog.js +196 -0
- package/dist/components/BrandProfiles.js +4 -3
- package/dist/components/Breadcrumbs.d.ts +9 -2
- package/dist/components/Breadcrumbs.js +3 -2
- package/dist/components/BusyBar.d.ts +13 -0
- package/dist/components/BusyBar.js +10 -0
- package/dist/components/BusyRegion.d.ts +18 -0
- package/dist/components/BusyRegion.js +12 -0
- package/dist/components/Button.d.ts +33 -5
- package/dist/components/Button.js +12 -6
- package/dist/components/ButtonFeedback.d.ts +30 -0
- package/dist/components/ButtonFeedback.js +78 -0
- package/dist/components/Card.d.ts +18 -1
- package/dist/components/Card.js +5 -1
- package/dist/components/ChangeHighlight.d.ts +30 -0
- package/dist/components/ChangeHighlight.js +21 -0
- package/dist/components/ChartCore.js +2 -1
- package/dist/components/Checkbox.d.ts +27 -1
- package/dist/components/Checkbox.js +31 -2
- package/dist/components/CodeDisplay.d.ts +65 -0
- package/dist/components/CodeDisplay.js +124 -0
- package/dist/components/Combobox.d.ts +27 -6
- package/dist/components/Combobox.js +195 -58
- package/dist/components/CommandPalette.d.ts +36 -1
- package/dist/components/CommandPalette.js +254 -2
- package/dist/components/ContactCard.d.ts +66 -0
- package/dist/components/ContactCard.js +74 -0
- package/dist/components/Count.d.ts +24 -0
- package/dist/components/Count.js +32 -0
- package/dist/components/DataWorkspace.d.ts +167 -0
- package/dist/components/DataWorkspace.js +383 -0
- package/dist/components/DateFieldParts.d.ts +2 -1
- package/dist/components/DateFieldParts.js +7 -0
- package/dist/components/DatePicker.d.ts +9 -2
- package/dist/components/DatePicker.js +67 -28
- package/dist/components/DateRangePicker.d.ts +12 -2
- package/dist/components/DateRangePicker.js +13 -12
- package/dist/components/DelayedRender.d.ts +15 -0
- package/dist/components/DelayedRender.js +10 -0
- package/dist/components/DetailPage.d.ts +7 -1
- package/dist/components/DetailPage.js +2 -1
- package/dist/components/Dialogs.d.ts +71 -10
- package/dist/components/Dialogs.js +130 -30
- package/dist/components/DiffViewer.d.ts +23 -3
- package/dist/components/DiffViewer.js +26 -12
- package/dist/components/DiscardPrompt.d.ts +1 -0
- package/dist/components/DiscardPrompt.js +16 -0
- package/dist/components/DisplayPreferences.d.ts +83 -0
- package/dist/components/DisplayPreferences.js +185 -0
- package/dist/components/Drawer.d.ts +1 -0
- package/dist/components/EditorialHome.d.ts +23 -3
- package/dist/components/EditorialHome.js +16 -11
- package/dist/components/EntityPicker.d.ts +20 -3
- package/dist/components/EntityPicker.js +32 -13
- package/dist/components/FilterEditor.d.ts +18 -4
- package/dist/components/FilterEditor.js +141 -19
- package/dist/components/InfoTip.js +11 -12
- package/dist/components/InlineEdit.d.ts +87 -20
- package/dist/components/InlineEdit.js +197 -54
- package/dist/components/Input.d.ts +12 -2
- package/dist/components/Input.js +5 -3
- package/dist/components/Kbd.d.ts +6 -1
- package/dist/components/Kbd.js +6 -6
- package/dist/components/Lightbox.d.ts +41 -5
- package/dist/components/Lightbox.js +95 -9
- package/dist/components/MatchReview.d.ts +40 -1
- package/dist/components/MatchReview.js +130 -4
- package/dist/components/MetricInput.js +3 -2
- package/dist/components/Modal.d.ts +3 -1
- package/dist/components/Modal.js +13 -4
- package/dist/components/NavFavourites.d.ts +5 -0
- package/dist/components/NavFavourites.js +7 -7
- package/dist/components/OtpInput.d.ts +33 -0
- package/dist/components/OtpInput.js +123 -0
- package/dist/components/PageHeader.d.ts +7 -1
- package/dist/components/PageHeader.js +2 -2
- package/dist/components/Pagination.js +6 -5
- package/dist/components/PasswordInput.d.ts +34 -0
- package/dist/components/PasswordInput.js +101 -0
- package/dist/components/Peek.js +3 -3
- package/dist/components/Popover.js +2 -0
- package/dist/components/PrintLayout.d.ts +63 -0
- package/dist/components/PrintLayout.js +114 -0
- package/dist/components/QrCode.d.ts +47 -0
- package/dist/components/QrCode.js +55 -0
- package/dist/components/QrScanner.d.ts +95 -0
- package/dist/components/QrScanner.js +266 -0
- package/dist/components/RelationshipGraph.d.ts +32 -1
- package/dist/components/RelationshipGraph.js +18 -5
- package/dist/components/RelationshipGraphLayered.d.ts +1 -1
- package/dist/components/RelationshipGraphLayered.js +190 -115
- package/dist/components/RelationshipGraphList.js +33 -6
- package/dist/components/RuleBuilder.js +39 -7
- package/dist/components/SaveStatus.d.ts +7 -1
- package/dist/components/SaveStatus.js +13 -4
- package/dist/components/SchedulingAgenda.d.ts +3 -1
- package/dist/components/SchedulingCalendar.d.ts +3 -1
- package/dist/components/SchedulingCalendar.js +43 -4
- package/dist/components/SchedulingResourceDay.d.ts +57 -0
- package/dist/components/SchedulingResourceDay.js +287 -0
- package/dist/components/SchedulingTimeGrid.d.ts +3 -1
- package/dist/components/SchedulingTimeline.d.ts +3 -1
- package/dist/components/SearchBar.d.ts +1 -0
- package/dist/components/SearchSuggest.d.ts +23 -3
- package/dist/components/SearchSuggest.js +48 -17
- package/dist/components/Segmented.d.ts +39 -4
- package/dist/components/Segmented.js +31 -3
- package/dist/components/Select.d.ts +3 -2
- package/dist/components/Select.js +1 -1
- package/dist/components/ShortcutHint.d.ts +11 -10
- package/dist/components/ShortcutHint.js +44 -38
- package/dist/components/Sidebar.d.ts +36 -4
- package/dist/components/Sidebar.js +37 -12
- package/dist/components/SortableList.d.ts +45 -0
- package/dist/components/SortableList.js +134 -0
- package/dist/components/Spinner.d.ts +7 -1
- package/dist/components/Spinner.js +7 -1
- package/dist/components/Stat.d.ts +28 -3
- package/dist/components/Stat.js +13 -3
- package/dist/components/States.d.ts +7 -1
- package/dist/components/States.js +7 -1
- package/dist/components/StatusPill.d.ts +14 -3
- package/dist/components/StatusPill.js +11 -3
- package/dist/components/Steps.js +2 -1
- package/dist/components/Table.d.ts +16 -2
- package/dist/components/Table.js +8 -4
- package/dist/components/TableControls.js +18 -58
- package/dist/components/TableOverflowProbe.d.ts +12 -0
- package/dist/components/TableOverflowProbe.js +27 -0
- package/dist/components/Tabs.d.ts +2 -1
- package/dist/components/Tabs.js +1 -0
- package/dist/components/TagInput.d.ts +67 -0
- package/dist/components/TagInput.js +342 -0
- package/dist/components/Textarea.d.ts +5 -0
- package/dist/components/Textarea.js +2 -2
- package/dist/components/TimePicker.d.ts +80 -0
- package/dist/components/TimePicker.js +347 -0
- package/dist/components/Toast.js +3 -2
- package/dist/components/Tooltip.d.ts +8 -4
- package/dist/components/Tooltip.js +24 -21
- package/dist/components/Tree.d.ts +8 -0
- package/dist/components/Tree.js +11 -5
- package/dist/display-preferences-model.d.ts +53 -0
- package/dist/display-preferences-model.js +64 -0
- package/dist/emoji.cjs +28 -35
- package/dist/filter-model.d.ts +59 -3
- package/dist/filter-model.js +67 -2
- package/dist/hooks/useChangeHighlight.d.ts +33 -0
- package/dist/hooks/useChangeHighlight.js +44 -0
- package/dist/hooks/useDelayedPending.d.ts +22 -0
- package/dist/hooks/useDelayedPending.js +35 -0
- package/dist/hooks/useDialog.d.ts +5 -0
- package/dist/hooks/useDialog.js +3 -2
- package/dist/hooks/useOptimisticValue.d.ts +51 -0
- package/dist/hooks/useOptimisticValue.js +61 -0
- package/dist/hooks/useReducedMotion.d.ts +4 -1
- package/dist/hooks/useReducedMotion.js +7 -1
- package/dist/hooks/useResolvedFilterLabels.d.ts +15 -0
- package/dist/hooks/useResolvedFilterLabels.js +34 -0
- package/dist/hooks/useVirtualRows.d.ts +21 -2
- package/dist/hooks/useVirtualRows.js +30 -3
- package/dist/icons/Icon.d.ts +1 -1
- package/dist/index.cjs +18977 -13378
- package/dist/index.d.cts +3065 -664
- package/dist/index.d.ts +46 -16
- package/dist/index.js +149 -7
- package/dist/labels-context.d.ts +93 -3
- package/dist/motion-timing.d.ts +8 -0
- package/dist/motion-timing.js +8 -0
- package/dist/overlay-stack.d.ts +6 -0
- package/dist/overlay-stack.js +13 -0
- package/dist/qr-model.d.ts +65 -0
- package/dist/qr-model.js +323 -0
- package/dist/relationship-graph-model.d.ts +78 -3
- package/dist/relationship-graph-model.js +112 -5
- package/dist/reorder.d.ts +30 -0
- package/dist/reorder.js +74 -0
- package/dist/rich-text.cjs +4 -2
- package/dist/scheduling-resource-model.d.ts +76 -0
- package/dist/scheduling-resource-model.js +74 -0
- package/dist/search-suggest-model.js +3 -1
- package/dist/shell-context.d.ts +11 -0
- package/dist/shell-context.js +7 -0
- package/dist/time-field-model.d.ts +46 -0
- package/dist/time-field-model.js +152 -0
- package/dist/toast-store.d.ts +17 -1
- package/dist/toast-store.js +23 -7
- package/package.json +2 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uix time-field model — pure helpers behind `TimePicker` (HAR-1835): how a locale writes a time
|
|
3
|
+
* of day, how a typed time is read, and how the arrow keys step it. No DOM, no React, no runtime
|
|
4
|
+
* import, so the unit test loads this file directly (time-field-model.test.mjs).
|
|
5
|
+
*
|
|
6
|
+
* A time is a wall-clock `HH:mm` string (what `<input type="time">` holds): 24-hour, zero-padded,
|
|
7
|
+
* no seconds, no zone.
|
|
8
|
+
*/
|
|
9
|
+
/** Whether `HH:mm` names a time of day (00:00 to 23:59). */
|
|
10
|
+
declare function isValidTimeKey(value: string | null | undefined): value is string;
|
|
11
|
+
/** Minutes since midnight of `HH:mm`. */
|
|
12
|
+
declare const timeToMinutes: (value: string) => number;
|
|
13
|
+
/** `HH:mm` of a minute of the day (wrapped into 0 … 1439). */
|
|
14
|
+
declare const minutesToTime: (minutes: number) => string;
|
|
15
|
+
/** Whether `locale` writes times on a 12-hour clock (en-US: yes; de, en-GB, bs: no). */
|
|
16
|
+
declare function uses12Hour(locale?: string | readonly string[]): boolean;
|
|
17
|
+
/** A time in the locale's own shape: 14:30 in German, 2:30 PM in en-US. `hour12` overrides the locale. */
|
|
18
|
+
declare function formatTimeKey(value: string, locale?: string | readonly string[], hour12?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Where the hour and the minutes end in `formatTimeKey(value, locale, hour12)` (character offsets),
|
|
21
|
+
* found from the formatter's own parts, so "오후 2:30" (ko, the day period first) and "2:30 PM"
|
|
22
|
+
* both work. `null` when the value is not a time.
|
|
23
|
+
*/
|
|
24
|
+
declare function timePartEnds(value: string, locale?: string | readonly string[], hour12?: boolean): {
|
|
25
|
+
hour: number;
|
|
26
|
+
minute: number;
|
|
27
|
+
} | null;
|
|
28
|
+
/**
|
|
29
|
+
* Read a typed time. Accepts `14:30`, `14.30`, `14h30`, `1430`, `930`, `9` and, with a day period,
|
|
30
|
+
* `2:30 pm`, `2pm`, `2:30 p.m.` (and the locale's own words). Without a day period the hour is
|
|
31
|
+
* read on the 24-hour clock. Returns `HH:mm`, or `null` when the text is not a time.
|
|
32
|
+
*/
|
|
33
|
+
declare function parseTimeInput(text: string, locale?: string | readonly string[]): string | null;
|
|
34
|
+
/** Whether `min` is after `max`: an overnight range (22:00 to 06:00) that wraps round midnight. */
|
|
35
|
+
declare const isOvernightRange: (min?: string, max?: string) => boolean;
|
|
36
|
+
/** Whether `value` is outside `min` / `max` (both `HH:mm`, inclusive; `min` after `max` wraps midnight). */
|
|
37
|
+
declare function isTimeOutOfRange(value: string, min?: string, max?: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The time `delta` minutes from `value`, for the arrow keys. Between `min` and `max` it stops at
|
|
40
|
+
* the ends; with neither it wraps round midnight. From an empty field it starts at `min`, or 00:00.
|
|
41
|
+
*/
|
|
42
|
+
declare function stepTime(value: string | null, delta: number, min?: string, max?: string): string;
|
|
43
|
+
/** The times a list offers: every `step` minutes from `min` (or 00:00) to `max` (or 23:59). */
|
|
44
|
+
declare function timeSlots(step: number, min?: string, max?: string): string[];
|
|
45
|
+
|
|
46
|
+
export { formatTimeKey, isOvernightRange, isTimeOutOfRange, isValidTimeKey, minutesToTime, parseTimeInput, stepTime, timePartEnds, timeSlots, timeToMinutes, uses12Hour };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
2
|
+
function isValidTimeKey(value) {
|
|
3
|
+
const match = value ? /^(\d{2}):(\d{2})$/.exec(value) : null;
|
|
4
|
+
return !!match && Number(match[1]) < 24 && Number(match[2]) < 60;
|
|
5
|
+
}
|
|
6
|
+
const timeToMinutes = (value) => Number(value.slice(0, 2)) * 60 + Number(value.slice(3, 5));
|
|
7
|
+
const minutesToTime = (minutes) => {
|
|
8
|
+
const m = (Math.round(minutes) % 1440 + 1440) % 1440;
|
|
9
|
+
return `${pad(Math.floor(m / 60))}:${pad(m % 60)}`;
|
|
10
|
+
};
|
|
11
|
+
function uses12Hour(locale) {
|
|
12
|
+
try {
|
|
13
|
+
const options = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions();
|
|
14
|
+
const cycle = options.hourCycle;
|
|
15
|
+
return cycle === "h11" || cycle === "h12";
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const at = (value) => new Date(Date.UTC(2026, 0, 1, Number(value.slice(0, 2)), Number(value.slice(3, 5))));
|
|
21
|
+
function formatTimeKey(value, locale, hour12) {
|
|
22
|
+
if (!isValidTimeKey(value)) return value;
|
|
23
|
+
const twelve = hour12 ?? uses12Hour(locale);
|
|
24
|
+
try {
|
|
25
|
+
return new Intl.DateTimeFormat(locale, {
|
|
26
|
+
hour: twelve ? "numeric" : "2-digit",
|
|
27
|
+
minute: "2-digit",
|
|
28
|
+
hourCycle: twelve ? "h12" : "h23",
|
|
29
|
+
timeZone: "UTC"
|
|
30
|
+
}).format(at(value));
|
|
31
|
+
} catch {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function timePartEnds(value, locale, hour12) {
|
|
36
|
+
if (!isValidTimeKey(value)) return null;
|
|
37
|
+
const twelve = hour12 ?? uses12Hour(locale);
|
|
38
|
+
try {
|
|
39
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
40
|
+
hour: twelve ? "numeric" : "2-digit",
|
|
41
|
+
minute: "2-digit",
|
|
42
|
+
hourCycle: twelve ? "h12" : "h23",
|
|
43
|
+
timeZone: "UTC"
|
|
44
|
+
}).formatToParts(at(value));
|
|
45
|
+
let offset = 0;
|
|
46
|
+
let hour = -1;
|
|
47
|
+
let minute = -1;
|
|
48
|
+
for (const part of parts) {
|
|
49
|
+
offset += part.value.length;
|
|
50
|
+
if (part.type === "hour") hour = offset;
|
|
51
|
+
if (part.type === "minute") minute = offset;
|
|
52
|
+
}
|
|
53
|
+
return hour >= 0 && minute >= 0 ? { hour, minute } : null;
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function dayPeriods(locale) {
|
|
59
|
+
const am = ["am", "a.m.", "a"];
|
|
60
|
+
const pm = ["pm", "p.m.", "p"];
|
|
61
|
+
try {
|
|
62
|
+
const fmt = new Intl.DateTimeFormat(locale, { hour: "numeric", hourCycle: "h12", timeZone: "UTC" });
|
|
63
|
+
const word = (hour) => fmt.formatToParts(at(`${pad(hour)}:00`)).find((p2) => p2.type === "dayPeriod")?.value.trim().toLowerCase();
|
|
64
|
+
const a = word(1);
|
|
65
|
+
const p = word(13);
|
|
66
|
+
if (a && !am.includes(a)) am.unshift(a);
|
|
67
|
+
if (p && !pm.includes(p)) pm.unshift(p);
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
return { am, pm };
|
|
71
|
+
}
|
|
72
|
+
function parseTimeInput(text, locale) {
|
|
73
|
+
let rest = text.normalize("NFKC").trim().toLowerCase().replace(/\s+/g, " ");
|
|
74
|
+
if (!rest) return null;
|
|
75
|
+
let period = null;
|
|
76
|
+
const { am, pm } = dayPeriods(locale);
|
|
77
|
+
const words = [...am.map((w) => [w, "am"]), ...pm.map((w) => [w, "pm"])].sort((x, y) => y[0].length - x[0].length);
|
|
78
|
+
for (const [word, which] of words) {
|
|
79
|
+
if (rest.endsWith(word) && /[\d\s.]$/.test(rest.slice(0, -word.length) || " ")) {
|
|
80
|
+
period = which;
|
|
81
|
+
rest = rest.slice(0, -word.length).trim();
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
if (rest.startsWith(word) && /^[\s\d]/.test(rest.slice(word.length))) {
|
|
85
|
+
period = which;
|
|
86
|
+
rest = rest.slice(word.length).trim();
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let hour;
|
|
91
|
+
let minute;
|
|
92
|
+
const split = /^(\d{1,2})\s*(?:[:.h]\s*(\d{1,2}))?\s*(?:h|uhr)?$/.exec(rest);
|
|
93
|
+
const packed = /^(\d{3,4})$/.exec(rest);
|
|
94
|
+
if (split && (split[2] === void 0 || split[2].length === 2)) {
|
|
95
|
+
hour = Number(split[1]);
|
|
96
|
+
minute = split[2] === void 0 ? 0 : Number(split[2]);
|
|
97
|
+
} else if (packed) {
|
|
98
|
+
hour = Number(packed[1].slice(0, -2));
|
|
99
|
+
minute = Number(packed[1].slice(-2));
|
|
100
|
+
} else {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
if (minute > 59) return null;
|
|
104
|
+
if (period) {
|
|
105
|
+
if (hour < 1 || hour > 12) return null;
|
|
106
|
+
hour = hour % 12 + (period === "pm" ? 12 : 0);
|
|
107
|
+
} else if (hour > 23) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return `${pad(hour)}:${pad(minute)}`;
|
|
111
|
+
}
|
|
112
|
+
const isOvernightRange = (min, max) => !!min && !!max && isValidTimeKey(min) && isValidTimeKey(max) && min > max;
|
|
113
|
+
function isTimeOutOfRange(value, min, max) {
|
|
114
|
+
if (isOvernightRange(min, max)) return value < min && value > max;
|
|
115
|
+
return !!min && isValidTimeKey(min) && value < min || !!max && isValidTimeKey(max) && value > max;
|
|
116
|
+
}
|
|
117
|
+
function stepTime(value, delta, min, max) {
|
|
118
|
+
const lo = min && isValidTimeKey(min) ? timeToMinutes(min) : null;
|
|
119
|
+
const hi = max && isValidTimeKey(max) ? timeToMinutes(max) : null;
|
|
120
|
+
if (!value || !isValidTimeKey(value)) return minutesToTime(lo ?? 0);
|
|
121
|
+
if (lo !== null && hi !== null && lo > hi) {
|
|
122
|
+
const wrapped = ((timeToMinutes(value) + delta) % 1440 + 1440) % 1440;
|
|
123
|
+
return minutesToTime(wrapped >= lo || wrapped <= hi ? wrapped : delta > 0 ? hi : lo);
|
|
124
|
+
}
|
|
125
|
+
let next = timeToMinutes(value) + delta;
|
|
126
|
+
if (lo === null && hi === null) return minutesToTime(next);
|
|
127
|
+
if (lo !== null && next < lo) next = lo;
|
|
128
|
+
if (hi !== null && next > hi) next = hi;
|
|
129
|
+
return minutesToTime(Math.max(0, Math.min(1439, next)));
|
|
130
|
+
}
|
|
131
|
+
function timeSlots(step, min, max) {
|
|
132
|
+
const size = Math.max(1, Math.round(step));
|
|
133
|
+
const lo = min && isValidTimeKey(min) ? timeToMinutes(min) : 0;
|
|
134
|
+
const hi = max && isValidTimeKey(max) ? timeToMinutes(max) : 1439;
|
|
135
|
+
const out = [];
|
|
136
|
+
const end = lo > hi ? hi + 1440 : hi;
|
|
137
|
+
for (let m = lo; m <= end; m += size) out.push(minutesToTime(m));
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
formatTimeKey,
|
|
142
|
+
isOvernightRange,
|
|
143
|
+
isTimeOutOfRange,
|
|
144
|
+
isValidTimeKey,
|
|
145
|
+
minutesToTime,
|
|
146
|
+
parseTimeInput,
|
|
147
|
+
stepTime,
|
|
148
|
+
timePartEnds,
|
|
149
|
+
timeSlots,
|
|
150
|
+
timeToMinutes,
|
|
151
|
+
uses12Hour
|
|
152
|
+
};
|
package/dist/toast-store.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ interface ToastOptions {
|
|
|
25
25
|
* Defaults: success/info/default 5 s, warning 8 s, error and loading stay.
|
|
26
26
|
*/
|
|
27
27
|
duration?: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* `false`: a fixed timer (HAR-1831). The toast closes `duration` after it appears, even while the
|
|
30
|
+
* pointer or focus is on it or the tab is hidden; for an undo window that must end on time
|
|
31
|
+
* (TENSOR's `useUndoableAction` commits after exactly 5 s). A toast waiting beyond the
|
|
32
|
+
* Toaster's `limit` starts its timer when it appears. Default `true`: the timer pauses.
|
|
33
|
+
*/
|
|
34
|
+
pauseOnHover?: boolean;
|
|
28
35
|
action?: ToastAction;
|
|
29
36
|
/** Replaces the tone glyph. */
|
|
30
37
|
icon?: ReactNode;
|
|
@@ -37,6 +44,8 @@ interface ToastRecord {
|
|
|
37
44
|
message: ReactNode;
|
|
38
45
|
description?: ReactNode;
|
|
39
46
|
duration: number | null;
|
|
47
|
+
/** `false`: the timer does not pause (see {@link ToastOptions.pauseOnHover}). */
|
|
48
|
+
pauseOnHover?: boolean;
|
|
40
49
|
action?: ToastAction;
|
|
41
50
|
icon?: ReactNode;
|
|
42
51
|
/** Set while the leave animation runs; the record is removed after it. */
|
|
@@ -84,9 +93,16 @@ interface ToastApi {
|
|
|
84
93
|
promise: <T>(promise: Promise<T>, messages: ToastPromiseMessages<T>, options?: ToastOptions) => Promise<T>;
|
|
85
94
|
/**
|
|
86
95
|
* An optimistic action with an Undo button (TENSOR C2 `useUndoableAction`): `onCommit` runs
|
|
87
|
-
* when the toast closes without Undo; `onUndo` runs instead when Undo is pressed.
|
|
96
|
+
* when the toast closes without Undo; `onUndo` runs instead when Undo is pressed. Pass
|
|
97
|
+
* `pauseOnHover: false` for a commit that happens exactly `duration` after the toast appears.
|
|
88
98
|
*/
|
|
89
99
|
undoable: (message: ReactNode, options: UndoableToastOptions) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Undo an `undoable` toast from code, as if its Undo were pressed (HAR-1831): `onUndo` runs,
|
|
102
|
+
* `onCommit` does not, and the toast closes. Returns `false` when `id` is not an open undoable
|
|
103
|
+
* toast (it was already undone or committed). `dismiss(id)` commits instead.
|
|
104
|
+
*/
|
|
105
|
+
undo: (id: string) => boolean;
|
|
90
106
|
/** The store this API writes to; pass it to `<Toaster store>` for a non-default queue. */
|
|
91
107
|
store: ToastStore;
|
|
92
108
|
}
|
package/dist/toast-store.js
CHANGED
|
@@ -26,6 +26,7 @@ function createToastStore() {
|
|
|
26
26
|
message,
|
|
27
27
|
description: options.description,
|
|
28
28
|
duration: options.duration === void 0 ? DEFAULT_DURATION[kind] : options.duration,
|
|
29
|
+
pauseOnHover: options.pauseOnHover,
|
|
29
30
|
action: options.action,
|
|
30
31
|
icon: options.icon,
|
|
31
32
|
onDismiss: options.onDismiss,
|
|
@@ -84,19 +85,34 @@ function createToastApi(store) {
|
|
|
84
85
|
);
|
|
85
86
|
return promise;
|
|
86
87
|
};
|
|
88
|
+
const undoers = /* @__PURE__ */ new Map();
|
|
87
89
|
api.undoable = (message, { onUndo, onCommit, undoLabel = "Undo", duration = 6e3, ...options }) => {
|
|
88
|
-
let
|
|
89
|
-
|
|
90
|
+
let settled = false;
|
|
91
|
+
const undo = () => {
|
|
92
|
+
if (settled) return;
|
|
93
|
+
settled = true;
|
|
94
|
+
onUndo();
|
|
95
|
+
};
|
|
96
|
+
const id = store.show("default", message, {
|
|
90
97
|
...options,
|
|
91
98
|
duration,
|
|
92
|
-
action: { label: undoLabel, onClick:
|
|
93
|
-
undone = true;
|
|
94
|
-
onUndo();
|
|
95
|
-
} },
|
|
99
|
+
action: { label: undoLabel, onClick: undo },
|
|
96
100
|
onDismiss: () => {
|
|
97
|
-
|
|
101
|
+
undoers.delete(id);
|
|
102
|
+
if (settled) return;
|
|
103
|
+
settled = true;
|
|
104
|
+
onCommit();
|
|
98
105
|
}
|
|
99
106
|
});
|
|
107
|
+
undoers.set(id, undo);
|
|
108
|
+
return id;
|
|
109
|
+
};
|
|
110
|
+
api.undo = (id) => {
|
|
111
|
+
const undo = undoers.get(id);
|
|
112
|
+
if (!undo) return false;
|
|
113
|
+
undo();
|
|
114
|
+
store.dismiss(id, "action");
|
|
115
|
+
return true;
|
|
100
116
|
};
|
|
101
117
|
api.store = store;
|
|
102
118
|
return api;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tensor_1/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.48.0",
|
|
4
4
|
"description": "Thin React wrappers over the UIx v2 CSS component library.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -149,6 +149,7 @@
|
|
|
149
149
|
"emojibase-data": "17.0.0",
|
|
150
150
|
"esbuild": "^0.27.0",
|
|
151
151
|
"jsdom": "30.1.0",
|
|
152
|
+
"jsqr": "1.4.0",
|
|
152
153
|
"marked": "17.0.6",
|
|
153
154
|
"tsup": "^8.0.0",
|
|
154
155
|
"typescript": "^5.0.0"
|