@alfadocs/ui-kit 0.33.9 → 0.33.11

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.
@@ -1,120 +0,0 @@
1
- import { t as D, c as p, m as N, a as g } from "./isSameDay-DUEiAT0G.js";
2
- function W(t, e) {
3
- const n = () => p(e == null ? void 0 : e.in, NaN), a = I(t);
4
- let s;
5
- if (a.date) {
6
- const i = x(a.date, 2);
7
- s = Y(i.restDateString, i.year);
8
- }
9
- if (!s || isNaN(+s)) return n();
10
- const l = +s;
11
- let c = 0, u;
12
- if (a.time && (c = w(a.time), isNaN(c)))
13
- return n();
14
- if (a.timezone) {
15
- if (u = y(a.timezone), isNaN(u)) return n();
16
- } else {
17
- const i = new Date(l + c), d = D(0, e == null ? void 0 : e.in);
18
- return d.setFullYear(
19
- i.getUTCFullYear(),
20
- i.getUTCMonth(),
21
- i.getUTCDate()
22
- ), d.setHours(
23
- i.getUTCHours(),
24
- i.getUTCMinutes(),
25
- i.getUTCSeconds(),
26
- i.getUTCMilliseconds()
27
- ), d;
28
- }
29
- return D(l + c + u, e == null ? void 0 : e.in);
30
- }
31
- const f = {
32
- dateTimeDelimiter: /[T ]/,
33
- timeZoneDelimiter: /[Z ]/i,
34
- timezone: /([Z+-].*)$/
35
- }, U = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, h = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, C = /^([+-])(\d{2})(?::?(\d{2}))?$/;
36
- function I(t) {
37
- const e = {}, n = t.split(f.dateTimeDelimiter);
38
- let r;
39
- if (n.length > 2)
40
- return e;
41
- if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], f.timeZoneDelimiter.test(e.date) && (e.date = t.split(f.timeZoneDelimiter)[0], r = t.substr(
42
- e.date.length,
43
- t.length
44
- ))), r) {
45
- const a = f.timezone.exec(r);
46
- a ? (e.time = r.replace(a[1], ""), e.timezone = a[1]) : e.time = r;
47
- }
48
- return e;
49
- }
50
- function x(t, e) {
51
- const n = new RegExp(
52
- "^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
53
- ), r = t.match(n);
54
- if (!r) return { year: NaN, restDateString: "" };
55
- const a = r[1] ? parseInt(r[1]) : null, s = r[2] ? parseInt(r[2]) : null;
56
- return {
57
- year: s === null ? a : s * 100,
58
- restDateString: t.slice((r[1] || r[2]).length)
59
- };
60
- }
61
- function Y(t, e) {
62
- if (e === null) return /* @__PURE__ */ new Date(NaN);
63
- const n = t.match(U);
64
- if (!n) return /* @__PURE__ */ new Date(NaN);
65
- const r = !!n[4], a = o(n[1]), s = o(n[2]) - 1, l = o(n[3]), c = o(n[4]), u = o(n[5]) - 1;
66
- if (r)
67
- return Z(e, c, u) ? z(e, c, u) : /* @__PURE__ */ new Date(NaN);
68
- {
69
- const i = /* @__PURE__ */ new Date(0);
70
- return !M(e, s, l) || !O(e, a) ? /* @__PURE__ */ new Date(NaN) : (i.setUTCFullYear(e, s, Math.max(a, l)), i);
71
- }
72
- }
73
- function o(t) {
74
- return t ? parseInt(t) : 1;
75
- }
76
- function w(t) {
77
- const e = t.match(h);
78
- if (!e) return NaN;
79
- const n = m(e[1]), r = m(e[2]), a = m(e[3]);
80
- return k(n, r, a) ? n * N + r * g + a * 1e3 : NaN;
81
- }
82
- function m(t) {
83
- return t && parseFloat(t.replace(",", ".")) || 0;
84
- }
85
- function y(t) {
86
- if (t === "Z") return 0;
87
- const e = t.match(C);
88
- if (!e) return 0;
89
- const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), a = e[3] && parseInt(e[3]) || 0;
90
- return R(r, a) ? n * (r * N + a * g) : NaN;
91
- }
92
- function z(t, e, n) {
93
- const r = /* @__PURE__ */ new Date(0);
94
- r.setUTCFullYear(t, 0, 4);
95
- const a = r.getUTCDay() || 7, s = (e - 1) * 7 + n + 1 - a;
96
- return r.setUTCDate(r.getUTCDate() + s), r;
97
- }
98
- const F = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
99
- function T(t) {
100
- return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
101
- }
102
- function M(t, e, n) {
103
- return e >= 0 && e <= 11 && n >= 1 && n <= (F[e] || (T(t) ? 29 : 28));
104
- }
105
- function O(t, e) {
106
- return e >= 1 && e <= (T(t) ? 366 : 365);
107
- }
108
- function Z(t, e, n) {
109
- return e >= 1 && e <= 53 && n >= 0 && n <= 6;
110
- }
111
- function k(t, e, n) {
112
- return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
113
- }
114
- function R(t, e) {
115
- return e >= 0 && e <= 59;
116
- }
117
- export {
118
- W as p
119
- };
120
- //# sourceMappingURL=parseISO-DEpUNwxZ.js.map
@@ -1,387 +0,0 @@
1
- import { jsx as t, jsxs as x } from "react/jsx-runtime";
2
- import { forwardRef as os, useId as ls, useState as cs, useCallback as L } from "react";
3
- import { c as f } from "./index-D2ZczOXr.js";
4
- import { useTranslation as ms } from "react-i18next";
5
- import { B as $ } from "./button-DD_0Xdmr.js";
6
- import { I as A } from "./icon-button-CKEOrN37.js";
7
- import { E as us } from "./empty-state-BLy7tigq.js";
8
- import { S as B } from "./skeleton-CZbwyJAA.js";
9
- import { i as fs } from "./isSameDay-DUEiAT0G.js";
10
- import { p as gs } from "./parseISO-DEpUNwxZ.js";
11
- const ps = f(
12
- [
13
- "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
14
- "ds:text-[var(--foreground)]",
15
- "ds:w-full"
16
- ].join(" "),
17
- {
18
- variants: {
19
- size: {
20
- sm: "ds:text-[length:var(--font-size-sm)]",
21
- md: "ds:text-[length:var(--font-size-base)]",
22
- lg: "ds:text-[length:var(--font-size-lg)]"
23
- }
24
- },
25
- defaultVariants: { size: "md" }
26
- }
27
- ), vs = f(
28
- "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)] ds:w-full"
29
- ), hs = 12, bs = f(
30
- "ds:grid ds:gap-[var(--spacing-sm)] ds:w-full ds:auto-rows-min ds:items-start",
31
- {
32
- variants: {
33
- cols: {
34
- 1: "ds:grid-cols-1",
35
- 2: "ds:grid-cols-2",
36
- 3: "ds:grid-cols-3",
37
- 4: "ds:grid-cols-4",
38
- 5: "ds:grid-cols-5",
39
- 6: "ds:grid-cols-6",
40
- 7: "ds:grid-cols-7",
41
- 8: "ds:grid-cols-8",
42
- 9: "ds:grid-cols-9",
43
- 10: "ds:grid-cols-10",
44
- 11: "ds:grid-cols-11",
45
- 12: "ds:grid-cols-12"
46
- }
47
- },
48
- defaultVariants: { cols: 1 }
49
- }
50
- );
51
- function xs(s) {
52
- return Math.max(1, Math.min(s, hs));
53
- }
54
- const R = f(
55
- [
56
- "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
57
- "ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
58
- "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]",
59
- "ds:rounded-[var(--radius-md)]",
60
- "ds:bg-[var(--card)]",
61
- "ds:min-w-0"
62
- ].join(" ")
63
- ), ys = f(
64
- [
65
- "ds:font-[var(--font-weight-semibold)]",
66
- "ds:text-[var(--foreground)]",
67
- "ds:text-start",
68
- "ds:truncate"
69
- ].join(" "),
70
- {
71
- variants: {
72
- size: {
73
- sm: "ds:text-[length:var(--font-size-xs)]",
74
- md: "ds:text-[length:var(--font-size-sm)]",
75
- lg: "ds:text-[length:var(--font-size-base)]"
76
- }
77
- },
78
- defaultVariants: { size: "md" }
79
- }
80
- ), T = f(
81
- "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:w-full ds:m-0 ds:p-0 ds:list-none"
82
- ), ws = f(
83
- [
84
- "ds:inline-flex ds:items-center ds:justify-center",
85
- "ds:w-full",
86
- "ds:rounded-[var(--radius-sm)]",
87
- "ds:font-[var(--font-weight-medium)]",
88
- "ds:bg-[var(--secondary)]",
89
- "ds:shadow-[var(--shadow-sm)]",
90
- "ds:text-[var(--foreground)]",
91
- "ds:transition-[background-color,color,box-shadow]",
92
- "ds:duration-[var(--animation-duration)]",
93
- "ds:motion-reduce:transition-none",
94
- "ds:focus-visible:outline-[var(--focus-ring-width)]",
95
- "ds:focus-visible:outline-solid",
96
- "ds:focus-visible:outline-[var(--ring)]",
97
- "ds:focus-visible:outline-offset-[var(--focus-ring-offset)]",
98
- "ds:min-h-[var(--min-target-size)]",
99
- "ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:shadow-none",
100
- "ds:aria-disabled:opacity-50 ds:aria-disabled:cursor-not-allowed ds:aria-disabled:shadow-none",
101
- "ds:hover:enabled:shadow-[var(--shadow-md)]",
102
- "ds:aria-pressed:bg-[var(--primary)] ds:aria-pressed:text-[var(--primary-foreground)]"
103
- ].join(" "),
104
- {
105
- variants: {
106
- size: {
107
- sm: "ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)] ds:text-[length:var(--font-size-xs)] ds:h-8",
108
- md: "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:text-[length:var(--font-size-sm)] ds:h-10",
109
- lg: "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:text-[length:var(--font-size-base)] ds:h-12"
110
- }
111
- },
112
- defaultVariants: { size: "md" }
113
- }
114
- );
115
- function u(s) {
116
- return s instanceof Date ? s : gs(s);
117
- }
118
- function Rs(s, r) {
119
- return fs(u(s), u(r));
120
- }
121
- function Ts(s) {
122
- for (const r of s) {
123
- const e = r.slots.find((n) => n.available !== !1);
124
- if (e) return { day: r, slot: e };
125
- }
126
- }
127
- function F(s, r, e) {
128
- try {
129
- return new Intl.DateTimeFormat(r, {
130
- weekday: "short",
131
- month: "short",
132
- day: "numeric",
133
- timeZone: e
134
- }).format(s);
135
- } catch {
136
- return new Intl.DateTimeFormat("en", {
137
- weekday: "short",
138
- month: "short",
139
- day: "numeric"
140
- }).format(s);
141
- }
142
- }
143
- function O(s, r, e) {
144
- if (s.label !== void 0) return s.label;
145
- const n = u(s.start);
146
- try {
147
- const d = new Intl.DateTimeFormat(r, {
148
- hour: "numeric",
149
- minute: "2-digit",
150
- timeZone: e
151
- });
152
- if (s.end) {
153
- const g = u(s.end);
154
- if (typeof d.formatRange == "function")
155
- try {
156
- return d.formatRange(n, g);
157
- } catch {
158
- }
159
- return `${d.format(n)} – ${d.format(g)}`;
160
- }
161
- return d.format(n);
162
- } catch {
163
- return n.toISOString();
164
- }
165
- }
166
- function ks(s, r, e, n, d) {
167
- if (s.ariaLabel !== void 0) return s.ariaLabel;
168
- const g = O(s, e, n), p = r.label !== void 0 ? r.label : F(u(r.date), e, n);
169
- return d({ time: g, day: p });
170
- }
171
- function Cs() {
172
- return /* @__PURE__ */ t(
173
- "svg",
174
- {
175
- "aria-hidden": "true",
176
- viewBox: "0 0 24 24",
177
- fill: "none",
178
- stroke: "currentColor",
179
- strokeWidth: "2",
180
- strokeLinecap: "round",
181
- strokeLinejoin: "round",
182
- className: "ds:size-4",
183
- children: /* @__PURE__ */ t("path", { d: "M15 18l-6-6 6-6" })
184
- }
185
- );
186
- }
187
- function Ls() {
188
- return /* @__PURE__ */ t(
189
- "svg",
190
- {
191
- "aria-hidden": "true",
192
- viewBox: "0 0 24 24",
193
- fill: "none",
194
- stroke: "currentColor",
195
- strokeWidth: "2",
196
- strokeLinecap: "round",
197
- strokeLinejoin: "round",
198
- className: "ds:size-4",
199
- children: /* @__PURE__ */ t("path", { d: "M9 6l6 6-6 6" })
200
- }
201
- );
202
- }
203
- const Ds = os(
204
- ({
205
- days: s,
206
- state: r = "default",
207
- size: e = "md",
208
- selectedSlotId: n,
209
- maxInitialSlotsPerDay: d = 6,
210
- locale: g,
211
- timeZone: p,
212
- hasPrevious: K = !1,
213
- hasNext: M = !1,
214
- showNextAvailable: _ = !1,
215
- ariaLabel: H,
216
- onSlotSelect: v,
217
- onPreviousDays: W,
218
- onNextDays: X,
219
- onShowMore: h,
220
- onJumpToNextAvailable: q,
221
- className: J,
222
- ...Q
223
- }, U) => {
224
- const { t: o, i18n: Y } = ms(), y = g ?? Y.language ?? "en", P = ls(), [Z, ss] = cs({}), D = r === "loading", z = r === "disabled", m = D || z, as = r === "empty" || s.length === 0 || s.every((a) => a.slots.length === 0), ts = H ?? o("slotGrid.ariaLabel"), w = L(
225
- (a, i) => {
226
- m || a.available !== !1 && (v == null || v(a, i));
227
- },
228
- [m, v]
229
- ), es = L(
230
- (a, i) => {
231
- ss((l) => ({ ...l, [i]: !0 })), h == null || h(a);
232
- },
233
- [h]
234
- ), rs = L(
235
- (a, i, l) => {
236
- (a.key === "Enter" || a.key === " ") && (a.preventDefault(), w(i, l));
237
- },
238
- [w]
239
- ), I = xs(s.length || 1), N = bs({ cols: I });
240
- let b;
241
- return D ? b = /* @__PURE__ */ t(
242
- "div",
243
- {
244
- className: N,
245
- "data-state": "loading",
246
- role: "status",
247
- "aria-live": "polite",
248
- "aria-label": o("common.loading"),
249
- children: Array.from({ length: I }, (a, i) => /* @__PURE__ */ x("div", { className: R(), children: [
250
- /* @__PURE__ */ t(B, { variant: "text", size: e, width: "60%" }),
251
- /* @__PURE__ */ t("div", { className: T(), children: Array.from(
252
- { length: Math.min(d, 4) },
253
- (l, k) => /* @__PURE__ */ t(
254
- B,
255
- {
256
- variant: "rounded",
257
- size: e,
258
- height: "40px"
259
- },
260
- `loading-slot-${i}-${k}`
261
- )
262
- ) })
263
- ] }, `loading-col-${i}`))
264
- }
265
- ) : as ? b = /* @__PURE__ */ t("div", { "data-state": "empty", children: /* @__PURE__ */ t(us, { variant: "no-results", title: o("slotGrid.noSlots") }) }) : b = /* @__PURE__ */ t(
266
- "div",
267
- {
268
- className: N,
269
- "data-state": z ? "disabled" : "default",
270
- children: s.map((a, i) => {
271
- const l = `${u(a.date).toISOString()}-${i}`, k = a.label ?? F(u(a.date), y, p), S = `${P}-day-${i}-header`, G = Z[l] ?? !1 ? a.slots : a.slots.slice(0, d), V = a.slots.length - G.length, j = a.slots.length === 0;
272
- return (
273
- // Use a plain <div role="group"> rather than <section> — a
274
- // <section> with aria-labelledby is a landmark, and nesting many
275
- // landmarks inside the outer slot-grid landmark fails axe's
276
- // landmark-unique rule.
277
- /* @__PURE__ */ x(
278
- "div",
279
- {
280
- role: "group",
281
- className: R(),
282
- "aria-labelledby": S,
283
- "data-empty": j || void 0,
284
- children: [
285
- /* @__PURE__ */ t("h3", { id: S, className: ys({ size: e }), children: k }),
286
- j ? /* @__PURE__ */ t("p", { className: "type-body-sm ds:text-[var(--muted-foreground)] ds:m-0", children: o("slotGrid.noSlots") }) : null,
287
- /* @__PURE__ */ t("ul", { className: T(), children: G.map((c) => {
288
- const ns = ks(
289
- c,
290
- a,
291
- y,
292
- p,
293
- ({ time: C, day: ds }) => o("slotGrid.slotLabel", { time: C, day: ds })
294
- ), is = n === c.id, E = c.available === !1 || m;
295
- return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
296
- "button",
297
- {
298
- type: "button",
299
- className: ws({ size: e }),
300
- "aria-label": ns,
301
- "aria-pressed": is,
302
- disabled: E,
303
- "aria-disabled": E || void 0,
304
- "data-slot-id": c.id,
305
- onClick: () => w(c, a),
306
- onKeyDown: (C) => rs(C, c, a),
307
- children: O(c, y, p)
308
- }
309
- ) }, c.id);
310
- }) }),
311
- V > 0 ? /* @__PURE__ */ t(
312
- $,
313
- {
314
- intent: "ghost",
315
- size: e === "lg" ? "md" : "sm",
316
- onClick: () => es(a, l),
317
- disabled: m,
318
- children: o("slotGrid.showMore", { count: V })
319
- }
320
- ) : null
321
- ]
322
- },
323
- l
324
- )
325
- );
326
- })
327
- }
328
- ), /* @__PURE__ */ x(
329
- "div",
330
- {
331
- ref: U,
332
- role: "region",
333
- "aria-label": ts,
334
- className: ps({ size: e, className: J }),
335
- "data-component": "slot-grid",
336
- "data-state": r,
337
- ...Q,
338
- children: [
339
- /* @__PURE__ */ x("div", { className: vs(), children: [
340
- /* @__PURE__ */ t(
341
- A,
342
- {
343
- icon: /* @__PURE__ */ t(Cs, {}),
344
- "aria-label": o("slotGrid.previousDays"),
345
- size: e === "lg" ? "md" : "sm",
346
- intent: "ghost",
347
- flipIconInRtl: !0,
348
- disabled: !K || m,
349
- onClick: W
350
- }
351
- ),
352
- _ ? /* @__PURE__ */ t(
353
- $,
354
- {
355
- intent: "secondary",
356
- size: e === "lg" ? "md" : "sm",
357
- disabled: m,
358
- onClick: q,
359
- children: o("slotGrid.nextAvailable")
360
- }
361
- ) : /* @__PURE__ */ t("span", { "aria-hidden": "true" }),
362
- /* @__PURE__ */ t(
363
- A,
364
- {
365
- icon: /* @__PURE__ */ t(Ls, {}),
366
- "aria-label": o("slotGrid.nextDays"),
367
- size: e === "lg" ? "md" : "sm",
368
- intent: "ghost",
369
- flipIconInRtl: !0,
370
- disabled: !M || m,
371
- onClick: X
372
- }
373
- )
374
- ] }),
375
- b
376
- ]
377
- }
378
- );
379
- }
380
- );
381
- Ds.displayName = "SlotGrid";
382
- export {
383
- Ds as S,
384
- Ts as f,
385
- Rs as i
386
- };
387
- //# sourceMappingURL=slot-grid-Dz13dH82.js.map