@teja-app/ui 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/theme/components/CountdownPill.d.ts +15 -0
- package/dist/theme/components/CountdownPill.d.ts.map +1 -0
- package/dist/theme/components/DateTimePicker.d.ts +68 -0
- package/dist/theme/components/DateTimePicker.d.ts.map +1 -0
- package/dist/theme/components/countdown.d.ts +37 -0
- package/dist/theme/components/countdown.d.ts.map +1 -0
- package/dist/theme/components/countdown.test.d.ts +2 -0
- package/dist/theme/components/countdown.test.d.ts.map +1 -0
- package/dist/theme/components/index.d.ts +3 -0
- package/dist/theme/components/index.d.ts.map +1 -1
- package/dist/theme/index.cjs +519 -3
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.js +519 -3
- package/dist/theme/index.js.map +1 -1
- package/package.json +1 -1
package/dist/theme/index.cjs
CHANGED
|
@@ -795,6 +795,61 @@ function Badge({
|
|
|
795
795
|
children
|
|
796
796
|
] });
|
|
797
797
|
}
|
|
798
|
+
const TONE_COLORS = {
|
|
799
|
+
waiting: { bg: "var(--ai-soft)", fg: "var(--ai)", dot: "var(--ai)" },
|
|
800
|
+
soon: { bg: "var(--warning-soft)", fg: "var(--warning)", dot: "var(--warning)" },
|
|
801
|
+
ready: { bg: "var(--success-soft)", fg: "var(--success)", dot: "var(--success)" }
|
|
802
|
+
};
|
|
803
|
+
function CountdownPill({
|
|
804
|
+
tone,
|
|
805
|
+
label,
|
|
806
|
+
icon = "clock",
|
|
807
|
+
dot,
|
|
808
|
+
testId,
|
|
809
|
+
"data-testid": dataTestId
|
|
810
|
+
}) {
|
|
811
|
+
const showDot = dot ?? tone !== "ready";
|
|
812
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
813
|
+
Badge,
|
|
814
|
+
{
|
|
815
|
+
tone: "neutral",
|
|
816
|
+
colors: TONE_COLORS[tone],
|
|
817
|
+
dot: showDot,
|
|
818
|
+
testId,
|
|
819
|
+
"data-testid": dataTestId,
|
|
820
|
+
children: [
|
|
821
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, size: 12 }),
|
|
822
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily: "var(--font-mono)", fontWeight: 600 }, children: label })
|
|
823
|
+
]
|
|
824
|
+
}
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
const DAY_S = 86400;
|
|
828
|
+
const HOUR_S = 3600;
|
|
829
|
+
const MIN_S = 60;
|
|
830
|
+
function countdownParts(startMs, nowMs, soonThresholdSeconds = 120) {
|
|
831
|
+
const deltaMs = startMs - nowMs;
|
|
832
|
+
if (deltaMs <= 0) {
|
|
833
|
+
return {
|
|
834
|
+
tone: "ready",
|
|
835
|
+
days: 0,
|
|
836
|
+
hours: 0,
|
|
837
|
+
minutes: 0,
|
|
838
|
+
seconds: 0,
|
|
839
|
+
unit: "now",
|
|
840
|
+
clock: "00:00"
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
const total = Math.floor(deltaMs / 1e3);
|
|
844
|
+
const days = Math.floor(total / DAY_S);
|
|
845
|
+
const hours = Math.floor(total % DAY_S / HOUR_S);
|
|
846
|
+
const minutes = Math.floor(total % HOUR_S / MIN_S);
|
|
847
|
+
const seconds = total % MIN_S;
|
|
848
|
+
const unit = days > 0 ? "days" : hours > 0 ? "hours" : "minutes";
|
|
849
|
+
const clock = `${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
850
|
+
const tone = total <= soonThresholdSeconds ? "soon" : "waiting";
|
|
851
|
+
return { tone, days, hours, minutes, seconds, unit, clock };
|
|
852
|
+
}
|
|
798
853
|
const Card = React.forwardRef(function Card2({
|
|
799
854
|
padding = 20,
|
|
800
855
|
children,
|
|
@@ -12401,7 +12456,7 @@ const MONTHS_SHORT = [
|
|
|
12401
12456
|
"Nov",
|
|
12402
12457
|
"Dec"
|
|
12403
12458
|
];
|
|
12404
|
-
const pad2 = (n2) => String(n2).padStart(2, "0");
|
|
12459
|
+
const pad2$1 = (n2) => String(n2).padStart(2, "0");
|
|
12405
12460
|
function parseDate(value) {
|
|
12406
12461
|
if (!value) return void 0;
|
|
12407
12462
|
const [y3, m2, d2] = value.split("-").map(Number);
|
|
@@ -12413,13 +12468,13 @@ function parseDate(value) {
|
|
|
12413
12468
|
return date;
|
|
12414
12469
|
}
|
|
12415
12470
|
function formatDate(date) {
|
|
12416
|
-
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
|
|
12471
|
+
return `${date.getFullYear()}-${pad2$1(date.getMonth() + 1)}-${pad2$1(date.getDate())}`;
|
|
12417
12472
|
}
|
|
12418
12473
|
function isValidDateString(value) {
|
|
12419
12474
|
return /^\d{4}-\d{2}-\d{2}$/.test(value) && parseDate(value) !== void 0;
|
|
12420
12475
|
}
|
|
12421
12476
|
function displayDate(date) {
|
|
12422
|
-
return `${MONTHS_SHORT[date.getMonth()]} ${pad2(date.getDate())}, ${date.getFullYear()}`;
|
|
12477
|
+
return `${MONTHS_SHORT[date.getMonth()]} ${pad2$1(date.getDate())}, ${date.getFullYear()}`;
|
|
12423
12478
|
}
|
|
12424
12479
|
function startOfDay(date) {
|
|
12425
12480
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
@@ -19085,6 +19140,464 @@ const AccordionItem = React.forwardRef(
|
|
|
19085
19140
|
] });
|
|
19086
19141
|
}
|
|
19087
19142
|
);
|
|
19143
|
+
const DOW = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
19144
|
+
const MONTHS = [
|
|
19145
|
+
"January",
|
|
19146
|
+
"February",
|
|
19147
|
+
"March",
|
|
19148
|
+
"April",
|
|
19149
|
+
"May",
|
|
19150
|
+
"June",
|
|
19151
|
+
"July",
|
|
19152
|
+
"August",
|
|
19153
|
+
"September",
|
|
19154
|
+
"October",
|
|
19155
|
+
"November",
|
|
19156
|
+
"December"
|
|
19157
|
+
];
|
|
19158
|
+
const pad2 = (n2) => String(n2).padStart(2, "0");
|
|
19159
|
+
function dateKeyOf(year, month0, day) {
|
|
19160
|
+
return `${year}-${pad2(month0 + 1)}-${pad2(day)}`;
|
|
19161
|
+
}
|
|
19162
|
+
function realTodayKey() {
|
|
19163
|
+
const d2 = /* @__PURE__ */ new Date();
|
|
19164
|
+
return dateKeyOf(d2.getFullYear(), d2.getMonth(), d2.getDate());
|
|
19165
|
+
}
|
|
19166
|
+
function prettyDate(dateKey) {
|
|
19167
|
+
if (!dateKey) return null;
|
|
19168
|
+
const [y3, m2, d2] = dateKey.split("-").map(Number);
|
|
19169
|
+
if (!y3 || !m2 || !d2) return null;
|
|
19170
|
+
const dow = DOW[(new Date(y3, m2 - 1, d2).getDay() + 6) % 7];
|
|
19171
|
+
return `${dow}, ${MONTHS[m2 - 1]} ${d2}`;
|
|
19172
|
+
}
|
|
19173
|
+
function monthGrid(year, month0, todayKey) {
|
|
19174
|
+
const first = new Date(year, month0, 1);
|
|
19175
|
+
const lead = (first.getDay() + 6) % 7;
|
|
19176
|
+
const daysInMonth = new Date(year, month0 + 1, 0).getDate();
|
|
19177
|
+
const cells = [];
|
|
19178
|
+
for (let i2 = 0; i2 < lead; i2++) cells.push(null);
|
|
19179
|
+
for (let d2 = 1; d2 <= daysInMonth; d2++) {
|
|
19180
|
+
const key = dateKeyOf(year, month0, d2);
|
|
19181
|
+
cells.push({ day: d2, key, past: key < todayKey, today: key === todayKey });
|
|
19182
|
+
}
|
|
19183
|
+
while (cells.length % 7 !== 0) cells.push(null);
|
|
19184
|
+
return cells;
|
|
19185
|
+
}
|
|
19186
|
+
const PERIODS = [
|
|
19187
|
+
{ id: "morning", label: "Morning", sub: "Before noon" },
|
|
19188
|
+
{ id: "afternoon", label: "Afternoon", sub: "12:00 – 5:00 PM" },
|
|
19189
|
+
{ id: "evening", label: "Evening", sub: "After 5:00 PM" }
|
|
19190
|
+
];
|
|
19191
|
+
function NavButton({
|
|
19192
|
+
icon,
|
|
19193
|
+
disabled,
|
|
19194
|
+
onClick,
|
|
19195
|
+
ariaLabel
|
|
19196
|
+
}) {
|
|
19197
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19198
|
+
"button",
|
|
19199
|
+
{
|
|
19200
|
+
"aria-label": ariaLabel,
|
|
19201
|
+
disabled,
|
|
19202
|
+
type: "button",
|
|
19203
|
+
onClick,
|
|
19204
|
+
style: {
|
|
19205
|
+
width: 26,
|
|
19206
|
+
height: 26,
|
|
19207
|
+
borderRadius: "var(--r-sm)",
|
|
19208
|
+
border: "1px solid var(--border)",
|
|
19209
|
+
background: "var(--surface-0)",
|
|
19210
|
+
color: "var(--ink-2)",
|
|
19211
|
+
boxShadow: "var(--shadow-xs)",
|
|
19212
|
+
display: "inline-flex",
|
|
19213
|
+
alignItems: "center",
|
|
19214
|
+
justifyContent: "center",
|
|
19215
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
19216
|
+
opacity: disabled ? 0.4 : 1,
|
|
19217
|
+
flexShrink: 0
|
|
19218
|
+
},
|
|
19219
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { color: "var(--ink-2)", name: icon, size: 13 })
|
|
19220
|
+
}
|
|
19221
|
+
);
|
|
19222
|
+
}
|
|
19223
|
+
function CalendarPane({
|
|
19224
|
+
value,
|
|
19225
|
+
todayKey,
|
|
19226
|
+
isDateDisabled,
|
|
19227
|
+
onPick,
|
|
19228
|
+
note
|
|
19229
|
+
}) {
|
|
19230
|
+
const initial = (value ?? todayKey).split("-").map(Number);
|
|
19231
|
+
const [view, setView] = React.useState({
|
|
19232
|
+
year: initial[0],
|
|
19233
|
+
month0: (initial[1] ?? 1) - 1
|
|
19234
|
+
});
|
|
19235
|
+
const grid = React.useMemo(
|
|
19236
|
+
() => monthGrid(view.year, view.month0, todayKey),
|
|
19237
|
+
[view.year, view.month0, todayKey]
|
|
19238
|
+
);
|
|
19239
|
+
const [ty, tm] = todayKey.split("-").map(Number);
|
|
19240
|
+
const canGoPrev = view.year > (ty ?? 0) || view.month0 > (tm ?? 1) - 1;
|
|
19241
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: "100%" }, children: [
|
|
19242
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
19243
|
+
"div",
|
|
19244
|
+
{
|
|
19245
|
+
style: {
|
|
19246
|
+
display: "flex",
|
|
19247
|
+
alignItems: "center",
|
|
19248
|
+
justifyContent: "space-between",
|
|
19249
|
+
marginBottom: 12,
|
|
19250
|
+
padding: "2px 2px 0"
|
|
19251
|
+
},
|
|
19252
|
+
children: [
|
|
19253
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
19254
|
+
NavButton,
|
|
19255
|
+
{
|
|
19256
|
+
ariaLabel: "Previous month",
|
|
19257
|
+
disabled: !canGoPrev,
|
|
19258
|
+
icon: "chevronLeft",
|
|
19259
|
+
onClick: () => {
|
|
19260
|
+
if (!canGoPrev) return;
|
|
19261
|
+
setView((v2) => v2.month0 === 0 ? { year: v2.year - 1, month0: 11 } : { ...v2, month0: v2.month0 - 1 });
|
|
19262
|
+
}
|
|
19263
|
+
}
|
|
19264
|
+
),
|
|
19265
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--ink-1)" }, children: [
|
|
19266
|
+
MONTHS[view.month0],
|
|
19267
|
+
" ",
|
|
19268
|
+
view.year
|
|
19269
|
+
] }),
|
|
19270
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
19271
|
+
NavButton,
|
|
19272
|
+
{
|
|
19273
|
+
ariaLabel: "Next month",
|
|
19274
|
+
icon: "chevronRight",
|
|
19275
|
+
onClick: () => {
|
|
19276
|
+
setView((v2) => v2.month0 === 11 ? { year: v2.year + 1, month0: 0 } : { ...v2, month0: v2.month0 + 1 });
|
|
19277
|
+
}
|
|
19278
|
+
}
|
|
19279
|
+
)
|
|
19280
|
+
]
|
|
19281
|
+
}
|
|
19282
|
+
),
|
|
19283
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: 2, marginBottom: 4 }, children: DOW.map((d2, i2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
19284
|
+
"span",
|
|
19285
|
+
{
|
|
19286
|
+
style: {
|
|
19287
|
+
textAlign: "center",
|
|
19288
|
+
fontSize: 10,
|
|
19289
|
+
fontWeight: 600,
|
|
19290
|
+
color: "var(--ink-3)",
|
|
19291
|
+
textTransform: "uppercase",
|
|
19292
|
+
letterSpacing: "0.04em"
|
|
19293
|
+
},
|
|
19294
|
+
children: d2[0]
|
|
19295
|
+
},
|
|
19296
|
+
i2
|
|
19297
|
+
)) }),
|
|
19298
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: 2, justifyItems: "center" }, children: grid.map((c2, i2) => {
|
|
19299
|
+
if (!c2) return /* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: 34, height: 34 } }, `e${i2}`);
|
|
19300
|
+
const disabled = c2.past || isDateDisabled(c2.key);
|
|
19301
|
+
const selected = c2.key === value;
|
|
19302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19303
|
+
"button",
|
|
19304
|
+
{
|
|
19305
|
+
"data-testid": `dtp-day-${c2.key}`,
|
|
19306
|
+
disabled,
|
|
19307
|
+
type: "button",
|
|
19308
|
+
onClick: () => onPick(c2.key),
|
|
19309
|
+
style: {
|
|
19310
|
+
width: 34,
|
|
19311
|
+
height: 34,
|
|
19312
|
+
borderRadius: 999,
|
|
19313
|
+
border: 0,
|
|
19314
|
+
fontSize: 12.5,
|
|
19315
|
+
fontWeight: selected ? 700 : c2.today ? 600 : 500,
|
|
19316
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
19317
|
+
background: selected ? "var(--primary)" : "transparent",
|
|
19318
|
+
color: disabled ? "var(--ink-4)" : selected ? "white" : c2.today ? "var(--primary)" : "var(--ink-1)",
|
|
19319
|
+
opacity: disabled ? 0.45 : 1,
|
|
19320
|
+
textDecoration: disabled ? "line-through" : "none",
|
|
19321
|
+
outline: c2.today && !selected ? "1px solid var(--primary-soft)" : "none",
|
|
19322
|
+
display: "inline-flex",
|
|
19323
|
+
alignItems: "center",
|
|
19324
|
+
justifyContent: "center"
|
|
19325
|
+
},
|
|
19326
|
+
children: c2.day
|
|
19327
|
+
},
|
|
19328
|
+
c2.key
|
|
19329
|
+
);
|
|
19330
|
+
}) }),
|
|
19331
|
+
note ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
19332
|
+
"div",
|
|
19333
|
+
{
|
|
19334
|
+
style: {
|
|
19335
|
+
marginTop: 10,
|
|
19336
|
+
fontSize: 10.5,
|
|
19337
|
+
color: "var(--ink-3)",
|
|
19338
|
+
display: "flex",
|
|
19339
|
+
alignItems: "center",
|
|
19340
|
+
gap: 5
|
|
19341
|
+
},
|
|
19342
|
+
children: [
|
|
19343
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { color: "var(--ink-4)", name: "calendar", size: 11 }),
|
|
19344
|
+
note
|
|
19345
|
+
]
|
|
19346
|
+
}
|
|
19347
|
+
) : null
|
|
19348
|
+
] });
|
|
19349
|
+
}
|
|
19350
|
+
function SlotsPane({
|
|
19351
|
+
state,
|
|
19352
|
+
value,
|
|
19353
|
+
hint,
|
|
19354
|
+
onPick,
|
|
19355
|
+
onRetry
|
|
19356
|
+
}) {
|
|
19357
|
+
if (state.status === "loading") {
|
|
19358
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19359
|
+
"div",
|
|
19360
|
+
{
|
|
19361
|
+
"data-testid": "dtp-slots-loading",
|
|
19362
|
+
style: { minHeight: 120, display: "flex", alignItems: "center", justifyContent: "center", color: "var(--ink-3)", fontSize: 12.5 },
|
|
19363
|
+
children: "Loading times…"
|
|
19364
|
+
}
|
|
19365
|
+
);
|
|
19366
|
+
}
|
|
19367
|
+
if (state.status === "error") {
|
|
19368
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
19369
|
+
"div",
|
|
19370
|
+
{
|
|
19371
|
+
"data-testid": "dtp-slots-error",
|
|
19372
|
+
style: { minHeight: 120, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 8, color: "var(--ink-3)", textAlign: "center", padding: 16 },
|
|
19373
|
+
children: [
|
|
19374
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { color: "var(--danger)", name: "alert-circle", size: 18 }),
|
|
19375
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5 }, children: "Couldn't load times." }),
|
|
19376
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button$1, { size: "sm", variant: "secondary", onClick: onRetry, children: "Try again" })
|
|
19377
|
+
]
|
|
19378
|
+
}
|
|
19379
|
+
);
|
|
19380
|
+
}
|
|
19381
|
+
const { slots } = state;
|
|
19382
|
+
const anyAvailable = slots.some((s2) => s2.available !== false);
|
|
19383
|
+
if (slots.length === 0 || !anyAvailable) {
|
|
19384
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
19385
|
+
"div",
|
|
19386
|
+
{
|
|
19387
|
+
"data-testid": "dtp-slots-empty",
|
|
19388
|
+
style: { minHeight: 120, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 8, color: "var(--ink-3)", textAlign: "center", padding: 16 },
|
|
19389
|
+
children: [
|
|
19390
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { color: "var(--ink-4)", name: "clock", size: 18 }),
|
|
19391
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12.5, fontWeight: 500 }, children: "No times available" }),
|
|
19392
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, maxWidth: 200 }, children: "Try another day, or adjust the session length." })
|
|
19393
|
+
]
|
|
19394
|
+
}
|
|
19395
|
+
);
|
|
19396
|
+
}
|
|
19397
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "dtp-slots", style: { display: "flex", flexDirection: "column", gap: 14 }, children: [
|
|
19398
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 12, color: "var(--ink-2)" }, children: hint }) : null,
|
|
19399
|
+
PERIODS.map((p2) => {
|
|
19400
|
+
const inPeriod = slots.filter((s2) => s2.period === p2.id);
|
|
19401
|
+
if (inPeriod.length === 0) return null;
|
|
19402
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
19403
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "baseline", gap: 8, marginBottom: 8 }, children: [
|
|
19404
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11.5, fontWeight: 700, color: "var(--ink-1)" }, children: p2.label }),
|
|
19405
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 10.5, color: "var(--ink-3)" }, children: p2.sub })
|
|
19406
|
+
] }),
|
|
19407
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(84px, 1fr))", gap: 8 }, children: inPeriod.map((s2) => {
|
|
19408
|
+
const blocked = s2.available === false;
|
|
19409
|
+
const on = s2.id === value;
|
|
19410
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19411
|
+
"button",
|
|
19412
|
+
{
|
|
19413
|
+
"data-testid": `dtp-slot-${s2.id}`,
|
|
19414
|
+
disabled: blocked,
|
|
19415
|
+
title: blocked ? s2.reason : void 0,
|
|
19416
|
+
type: "button",
|
|
19417
|
+
onClick: () => onPick(s2.id),
|
|
19418
|
+
style: {
|
|
19419
|
+
height: 38,
|
|
19420
|
+
borderRadius: "var(--r-md)",
|
|
19421
|
+
border: `1px solid ${on ? "var(--primary)" : "var(--border-strong)"}`,
|
|
19422
|
+
background: on ? "var(--primary)" : "var(--surface-0)",
|
|
19423
|
+
color: blocked ? "var(--ink-4)" : on ? "white" : "var(--ink-1)",
|
|
19424
|
+
fontSize: 12.5,
|
|
19425
|
+
fontWeight: on ? 600 : 500,
|
|
19426
|
+
cursor: blocked ? "not-allowed" : "pointer",
|
|
19427
|
+
opacity: blocked ? 0.5 : 1,
|
|
19428
|
+
textDecoration: blocked ? "line-through" : "none"
|
|
19429
|
+
},
|
|
19430
|
+
children: s2.label
|
|
19431
|
+
},
|
|
19432
|
+
s2.id
|
|
19433
|
+
);
|
|
19434
|
+
}) })
|
|
19435
|
+
] }, p2.id);
|
|
19436
|
+
})
|
|
19437
|
+
] });
|
|
19438
|
+
}
|
|
19439
|
+
function DateTimePicker({
|
|
19440
|
+
value,
|
|
19441
|
+
onChange,
|
|
19442
|
+
loadSlots,
|
|
19443
|
+
isDateDisabled,
|
|
19444
|
+
reloadKey,
|
|
19445
|
+
slotsHint,
|
|
19446
|
+
calendarNote,
|
|
19447
|
+
initialStep = "date",
|
|
19448
|
+
todayKey,
|
|
19449
|
+
testId = "date-time-picker"
|
|
19450
|
+
}) {
|
|
19451
|
+
const today = todayKey ?? realTodayKey();
|
|
19452
|
+
const dateDisabled = React.useCallback(
|
|
19453
|
+
(k2) => isDateDisabled ? isDateDisabled(k2) : k2 < today,
|
|
19454
|
+
[isDateDisabled, today]
|
|
19455
|
+
);
|
|
19456
|
+
const [step, setStep] = React.useState(initialStep);
|
|
19457
|
+
const [slotsState, setSlotsState] = React.useState(
|
|
19458
|
+
value.dateKey ? { status: "loading" } : { status: "ready", slots: [] }
|
|
19459
|
+
);
|
|
19460
|
+
const reqIdRef = React.useRef(0);
|
|
19461
|
+
const runLoad = React.useCallback(
|
|
19462
|
+
(dateKey) => {
|
|
19463
|
+
const id = ++reqIdRef.current;
|
|
19464
|
+
setSlotsState({ status: "loading" });
|
|
19465
|
+
loadSlots(dateKey).then(
|
|
19466
|
+
(slots) => {
|
|
19467
|
+
if (reqIdRef.current === id) setSlotsState({ status: "ready", slots });
|
|
19468
|
+
},
|
|
19469
|
+
() => {
|
|
19470
|
+
if (reqIdRef.current === id) setSlotsState({ status: "error" });
|
|
19471
|
+
}
|
|
19472
|
+
);
|
|
19473
|
+
},
|
|
19474
|
+
[loadSlots]
|
|
19475
|
+
);
|
|
19476
|
+
const dateKeyRef = React.useRef(value.dateKey);
|
|
19477
|
+
React.useEffect(() => {
|
|
19478
|
+
dateKeyRef.current = value.dateKey;
|
|
19479
|
+
}, [value.dateKey]);
|
|
19480
|
+
React.useEffect(() => {
|
|
19481
|
+
const dateKey = dateKeyRef.current;
|
|
19482
|
+
if (dateKey) runLoad(dateKey);
|
|
19483
|
+
}, [reloadKey, runLoad]);
|
|
19484
|
+
const handlePickDate = (dateKey) => {
|
|
19485
|
+
onChange({ dateKey, slotId: null });
|
|
19486
|
+
setStep("time");
|
|
19487
|
+
runLoad(dateKey);
|
|
19488
|
+
};
|
|
19489
|
+
const handlePickSlot = (slotId) => {
|
|
19490
|
+
onChange({ ...value, slotId });
|
|
19491
|
+
};
|
|
19492
|
+
const pretty = prettyDate(value.dateKey);
|
|
19493
|
+
const selectedLabel = slotsState.status === "ready" ? slotsState.slots.find((s2) => s2.id === value.slotId)?.label : void 0;
|
|
19494
|
+
const note = calendarNote === void 0 ? "Past dates are off — sessions can't be created in the past." : calendarNote;
|
|
19495
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
19496
|
+
"div",
|
|
19497
|
+
{
|
|
19498
|
+
"data-testid": testId,
|
|
19499
|
+
style: {
|
|
19500
|
+
width: 340,
|
|
19501
|
+
maxWidth: "calc(100vw - 32px)",
|
|
19502
|
+
background: "var(--surface-0)",
|
|
19503
|
+
borderRadius: "var(--r-lg)",
|
|
19504
|
+
border: "1px solid var(--border-strong)",
|
|
19505
|
+
boxShadow: "var(--shadow-lg)",
|
|
19506
|
+
overflow: "hidden",
|
|
19507
|
+
display: "flex",
|
|
19508
|
+
flexDirection: "column",
|
|
19509
|
+
maxHeight: "min(440px, 80vh)"
|
|
19510
|
+
},
|
|
19511
|
+
children: [
|
|
19512
|
+
step === "date" ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 16 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
19513
|
+
CalendarPane,
|
|
19514
|
+
{
|
|
19515
|
+
isDateDisabled: dateDisabled,
|
|
19516
|
+
note,
|
|
19517
|
+
todayKey: today,
|
|
19518
|
+
value: value.dateKey,
|
|
19519
|
+
onPick: handlePickDate
|
|
19520
|
+
}
|
|
19521
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
19522
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
19523
|
+
"button",
|
|
19524
|
+
{
|
|
19525
|
+
"data-testid": "dtp-back-to-date",
|
|
19526
|
+
type: "button",
|
|
19527
|
+
onClick: () => setStep("date"),
|
|
19528
|
+
style: {
|
|
19529
|
+
display: "flex",
|
|
19530
|
+
alignItems: "center",
|
|
19531
|
+
gap: 8,
|
|
19532
|
+
width: "100%",
|
|
19533
|
+
padding: "12px 16px",
|
|
19534
|
+
border: 0,
|
|
19535
|
+
borderBottom: "1px solid var(--divider)",
|
|
19536
|
+
background: "var(--surface-1)",
|
|
19537
|
+
cursor: "pointer",
|
|
19538
|
+
textAlign: "left"
|
|
19539
|
+
},
|
|
19540
|
+
children: [
|
|
19541
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { color: "var(--ink-3)", name: "chevronLeft", size: 13 }),
|
|
19542
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "var(--ink-3)" }, children: "Date" }),
|
|
19543
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 13, fontWeight: 600, color: "var(--ink-1)", marginLeft: "auto" }, children: pretty })
|
|
19544
|
+
]
|
|
19545
|
+
}
|
|
19546
|
+
),
|
|
19547
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 16, overflowY: "auto", flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
19548
|
+
SlotsPane,
|
|
19549
|
+
{
|
|
19550
|
+
hint: slotsHint,
|
|
19551
|
+
state: slotsState,
|
|
19552
|
+
value: value.slotId,
|
|
19553
|
+
onPick: handlePickSlot,
|
|
19554
|
+
onRetry: () => {
|
|
19555
|
+
if (value.dateKey) runLoad(value.dateKey);
|
|
19556
|
+
}
|
|
19557
|
+
}
|
|
19558
|
+
) })
|
|
19559
|
+
] }),
|
|
19560
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
19561
|
+
"div",
|
|
19562
|
+
{
|
|
19563
|
+
style: {
|
|
19564
|
+
padding: "10px 16px",
|
|
19565
|
+
borderTop: "1px solid var(--divider)",
|
|
19566
|
+
background: "var(--surface-1)",
|
|
19567
|
+
display: "flex",
|
|
19568
|
+
alignItems: "center",
|
|
19569
|
+
justifyContent: "space-between",
|
|
19570
|
+
gap: 8,
|
|
19571
|
+
flexShrink: 0
|
|
19572
|
+
},
|
|
19573
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
19574
|
+
"span",
|
|
19575
|
+
{
|
|
19576
|
+
style: {
|
|
19577
|
+
fontSize: 12,
|
|
19578
|
+
color: "var(--ink-2)",
|
|
19579
|
+
minWidth: 0,
|
|
19580
|
+
overflow: "hidden",
|
|
19581
|
+
textOverflow: "ellipsis",
|
|
19582
|
+
whiteSpace: "nowrap"
|
|
19583
|
+
},
|
|
19584
|
+
children: value.slotId && selectedLabel ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
19585
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--ink-3)" }, children: "Selected:" }),
|
|
19586
|
+
" ",
|
|
19587
|
+
/* @__PURE__ */ jsxRuntime.jsxs("b", { children: [
|
|
19588
|
+
pretty,
|
|
19589
|
+
" · ",
|
|
19590
|
+
selectedLabel
|
|
19591
|
+
] })
|
|
19592
|
+
] }) : step === "date" ? "Pick a date" : "Pick a time"
|
|
19593
|
+
}
|
|
19594
|
+
)
|
|
19595
|
+
}
|
|
19596
|
+
)
|
|
19597
|
+
]
|
|
19598
|
+
}
|
|
19599
|
+
);
|
|
19600
|
+
}
|
|
19088
19601
|
exports.AIBadge = AIBadge;
|
|
19089
19602
|
exports.AICard = AICard;
|
|
19090
19603
|
exports.AIChip = AIChip;
|
|
@@ -19110,12 +19623,14 @@ exports.Checkbox = Checkbox;
|
|
|
19110
19623
|
exports.Chip = Chip;
|
|
19111
19624
|
exports.Combobox = Combobox;
|
|
19112
19625
|
exports.ConfirmDialog = ConfirmDialog;
|
|
19626
|
+
exports.CountdownPill = CountdownPill;
|
|
19113
19627
|
exports.CountryPicker = CountryPicker;
|
|
19114
19628
|
exports.DEFAULT_LANG_OPTIONS = DEFAULT_LANG_OPTIONS;
|
|
19115
19629
|
exports.DENSITY_OPTIONS = DENSITY_OPTIONS;
|
|
19116
19630
|
exports.DISPLAY_OPTIONS = DISPLAY_OPTIONS;
|
|
19117
19631
|
exports.DarkScope = DarkScope;
|
|
19118
19632
|
exports.DateInput = DateInput;
|
|
19633
|
+
exports.DateTimePicker = DateTimePicker;
|
|
19119
19634
|
exports.Divider = Divider;
|
|
19120
19635
|
exports.Drawer = Drawer;
|
|
19121
19636
|
exports.DrawerFooter = DrawerFooter;
|
|
@@ -19202,6 +19717,7 @@ exports.US_STATES = US_STATES;
|
|
|
19202
19717
|
exports.ViewToggle = ViewToggle;
|
|
19203
19718
|
exports.applyTheme = applyTheme;
|
|
19204
19719
|
exports.controlBoxStyle = controlBoxStyle;
|
|
19720
|
+
exports.countdownParts = countdownParts;
|
|
19205
19721
|
exports.ensureAIStyles = ensureAIStyles;
|
|
19206
19722
|
exports.ensureSidebarNavStyles = ensureSidebarNavStyles;
|
|
19207
19723
|
exports.ensureSkeletonStyles = ensureSkeletonStyles;
|