@bug-on/m3-expressive 1.0.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/CHANGELOG.md +110 -0
- package/README.md +110 -0
- package/dist/assets/fonts/GoogleSansFlex-VariableFont.woff2 +0 -0
- package/dist/assets/fonts/MaterialSymbolsOutlined-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsSharp-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/loading-indicator.svg +19 -0
- package/dist/assets/material-symbols-cdn.css +65 -0
- package/dist/assets/material-symbols-self-hosted.css +94 -0
- package/dist/buttons.d.mts +180 -0
- package/dist/buttons.d.ts +180 -0
- package/dist/buttons.js +4282 -0
- package/dist/buttons.js.map +1 -0
- package/dist/buttons.mjs +4227 -0
- package/dist/buttons.mjs.map +1 -0
- package/dist/core.d.mts +422 -0
- package/dist/core.d.ts +422 -0
- package/dist/core.js +2581 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +2547 -0
- package/dist/core.mjs.map +1 -0
- package/dist/feedback.d.mts +600 -0
- package/dist/feedback.d.ts +600 -0
- package/dist/feedback.js +2357 -0
- package/dist/feedback.js.map +1 -0
- package/dist/feedback.mjs +2321 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/forms.d.mts +40 -0
- package/dist/forms.d.ts +40 -0
- package/dist/forms.js +4263 -0
- package/dist/forms.js.map +1 -0
- package/dist/forms.mjs +4228 -0
- package/dist/forms.mjs.map +1 -0
- package/dist/icon-button-D-gs0gfj.d.mts +136 -0
- package/dist/icon-button-D-gs0gfj.d.ts +136 -0
- package/dist/index.css +309 -0
- package/dist/index.css.d.ts +2 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23972 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +23668 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layout.d.mts +610 -0
- package/dist/layout.d.ts +610 -0
- package/dist/layout.js +5091 -0
- package/dist/layout.js.map +1 -0
- package/dist/layout.mjs +5042 -0
- package/dist/layout.mjs.map +1 -0
- package/dist/material-symbols-cdn.css +65 -0
- package/dist/material-symbols-cdn.css.d.ts +2 -0
- package/dist/material-symbols-self-hosted.css +94 -0
- package/dist/material-symbols-self-hosted.css.d.ts +2 -0
- package/dist/md3-DFhj-NZj.d.mts +17 -0
- package/dist/md3-DFhj-NZj.d.ts +17 -0
- package/dist/navigation.d.mts +2766 -0
- package/dist/navigation.d.ts +2766 -0
- package/dist/navigation.js +6684 -0
- package/dist/navigation.js.map +1 -0
- package/dist/navigation.mjs +6573 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/overlays.d.mts +161 -0
- package/dist/overlays.d.ts +161 -0
- package/dist/overlays.js +3298 -0
- package/dist/overlays.js.map +1 -0
- package/dist/overlays.mjs +3244 -0
- package/dist/overlays.mjs.map +1 -0
- package/dist/pickers.d.mts +1074 -0
- package/dist/pickers.d.ts +1074 -0
- package/dist/pickers.js +4240 -0
- package/dist/pickers.js.map +1 -0
- package/dist/pickers.mjs +4200 -0
- package/dist/pickers.mjs.map +1 -0
- package/dist/plugin.d.mts +1 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugin.mjs +3 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/scroll-area-CVS6HyLl.d.mts +33 -0
- package/dist/scroll-area-CVS6HyLl.d.ts +33 -0
- package/dist/shapes.d.mts +1119 -0
- package/dist/shapes.d.ts +1119 -0
- package/dist/shapes.js +2941 -0
- package/dist/shapes.js.map +1 -0
- package/dist/shapes.mjs +2889 -0
- package/dist/shapes.mjs.map +1 -0
- package/dist/side-sheet-modal-BY6VCC8p.d.mts +553 -0
- package/dist/side-sheet-modal-CglP6KYA.d.ts +553 -0
- package/dist/split-button-trailing-uncheckable-C5CLCIKP.d.ts +731 -0
- package/dist/split-button-trailing-uncheckable-MXj_kyNt.d.mts +731 -0
- package/dist/text-field-eAIpz9z1.d.mts +1038 -0
- package/dist/text-field-eAIpz9z1.d.ts +1038 -0
- package/dist/typography-339RV6v7.d.mts +486 -0
- package/dist/typography-339RV6v7.d.ts +486 -0
- package/dist/typography.css +22 -0
- package/dist/typography.css.d.ts +2 -0
- package/package.json +207 -0
package/dist/pickers.js
ADDED
|
@@ -0,0 +1,4240 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('motion/react');
|
|
5
|
+
var React17 = require('react');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var tailwindMerge = require('tailwind-merge');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var RadixDialog = require('@radix-ui/react-dialog');
|
|
10
|
+
var RadixScrollArea = require('@radix-ui/react-scroll-area');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React17__namespace = /*#__PURE__*/_interopNamespace(React17);
|
|
31
|
+
var RadixDialog__namespace = /*#__PURE__*/_interopNamespace(RadixDialog);
|
|
32
|
+
var RadixScrollArea__namespace = /*#__PURE__*/_interopNamespace(RadixScrollArea);
|
|
33
|
+
|
|
34
|
+
var __defProp = Object.defineProperty;
|
|
35
|
+
var __defProps = Object.defineProperties;
|
|
36
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
37
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
38
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
39
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
40
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
41
|
+
var __spreadValues = (a, b) => {
|
|
42
|
+
for (var prop in b || (b = {}))
|
|
43
|
+
if (__hasOwnProp.call(b, prop))
|
|
44
|
+
__defNormalProp(a, prop, b[prop]);
|
|
45
|
+
if (__getOwnPropSymbols)
|
|
46
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
47
|
+
if (__propIsEnum.call(b, prop))
|
|
48
|
+
__defNormalProp(a, prop, b[prop]);
|
|
49
|
+
}
|
|
50
|
+
return a;
|
|
51
|
+
};
|
|
52
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
53
|
+
var __objRest = (source, exclude) => {
|
|
54
|
+
var target = {};
|
|
55
|
+
for (var prop in source)
|
|
56
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
57
|
+
target[prop] = source[prop];
|
|
58
|
+
if (source != null && __getOwnPropSymbols)
|
|
59
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
60
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
61
|
+
target[prop] = source[prop];
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
};
|
|
65
|
+
function cn(...inputs) {
|
|
66
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/ui/date-time-pickers/shared/calendar-model.ts
|
|
70
|
+
var startOfDayUTC = (ms) => {
|
|
71
|
+
const d = new Date(ms);
|
|
72
|
+
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
73
|
+
};
|
|
74
|
+
var todayUTC = () => startOfDayUTC(Date.now());
|
|
75
|
+
var getDaysInMonth = (year, month) => new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
76
|
+
var getFirstDayOfWeek = (year, month) => new Date(Date.UTC(year, month, 1)).getUTCDay();
|
|
77
|
+
var getWeeksInMonth = (year, month, weekStartsOn) => {
|
|
78
|
+
const todayMs = todayUTC();
|
|
79
|
+
const daysInMonth = getDaysInMonth(year, month);
|
|
80
|
+
const firstDow = getFirstDayOfWeek(year, month);
|
|
81
|
+
const startPadding = (firstDow - weekStartsOn + 7) % 7;
|
|
82
|
+
const totalCells = startPadding + daysInMonth;
|
|
83
|
+
const totalWeeks = Math.ceil(totalCells / 7);
|
|
84
|
+
const weeks = [];
|
|
85
|
+
for (let w = 0; w < totalWeeks; w++) {
|
|
86
|
+
const week = [];
|
|
87
|
+
for (let d = 0; d < 7; d++) {
|
|
88
|
+
const cellIndex = w * 7 + d;
|
|
89
|
+
const dayNumber = cellIndex - startPadding + 1;
|
|
90
|
+
if (dayNumber < 1 || dayNumber > daysInMonth) {
|
|
91
|
+
week.push(null);
|
|
92
|
+
} else {
|
|
93
|
+
const utcMs = Date.UTC(year, month, dayNumber);
|
|
94
|
+
week.push({
|
|
95
|
+
utcMs,
|
|
96
|
+
day: dayNumber,
|
|
97
|
+
month,
|
|
98
|
+
year,
|
|
99
|
+
isCurrentMonth: true,
|
|
100
|
+
isToday: utcMs === todayMs
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
weeks.push(week);
|
|
105
|
+
}
|
|
106
|
+
return weeks;
|
|
107
|
+
};
|
|
108
|
+
var isSameDay = (a, b) => startOfDayUTC(a) === startOfDayUTC(b);
|
|
109
|
+
var isDateInRange = (ms, startMs, endMs) => {
|
|
110
|
+
if (startMs === null || endMs === null) return false;
|
|
111
|
+
const day = startOfDayUTC(ms);
|
|
112
|
+
const start = startOfDayUTC(startMs);
|
|
113
|
+
const end = startOfDayUTC(endMs);
|
|
114
|
+
return day >= start && day <= end;
|
|
115
|
+
};
|
|
116
|
+
var isRangeStart = (ms, startMs) => startMs !== null && isSameDay(ms, startMs);
|
|
117
|
+
var isRangeEnd = (ms, endMs) => endMs !== null && isSameDay(ms, endMs);
|
|
118
|
+
var isYearSelectable = (year, selectableDates) => selectableDates.isSelectableYear(year);
|
|
119
|
+
var resolveLocale = (locale) => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
return {
|
|
122
|
+
locale: (_a = locale == null ? void 0 : locale.locale) != null ? _a : typeof navigator !== "undefined" ? navigator.language : "en-US",
|
|
123
|
+
weekStartsOn: (_b = locale == null ? void 0 : locale.weekStartsOn) != null ? _b : 1
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
var normalizeToMonthStart = (ms) => {
|
|
127
|
+
const d = new Date(ms);
|
|
128
|
+
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1);
|
|
129
|
+
};
|
|
130
|
+
var navigateMonth = (currentMs, direction) => {
|
|
131
|
+
const d = new Date(currentMs);
|
|
132
|
+
const year = d.getUTCFullYear();
|
|
133
|
+
const month = d.getUTCMonth();
|
|
134
|
+
if (direction === "next") {
|
|
135
|
+
return month === 11 ? Date.UTC(year + 1, 0, 1) : Date.UTC(year, month + 1, 1);
|
|
136
|
+
}
|
|
137
|
+
return month === 0 ? Date.UTC(year - 1, 11, 1) : Date.UTC(year, month - 1, 1);
|
|
138
|
+
};
|
|
139
|
+
var isMonthNavigable = (year, yearRange, selectableDates) => year >= yearRange[0] && year <= yearRange[1] && selectableDates.isSelectableYear(year);
|
|
140
|
+
var getNavigableMonth = (currentMs, direction, yearRange, selectableDates) => {
|
|
141
|
+
const targetMs = navigateMonth(currentMs, direction);
|
|
142
|
+
const targetYear = new Date(targetMs).getUTCFullYear();
|
|
143
|
+
return isMonthNavigable(targetYear, yearRange, selectableDates) ? targetMs : null;
|
|
144
|
+
};
|
|
145
|
+
var formatDate = (utcMs, locale, options) => {
|
|
146
|
+
const defaultOptions = {
|
|
147
|
+
year: "numeric",
|
|
148
|
+
month: "long",
|
|
149
|
+
day: "numeric",
|
|
150
|
+
timeZone: "UTC"
|
|
151
|
+
};
|
|
152
|
+
return new Intl.DateTimeFormat(locale.locale, __spreadValues(__spreadValues({}, defaultOptions), options)).format(new Date(utcMs));
|
|
153
|
+
};
|
|
154
|
+
var formatMonthYear = (utcMs, locale) => new Intl.DateTimeFormat(locale.locale, {
|
|
155
|
+
year: "numeric",
|
|
156
|
+
month: "long",
|
|
157
|
+
timeZone: "UTC"
|
|
158
|
+
}).format(new Date(utcMs));
|
|
159
|
+
var getWeekdayNames = (locale) => {
|
|
160
|
+
const SUNDAY_MS = Date.UTC(2025, 0, 5);
|
|
161
|
+
const formatter = new Intl.DateTimeFormat(locale.locale, {
|
|
162
|
+
weekday: "narrow",
|
|
163
|
+
timeZone: "UTC"
|
|
164
|
+
});
|
|
165
|
+
const allDays = Array.from(
|
|
166
|
+
{ length: 7 },
|
|
167
|
+
(_, i) => formatter.format(new Date(SUNDAY_MS + i * 864e5))
|
|
168
|
+
);
|
|
169
|
+
return [
|
|
170
|
+
...allDays.slice(locale.weekStartsOn),
|
|
171
|
+
...allDays.slice(0, locale.weekStartsOn)
|
|
172
|
+
];
|
|
173
|
+
};
|
|
174
|
+
var parseDateInput = (input) => {
|
|
175
|
+
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
176
|
+
if (!match) return null;
|
|
177
|
+
const [, mm, dd, yyyy] = match;
|
|
178
|
+
const month = parseInt(mm, 10) - 1;
|
|
179
|
+
const day = parseInt(dd, 10);
|
|
180
|
+
const year = parseInt(yyyy, 10);
|
|
181
|
+
if (month < 0 || month > 11 || day < 1 || day > 31 || year < 1) return null;
|
|
182
|
+
const maxDay = getDaysInMonth(year, month);
|
|
183
|
+
if (day > maxDay) return null;
|
|
184
|
+
return Date.UTC(year, month, day);
|
|
185
|
+
};
|
|
186
|
+
var DatePickerInput = ({
|
|
187
|
+
value,
|
|
188
|
+
onChange,
|
|
189
|
+
onCommit,
|
|
190
|
+
label = "Enter date",
|
|
191
|
+
error,
|
|
192
|
+
locale,
|
|
193
|
+
className
|
|
194
|
+
}) => {
|
|
195
|
+
const inputId = React17__namespace.useId();
|
|
196
|
+
const errorId = `${inputId}-error`;
|
|
197
|
+
const placeholder = React17__namespace.useMemo(() => {
|
|
198
|
+
if (locale == null ? void 0 : locale.startsWith("vi")) return "DD/MM/YYYY";
|
|
199
|
+
return "MM/DD/YYYY";
|
|
200
|
+
}, [locale]);
|
|
201
|
+
const handleKeyDown = React17__namespace.useCallback(
|
|
202
|
+
(e) => {
|
|
203
|
+
if (e.key === "Enter") {
|
|
204
|
+
const parsed = parseDateInput(value);
|
|
205
|
+
onCommit(parsed);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
[value, onCommit]
|
|
209
|
+
);
|
|
210
|
+
const handleBlur = React17__namespace.useCallback(() => {
|
|
211
|
+
const parsed = parseDateInput(value);
|
|
212
|
+
onCommit(parsed);
|
|
213
|
+
}, [value, onCommit]);
|
|
214
|
+
const handleChange = React17__namespace.useCallback(
|
|
215
|
+
(e) => {
|
|
216
|
+
let raw = e.target.value.replace(/\D/g, "");
|
|
217
|
+
if (raw.length > 8) raw = raw.slice(0, 8);
|
|
218
|
+
let formatted = raw;
|
|
219
|
+
if (raw.length > 2) {
|
|
220
|
+
formatted = `${raw.slice(0, 2)}/${raw.slice(2)}`;
|
|
221
|
+
}
|
|
222
|
+
if (raw.length > 4) {
|
|
223
|
+
formatted = `${raw.slice(0, 2)}/${raw.slice(2, 4)}/${raw.slice(4)}`;
|
|
224
|
+
}
|
|
225
|
+
onChange(formatted);
|
|
226
|
+
},
|
|
227
|
+
[onChange]
|
|
228
|
+
);
|
|
229
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
230
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
231
|
+
"label",
|
|
232
|
+
{
|
|
233
|
+
htmlFor: inputId,
|
|
234
|
+
className: "block text-[length:var(--md-typescale-label-large-size,14px)]\n font-[number:var(--md-typescale-label-large-weight,500)]\n text-m3-on-surface-variant\n mb-1",
|
|
235
|
+
children: label
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
239
|
+
"input",
|
|
240
|
+
{
|
|
241
|
+
id: inputId,
|
|
242
|
+
type: "text",
|
|
243
|
+
inputMode: "numeric",
|
|
244
|
+
value,
|
|
245
|
+
onChange: handleChange,
|
|
246
|
+
onBlur: handleBlur,
|
|
247
|
+
onKeyDown: handleKeyDown,
|
|
248
|
+
placeholder,
|
|
249
|
+
"aria-label": label,
|
|
250
|
+
"aria-invalid": !!error || void 0,
|
|
251
|
+
"aria-describedby": error ? errorId : void 0,
|
|
252
|
+
maxLength: 10,
|
|
253
|
+
className: "w-full h-14 px-4 rounded-m3-xs\n bg-m3-surface-container-highest\n text-[length:var(--md-typescale-body-large-size,16px)]\n hover:bg-m3-on-surface/8\n text-m3-on-surface\n caret-m3-primary\n placeholder:text-m3-on-surface-variant\n outline-none border-0\n focus:ring-2 focus:ring-m3-primary\n transition-m3-fast-effects"
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: "mt-1 text-xs text-m3-error px-1", children: error })
|
|
257
|
+
] }) }) });
|
|
258
|
+
};
|
|
259
|
+
DatePickerInput.displayName = "DatePickerInput";
|
|
260
|
+
|
|
261
|
+
// src/ui/shared/motion-tokens.ts
|
|
262
|
+
var FAST_SPATIAL_SPRING = {
|
|
263
|
+
type: "spring",
|
|
264
|
+
stiffness: 800,
|
|
265
|
+
damping: 33.94
|
|
266
|
+
};
|
|
267
|
+
var DEFAULT_SPATIAL_SPRING = {
|
|
268
|
+
type: "spring",
|
|
269
|
+
stiffness: 380,
|
|
270
|
+
damping: 31.19
|
|
271
|
+
};
|
|
272
|
+
var FAST_EFFECTS_SPRING = {
|
|
273
|
+
type: "spring",
|
|
274
|
+
stiffness: 3800,
|
|
275
|
+
damping: 123.29
|
|
276
|
+
};
|
|
277
|
+
var DEFAULT_EFFECTS_SPRING = {
|
|
278
|
+
type: "spring",
|
|
279
|
+
stiffness: 1600,
|
|
280
|
+
damping: 80
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/ui/date-time-pickers/shared/animation-tokens.ts
|
|
284
|
+
var PICKER_OVERLAY_ANIM = {
|
|
285
|
+
initial: { opacity: 0 },
|
|
286
|
+
animate: {
|
|
287
|
+
opacity: 1,
|
|
288
|
+
transition: { duration: 0.2, ease: [0, 0, 0, 1] }
|
|
289
|
+
},
|
|
290
|
+
exit: {
|
|
291
|
+
opacity: 0,
|
|
292
|
+
transition: { duration: 0.15, ease: [0.3, 0, 1, 1] }
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var PICKER_CONTENT_ANIM = {
|
|
296
|
+
initial: { opacity: 0, scale: 0.85, y: 16 },
|
|
297
|
+
animate: {
|
|
298
|
+
opacity: 1,
|
|
299
|
+
scale: 1,
|
|
300
|
+
y: 0,
|
|
301
|
+
transition: DEFAULT_SPATIAL_SPRING
|
|
302
|
+
},
|
|
303
|
+
exit: {
|
|
304
|
+
opacity: 0,
|
|
305
|
+
scale: 0.95,
|
|
306
|
+
y: 8,
|
|
307
|
+
transition: { duration: 0.15, ease: [0.3, 0, 1, 1] }
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var CALENDAR_SLIDE_VARIANTS = {
|
|
311
|
+
enterFromRight: {
|
|
312
|
+
x: "100%",
|
|
313
|
+
opacity: 0
|
|
314
|
+
},
|
|
315
|
+
enterFromLeft: {
|
|
316
|
+
x: "-100%",
|
|
317
|
+
opacity: 0
|
|
318
|
+
},
|
|
319
|
+
center: {
|
|
320
|
+
x: 0,
|
|
321
|
+
opacity: 1,
|
|
322
|
+
transition: FAST_SPATIAL_SPRING
|
|
323
|
+
},
|
|
324
|
+
exitToLeft: {
|
|
325
|
+
x: "-100%",
|
|
326
|
+
opacity: 0,
|
|
327
|
+
transition: { duration: 0.15, ease: [0.3, 0, 1, 1] }
|
|
328
|
+
},
|
|
329
|
+
exitToRight: {
|
|
330
|
+
x: "100%",
|
|
331
|
+
opacity: 0,
|
|
332
|
+
transition: { duration: 0.15, ease: [0.3, 0, 1, 1] }
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
var DAY_CELL_STATE_TRANSITION = FAST_EFFECTS_SPRING;
|
|
336
|
+
var DayCell = ({
|
|
337
|
+
day,
|
|
338
|
+
selectedMs,
|
|
339
|
+
selectedStartMs = null,
|
|
340
|
+
selectedEndMs = null,
|
|
341
|
+
isRangePicker = false,
|
|
342
|
+
isSelectable,
|
|
343
|
+
onSelect,
|
|
344
|
+
locale
|
|
345
|
+
}) => {
|
|
346
|
+
const { utcMs, day: dayNum, isToday } = day;
|
|
347
|
+
const isSelected = !isRangePicker && selectedMs !== null && isSameDay(utcMs, selectedMs);
|
|
348
|
+
const isStart = isRangePicker && isRangeStart(utcMs, selectedStartMs);
|
|
349
|
+
const isEnd = isRangePicker && isRangeEnd(utcMs, selectedEndMs);
|
|
350
|
+
const isInRange = isRangePicker && !isStart && !isEnd && isDateInRange(utcMs, selectedStartMs, selectedEndMs);
|
|
351
|
+
const isDisabled = !isSelectable;
|
|
352
|
+
const ariaLabel = new Intl.DateTimeFormat(locale, {
|
|
353
|
+
year: "numeric",
|
|
354
|
+
month: "long",
|
|
355
|
+
day: "numeric",
|
|
356
|
+
timeZone: "UTC"
|
|
357
|
+
}).format(new Date(utcMs));
|
|
358
|
+
const rangeHighlightClass = cn(
|
|
359
|
+
"absolute inset-y-0 bg-m3-secondary-container",
|
|
360
|
+
isStart && selectedEndMs !== null && "left-1/2 right-0",
|
|
361
|
+
isEnd && selectedStartMs !== null && "left-0 right-1/2",
|
|
362
|
+
isInRange && "inset-x-0"
|
|
363
|
+
);
|
|
364
|
+
const circleClass = cn(
|
|
365
|
+
"relative z-10 flex items-center justify-center w-10 h-10 rounded-m3-full",
|
|
366
|
+
"text-[length:var(--md-typescale-body-large-size,14px)]",
|
|
367
|
+
"font-[number:var(--md-typescale-body-large-weight,400)]",
|
|
368
|
+
"transition-m3-fast-effects",
|
|
369
|
+
// Selected (single) or range endpoints
|
|
370
|
+
(isSelected || isStart || isEnd) && ["bg-m3-primary", "text-m3-on-primary"],
|
|
371
|
+
// In-range text
|
|
372
|
+
isInRange && "text-m3-on-secondary-container",
|
|
373
|
+
// Today outline (only when not selected)
|
|
374
|
+
isToday && !isSelected && !isStart && !isEnd && ["outline outline-1 outline-m3-primary", "text-m3-primary"],
|
|
375
|
+
// Default text
|
|
376
|
+
!isSelected && !isStart && !isEnd && !isInRange && !isToday && "text-m3-on-surface",
|
|
377
|
+
// Hover states (only when selectable and not selected/range endpoints)
|
|
378
|
+
!isDisabled && !isSelected && !isStart && !isEnd && [
|
|
379
|
+
isInRange ? "hover:bg-m3-on-secondary-container/8" : "hover:bg-m3-on-surface/8"
|
|
380
|
+
],
|
|
381
|
+
// Disabled
|
|
382
|
+
isDisabled && "opacity-[0.38]"
|
|
383
|
+
);
|
|
384
|
+
const handleClick = React17__namespace.useCallback(() => {
|
|
385
|
+
if (isDisabled) return;
|
|
386
|
+
onSelect(utcMs);
|
|
387
|
+
}, [isDisabled, utcMs, onSelect]);
|
|
388
|
+
const handleKeyDown = React17__namespace.useCallback(
|
|
389
|
+
(e) => {
|
|
390
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
handleClick();
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
[handleClick]
|
|
396
|
+
);
|
|
397
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "relative flex items-center justify-center", children: [
|
|
398
|
+
isRangePicker && (isInRange || isStart || isEnd) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: rangeHighlightClass }),
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
400
|
+
react.m.button,
|
|
401
|
+
{
|
|
402
|
+
type: "button",
|
|
403
|
+
className: cn(
|
|
404
|
+
circleClass,
|
|
405
|
+
isDisabled && "pointer-events-none cursor-not-allowed"
|
|
406
|
+
),
|
|
407
|
+
onClick: handleClick,
|
|
408
|
+
onKeyDown: handleKeyDown,
|
|
409
|
+
"aria-label": ariaLabel,
|
|
410
|
+
"aria-selected": isSelected || isStart || isEnd || void 0,
|
|
411
|
+
"aria-disabled": isDisabled || void 0,
|
|
412
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
413
|
+
whileTap: !isDisabled ? {
|
|
414
|
+
scale: 0.94,
|
|
415
|
+
transition: DAY_CELL_STATE_TRANSITION
|
|
416
|
+
} : void 0,
|
|
417
|
+
children: dayNum
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
] });
|
|
421
|
+
};
|
|
422
|
+
DayCell.displayName = "DayCell";
|
|
423
|
+
var WeekdayRow = ({ locale }) => {
|
|
424
|
+
const names = React17__namespace.useMemo(() => getWeekdayNames(locale), [locale]);
|
|
425
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "grid grid-cols-7 mb-1", children: names.map((name, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
426
|
+
"th",
|
|
427
|
+
{
|
|
428
|
+
scope: "col",
|
|
429
|
+
"aria-label": name,
|
|
430
|
+
className: "flex items-center justify-center h-10 w-10 mx-auto\n text-[length:var(--md-typescale-label-large-size,14px)]\n font-[number:var(--md-typescale-label-large-weight,500)]\n text-m3-on-surface\n select-none\n font-normal",
|
|
431
|
+
children: name
|
|
432
|
+
},
|
|
433
|
+
i
|
|
434
|
+
)) });
|
|
435
|
+
};
|
|
436
|
+
WeekdayRow.displayName = "WeekdayRow";
|
|
437
|
+
var CalendarGrid = ({
|
|
438
|
+
displayedMonthMs,
|
|
439
|
+
slideDirection,
|
|
440
|
+
locale,
|
|
441
|
+
selectableDates,
|
|
442
|
+
selectedMs,
|
|
443
|
+
selectedStartMs = null,
|
|
444
|
+
selectedEndMs = null,
|
|
445
|
+
isRangePicker = false,
|
|
446
|
+
onDaySelect
|
|
447
|
+
}) => {
|
|
448
|
+
const d = new Date(displayedMonthMs);
|
|
449
|
+
const year = d.getUTCFullYear();
|
|
450
|
+
const month = d.getUTCMonth();
|
|
451
|
+
const weeks = React17__namespace.useMemo(
|
|
452
|
+
() => getWeeksInMonth(year, month, locale.weekStartsOn),
|
|
453
|
+
[year, month, locale.weekStartsOn]
|
|
454
|
+
);
|
|
455
|
+
const enterVariant = slideDirection === "next" ? "enterFromRight" : "enterFromLeft";
|
|
456
|
+
const exitVariant = slideDirection === "next" ? "exitToLeft" : "exitToRight";
|
|
457
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full px-3 border-collapse block", children: [
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "block", children: /* @__PURE__ */ jsxRuntime.jsx(WeekdayRow, { locale }) }),
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, mode: "popLayout", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
460
|
+
react.m.tbody,
|
|
461
|
+
{
|
|
462
|
+
variants: CALENDAR_SLIDE_VARIANTS,
|
|
463
|
+
initial: slideDirection !== null ? enterVariant : false,
|
|
464
|
+
animate: "center",
|
|
465
|
+
exit: slideDirection !== null ? exitVariant : void 0,
|
|
466
|
+
className: "overflow-hidden block",
|
|
467
|
+
"aria-label": new Intl.DateTimeFormat(locale.locale, {
|
|
468
|
+
year: "numeric",
|
|
469
|
+
month: "long",
|
|
470
|
+
timeZone: "UTC"
|
|
471
|
+
}).format(new Date(displayedMonthMs)),
|
|
472
|
+
children: weeks.map((week, weekIdx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
473
|
+
"tr",
|
|
474
|
+
{
|
|
475
|
+
className: "grid grid-cols-7",
|
|
476
|
+
children: week.map(
|
|
477
|
+
(day, dayIdx) => day === null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
478
|
+
"td",
|
|
479
|
+
{
|
|
480
|
+
className: "w-10 h-10 mx-auto block",
|
|
481
|
+
"aria-hidden": true
|
|
482
|
+
},
|
|
483
|
+
`empty-${weekIdx}-${dayIdx}`
|
|
484
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
485
|
+
DayCell,
|
|
486
|
+
{
|
|
487
|
+
day,
|
|
488
|
+
selectedMs,
|
|
489
|
+
selectedStartMs,
|
|
490
|
+
selectedEndMs,
|
|
491
|
+
isRangePicker,
|
|
492
|
+
isSelectable: selectableDates.isSelectableDate(day.utcMs),
|
|
493
|
+
onSelect: onDaySelect,
|
|
494
|
+
locale: locale.locale
|
|
495
|
+
},
|
|
496
|
+
day.utcMs
|
|
497
|
+
)
|
|
498
|
+
)
|
|
499
|
+
},
|
|
500
|
+
weekIdx
|
|
501
|
+
))
|
|
502
|
+
},
|
|
503
|
+
displayedMonthMs
|
|
504
|
+
) })
|
|
505
|
+
] });
|
|
506
|
+
};
|
|
507
|
+
CalendarGrid.displayName = "CalendarGrid";
|
|
508
|
+
var SHAPE_KEY_TIMES = "0; 0.14; 0.14; 0.29; 0.29; 0.43; 0.43; 0.57; 0.57; 0.71; 0.71; 0.86; 0.86; 1";
|
|
509
|
+
var SHAPE_KEY_SPLINES = [
|
|
510
|
+
"0.5 0.2 0 0.8",
|
|
511
|
+
"0.5 0.2 0 0.8",
|
|
512
|
+
"0.5 0.2 0 0.8",
|
|
513
|
+
"0.5 0.2 0 0.8",
|
|
514
|
+
"0.5 0.2 0 0.8",
|
|
515
|
+
"0.5 0.2 0 0.8",
|
|
516
|
+
"0.5 0.2 0 0.8",
|
|
517
|
+
"0.5 0.2 0 0.8",
|
|
518
|
+
"0.5 0.2 0 0.8",
|
|
519
|
+
"0.5 0.2 0 0.8",
|
|
520
|
+
"0.5 0.2 0 0.8",
|
|
521
|
+
"0.5 0.2 0 0.8",
|
|
522
|
+
"0.5 0.2 0 0.8"
|
|
523
|
+
].join("; ");
|
|
524
|
+
var SHAPE_VALUES = [
|
|
525
|
+
"M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z",
|
|
526
|
+
"M20.3 8.6 21.1 8 22 7.6 23 7.3 23 7.3 24 7.2 25 7.3 25.9 7.5 26.8 8 27.6 8.6 28.4 9.1 28.4 9.1 29.3 9.6 30.3 9.8 31.3 9.9 32.3 10 33.3 10.2 34.2 10.6 34.2 10.6 35 11.2 35.7 11.9 36.3 12.7 36.7 13.6 36.9 14.6 37.2 15.5 37.2 15.5 37.6 16.5 38.2 17.3 38.9 18 39.6 18.7 40.2 19.5 40.6 20.4 40.6 20.4 40.9 21.3 41 22.3 40.9 23.3 40.6 24.3 40.2 25.2 39.8 26.1 39.8 26.1 39.5 27 39.4 28 39.5 29 39.6 30 39.5 31 39.3 32 39.3 32 38.9 32.9 38.3 33.7 37.6 34.4 36.8 35 35.9 35.4 35 35.8 35 35.8 34.1 36.3 33.4 37 32.9 37.9 32.3 38.7 31.6 39.4 30.8 40 30.8 40 29.9 40.4 28.9 40.7 27.9 40.8 27 40.7 26 40.4 25 40.1 25 40.1 24 40 23 40.1 22.1 40.4 21.1 40.7 20.1 40.8 19.1 40.7 19.1 40.7 18.2 40.5 17.3 40 16.4 39.5 15.7 38.8 15.2 37.9 14.6 37.1 14.6 37.1 13.9 36.4 13.1 35.8 12.2 35.4 11.3 35 10.5 34.4 9.7 33.8 9.7 33.8 9.1 32.9 8.7 32 8.5 31.1 8.4 30.1 8.5 29.1 8.6 28.1 8.6 28.1 8.5 27.1 8.3 26.1 7.8 25.2 7.4 24.3 7.1 23.4 7 22.4 7 22.4 7.1 21.4 7.3 20.4 7.8 19.5 8.3 18.7 9.1 18 9.8 17.3 9.8 17.3 10.4 16.5 10.8 15.6 11 14.6 11.3 13.7 11.7 12.8 12.2 11.9 12.2 11.9 12.9 11.2 13.8 10.7 14.7 10.2 15.6 10 16.6 9.9 17.6 9.8 17.6 9.8 18.6 9.6 19.5 9.2Z",
|
|
527
|
+
"M18.6 9.6 19.5 9.2 20.3 8.6 21.1 8 22 7.6 23 7.3 24 7.2 25 7.3 25.9 7.5 26.8 8 27.6 8.6 28.4 9.1 29.3 9.6 30.3 9.8 31.3 9.9 32.3 10 33.3 10.2 34.2 10.6 35 11.2 35.7 11.9 36.3 12.7 36.7 13.6 36.9 14.6 37.2 15.5 37.6 16.4 38.2 17.3 38.9 18 39.6 18.7 40.2 19.5 40.6 20.4 40.9 21.3 41 22.3 40.9 23.3 40.6 24.3 40.2 25.2 39.8 26.1 39.5 27 39.4 28 39.5 29 39.6 30 39.5 31 39.3 32 38.9 32.9 38.3 33.7 37.6 34.4 36.8 35 35.9 35.4 35 35.8 34.1 36.3 33.4 37 32.9 37.9 32.3 38.7 31.6 39.4 30.8 40 29.9 40.4 28.9 40.7 27.9 40.8 27 40.7 26 40.4 25 40.1 24 40 23 40.1 22.1 40.4 21.1 40.7 20.1 40.8 19.1 40.7 18.2 40.5 17.3 40 16.4 39.5 15.7 38.8 15.2 37.9 14.6 37.1 13.9 36.4 13.1 35.8 12.2 35.4 11.3 35 10.5 34.4 9.7 33.8 9.1 32.9 8.7 32 8.5 31.1 8.4 30.1 8.5 29.1 8.6 28.1 8.5 27.1 8.3 26.1 7.8 25.2 7.4 24.3 7.1 23.4 7 22.4 7.1 21.4 7.3 20.4 7.8 19.5 8.3 18.7 9.1 18 9.8 17.3 10.4 16.5 10.8 15.6 11 14.6 11.3 13.7 11.7 12.8 12.2 11.9 12.9 11.2 13.8 10.7 14.7 10.2 15.6 10 16.6 9.9 17.6 9.8Z",
|
|
528
|
+
"M18.6 9.9 19.5 9.4 20.3 8.8 21.1 8.2 22 7.8 23 7.6 23.9 7.5 24.9 7.6 25.9 7.8 26.8 8.2 27.6 8.7 28.5 9.3 29.3 9.9 30.1 10.5 30.9 11 31.7 11.6 32.5 12.2 33.3 12.8 33.7 13.1 34.1 13.3 34.9 13.9 35.7 14.5 36.6 15 37.4 15.6 38.2 16.2 39 16.8 39.7 17.5 40.2 18.3 40.7 19.2 40.9 20.1 41 21.1 40.9 22.1 40.7 23.1 40.3 24 40 24.9 39.7 25.9 39.4 26.8 39 27.8 38.7 28.7 38.4 29.6 38.1 30.6 37.8 31.5 37.5 32.5 37.2 33.4 36.9 34.4 36.6 35.3 36.2 36.2 35.7 37.1 35 37.8 34.3 38.4 33.4 38.9 32.5 39.3 31.5 39.5 30.5 39.5 30 39.5 29.5 39.5 28.5 39.5 27.5 39.5 26.5 39.5 25.5 39.4 24.5 39.4 23.6 39.4 22.6 39.4 21.6 39.5 20.6 39.5 19.6 39.5 18.6 39.5 17.6 39.5 16.6 39.5 15.6 39.3 14.7 39 13.8 38.5 13.1 37.9 12.4 37.2 11.9 36.3 11.5 35.4 11.2 34.5 10.9 33.5 10.6 32.6 10.3 31.6 10 30.7 9.7 29.7 9.3 28.8 9 27.9 8.7 26.9 8.4 26 8 25 7.7 24.1 7.4 23.2 7.1 22.2 7.1 21.7 7 21.2 7.1 20.2 7.3 19.3 7.7 18.4 8.3 17.5 8.9 16.8 9.7 16.2 10.5 15.6 11.4 15.1 12.2 14.5 13 14 13.8 13.4 14.6 12.8 15.4 12.3 16.2 11.7 17 11.1 17.8 10.5Z",
|
|
529
|
+
"M15.4 12.3 16.2 11.7 17 11.1 17.8 10.5 18.6 9.9 19.5 9.4 20.3 8.8 21.1 8.3 22 7.8 23 7.6 23.9 7.5 24.9 7.6 25.9 7.8 26.8 8.2 27.6 8.7 28.5 9.3 29.3 9.9 30.1 10.5 30.9 11 31.7 11.6 32.5 12.2 33.3 12.8 34.1 13.3 34.9 13.9 35.7 14.5 36.6 15 37.4 15.6 38.2 16.2 39 16.8 39.7 17.5 40.2 18.3 40.7 19.2 40.9 20.1 41 21.1 40.9 22.1 40.7 23.1 40.3 24 40 24.9 39.7 25.9 39.4 26.8 39 27.8 38.7 28.7 38.4 29.6 38.1 30.6 37.8 31.5 37.5 32.5 37.2 33.4 36.9 34.4 36.6 35.3 36.2 36.2 35.7 37.1 35 37.8 34.3 38.4 33.4 38.9 32.5 39.3 31.5 39.4 30.5 39.5 29.5 39.5 28.5 39.5 27.5 39.5 26.5 39.5 25.5 39.4 24.5 39.4 23.6 39.4 22.6 39.4 21.6 39.5 20.6 39.5 19.6 39.5 18.6 39.5 17.6 39.5 16.6 39.5 15.6 39.3 14.7 39 13.8 38.5 13.1 37.9 12.4 37.2 11.9 36.3 11.5 35.4 11.2 34.5 10.9 33.5 10.6 32.6 10.3 31.6 10 30.7 9.7 29.7 9.3 28.8 9 27.9 8.7 26.9 8.4 26 8 25 7.7 24.1 7.4 23.2 7.1 22.2 7 21.2 7.1 20.2 7.3 19.3 7.7 18.4 8.3 17.5 8.9 16.8 9.7 16.2 10.5 15.6 11.4 15.1 12.2 14.5 13 14 13.8 13.4 14.6 12.8Z",
|
|
530
|
+
"M17 12.8 17.7 12.1 18.5 11.5 19.3 10.9 20.1 10.5 20.2 10.4 21.1 10 22 9.7 23 9.4 24 9.2 25 9 26 9 27 9 27.6 9.1 28 9.1 28.9 9.3 29.9 9.6 30.9 9.9 31.8 10.3 32.6 10.8 33.5 11.3 34.3 11.9 34.6 12.2 35 12.6 35.7 13.3 36.4 14.1 36.9 14.9 37.4 15.8 37.9 16.6 38.3 17.6 38.6 18.5 38.6 18.7 38.8 19.5 38.9 20.5 39 21.5 39 22.5 38.9 23.5 38.7 24.5 38.5 25.4 38.2 26.3 38.2 26.4 37.8 27.3 37.4 28.2 36.8 29.1 36.2 29.9 35.6 30.6 34.9 31.3 34.2 32 33.8 32.5 33.5 32.8 32.8 33.5 32.1 34.2 31.4 34.9 30.7 35.6 29.9 36.2 29.1 36.8 28.2 37.3 27.9 37.5 27.4 37.8 26.4 38.2 25.5 38.5 24.5 38.7 23.5 38.9 22.5 39 21.5 39 20.5 38.9 20.4 38.9 19.5 38.8 18.6 38.6 17.6 38.3 16.7 37.9 15.8 37.5 14.9 37 14.1 36.4 13.4 35.8 13.3 35.8 12.6 35.1 12 34.3 11.3 33.5 10.8 32.7 10.3 31.8 9.9 30.9 9.6 30 9.4 29.3 9.3 29 9.1 28 9 27 9 26 9 25 9.2 24 9.4 23 9.6 22.1 9.8 21.7 10 21.1 10.4 20.2 10.9 19.4 11.4 18.5 12.1 17.8 12.7 17 13.4 16.3 14.2 15.6 14.2 15.5 14.9 14.9 15.6 14.2 16.3 13.5Z",
|
|
531
|
+
"M33.5 11.3 34.3 11.9 35 12.6 35.3 12.8 35.7 13.3 36.4 14.1 36.9 14.9 37.4 15.8 37.9 16.6 38.3 17.6 38.3 17.7 38.6 18.5 38.8 19.5 38.9 20.5 39 21.5 39 22.5 38.9 23.5 38.9 23.5 38.7 24.5 38.5 25.4 38.2 26.4 37.8 27.3 37.4 28.2 36.9 28.9 36.8 29.1 36.2 29.9 35.6 30.6 34.9 31.3 34.2 32 33.5 32.8 33.1 33.2 32.8 33.5 32.1 34.2 31.4 34.9 30.7 35.6 29.9 36.2 29.1 36.8 28.7 37 28.2 37.3 27.4 37.8 26.4 38.2 25.5 38.5 24.5 38.7 23.5 38.9 23.3 38.9 22.5 39 21.5 39 20.5 38.9 19.5 38.8 18.6 38.6 17.6 38.3 17.6 38.3 16.7 37.9 15.8 37.5 14.9 37 14.1 36.4 13.3 35.8 12.7 35.2 12.6 35.1 12 34.3 11.3 33.5 10.8 32.7 10.3 31.8 9.9 30.9 9.7 30.3 9.6 29.9 9.3 29 9.1 28 9 27 9 26 9 25 9.1 24.5 9.2 24 9.4 23 9.6 22.1 10 21.1 10.4 20.2 10.9 19.4 11.1 19.1 11.5 18.5 12.1 17.7 12.7 17 13.5 16.3 14.2 15.6 14.9 14.9 14.9 14.8 15.6 14.2 16.3 13.5 17 12.8 17.7 12.1 18.5 11.5 19.3 11 19.3 10.9 20.2 10.4 21.1 10 22 9.7 23 9.4 24 9.2 24.7 9.1 25 9 26 9 27 9 28 9.1 28.9 9.3 29.9 9.6 30.4 9.7 30.9 9.9 31.8 10.3 32.6 10.8Z",
|
|
532
|
+
"M33.2 11.1 34.2 11.2 35.1 11.4 36 11.9 36.6 12.7 36.8 13.7 36.9 14.7 36.9 15.7 37 16.7 37.1 17.7 37.3 18.6 37.9 19.4 38.5 20.2 39.2 20.9 39.8 21.7 40.5 22.4 40.9 23.3 41 24.3 40.7 25.2 40.1 26 39.4 26.8 38.8 27.5 38.1 28.3 37.5 29.1 37.1 30 37 31 37 31.9 36.9 32.9 36.8 33.9 36.7 34.9 36.2 35.8 35.5 36.4 34.5 36.8 33.6 36.8 32.6 36.9 31.6 37 30.6 37.1 29.6 37.2 28.8 37.7 28 38.4 27.3 39 26.5 39.7 25.8 40.3 24.9 40.8 23.9 41 23 40.8 22.1 40.2 21.4 39.6 20.6 38.9 19.9 38.3 19.1 37.6 18.3 37.2 17.3 37 16.3 37 15.3 36.9 14.3 36.8 13.3 36.7 12.4 36.4 11.7 35.7 11.3 34.8 11.2 33.8 11.1 32.8 11 31.8 11 30.8 10.9 29.9 10.4 29 9.8 28.2 9.1 27.5 8.5 26.7 7.8 26 7.3 25.1 7 24.2 7.1 23.2 7.6 22.3 8.2 21.6 8.9 20.8 9.5 20.1 10.2 19.3 10.7 18.5 10.9 17.5 11 16.6 11.1 15.6 11.1 14.6 11.2 13.6 11.5 12.6 12.1 11.9 13 11.4 13.9 11.2 14.9 11.1 15.9 11 16.9 11 17.9 10.9 18.8 10.6 19.6 10 20.4 9.3 21.1 8.6 21.9 8 22.6 7.4 23.6 7 24.6 7.1 25.5 7.5 26.2 8.1 27 8.7 27.7 9.4 28.5 10 29.3 10.6 30.2 10.9 31.2 11 32.2 11.1Z",
|
|
533
|
+
"M27.7 9.4 28.5 10 29.3 10.6 30.2 10.9 31.2 11 32.2 11.1 33.2 11.1 34.2 11.2 35.1 11.4 36 11.9 36.6 12.7 36.8 13.7 36.9 14.7 36.9 15.7 37 16.7 37.1 17.7 37.3 18.6 37.9 19.4 38.5 20.2 39.2 20.9 39.8 21.7 40.5 22.4 40.9 23.3 41 24.3 40.7 25.2 40.1 26 39.4 26.8 38.8 27.5 38.1 28.3 37.5 29.1 37.1 30 37 31 37 31.9 36.9 32.9 36.8 33.9 36.7 34.9 36.2 35.8 35.5 36.4 34.5 36.8 33.6 36.9 32.6 36.9 31.6 37 30.6 37.1 29.6 37.2 28.8 37.7 28 38.4 27.3 39 26.5 39.7 25.8 40.3 24.9 40.8 23.9 41 23 40.8 22.1 40.2 21.4 39.6 20.6 38.9 19.9 38.3 19.1 37.6 18.3 37.2 17.3 37 16.3 37 15.3 36.9 14.3 36.8 13.3 36.7 12.4 36.4 11.7 35.7 11.3 34.8 11.2 33.8 11.1 32.8 11 31.8 11 30.8 10.9 29.9 10.4 29 9.8 28.2 9.1 27.5 8.5 26.7 7.8 26 7.3 25.1 7 24.2 7.1 23.2 7.6 22.3 8.2 21.6 8.9 20.8 9.5 20.1 10.2 19.3 10.7 18.5 10.9 17.5 11 16.5 11.1 15.6 11.1 14.6 11.2 13.6 11.5 12.6 12.1 11.9 13 11.4 13.9 11.2 14.9 11.1 15.9 11 16.9 11 17.9 10.9 18.8 10.6 19.6 10 20.4 9.3 21.1 8.6 21.9 8 22.6 7.4 23.6 7 24.6 7.1 25.5 7.5 26.2 8.1 27 8.7Z",
|
|
534
|
+
"M27.9 10.6 28.8 10.3 29.8 10.1 30.8 10 31.8 10.1 32.7 10.3 33.7 10.6 34.6 11.1 34.8 11.3 35.4 11.7 36.1 12.4 36.7 13.1 37.2 14 37.6 14.9 37.9 15.9 38 16.9 38 17.9 37.8 18.8 37.5 19.8 37.1 20.7 36.8 21.6 36.5 22.6 36.4 23.6 36.4 24.4 36.4 24.6 36.5 25.5 36.8 26.5 37.2 27.4 37.6 28.3 37.8 29.3 38 30.3 38 31.3 37.8 32.3 37.6 33.2 37.2 34.1 36.6 35 36 35.7 35.3 36.4 34.4 37 34.1 37.2 33.6 37.4 32.6 37.8 31.6 37.9 30.6 38 29.7 37.9 28.7 37.7 27.8 37.3 26.8 36.9 25.9 36.6 24.9 36.4 23.9 36.4 22.9 36.4 22 36.6 21 37 20.1 37.4 20.1 37.4 19.2 37.7 18.2 37.9 17.2 38 16.2 37.9 15.3 37.7 14.3 37.4 13.4 36.9 12.6 36.3 11.9 35.6 11.3 34.9 10.8 34 10.4 33.1 10.1 32.1 10 31.1 10 30.6 10 30.1 10.2 29.2 10.5 28.2 10.9 27.3 11.2 26.4 11.5 25.4 11.6 24.4 11.6 23.4 11.5 22.5 11.2 21.5 10.8 20.6 10.4 19.7 10.2 18.7 10 17.7 10 16.7 10 16.6 10.2 15.7 10.4 14.8 10.8 13.9 11.4 13 12 12.3 12.7 11.6 13.6 11 14.4 10.6 15.4 10.2 16.4 10.1 17.4 10 18.3 10.1 19.3 10.3 20.2 10.7 20.9 11 21.2 11.1 22.1 11.4 23.1 11.6 24.1 11.6 25.1 11.6 26 11.4 27 11Z",
|
|
535
|
+
"M36 35.7 35.3 36.4 34.4 37 33.6 37.4 32.6 37.8 31.6 37.9 30.6 38 29.7 37.9 28.7 37.7 27.8 37.3 26.8 36.9 25.9 36.6 24.9 36.4 23.9 36.4 22.9 36.4 22 36.6 21 37 20.1 37.4 19.2 37.7 18.2 37.9 17.2 38 16.2 37.9 15.3 37.7 14.3 37.4 13.4 36.9 12.6 36.3 11.9 35.6 11.3 34.9 10.8 34 10.4 33.1 10.1 32.1 10 31.1 10 30.2 10.2 29.2 10.5 28.2 10.9 27.3 11.2 26.4 11.5 25.4 11.6 24.4 11.6 23.4 11.5 22.5 11.2 21.5 10.8 20.6 10.4 19.7 10.2 18.7 10 17.7 10 16.7 10.2 15.7 10.4 14.8 10.8 13.9 11.4 13 12 12.3 12.7 11.6 13.6 11 14.4 10.6 15.4 10.2 16.4 10.1 17.4 10 18.3 10.1 19.3 10.3 20.2 10.7 21.2 11.1 22.1 11.4 23.1 11.6 24.1 11.6 25.1 11.6 26 11.4 27 11 27.9 10.6 28.8 10.3 29.8 10.1 30.8 10 31.8 10.1 32.7 10.3 33.7 10.6 34.6 11.1 35.4 11.7 36.1 12.4 36.7 13.1 37.2 14 37.6 14.9 37.9 15.9 38 16.9 38 17.8 37.8 18.8 37.5 19.8 37.1 20.7 36.8 21.6 36.5 22.6 36.4 23.6 36.4 24.6 36.5 25.5 36.8 26.5 37.2 27.4 37.6 28.3 37.8 29.3 38 30.3 38 31.3 37.8 32.3 37.6 33.2 37.2 34.1 36.6 35Z",
|
|
536
|
+
"M32.1 32.1 31.4 32.8 30.7 33.5 29.9 34.1 29.1 34.7 28.3 35.3 27.6 35.8 27.5 35.8 26.6 36.4 25.8 36.8 24.9 37.3 24 37.7 23.1 38 22.1 38.3 21.2 38.6 20.2 38.8 19.2 38.9 18.2 39 17.2 39 16.6 38.9 16.3 38.9 15.3 38.7 14.3 38.4 13.4 38 12.5 37.5 11.7 36.9 11.1 36.3 10.5 35.5 10 34.6 9.6 33.7 9.3 32.7 9.1 31.7 9.1 31.4 9 30.8 9 29.8 9.1 28.8 9.2 27.8 9.4 26.8 9.7 25.9 10 24.9 10.3 24 10.7 23.1 11.2 22.2 11.6 21.4 12.2 20.5 12.2 20.4 12.7 19.7 13.3 18.9 13.9 18.1 14.5 17.3 15.2 16.6 15.9 15.9 16.6 15.2 17.3 14.5 18.1 13.9 18.9 13.3 19.7 12.7 20.4 12.2 20.5 12.2 21.4 11.6 22.2 11.2 23.1 10.7 24 10.3 24.9 10 25.9 9.7 26.8 9.4 27.8 9.2 28.8 9.1 29.8 9 30.8 9 31.4 9.1 31.7 9.1 32.7 9.3 33.7 9.6 34.6 10 35.5 10.5 36.3 11.1 36.9 11.7 37.5 12.5 38 13.4 38.4 14.3 38.7 15.3 38.9 16.3 38.9 16.6 39 17.2 39 18.2 38.9 19.2 38.8 20.2 38.6 21.2 38.3 22.1 38 23.1 37.7 24 37.3 24.9 36.8 25.8 36.4 26.6 35.8 27.5 35.8 27.6 35.3 28.3 34.7 29.1 34.1 29.9 33.5 30.7 32.8 31.4Z",
|
|
537
|
+
"M24.3 10.2 24.9 10 25.9 9.7 26.8 9.4 27.1 9.4 27.8 9.2 28.8 9.1 29.8 9 29.9 9 30.8 9 31.7 9.1 32.7 9.3 32.8 9.3 33.7 9.6 34.6 10 35.5 10.5 35.5 10.5 36.3 11.1 36.9 11.7 37.5 12.5 37.5 12.5 38 13.4 38.4 14.3 38.7 15.2 38.7 15.3 38.9 16.3 39 17.2 39 18.1 39 18.2 38.9 19.2 38.8 20.2 38.6 20.9 38.6 21.2 38.3 22.1 38 23.1 37.8 23.7 37.7 24 37.3 24.9 36.8 25.8 36.5 26.4 36.4 26.6 35.8 27.5 35.3 28.3 35 28.8 34.7 29.1 34.1 29.9 33.5 30.7 33.1 31.1 32.8 31.4 32.1 32.1 31.4 32.8 31.1 33.1 30.7 33.5 29.9 34.1 29.1 34.7 28.8 35 28.3 35.3 27.5 35.8 26.6 36.4 26.4 36.5 25.8 36.8 24.9 37.3 24 37.7 23.7 37.8 23.1 38 22.1 38.3 21.2 38.6 20.9 38.6 20.2 38.8 19.2 38.9 18.2 39 18.1 39 17.2 39 16.3 38.9 15.3 38.7 15.2 38.7 14.3 38.4 13.4 38 12.5 37.5 12.5 37.5 11.7 36.9 11.1 36.3 10.5 35.5 10.5 35.5 10 34.6 9.6 33.7 9.3 32.8 9.3 32.7 9.1 31.7 9 30.8 9 29.9 9 29.8 9.1 28.8 9.2 27.8 9.4 27.1 9.4 26.8 9.7 25.9 10 24.9 10.2 24.3 10.3 24 10.7 23.1 11.2 22.2 11.5 21.6 11.6 21.4 12.2 20.5 12.7 19.7 13 19.2 13.3 18.9 13.9 18.1 14.5 17.3 14.9 16.9 15.2 16.6 15.9 15.9 16.6 15.2 16.9 14.9 17.3 14.5 18.1 13.9 18.9 13.3 19.2 13 19.7 12.7 20.5 12.2 21.4 11.6 21.6 11.5 22.2 11.2 23.1 10.7 24 10.3Z",
|
|
538
|
+
"M22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.3 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.4 38.9 26.2 39.6 27 40.2 27.7 40.5 28.6 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.8 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.6 9.1 21.8 8.4 21 7.8 20.3 7.5 19.4 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.2 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1 20.9 10.4 21.4 9.5 21.9 8.7Z"
|
|
539
|
+
].join(";");
|
|
540
|
+
var ROTATE_KEY_TIMES = "0; 0.14; 0.29; 0.43; 0.57; 0.71; 0.86; 1";
|
|
541
|
+
var ROTATE_KEY_SPLINES = [
|
|
542
|
+
"0.5 0.2 0 0.8",
|
|
543
|
+
"0.5 0.2 0 0.8",
|
|
544
|
+
"0.5 0.2 0 0.8",
|
|
545
|
+
"0.5 0.2 0 0.8",
|
|
546
|
+
"0.5 0.2 0 0.8",
|
|
547
|
+
"0.5 0.2 0 0.8",
|
|
548
|
+
"0.5 0.2 0 0.8"
|
|
549
|
+
].join("; ");
|
|
550
|
+
var ROTATE_VALUES = "0 24 24; 154 24 24; 309 24 24; 463 24 24; 617 24 24; 771 24 24; 926 24 24; 1080 24 24";
|
|
551
|
+
var DETERMINATE_CIRCLE = "M24 7 C34.49 7 41 13.51 41 24 C41 34.49 34.49 41 24 41 C13.51 41 7 34.49 7 24 C7 13.51 13.51 7 24 7 Z";
|
|
552
|
+
var DETERMINATE_SOFT_BURST = "M20.9 10.4 21.4 9.5 21.9 8.7 22.5 7.8 23.2 7.2 24.2 7 25.1 7.4 25.7 8.1 26.2 9 26.8 9.8 27.3 10.6 28.1 11.2 29 11.3 30 11 30.9 10.6 31.8 10.3 32.8 9.9 33.7 10 34.5 10.6 34.9 11.5 34.8 12.5 34.8 13.5 34.7 14.5 34.7 15.5 35.2 16.3 36 16.8 37 17.1 37.9 17.3 38.9 17.5 39.8 17.9 40.4 18.7 40.5 19.7 40 20.5 39.4 21.3 38.7 22 38.1 22.8 37.6 23.7 37.7 24.6 38.3 25.5 38.9 26.2 39.6 27 40.2 27.7 40.5 28.7 40.3 29.6 39.5 30.3 38.6 30.6 37.6 30.8 36.7 31 35.7 31.3 35 31.9 34.6 32.8 34.7 33.8 34.8 34.8 34.9 35.8 34.8 36.8 34.3 37.6 33.4 38.1 32.4 38 31.5 37.6 30.6 37.2 29.7 36.9 28.7 36.6 27.8 36.9 27.1 37.6 26.6 38.5 26.1 39.3 25.5 40.2 24.8 40.8 23.8 41 22.9 40.6 22.3 39.9 21.8 39 21.2 38.2 20.7 37.4 19.9 36.8 19 36.7 18 37 17.1 37.4 16.2 37.7 15.2 38.1 14.3 38 13.5 37.4 13.1 36.5 13.2 35.5 13.2 34.5 13.3 33.5 13.3 32.5 12.8 31.7 12 31.2 11 31 10.1 30.7 9.1 30.5 8.2 30.1 7.6 29.3 7.5 28.3 8 27.5 8.7 26.7 9.3 26 9.9 25.2 10.4 24.3 10.3 23.4 9.7 22.5 9.1 21.8 8.4 21 7.8 20.3 7.5 19.3 7.7 18.4 8.5 17.7 9.4 17.4 10.4 17.2 11.3 17 12.3 16.7 13 16.1 13.4 15.2 13.3 14.2 13.2 13.2 13.1 12.2 13.2 11.2 13.7 10.4 14.6 9.9 15.6 10 16.5 10.4 17.4 10.8 18.3 11.1 19.3 11.4 20.2 11.1Z";
|
|
553
|
+
var IndeterminateSvg = React17__namespace.memo(function IndeterminateSvg2({
|
|
554
|
+
size
|
|
555
|
+
}) {
|
|
556
|
+
const [ready, setReady] = React17__namespace.useState(false);
|
|
557
|
+
React17__namespace.useEffect(() => {
|
|
558
|
+
const raf = requestAnimationFrame(() => setReady(true));
|
|
559
|
+
return () => cancelAnimationFrame(raf);
|
|
560
|
+
}, []);
|
|
561
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
562
|
+
"svg",
|
|
563
|
+
{
|
|
564
|
+
viewBox: "4 4 40 40",
|
|
565
|
+
width: size,
|
|
566
|
+
height: size,
|
|
567
|
+
fill: "currentColor",
|
|
568
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
569
|
+
"aria-hidden": "true",
|
|
570
|
+
focusable: "false",
|
|
571
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: SHAPE_VALUES.split(";")[0], children: ready && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
572
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
573
|
+
"animate",
|
|
574
|
+
{
|
|
575
|
+
attributeName: "d",
|
|
576
|
+
dur: "5s",
|
|
577
|
+
repeatCount: "indefinite",
|
|
578
|
+
calcMode: "spline",
|
|
579
|
+
keySplines: SHAPE_KEY_SPLINES,
|
|
580
|
+
keyTimes: SHAPE_KEY_TIMES,
|
|
581
|
+
values: SHAPE_VALUES
|
|
582
|
+
}
|
|
583
|
+
),
|
|
584
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
585
|
+
"animateTransform",
|
|
586
|
+
{
|
|
587
|
+
attributeName: "transform",
|
|
588
|
+
attributeType: "XML",
|
|
589
|
+
type: "rotate",
|
|
590
|
+
dur: "5s",
|
|
591
|
+
repeatCount: "indefinite",
|
|
592
|
+
calcMode: "spline",
|
|
593
|
+
keySplines: ROTATE_KEY_SPLINES,
|
|
594
|
+
keyTimes: ROTATE_KEY_TIMES,
|
|
595
|
+
values: ROTATE_VALUES
|
|
596
|
+
}
|
|
597
|
+
)
|
|
598
|
+
] }) })
|
|
599
|
+
}
|
|
600
|
+
);
|
|
601
|
+
});
|
|
602
|
+
var DeterminateSvg = React17__namespace.memo(function DeterminateSvg2({
|
|
603
|
+
size,
|
|
604
|
+
progress
|
|
605
|
+
}) {
|
|
606
|
+
const p = Math.min(1, Math.max(0, progress));
|
|
607
|
+
const rotation = -180 * p;
|
|
608
|
+
const pathD = p < 0.5 ? DETERMINATE_CIRCLE : DETERMINATE_SOFT_BURST;
|
|
609
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
610
|
+
"svg",
|
|
611
|
+
{
|
|
612
|
+
viewBox: "4 4 40 40",
|
|
613
|
+
width: size,
|
|
614
|
+
height: size,
|
|
615
|
+
fill: "currentColor",
|
|
616
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
617
|
+
"aria-hidden": "true",
|
|
618
|
+
focusable: "false",
|
|
619
|
+
style: {
|
|
620
|
+
transform: `rotate(${rotation}deg)`,
|
|
621
|
+
transition: "transform 0.3s ease"
|
|
622
|
+
},
|
|
623
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: pathD, style: { transition: "d 0.3s ease" } })
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
});
|
|
627
|
+
var LoadingIndicator = React17__namespace.forwardRef(
|
|
628
|
+
(_a, ref) => {
|
|
629
|
+
var _b = _a, {
|
|
630
|
+
variant = "uncontained",
|
|
631
|
+
size = 48,
|
|
632
|
+
progress,
|
|
633
|
+
color,
|
|
634
|
+
className,
|
|
635
|
+
"aria-label": ariaLabel,
|
|
636
|
+
style
|
|
637
|
+
} = _b, restProps = __objRest(_b, [
|
|
638
|
+
"variant",
|
|
639
|
+
"size",
|
|
640
|
+
"progress",
|
|
641
|
+
"color",
|
|
642
|
+
"className",
|
|
643
|
+
"aria-label",
|
|
644
|
+
"style"
|
|
645
|
+
]);
|
|
646
|
+
const isContained = variant === "contained";
|
|
647
|
+
const isDeterminate = progress !== void 0;
|
|
648
|
+
const clampedSize = Math.min(240, Math.max(24, size));
|
|
649
|
+
const scaleFactor = clampedSize / 48;
|
|
650
|
+
const containerSize = isContained ? 38 * scaleFactor : void 0;
|
|
651
|
+
const indicatorSize = isContained ? 24 * scaleFactor : clampedSize;
|
|
652
|
+
const activeColor = isContained ? color != null ? color : "var(--md-sys-color-indicator-contained-active)" : color != null ? color : "var(--md-sys-color-indicator-active)";
|
|
653
|
+
const ariaNow = isDeterminate ? Math.round(Math.min(1, Math.max(0, progress)) * 100) : void 0;
|
|
654
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
655
|
+
"div",
|
|
656
|
+
__spreadProps(__spreadValues({
|
|
657
|
+
ref,
|
|
658
|
+
role: "progressbar",
|
|
659
|
+
"aria-label": ariaLabel,
|
|
660
|
+
"aria-valuemin": 0,
|
|
661
|
+
"aria-valuemax": 100,
|
|
662
|
+
"aria-valuenow": ariaNow,
|
|
663
|
+
className: cn(
|
|
664
|
+
"inline-flex items-center justify-center shrink-0",
|
|
665
|
+
className
|
|
666
|
+
),
|
|
667
|
+
style: __spreadValues({
|
|
668
|
+
width: clampedSize,
|
|
669
|
+
height: clampedSize,
|
|
670
|
+
color: activeColor
|
|
671
|
+
}, style)
|
|
672
|
+
}, restProps), {
|
|
673
|
+
children: isContained ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
className: "flex items-center justify-center rounded-full",
|
|
677
|
+
style: {
|
|
678
|
+
width: containerSize,
|
|
679
|
+
height: containerSize,
|
|
680
|
+
backgroundColor: "var(--md-sys-color-indicator-contained-container)"
|
|
681
|
+
},
|
|
682
|
+
children: isDeterminate ? /* @__PURE__ */ jsxRuntime.jsx(DeterminateSvg, { size: indicatorSize, progress }) : /* @__PURE__ */ jsxRuntime.jsx(IndeterminateSvg, { size: indicatorSize })
|
|
683
|
+
}
|
|
684
|
+
) : isDeterminate ? /* @__PURE__ */ jsxRuntime.jsx(DeterminateSvg, { size: indicatorSize, progress }) : /* @__PURE__ */ jsxRuntime.jsx(IndeterminateSvg, { size: indicatorSize })
|
|
685
|
+
})
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
LoadingIndicator.displayName = "LoadingIndicator";
|
|
690
|
+
|
|
691
|
+
// src/ui/progress-indicator/utils.ts
|
|
692
|
+
function easeInOutCubic(x) {
|
|
693
|
+
return x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2;
|
|
694
|
+
}
|
|
695
|
+
function generateWavyCircularPath(center, radius, amplitude, wavelength) {
|
|
696
|
+
const circumference = 2 * Math.PI * radius;
|
|
697
|
+
const numWaves = Math.max(
|
|
698
|
+
3,
|
|
699
|
+
Math.round(circumference / Math.max(1, wavelength))
|
|
700
|
+
);
|
|
701
|
+
const steps = numWaves * 4;
|
|
702
|
+
const dt = 2 * Math.PI / steps;
|
|
703
|
+
const rAt = (t) => radius + amplitude * Math.sin(numWaves * t);
|
|
704
|
+
const drAt = (t) => amplitude * numWaves * Math.cos(numWaves * t);
|
|
705
|
+
const xAt = (t) => center + rAt(t) * Math.cos(t);
|
|
706
|
+
const yAt = (t) => center + rAt(t) * Math.sin(t);
|
|
707
|
+
const dxAt = (t) => drAt(t) * Math.cos(t) - rAt(t) * Math.sin(t);
|
|
708
|
+
const dyAt = (t) => drAt(t) * Math.sin(t) + rAt(t) * Math.cos(t);
|
|
709
|
+
let d = "";
|
|
710
|
+
const tStart = 0;
|
|
711
|
+
for (let i = 0; i < steps; i++) {
|
|
712
|
+
const t0 = tStart + i * dt;
|
|
713
|
+
const t1 = tStart + (i + 1) * dt;
|
|
714
|
+
const scale = dt / 3;
|
|
715
|
+
const cp1x = xAt(t0) + scale * dxAt(t0);
|
|
716
|
+
const cp1y = yAt(t0) + scale * dyAt(t0);
|
|
717
|
+
const cp2x = xAt(t1) - scale * dxAt(t1);
|
|
718
|
+
const cp2y = yAt(t1) - scale * dyAt(t1);
|
|
719
|
+
if (i === 0) d += `M ${xAt(t0).toFixed(2)} ${yAt(t0).toFixed(2)}`;
|
|
720
|
+
d += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${xAt(t1).toFixed(2)} ${yAt(t1).toFixed(2)}`;
|
|
721
|
+
}
|
|
722
|
+
d += " Z";
|
|
723
|
+
return d;
|
|
724
|
+
}
|
|
725
|
+
function getSinePath(startX, endX, phase, wl, amp) {
|
|
726
|
+
if (startX >= endX) return "";
|
|
727
|
+
let d = "";
|
|
728
|
+
const step = amp === 0 ? Math.max(10, endX - startX) : 1;
|
|
729
|
+
const yStart = Math.sin((startX + phase) / wl * 2 * Math.PI) * amp;
|
|
730
|
+
d += `M ${startX.toFixed(2)} ${yStart.toFixed(2)}`;
|
|
731
|
+
let nextX = Math.ceil(startX / step) * step;
|
|
732
|
+
if (nextX === startX) nextX += step;
|
|
733
|
+
while (nextX < endX) {
|
|
734
|
+
const y = Math.sin((nextX + phase) / wl * 2 * Math.PI) * amp;
|
|
735
|
+
d += ` L ${nextX.toFixed(2)} ${y.toFixed(2)}`;
|
|
736
|
+
nextX += step;
|
|
737
|
+
}
|
|
738
|
+
const yEnd = Math.sin((endX + phase) / wl * 2 * Math.PI) * amp;
|
|
739
|
+
d += ` L ${endX.toFixed(2)} ${yEnd.toFixed(2)}`;
|
|
740
|
+
return d;
|
|
741
|
+
}
|
|
742
|
+
var CircularProgress = React17__namespace.forwardRef(
|
|
743
|
+
(_a, ref) => {
|
|
744
|
+
var _b = _a, {
|
|
745
|
+
value,
|
|
746
|
+
size = 48,
|
|
747
|
+
trackHeight = 4,
|
|
748
|
+
shape = "flat",
|
|
749
|
+
amplitude,
|
|
750
|
+
wavelength,
|
|
751
|
+
gapSize = 4,
|
|
752
|
+
crawlerSpeed = 1,
|
|
753
|
+
color,
|
|
754
|
+
trackColor,
|
|
755
|
+
className,
|
|
756
|
+
"aria-label": ariaLabel
|
|
757
|
+
} = _b, restProps = __objRest(_b, [
|
|
758
|
+
"value",
|
|
759
|
+
"size",
|
|
760
|
+
"trackHeight",
|
|
761
|
+
"shape",
|
|
762
|
+
"amplitude",
|
|
763
|
+
"wavelength",
|
|
764
|
+
"gapSize",
|
|
765
|
+
"crawlerSpeed",
|
|
766
|
+
"color",
|
|
767
|
+
"trackColor",
|
|
768
|
+
"className",
|
|
769
|
+
"aria-label"
|
|
770
|
+
]);
|
|
771
|
+
const isDeterminate = value !== void 0;
|
|
772
|
+
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
773
|
+
const radius = (size - trackHeight) / 2;
|
|
774
|
+
const center = size / 2;
|
|
775
|
+
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
776
|
+
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
777
|
+
const isWavy = shape === "wavy";
|
|
778
|
+
const BASELINE_SIZE = 48;
|
|
779
|
+
const scaleFactor = size / BASELINE_SIZE;
|
|
780
|
+
const effectiveAmplitude = React17__namespace.useMemo(
|
|
781
|
+
() => amplitude != null ? amplitude : 1.6 * scaleFactor,
|
|
782
|
+
[amplitude, scaleFactor]
|
|
783
|
+
);
|
|
784
|
+
const effectiveWavelength = React17__namespace.useMemo(
|
|
785
|
+
() => wavelength != null ? wavelength : 15 * scaleFactor,
|
|
786
|
+
[wavelength, scaleFactor]
|
|
787
|
+
);
|
|
788
|
+
const wavyActivePath = React17__namespace.useMemo(
|
|
789
|
+
() => isWavy ? generateWavyCircularPath(
|
|
790
|
+
center,
|
|
791
|
+
radius,
|
|
792
|
+
effectiveAmplitude,
|
|
793
|
+
effectiveWavelength
|
|
794
|
+
) : null,
|
|
795
|
+
[isWavy, center, radius, effectiveAmplitude, effectiveWavelength]
|
|
796
|
+
);
|
|
797
|
+
const circumference = React17__namespace.useMemo(() => 2 * Math.PI * radius, [radius]);
|
|
798
|
+
const gapForTrack = React17__namespace.useMemo(
|
|
799
|
+
() => (gapSize + trackHeight) / circumference,
|
|
800
|
+
[gapSize, trackHeight, circumference]
|
|
801
|
+
);
|
|
802
|
+
const activeAngularFraction = isDeterminate ? clampedValue / 100 : 0;
|
|
803
|
+
const trackOffset = isDeterminate ? activeAngularFraction + gapForTrack : 0;
|
|
804
|
+
const trackLength = isDeterminate ? Math.max(1e-3, 1 - activeAngularFraction - 2 * gapForTrack) : 1;
|
|
805
|
+
const ActiveCircleElem = react.m.circle;
|
|
806
|
+
const ActivePathElem = react.m.path;
|
|
807
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
808
|
+
"div",
|
|
809
|
+
__spreadProps(__spreadValues({
|
|
810
|
+
ref,
|
|
811
|
+
role: "progressbar",
|
|
812
|
+
"aria-label": ariaLabel,
|
|
813
|
+
"aria-valuenow": isDeterminate ? clampedValue : void 0,
|
|
814
|
+
"aria-valuemin": 0,
|
|
815
|
+
"aria-valuemax": 100,
|
|
816
|
+
className: cn(
|
|
817
|
+
"relative inline-flex items-center justify-center shrink-0",
|
|
818
|
+
className
|
|
819
|
+
),
|
|
820
|
+
style: { width: size, height: size }
|
|
821
|
+
}, restProps), {
|
|
822
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(react.LazyMotion, { features: react.domMax, strict: true, children: [
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
824
|
+
"svg",
|
|
825
|
+
{
|
|
826
|
+
width: size,
|
|
827
|
+
height: size,
|
|
828
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
829
|
+
"aria-hidden": "true",
|
|
830
|
+
style: { transform: "rotate(-90deg)", overflow: "visible" },
|
|
831
|
+
children: [
|
|
832
|
+
isDeterminate ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
833
|
+
react.m.circle,
|
|
834
|
+
{
|
|
835
|
+
cx: center,
|
|
836
|
+
cy: center,
|
|
837
|
+
r: radius,
|
|
838
|
+
fill: "none",
|
|
839
|
+
stroke: bgTrackColor,
|
|
840
|
+
strokeWidth: trackHeight,
|
|
841
|
+
initial: { pathLength: trackLength, pathOffset: trackOffset },
|
|
842
|
+
animate: { pathLength: trackLength, pathOffset: trackOffset },
|
|
843
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] },
|
|
844
|
+
strokeLinecap: "round"
|
|
845
|
+
}
|
|
846
|
+
) : null,
|
|
847
|
+
isDeterminate && (isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
848
|
+
ActivePathElem,
|
|
849
|
+
{
|
|
850
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
851
|
+
fill: "none",
|
|
852
|
+
stroke: activeColor,
|
|
853
|
+
strokeWidth: trackHeight,
|
|
854
|
+
strokeLinecap: "round",
|
|
855
|
+
initial: { pathLength: 0 },
|
|
856
|
+
animate: { pathLength: clampedValue / 100 },
|
|
857
|
+
transition: {
|
|
858
|
+
duration: 0.4,
|
|
859
|
+
ease: [0.2, 0, 0, 1]
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
863
|
+
ActiveCircleElem,
|
|
864
|
+
{
|
|
865
|
+
cx: center,
|
|
866
|
+
cy: center,
|
|
867
|
+
r: radius,
|
|
868
|
+
fill: "none",
|
|
869
|
+
stroke: activeColor,
|
|
870
|
+
strokeWidth: trackHeight,
|
|
871
|
+
strokeLinecap: "round",
|
|
872
|
+
initial: { pathLength: 0 },
|
|
873
|
+
animate: { pathLength: clampedValue / 100 },
|
|
874
|
+
transition: {
|
|
875
|
+
duration: 0.4,
|
|
876
|
+
ease: [0.2, 0, 0, 1]
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
))
|
|
880
|
+
]
|
|
881
|
+
}
|
|
882
|
+
),
|
|
883
|
+
!isDeterminate && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
884
|
+
react.m.svg,
|
|
885
|
+
{
|
|
886
|
+
width: size,
|
|
887
|
+
height: size,
|
|
888
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
889
|
+
"aria-hidden": "true",
|
|
890
|
+
style: {
|
|
891
|
+
position: "absolute",
|
|
892
|
+
inset: 0,
|
|
893
|
+
overflow: "visible",
|
|
894
|
+
rotate: "-90deg",
|
|
895
|
+
transformOrigin: "center"
|
|
896
|
+
},
|
|
897
|
+
animate: { rotate: ["-90deg", "270deg"] },
|
|
898
|
+
transition: {
|
|
899
|
+
rotate: {
|
|
900
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
901
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
902
|
+
ease: "linear"
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
children: [
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
907
|
+
react.m.circle,
|
|
908
|
+
{
|
|
909
|
+
cx: center,
|
|
910
|
+
cy: center,
|
|
911
|
+
r: radius,
|
|
912
|
+
fill: "none",
|
|
913
|
+
stroke: bgTrackColor,
|
|
914
|
+
strokeWidth: trackHeight,
|
|
915
|
+
strokeLinecap: "round",
|
|
916
|
+
style: { originX: "50%", originY: "50%" },
|
|
917
|
+
animate: {
|
|
918
|
+
pathLength: [
|
|
919
|
+
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack),
|
|
920
|
+
Math.max(1e-3, 1 - 0.75 - 2 * gapForTrack),
|
|
921
|
+
Math.max(1e-3, 1 - 0.1 - 2 * gapForTrack)
|
|
922
|
+
],
|
|
923
|
+
rotate: [
|
|
924
|
+
`${(0.1 + gapForTrack) * 360}deg`,
|
|
925
|
+
`${(1 + gapForTrack) * 360}deg`,
|
|
926
|
+
`${(1.1 + gapForTrack) * 360}deg`
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
transition: {
|
|
930
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
931
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
932
|
+
ease: [0.4, 0, 0.2, 1]
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
937
|
+
ActivePathElem,
|
|
938
|
+
{
|
|
939
|
+
d: wavyActivePath != null ? wavyActivePath : "",
|
|
940
|
+
fill: "none",
|
|
941
|
+
stroke: activeColor,
|
|
942
|
+
strokeWidth: trackHeight,
|
|
943
|
+
strokeLinecap: "round",
|
|
944
|
+
style: { originX: "50%", originY: "50%" },
|
|
945
|
+
animate: {
|
|
946
|
+
pathLength: [0.1, 0.75, 0.1],
|
|
947
|
+
rotate: ["0deg", "90deg", "360deg"]
|
|
948
|
+
},
|
|
949
|
+
transition: {
|
|
950
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
951
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
952
|
+
ease: [0.4, 0, 0.2, 1]
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
956
|
+
ActiveCircleElem,
|
|
957
|
+
{
|
|
958
|
+
cx: center,
|
|
959
|
+
cy: center,
|
|
960
|
+
r: radius,
|
|
961
|
+
fill: "none",
|
|
962
|
+
stroke: activeColor,
|
|
963
|
+
strokeWidth: trackHeight,
|
|
964
|
+
strokeLinecap: "round",
|
|
965
|
+
style: { originX: "50%", originY: "50%" },
|
|
966
|
+
animate: {
|
|
967
|
+
pathLength: [0.1, 0.75, 0.1],
|
|
968
|
+
rotate: ["0deg", "90deg", "360deg"]
|
|
969
|
+
},
|
|
970
|
+
transition: {
|
|
971
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
972
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
973
|
+
ease: [0.4, 0, 0.2, 1]
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
)
|
|
977
|
+
]
|
|
978
|
+
}
|
|
979
|
+
)
|
|
980
|
+
] })
|
|
981
|
+
})
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
);
|
|
985
|
+
CircularProgress.displayName = "CircularProgress";
|
|
986
|
+
function useContainerWidth() {
|
|
987
|
+
const [width, setWidth] = React17__namespace.useState(0);
|
|
988
|
+
const observerRef = React17__namespace.useRef(null);
|
|
989
|
+
const ref = React17__namespace.useCallback((node) => {
|
|
990
|
+
if (observerRef.current) {
|
|
991
|
+
observerRef.current.disconnect();
|
|
992
|
+
observerRef.current = null;
|
|
993
|
+
}
|
|
994
|
+
if (node) {
|
|
995
|
+
const obs = new ResizeObserver((entries) => {
|
|
996
|
+
const contentRect = entries[0].contentRect;
|
|
997
|
+
setWidth(contentRect.width);
|
|
998
|
+
});
|
|
999
|
+
obs.observe(node);
|
|
1000
|
+
observerRef.current = obs;
|
|
1001
|
+
}
|
|
1002
|
+
}, []);
|
|
1003
|
+
React17__namespace.useEffect(() => {
|
|
1004
|
+
return () => {
|
|
1005
|
+
if (observerRef.current) {
|
|
1006
|
+
observerRef.current.disconnect();
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
}, []);
|
|
1010
|
+
return [ref, width];
|
|
1011
|
+
}
|
|
1012
|
+
function useMergedRef(...refs) {
|
|
1013
|
+
return React17__namespace.useCallback(
|
|
1014
|
+
(node) => {
|
|
1015
|
+
for (const ref of refs) {
|
|
1016
|
+
if (typeof ref === "function") {
|
|
1017
|
+
ref(node);
|
|
1018
|
+
} else if (ref && typeof ref === "object") {
|
|
1019
|
+
ref.current = node;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1024
|
+
[refs]
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
var FlatLinearTrack = React17__namespace.memo(function FlatLinearTrack2({
|
|
1028
|
+
trackHeight,
|
|
1029
|
+
activeColor,
|
|
1030
|
+
trackColor,
|
|
1031
|
+
value,
|
|
1032
|
+
isRtl,
|
|
1033
|
+
gapSize,
|
|
1034
|
+
crawlerSpeed
|
|
1035
|
+
}) {
|
|
1036
|
+
const isDeterminate = value !== void 0;
|
|
1037
|
+
const radius = trackHeight / 2;
|
|
1038
|
+
const minActiveWidth = trackHeight;
|
|
1039
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1040
|
+
"div",
|
|
1041
|
+
{
|
|
1042
|
+
className: "relative w-full overflow-hidden",
|
|
1043
|
+
style: { height: trackHeight, borderRadius: radius },
|
|
1044
|
+
children: isDeterminate ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1045
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1046
|
+
react.m.div,
|
|
1047
|
+
{
|
|
1048
|
+
className: "absolute inset-y-0",
|
|
1049
|
+
style: {
|
|
1050
|
+
backgroundColor: trackColor,
|
|
1051
|
+
borderRadius: radius,
|
|
1052
|
+
width: "100%"
|
|
1053
|
+
},
|
|
1054
|
+
initial: {
|
|
1055
|
+
[isRtl ? "right" : "left"]: `calc(max(${minActiveWidth}px, 0%) + ${gapSize}px)`
|
|
1056
|
+
},
|
|
1057
|
+
animate: {
|
|
1058
|
+
[isRtl ? "right" : "left"]: `calc(max(${minActiveWidth}px, ${value}%) + ${gapSize}px)`
|
|
1059
|
+
},
|
|
1060
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] }
|
|
1061
|
+
}
|
|
1062
|
+
),
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1064
|
+
react.m.div,
|
|
1065
|
+
{
|
|
1066
|
+
className: "absolute inset-y-0",
|
|
1067
|
+
style: __spreadValues({
|
|
1068
|
+
backgroundColor: activeColor,
|
|
1069
|
+
borderRadius: radius,
|
|
1070
|
+
minWidth: minActiveWidth
|
|
1071
|
+
}, isRtl ? { right: 0 } : { left: 0 }),
|
|
1072
|
+
initial: { width: `${minActiveWidth}px` },
|
|
1073
|
+
animate: { width: `${value}%` },
|
|
1074
|
+
transition: { duration: 0.4, ease: [0.2, 0, 0, 1] }
|
|
1075
|
+
}
|
|
1076
|
+
)
|
|
1077
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1078
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1079
|
+
"div",
|
|
1080
|
+
{
|
|
1081
|
+
className: "absolute inset-0",
|
|
1082
|
+
style: { backgroundColor: trackColor, borderRadius: radius }
|
|
1083
|
+
}
|
|
1084
|
+
),
|
|
1085
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1086
|
+
react.m.div,
|
|
1087
|
+
{
|
|
1088
|
+
className: "absolute inset-y-0",
|
|
1089
|
+
style: { backgroundColor: activeColor, borderRadius: radius },
|
|
1090
|
+
initial: { left: "-40%", width: "40%" },
|
|
1091
|
+
animate: { left: ["-40%", "100%"], width: ["40%", "20%", "40%"] },
|
|
1092
|
+
transition: {
|
|
1093
|
+
duration: 2 / Math.max(0.1, crawlerSpeed),
|
|
1094
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
1095
|
+
ease: "easeInOut"
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
1099
|
+
] })
|
|
1100
|
+
}
|
|
1101
|
+
);
|
|
1102
|
+
});
|
|
1103
|
+
var WavyLinearTrack = React17__namespace.memo(function WavyLinearTrack2({
|
|
1104
|
+
trackHeight,
|
|
1105
|
+
svgHeight,
|
|
1106
|
+
amplitude,
|
|
1107
|
+
wavelength,
|
|
1108
|
+
indeterminateWavelength,
|
|
1109
|
+
activeColor,
|
|
1110
|
+
trackColor,
|
|
1111
|
+
value,
|
|
1112
|
+
isRtl,
|
|
1113
|
+
gapSize,
|
|
1114
|
+
waveSpeed,
|
|
1115
|
+
crawlerSpeed,
|
|
1116
|
+
determinateAnimation,
|
|
1117
|
+
indeterminateAnimation,
|
|
1118
|
+
trackShape
|
|
1119
|
+
}) {
|
|
1120
|
+
const isDeterminate = typeof value === "number";
|
|
1121
|
+
const clampedValue = isDeterminate ? Math.max(0, Math.min(100, value)) : 100;
|
|
1122
|
+
const titleId = React17__namespace.useId();
|
|
1123
|
+
const [containerRef, width] = useContainerWidth();
|
|
1124
|
+
const activePathRef = React17__namespace.useRef(null);
|
|
1125
|
+
const trackPathRef = React17__namespace.useRef(null);
|
|
1126
|
+
const amplitudeMV = react.useMotionValue(amplitude);
|
|
1127
|
+
const fractionMV = react.useMotionValue(isDeterminate ? clampedValue / 100 : 1);
|
|
1128
|
+
React17__namespace.useEffect(() => {
|
|
1129
|
+
if (isDeterminate) {
|
|
1130
|
+
const fraction = clampedValue / 100;
|
|
1131
|
+
let targetAmp = amplitude;
|
|
1132
|
+
if (determinateAnimation === "md3") {
|
|
1133
|
+
targetAmp = fraction <= 0.1 || fraction >= 0.95 ? 0 : amplitude;
|
|
1134
|
+
}
|
|
1135
|
+
react.animate(amplitudeMV, targetAmp, {
|
|
1136
|
+
type: "spring",
|
|
1137
|
+
bounce: 0,
|
|
1138
|
+
duration: 0.5
|
|
1139
|
+
});
|
|
1140
|
+
react.animate(fractionMV, fraction, { duration: 0.4, ease: [0.2, 0, 0, 1] });
|
|
1141
|
+
}
|
|
1142
|
+
}, [
|
|
1143
|
+
clampedValue,
|
|
1144
|
+
isDeterminate,
|
|
1145
|
+
amplitude,
|
|
1146
|
+
amplitudeMV,
|
|
1147
|
+
fractionMV,
|
|
1148
|
+
determinateAnimation
|
|
1149
|
+
]);
|
|
1150
|
+
const activeWavelength = Math.max(
|
|
1151
|
+
1,
|
|
1152
|
+
isDeterminate ? wavelength : indeterminateWavelength
|
|
1153
|
+
);
|
|
1154
|
+
const trackAmp = trackShape === "wavy" ? amplitude : 0;
|
|
1155
|
+
react.useAnimationFrame((time) => {
|
|
1156
|
+
if (width === 0) return;
|
|
1157
|
+
const currentAmp = amplitudeMV.get();
|
|
1158
|
+
const phase = time / 1e3 * waveSpeed * activeWavelength;
|
|
1159
|
+
const capWidth = trackHeight / 2;
|
|
1160
|
+
let activePathD = "";
|
|
1161
|
+
let trackD = "";
|
|
1162
|
+
const totalGap = gapSize + trackHeight;
|
|
1163
|
+
if (isDeterminate) {
|
|
1164
|
+
const fraction = fractionMV.get();
|
|
1165
|
+
const barHead = fraction * width;
|
|
1166
|
+
const adjHead = Math.max(capWidth, Math.min(width - capWidth, barHead));
|
|
1167
|
+
const adjTail = capWidth;
|
|
1168
|
+
if (fraction > 0 && adjHead - adjTail > 0.1) {
|
|
1169
|
+
activePathD = getSinePath(
|
|
1170
|
+
adjTail,
|
|
1171
|
+
adjHead,
|
|
1172
|
+
phase,
|
|
1173
|
+
activeWavelength,
|
|
1174
|
+
currentAmp
|
|
1175
|
+
);
|
|
1176
|
+
} else if (fraction === 0) {
|
|
1177
|
+
activePathD = `M ${capWidth} 0 L ${capWidth + 0.01} 0`;
|
|
1178
|
+
}
|
|
1179
|
+
const trackStart = adjHead + totalGap;
|
|
1180
|
+
if (trackStart < width - capWidth) {
|
|
1181
|
+
trackD = getSinePath(
|
|
1182
|
+
trackStart,
|
|
1183
|
+
width - capWidth,
|
|
1184
|
+
phase,
|
|
1185
|
+
activeWavelength,
|
|
1186
|
+
trackAmp
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
} else {
|
|
1190
|
+
const safeCrawlerSpeed = Math.max(0.1, crawlerSpeed);
|
|
1191
|
+
const activeLines = [];
|
|
1192
|
+
if (indeterminateAnimation === "continuous") {
|
|
1193
|
+
const cycle = 2e3 / safeCrawlerSpeed;
|
|
1194
|
+
const fraction = time % cycle / cycle;
|
|
1195
|
+
activeLines.push({
|
|
1196
|
+
tail: easeInOutCubic(Math.max(0, fraction * 1.5 - 0.5)),
|
|
1197
|
+
head: easeInOutCubic(Math.min(1, fraction * 1.5))
|
|
1198
|
+
});
|
|
1199
|
+
} else {
|
|
1200
|
+
const cycle = 1750 / safeCrawlerSpeed;
|
|
1201
|
+
const t = time % cycle * safeCrawlerSpeed;
|
|
1202
|
+
const l1H = easeInOutCubic(Math.max(0, Math.min(1, t / 1e3)));
|
|
1203
|
+
const l1T = easeInOutCubic(Math.max(0, Math.min(1, (t - 250) / 1e3)));
|
|
1204
|
+
const l2H = easeInOutCubic(Math.max(0, Math.min(1, (t - 650) / 850)));
|
|
1205
|
+
const l2T = easeInOutCubic(Math.max(0, Math.min(1, (t - 900) / 850)));
|
|
1206
|
+
activeLines.push({ tail: l1T, head: l1H });
|
|
1207
|
+
activeLines.push({ tail: l2T, head: l2H });
|
|
1208
|
+
}
|
|
1209
|
+
const segments = activeLines.map((line) => {
|
|
1210
|
+
const barTail = line.tail * width;
|
|
1211
|
+
const barHead = line.head * width;
|
|
1212
|
+
const adjTail = Math.max(
|
|
1213
|
+
capWidth,
|
|
1214
|
+
Math.min(width - capWidth, barTail)
|
|
1215
|
+
);
|
|
1216
|
+
const adjHead = Math.max(
|
|
1217
|
+
capWidth,
|
|
1218
|
+
Math.min(width - capWidth, barHead)
|
|
1219
|
+
);
|
|
1220
|
+
return { adjTail, adjHead };
|
|
1221
|
+
}).filter((seg) => seg.adjHead - seg.adjTail > 0.1);
|
|
1222
|
+
activePathD = segments.map(
|
|
1223
|
+
(seg) => getSinePath(
|
|
1224
|
+
seg.adjTail,
|
|
1225
|
+
seg.adjHead,
|
|
1226
|
+
phase,
|
|
1227
|
+
activeWavelength,
|
|
1228
|
+
currentAmp
|
|
1229
|
+
)
|
|
1230
|
+
).join(" ");
|
|
1231
|
+
let currentTrackX = capWidth;
|
|
1232
|
+
for (const seg of segments) {
|
|
1233
|
+
const trackEnd = seg.adjTail - totalGap;
|
|
1234
|
+
if (trackEnd > currentTrackX) {
|
|
1235
|
+
trackD += `${getSinePath(currentTrackX, trackEnd, phase, activeWavelength, trackAmp)} `;
|
|
1236
|
+
}
|
|
1237
|
+
currentTrackX = Math.max(currentTrackX, seg.adjHead + totalGap);
|
|
1238
|
+
}
|
|
1239
|
+
if (currentTrackX < width - capWidth) {
|
|
1240
|
+
trackD += getSinePath(
|
|
1241
|
+
currentTrackX,
|
|
1242
|
+
width - capWidth,
|
|
1243
|
+
phase,
|
|
1244
|
+
activeWavelength,
|
|
1245
|
+
trackAmp
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
if (activePathRef.current)
|
|
1250
|
+
activePathRef.current.setAttribute("d", activePathD);
|
|
1251
|
+
if (trackPathRef.current)
|
|
1252
|
+
trackPathRef.current.setAttribute("d", trackD.trim());
|
|
1253
|
+
});
|
|
1254
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1255
|
+
"div",
|
|
1256
|
+
{
|
|
1257
|
+
ref: containerRef,
|
|
1258
|
+
className: "relative w-full overflow-hidden",
|
|
1259
|
+
style: { height: svgHeight },
|
|
1260
|
+
children: width > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1261
|
+
"svg",
|
|
1262
|
+
{
|
|
1263
|
+
className: "absolute inset-0 w-full h-full",
|
|
1264
|
+
style: {
|
|
1265
|
+
overflow: "visible",
|
|
1266
|
+
transform: isRtl ? "scaleX(-1)" : void 0
|
|
1267
|
+
},
|
|
1268
|
+
"aria-labelledby": titleId,
|
|
1269
|
+
children: [
|
|
1270
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { id: titleId, children: isDeterminate ? `Progress: ${clampedValue}%` : "Indeterminate loading progress" }),
|
|
1271
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(0, ${svgHeight / 2})`, children: [
|
|
1272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1273
|
+
"path",
|
|
1274
|
+
{
|
|
1275
|
+
ref: trackPathRef,
|
|
1276
|
+
fill: "none",
|
|
1277
|
+
stroke: trackColor,
|
|
1278
|
+
strokeWidth: trackHeight,
|
|
1279
|
+
strokeLinecap: "round"
|
|
1280
|
+
}
|
|
1281
|
+
),
|
|
1282
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1283
|
+
"path",
|
|
1284
|
+
{
|
|
1285
|
+
ref: activePathRef,
|
|
1286
|
+
fill: "none",
|
|
1287
|
+
stroke: activeColor,
|
|
1288
|
+
strokeWidth: trackHeight,
|
|
1289
|
+
strokeLinecap: "round"
|
|
1290
|
+
}
|
|
1291
|
+
)
|
|
1292
|
+
] })
|
|
1293
|
+
]
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
}
|
|
1297
|
+
);
|
|
1298
|
+
});
|
|
1299
|
+
var LinearProgress = React17__namespace.forwardRef(
|
|
1300
|
+
(_a, ref) => {
|
|
1301
|
+
var _b = _a, {
|
|
1302
|
+
value,
|
|
1303
|
+
shape = "flat",
|
|
1304
|
+
trackShape,
|
|
1305
|
+
trackHeight = 4,
|
|
1306
|
+
amplitude,
|
|
1307
|
+
wavelength = 40,
|
|
1308
|
+
indeterminateWavelength = 20,
|
|
1309
|
+
waveSpeed = 1,
|
|
1310
|
+
crawlerSpeed = 1,
|
|
1311
|
+
determinateAnimation = "md3",
|
|
1312
|
+
indeterminateAnimation = "continuous",
|
|
1313
|
+
gapSize = 4,
|
|
1314
|
+
showStopIndicator = "auto",
|
|
1315
|
+
color,
|
|
1316
|
+
trackColor,
|
|
1317
|
+
className,
|
|
1318
|
+
"aria-label": ariaLabel
|
|
1319
|
+
} = _b, restProps = __objRest(_b, [
|
|
1320
|
+
"value",
|
|
1321
|
+
"shape",
|
|
1322
|
+
"trackShape",
|
|
1323
|
+
"trackHeight",
|
|
1324
|
+
"amplitude",
|
|
1325
|
+
"wavelength",
|
|
1326
|
+
"indeterminateWavelength",
|
|
1327
|
+
"waveSpeed",
|
|
1328
|
+
"crawlerSpeed",
|
|
1329
|
+
"determinateAnimation",
|
|
1330
|
+
"indeterminateAnimation",
|
|
1331
|
+
"gapSize",
|
|
1332
|
+
"showStopIndicator",
|
|
1333
|
+
"color",
|
|
1334
|
+
"trackColor",
|
|
1335
|
+
"className",
|
|
1336
|
+
"aria-label"
|
|
1337
|
+
]);
|
|
1338
|
+
const isDeterminate = value !== void 0;
|
|
1339
|
+
const clampedValue = isDeterminate ? Math.min(100, Math.max(0, value)) : 0;
|
|
1340
|
+
const containerRef = React17__namespace.useRef(null);
|
|
1341
|
+
const mergedRef = useMergedRef(ref, containerRef);
|
|
1342
|
+
const [isRtl, setIsRtl] = React17__namespace.useState(false);
|
|
1343
|
+
React17__namespace.useEffect(() => {
|
|
1344
|
+
if (containerRef.current) {
|
|
1345
|
+
const dir = getComputedStyle(containerRef.current).direction;
|
|
1346
|
+
setIsRtl(dir === "rtl");
|
|
1347
|
+
}
|
|
1348
|
+
}, []);
|
|
1349
|
+
const isWavy = shape === "wavy";
|
|
1350
|
+
const resolvedTrackShape = trackShape != null ? trackShape : shape;
|
|
1351
|
+
const effectiveAmplitude = React17__namespace.useMemo(() => amplitude != null ? amplitude : 3, [amplitude]);
|
|
1352
|
+
const svgHeight = React17__namespace.useMemo(
|
|
1353
|
+
() => isWavy ? trackHeight + effectiveAmplitude * 2 : trackHeight,
|
|
1354
|
+
[isWavy, trackHeight, effectiveAmplitude]
|
|
1355
|
+
);
|
|
1356
|
+
const shouldShowStop = React17__namespace.useMemo(
|
|
1357
|
+
() => isDeterminate && resolvedTrackShape === "flat" && (showStopIndicator === true || showStopIndicator === "auto" && isDeterminate),
|
|
1358
|
+
[isDeterminate, resolvedTrackShape, showStopIndicator]
|
|
1359
|
+
);
|
|
1360
|
+
const stopSize = React17__namespace.useMemo(
|
|
1361
|
+
() => Math.max(2, trackHeight > 4 ? 4 : trackHeight / 2),
|
|
1362
|
+
[trackHeight]
|
|
1363
|
+
);
|
|
1364
|
+
const stopOffset = (trackHeight - stopSize) / 2;
|
|
1365
|
+
const activeColor = color || "var(--md-sys-color-indicator-active)";
|
|
1366
|
+
const bgTrackColor = trackColor || "var(--md-sys-color-indicator-track)";
|
|
1367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1368
|
+
"div",
|
|
1369
|
+
__spreadProps(__spreadValues({
|
|
1370
|
+
ref: mergedRef,
|
|
1371
|
+
role: "progressbar",
|
|
1372
|
+
"aria-label": ariaLabel,
|
|
1373
|
+
"aria-valuenow": isDeterminate ? clampedValue : void 0,
|
|
1374
|
+
"aria-valuemin": 0,
|
|
1375
|
+
"aria-valuemax": 100,
|
|
1376
|
+
className: cn(
|
|
1377
|
+
"relative flex w-full flex-col justify-center",
|
|
1378
|
+
className
|
|
1379
|
+
),
|
|
1380
|
+
style: { height: svgHeight }
|
|
1381
|
+
}, restProps), {
|
|
1382
|
+
children: [
|
|
1383
|
+
isWavy ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1384
|
+
WavyLinearTrack,
|
|
1385
|
+
{
|
|
1386
|
+
trackHeight,
|
|
1387
|
+
svgHeight,
|
|
1388
|
+
amplitude: effectiveAmplitude,
|
|
1389
|
+
wavelength,
|
|
1390
|
+
indeterminateWavelength,
|
|
1391
|
+
activeColor,
|
|
1392
|
+
trackColor: bgTrackColor,
|
|
1393
|
+
value: isDeterminate ? clampedValue : void 0,
|
|
1394
|
+
isRtl,
|
|
1395
|
+
gapSize,
|
|
1396
|
+
waveSpeed,
|
|
1397
|
+
crawlerSpeed,
|
|
1398
|
+
determinateAnimation,
|
|
1399
|
+
indeterminateAnimation,
|
|
1400
|
+
trackShape: resolvedTrackShape
|
|
1401
|
+
}
|
|
1402
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1403
|
+
FlatLinearTrack,
|
|
1404
|
+
{
|
|
1405
|
+
trackHeight,
|
|
1406
|
+
activeColor,
|
|
1407
|
+
trackColor: bgTrackColor,
|
|
1408
|
+
value: isDeterminate ? clampedValue : void 0,
|
|
1409
|
+
isRtl,
|
|
1410
|
+
gapSize,
|
|
1411
|
+
crawlerSpeed
|
|
1412
|
+
}
|
|
1413
|
+
),
|
|
1414
|
+
shouldShowStop && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1415
|
+
"div",
|
|
1416
|
+
{
|
|
1417
|
+
"aria-hidden": "true",
|
|
1418
|
+
className: "absolute rounded-full",
|
|
1419
|
+
style: __spreadValues({
|
|
1420
|
+
width: stopSize,
|
|
1421
|
+
height: stopSize,
|
|
1422
|
+
backgroundColor: "var(--md-sys-color-indicator-stop)",
|
|
1423
|
+
top: svgHeight / 2 - stopSize / 2
|
|
1424
|
+
}, isRtl ? { left: stopOffset } : { right: stopOffset })
|
|
1425
|
+
}
|
|
1426
|
+
)
|
|
1427
|
+
]
|
|
1428
|
+
})
|
|
1429
|
+
) });
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
LinearProgress.displayName = "LinearProgress";
|
|
1433
|
+
var ProgressIndicator = React17__namespace.forwardRef((props, ref) => {
|
|
1434
|
+
if (props.variant === "circular") {
|
|
1435
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, __spreadValues({ ref }, props));
|
|
1436
|
+
}
|
|
1437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinearProgress, __spreadValues({ ref }, props));
|
|
1438
|
+
});
|
|
1439
|
+
ProgressIndicator.displayName = "ProgressIndicator";
|
|
1440
|
+
var RippleItem = React17__namespace.memo(function RippleItem2({
|
|
1441
|
+
ripple,
|
|
1442
|
+
onDone
|
|
1443
|
+
}) {
|
|
1444
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1445
|
+
react.m.span,
|
|
1446
|
+
{
|
|
1447
|
+
"aria-hidden": "true",
|
|
1448
|
+
style: {
|
|
1449
|
+
position: "absolute",
|
|
1450
|
+
left: ripple.x - ripple.size / 2,
|
|
1451
|
+
top: ripple.y - ripple.size / 2,
|
|
1452
|
+
width: ripple.size,
|
|
1453
|
+
height: ripple.size,
|
|
1454
|
+
borderRadius: "50%",
|
|
1455
|
+
backgroundColor: "currentColor",
|
|
1456
|
+
pointerEvents: "none",
|
|
1457
|
+
transformOrigin: "center"
|
|
1458
|
+
},
|
|
1459
|
+
initial: { scale: 0, opacity: 0.12 },
|
|
1460
|
+
animate: { scale: 1, opacity: 0 },
|
|
1461
|
+
exit: { opacity: 0 },
|
|
1462
|
+
transition: {
|
|
1463
|
+
scale: { duration: 0.5, ease: [0.2, 0, 0, 1] },
|
|
1464
|
+
opacity: { duration: 0.4, ease: "easeOut", delay: 0.1 }
|
|
1465
|
+
},
|
|
1466
|
+
onAnimationComplete: () => onDone(ripple.id)
|
|
1467
|
+
},
|
|
1468
|
+
ripple.id
|
|
1469
|
+
);
|
|
1470
|
+
});
|
|
1471
|
+
function Ripple({
|
|
1472
|
+
ripples,
|
|
1473
|
+
onRippleDone,
|
|
1474
|
+
disabled = false,
|
|
1475
|
+
respectSystemMotion = true
|
|
1476
|
+
}) {
|
|
1477
|
+
const prefersReduced = react.useReducedMotion();
|
|
1478
|
+
if (disabled) return null;
|
|
1479
|
+
if (respectSystemMotion && prefersReduced) return null;
|
|
1480
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { children: ripples.map((r) => /* @__PURE__ */ jsxRuntime.jsx(RippleItem, { ripple: r, onDone: onRippleDone }, r.id)) });
|
|
1481
|
+
}
|
|
1482
|
+
function useRippleState(options = {}) {
|
|
1483
|
+
const { disabled = false } = options;
|
|
1484
|
+
const [ripples, setRipples] = React17__namespace.useState([]);
|
|
1485
|
+
const onPointerDown = React17__namespace.useCallback(
|
|
1486
|
+
(e) => {
|
|
1487
|
+
if (disabled) return;
|
|
1488
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1489
|
+
const x = e.clientX - rect.left;
|
|
1490
|
+
const y = e.clientY - rect.top;
|
|
1491
|
+
const rippleSize = Math.hypot(rect.width, rect.height) * 2;
|
|
1492
|
+
setRipples((prev) => [
|
|
1493
|
+
...prev,
|
|
1494
|
+
{ id: Date.now(), x, y, size: rippleSize }
|
|
1495
|
+
]);
|
|
1496
|
+
},
|
|
1497
|
+
[disabled]
|
|
1498
|
+
);
|
|
1499
|
+
const removeRipple = React17__namespace.useCallback((id) => {
|
|
1500
|
+
setRipples((prev) => prev.filter((r) => r.id !== id));
|
|
1501
|
+
}, []);
|
|
1502
|
+
return { ripples, onPointerDown, removeRipple };
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// src/ui/shared/constants.ts
|
|
1506
|
+
var SPRING_TRANSITION_FAST = FAST_EFFECTS_SPRING;
|
|
1507
|
+
var SPRING_TRANSITION = DEFAULT_EFFECTS_SPRING;
|
|
1508
|
+
var ICON_SPAN_VARIANTS = {
|
|
1509
|
+
initial: { scale: 0.01 },
|
|
1510
|
+
animate: { scale: 1 },
|
|
1511
|
+
exit: { scale: 0.01 }
|
|
1512
|
+
};
|
|
1513
|
+
function TouchTarget() {
|
|
1514
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1515
|
+
"span",
|
|
1516
|
+
{
|
|
1517
|
+
"aria-hidden": "true",
|
|
1518
|
+
className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 min-w-12 min-h-12 cursor-pointer pointer-events-none"
|
|
1519
|
+
}
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
var SIZE_STYLES = {
|
|
1523
|
+
xs: "h-8 w-8",
|
|
1524
|
+
sm: "h-10 w-10",
|
|
1525
|
+
md: "h-14 w-14",
|
|
1526
|
+
lg: "h-24 w-24",
|
|
1527
|
+
xl: "h-[8.5rem] w-[8.5rem]"
|
|
1528
|
+
};
|
|
1529
|
+
var SIZE_ICON = {
|
|
1530
|
+
xs: { cls: "size-5", px: 20 },
|
|
1531
|
+
sm: { cls: "size-6", px: 24 },
|
|
1532
|
+
md: { cls: "size-6", px: 24 },
|
|
1533
|
+
lg: { cls: "size-8", px: 32 },
|
|
1534
|
+
xl: { cls: "size-10", px: 40 }
|
|
1535
|
+
};
|
|
1536
|
+
var RADIUS_MAP = {
|
|
1537
|
+
xs: {
|
|
1538
|
+
round: 16,
|
|
1539
|
+
square: 12,
|
|
1540
|
+
pressed: 8,
|
|
1541
|
+
selectedRound: 12,
|
|
1542
|
+
selectedSquare: 16
|
|
1543
|
+
},
|
|
1544
|
+
sm: {
|
|
1545
|
+
round: 20,
|
|
1546
|
+
square: 12,
|
|
1547
|
+
pressed: 8,
|
|
1548
|
+
selectedRound: 12,
|
|
1549
|
+
selectedSquare: 20
|
|
1550
|
+
},
|
|
1551
|
+
md: {
|
|
1552
|
+
round: 28,
|
|
1553
|
+
square: 16,
|
|
1554
|
+
pressed: 12,
|
|
1555
|
+
selectedRound: 16,
|
|
1556
|
+
selectedSquare: 28
|
|
1557
|
+
},
|
|
1558
|
+
lg: {
|
|
1559
|
+
round: 48,
|
|
1560
|
+
square: 28,
|
|
1561
|
+
pressed: 16,
|
|
1562
|
+
selectedRound: 28,
|
|
1563
|
+
selectedSquare: 48
|
|
1564
|
+
},
|
|
1565
|
+
xl: {
|
|
1566
|
+
round: 68,
|
|
1567
|
+
square: 28,
|
|
1568
|
+
pressed: 16,
|
|
1569
|
+
selectedRound: 28,
|
|
1570
|
+
selectedSquare: 68
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
var SIZE_OUTLINE_WIDTH = {
|
|
1574
|
+
xs: "border",
|
|
1575
|
+
sm: "border",
|
|
1576
|
+
md: "border",
|
|
1577
|
+
lg: "border-2",
|
|
1578
|
+
xl: "border-[3px]"
|
|
1579
|
+
};
|
|
1580
|
+
var colorStyles = {
|
|
1581
|
+
standard: {
|
|
1582
|
+
default: "text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1583
|
+
selected: "text-m3-primary hover:bg-m3-primary/8 active:bg-m3-primary/12"
|
|
1584
|
+
},
|
|
1585
|
+
filled: {
|
|
1586
|
+
default: "bg-m3-surface-container text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1587
|
+
selected: "bg-m3-primary text-m3-on-primary hover:brightness-95 active:brightness-90"
|
|
1588
|
+
},
|
|
1589
|
+
tonal: {
|
|
1590
|
+
default: "bg-m3-secondary-container text-m3-on-secondary-container hover:bg-m3-on-secondary-container/8 active:bg-m3-on-secondary-container/12",
|
|
1591
|
+
selected: "bg-m3-secondary text-m3-on-secondary hover:brightness-95 active:brightness-90"
|
|
1592
|
+
},
|
|
1593
|
+
outlined: {
|
|
1594
|
+
default: "border-m3-outline-variant text-m3-on-surface-variant hover:bg-m3-on-surface-variant/8 active:bg-m3-on-surface-variant/12",
|
|
1595
|
+
selected: "bg-m3-inverse-surface text-m3-inverse-on-surface border-transparent hover:brightness-95 active:brightness-90"
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
var baseIconButtonClasses = [
|
|
1599
|
+
"relative shrink-0 inline-flex items-center justify-center",
|
|
1600
|
+
"select-none cursor-pointer",
|
|
1601
|
+
"transition-[background-color,color,border-color,box-shadow,opacity,filter] duration-200",
|
|
1602
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-2",
|
|
1603
|
+
"disabled:pointer-events-none disabled:opacity-[0.38]"
|
|
1604
|
+
];
|
|
1605
|
+
function resolveAnimateRadius(radiusConfig, shape, isToggle, isSelected) {
|
|
1606
|
+
if (isToggle && isSelected) {
|
|
1607
|
+
return shape === "round" ? radiusConfig.selectedRound : radiusConfig.selectedSquare;
|
|
1608
|
+
}
|
|
1609
|
+
return shape === "round" ? radiusConfig.round : radiusConfig.square;
|
|
1610
|
+
}
|
|
1611
|
+
function resolveDisabledBgClass(colorStyle) {
|
|
1612
|
+
if (colorStyle === "filled" || colorStyle === "tonal") {
|
|
1613
|
+
return "disabled:bg-m3-on-surface/12 disabled:text-m3-on-surface/[0.38]";
|
|
1614
|
+
}
|
|
1615
|
+
if (colorStyle === "outlined") {
|
|
1616
|
+
return "disabled:text-m3-on-surface/[0.38] disabled:border-m3-on-surface/[0.12]";
|
|
1617
|
+
}
|
|
1618
|
+
return "disabled:text-m3-on-surface/[0.38]";
|
|
1619
|
+
}
|
|
1620
|
+
var IconButtonComponent = React17__namespace.forwardRef(
|
|
1621
|
+
(_a, ref) => {
|
|
1622
|
+
var _b = _a, {
|
|
1623
|
+
className,
|
|
1624
|
+
style,
|
|
1625
|
+
variant = "default",
|
|
1626
|
+
colorStyle = "standard",
|
|
1627
|
+
size = "sm",
|
|
1628
|
+
shape = "round",
|
|
1629
|
+
selected,
|
|
1630
|
+
loading = false,
|
|
1631
|
+
loadingVariant = "loading-indicator",
|
|
1632
|
+
iconSize,
|
|
1633
|
+
children,
|
|
1634
|
+
onClick,
|
|
1635
|
+
onKeyDown,
|
|
1636
|
+
"aria-label": ariaLabel
|
|
1637
|
+
} = _b, restProps = __objRest(_b, [
|
|
1638
|
+
"className",
|
|
1639
|
+
"style",
|
|
1640
|
+
"variant",
|
|
1641
|
+
"colorStyle",
|
|
1642
|
+
"size",
|
|
1643
|
+
"shape",
|
|
1644
|
+
"selected",
|
|
1645
|
+
"loading",
|
|
1646
|
+
"loadingVariant",
|
|
1647
|
+
"iconSize",
|
|
1648
|
+
"children",
|
|
1649
|
+
"onClick",
|
|
1650
|
+
"onKeyDown",
|
|
1651
|
+
"aria-label"
|
|
1652
|
+
]);
|
|
1653
|
+
var _a2, _b2;
|
|
1654
|
+
const isToggle = variant === "toggle";
|
|
1655
|
+
const isSelected = isToggle && !!selected;
|
|
1656
|
+
const resolvedColorClass = React17__namespace.useMemo(
|
|
1657
|
+
() => isSelected ? colorStyles[colorStyle].selected : colorStyles[colorStyle].default,
|
|
1658
|
+
[isSelected, colorStyle]
|
|
1659
|
+
);
|
|
1660
|
+
const outlineWidthClass = React17__namespace.useMemo(
|
|
1661
|
+
() => {
|
|
1662
|
+
var _a3;
|
|
1663
|
+
return colorStyle === "outlined" && !isSelected ? (_a3 = SIZE_OUTLINE_WIDTH[size]) != null ? _a3 : "border" : "";
|
|
1664
|
+
},
|
|
1665
|
+
[colorStyle, isSelected, size]
|
|
1666
|
+
);
|
|
1667
|
+
const disabledBgClass = React17__namespace.useMemo(
|
|
1668
|
+
() => resolveDisabledBgClass(colorStyle),
|
|
1669
|
+
[colorStyle]
|
|
1670
|
+
);
|
|
1671
|
+
const radiusConfig = (_a2 = RADIUS_MAP[size]) != null ? _a2 : RADIUS_MAP.sm;
|
|
1672
|
+
const animateRadius = resolveAnimateRadius(
|
|
1673
|
+
radiusConfig,
|
|
1674
|
+
shape,
|
|
1675
|
+
isToggle,
|
|
1676
|
+
isSelected
|
|
1677
|
+
);
|
|
1678
|
+
const pressedRadius = radiusConfig.pressed;
|
|
1679
|
+
const sizeIcon = (_b2 = SIZE_ICON[size]) != null ? _b2 : SIZE_ICON.sm;
|
|
1680
|
+
const iconClass = sizeIcon.cls;
|
|
1681
|
+
const defaultIconPx = sizeIcon.px;
|
|
1682
|
+
const iconPx = iconSize != null ? iconSize : defaultIconPx;
|
|
1683
|
+
const isCustomSize = iconSize != null && iconSize !== "inherit";
|
|
1684
|
+
const needsTouchTarget = size === "xs" || size === "sm";
|
|
1685
|
+
const { ripples, onPointerDown, removeRipple } = useRippleState({
|
|
1686
|
+
disabled: loading
|
|
1687
|
+
});
|
|
1688
|
+
const handleClick = React17__namespace.useCallback(
|
|
1689
|
+
(e) => {
|
|
1690
|
+
if (loading) {
|
|
1691
|
+
e.preventDefault();
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
onClick == null ? void 0 : onClick(e);
|
|
1695
|
+
},
|
|
1696
|
+
[loading, onClick]
|
|
1697
|
+
);
|
|
1698
|
+
const handleKeyDown = React17__namespace.useCallback(
|
|
1699
|
+
(e) => {
|
|
1700
|
+
if (loading) return;
|
|
1701
|
+
if ((e.key === "Enter" || e.key === " ") && onClick) {
|
|
1702
|
+
e.preventDefault();
|
|
1703
|
+
e.currentTarget.click();
|
|
1704
|
+
}
|
|
1705
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
1706
|
+
},
|
|
1707
|
+
[loading, onClick, onKeyDown]
|
|
1708
|
+
);
|
|
1709
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1710
|
+
react.m.button,
|
|
1711
|
+
__spreadProps(__spreadValues({
|
|
1712
|
+
ref,
|
|
1713
|
+
type: "button",
|
|
1714
|
+
"aria-pressed": isToggle ? isSelected : void 0,
|
|
1715
|
+
"aria-label": ariaLabel,
|
|
1716
|
+
"aria-busy": loading || void 0,
|
|
1717
|
+
"aria-disabled": loading || restProps.disabled,
|
|
1718
|
+
onClick: handleClick,
|
|
1719
|
+
onPointerDown,
|
|
1720
|
+
onKeyDown: handleKeyDown,
|
|
1721
|
+
style,
|
|
1722
|
+
animate: { borderRadius: animateRadius },
|
|
1723
|
+
whileTap: { borderRadius: pressedRadius },
|
|
1724
|
+
transition: { borderRadius: SPRING_TRANSITION_FAST },
|
|
1725
|
+
className: cn(
|
|
1726
|
+
baseIconButtonClasses,
|
|
1727
|
+
resolvedColorClass,
|
|
1728
|
+
outlineWidthClass,
|
|
1729
|
+
disabledBgClass,
|
|
1730
|
+
"overflow-hidden",
|
|
1731
|
+
SIZE_STYLES[size],
|
|
1732
|
+
loading && "pointer-events-none opacity-75 cursor-not-allowed",
|
|
1733
|
+
className
|
|
1734
|
+
)
|
|
1735
|
+
}, restProps), {
|
|
1736
|
+
children: [
|
|
1737
|
+
needsTouchTarget && /* @__PURE__ */ jsxRuntime.jsx(TouchTarget, {}),
|
|
1738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Ripple, { ripples, onRippleDone: removeRipple }),
|
|
1739
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "wait", initial: false, children: loading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1740
|
+
react.m.span,
|
|
1741
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
1742
|
+
transition: SPRING_TRANSITION,
|
|
1743
|
+
className: cn(
|
|
1744
|
+
"flex items-center justify-center shrink-0",
|
|
1745
|
+
iconSize != null ? void 0 : iconClass
|
|
1746
|
+
),
|
|
1747
|
+
style: isCustomSize ? { width: `${iconSize}px`, height: `${iconSize}px` } : void 0,
|
|
1748
|
+
children: loadingVariant === "loading-indicator" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1749
|
+
LoadingIndicator,
|
|
1750
|
+
{
|
|
1751
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
1752
|
+
color: "currentColor",
|
|
1753
|
+
"aria-label": "Loading"
|
|
1754
|
+
}
|
|
1755
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1756
|
+
ProgressIndicator,
|
|
1757
|
+
{
|
|
1758
|
+
variant: "circular",
|
|
1759
|
+
size: typeof iconPx === "number" ? iconPx : defaultIconPx,
|
|
1760
|
+
color: "currentColor",
|
|
1761
|
+
trackColor: "transparent",
|
|
1762
|
+
"aria-label": "Loading"
|
|
1763
|
+
}
|
|
1764
|
+
)
|
|
1765
|
+
}),
|
|
1766
|
+
"loading"
|
|
1767
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1768
|
+
react.m.span,
|
|
1769
|
+
__spreadProps(__spreadValues({}, ICON_SPAN_VARIANTS), {
|
|
1770
|
+
transition: SPRING_TRANSITION,
|
|
1771
|
+
"aria-hidden": "true",
|
|
1772
|
+
className: cn(
|
|
1773
|
+
"flex items-center justify-center shrink-0 [&_svg]:w-full [&_svg]:h-full [&_.md-icon]:text-[length:inherit]!",
|
|
1774
|
+
iconSize != null ? void 0 : iconClass
|
|
1775
|
+
),
|
|
1776
|
+
style: {
|
|
1777
|
+
fontSize: typeof iconPx === "number" ? `${iconPx}px` : iconPx,
|
|
1778
|
+
width: isCustomSize ? `${iconSize}px` : void 0,
|
|
1779
|
+
height: isCustomSize ? `${iconSize}px` : void 0
|
|
1780
|
+
},
|
|
1781
|
+
children
|
|
1782
|
+
}),
|
|
1783
|
+
"content"
|
|
1784
|
+
) })
|
|
1785
|
+
]
|
|
1786
|
+
})
|
|
1787
|
+
) });
|
|
1788
|
+
}
|
|
1789
|
+
);
|
|
1790
|
+
IconButtonComponent.displayName = "IconButton";
|
|
1791
|
+
var IconButton = React17__namespace.memo(IconButtonComponent);
|
|
1792
|
+
var VARIANT_FONT = {
|
|
1793
|
+
outlined: "'Material Symbols Outlined'",
|
|
1794
|
+
rounded: "'Material Symbols Rounded'",
|
|
1795
|
+
sharp: "'Material Symbols Sharp'"
|
|
1796
|
+
};
|
|
1797
|
+
var IconComponent = React17__namespace.forwardRef(
|
|
1798
|
+
(_a, ref) => {
|
|
1799
|
+
var _b = _a, {
|
|
1800
|
+
name,
|
|
1801
|
+
variant = "outlined",
|
|
1802
|
+
fill = 0,
|
|
1803
|
+
weight = 400,
|
|
1804
|
+
grade = 0,
|
|
1805
|
+
opticalSize = 24,
|
|
1806
|
+
size,
|
|
1807
|
+
animateFill = false,
|
|
1808
|
+
className,
|
|
1809
|
+
style
|
|
1810
|
+
} = _b, restProps = __objRest(_b, [
|
|
1811
|
+
"name",
|
|
1812
|
+
"variant",
|
|
1813
|
+
"fill",
|
|
1814
|
+
"weight",
|
|
1815
|
+
"grade",
|
|
1816
|
+
"opticalSize",
|
|
1817
|
+
"size",
|
|
1818
|
+
"animateFill",
|
|
1819
|
+
"className",
|
|
1820
|
+
"style"
|
|
1821
|
+
]);
|
|
1822
|
+
const fontVariationSettings = `'FILL' ${fill}, 'wght' ${weight}, 'GRAD' ${grade}, 'opsz' ${opticalSize}`;
|
|
1823
|
+
const computedStyle = __spreadValues({
|
|
1824
|
+
fontFamily: VARIANT_FONT[variant],
|
|
1825
|
+
fontSize: size === "inherit" ? "inherit" : size != null ? `${size}px` : `${opticalSize}px`,
|
|
1826
|
+
fontVariationSettings
|
|
1827
|
+
}, style);
|
|
1828
|
+
if (animateFill) {
|
|
1829
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domMax, strict: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1830
|
+
react.m.span,
|
|
1831
|
+
__spreadProps(__spreadValues({
|
|
1832
|
+
ref,
|
|
1833
|
+
className: cn(
|
|
1834
|
+
"md-icon inline-flex items-center justify-center shrink-0 select-none",
|
|
1835
|
+
className
|
|
1836
|
+
),
|
|
1837
|
+
"aria-hidden": "true",
|
|
1838
|
+
animate: { fontVariationSettings },
|
|
1839
|
+
transition: SPRING_TRANSITION_FAST,
|
|
1840
|
+
style: computedStyle
|
|
1841
|
+
}, restProps), {
|
|
1842
|
+
children: name
|
|
1843
|
+
})
|
|
1844
|
+
) });
|
|
1845
|
+
}
|
|
1846
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1847
|
+
"span",
|
|
1848
|
+
__spreadProps(__spreadValues({
|
|
1849
|
+
ref,
|
|
1850
|
+
className: cn(
|
|
1851
|
+
"md-icon inline-flex items-center justify-center shrink-0 select-none",
|
|
1852
|
+
className
|
|
1853
|
+
),
|
|
1854
|
+
"aria-hidden": "true",
|
|
1855
|
+
style: computedStyle
|
|
1856
|
+
}, restProps), {
|
|
1857
|
+
children: name
|
|
1858
|
+
})
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1861
|
+
);
|
|
1862
|
+
IconComponent.displayName = "Icon";
|
|
1863
|
+
var Icon = React17__namespace.memo(IconComponent);
|
|
1864
|
+
var selectorClassName = "flex items-center gap-1 rounded-m3-full px-2 py-1 text-[length:var(--md-typescale-title-small-size,14px)] font-[number:var(--md-typescale-title-small-weight,500)] text-m3-on-surface transition-m3-fast-effects hover:bg-m3-on-surface/8 focus-visible:outline-2 focus-visible:outline-m3-primary";
|
|
1865
|
+
var CalendarHeader = ({
|
|
1866
|
+
displayedMonthMs,
|
|
1867
|
+
activeSelector,
|
|
1868
|
+
displayMode,
|
|
1869
|
+
showModeToggle,
|
|
1870
|
+
title,
|
|
1871
|
+
headline,
|
|
1872
|
+
locale,
|
|
1873
|
+
canNavigatePrev,
|
|
1874
|
+
canNavigateNext,
|
|
1875
|
+
canNavigatePreviousYear,
|
|
1876
|
+
canNavigateNextYear,
|
|
1877
|
+
onPrev,
|
|
1878
|
+
onNext,
|
|
1879
|
+
onPreviousYear,
|
|
1880
|
+
onNextYear,
|
|
1881
|
+
onToggleSelector,
|
|
1882
|
+
onToggleMode
|
|
1883
|
+
}) => {
|
|
1884
|
+
const date = new Date(displayedMonthMs);
|
|
1885
|
+
const monthLabel = new Intl.DateTimeFormat(locale.locale, {
|
|
1886
|
+
month: "short",
|
|
1887
|
+
timeZone: "UTC"
|
|
1888
|
+
}).format(date);
|
|
1889
|
+
const yearLabel = String(date.getUTCFullYear());
|
|
1890
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 px-6 pb-4 pt-5", children: [
|
|
1891
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[length:var(--md-typescale-label-large-size,14px)] font-[number:var(--md-typescale-label-large-weight,500)] text-m3-on-surface-variant", children: title }),
|
|
1892
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 leading-tight text-[length:var(--md-typescale-headline-large-size,32px)] font-[number:var(--md-typescale-headline-large-weight,400)] text-m3-on-surface-variant", children: headline }),
|
|
1893
|
+
displayMode === "picker" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "-mx-2 flex min-h-10 items-center gap-0.5", children: [
|
|
1894
|
+
activeSelector === null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1895
|
+
IconButton,
|
|
1896
|
+
{
|
|
1897
|
+
onClick: onPrev,
|
|
1898
|
+
"aria-label": "Previous month",
|
|
1899
|
+
disabled: !canNavigatePrev,
|
|
1900
|
+
size: "sm",
|
|
1901
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "chevron_left" })
|
|
1902
|
+
}
|
|
1903
|
+
),
|
|
1904
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1905
|
+
"button",
|
|
1906
|
+
{
|
|
1907
|
+
type: "button",
|
|
1908
|
+
onClick: () => onToggleSelector("month"),
|
|
1909
|
+
"aria-expanded": activeSelector === "month",
|
|
1910
|
+
"aria-controls": "date-picker-selection",
|
|
1911
|
+
className: cn(
|
|
1912
|
+
selectorClassName,
|
|
1913
|
+
activeSelector === "month" && "bg-m3-on-surface/8"
|
|
1914
|
+
),
|
|
1915
|
+
children: [
|
|
1916
|
+
monthLabel,
|
|
1917
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1918
|
+
Icon,
|
|
1919
|
+
{
|
|
1920
|
+
name: "arrow_drop_down",
|
|
1921
|
+
className: cn(
|
|
1922
|
+
"text-[20px]",
|
|
1923
|
+
activeSelector === "month" && "rotate-180"
|
|
1924
|
+
)
|
|
1925
|
+
}
|
|
1926
|
+
)
|
|
1927
|
+
]
|
|
1928
|
+
}
|
|
1929
|
+
),
|
|
1930
|
+
activeSelector === null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1931
|
+
IconButton,
|
|
1932
|
+
{
|
|
1933
|
+
onClick: onNext,
|
|
1934
|
+
"aria-label": "Next month",
|
|
1935
|
+
disabled: !canNavigateNext,
|
|
1936
|
+
size: "sm",
|
|
1937
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "chevron_right" })
|
|
1938
|
+
}
|
|
1939
|
+
),
|
|
1940
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-0.5", children: [
|
|
1941
|
+
activeSelector === null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1942
|
+
IconButton,
|
|
1943
|
+
{
|
|
1944
|
+
onClick: onPreviousYear,
|
|
1945
|
+
"aria-label": "Previous year",
|
|
1946
|
+
disabled: !canNavigatePreviousYear,
|
|
1947
|
+
size: "sm",
|
|
1948
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "chevron_left" })
|
|
1949
|
+
}
|
|
1950
|
+
),
|
|
1951
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1952
|
+
"button",
|
|
1953
|
+
{
|
|
1954
|
+
type: "button",
|
|
1955
|
+
onClick: () => onToggleSelector("year"),
|
|
1956
|
+
"aria-expanded": activeSelector === "year",
|
|
1957
|
+
"aria-controls": "date-picker-selection",
|
|
1958
|
+
className: cn(
|
|
1959
|
+
selectorClassName,
|
|
1960
|
+
activeSelector === "year" && "bg-m3-on-surface/8"
|
|
1961
|
+
),
|
|
1962
|
+
children: [
|
|
1963
|
+
yearLabel,
|
|
1964
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1965
|
+
Icon,
|
|
1966
|
+
{
|
|
1967
|
+
name: "arrow_drop_down",
|
|
1968
|
+
className: cn(
|
|
1969
|
+
"text-[20px]",
|
|
1970
|
+
activeSelector === "year" && "rotate-180"
|
|
1971
|
+
)
|
|
1972
|
+
}
|
|
1973
|
+
)
|
|
1974
|
+
]
|
|
1975
|
+
}
|
|
1976
|
+
),
|
|
1977
|
+
activeSelector === null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1978
|
+
IconButton,
|
|
1979
|
+
{
|
|
1980
|
+
onClick: onNextYear,
|
|
1981
|
+
"aria-label": "Next year",
|
|
1982
|
+
disabled: !canNavigateNextYear,
|
|
1983
|
+
size: "sm",
|
|
1984
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "chevron_right" })
|
|
1985
|
+
}
|
|
1986
|
+
),
|
|
1987
|
+
showModeToggle && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1988
|
+
IconButton,
|
|
1989
|
+
{
|
|
1990
|
+
onClick: onToggleMode,
|
|
1991
|
+
"aria-label": "Switch to text input",
|
|
1992
|
+
size: "sm",
|
|
1993
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "keyboard" })
|
|
1994
|
+
}
|
|
1995
|
+
)
|
|
1996
|
+
] })
|
|
1997
|
+
] }),
|
|
1998
|
+
displayMode === "input" && showModeToggle && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1999
|
+
IconButton,
|
|
2000
|
+
{
|
|
2001
|
+
onClick: onToggleMode,
|
|
2002
|
+
"aria-label": "Switch to calendar",
|
|
2003
|
+
size: "sm",
|
|
2004
|
+
className: "self-end",
|
|
2005
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "calendar_month" })
|
|
2006
|
+
}
|
|
2007
|
+
),
|
|
2008
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: formatMonthYear(displayedMonthMs, locale) })
|
|
2009
|
+
] });
|
|
2010
|
+
};
|
|
2011
|
+
CalendarHeader.displayName = "CalendarHeader";
|
|
2012
|
+
var getMonthLabel = (month, locale) => new Intl.DateTimeFormat(locale, {
|
|
2013
|
+
month: "long",
|
|
2014
|
+
timeZone: "UTC"
|
|
2015
|
+
}).format(new Date(Date.UTC(2025, month, 1)));
|
|
2016
|
+
var MonthPickerList = ({
|
|
2017
|
+
selectedMonth,
|
|
2018
|
+
locale,
|
|
2019
|
+
onMonthSelect
|
|
2020
|
+
}) => {
|
|
2021
|
+
const selectedRef = React17__namespace.useRef(null);
|
|
2022
|
+
React17__namespace.useEffect(() => {
|
|
2023
|
+
var _a, _b;
|
|
2024
|
+
(_b = (_a = selectedRef.current) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, {
|
|
2025
|
+
block: "center",
|
|
2026
|
+
behavior: "instant"
|
|
2027
|
+
});
|
|
2028
|
+
}, []);
|
|
2029
|
+
const months = React17__namespace.useMemo(
|
|
2030
|
+
() => Array.from({ length: 12 }, (_, month) => month),
|
|
2031
|
+
[]
|
|
2032
|
+
);
|
|
2033
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2034
|
+
"div",
|
|
2035
|
+
{
|
|
2036
|
+
className: "h-full min-h-[240px] overflow-y-auto py-2",
|
|
2037
|
+
role: "listbox",
|
|
2038
|
+
"aria-label": "Select month",
|
|
2039
|
+
children: months.map((month) => {
|
|
2040
|
+
const isSelected = month === selectedMonth;
|
|
2041
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2042
|
+
"button",
|
|
2043
|
+
{
|
|
2044
|
+
ref: isSelected ? selectedRef : void 0,
|
|
2045
|
+
type: "button",
|
|
2046
|
+
role: "option",
|
|
2047
|
+
"aria-selected": isSelected,
|
|
2048
|
+
onClick: () => onMonthSelect(month),
|
|
2049
|
+
className: cn(
|
|
2050
|
+
"flex min-h-12 w-full items-center gap-4 px-6 text-left",
|
|
2051
|
+
"text-[length:var(--md-typescale-body-large-size,16px)]",
|
|
2052
|
+
"text-m3-on-surface transition-m3-fast-effects",
|
|
2053
|
+
"hover:bg-m3-on-surface/8 focus-visible:outline-2 focus-visible:outline-m3-primary",
|
|
2054
|
+
isSelected && "bg-m3-secondary-container text-m3-on-secondary-container"
|
|
2055
|
+
),
|
|
2056
|
+
children: [
|
|
2057
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-6", "aria-hidden": true, children: isSelected && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "check", className: "text-[20px]" }) }),
|
|
2058
|
+
getMonthLabel(month, locale.locale)
|
|
2059
|
+
]
|
|
2060
|
+
},
|
|
2061
|
+
month
|
|
2062
|
+
);
|
|
2063
|
+
})
|
|
2064
|
+
}
|
|
2065
|
+
);
|
|
2066
|
+
};
|
|
2067
|
+
MonthPickerList.displayName = "MonthPickerList";
|
|
2068
|
+
var YearPickerList = ({
|
|
2069
|
+
selectedYear,
|
|
2070
|
+
yearRange,
|
|
2071
|
+
selectableDates,
|
|
2072
|
+
onYearSelect
|
|
2073
|
+
}) => {
|
|
2074
|
+
const selectedRef = React17__namespace.useRef(null);
|
|
2075
|
+
const years = React17__namespace.useMemo(() => {
|
|
2076
|
+
const [min, max] = yearRange;
|
|
2077
|
+
return Array.from({ length: max - min + 1 }, (_, index) => min + index);
|
|
2078
|
+
}, [yearRange]);
|
|
2079
|
+
React17__namespace.useEffect(() => {
|
|
2080
|
+
var _a, _b;
|
|
2081
|
+
(_b = (_a = selectedRef.current) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, {
|
|
2082
|
+
block: "center",
|
|
2083
|
+
behavior: "instant"
|
|
2084
|
+
});
|
|
2085
|
+
}, []);
|
|
2086
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2087
|
+
"div",
|
|
2088
|
+
{
|
|
2089
|
+
className: "h-full min-h-[240px] overflow-y-auto py-2",
|
|
2090
|
+
role: "listbox",
|
|
2091
|
+
"aria-label": "Select year",
|
|
2092
|
+
children: years.map((year) => {
|
|
2093
|
+
const isSelected = year === selectedYear;
|
|
2094
|
+
const isSelectable = isYearSelectable(year, selectableDates);
|
|
2095
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2096
|
+
"button",
|
|
2097
|
+
{
|
|
2098
|
+
ref: isSelected ? selectedRef : void 0,
|
|
2099
|
+
type: "button",
|
|
2100
|
+
role: "option",
|
|
2101
|
+
"aria-selected": isSelected,
|
|
2102
|
+
"aria-disabled": !isSelectable || void 0,
|
|
2103
|
+
disabled: !isSelectable,
|
|
2104
|
+
onClick: () => onYearSelect(year),
|
|
2105
|
+
className: cn(
|
|
2106
|
+
"flex min-h-12 w-full items-center gap-4 px-6 text-left",
|
|
2107
|
+
"text-[length:var(--md-typescale-body-large-size,16px)]",
|
|
2108
|
+
"text-m3-on-surface transition-m3-fast-effects",
|
|
2109
|
+
"hover:bg-m3-on-surface/8 focus-visible:outline-2 focus-visible:outline-m3-primary",
|
|
2110
|
+
isSelected && "bg-m3-secondary-container text-m3-on-secondary-container",
|
|
2111
|
+
!isSelectable && "cursor-not-allowed opacity-[0.38]"
|
|
2112
|
+
),
|
|
2113
|
+
children: [
|
|
2114
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-6", "aria-hidden": true, children: isSelected && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "check", className: "text-[20px]" }) }),
|
|
2115
|
+
year
|
|
2116
|
+
]
|
|
2117
|
+
},
|
|
2118
|
+
year
|
|
2119
|
+
);
|
|
2120
|
+
})
|
|
2121
|
+
}
|
|
2122
|
+
);
|
|
2123
|
+
};
|
|
2124
|
+
YearPickerList.displayName = "YearPickerList";
|
|
2125
|
+
var formatInputDate = (ms) => new Intl.DateTimeFormat("en-US", {
|
|
2126
|
+
month: "2-digit",
|
|
2127
|
+
day: "2-digit",
|
|
2128
|
+
year: "numeric",
|
|
2129
|
+
timeZone: "UTC"
|
|
2130
|
+
}).format(new Date(ms));
|
|
2131
|
+
var DatePicker = ({
|
|
2132
|
+
state,
|
|
2133
|
+
showModeToggle = true,
|
|
2134
|
+
title,
|
|
2135
|
+
headline,
|
|
2136
|
+
className
|
|
2137
|
+
}) => {
|
|
2138
|
+
const {
|
|
2139
|
+
selectedDateMs,
|
|
2140
|
+
displayedMonthMs,
|
|
2141
|
+
displayMode,
|
|
2142
|
+
yearRange,
|
|
2143
|
+
locale,
|
|
2144
|
+
selectableDates,
|
|
2145
|
+
selectDate,
|
|
2146
|
+
navigateMonth: navigateMonth2,
|
|
2147
|
+
navigateToMonth,
|
|
2148
|
+
setDisplayMode
|
|
2149
|
+
} = state;
|
|
2150
|
+
const [activeSelector, setActiveSelector] = React17__namespace.useState(null);
|
|
2151
|
+
const [slideDirection, setSlideDirection] = React17__namespace.useState(null);
|
|
2152
|
+
const handlePrev = React17__namespace.useCallback(() => {
|
|
2153
|
+
setSlideDirection("prev");
|
|
2154
|
+
navigateMonth2("prev");
|
|
2155
|
+
}, [navigateMonth2]);
|
|
2156
|
+
const handleNext = React17__namespace.useCallback(() => {
|
|
2157
|
+
setSlideDirection("next");
|
|
2158
|
+
navigateMonth2("next");
|
|
2159
|
+
}, [navigateMonth2]);
|
|
2160
|
+
const handleYearSelect = React17__namespace.useCallback(
|
|
2161
|
+
(year) => {
|
|
2162
|
+
const d = new Date(displayedMonthMs);
|
|
2163
|
+
navigateToMonth(year, d.getUTCMonth());
|
|
2164
|
+
setActiveSelector(null);
|
|
2165
|
+
},
|
|
2166
|
+
[displayedMonthMs, navigateToMonth]
|
|
2167
|
+
);
|
|
2168
|
+
const handleMonthSelect = React17__namespace.useCallback(
|
|
2169
|
+
(month) => {
|
|
2170
|
+
const d = new Date(displayedMonthMs);
|
|
2171
|
+
navigateToMonth(d.getUTCFullYear(), month);
|
|
2172
|
+
setActiveSelector(null);
|
|
2173
|
+
},
|
|
2174
|
+
[displayedMonthMs, navigateToMonth]
|
|
2175
|
+
);
|
|
2176
|
+
const [inputValue, setInputValue] = React17__namespace.useState(
|
|
2177
|
+
() => selectedDateMs !== null ? formatInputDate(selectedDateMs) : ""
|
|
2178
|
+
);
|
|
2179
|
+
const [inputError, setInputError] = React17__namespace.useState();
|
|
2180
|
+
const handleInputCommit = React17__namespace.useCallback(
|
|
2181
|
+
(ms) => {
|
|
2182
|
+
if (ms === null && inputValue.length > 0) {
|
|
2183
|
+
setInputError("Invalid date");
|
|
2184
|
+
} else {
|
|
2185
|
+
setInputError(void 0);
|
|
2186
|
+
selectDate(ms);
|
|
2187
|
+
}
|
|
2188
|
+
},
|
|
2189
|
+
[inputValue, selectDate]
|
|
2190
|
+
);
|
|
2191
|
+
const resolvedTitle = title != null ? title : "Select date";
|
|
2192
|
+
const resolvedHeadline = headline != null ? headline : selectedDateMs !== null ? formatDate(selectedDateMs, locale, {
|
|
2193
|
+
weekday: "short",
|
|
2194
|
+
month: "short",
|
|
2195
|
+
day: "numeric",
|
|
2196
|
+
timeZone: "UTC"
|
|
2197
|
+
}) : "\u2014";
|
|
2198
|
+
const currentYear = new Date(displayedMonthMs).getUTCFullYear();
|
|
2199
|
+
const currentMonth = new Date(displayedMonthMs).getUTCMonth();
|
|
2200
|
+
const computedAriaLabel = typeof resolvedTitle === "string" ? resolvedTitle : "Date picker";
|
|
2201
|
+
const canNavigatePrev = getNavigableMonth(displayedMonthMs, "prev", yearRange, selectableDates) !== null;
|
|
2202
|
+
const canNavigateNext = getNavigableMonth(displayedMonthMs, "next", yearRange, selectableDates) !== null;
|
|
2203
|
+
const canNavigatePreviousYear = isMonthNavigable(
|
|
2204
|
+
currentYear - 1,
|
|
2205
|
+
yearRange,
|
|
2206
|
+
selectableDates
|
|
2207
|
+
);
|
|
2208
|
+
const canNavigateNextYear = isMonthNavigable(
|
|
2209
|
+
currentYear + 1,
|
|
2210
|
+
yearRange,
|
|
2211
|
+
selectableDates
|
|
2212
|
+
);
|
|
2213
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2214
|
+
"fieldset",
|
|
2215
|
+
{
|
|
2216
|
+
className: cn("flex flex-col select-none", className),
|
|
2217
|
+
style: { width: "min(100%, 360px)" },
|
|
2218
|
+
"aria-label": computedAriaLabel,
|
|
2219
|
+
children: [
|
|
2220
|
+
/* @__PURE__ */ jsxRuntime.jsx("legend", { className: "sr-only", children: computedAriaLabel }),
|
|
2221
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2222
|
+
CalendarHeader,
|
|
2223
|
+
{
|
|
2224
|
+
displayedMonthMs,
|
|
2225
|
+
activeSelector,
|
|
2226
|
+
displayMode,
|
|
2227
|
+
showModeToggle,
|
|
2228
|
+
title: resolvedTitle,
|
|
2229
|
+
headline: resolvedHeadline,
|
|
2230
|
+
locale,
|
|
2231
|
+
canNavigatePrev,
|
|
2232
|
+
canNavigateNext,
|
|
2233
|
+
canNavigatePreviousYear,
|
|
2234
|
+
canNavigateNextYear,
|
|
2235
|
+
onPrev: handlePrev,
|
|
2236
|
+
onNext: handleNext,
|
|
2237
|
+
onPreviousYear: () => navigateToMonth(currentYear - 1, currentMonth),
|
|
2238
|
+
onNextYear: () => navigateToMonth(currentYear + 1, currentMonth),
|
|
2239
|
+
onToggleSelector: (selector) => setActiveSelector((active) => active === selector ? null : selector),
|
|
2240
|
+
onToggleMode: () => {
|
|
2241
|
+
setDisplayMode(displayMode === "picker" ? "input" : "picker");
|
|
2242
|
+
setActiveSelector(null);
|
|
2243
|
+
setInputError(void 0);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
),
|
|
2247
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2248
|
+
"div",
|
|
2249
|
+
{
|
|
2250
|
+
className: "relative flex-1 overflow-hidden",
|
|
2251
|
+
style: { minHeight: "296px" },
|
|
2252
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "wait", children: displayMode === "input" ? (
|
|
2253
|
+
// Input mode
|
|
2254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2255
|
+
DatePickerInput,
|
|
2256
|
+
{
|
|
2257
|
+
value: inputValue,
|
|
2258
|
+
onChange: setInputValue,
|
|
2259
|
+
onCommit: handleInputCommit,
|
|
2260
|
+
error: inputError,
|
|
2261
|
+
locale: locale.locale
|
|
2262
|
+
},
|
|
2263
|
+
"input-mode"
|
|
2264
|
+
)
|
|
2265
|
+
) : activeSelector === "month" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2266
|
+
"div",
|
|
2267
|
+
{
|
|
2268
|
+
id: "date-picker-selection",
|
|
2269
|
+
className: "absolute inset-0",
|
|
2270
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2271
|
+
MonthPickerList,
|
|
2272
|
+
{
|
|
2273
|
+
selectedMonth: currentMonth,
|
|
2274
|
+
locale,
|
|
2275
|
+
onMonthSelect: handleMonthSelect
|
|
2276
|
+
}
|
|
2277
|
+
)
|
|
2278
|
+
},
|
|
2279
|
+
"month-list"
|
|
2280
|
+
) : activeSelector === "year" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2281
|
+
"div",
|
|
2282
|
+
{
|
|
2283
|
+
id: "date-picker-selection",
|
|
2284
|
+
className: "absolute inset-0",
|
|
2285
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2286
|
+
YearPickerList,
|
|
2287
|
+
{
|
|
2288
|
+
selectedYear: currentYear,
|
|
2289
|
+
yearRange,
|
|
2290
|
+
selectableDates,
|
|
2291
|
+
onYearSelect: handleYearSelect
|
|
2292
|
+
}
|
|
2293
|
+
)
|
|
2294
|
+
},
|
|
2295
|
+
"year-list"
|
|
2296
|
+
) : (
|
|
2297
|
+
// Calendar grid
|
|
2298
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2299
|
+
CalendarGrid,
|
|
2300
|
+
{
|
|
2301
|
+
displayedMonthMs,
|
|
2302
|
+
slideDirection,
|
|
2303
|
+
locale,
|
|
2304
|
+
selectableDates,
|
|
2305
|
+
selectedMs: selectedDateMs,
|
|
2306
|
+
isRangePicker: false,
|
|
2307
|
+
onDaySelect: (ms) => {
|
|
2308
|
+
selectDate(ms);
|
|
2309
|
+
setInputValue(formatInputDate(ms));
|
|
2310
|
+
}
|
|
2311
|
+
},
|
|
2312
|
+
"calendar"
|
|
2313
|
+
)
|
|
2314
|
+
) })
|
|
2315
|
+
}
|
|
2316
|
+
)
|
|
2317
|
+
]
|
|
2318
|
+
}
|
|
2319
|
+
);
|
|
2320
|
+
};
|
|
2321
|
+
DatePicker.displayName = "DatePicker";
|
|
2322
|
+
|
|
2323
|
+
// src/ui/date-time-pickers/date-picker/date-picker.tokens.ts
|
|
2324
|
+
var DP_COLORS = {
|
|
2325
|
+
/** Dialog container — SurfaceContainerHigh */
|
|
2326
|
+
container: "var(--md-sys-color-surface-container-high)",
|
|
2327
|
+
/** Selected day background — Primary */
|
|
2328
|
+
daySelected: "var(--md-sys-color-primary)",
|
|
2329
|
+
/** Selected day text — OnPrimary */
|
|
2330
|
+
daySelectedText: "var(--md-sys-color-on-primary)",
|
|
2331
|
+
/** Today outline — Primary */
|
|
2332
|
+
todayOutline: "var(--md-sys-color-primary)",
|
|
2333
|
+
/** Today text — Primary */
|
|
2334
|
+
todayText: "var(--md-sys-color-primary)",
|
|
2335
|
+
/** Unselected day text — OnSurface */
|
|
2336
|
+
dayText: "var(--md-sys-color-on-surface)",
|
|
2337
|
+
/** Weekday header text — OnSurface */
|
|
2338
|
+
weekdayText: "var(--md-sys-color-on-surface)",
|
|
2339
|
+
/** Header headline + supporting text — OnSurfaceVariant */
|
|
2340
|
+
headerText: "var(--md-sys-color-on-surface-variant)",
|
|
2341
|
+
/** Range highlight background — SecondaryContainer */
|
|
2342
|
+
rangeHighlight: "var(--md-sys-color-secondary-container)",
|
|
2343
|
+
/** Range highlight text — OnSecondaryContainer */
|
|
2344
|
+
rangeText: "var(--md-sys-color-on-secondary-container)",
|
|
2345
|
+
/** Unselected year text — OnSurfaceVariant */
|
|
2346
|
+
yearText: "var(--md-sys-color-on-surface-variant)",
|
|
2347
|
+
/** Selected year background — Primary */
|
|
2348
|
+
yearSelected: "var(--md-sys-color-primary)",
|
|
2349
|
+
/** Selected year text — OnPrimary */
|
|
2350
|
+
yearSelectedText: "var(--md-sys-color-on-primary)",
|
|
2351
|
+
/** Scrim overlay */
|
|
2352
|
+
scrim: "var(--md-sys-color-scrim)"
|
|
2353
|
+
};
|
|
2354
|
+
var DP_SHAPE = {
|
|
2355
|
+
/** Dialog container — CornerExtraLarge = 28px */
|
|
2356
|
+
container: "var(--md-sys-shape-corner-extra-large)",
|
|
2357
|
+
/** Day cell — CornerFull = pill */
|
|
2358
|
+
day: "var(--md-sys-shape-corner-full)",
|
|
2359
|
+
/** Range start/end indicator — CornerFull */
|
|
2360
|
+
rangeEndpoint: "var(--md-sys-shape-corner-full)",
|
|
2361
|
+
/** Year chip — CornerFull */
|
|
2362
|
+
year: "var(--md-sys-shape-corner-full)"
|
|
2363
|
+
};
|
|
2364
|
+
var DP_SIZE = {
|
|
2365
|
+
/** Dialog container width */
|
|
2366
|
+
containerWidth: 360,
|
|
2367
|
+
/** Dialog container height */
|
|
2368
|
+
containerHeight: 568,
|
|
2369
|
+
/** Day cell width/height */
|
|
2370
|
+
dayCell: 40,
|
|
2371
|
+
/** Today border width */
|
|
2372
|
+
todayOutlineWidth: 1,
|
|
2373
|
+
/** Header container height */
|
|
2374
|
+
headerHeight: 120,
|
|
2375
|
+
/** Range picker header height */
|
|
2376
|
+
rangeHeaderHeight: 128,
|
|
2377
|
+
/** Year chip height */
|
|
2378
|
+
yearChipHeight: 36,
|
|
2379
|
+
/** Year chip width */
|
|
2380
|
+
yearChipWidth: 72
|
|
2381
|
+
};
|
|
2382
|
+
var DP_CLASSES = {
|
|
2383
|
+
/** Dialog container */
|
|
2384
|
+
dialog: [
|
|
2385
|
+
"bg-m3-surface-container-high",
|
|
2386
|
+
"rounded-m3-xl",
|
|
2387
|
+
"w-[360px]",
|
|
2388
|
+
"overflow-hidden",
|
|
2389
|
+
"elevation-3"
|
|
2390
|
+
].join(" "),
|
|
2391
|
+
/** Day cell container */
|
|
2392
|
+
dayCell: [
|
|
2393
|
+
"relative flex items-center justify-center",
|
|
2394
|
+
"w-10 h-10 rounded-m3-full",
|
|
2395
|
+
"text-[length:var(--md-typescale-body-large-size,14px)]",
|
|
2396
|
+
"font-[var(--md-typescale-body-large-weight,400)]",
|
|
2397
|
+
"cursor-pointer select-none",
|
|
2398
|
+
"transition-m3-fast-effects"
|
|
2399
|
+
].join(" "),
|
|
2400
|
+
/** Day cell: selected state */
|
|
2401
|
+
dayCellSelected: ["bg-m3-primary", "text-m3-on-primary"].join(" "),
|
|
2402
|
+
/** Day cell: today state */
|
|
2403
|
+
dayCellToday: [
|
|
2404
|
+
"outline outline-1 outline-m3-primary",
|
|
2405
|
+
"text-m3-primary"
|
|
2406
|
+
].join(" "),
|
|
2407
|
+
/** Day cell: disabled state */
|
|
2408
|
+
dayCellDisabled: "opacity-[0.38] pointer-events-none cursor-not-allowed",
|
|
2409
|
+
/** Range highlight (between start and end) */
|
|
2410
|
+
rangeHighlight: "bg-m3-secondary-container",
|
|
2411
|
+
/** Weekday header row */
|
|
2412
|
+
weekdayRow: "text-[length:var(--md-typescale-body-large-size,14px)] text-m3-on-surface"
|
|
2413
|
+
};
|
|
2414
|
+
var ScrollArea = React17__namespace.forwardRef(
|
|
2415
|
+
(_a, ref) => {
|
|
2416
|
+
var _b = _a, {
|
|
2417
|
+
className,
|
|
2418
|
+
viewportClassName,
|
|
2419
|
+
children,
|
|
2420
|
+
type = "hover",
|
|
2421
|
+
orientation = "vertical",
|
|
2422
|
+
scrollHideDelay = 600,
|
|
2423
|
+
viewportRef,
|
|
2424
|
+
viewportProps
|
|
2425
|
+
} = _b, props = __objRest(_b, [
|
|
2426
|
+
"className",
|
|
2427
|
+
"viewportClassName",
|
|
2428
|
+
"children",
|
|
2429
|
+
"type",
|
|
2430
|
+
"orientation",
|
|
2431
|
+
"scrollHideDelay",
|
|
2432
|
+
"viewportRef",
|
|
2433
|
+
"viewportProps"
|
|
2434
|
+
]);
|
|
2435
|
+
const [isTouchDevice, setIsTouchDevice] = React17__namespace.useState(false);
|
|
2436
|
+
React17__namespace.useEffect(() => {
|
|
2437
|
+
if (typeof window !== "undefined") {
|
|
2438
|
+
setIsTouchDevice(
|
|
2439
|
+
"ontouchstart" in window || navigator.maxTouchPoints > 0
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
}, []);
|
|
2443
|
+
const resolvedType = React17__namespace.useMemo(() => {
|
|
2444
|
+
if (type === "hover" && isTouchDevice) {
|
|
2445
|
+
return "scroll";
|
|
2446
|
+
}
|
|
2447
|
+
return type;
|
|
2448
|
+
}, [type, isTouchDevice]);
|
|
2449
|
+
const radixType = resolvedType === "none" ? "always" : resolvedType;
|
|
2450
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2451
|
+
RadixScrollArea__namespace.Root,
|
|
2452
|
+
__spreadProps(__spreadValues({
|
|
2453
|
+
ref,
|
|
2454
|
+
type: radixType,
|
|
2455
|
+
scrollHideDelay,
|
|
2456
|
+
className: cn("relative overflow-hidden flex flex-col", className)
|
|
2457
|
+
}, props), {
|
|
2458
|
+
children: [
|
|
2459
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2460
|
+
RadixScrollArea__namespace.Viewport,
|
|
2461
|
+
__spreadProps(__spreadValues({
|
|
2462
|
+
ref: viewportRef
|
|
2463
|
+
}, viewportProps), {
|
|
2464
|
+
className: cn(
|
|
2465
|
+
"h-full w-full flex-1 min-h-0 min-w-0 rounded-[inherit]",
|
|
2466
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-m3-primary focus-visible:ring-offset-1",
|
|
2467
|
+
viewportClassName,
|
|
2468
|
+
viewportProps == null ? void 0 : viewportProps.className
|
|
2469
|
+
),
|
|
2470
|
+
children
|
|
2471
|
+
})
|
|
2472
|
+
),
|
|
2473
|
+
(orientation === "vertical" || orientation === "both") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2474
|
+
ScrollAreaScrollbar,
|
|
2475
|
+
{
|
|
2476
|
+
orientation: "vertical",
|
|
2477
|
+
className: resolvedType === "none" ? "hidden" : void 0
|
|
2478
|
+
}
|
|
2479
|
+
),
|
|
2480
|
+
(orientation === "horizontal" || orientation === "both") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2481
|
+
ScrollAreaScrollbar,
|
|
2482
|
+
{
|
|
2483
|
+
orientation: "horizontal",
|
|
2484
|
+
className: resolvedType === "none" ? "hidden" : void 0
|
|
2485
|
+
}
|
|
2486
|
+
),
|
|
2487
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixScrollArea__namespace.Corner, { className: "bg-m3-surface-container" })
|
|
2488
|
+
]
|
|
2489
|
+
})
|
|
2490
|
+
);
|
|
2491
|
+
}
|
|
2492
|
+
);
|
|
2493
|
+
ScrollArea.displayName = "ScrollArea";
|
|
2494
|
+
var ScrollAreaScrollbar = React17__namespace.forwardRef((_a, ref) => {
|
|
2495
|
+
var _b = _a, { className, orientation = "vertical" } = _b, props = __objRest(_b, ["className", "orientation"]);
|
|
2496
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2497
|
+
RadixScrollArea__namespace.Scrollbar,
|
|
2498
|
+
__spreadProps(__spreadValues({
|
|
2499
|
+
ref,
|
|
2500
|
+
orientation,
|
|
2501
|
+
className: cn(
|
|
2502
|
+
"flex touch-none select-none transition-all duration-300 ease-in-out",
|
|
2503
|
+
"absolute z-50",
|
|
2504
|
+
orientation === "vertical" && "right-0 top-0 bottom-0 w-2.5 border-l border-l-transparent p-px",
|
|
2505
|
+
orientation === "horizontal" && "bottom-0 left-0 right-0 h-2.5 flex-col border-t border-t-transparent p-px",
|
|
2506
|
+
"data-[state=hidden]:opacity-0 data-[state=visible]:opacity-100",
|
|
2507
|
+
className
|
|
2508
|
+
)
|
|
2509
|
+
}, props), {
|
|
2510
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2511
|
+
RadixScrollArea__namespace.Thumb,
|
|
2512
|
+
{
|
|
2513
|
+
className: cn(
|
|
2514
|
+
"relative flex-1 rounded-full bg-m3-on-surface/25 transition-colors duration-200",
|
|
2515
|
+
"hover:bg-m3-on-surface/40 active:bg-m3-on-surface/55",
|
|
2516
|
+
"before:absolute before:left-1/2 before:top-1/2 before:min-h-11 before:min-w-11 before:-translate-x-1/2 before:-translate-y-1/2"
|
|
2517
|
+
)
|
|
2518
|
+
}
|
|
2519
|
+
)
|
|
2520
|
+
})
|
|
2521
|
+
);
|
|
2522
|
+
});
|
|
2523
|
+
ScrollAreaScrollbar.displayName = RadixScrollArea__namespace.Scrollbar.displayName;
|
|
2524
|
+
var ScrollAreaCorner = React17__namespace.forwardRef((_a, ref) => {
|
|
2525
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
2526
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2527
|
+
RadixScrollArea__namespace.Corner,
|
|
2528
|
+
__spreadValues({
|
|
2529
|
+
ref,
|
|
2530
|
+
className: cn("bg-m3-surface-container", className)
|
|
2531
|
+
}, props)
|
|
2532
|
+
);
|
|
2533
|
+
});
|
|
2534
|
+
ScrollAreaCorner.displayName = "ScrollAreaCorner";
|
|
2535
|
+
var MD3_SPRING = DEFAULT_SPATIAL_SPRING;
|
|
2536
|
+
var MD3_OVERLAY_ANIM = {
|
|
2537
|
+
initial: { opacity: 0 },
|
|
2538
|
+
animate: {
|
|
2539
|
+
opacity: 1,
|
|
2540
|
+
transition: { duration: 0.2, ease: "easeOut" }
|
|
2541
|
+
},
|
|
2542
|
+
exit: { opacity: 0, transition: { duration: 0.15, ease: "easeIn" } }
|
|
2543
|
+
};
|
|
2544
|
+
var MD3_CONTENT_ANIM = {
|
|
2545
|
+
initial: { opacity: 0, scale: 0.85, y: 24 },
|
|
2546
|
+
animate: { opacity: 1, scale: 1, y: 0, transition: MD3_SPRING },
|
|
2547
|
+
exit: {
|
|
2548
|
+
opacity: 0,
|
|
2549
|
+
scale: 0.95,
|
|
2550
|
+
y: 8,
|
|
2551
|
+
transition: { duration: 0.15, ease: "easeIn" }
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
var MD3_FULLSCREEN_ANIM = {
|
|
2555
|
+
initial: { y: "100%" },
|
|
2556
|
+
animate: { y: 0, transition: MD3_SPRING },
|
|
2557
|
+
exit: { y: "100%", transition: { duration: 0.2, ease: "easeIn" } }
|
|
2558
|
+
};
|
|
2559
|
+
var Dialog = ({ open, onOpenChange, children }) => /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Root, { open, onOpenChange, children });
|
|
2560
|
+
Dialog.displayName = "Dialog";
|
|
2561
|
+
var DialogTrigger = RadixDialog__namespace.Trigger;
|
|
2562
|
+
DialogTrigger.displayName = "DialogTrigger";
|
|
2563
|
+
var DialogPortal = ({
|
|
2564
|
+
open,
|
|
2565
|
+
children
|
|
2566
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Portal, { forceMount: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { children: open ? React17__namespace.Children.toArray(children) : null }) });
|
|
2567
|
+
DialogPortal.displayName = "DialogPortal";
|
|
2568
|
+
var DialogOverlay = React17__namespace.forwardRef((_a, ref) => {
|
|
2569
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
2570
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Overlay, __spreadProps(__spreadValues({ ref, asChild: true }, props), { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2571
|
+
react.m.div,
|
|
2572
|
+
__spreadValues({
|
|
2573
|
+
className: cn("fixed inset-0 z-50 bg-black/32", className),
|
|
2574
|
+
"aria-hidden": "true"
|
|
2575
|
+
}, MD3_OVERLAY_ANIM)
|
|
2576
|
+
) }));
|
|
2577
|
+
});
|
|
2578
|
+
DialogOverlay.displayName = "DialogOverlay";
|
|
2579
|
+
var DialogContent = React17__namespace.forwardRef((_a, ref) => {
|
|
2580
|
+
var _b = _a, { className, children, hideCloseButton = false } = _b, props = __objRest(_b, ["className", "children", "hideCloseButton"]);
|
|
2581
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2582
|
+
RadixDialog__namespace.Content,
|
|
2583
|
+
__spreadProps(__spreadValues({
|
|
2584
|
+
ref,
|
|
2585
|
+
asChild: true,
|
|
2586
|
+
"aria-describedby": void 0
|
|
2587
|
+
}, props), {
|
|
2588
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2589
|
+
react.m.div,
|
|
2590
|
+
__spreadProps(__spreadValues({
|
|
2591
|
+
className: cn(
|
|
2592
|
+
"fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2",
|
|
2593
|
+
"w-[calc(100%-2rem)] max-w-140",
|
|
2594
|
+
"rounded-[28px] bg-m3-surface-container-high p-6",
|
|
2595
|
+
"shadow-lg outline-none focus-visible:ring-2 focus-visible:ring-m3-primary",
|
|
2596
|
+
className
|
|
2597
|
+
),
|
|
2598
|
+
role: "dialog"
|
|
2599
|
+
}, MD3_CONTENT_ANIM), {
|
|
2600
|
+
children: [
|
|
2601
|
+
children,
|
|
2602
|
+
!hideCloseButton && /* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Close, { asChild: true, "aria-label": "Close dialog", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2603
|
+
IconButton,
|
|
2604
|
+
{
|
|
2605
|
+
size: "sm",
|
|
2606
|
+
colorStyle: "filled",
|
|
2607
|
+
className: "absolute right-4 top-4",
|
|
2608
|
+
"aria-label": "Close",
|
|
2609
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", "aria-hidden": "true" })
|
|
2610
|
+
}
|
|
2611
|
+
) })
|
|
2612
|
+
]
|
|
2613
|
+
})
|
|
2614
|
+
)
|
|
2615
|
+
})
|
|
2616
|
+
);
|
|
2617
|
+
});
|
|
2618
|
+
DialogContent.displayName = "DialogContent";
|
|
2619
|
+
var DialogIcon = React17__namespace.forwardRef((_a, ref) => {
|
|
2620
|
+
var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
|
|
2621
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2622
|
+
"div",
|
|
2623
|
+
__spreadProps(__spreadValues({
|
|
2624
|
+
ref,
|
|
2625
|
+
className: cn("flex justify-center mb-4 text-m3-secondary", className),
|
|
2626
|
+
"aria-hidden": "true"
|
|
2627
|
+
}, props), {
|
|
2628
|
+
children
|
|
2629
|
+
})
|
|
2630
|
+
);
|
|
2631
|
+
});
|
|
2632
|
+
DialogIcon.displayName = "DialogIcon";
|
|
2633
|
+
var DialogTitle = React17__namespace.forwardRef((_a, ref) => {
|
|
2634
|
+
var _b = _a, { className, asChild } = _b, props = __objRest(_b, ["className", "asChild"]);
|
|
2635
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2636
|
+
RadixDialog__namespace.Title,
|
|
2637
|
+
__spreadValues({
|
|
2638
|
+
ref,
|
|
2639
|
+
asChild,
|
|
2640
|
+
className: cn(
|
|
2641
|
+
"text-[24px] leading-8 font-normal text-m3-on-surface tracking-[0em]",
|
|
2642
|
+
className
|
|
2643
|
+
)
|
|
2644
|
+
}, props)
|
|
2645
|
+
);
|
|
2646
|
+
});
|
|
2647
|
+
DialogTitle.displayName = "DialogTitle";
|
|
2648
|
+
var DialogDescription = React17__namespace.forwardRef((_a, ref) => {
|
|
2649
|
+
var _b = _a, { className, asChild } = _b, props = __objRest(_b, ["className", "asChild"]);
|
|
2650
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2651
|
+
RadixDialog__namespace.Description,
|
|
2652
|
+
__spreadValues({
|
|
2653
|
+
ref,
|
|
2654
|
+
asChild,
|
|
2655
|
+
className: cn("text-sm text-m3-on-surface-variant leading-5", className)
|
|
2656
|
+
}, props)
|
|
2657
|
+
);
|
|
2658
|
+
});
|
|
2659
|
+
DialogDescription.displayName = "DialogDescription";
|
|
2660
|
+
var DialogBody = React17__namespace.forwardRef((_a, ref) => {
|
|
2661
|
+
var _b = _a, { className, children, dir } = _b, props = __objRest(_b, ["className", "children", "dir"]);
|
|
2662
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2663
|
+
ScrollArea,
|
|
2664
|
+
__spreadProps(__spreadValues({
|
|
2665
|
+
ref,
|
|
2666
|
+
type: "hover",
|
|
2667
|
+
dir,
|
|
2668
|
+
className: cn("max-h-[calc(85dvh-200px)] -mx-6", className),
|
|
2669
|
+
viewportClassName: "px-6"
|
|
2670
|
+
}, props), {
|
|
2671
|
+
children
|
|
2672
|
+
})
|
|
2673
|
+
);
|
|
2674
|
+
});
|
|
2675
|
+
DialogBody.displayName = "DialogBody";
|
|
2676
|
+
var DialogFullScreenContent = React17__namespace.forwardRef(
|
|
2677
|
+
(_a, ref) => {
|
|
2678
|
+
var _b = _a, {
|
|
2679
|
+
className,
|
|
2680
|
+
children,
|
|
2681
|
+
title,
|
|
2682
|
+
actionLabel,
|
|
2683
|
+
onAction,
|
|
2684
|
+
showDivider
|
|
2685
|
+
} = _b, props = __objRest(_b, [
|
|
2686
|
+
"className",
|
|
2687
|
+
"children",
|
|
2688
|
+
"title",
|
|
2689
|
+
"actionLabel",
|
|
2690
|
+
"onAction",
|
|
2691
|
+
"showDivider"
|
|
2692
|
+
]);
|
|
2693
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2694
|
+
RadixDialog__namespace.Content,
|
|
2695
|
+
__spreadProps(__spreadValues({
|
|
2696
|
+
ref,
|
|
2697
|
+
asChild: true,
|
|
2698
|
+
"aria-describedby": void 0
|
|
2699
|
+
}, props), {
|
|
2700
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2701
|
+
react.m.div,
|
|
2702
|
+
__spreadProps(__spreadValues({
|
|
2703
|
+
className: cn(
|
|
2704
|
+
"fixed inset-0 z-50 w-full h-full bg-m3-surface flex flex-col",
|
|
2705
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-m3-primary",
|
|
2706
|
+
className
|
|
2707
|
+
),
|
|
2708
|
+
role: "dialog"
|
|
2709
|
+
}, MD3_FULLSCREEN_ANIM), {
|
|
2710
|
+
children: [
|
|
2711
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center px-4 h-14 gap-2 bg-m3-surface", children: [
|
|
2712
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Close, { asChild: true, "aria-label": "Close dialog", children: /* @__PURE__ */ jsxRuntime.jsx(IconButton, { size: "sm", colorStyle: "filled", "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", "aria-hidden": "true" }) }) }),
|
|
2713
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "flex-1 text-[22px] leading-7 font-medium truncate pr-2", children: title }),
|
|
2714
|
+
actionLabel && onAction && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2715
|
+
"button",
|
|
2716
|
+
{
|
|
2717
|
+
type: "button",
|
|
2718
|
+
onClick: onAction,
|
|
2719
|
+
className: "text-sm font-medium text-m3-primary px-3 py-2 rounded-full hover:bg-m3-primary/8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary transition-colors whitespace-nowrap",
|
|
2720
|
+
children: actionLabel
|
|
2721
|
+
}
|
|
2722
|
+
)
|
|
2723
|
+
] }),
|
|
2724
|
+
showDivider && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-m3-outline-variant w-full shrink-0 m-0" }),
|
|
2725
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2726
|
+
ScrollArea,
|
|
2727
|
+
{
|
|
2728
|
+
type: "hover",
|
|
2729
|
+
className: "flex-1 w-full",
|
|
2730
|
+
viewportClassName: "p-6",
|
|
2731
|
+
children
|
|
2732
|
+
}
|
|
2733
|
+
)
|
|
2734
|
+
]
|
|
2735
|
+
})
|
|
2736
|
+
)
|
|
2737
|
+
})
|
|
2738
|
+
);
|
|
2739
|
+
}
|
|
2740
|
+
);
|
|
2741
|
+
DialogFullScreenContent.displayName = "DialogFullScreenContent";
|
|
2742
|
+
var DatePickerDialog = ({
|
|
2743
|
+
open,
|
|
2744
|
+
onDismiss,
|
|
2745
|
+
confirmButton,
|
|
2746
|
+
dismissButton,
|
|
2747
|
+
children,
|
|
2748
|
+
className,
|
|
2749
|
+
title = "Select date"
|
|
2750
|
+
}) => {
|
|
2751
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: (v) => !v && onDismiss(), children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { open, children: [
|
|
2752
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Overlay, { asChild: true, forceMount: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2753
|
+
react.m.div,
|
|
2754
|
+
{
|
|
2755
|
+
className: "fixed inset-0 z-50 bg-m3-scrim/40",
|
|
2756
|
+
initial: PICKER_OVERLAY_ANIM.initial,
|
|
2757
|
+
animate: PICKER_OVERLAY_ANIM.animate,
|
|
2758
|
+
exit: PICKER_OVERLAY_ANIM.exit,
|
|
2759
|
+
onClick: onDismiss
|
|
2760
|
+
},
|
|
2761
|
+
"picker-overlay"
|
|
2762
|
+
) }),
|
|
2763
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2764
|
+
RadixDialog__namespace.Content,
|
|
2765
|
+
{
|
|
2766
|
+
asChild: true,
|
|
2767
|
+
forceMount: true,
|
|
2768
|
+
onEscapeKeyDown: onDismiss,
|
|
2769
|
+
onPointerDownOutside: (e) => e.preventDefault(),
|
|
2770
|
+
"aria-modal": true,
|
|
2771
|
+
"aria-describedby": void 0,
|
|
2772
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2773
|
+
react.m.div,
|
|
2774
|
+
{
|
|
2775
|
+
className: cn(
|
|
2776
|
+
"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
2777
|
+
"flex flex-col",
|
|
2778
|
+
"bg-m3-surface-container-high",
|
|
2779
|
+
"rounded-m3-xl",
|
|
2780
|
+
"overflow-hidden",
|
|
2781
|
+
// Elevation Level 3
|
|
2782
|
+
"elevation-3",
|
|
2783
|
+
className
|
|
2784
|
+
),
|
|
2785
|
+
style: { width: "min(calc(100vw - 32px), 360px)" },
|
|
2786
|
+
initial: PICKER_CONTENT_ANIM.initial,
|
|
2787
|
+
animate: PICKER_CONTENT_ANIM.animate,
|
|
2788
|
+
exit: PICKER_CONTENT_ANIM.exit,
|
|
2789
|
+
children: [
|
|
2790
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Title, { className: "sr-only", children: title }),
|
|
2791
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children }),
|
|
2792
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-2 px-4 py-3", children: [
|
|
2793
|
+
dismissButton,
|
|
2794
|
+
confirmButton
|
|
2795
|
+
] })
|
|
2796
|
+
]
|
|
2797
|
+
},
|
|
2798
|
+
"picker-content"
|
|
2799
|
+
)
|
|
2800
|
+
}
|
|
2801
|
+
)
|
|
2802
|
+
] }) });
|
|
2803
|
+
};
|
|
2804
|
+
DatePickerDialog.displayName = "DatePickerDialog";
|
|
2805
|
+
var DateRangePicker = ({
|
|
2806
|
+
state,
|
|
2807
|
+
showModeToggle = false,
|
|
2808
|
+
title,
|
|
2809
|
+
className
|
|
2810
|
+
}) => {
|
|
2811
|
+
const {
|
|
2812
|
+
selectedStartMs,
|
|
2813
|
+
selectedEndMs,
|
|
2814
|
+
displayedMonthMs,
|
|
2815
|
+
displayMode,
|
|
2816
|
+
yearRange,
|
|
2817
|
+
locale,
|
|
2818
|
+
selectableDates,
|
|
2819
|
+
selectDate,
|
|
2820
|
+
navigateMonth: navigateMonth2,
|
|
2821
|
+
navigateToMonth,
|
|
2822
|
+
setDisplayMode
|
|
2823
|
+
} = state;
|
|
2824
|
+
const [activeSelector, setActiveSelector] = React17__namespace.useState(null);
|
|
2825
|
+
const [slideDirection, setSlideDirection] = React17__namespace.useState(null);
|
|
2826
|
+
const handlePrev = React17__namespace.useCallback(() => {
|
|
2827
|
+
setSlideDirection("prev");
|
|
2828
|
+
navigateMonth2("prev");
|
|
2829
|
+
}, [navigateMonth2]);
|
|
2830
|
+
const handleNext = React17__namespace.useCallback(() => {
|
|
2831
|
+
setSlideDirection("next");
|
|
2832
|
+
navigateMonth2("next");
|
|
2833
|
+
}, [navigateMonth2]);
|
|
2834
|
+
const handleYearSelect = React17__namespace.useCallback(
|
|
2835
|
+
(year) => {
|
|
2836
|
+
const d = new Date(displayedMonthMs);
|
|
2837
|
+
navigateToMonth(year, d.getUTCMonth());
|
|
2838
|
+
setActiveSelector(null);
|
|
2839
|
+
},
|
|
2840
|
+
[displayedMonthMs, navigateToMonth]
|
|
2841
|
+
);
|
|
2842
|
+
const handleMonthSelect = React17__namespace.useCallback(
|
|
2843
|
+
(month) => {
|
|
2844
|
+
const d = new Date(displayedMonthMs);
|
|
2845
|
+
navigateToMonth(d.getUTCFullYear(), month);
|
|
2846
|
+
setActiveSelector(null);
|
|
2847
|
+
},
|
|
2848
|
+
[displayedMonthMs, navigateToMonth]
|
|
2849
|
+
);
|
|
2850
|
+
const formatShort = React17__namespace.useCallback(
|
|
2851
|
+
(ms) => {
|
|
2852
|
+
if (ms === null) return "\u2014";
|
|
2853
|
+
return formatDate(ms, locale, {
|
|
2854
|
+
month: "short",
|
|
2855
|
+
day: "numeric",
|
|
2856
|
+
timeZone: "UTC"
|
|
2857
|
+
});
|
|
2858
|
+
},
|
|
2859
|
+
[locale]
|
|
2860
|
+
);
|
|
2861
|
+
const headline = `${formatShort(selectedStartMs)} \u2013 ${formatShort(selectedEndMs)}`;
|
|
2862
|
+
const currentYear = new Date(displayedMonthMs).getUTCFullYear();
|
|
2863
|
+
const currentMonth = new Date(displayedMonthMs).getUTCMonth();
|
|
2864
|
+
const computedAriaLabel = typeof title === "string" ? title : "Date range picker";
|
|
2865
|
+
const canNavigatePrev = getNavigableMonth(displayedMonthMs, "prev", yearRange, selectableDates) !== null;
|
|
2866
|
+
const canNavigateNext = getNavigableMonth(displayedMonthMs, "next", yearRange, selectableDates) !== null;
|
|
2867
|
+
const canNavigatePreviousYear = isMonthNavigable(
|
|
2868
|
+
currentYear - 1,
|
|
2869
|
+
yearRange,
|
|
2870
|
+
selectableDates
|
|
2871
|
+
);
|
|
2872
|
+
const canNavigateNextYear = isMonthNavigable(
|
|
2873
|
+
currentYear + 1,
|
|
2874
|
+
yearRange,
|
|
2875
|
+
selectableDates
|
|
2876
|
+
);
|
|
2877
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2878
|
+
"fieldset",
|
|
2879
|
+
{
|
|
2880
|
+
className: cn("flex flex-col select-none", className),
|
|
2881
|
+
style: { width: "min(100%, 360px)" },
|
|
2882
|
+
"aria-label": computedAriaLabel,
|
|
2883
|
+
children: [
|
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsx("legend", { className: "sr-only", children: computedAriaLabel }),
|
|
2885
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2886
|
+
CalendarHeader,
|
|
2887
|
+
{
|
|
2888
|
+
displayedMonthMs,
|
|
2889
|
+
activeSelector,
|
|
2890
|
+
displayMode,
|
|
2891
|
+
showModeToggle,
|
|
2892
|
+
title: title != null ? title : "Select dates",
|
|
2893
|
+
headline,
|
|
2894
|
+
locale,
|
|
2895
|
+
canNavigatePrev,
|
|
2896
|
+
canNavigateNext,
|
|
2897
|
+
canNavigatePreviousYear,
|
|
2898
|
+
canNavigateNextYear,
|
|
2899
|
+
onPrev: handlePrev,
|
|
2900
|
+
onNext: handleNext,
|
|
2901
|
+
onPreviousYear: () => navigateToMonth(currentYear - 1, currentMonth),
|
|
2902
|
+
onNextYear: () => navigateToMonth(currentYear + 1, currentMonth),
|
|
2903
|
+
onToggleSelector: (selector) => setActiveSelector((active) => active === selector ? null : selector),
|
|
2904
|
+
onToggleMode: () => {
|
|
2905
|
+
setDisplayMode(displayMode === "picker" ? "input" : "picker");
|
|
2906
|
+
setActiveSelector(null);
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
),
|
|
2910
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2911
|
+
"div",
|
|
2912
|
+
{
|
|
2913
|
+
className: "relative flex-1 overflow-hidden",
|
|
2914
|
+
style: { minHeight: "296px" },
|
|
2915
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "wait", children: activeSelector === "month" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2916
|
+
"div",
|
|
2917
|
+
{
|
|
2918
|
+
id: "date-picker-selection",
|
|
2919
|
+
className: "absolute inset-0",
|
|
2920
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2921
|
+
MonthPickerList,
|
|
2922
|
+
{
|
|
2923
|
+
selectedMonth: currentMonth,
|
|
2924
|
+
locale,
|
|
2925
|
+
onMonthSelect: handleMonthSelect
|
|
2926
|
+
}
|
|
2927
|
+
)
|
|
2928
|
+
},
|
|
2929
|
+
"month-list"
|
|
2930
|
+
) : activeSelector === "year" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2931
|
+
"div",
|
|
2932
|
+
{
|
|
2933
|
+
id: "date-picker-selection",
|
|
2934
|
+
className: "absolute inset-0",
|
|
2935
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2936
|
+
YearPickerList,
|
|
2937
|
+
{
|
|
2938
|
+
selectedYear: currentYear,
|
|
2939
|
+
yearRange,
|
|
2940
|
+
selectableDates,
|
|
2941
|
+
onYearSelect: handleYearSelect
|
|
2942
|
+
}
|
|
2943
|
+
)
|
|
2944
|
+
},
|
|
2945
|
+
"year-list"
|
|
2946
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2947
|
+
CalendarGrid,
|
|
2948
|
+
{
|
|
2949
|
+
displayedMonthMs,
|
|
2950
|
+
slideDirection,
|
|
2951
|
+
locale,
|
|
2952
|
+
selectableDates,
|
|
2953
|
+
selectedMs: null,
|
|
2954
|
+
selectedStartMs,
|
|
2955
|
+
selectedEndMs,
|
|
2956
|
+
isRangePicker: true,
|
|
2957
|
+
onDaySelect: selectDate
|
|
2958
|
+
},
|
|
2959
|
+
"calendar"
|
|
2960
|
+
) })
|
|
2961
|
+
}
|
|
2962
|
+
)
|
|
2963
|
+
]
|
|
2964
|
+
}
|
|
2965
|
+
);
|
|
2966
|
+
};
|
|
2967
|
+
DateRangePicker.displayName = "DateRangePicker";
|
|
2968
|
+
|
|
2969
|
+
// src/ui/date-time-pickers/shared/types.ts
|
|
2970
|
+
var ALL_DATES_SELECTABLE = {
|
|
2971
|
+
isSelectableDate: () => true,
|
|
2972
|
+
isSelectableYear: () => true
|
|
2973
|
+
};
|
|
2974
|
+
|
|
2975
|
+
// src/ui/date-time-pickers/date-picker/use-date-picker-state.ts
|
|
2976
|
+
var DEFAULT_YEAR_RANGE = [1900, 2100];
|
|
2977
|
+
var DEFAULT_DISPLAY_MODE = "picker";
|
|
2978
|
+
var useDatePickerState = (options) => {
|
|
2979
|
+
var _a, _b, _c, _d, _e;
|
|
2980
|
+
const initialSelectedMs = (_a = options == null ? void 0 : options.initialSelectedDateMs) != null ? _a : null;
|
|
2981
|
+
const initialMonthMs = normalizeToMonthStart(
|
|
2982
|
+
(_b = options == null ? void 0 : options.initialDisplayedMonthMs) != null ? _b : initialSelectedMs !== null ? initialSelectedMs : todayUTC()
|
|
2983
|
+
);
|
|
2984
|
+
const yearRange = (_c = options == null ? void 0 : options.yearRange) != null ? _c : DEFAULT_YEAR_RANGE;
|
|
2985
|
+
const selectableDates = (_d = options == null ? void 0 : options.selectableDates) != null ? _d : ALL_DATES_SELECTABLE;
|
|
2986
|
+
const initialDisplayMode = (_e = options == null ? void 0 : options.initialDisplayMode) != null ? _e : DEFAULT_DISPLAY_MODE;
|
|
2987
|
+
const locale = resolveLocale(options == null ? void 0 : options.locale);
|
|
2988
|
+
const [selectedDateMs, setSelectedDateMs] = React17.useState(
|
|
2989
|
+
initialSelectedMs !== null ? startOfDayUTC(initialSelectedMs) : null
|
|
2990
|
+
);
|
|
2991
|
+
const [displayedMonthMs, setDisplayedMonthMs] = React17.useState(initialMonthMs);
|
|
2992
|
+
const [displayMode, setDisplayModeState] = React17.useState(initialDisplayMode);
|
|
2993
|
+
const selectDate = React17.useCallback(
|
|
2994
|
+
(ms) => {
|
|
2995
|
+
if (ms === null) {
|
|
2996
|
+
setSelectedDateMs(null);
|
|
2997
|
+
return;
|
|
2998
|
+
}
|
|
2999
|
+
const normalized = startOfDayUTC(ms);
|
|
3000
|
+
if (!selectableDates.isSelectableDate(normalized)) return;
|
|
3001
|
+
setSelectedDateMs(normalized);
|
|
3002
|
+
setDisplayedMonthMs(normalizeToMonthStart(normalized));
|
|
3003
|
+
},
|
|
3004
|
+
[selectableDates]
|
|
3005
|
+
);
|
|
3006
|
+
const navigateMonthAction = React17.useCallback(
|
|
3007
|
+
(direction) => {
|
|
3008
|
+
setDisplayedMonthMs(
|
|
3009
|
+
(prev) => {
|
|
3010
|
+
var _a2;
|
|
3011
|
+
return (_a2 = getNavigableMonth(prev, direction, yearRange, selectableDates)) != null ? _a2 : prev;
|
|
3012
|
+
}
|
|
3013
|
+
);
|
|
3014
|
+
},
|
|
3015
|
+
[yearRange, selectableDates]
|
|
3016
|
+
);
|
|
3017
|
+
const navigateToMonth = React17.useCallback(
|
|
3018
|
+
(year, month) => {
|
|
3019
|
+
if (!isMonthNavigable(year, yearRange, selectableDates)) return;
|
|
3020
|
+
setDisplayedMonthMs(Date.UTC(year, month, 1));
|
|
3021
|
+
},
|
|
3022
|
+
[yearRange, selectableDates]
|
|
3023
|
+
);
|
|
3024
|
+
const setDisplayMode = React17.useCallback((mode) => {
|
|
3025
|
+
setDisplayModeState(mode);
|
|
3026
|
+
}, []);
|
|
3027
|
+
const reset = React17.useCallback(() => {
|
|
3028
|
+
setSelectedDateMs(
|
|
3029
|
+
initialSelectedMs !== null ? startOfDayUTC(initialSelectedMs) : null
|
|
3030
|
+
);
|
|
3031
|
+
setDisplayedMonthMs(initialMonthMs);
|
|
3032
|
+
setDisplayModeState(initialDisplayMode);
|
|
3033
|
+
}, [initialSelectedMs, initialMonthMs, initialDisplayMode]);
|
|
3034
|
+
return React17.useMemo(
|
|
3035
|
+
() => ({
|
|
3036
|
+
selectedDateMs,
|
|
3037
|
+
displayedMonthMs,
|
|
3038
|
+
displayMode,
|
|
3039
|
+
yearRange,
|
|
3040
|
+
locale,
|
|
3041
|
+
selectableDates,
|
|
3042
|
+
selectDate,
|
|
3043
|
+
navigateMonth: navigateMonthAction,
|
|
3044
|
+
navigateToMonth,
|
|
3045
|
+
setDisplayMode,
|
|
3046
|
+
reset
|
|
3047
|
+
}),
|
|
3048
|
+
[
|
|
3049
|
+
selectedDateMs,
|
|
3050
|
+
displayedMonthMs,
|
|
3051
|
+
displayMode,
|
|
3052
|
+
yearRange,
|
|
3053
|
+
locale,
|
|
3054
|
+
selectableDates,
|
|
3055
|
+
selectDate,
|
|
3056
|
+
navigateMonthAction,
|
|
3057
|
+
navigateToMonth,
|
|
3058
|
+
setDisplayMode,
|
|
3059
|
+
reset
|
|
3060
|
+
]
|
|
3061
|
+
);
|
|
3062
|
+
};
|
|
3063
|
+
var DEFAULT_YEAR_RANGE2 = [1900, 2100];
|
|
3064
|
+
function rangeReducer(state, action) {
|
|
3065
|
+
switch (action.type) {
|
|
3066
|
+
case "SELECT": {
|
|
3067
|
+
const { startMs, endMs } = state;
|
|
3068
|
+
const ms = action.ms;
|
|
3069
|
+
if (startMs === null) return { startMs: ms, endMs: null };
|
|
3070
|
+
if (endMs !== null) return { startMs: ms, endMs: null };
|
|
3071
|
+
if (ms > startMs) return { startMs, endMs: ms };
|
|
3072
|
+
return { startMs: ms, endMs: null };
|
|
3073
|
+
}
|
|
3074
|
+
case "CLEAR":
|
|
3075
|
+
return { startMs: null, endMs: null };
|
|
3076
|
+
case "RESET":
|
|
3077
|
+
return { startMs: action.startMs, endMs: action.endMs };
|
|
3078
|
+
default:
|
|
3079
|
+
return state;
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
var useDateRangePickerState = (options) => {
|
|
3083
|
+
var _a, _b, _c, _d;
|
|
3084
|
+
const initialStartMs = (options == null ? void 0 : options.initialStartMs) != null ? startOfDayUTC(options.initialStartMs) : null;
|
|
3085
|
+
const initialEndMs = (options == null ? void 0 : options.initialEndMs) != null ? startOfDayUTC(options.initialEndMs) : null;
|
|
3086
|
+
const initialMonthMs = normalizeToMonthStart(
|
|
3087
|
+
(_a = options == null ? void 0 : options.initialDisplayedMonthMs) != null ? _a : initialStartMs !== null ? initialStartMs : todayUTC()
|
|
3088
|
+
);
|
|
3089
|
+
const yearRange = (_b = options == null ? void 0 : options.yearRange) != null ? _b : DEFAULT_YEAR_RANGE2;
|
|
3090
|
+
const selectableDates = (_c = options == null ? void 0 : options.selectableDates) != null ? _c : ALL_DATES_SELECTABLE;
|
|
3091
|
+
const initialDisplayMode = (_d = options == null ? void 0 : options.initialDisplayMode) != null ? _d : "picker";
|
|
3092
|
+
const locale = resolveLocale(options == null ? void 0 : options.locale);
|
|
3093
|
+
const [{ startMs: selectedStartMs, endMs: selectedEndMs }, dispatch] = React17.useReducer(rangeReducer, {
|
|
3094
|
+
startMs: initialStartMs,
|
|
3095
|
+
endMs: initialEndMs
|
|
3096
|
+
});
|
|
3097
|
+
const [displayedMonthMs, setDisplayedMonthMs] = React17.useState(initialMonthMs);
|
|
3098
|
+
const [displayMode, setDisplayModeState] = React17.useState(initialDisplayMode);
|
|
3099
|
+
const selectDate = React17.useCallback(
|
|
3100
|
+
(ms) => {
|
|
3101
|
+
const normalized = startOfDayUTC(ms);
|
|
3102
|
+
if (!selectableDates.isSelectableDate(normalized)) return;
|
|
3103
|
+
dispatch({ type: "SELECT", ms: normalized });
|
|
3104
|
+
},
|
|
3105
|
+
[selectableDates]
|
|
3106
|
+
);
|
|
3107
|
+
const clearRange = React17.useCallback(() => {
|
|
3108
|
+
dispatch({ type: "CLEAR" });
|
|
3109
|
+
}, []);
|
|
3110
|
+
const navigateMonthAction = React17.useCallback(
|
|
3111
|
+
(direction) => {
|
|
3112
|
+
setDisplayedMonthMs(
|
|
3113
|
+
(prev) => {
|
|
3114
|
+
var _a2;
|
|
3115
|
+
return (_a2 = getNavigableMonth(prev, direction, yearRange, selectableDates)) != null ? _a2 : prev;
|
|
3116
|
+
}
|
|
3117
|
+
);
|
|
3118
|
+
},
|
|
3119
|
+
[yearRange, selectableDates]
|
|
3120
|
+
);
|
|
3121
|
+
const navigateToMonth = React17.useCallback(
|
|
3122
|
+
(year, month) => {
|
|
3123
|
+
if (!isMonthNavigable(year, yearRange, selectableDates)) return;
|
|
3124
|
+
setDisplayedMonthMs(Date.UTC(year, month, 1));
|
|
3125
|
+
},
|
|
3126
|
+
[yearRange, selectableDates]
|
|
3127
|
+
);
|
|
3128
|
+
const setDisplayMode = React17.useCallback((mode) => {
|
|
3129
|
+
setDisplayModeState(mode);
|
|
3130
|
+
}, []);
|
|
3131
|
+
const reset = React17.useCallback(() => {
|
|
3132
|
+
dispatch({ type: "RESET", startMs: initialStartMs, endMs: initialEndMs });
|
|
3133
|
+
setDisplayedMonthMs(initialMonthMs);
|
|
3134
|
+
setDisplayModeState(initialDisplayMode);
|
|
3135
|
+
}, [initialStartMs, initialEndMs, initialMonthMs, initialDisplayMode]);
|
|
3136
|
+
return React17.useMemo(
|
|
3137
|
+
() => ({
|
|
3138
|
+
selectedStartMs,
|
|
3139
|
+
selectedEndMs,
|
|
3140
|
+
displayedMonthMs,
|
|
3141
|
+
displayMode,
|
|
3142
|
+
yearRange,
|
|
3143
|
+
locale,
|
|
3144
|
+
selectableDates,
|
|
3145
|
+
selectDate,
|
|
3146
|
+
clearRange,
|
|
3147
|
+
navigateMonth: navigateMonthAction,
|
|
3148
|
+
navigateToMonth,
|
|
3149
|
+
setDisplayMode,
|
|
3150
|
+
reset
|
|
3151
|
+
}),
|
|
3152
|
+
[
|
|
3153
|
+
selectedStartMs,
|
|
3154
|
+
selectedEndMs,
|
|
3155
|
+
displayedMonthMs,
|
|
3156
|
+
displayMode,
|
|
3157
|
+
yearRange,
|
|
3158
|
+
locale,
|
|
3159
|
+
selectableDates,
|
|
3160
|
+
selectDate,
|
|
3161
|
+
clearRange,
|
|
3162
|
+
navigateMonthAction,
|
|
3163
|
+
navigateToMonth,
|
|
3164
|
+
setDisplayMode,
|
|
3165
|
+
reset
|
|
3166
|
+
]
|
|
3167
|
+
);
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3170
|
+
// src/ui/date-time-pickers/time-picker/time-picker.tokens.ts
|
|
3171
|
+
var TP_COLORS = {
|
|
3172
|
+
// ── Clock Dial (TimePickerTokens) ─────────────────────────────────────────
|
|
3173
|
+
/** Dial background — SurfaceContainerHighest */
|
|
3174
|
+
clockDial: "var(--md-sys-color-surface-container-highest)",
|
|
3175
|
+
/** Selected number text — OnPrimary */
|
|
3176
|
+
clockDialSelected: "var(--md-sys-color-on-primary)",
|
|
3177
|
+
/** Unselected number text — OnSurface */
|
|
3178
|
+
clockDialUnselected: "var(--md-sys-color-on-surface)",
|
|
3179
|
+
/** Selector handle circle — Primary */
|
|
3180
|
+
selectorHandle: "var(--md-sys-color-primary)",
|
|
3181
|
+
/** Selector track line — Primary */
|
|
3182
|
+
selectorTrack: "var(--md-sys-color-primary)",
|
|
3183
|
+
/** Selector center dot — Primary */
|
|
3184
|
+
selectorCenter: "var(--md-sys-color-primary)",
|
|
3185
|
+
// ── Container ─────────────────────────────────────────────────────────────
|
|
3186
|
+
/** Picker/Input container — SurfaceContainerHigh */
|
|
3187
|
+
container: "var(--md-sys-color-surface-container-high)",
|
|
3188
|
+
// ── Time Selector Buttons (hour/minute display) ───────────────────────────
|
|
3189
|
+
/** Selected selector (hour/min button) — PrimaryContainer */
|
|
3190
|
+
timeSelectorSelected: "var(--md-sys-color-primary-container)",
|
|
3191
|
+
/** Unselected selector — SurfaceContainerHighest */
|
|
3192
|
+
timeSelectorUnselected: "var(--md-sys-color-surface-container-highest)",
|
|
3193
|
+
/** Selected selector text — OnPrimaryContainer */
|
|
3194
|
+
timeSelectorSelectedText: "var(--md-sys-color-on-primary-container)",
|
|
3195
|
+
/** Unselected selector text — OnSurface */
|
|
3196
|
+
timeSelectorUnselectedText: "var(--md-sys-color-on-surface)",
|
|
3197
|
+
// ── Period Selector AM/PM (updated flag = true → PrimaryContainer) ────────
|
|
3198
|
+
/** AM/PM selected background — TertiaryContainer */
|
|
3199
|
+
periodSelected: "var(--md-sys-color-tertiary-container)",
|
|
3200
|
+
/** AM/PM unselected background — transparent */
|
|
3201
|
+
periodUnselected: "transparent",
|
|
3202
|
+
/** AM/PM selected text — OnTertiaryContainer */
|
|
3203
|
+
periodSelectedText: "var(--md-sys-color-on-tertiary-container)",
|
|
3204
|
+
/** AM/PM unselected text — OnSurfaceVariant */
|
|
3205
|
+
periodUnselectedText: "var(--md-sys-color-on-surface-variant)",
|
|
3206
|
+
/** AM/PM border — Outline */
|
|
3207
|
+
periodOutline: "var(--md-sys-color-outline)",
|
|
3208
|
+
// ── Time Field (TimeInput mode, TimeInputTokens) ───────────────────────────
|
|
3209
|
+
/** Time field default background — SurfaceContainerHighest */
|
|
3210
|
+
timeField: "var(--md-sys-color-surface-container-highest)",
|
|
3211
|
+
/** Time field focused background — PrimaryContainer */
|
|
3212
|
+
timeFieldFocus: "var(--md-sys-color-primary-container)",
|
|
3213
|
+
/** Time field focused text — OnPrimaryContainer */
|
|
3214
|
+
timeFieldFocusText: "var(--md-sys-color-on-primary-container)",
|
|
3215
|
+
/** Time field focus outline — Primary */
|
|
3216
|
+
timeFieldFocusOutline: "var(--md-sys-color-primary)",
|
|
3217
|
+
/** Time field default text — OnSurface */
|
|
3218
|
+
timeFieldText: "var(--md-sys-color-on-surface)",
|
|
3219
|
+
/** ":" separator — OnSurface */
|
|
3220
|
+
separator: "var(--md-sys-color-on-surface)",
|
|
3221
|
+
/** Headline label ("Select time") — OnSurfaceVariant */
|
|
3222
|
+
headline: "var(--md-sys-color-on-surface-variant)"
|
|
3223
|
+
};
|
|
3224
|
+
var TP_CLASSES = {
|
|
3225
|
+
// ── Container ─────────────────────────────────────────────────────────────
|
|
3226
|
+
/** Main picker/input container */
|
|
3227
|
+
container: "bg-m3-surface-container-high rounded-m3-xl select-none",
|
|
3228
|
+
// ── Time Selector Buttons ─────────────────────────────────────────────────
|
|
3229
|
+
/** Hour/minute selector button — selected */
|
|
3230
|
+
timeSelectorSelected: "bg-m3-primary-container text-m3-on-primary-container",
|
|
3231
|
+
/** Hour/minute selector button — unselected */
|
|
3232
|
+
timeSelectorUnselected: "bg-m3-surface-container-highest text-m3-on-surface",
|
|
3233
|
+
// ── Period Selector ───────────────────────────────────────────────────────
|
|
3234
|
+
/** AM/PM button — selected */
|
|
3235
|
+
periodSelected: "bg-m3-primary-container text-m3-on-primary-container",
|
|
3236
|
+
/** AM/PM button — unselected */
|
|
3237
|
+
periodUnselected: "bg-transparent text-m3-on-surface-variant",
|
|
3238
|
+
// ── Time Field (input mode) ────────────────────────────────────────────────
|
|
3239
|
+
/** Time input field — default */
|
|
3240
|
+
timeField: "bg-m3-surface-container-highest text-m3-on-surface",
|
|
3241
|
+
/** Time input field — focused */
|
|
3242
|
+
timeFieldFocused: "bg-m3-primary-container text-m3-on-primary-container ring-2 ring-m3-primary",
|
|
3243
|
+
// ── Clock Dial ─────────────────────────────────────────────────────────────
|
|
3244
|
+
/** Clock dial background circle */
|
|
3245
|
+
clockDial: "fill-[var(--md-sys-color-surface-container-highest)]",
|
|
3246
|
+
/** Selected number on dial */
|
|
3247
|
+
clockDialSelectedText: "fill-[var(--md-sys-color-on-primary)]",
|
|
3248
|
+
/** Unselected number on dial */
|
|
3249
|
+
clockDialUnselectedText: "fill-[var(--md-sys-color-on-surface)]",
|
|
3250
|
+
/** Selector handle, track, center dot */
|
|
3251
|
+
selectorPrimary: "fill-m3-primary stroke-m3-primary"
|
|
3252
|
+
};
|
|
3253
|
+
var TP_SHAPE = {
|
|
3254
|
+
/** Dialog container — CornerExtraLarge = 28px */
|
|
3255
|
+
container: "rounded-m3-xl",
|
|
3256
|
+
/** Hour/minute selector button — CornerSmall = 8px */
|
|
3257
|
+
timeSelector: "rounded-m3-sm",
|
|
3258
|
+
/** Period (AM/PM) container — CornerSmall = 8px */
|
|
3259
|
+
periodSelector: "rounded-m3-sm",
|
|
3260
|
+
/** Clock dial circle — CornerFull */
|
|
3261
|
+
clockDial: "rounded-m3-full",
|
|
3262
|
+
/** Time field — CornerSmall = 8px */
|
|
3263
|
+
timeField: "rounded-m3-sm"
|
|
3264
|
+
};
|
|
3265
|
+
var TP_SIZE = {
|
|
3266
|
+
// ── Clock Dial (TimePickerTokens) ─────────────────────────────────────────
|
|
3267
|
+
/** ClockDialContainerSize = 256dp */
|
|
3268
|
+
clockDialSize: 256,
|
|
3269
|
+
/** ClockDialSelectorHandleContainerSize = 48dp */
|
|
3270
|
+
selectorHandleSize: 48,
|
|
3271
|
+
/** ClockDialSelectorCenterContainerSize = 8dp */
|
|
3272
|
+
selectorCenterSize: 8,
|
|
3273
|
+
/** ClockDialSelectorTrackContainerWidth = 2dp */
|
|
3274
|
+
selectorTrackWidth: 2,
|
|
3275
|
+
// ── Time Selector (TimeSelectorContainer) ─────────────────────────────────
|
|
3276
|
+
/** TimeSelectorContainerWidth = 96dp */
|
|
3277
|
+
timeSelectorWidth: 96,
|
|
3278
|
+
/** TimeSelectorContainerHeight = 80dp */
|
|
3279
|
+
timeSelectorHeight: 80,
|
|
3280
|
+
/** TimeSelector24HVerticalContainerWidth = 114dp (24h mode) */
|
|
3281
|
+
timeSelector24hWidth: 114,
|
|
3282
|
+
// ── Period Selector (Picker mode) ─────────────────────────────────────────
|
|
3283
|
+
/** PeriodSelectorVerticalContainerWidth = 52dp */
|
|
3284
|
+
periodSelectorVerticalWidth: 52,
|
|
3285
|
+
/** PeriodSelectorVerticalContainerHeight = 80dp */
|
|
3286
|
+
periodSelectorVerticalHeight: 80,
|
|
3287
|
+
/** PeriodSelectorHorizontalContainerWidth = 216dp */
|
|
3288
|
+
periodSelectorHorizWidth: 216,
|
|
3289
|
+
/** PeriodSelectorHorizontalContainerHeight = 38dp */
|
|
3290
|
+
periodSelectorHorizHeight: 38,
|
|
3291
|
+
// ── Time Field (Input mode, TimeInputTokens) ───────────────────────────────
|
|
3292
|
+
/** TimeFieldContainerWidth = 96dp */
|
|
3293
|
+
timeFieldWidth: 96,
|
|
3294
|
+
/** TimeFieldContainerHeight = 72dp */
|
|
3295
|
+
timeFieldHeight: 72,
|
|
3296
|
+
/** PeriodSelectorContainerHeight (Input mode) = 72dp */
|
|
3297
|
+
periodInputHeight: 72,
|
|
3298
|
+
/** PeriodSelectorContainerWidth (Input mode) = 52dp */
|
|
3299
|
+
periodInputWidth: 52
|
|
3300
|
+
};
|
|
3301
|
+
var PeriodSelector = ({
|
|
3302
|
+
state,
|
|
3303
|
+
layout = "vertical",
|
|
3304
|
+
style,
|
|
3305
|
+
className
|
|
3306
|
+
}) => {
|
|
3307
|
+
if (state.is24hour) return null;
|
|
3308
|
+
const { isPm, isHourInputValid, setIsPm } = state;
|
|
3309
|
+
const handleAmClick = () => {
|
|
3310
|
+
if (isPm && isHourInputValid) {
|
|
3311
|
+
setIsPm(false);
|
|
3312
|
+
}
|
|
3313
|
+
};
|
|
3314
|
+
const handlePmClick = () => {
|
|
3315
|
+
if (!isPm && isHourInputValid) {
|
|
3316
|
+
setIsPm(true);
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
const isVertical = layout === "vertical";
|
|
3320
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3321
|
+
"fieldset",
|
|
3322
|
+
{
|
|
3323
|
+
"aria-label": "AM/PM",
|
|
3324
|
+
style: __spreadValues({
|
|
3325
|
+
width: isVertical ? TP_SIZE.periodSelectorVerticalWidth : TP_SIZE.periodSelectorHorizWidth,
|
|
3326
|
+
height: isVertical ? TP_SIZE.periodSelectorVerticalHeight : TP_SIZE.periodSelectorHorizHeight
|
|
3327
|
+
}, style),
|
|
3328
|
+
className: cn(
|
|
3329
|
+
// Layout
|
|
3330
|
+
isVertical ? "flex flex-col" : "flex flex-row",
|
|
3331
|
+
"gap-0 overflow-hidden",
|
|
3332
|
+
// Container shape (CornerSmall = rounded-m3-sm)
|
|
3333
|
+
"rounded-m3-sm",
|
|
3334
|
+
// Border (period selector outline — updated toggle uses border on container)
|
|
3335
|
+
"border border-m3-outline",
|
|
3336
|
+
className
|
|
3337
|
+
),
|
|
3338
|
+
children: [
|
|
3339
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3340
|
+
PeriodButton,
|
|
3341
|
+
{
|
|
3342
|
+
label: "AM",
|
|
3343
|
+
isSelected: !isPm,
|
|
3344
|
+
onClick: handleAmClick,
|
|
3345
|
+
isFirst: true,
|
|
3346
|
+
isVertical
|
|
3347
|
+
}
|
|
3348
|
+
),
|
|
3349
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3350
|
+
PeriodButton,
|
|
3351
|
+
{
|
|
3352
|
+
label: "PM",
|
|
3353
|
+
isSelected: isPm,
|
|
3354
|
+
onClick: handlePmClick,
|
|
3355
|
+
isFirst: false,
|
|
3356
|
+
isVertical
|
|
3357
|
+
}
|
|
3358
|
+
)
|
|
3359
|
+
]
|
|
3360
|
+
}
|
|
3361
|
+
);
|
|
3362
|
+
};
|
|
3363
|
+
PeriodSelector.displayName = "PeriodSelector";
|
|
3364
|
+
var PeriodButton = ({
|
|
3365
|
+
label,
|
|
3366
|
+
isSelected,
|
|
3367
|
+
onClick,
|
|
3368
|
+
isFirst,
|
|
3369
|
+
isVertical
|
|
3370
|
+
}) => {
|
|
3371
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3372
|
+
"button",
|
|
3373
|
+
{
|
|
3374
|
+
type: "button",
|
|
3375
|
+
"aria-pressed": isSelected,
|
|
3376
|
+
"aria-label": label,
|
|
3377
|
+
onClick,
|
|
3378
|
+
className: cn(
|
|
3379
|
+
// Layout
|
|
3380
|
+
"flex-1 flex items-center justify-center",
|
|
3381
|
+
"min-w-0 min-h-0",
|
|
3382
|
+
// Typography — TitleMedium equivalent (16px, medium weight)
|
|
3383
|
+
"text-[16px] leading-none",
|
|
3384
|
+
// Selected state — from PeriodToggleImpl (useUpdatedToggle = true)
|
|
3385
|
+
isSelected ? [
|
|
3386
|
+
"bg-m3-tertiary-container text-m3-on-tertiary-container",
|
|
3387
|
+
"font-bold"
|
|
3388
|
+
] : ["bg-transparent text-m3-on-surface-variant", "font-medium"],
|
|
3389
|
+
// Divider between buttons via border
|
|
3390
|
+
!isFirst && isVertical && "border-t border-m3-outline",
|
|
3391
|
+
!isFirst && !isVertical && "border-l border-m3-outline",
|
|
3392
|
+
// Interaction
|
|
3393
|
+
"cursor-pointer transition-colors transition-m3-fast-effects",
|
|
3394
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-m3-primary"
|
|
3395
|
+
),
|
|
3396
|
+
children: label
|
|
3397
|
+
}
|
|
3398
|
+
);
|
|
3399
|
+
};
|
|
3400
|
+
var TimeField = (props) => {
|
|
3401
|
+
if (props.mode === "selector") {
|
|
3402
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectorField, __spreadValues({}, props));
|
|
3403
|
+
}
|
|
3404
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InputField, __spreadValues({}, props));
|
|
3405
|
+
};
|
|
3406
|
+
TimeField.displayName = "TimeField";
|
|
3407
|
+
var SelectorField = ({
|
|
3408
|
+
value,
|
|
3409
|
+
field,
|
|
3410
|
+
selection,
|
|
3411
|
+
onActivate,
|
|
3412
|
+
className
|
|
3413
|
+
}) => {
|
|
3414
|
+
const isSelected = selection === field;
|
|
3415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3416
|
+
"button",
|
|
3417
|
+
{
|
|
3418
|
+
type: "button",
|
|
3419
|
+
"aria-label": field === "hour" ? "Hour" : "Minute",
|
|
3420
|
+
"aria-pressed": isSelected,
|
|
3421
|
+
onClick: onActivate,
|
|
3422
|
+
style: {
|
|
3423
|
+
width: TP_SIZE.timeSelectorWidth,
|
|
3424
|
+
height: TP_SIZE.timeSelectorHeight
|
|
3425
|
+
},
|
|
3426
|
+
className: cn(
|
|
3427
|
+
// Layout
|
|
3428
|
+
"flex items-center justify-center",
|
|
3429
|
+
"rounded-m3-sm",
|
|
3430
|
+
// Typography — DisplayLarge equivalent (57px)
|
|
3431
|
+
"text-[57px] font-normal leading-none tabular-nums",
|
|
3432
|
+
// State
|
|
3433
|
+
isSelected ? "bg-m3-primary-container text-m3-on-primary-container" : "bg-m3-surface-container-highest text-m3-on-surface",
|
|
3434
|
+
// Interaction
|
|
3435
|
+
"cursor-pointer transition-colors transition-m3-fast-effects",
|
|
3436
|
+
"hover:opacity-90 active:opacity-80",
|
|
3437
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-m3-primary",
|
|
3438
|
+
className
|
|
3439
|
+
),
|
|
3440
|
+
children: String(value).padStart(2, "0")
|
|
3441
|
+
}
|
|
3442
|
+
);
|
|
3443
|
+
};
|
|
3444
|
+
var InputField = ({
|
|
3445
|
+
value,
|
|
3446
|
+
field,
|
|
3447
|
+
isFocused,
|
|
3448
|
+
isValid,
|
|
3449
|
+
onChange,
|
|
3450
|
+
onAutoAdvance,
|
|
3451
|
+
onFocus,
|
|
3452
|
+
onBlur,
|
|
3453
|
+
className
|
|
3454
|
+
}) => {
|
|
3455
|
+
const [inputText, setInputText] = React17__namespace.useState(
|
|
3456
|
+
String(value).padStart(2, "0")
|
|
3457
|
+
);
|
|
3458
|
+
const inputRef = React17__namespace.useRef(null);
|
|
3459
|
+
React17__namespace.useEffect(() => {
|
|
3460
|
+
if (!isFocused) {
|
|
3461
|
+
setInputText(String(value).padStart(2, "0"));
|
|
3462
|
+
}
|
|
3463
|
+
}, [value, isFocused]);
|
|
3464
|
+
React17__namespace.useEffect(() => {
|
|
3465
|
+
var _a, _b;
|
|
3466
|
+
if (isFocused) {
|
|
3467
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
3468
|
+
(_b = inputRef.current) == null ? void 0 : _b.select();
|
|
3469
|
+
}
|
|
3470
|
+
}, [isFocused]);
|
|
3471
|
+
const handleChange = (e) => {
|
|
3472
|
+
const raw = e.target.value.replace(/\D/g, "");
|
|
3473
|
+
const limited = raw.slice(-2);
|
|
3474
|
+
setInputText(limited);
|
|
3475
|
+
const numVal = parseInt(limited, 10);
|
|
3476
|
+
if (!Number.isNaN(numVal)) {
|
|
3477
|
+
onChange(numVal);
|
|
3478
|
+
if (limited.length === 2) {
|
|
3479
|
+
onAutoAdvance == null ? void 0 : onAutoAdvance();
|
|
3480
|
+
}
|
|
3481
|
+
} else if (limited === "") {
|
|
3482
|
+
onChange(0);
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
const handleKeyDown = (e) => {
|
|
3486
|
+
const allowed = [
|
|
3487
|
+
"Backspace",
|
|
3488
|
+
"Delete",
|
|
3489
|
+
"Tab",
|
|
3490
|
+
"ArrowLeft",
|
|
3491
|
+
"ArrowRight",
|
|
3492
|
+
"Enter"
|
|
3493
|
+
];
|
|
3494
|
+
const isDigit = e.key >= "0" && e.key <= "9";
|
|
3495
|
+
if (!isDigit && !allowed.includes(e.key)) {
|
|
3496
|
+
e.preventDefault();
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
const handleFocus = (e) => {
|
|
3500
|
+
e.target.select();
|
|
3501
|
+
onFocus == null ? void 0 : onFocus();
|
|
3502
|
+
};
|
|
3503
|
+
const displayText = isFocused ? inputText : String(value).padStart(2, "0");
|
|
3504
|
+
const isError = isFocused && !isValid && inputText.length === 2;
|
|
3505
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3506
|
+
"div",
|
|
3507
|
+
{
|
|
3508
|
+
style: {
|
|
3509
|
+
width: TP_SIZE.timeFieldWidth,
|
|
3510
|
+
height: TP_SIZE.timeFieldHeight
|
|
3511
|
+
},
|
|
3512
|
+
className: cn(
|
|
3513
|
+
"relative flex items-center justify-center rounded-m3-sm",
|
|
3514
|
+
// Background state
|
|
3515
|
+
isFocused ? "bg-m3-primary-container" : "bg-m3-surface-container-highest",
|
|
3516
|
+
// Error border
|
|
3517
|
+
isError && "ring-2 ring-m3-error",
|
|
3518
|
+
// Focus outline (non-error)
|
|
3519
|
+
isFocused && !isError && "ring-2 ring-m3-primary",
|
|
3520
|
+
className
|
|
3521
|
+
),
|
|
3522
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3523
|
+
"input",
|
|
3524
|
+
{
|
|
3525
|
+
ref: inputRef,
|
|
3526
|
+
type: "text",
|
|
3527
|
+
inputMode: "numeric",
|
|
3528
|
+
value: displayText,
|
|
3529
|
+
maxLength: 2,
|
|
3530
|
+
"aria-label": field === "hour" ? "Hour" : "Minute",
|
|
3531
|
+
"aria-invalid": isError,
|
|
3532
|
+
onChange: handleChange,
|
|
3533
|
+
onKeyDown: handleKeyDown,
|
|
3534
|
+
onFocus: handleFocus,
|
|
3535
|
+
onBlur,
|
|
3536
|
+
className: cn(
|
|
3537
|
+
// Reset input styles
|
|
3538
|
+
"w-full h-full bg-transparent border-none outline-none",
|
|
3539
|
+
"text-center tabular-nums select-all",
|
|
3540
|
+
// Typography — DisplayMedium equivalent (45px)
|
|
3541
|
+
"text-[45px] font-normal leading-none",
|
|
3542
|
+
// Color
|
|
3543
|
+
isFocused ? "text-m3-on-primary-container" : "text-m3-on-surface",
|
|
3544
|
+
// Caret
|
|
3545
|
+
"caret-m3-primary"
|
|
3546
|
+
)
|
|
3547
|
+
}
|
|
3548
|
+
)
|
|
3549
|
+
}
|
|
3550
|
+
);
|
|
3551
|
+
};
|
|
3552
|
+
var TimeInput = ({ state, className }) => {
|
|
3553
|
+
const { is24hour, setHourInput, setMinuteInput, setSelection } = state;
|
|
3554
|
+
const [focusedField, setFocusedField] = React17__namespace.useState(null);
|
|
3555
|
+
const handleHourAutoAdvance = () => {
|
|
3556
|
+
setFocusedField("minute");
|
|
3557
|
+
setSelection("minute");
|
|
3558
|
+
};
|
|
3559
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3560
|
+
"div",
|
|
3561
|
+
{
|
|
3562
|
+
className: cn(
|
|
3563
|
+
"bg-m3-surface-container-high rounded-m3-xl",
|
|
3564
|
+
"flex flex-col",
|
|
3565
|
+
"p-6 gap-0 select-none",
|
|
3566
|
+
className
|
|
3567
|
+
),
|
|
3568
|
+
children: [
|
|
3569
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3570
|
+
"p",
|
|
3571
|
+
{
|
|
3572
|
+
className: "w-full text-left text-m3-on-surface-variant mb-5",
|
|
3573
|
+
style: { fontSize: "12px", fontWeight: 500, letterSpacing: "0.1em" },
|
|
3574
|
+
children: "Enter time"
|
|
3575
|
+
}
|
|
3576
|
+
),
|
|
3577
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-start gap-2", children: [
|
|
3578
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-1", children: [
|
|
3579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3580
|
+
TimeField,
|
|
3581
|
+
{
|
|
3582
|
+
mode: "input",
|
|
3583
|
+
value: state.hourInput,
|
|
3584
|
+
field: "hour",
|
|
3585
|
+
isFocused: focusedField === "hour",
|
|
3586
|
+
isValid: state.isHourInputValid,
|
|
3587
|
+
onChange: setHourInput,
|
|
3588
|
+
onAutoAdvance: handleHourAutoAdvance,
|
|
3589
|
+
onFocus: () => {
|
|
3590
|
+
setFocusedField("hour");
|
|
3591
|
+
setSelection("hour");
|
|
3592
|
+
},
|
|
3593
|
+
onBlur: () => setFocusedField(null)
|
|
3594
|
+
}
|
|
3595
|
+
),
|
|
3596
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-m3-on-surface-variant font-normal leading-none mt-1", children: "Hour" })
|
|
3597
|
+
] }),
|
|
3598
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3599
|
+
"span",
|
|
3600
|
+
{
|
|
3601
|
+
className: "text-m3-on-surface text-center self-start",
|
|
3602
|
+
style: {
|
|
3603
|
+
fontSize: "57px",
|
|
3604
|
+
fontWeight: 400,
|
|
3605
|
+
lineHeight: 1,
|
|
3606
|
+
width: 24,
|
|
3607
|
+
// Căn theo height của input field
|
|
3608
|
+
marginTop: `${(TP_SIZE.timeFieldHeight - 57) / 2}px`
|
|
3609
|
+
},
|
|
3610
|
+
"aria-hidden": true,
|
|
3611
|
+
children: ":"
|
|
3612
|
+
}
|
|
3613
|
+
),
|
|
3614
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-1", children: [
|
|
3615
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3616
|
+
TimeField,
|
|
3617
|
+
{
|
|
3618
|
+
mode: "input",
|
|
3619
|
+
value: state.minuteInput,
|
|
3620
|
+
field: "minute",
|
|
3621
|
+
isFocused: focusedField === "minute",
|
|
3622
|
+
isValid: state.isMinuteInputValid,
|
|
3623
|
+
onChange: setMinuteInput,
|
|
3624
|
+
onFocus: () => {
|
|
3625
|
+
setFocusedField("minute");
|
|
3626
|
+
setSelection("minute");
|
|
3627
|
+
},
|
|
3628
|
+
onBlur: () => setFocusedField(null)
|
|
3629
|
+
}
|
|
3630
|
+
),
|
|
3631
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-m3-on-surface-variant font-normal leading-none mt-1", children: "Minute" })
|
|
3632
|
+
] }),
|
|
3633
|
+
!is24hour && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3634
|
+
PeriodSelector,
|
|
3635
|
+
{
|
|
3636
|
+
state,
|
|
3637
|
+
layout: "vertical",
|
|
3638
|
+
className: "ml-2 self-start",
|
|
3639
|
+
style: {
|
|
3640
|
+
height: TP_SIZE.periodInputHeight,
|
|
3641
|
+
width: TP_SIZE.periodInputWidth
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
)
|
|
3645
|
+
] })
|
|
3646
|
+
]
|
|
3647
|
+
}
|
|
3648
|
+
);
|
|
3649
|
+
};
|
|
3650
|
+
TimeInput.displayName = "TimeInput";
|
|
3651
|
+
var FULL_CIRCLE = Math.PI * 2;
|
|
3652
|
+
var QUARTER_CIRCLE = Math.PI / 2;
|
|
3653
|
+
var RADIANS_PER_HOUR = FULL_CIRCLE / 12;
|
|
3654
|
+
var RADIANS_PER_MINUTE = FULL_CIRCLE / 60;
|
|
3655
|
+
var OUTER_CIRCLE_RATIO = 101 / TP_SIZE.clockDialSize;
|
|
3656
|
+
var INNER_CIRCLE_RATIO = 69 / TP_SIZE.clockDialSize;
|
|
3657
|
+
var CENTER = TP_SIZE.clockDialSize / 2;
|
|
3658
|
+
var OUTER_RADIUS = TP_SIZE.clockDialSize * OUTER_CIRCLE_RATIO;
|
|
3659
|
+
var INNER_RADIUS = TP_SIZE.clockDialSize * INNER_CIRCLE_RATIO;
|
|
3660
|
+
var HANDLE_RADIUS = TP_SIZE.selectorHandleSize / 2;
|
|
3661
|
+
var SELECTOR_GAP = 4;
|
|
3662
|
+
var getPositionOnDial = (index, total, radius) => {
|
|
3663
|
+
const angle = index / total * FULL_CIRCLE - QUARTER_CIRCLE;
|
|
3664
|
+
return {
|
|
3665
|
+
x: CENTER + radius * Math.cos(angle),
|
|
3666
|
+
y: CENTER + radius * Math.sin(angle)
|
|
3667
|
+
};
|
|
3668
|
+
};
|
|
3669
|
+
var buildHour12Numbers = () => Array.from({ length: 12 }, (_, i) => {
|
|
3670
|
+
const hour = i === 0 ? 12 : i;
|
|
3671
|
+
const pos = getPositionOnDial(i, 12, OUTER_RADIUS);
|
|
3672
|
+
return __spreadProps(__spreadValues({ value: hour }, pos), { radius: OUTER_RADIUS });
|
|
3673
|
+
});
|
|
3674
|
+
var buildHour24Numbers = () => {
|
|
3675
|
+
const outer = Array.from({ length: 12 }, (_, i) => {
|
|
3676
|
+
const hour = i;
|
|
3677
|
+
const pos = getPositionOnDial(i, 12, OUTER_RADIUS);
|
|
3678
|
+
return __spreadProps(__spreadValues({ value: hour }, pos), { radius: OUTER_RADIUS });
|
|
3679
|
+
});
|
|
3680
|
+
const inner = Array.from({ length: 12 }, (_, i) => {
|
|
3681
|
+
const hour = i + 12;
|
|
3682
|
+
const pos = getPositionOnDial(i, 12, INNER_RADIUS);
|
|
3683
|
+
return __spreadProps(__spreadValues({ value: hour }, pos), { radius: INNER_RADIUS });
|
|
3684
|
+
});
|
|
3685
|
+
return [...outer, ...inner];
|
|
3686
|
+
};
|
|
3687
|
+
var buildMinuteNumbers = () => Array.from({ length: 12 }, (_, i) => {
|
|
3688
|
+
const minute = i * 5;
|
|
3689
|
+
const pos = getPositionOnDial(i, 12, OUTER_RADIUS);
|
|
3690
|
+
return __spreadProps(__spreadValues({ value: minute }, pos), { radius: OUTER_RADIUS });
|
|
3691
|
+
});
|
|
3692
|
+
var getAngleFromPointer = (x, y) => {
|
|
3693
|
+
return Math.atan2(y - CENTER, x - CENTER);
|
|
3694
|
+
};
|
|
3695
|
+
var normalizeAngle = (angle) => {
|
|
3696
|
+
let a = angle % FULL_CIRCLE;
|
|
3697
|
+
if (a < 0) a += FULL_CIRCLE;
|
|
3698
|
+
return a;
|
|
3699
|
+
};
|
|
3700
|
+
var angleToHour12 = (angle) => {
|
|
3701
|
+
const hourOffset = RADIANS_PER_HOUR / 2;
|
|
3702
|
+
const totalOffset = hourOffset + QUARTER_CIRCLE;
|
|
3703
|
+
const hour = Math.round((angle + totalOffset) / RADIANS_PER_HOUR) % 12;
|
|
3704
|
+
return hour === 0 ? 12 : hour;
|
|
3705
|
+
};
|
|
3706
|
+
var angleToMinute = (angle, snap = true) => {
|
|
3707
|
+
if (snap) {
|
|
3708
|
+
const minuteOffset = RADIANS_PER_MINUTE / 2;
|
|
3709
|
+
const totalOffset = minuteOffset + QUARTER_CIRCLE;
|
|
3710
|
+
const raw2 = Math.round((angle + totalOffset) / RADIANS_PER_MINUTE) % 60;
|
|
3711
|
+
return raw2 < 0 ? raw2 + 60 : raw2;
|
|
3712
|
+
}
|
|
3713
|
+
const normalized = normalizeAngle(angle + QUARTER_CIRCLE);
|
|
3714
|
+
const raw = Math.round(normalized / FULL_CIRCLE * 60) % 60;
|
|
3715
|
+
return raw < 0 ? raw + 60 : raw;
|
|
3716
|
+
};
|
|
3717
|
+
var getSelectorPosition = (angle, selection, is24hour, isPm) => {
|
|
3718
|
+
const useInner = is24hour && isPm && selection === "hour";
|
|
3719
|
+
const baseRadius = useInner ? INNER_RADIUS : OUTER_RADIUS;
|
|
3720
|
+
const length = Math.min(baseRadius, CENTER - HANDLE_RADIUS - SELECTOR_GAP);
|
|
3721
|
+
return {
|
|
3722
|
+
x: CENTER + length * Math.cos(angle),
|
|
3723
|
+
y: CENTER + length * Math.sin(angle)
|
|
3724
|
+
};
|
|
3725
|
+
};
|
|
3726
|
+
var valueToAngle = (value, selection) => {
|
|
3727
|
+
if (selection === "hour") {
|
|
3728
|
+
return RADIANS_PER_HOUR * (value % 12) - QUARTER_CIRCLE;
|
|
3729
|
+
}
|
|
3730
|
+
return RADIANS_PER_MINUTE * value - QUARTER_CIRCLE;
|
|
3731
|
+
};
|
|
3732
|
+
var ClockDial = ({
|
|
3733
|
+
state,
|
|
3734
|
+
autoSwitchToMinute = true,
|
|
3735
|
+
style,
|
|
3736
|
+
className
|
|
3737
|
+
}) => {
|
|
3738
|
+
const {
|
|
3739
|
+
selection,
|
|
3740
|
+
is24hour,
|
|
3741
|
+
isPm,
|
|
3742
|
+
hour,
|
|
3743
|
+
minute,
|
|
3744
|
+
setHour,
|
|
3745
|
+
setMinute,
|
|
3746
|
+
setSelection
|
|
3747
|
+
} = state;
|
|
3748
|
+
const displayAngle = React17__namespace.useMemo(() => {
|
|
3749
|
+
if (selection === "hour") {
|
|
3750
|
+
return valueToAngle(hour, "hour");
|
|
3751
|
+
}
|
|
3752
|
+
return valueToAngle(minute, "minute");
|
|
3753
|
+
}, [selection, hour, minute]);
|
|
3754
|
+
const selectorPos = React17__namespace.useMemo(
|
|
3755
|
+
() => getSelectorPosition(displayAngle, selection, is24hour, isPm),
|
|
3756
|
+
[displayAngle, selection, is24hour, isPm]
|
|
3757
|
+
);
|
|
3758
|
+
const trackEnd = React17__namespace.useMemo(() => {
|
|
3759
|
+
const dx = selectorPos.x - CENTER;
|
|
3760
|
+
const dy = selectorPos.y - CENTER;
|
|
3761
|
+
const length = Math.hypot(dx, dy);
|
|
3762
|
+
if (length === 0) return selectorPos;
|
|
3763
|
+
return {
|
|
3764
|
+
x: selectorPos.x - dx / length * HANDLE_RADIUS,
|
|
3765
|
+
y: selectorPos.y - dy / length * HANDLE_RADIUS
|
|
3766
|
+
};
|
|
3767
|
+
}, [selectorPos]);
|
|
3768
|
+
const numbers = React17__namespace.useMemo(() => {
|
|
3769
|
+
if (selection === "minute") return buildMinuteNumbers();
|
|
3770
|
+
if (is24hour) return buildHour24Numbers();
|
|
3771
|
+
return buildHour12Numbers();
|
|
3772
|
+
}, [selection, is24hour]);
|
|
3773
|
+
const isDragging = React17__namespace.useRef(false);
|
|
3774
|
+
const svgRef = React17__namespace.useRef(null);
|
|
3775
|
+
const getSVGPoint = (e) => {
|
|
3776
|
+
const svg = svgRef.current;
|
|
3777
|
+
if (!svg) return { x: e.clientX, y: e.clientY };
|
|
3778
|
+
const rect = svg.getBoundingClientRect();
|
|
3779
|
+
const scaleX = TP_SIZE.clockDialSize / rect.width;
|
|
3780
|
+
const scaleY = TP_SIZE.clockDialSize / rect.height;
|
|
3781
|
+
return {
|
|
3782
|
+
x: (e.clientX - rect.left) * scaleX,
|
|
3783
|
+
y: (e.clientY - rect.top) * scaleY
|
|
3784
|
+
};
|
|
3785
|
+
};
|
|
3786
|
+
const handlePosition = (x, y, isPointerUp = false) => {
|
|
3787
|
+
const angle = getAngleFromPointer(x, y);
|
|
3788
|
+
if (selection === "hour") {
|
|
3789
|
+
let newHour;
|
|
3790
|
+
if (is24hour) {
|
|
3791
|
+
const dist = Math.sqrt((x - CENTER) ** 2 + (y - CENTER) ** 2);
|
|
3792
|
+
const isPmHour = dist < (OUTER_RADIUS + INNER_RADIUS) / 2;
|
|
3793
|
+
const hour12 = angleToHour12(angle);
|
|
3794
|
+
newHour = isPmHour ? hour12 + 12 : hour12 === 12 ? 0 : hour12;
|
|
3795
|
+
} else {
|
|
3796
|
+
const hour12 = angleToHour12(angle);
|
|
3797
|
+
newHour = hour12 === 12 ? isPm ? 12 : 0 : isPm ? hour12 + 12 : hour12;
|
|
3798
|
+
}
|
|
3799
|
+
setHour(newHour);
|
|
3800
|
+
if (isPointerUp && autoSwitchToMinute) {
|
|
3801
|
+
setTimeout(() => setSelection("minute"), 100);
|
|
3802
|
+
}
|
|
3803
|
+
} else {
|
|
3804
|
+
const newMinute = angleToMinute(angle, !isDragging.current);
|
|
3805
|
+
setMinute(newMinute);
|
|
3806
|
+
}
|
|
3807
|
+
};
|
|
3808
|
+
const handlePointerDown = (e) => {
|
|
3809
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
3810
|
+
isDragging.current = false;
|
|
3811
|
+
const { x, y } = getSVGPoint(e);
|
|
3812
|
+
handlePosition(x, y);
|
|
3813
|
+
};
|
|
3814
|
+
const handlePointerMove = (e) => {
|
|
3815
|
+
if (e.buttons === 0) return;
|
|
3816
|
+
isDragging.current = true;
|
|
3817
|
+
const { x, y } = getSVGPoint(e);
|
|
3818
|
+
handlePosition(x, y);
|
|
3819
|
+
};
|
|
3820
|
+
const handlePointerUp = (e) => {
|
|
3821
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
3822
|
+
const { x, y } = getSVGPoint(e);
|
|
3823
|
+
handlePosition(x, y, true);
|
|
3824
|
+
isDragging.current = false;
|
|
3825
|
+
};
|
|
3826
|
+
const getDisplayHour = () => {
|
|
3827
|
+
if (is24hour) return hour;
|
|
3828
|
+
return hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
|
|
3829
|
+
};
|
|
3830
|
+
const isNumberHighlighted = (num) => {
|
|
3831
|
+
if (selection === "hour") return num.value === getDisplayHour();
|
|
3832
|
+
const dx = selectorPos.x - num.x;
|
|
3833
|
+
const dy = selectorPos.y - num.y;
|
|
3834
|
+
return Math.sqrt(dx * dx + dy * dy) < HANDLE_RADIUS;
|
|
3835
|
+
};
|
|
3836
|
+
const isNumberAtHandle = (num) => {
|
|
3837
|
+
if (selection === "hour") return num.value === getDisplayHour();
|
|
3838
|
+
return false;
|
|
3839
|
+
};
|
|
3840
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3841
|
+
"svg",
|
|
3842
|
+
{
|
|
3843
|
+
ref: svgRef,
|
|
3844
|
+
width: TP_SIZE.clockDialSize,
|
|
3845
|
+
height: TP_SIZE.clockDialSize,
|
|
3846
|
+
viewBox: `0 0 ${TP_SIZE.clockDialSize} ${TP_SIZE.clockDialSize}`,
|
|
3847
|
+
role: "img",
|
|
3848
|
+
"aria-label": `Clock face, ${selection === "hour" ? "select hour" : "select minute"}`,
|
|
3849
|
+
style,
|
|
3850
|
+
overflow: "visible",
|
|
3851
|
+
className: cn("touch-none select-none cursor-pointer", className),
|
|
3852
|
+
onPointerDown: handlePointerDown,
|
|
3853
|
+
onPointerMove: handlePointerMove,
|
|
3854
|
+
onPointerUp: handlePointerUp,
|
|
3855
|
+
children: [
|
|
3856
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: CENTER, cy: CENTER, r: CENTER, fill: TP_COLORS.clockDial }),
|
|
3857
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3858
|
+
"line",
|
|
3859
|
+
{
|
|
3860
|
+
x1: CENTER,
|
|
3861
|
+
y1: CENTER,
|
|
3862
|
+
x2: trackEnd.x,
|
|
3863
|
+
y2: trackEnd.y,
|
|
3864
|
+
stroke: TP_COLORS.selectorTrack,
|
|
3865
|
+
strokeWidth: TP_SIZE.selectorTrackWidth,
|
|
3866
|
+
strokeLinecap: "round"
|
|
3867
|
+
}
|
|
3868
|
+
),
|
|
3869
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3870
|
+
"circle",
|
|
3871
|
+
{
|
|
3872
|
+
cx: selectorPos.x,
|
|
3873
|
+
cy: selectorPos.y,
|
|
3874
|
+
r: HANDLE_RADIUS,
|
|
3875
|
+
fill: TP_COLORS.selectorHandle
|
|
3876
|
+
}
|
|
3877
|
+
),
|
|
3878
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3879
|
+
"circle",
|
|
3880
|
+
{
|
|
3881
|
+
cx: CENTER,
|
|
3882
|
+
cy: CENTER,
|
|
3883
|
+
r: TP_SIZE.selectorCenterSize / 2,
|
|
3884
|
+
fill: TP_COLORS.selectorCenter
|
|
3885
|
+
}
|
|
3886
|
+
),
|
|
3887
|
+
numbers.map((num) => {
|
|
3888
|
+
const highlighted = isNumberHighlighted(num);
|
|
3889
|
+
const atHandle = isNumberAtHandle(num);
|
|
3890
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3891
|
+
"text",
|
|
3892
|
+
{
|
|
3893
|
+
x: atHandle ? selectorPos.x : num.x,
|
|
3894
|
+
y: atHandle ? selectorPos.y : num.y,
|
|
3895
|
+
textAnchor: "middle",
|
|
3896
|
+
dominantBaseline: "central",
|
|
3897
|
+
fontSize: is24hour && num.radius === INNER_RADIUS ? 12 : 14,
|
|
3898
|
+
fontWeight: highlighted ? "600" : "400",
|
|
3899
|
+
fill: highlighted ? TP_COLORS.clockDialSelected : TP_COLORS.clockDialUnselected,
|
|
3900
|
+
"aria-label": String(num.value),
|
|
3901
|
+
className: "pointer-events-none",
|
|
3902
|
+
children: selection === "hour" && is24hour ? String(num.value).padStart(2, "0") : num.value
|
|
3903
|
+
},
|
|
3904
|
+
`${num.value}-${num.radius}`
|
|
3905
|
+
);
|
|
3906
|
+
})
|
|
3907
|
+
]
|
|
3908
|
+
}
|
|
3909
|
+
);
|
|
3910
|
+
};
|
|
3911
|
+
ClockDial.displayName = "ClockDial";
|
|
3912
|
+
var getHourForDisplay = (state) => {
|
|
3913
|
+
const { hour, is24hour, isPm } = state;
|
|
3914
|
+
if (is24hour) return hour;
|
|
3915
|
+
if (hour % 12 === 0) return 12;
|
|
3916
|
+
return isPm ? hour - 12 : hour;
|
|
3917
|
+
};
|
|
3918
|
+
var getAutoLayout = () => {
|
|
3919
|
+
if (typeof window === "undefined") return "vertical";
|
|
3920
|
+
const { innerHeight, innerWidth } = window;
|
|
3921
|
+
return innerWidth >= 600 && innerHeight >= 300 && innerWidth >= innerHeight ? "horizontal" : "vertical";
|
|
3922
|
+
};
|
|
3923
|
+
var useResolvedLayout = (layout) => {
|
|
3924
|
+
const [autoLayout, setAutoLayout] = React17__namespace.useState("vertical");
|
|
3925
|
+
React17__namespace.useEffect(() => {
|
|
3926
|
+
if (layout !== "auto") return;
|
|
3927
|
+
const updateLayout = () => setAutoLayout(getAutoLayout());
|
|
3928
|
+
updateLayout();
|
|
3929
|
+
window.addEventListener("resize", updateLayout);
|
|
3930
|
+
return () => window.removeEventListener("resize", updateLayout);
|
|
3931
|
+
}, [layout]);
|
|
3932
|
+
return layout === "auto" ? autoLayout : layout;
|
|
3933
|
+
};
|
|
3934
|
+
var ClockDisplay = ({ state, layout }) => {
|
|
3935
|
+
const { selection, setSelection, is24hour } = state;
|
|
3936
|
+
const periodLayout = layout === "horizontal" ? "horizontal" : "vertical";
|
|
3937
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3938
|
+
"div",
|
|
3939
|
+
{
|
|
3940
|
+
className: cn(
|
|
3941
|
+
"flex",
|
|
3942
|
+
layout === "horizontal" ? "flex-col items-start justify-center" : "flex-row items-center justify-center"
|
|
3943
|
+
),
|
|
3944
|
+
children: [
|
|
3945
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
3946
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3947
|
+
TimeField,
|
|
3948
|
+
{
|
|
3949
|
+
mode: "selector",
|
|
3950
|
+
value: getHourForDisplay(state),
|
|
3951
|
+
field: "hour",
|
|
3952
|
+
selection,
|
|
3953
|
+
onActivate: () => setSelection("hour")
|
|
3954
|
+
}
|
|
3955
|
+
),
|
|
3956
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3957
|
+
"span",
|
|
3958
|
+
{
|
|
3959
|
+
"aria-hidden": true,
|
|
3960
|
+
className: "w-6 text-center text-[57px] leading-none font-normal text-m3-on-surface",
|
|
3961
|
+
children: ":"
|
|
3962
|
+
}
|
|
3963
|
+
),
|
|
3964
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3965
|
+
TimeField,
|
|
3966
|
+
{
|
|
3967
|
+
mode: "selector",
|
|
3968
|
+
value: state.minute,
|
|
3969
|
+
field: "minute",
|
|
3970
|
+
selection,
|
|
3971
|
+
onActivate: () => setSelection("minute")
|
|
3972
|
+
}
|
|
3973
|
+
)
|
|
3974
|
+
] }),
|
|
3975
|
+
!is24hour ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3976
|
+
PeriodSelector,
|
|
3977
|
+
{
|
|
3978
|
+
state,
|
|
3979
|
+
layout: periodLayout,
|
|
3980
|
+
className: layout === "horizontal" ? "mt-3" : "ml-3"
|
|
3981
|
+
}
|
|
3982
|
+
) : null
|
|
3983
|
+
]
|
|
3984
|
+
}
|
|
3985
|
+
);
|
|
3986
|
+
};
|
|
3987
|
+
var TimePicker = ({
|
|
3988
|
+
state,
|
|
3989
|
+
layout = "auto",
|
|
3990
|
+
className
|
|
3991
|
+
}) => {
|
|
3992
|
+
const resolvedLayout = useResolvedLayout(layout);
|
|
3993
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3994
|
+
"div",
|
|
3995
|
+
{
|
|
3996
|
+
"data-time-picker-layout": resolvedLayout,
|
|
3997
|
+
className: cn(
|
|
3998
|
+
"time-picker rounded-m3-xl bg-m3-surface-container-high p-6 select-none",
|
|
3999
|
+
className
|
|
4000
|
+
),
|
|
4001
|
+
children: [
|
|
4002
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-5 text-left text-[12px] font-medium tracking-[0.1em] text-m3-on-surface-variant", children: "Select time" }),
|
|
4003
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4004
|
+
"div",
|
|
4005
|
+
{
|
|
4006
|
+
className: cn(
|
|
4007
|
+
"flex",
|
|
4008
|
+
resolvedLayout === "horizontal" ? "flex-row items-center gap-[52px]" : "flex-col items-center gap-9"
|
|
4009
|
+
),
|
|
4010
|
+
children: [
|
|
4011
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockDisplay, { state, layout: resolvedLayout }),
|
|
4012
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4013
|
+
ClockDial,
|
|
4014
|
+
{
|
|
4015
|
+
state,
|
|
4016
|
+
autoSwitchToMinute: true,
|
|
4017
|
+
style: {
|
|
4018
|
+
width: TP_SIZE.clockDialSize,
|
|
4019
|
+
height: TP_SIZE.clockDialSize
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
)
|
|
4023
|
+
]
|
|
4024
|
+
}
|
|
4025
|
+
)
|
|
4026
|
+
]
|
|
4027
|
+
}
|
|
4028
|
+
);
|
|
4029
|
+
};
|
|
4030
|
+
TimePicker.displayName = "TimePicker";
|
|
4031
|
+
var TimePickerDialog = ({
|
|
4032
|
+
open,
|
|
4033
|
+
onDismiss,
|
|
4034
|
+
confirmButton,
|
|
4035
|
+
dismissButton,
|
|
4036
|
+
modeToggleButton,
|
|
4037
|
+
title = "Select time",
|
|
4038
|
+
children,
|
|
4039
|
+
className
|
|
4040
|
+
}) => {
|
|
4041
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: (v) => !v && onDismiss(), children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { open, children: [
|
|
4042
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Overlay, { asChild: true, forceMount: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4043
|
+
react.m.div,
|
|
4044
|
+
{
|
|
4045
|
+
className: "fixed inset-0 z-50 bg-m3-scrim/40",
|
|
4046
|
+
initial: PICKER_OVERLAY_ANIM.initial,
|
|
4047
|
+
animate: PICKER_OVERLAY_ANIM.animate,
|
|
4048
|
+
exit: PICKER_OVERLAY_ANIM.exit,
|
|
4049
|
+
onClick: onDismiss
|
|
4050
|
+
},
|
|
4051
|
+
"time-picker-overlay"
|
|
4052
|
+
) }),
|
|
4053
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4054
|
+
RadixDialog__namespace.Content,
|
|
4055
|
+
{
|
|
4056
|
+
asChild: true,
|
|
4057
|
+
forceMount: true,
|
|
4058
|
+
onEscapeKeyDown: onDismiss,
|
|
4059
|
+
onPointerDownOutside: (e) => e.preventDefault(),
|
|
4060
|
+
"aria-modal": true,
|
|
4061
|
+
"aria-describedby": void 0,
|
|
4062
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4063
|
+
react.m.div,
|
|
4064
|
+
{
|
|
4065
|
+
className: cn(
|
|
4066
|
+
// Positioning
|
|
4067
|
+
"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
4068
|
+
// Layout
|
|
4069
|
+
"flex flex-col",
|
|
4070
|
+
// MD3 Time Picker container tokens
|
|
4071
|
+
"bg-m3-surface-container-high",
|
|
4072
|
+
"rounded-m3-xl",
|
|
4073
|
+
"overflow-hidden",
|
|
4074
|
+
"max-w-[calc(100vw-32px)] max-h-[calc(100dvh-32px)]",
|
|
4075
|
+
// Elevation Level 3
|
|
4076
|
+
"elevation-3",
|
|
4077
|
+
className
|
|
4078
|
+
),
|
|
4079
|
+
initial: PICKER_CONTENT_ANIM.initial,
|
|
4080
|
+
animate: PICKER_CONTENT_ANIM.animate,
|
|
4081
|
+
exit: PICKER_CONTENT_ANIM.exit,
|
|
4082
|
+
children: [
|
|
4083
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadixDialog__namespace.Title, { className: "sr-only", children: title }),
|
|
4084
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children }),
|
|
4085
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-16 items-center gap-2 px-6 py-2", children: [
|
|
4086
|
+
modeToggleButton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: modeToggleButton }),
|
|
4087
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
|
|
4088
|
+
dismissButton,
|
|
4089
|
+
confirmButton
|
|
4090
|
+
] })
|
|
4091
|
+
]
|
|
4092
|
+
},
|
|
4093
|
+
"time-picker-content"
|
|
4094
|
+
)
|
|
4095
|
+
}
|
|
4096
|
+
)
|
|
4097
|
+
] }) });
|
|
4098
|
+
};
|
|
4099
|
+
TimePickerDialog.displayName = "TimePickerDialog";
|
|
4100
|
+
var clamp = (value, min, max) => Math.max(min, Math.min(max, value));
|
|
4101
|
+
var isValidHourInput = (h, is24hour) => is24hour ? h >= 0 && h <= 23 : h >= 1 && h <= 12;
|
|
4102
|
+
var isValidMinuteInput = (m11) => m11 >= 0 && m11 <= 59;
|
|
4103
|
+
var to24Hour = (hour12, isPm) => {
|
|
4104
|
+
if (isPm) {
|
|
4105
|
+
return hour12 === 12 ? 12 : hour12 + 12;
|
|
4106
|
+
}
|
|
4107
|
+
return hour12 === 12 ? 0 : hour12;
|
|
4108
|
+
};
|
|
4109
|
+
var to12Hour = (hour24) => {
|
|
4110
|
+
if (hour24 === 0) return 12;
|
|
4111
|
+
if (hour24 > 12) return hour24 - 12;
|
|
4112
|
+
return hour24;
|
|
4113
|
+
};
|
|
4114
|
+
var useTimePickerState = (options) => {
|
|
4115
|
+
var _a, _b, _c;
|
|
4116
|
+
const initialHour = clamp((_a = options == null ? void 0 : options.initialHour) != null ? _a : 0, 0, 23);
|
|
4117
|
+
const initialMinute = clamp((_b = options == null ? void 0 : options.initialMinute) != null ? _b : 0, 0, 59);
|
|
4118
|
+
const is24hour = (_c = options == null ? void 0 : options.is24hour) != null ? _c : false;
|
|
4119
|
+
const [hour, setHourState] = React17.useState(initialHour);
|
|
4120
|
+
const [minute, setMinuteState] = React17.useState(initialMinute);
|
|
4121
|
+
const [hourInput, setHourInputState] = React17.useState(
|
|
4122
|
+
is24hour ? initialHour : to12Hour(initialHour)
|
|
4123
|
+
);
|
|
4124
|
+
const [minuteInput, setMinuteInputState] = React17.useState(initialMinute);
|
|
4125
|
+
const [selection, setSelectionState] = React17.useState("hour");
|
|
4126
|
+
const isPm = hour >= 12;
|
|
4127
|
+
const isHourInputValid = isValidHourInput(hourInput, is24hour);
|
|
4128
|
+
const isMinuteInputValid = isValidMinuteInput(minuteInput);
|
|
4129
|
+
const isInputValid = isHourInputValid && isMinuteInputValid;
|
|
4130
|
+
const setHour = React17.useCallback(
|
|
4131
|
+
(h) => {
|
|
4132
|
+
const clamped = clamp(h, 0, 23);
|
|
4133
|
+
setHourState(clamped);
|
|
4134
|
+
setHourInputState(is24hour ? clamped : to12Hour(clamped));
|
|
4135
|
+
},
|
|
4136
|
+
[is24hour]
|
|
4137
|
+
);
|
|
4138
|
+
const setMinute = React17.useCallback((m11) => {
|
|
4139
|
+
const clamped = clamp(m11, 0, 59);
|
|
4140
|
+
setMinuteState(clamped);
|
|
4141
|
+
setMinuteInputState(clamped);
|
|
4142
|
+
}, []);
|
|
4143
|
+
const setHourInput = React17.useCallback(
|
|
4144
|
+
(h) => {
|
|
4145
|
+
setHourInputState(h);
|
|
4146
|
+
if (isValidHourInput(h, is24hour)) {
|
|
4147
|
+
const h24 = is24hour ? h : to24Hour(h, isPm);
|
|
4148
|
+
setHourState(clamp(h24, 0, 23));
|
|
4149
|
+
}
|
|
4150
|
+
},
|
|
4151
|
+
[is24hour, isPm]
|
|
4152
|
+
);
|
|
4153
|
+
const setMinuteInput = React17.useCallback((m11) => {
|
|
4154
|
+
setMinuteInputState(m11);
|
|
4155
|
+
if (isValidMinuteInput(m11)) {
|
|
4156
|
+
setMinuteState(m11);
|
|
4157
|
+
}
|
|
4158
|
+
}, []);
|
|
4159
|
+
const setSelection = React17.useCallback((mode) => {
|
|
4160
|
+
setSelectionState(mode);
|
|
4161
|
+
}, []);
|
|
4162
|
+
const setIsPm = React17.useCallback((pm) => {
|
|
4163
|
+
setHourState((prev) => {
|
|
4164
|
+
const wasAlreadyPm = prev >= 12;
|
|
4165
|
+
if (pm === wasAlreadyPm) return prev;
|
|
4166
|
+
const newHour = pm ? prev + 12 : prev - 12;
|
|
4167
|
+
const clamped = clamp(newHour, 0, 23);
|
|
4168
|
+
setHourInputState(to12Hour(clamped));
|
|
4169
|
+
return clamped;
|
|
4170
|
+
});
|
|
4171
|
+
}, []);
|
|
4172
|
+
const reset = React17.useCallback(() => {
|
|
4173
|
+
setHourState(initialHour);
|
|
4174
|
+
setMinuteState(initialMinute);
|
|
4175
|
+
setHourInputState(is24hour ? initialHour : to12Hour(initialHour));
|
|
4176
|
+
setMinuteInputState(initialMinute);
|
|
4177
|
+
setSelectionState("hour");
|
|
4178
|
+
}, [initialHour, initialMinute, is24hour]);
|
|
4179
|
+
return React17.useMemo(
|
|
4180
|
+
() => ({
|
|
4181
|
+
hour,
|
|
4182
|
+
minute,
|
|
4183
|
+
hourInput,
|
|
4184
|
+
minuteInput,
|
|
4185
|
+
is24hour,
|
|
4186
|
+
selection,
|
|
4187
|
+
isInputValid,
|
|
4188
|
+
isHourInputValid,
|
|
4189
|
+
isMinuteInputValid,
|
|
4190
|
+
isPm,
|
|
4191
|
+
setHour,
|
|
4192
|
+
setMinute,
|
|
4193
|
+
setHourInput,
|
|
4194
|
+
setMinuteInput,
|
|
4195
|
+
setSelection,
|
|
4196
|
+
setIsPm,
|
|
4197
|
+
reset
|
|
4198
|
+
}),
|
|
4199
|
+
[
|
|
4200
|
+
hour,
|
|
4201
|
+
minute,
|
|
4202
|
+
hourInput,
|
|
4203
|
+
minuteInput,
|
|
4204
|
+
is24hour,
|
|
4205
|
+
selection,
|
|
4206
|
+
isInputValid,
|
|
4207
|
+
isHourInputValid,
|
|
4208
|
+
isMinuteInputValid,
|
|
4209
|
+
isPm,
|
|
4210
|
+
setHour,
|
|
4211
|
+
setMinute,
|
|
4212
|
+
setHourInput,
|
|
4213
|
+
setMinuteInput,
|
|
4214
|
+
setSelection,
|
|
4215
|
+
setIsPm,
|
|
4216
|
+
reset
|
|
4217
|
+
]
|
|
4218
|
+
);
|
|
4219
|
+
};
|
|
4220
|
+
|
|
4221
|
+
exports.DP_CLASSES = DP_CLASSES;
|
|
4222
|
+
exports.DP_COLORS = DP_COLORS;
|
|
4223
|
+
exports.DP_SHAPE = DP_SHAPE;
|
|
4224
|
+
exports.DP_SIZE = DP_SIZE;
|
|
4225
|
+
exports.DatePicker = DatePicker;
|
|
4226
|
+
exports.DatePickerDialog = DatePickerDialog;
|
|
4227
|
+
exports.DatePickerInput = DatePickerInput;
|
|
4228
|
+
exports.DateRangePicker = DateRangePicker;
|
|
4229
|
+
exports.TP_CLASSES = TP_CLASSES;
|
|
4230
|
+
exports.TP_COLORS = TP_COLORS;
|
|
4231
|
+
exports.TP_SHAPE = TP_SHAPE;
|
|
4232
|
+
exports.TP_SIZE = TP_SIZE;
|
|
4233
|
+
exports.TimeInput = TimeInput;
|
|
4234
|
+
exports.TimePicker = TimePicker;
|
|
4235
|
+
exports.TimePickerDialog = TimePickerDialog;
|
|
4236
|
+
exports.useDatePickerState = useDatePickerState;
|
|
4237
|
+
exports.useDateRangePickerState = useDateRangePickerState;
|
|
4238
|
+
exports.useTimePickerState = useTimePickerState;
|
|
4239
|
+
//# sourceMappingURL=pickers.js.map
|
|
4240
|
+
//# sourceMappingURL=pickers.js.map
|