+150
-122
@@ -34,39 +34,41 @@ declare interface Atomico<Props, PropsForInstance, Base> | ||
| export declare const CalendarDate: Atomico<{ | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| export declare const CalendarDate: Atomico< { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| } & {}, { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
@@ -80,15 +82,15 @@ | ||
| export declare const CalendarMonth: Atomico<{ | ||
| offset: number; | ||
| onSelectDay: (event: CustomEvent<string>) => any; | ||
| onFocusDay: (event: CustomEvent<string>) => any; | ||
| onHoverDay: (event: CustomEvent<string>) => any; | ||
| export declare const CalendarMonth: Atomico< { | ||
| offset: number; | ||
| onSelectDay: (event: CustomEvent<string>) => any; | ||
| onFocusDay: (event: CustomEvent<string>) => any; | ||
| onHoverDay: (event: CustomEvent<string>) => any; | ||
| } & {}, { | ||
| offset: number; | ||
| onSelectDay: (event: CustomEvent<string>) => any; | ||
| onFocusDay: (event: CustomEvent<string>) => any; | ||
| onHoverDay: (event: CustomEvent<string>) => any; | ||
| offset: number; | ||
| onSelectDay: (event: CustomEvent<string>) => any; | ||
| onFocusDay: (event: CustomEvent<string>) => any; | ||
| onHoverDay: (event: CustomEvent<string>) => any; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
@@ -98,39 +100,41 @@ | ||
| export declare const CalendarMulti: Atomico<{ | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| export declare const CalendarMulti: Atomico< { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| } & {}, { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
@@ -140,45 +144,47 @@ | ||
| export declare const CalendarRange: Atomico<{ | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| tentative: string; | ||
| onRangeStart: (event: CustomEvent<Date>) => any; | ||
| onRangeEnd: (event: CustomEvent<Date>) => any; | ||
| export declare const CalendarRange: Atomico< { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| tentative: string; | ||
| onRangeStart: (event: CustomEvent<Date>) => any; | ||
| onRangeEnd: (event: CustomEvent<Date>) => any; | ||
| } & {}, { | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| tentative: string; | ||
| onRangeStart: (event: CustomEvent<Date>) => any; | ||
| onRangeEnd: (event: CustomEvent<Date>) => any; | ||
| months: number; | ||
| value: string; | ||
| focus: (options?: CalendarFocusOptions) => void; | ||
| firstDayOfWeek: DaysOfWeek; | ||
| isDateDisallowed: (date: Date) => boolean; | ||
| min: string; | ||
| max: string; | ||
| today: string; | ||
| locale: string | undefined; | ||
| focusedDate: string | undefined; | ||
| formatWeekday: "short" | "narrow"; | ||
| onFocusDay: (event: CustomEvent<Date>) => any; | ||
| getDayParts: (date: Date) => string; | ||
| showOutsideDays: boolean; | ||
| showWeekNumbers: boolean; | ||
| pageBy: Pagination; | ||
| onChange: (event: Event) => any; | ||
| tentative: string; | ||
| onRangeStart: (event: CustomEvent<Date>) => any; | ||
| onRangeEnd: (event: CustomEvent<Date>) => any; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
@@ -188,2 +194,24 @@ | ||
| export declare const CalendarSelectMonth: Atomico< { | ||
| formatMonth: "long" | "short"; | ||
| } & {}, { | ||
| formatMonth: "long" | "short"; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
| export declare type CalendarSelectMonthProps = ComponentProps<typeof CalendarSelectMonth>; | ||
| export declare const CalendarSelectYear: Atomico< { | ||
| maxYears: number; | ||
| } & {}, { | ||
| maxYears: number; | ||
| } & {}, { | ||
| new (): HTMLElement; | ||
| prototype: HTMLElement; | ||
| }>; | ||
| export declare type CalendarSelectYearProps = ComponentProps<typeof CalendarSelectYear>; | ||
| declare type CheckEvent<CurrentEvent, True> = CurrentEvent extends Event ? True : never; | ||
@@ -190,0 +218,0 @@ |
+621
-505
@@ -1,2 +0,2 @@ | ||
| class se { | ||
| class le { | ||
| /** | ||
@@ -32,58 +32,55 @@ * @type {T} | ||
| } | ||
| const At = (e) => new se(e), nt = Symbol.for("atomico.hooks"); | ||
| globalThis[nt] = globalThis[nt] || {}; | ||
| let O = globalThis[nt]; | ||
| const oe = Symbol.for("Atomico.suspense"), Ft = Symbol.for("Atomico.effect"), re = Symbol.for("Atomico.layoutEffect"), Rt = Symbol.for("Atomico.insertionEffect"), M = (e, t, n) => { | ||
| const { i: s, hooks: r } = O.c, o = r[s] = r[s] || {}; | ||
| return o.value = e(o.value), o.effect = t, o.tag = n, O.c.i++, r[s].value; | ||
| }, ae = (e) => M((t = At(e)) => t), _ = () => M((e = At(O.c.host)) => e), $t = () => O.c.update, ce = (e, t, n = 0) => { | ||
| let s = {}, r = !1; | ||
| const o = () => r, a = (l, c) => { | ||
| const Rt = (e) => new le(e), st = Symbol.for("atomico.hooks"); | ||
| globalThis[st] = globalThis[st] || {}; | ||
| let A = globalThis[st]; | ||
| const ue = Symbol.for("Atomico.suspense"), Yt = Symbol.for("Atomico.effect"), fe = Symbol.for("Atomico.layoutEffect"), Ft = Symbol.for("Atomico.insertionEffect"), U = (e, t, n) => { | ||
| const { i: s, hooks: o } = A.c, r = o[s] = o[s] || {}; | ||
| return r.value = e(r.value), r.effect = t, r.tag = n, A.c.i++, o[s].value; | ||
| }, It = (e) => U((t = Rt(e)) => t), H = () => U((e = Rt(A.c.host)) => e), Lt = () => A.c.update, de = (e, t, n = 0) => { | ||
| let s = {}, o = !1; | ||
| const r = () => o, a = (l, c) => { | ||
| for (const d in s) { | ||
| const f = s[d]; | ||
| f.effect && f.tag === l && (f.value = f.effect(f.value, c)); | ||
| const i = s[d]; | ||
| i.effect && i.tag === l && (i.value = i.effect(i.value, c)); | ||
| } | ||
| }; | ||
| return { load: (l) => { | ||
| O.c = { host: t, hooks: s, update: e, i: 0, id: n }; | ||
| A.c = { host: t, hooks: s, update: e, i: 0, id: n }; | ||
| let c; | ||
| try { | ||
| r = !1, c = l(); | ||
| o = !1, c = l(); | ||
| } catch (d) { | ||
| if (d !== oe) | ||
| throw d; | ||
| r = !0; | ||
| if (d !== ue) throw d; | ||
| o = !0; | ||
| } finally { | ||
| O.c = null; | ||
| A.c = null; | ||
| } | ||
| return c; | ||
| }, cleanEffects: (l) => (a(Rt, l), () => (a(re, l), () => { | ||
| a(Ft, l); | ||
| })), isSuspense: o }; | ||
| }, A = Symbol.for; | ||
| function It(e, t) { | ||
| }, cleanEffects: (l) => (a(Ft, l), () => (a(fe, l), () => { | ||
| a(Yt, l); | ||
| })), isSuspense: r }; | ||
| }, L = Symbol.for; | ||
| function xt(e, t) { | ||
| const n = e.length; | ||
| if (n !== t.length) | ||
| return !1; | ||
| if (n !== t.length) return !1; | ||
| for (let s = 0; s < n; s++) { | ||
| let r = e[s], o = t[s]; | ||
| if (r !== o) | ||
| return !1; | ||
| let o = e[s], r = t[s]; | ||
| if (o !== r) return !1; | ||
| } | ||
| return !0; | ||
| } | ||
| const T = (e) => typeof e == "function", R = (e) => typeof e == "object", { isArray: ie } = Array, st = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {}); | ||
| function Ut(e, t) { | ||
| const T = (e) => typeof e == "function", Y = (e) => typeof e == "object", { isArray: he } = Array, ot = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {}); | ||
| function _t(e, t) { | ||
| let n; | ||
| const s = (r) => { | ||
| let { length: o } = r; | ||
| for (let a = 0; a < o; a++) { | ||
| const u = r[a]; | ||
| const s = (o) => { | ||
| let { length: r } = o; | ||
| for (let a = 0; a < r; a++) { | ||
| const u = o[a]; | ||
| if (u && Array.isArray(u)) | ||
| s(u); | ||
| else { | ||
| const i = typeof u; | ||
| if (u == null || i === "function" || i === "boolean") | ||
| const f = typeof u; | ||
| if (u == null || f === "function" || f === "boolean") | ||
| continue; | ||
| i === "string" || i === "number" ? (n == null && (n = ""), n += u) : (n != null && (t(n), n = null), t(u)); | ||
| f === "string" || f === "number" ? (n == null && (n = ""), n += u) : (n != null && (t(n), n = null), t(u)); | ||
| } | ||
@@ -94,4 +91,4 @@ } | ||
| } | ||
| const Lt = (e, t, n) => (e.addEventListener(t, n), () => e.removeEventListener(t, n)); | ||
| class _t { | ||
| const jt = (e, t, n) => (e.addEventListener(t, n), () => e.removeEventListener(t, n)); | ||
| class Bt { | ||
| /** | ||
@@ -107,15 +104,15 @@ * | ||
| } | ||
| class jt extends _t { | ||
| class qt extends Bt { | ||
| } | ||
| class le extends _t { | ||
| class me extends Bt { | ||
| } | ||
| const x = "Custom", ue = null, fe = { true: 1, "": 1, 1: 1 }; | ||
| function de(e, t, n, s, r) { | ||
| const q = "Custom", ye = null, pe = { true: 1, "": 1, 1: 1 }; | ||
| function be(e, t, n, s, o) { | ||
| const { | ||
| type: o, | ||
| type: r, | ||
| reflect: a, | ||
| event: u, | ||
| value: i, | ||
| attr: l = he(t) | ||
| } = n?.name != x && R(n) && n != ue ? n : { type: n }, c = o?.name === x && o.map, d = i != null ? o == Function || !T(i) ? () => i : i : null; | ||
| value: f, | ||
| attr: l = ge(t) | ||
| } = n?.name != q && Y(n) && n != ye ? n : { type: n }, c = r?.name === q && r.map, d = f != null ? r == Function || !T(f) ? () => f : f : null; | ||
| Object.defineProperty(e, t, { | ||
@@ -127,17 +124,17 @@ configurable: !0, | ||
| */ | ||
| set(f) { | ||
| set(i) { | ||
| const m = this[t]; | ||
| d && o != Boolean && f == null && (f = d()); | ||
| const { error: E, value: g } = (c ? pe : be)( | ||
| o, | ||
| f | ||
| d && r != Boolean && i == null && (i = d()); | ||
| const { error: b, value: g } = (c ? Ee : we)( | ||
| r, | ||
| i | ||
| ); | ||
| if (E && g != null) | ||
| throw new jt( | ||
| if (b && g != null) | ||
| throw new qt( | ||
| this, | ||
| `The value defined for prop '${t}' must be of type '${o.name}'`, | ||
| `The value defined for prop '${t}' must be of type '${r.name}'`, | ||
| g | ||
| ); | ||
| m != g && (this._props[t] = g ?? void 0, this.update(), u && Yt(this, u), this.updated.then(() => { | ||
| a && (this._ignoreAttr = l, me(this, o, l, this[t]), this._ignoreAttr = null); | ||
| m != g && (this._props[t] = g ?? void 0, this.update(), u && zt(this, u), this.updated.then(() => { | ||
| a && (this._ignoreAttr = l, De(this, r, l, this[t]), this._ignoreAttr = null); | ||
| })); | ||
@@ -151,11 +148,11 @@ }, | ||
| } | ||
| }), d && (r[t] = d()), s[l] = { prop: t, type: o }; | ||
| }), d && (o[t] = d()), s[l] = { prop: t, type: r }; | ||
| } | ||
| const Yt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), he = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), me = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute( | ||
| const zt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), ge = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), De = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute( | ||
| n, | ||
| t?.name === x && t?.serialize ? t?.serialize(s) : R(s) ? JSON.stringify(s) : t == Boolean ? "" : s | ||
| ), ye = (e, t) => e == Boolean ? !!fe[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == x ? t : ( | ||
| t?.name === q && t?.serialize ? t?.serialize(s) : Y(s) ? JSON.stringify(s) : t == Boolean ? "" : s | ||
| ), Ce = (e, t) => e == Boolean ? !!pe[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == q ? t : ( | ||
| // TODO: If when defining reflect the prop can also be of type string? | ||
| new e(t) | ||
| ), pe = ({ map: e }, t) => { | ||
| ), Ee = ({ map: e }, t) => { | ||
| try { | ||
@@ -166,3 +163,3 @@ return { value: e(t), error: !1 }; | ||
| } | ||
| }, be = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? { | ||
| }, we = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? { | ||
| value: t, | ||
@@ -177,13 +174,12 @@ error: {}.toString.call(t) !== `[object ${e.name}]` | ||
| } : { value: t, error: !0 }; | ||
| let ge = 0; | ||
| const ve = (e) => { | ||
| let ve = 0; | ||
| const Se = (e) => { | ||
| const t = (e?.dataset || {})?.hydrate || ""; | ||
| return t || "c" + ge++; | ||
| }, j = (e, t = HTMLElement) => { | ||
| const n = {}, s = {}, r = "prototype" in t && t.prototype instanceof Element, o = r ? t : "base" in t ? t.base : HTMLElement, { props: a, styles: u } = r ? e : t; | ||
| class i extends o { | ||
| return t || "c" + ve++; | ||
| }, k = (e, t = HTMLElement) => { | ||
| const n = {}, s = {}, o = "prototype" in t && t.prototype instanceof Element, r = o ? t : "base" in t ? t.base : HTMLElement, { props: a, styles: u } = o ? e : t; | ||
| class f extends r { | ||
| constructor() { | ||
| super(), this._setup(), this._render = () => e({ ...this._props }); | ||
| for (const c in s) | ||
| this[c] = s[c]; | ||
| for (const c in s) this[c] = s[c]; | ||
| } | ||
@@ -197,4 +193,3 @@ /** | ||
| async _setup() { | ||
| if (this._props) | ||
| return; | ||
| if (this._props) return; | ||
| this._props = {}; | ||
@@ -208,17 +203,17 @@ let c, d; | ||
| (y) => this.unmount = () => { | ||
| y(), (c != this.parentNode || !this.isConnected) && (f.cleanEffects(!0)()(), d = this.parentNode, c = null); | ||
| y(), (c != this.parentNode || !this.isConnected) && (i.cleanEffects(!0)()(), d = this.parentNode, c = null); | ||
| } | ||
| ), this.symbolId = this.symbolId || Symbol(), this.symbolIdParent = Symbol(); | ||
| const f = ce( | ||
| const i = de( | ||
| () => this.update(), | ||
| this, | ||
| ve(this) | ||
| Se(this) | ||
| ); | ||
| let m, E = !0; | ||
| const g = st(this); | ||
| let m, b = !0; | ||
| const g = ot(this); | ||
| this.update = () => (m || (m = !0, this.updated = (this.updated || this.mounted).then(() => { | ||
| try { | ||
| const y = f.load(this._render), h = f.cleanEffects(); | ||
| const y = i.load(this._render), p = i.cleanEffects(); | ||
| return y && //@ts-ignore | ||
| y.render(this, this.symbolId, g), m = !1, E && !f.isSuspense() && (E = !1, !g && Ee(this)), h(); | ||
| y.render(this, this.symbolId, g), m = !1, b && !i.isSuspense() && (b = !1, !g && Te(this)), p(); | ||
| } finally { | ||
@@ -248,18 +243,17 @@ m = !1; | ||
| */ | ||
| attributeChangedCallback(c, d, f) { | ||
| attributeChangedCallback(c, d, i) { | ||
| if (n[c]) { | ||
| if (c === this._ignoreAttr || d === f) | ||
| return; | ||
| const { prop: m, type: E } = n[c]; | ||
| if (c === this._ignoreAttr || d === i) return; | ||
| const { prop: m, type: b } = n[c]; | ||
| try { | ||
| this[m] = ye(E, f); | ||
| this[m] = Ce(b, i); | ||
| } catch { | ||
| throw new le( | ||
| throw new me( | ||
| this, | ||
| `The value defined as attr '${c}' cannot be parsed by type '${E.name}'`, | ||
| f | ||
| `The value defined as attr '${c}' cannot be parsed by type '${b.name}'`, | ||
| i | ||
| ); | ||
| } | ||
| } else | ||
| super.attributeChangedCallback(c, d, f); | ||
| super.attributeChangedCallback(c, d, i); | ||
| } | ||
@@ -272,19 +266,19 @@ static get props() { | ||
| for (const d in a) | ||
| de(this.prototype, d, a[d], n, s); | ||
| be(this.prototype, d, a[d], n, s); | ||
| return Object.keys(n).concat(c); | ||
| } | ||
| } | ||
| return i; | ||
| return f; | ||
| }; | ||
| function Ee(e) { | ||
| function Te(e) { | ||
| const { styles: t } = e.constructor, { shadowRoot: n } = e; | ||
| if (n && t.length) { | ||
| const s = []; | ||
| Ut(t, (r) => { | ||
| r && (r instanceof Element ? n.appendChild(r.cloneNode(!0)) : s.push(r)); | ||
| _t(t, (o) => { | ||
| o && (o instanceof Element ? n.appendChild(o.cloneNode(!0)) : s.push(o)); | ||
| }), s.length && (n.adoptedStyleSheets = s); | ||
| } | ||
| } | ||
| const Bt = (e) => (t, n) => { | ||
| M( | ||
| const Ht = (e) => (t, n) => { | ||
| U( | ||
| /** | ||
@@ -294,11 +288,11 @@ * Clean the effect hook | ||
| */ | ||
| ([s, r] = []) => ((r || !r) && (r && It(r, n) ? s = s || !0 : (T(s) && s(), s = null)), [s, n]), | ||
| ([s, o] = []) => ((o || !o) && (o && xt(o, n) ? s = s || !0 : (T(s) && s(), s = null)), [s, n]), | ||
| /** | ||
| * @returns {any} | ||
| */ | ||
| ([s, r], o) => o ? (T(s) && s(), []) : [s || t(), r], | ||
| ([s, o], r) => r ? (T(s) && s(), []) : [s || t(), o], | ||
| e | ||
| ); | ||
| }, U = Bt(Ft), De = Bt(Rt); | ||
| class qt extends Array { | ||
| }, I = Ht(Yt), Pe = Ht(Ft); | ||
| class Wt extends Array { | ||
| /** | ||
@@ -311,5 +305,5 @@ * | ||
| let s = !0; | ||
| const r = (o) => { | ||
| const o = (r) => { | ||
| try { | ||
| n(o, this, s); | ||
| n(r, this, s); | ||
| } finally { | ||
@@ -319,3 +313,3 @@ s = !1; | ||
| }; | ||
| super(void 0, r, n), r(t); | ||
| super(void 0, o, n), o(t); | ||
| } | ||
@@ -335,16 +329,16 @@ /** | ||
| } | ||
| const ct = (e) => { | ||
| const t = $t(); | ||
| return M( | ||
| (n = new qt(e, (s, r, o) => { | ||
| s = T(s) ? s(r[0]) : s, s !== r[0] && (r[0] = s, o || t()); | ||
| const it = (e) => { | ||
| const t = Lt(); | ||
| return U( | ||
| (n = new Wt(e, (s, o, r) => { | ||
| s = T(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t()); | ||
| })) => n | ||
| ); | ||
| }, C = (e, t) => { | ||
| const [n] = M(([s, r, o = 0] = []) => ((!r || r && !It(r, t)) && (s = e()), [s, t, o])); | ||
| }, S = (e, t) => { | ||
| const [n] = U(([s, o, r = 0] = []) => ((!o || o && !xt(o, t)) && (s = e()), [s, t, r])); | ||
| return n; | ||
| }, it = (e) => { | ||
| const { current: t } = _(); | ||
| }, lt = (e) => { | ||
| const { current: t } = H(); | ||
| if (!(e in t)) | ||
| throw new jt( | ||
| throw new qt( | ||
| t, | ||
@@ -354,4 +348,4 @@ `For useProp("${e}"), the prop does not exist on the host.`, | ||
| ); | ||
| return M( | ||
| (n = new qt(t[e], (s, r) => { | ||
| return U( | ||
| (n = new Wt(t[e], (s, o) => { | ||
| s = T(s) ? s(t[e]) : s, t[e] = s; | ||
@@ -361,4 +355,4 @@ })) => (n[0] = t[e], n) | ||
| }, P = (e, t = {}) => { | ||
| const n = _(); | ||
| return n[e] || (n[e] = (s = t.detail) => Yt(n.current, { | ||
| const n = H(); | ||
| return n[e] || (n[e] = (s = t.detail) => zt(n.current, { | ||
| type: e, | ||
@@ -368,11 +362,13 @@ ...t, | ||
| })), n[e]; | ||
| }, ot = A("atomico/options"); | ||
| globalThis[ot] = globalThis[ot] || { | ||
| }, rt = L("atomico/options"); | ||
| globalThis[rt] = globalThis[rt] || { | ||
| sheet: !!document.adoptedStyleSheets | ||
| }; | ||
| const xt = globalThis[ot], Se = { | ||
| const W = globalThis[rt], Me = new Promise((e) => { | ||
| W.ssr || (document.readyState === "loading" ? jt(document, "DOMContentLoaded", e) : e()); | ||
| }), Ne = { | ||
| checked: 1, | ||
| value: 1, | ||
| selected: 1 | ||
| }, we = { | ||
| }, ke = { | ||
| list: 1, | ||
@@ -387,3 +383,3 @@ type: 1, | ||
| slot: 1 | ||
| }, Te = { | ||
| }, Oe = { | ||
| shadowDom: 1, | ||
@@ -394,29 +390,29 @@ staticNode: 1, | ||
| key: 1 | ||
| }, q = {}, rt = []; | ||
| class at extends Text { | ||
| }, B = {}, at = []; | ||
| class ct extends Text { | ||
| } | ||
| const Ce = A("atomico/id"), $ = A("atomico/type"), X = A("atomico/ref"), zt = A("atomico/vnode"), Pe = () => { | ||
| const Ae = L("atomico/id"), F = L("atomico/type"), Q = L("atomico/ref"), Kt = L("atomico/vnode"), Jt = () => { | ||
| }; | ||
| function Ne(e, t, n) { | ||
| return Kt(this, e, t, n); | ||
| function $e(e, t, n) { | ||
| return Xt(this, e, t, n); | ||
| } | ||
| const Ht = (e, t, ...n) => { | ||
| const s = t || q; | ||
| let { children: r } = s; | ||
| if (r = r ?? (n.length ? n : rt), e === Pe) | ||
| return r; | ||
| const o = e ? e instanceof Node ? 1 : ( | ||
| const Zt = (e, t, ...n) => { | ||
| const s = t || B; | ||
| let { children: o } = s; | ||
| if (o = o ?? (n.length ? n : at), e === Jt) | ||
| return o; | ||
| const r = e ? e instanceof Node ? 1 : ( | ||
| //@ts-ignore | ||
| e.prototype instanceof HTMLElement && 2 | ||
| ) : 0; | ||
| if (o === !1 && e instanceof Function) | ||
| if (r === !1 && e instanceof Function) | ||
| return e( | ||
| r != rt ? { children: r, ...s } : s | ||
| o != at ? { children: o, ...s } : s | ||
| ); | ||
| const a = xt.render || Ne; | ||
| const a = W.render || $e; | ||
| return { | ||
| [$]: zt, | ||
| [F]: Kt, | ||
| type: e, | ||
| props: s, | ||
| children: r, | ||
| children: o, | ||
| key: s.key, | ||
@@ -429,3 +425,3 @@ // key for lists by keys | ||
| // defines whether the type is a childNode `1` or a constructor `2` | ||
| raw: o, | ||
| raw: r, | ||
| // defines whether to use the second parameter for document.createElement | ||
@@ -438,7 +434,7 @@ is: s.is, | ||
| }; | ||
| function Kt(e, t, n = Ce, s, r) { | ||
| let o; | ||
| if (t && t[n] && t[n].vnode == e || e[$] != zt) | ||
| function Xt(e, t, n = Ae, s, o) { | ||
| let r; | ||
| if (t && t[n] && t[n].vnode == e || e[F] != Kt) | ||
| return t; | ||
| (e || !t) && (r = r || e.type == "svg", o = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[X] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[X] || t.localName != e.type : !t), o && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[X] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : r ? document.createElementNS( | ||
| (e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[Q] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[Q] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[Q] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS( | ||
| "http://www.w3.org/2000/svg", | ||
@@ -450,11 +446,10 @@ e.type | ||
| ))); | ||
| const a = t[n] ? t[n] : q, { vnode: u = q, cycle: i = 0 } = a; | ||
| const a = t[n] ? t[n] : B, { vnode: u = B, cycle: f = 0 } = a; | ||
| let { fragment: l, handlers: c } = a; | ||
| const { children: d = rt, props: f = q } = u; | ||
| if (c = o ? {} : c || {}, e.static && !o) | ||
| return t; | ||
| const { children: d = at, props: i = B } = u; | ||
| if (c = r ? {} : c || {}, e.static && !r) return t; | ||
| if (e.shadow && !t.shadowRoot && // @ts-ignore | ||
| t.attachShadow({ mode: "open", ...e.shadow }), e.props != f && Me(t, f, e.props, c, r), e.children !== d) { | ||
| t.attachShadow({ mode: "open", ...e.shadow }), e.props != i && Ye(t, i, e.props, c, o), e.children !== d) { | ||
| const m = e.shadow ? t.shadowRoot : t; | ||
| l = Oe( | ||
| l = Re( | ||
| e.children, | ||
@@ -468,23 +463,23 @@ /** | ||
| // add support to foreignObject, children will escape from svg | ||
| !i && s, | ||
| r && e.type == "foreignObject" ? !1 : r | ||
| !f && s, | ||
| o && e.type == "foreignObject" ? !1 : o | ||
| ); | ||
| } | ||
| return t[n] = { vnode: e, handlers: c, fragment: l, cycle: i + 1 }, t; | ||
| return t[n] = { vnode: e, handlers: c, fragment: l, cycle: f + 1 }, t; | ||
| } | ||
| function ke(e, t) { | ||
| const n = new at(""), s = new at(""); | ||
| let r; | ||
| function Ue(e, t) { | ||
| const n = new ct(""), s = new ct(""); | ||
| let o; | ||
| if (e[t ? "prepend" : "append"](n), t) { | ||
| let { lastElementChild: o } = e; | ||
| for (; o; ) { | ||
| const { previousElementSibling: a } = o; | ||
| if (st(o, !0) && !st(a, !0)) { | ||
| r = o; | ||
| let { lastElementChild: r } = e; | ||
| for (; r; ) { | ||
| const { previousElementSibling: a } = r; | ||
| if (ot(r, !0) && !ot(a, !0)) { | ||
| o = r; | ||
| break; | ||
| } | ||
| o = a; | ||
| r = a; | ||
| } | ||
| } | ||
| return r ? r.before(s) : e.append(s), { | ||
| return o ? o.before(s) : e.append(s), { | ||
| markStart: n, | ||
@@ -494,39 +489,41 @@ markEnd: s | ||
| } | ||
| function Oe(e, t, n, s, r, o) { | ||
| e = e == null ? null : ie(e) ? e : [e]; | ||
| const a = t || ke(n, r), { markStart: u, markEnd: i, keyes: l } = a; | ||
| function Re(e, t, n, s, o, r) { | ||
| e = e == null ? null : he(e) ? e : [e]; | ||
| const a = t || Ue(n, o), { markStart: u, markEnd: f, keyes: l } = a; | ||
| let c; | ||
| const d = l && /* @__PURE__ */ new Set(); | ||
| let f = u; | ||
| if (e && Ut(e, (m) => { | ||
| if (typeof m == "object" && !m[$]) | ||
| let i = u; | ||
| if (e && _t(e, (m) => { | ||
| if (typeof m == "object" && !m[F]) | ||
| return; | ||
| const E = m[$] && m.key, g = l && E != null && l.get(E); | ||
| f != i && f === g ? d.delete(f) : f = f == i ? i : f.nextSibling; | ||
| const y = l ? g : f; | ||
| let h = y; | ||
| if (m[$]) | ||
| h = Kt(m, y, s, r, o); | ||
| const b = m[F] && m.key, g = l && b != null && l.get(b); | ||
| i != f && i === g ? d.delete(i) : i = i == f ? f : i.nextSibling; | ||
| const y = l ? g : i; | ||
| let p = y; | ||
| if (m[F]) | ||
| p = Xt(m, y, s, o, r); | ||
| else { | ||
| const S = m + ""; | ||
| !(h instanceof Text) || h instanceof at ? h = new Text(S) : h.data != S && (h.data = S); | ||
| const v = m + ""; | ||
| !(p instanceof Text) || p instanceof ct ? p = new Text(v) : p.data != v && (p.data = v); | ||
| } | ||
| h != f && (l && d.delete(h), !y || l ? (n.insertBefore(h, f), l && f != i && d.add(f)) : y == i ? n.insertBefore(h, i) : (n.replaceChild(h, y), f = h)), E != null && (c = c || /* @__PURE__ */ new Map(), c.set(E, h)); | ||
| }), f = f == i ? i : f.nextSibling, t && f != i) | ||
| for (; f != i; ) { | ||
| const m = f; | ||
| f = f.nextSibling, m.remove(); | ||
| p != i && (l && d.delete(p), !y || l ? (n.insertBefore(p, i), l && i != f && d.add(i)) : y == f ? n.insertBefore(p, f) : (n.replaceChild(p, y), i = p)), b != null && (c = c || /* @__PURE__ */ new Map(), c.set(b, p)); | ||
| }), i = i == f ? f : i.nextSibling, t && i != f) | ||
| for (; i != f; ) { | ||
| const m = i; | ||
| i = i.nextSibling, m.remove(); | ||
| } | ||
| return d && d.forEach((m) => m.remove()), a.keyes = c, a; | ||
| } | ||
| function Me(e, t, n, s, r) { | ||
| for (const o in t) | ||
| !(o in n) && St(e, o, t[o], null, r, s); | ||
| for (const o in n) | ||
| St(e, o, t[o], n[o], r, s); | ||
| function Ye(e, t, n, s, o) { | ||
| for (const r in t) | ||
| !(r in n) && Tt(e, r, t[r], null, o, s); | ||
| for (const r in n) | ||
| Tt(e, r, t[r], n[r], o, s); | ||
| } | ||
| function St(e, t, n, s, r, o) { | ||
| if (t = t == "class" && !r ? "className" : t, n = n ?? null, s = s ?? null, t in e && Se[t] && (n = e[t]), !(s === n || Te[t] || t[0] == "_")) | ||
| if (t[0] == "o" && t[1] == "n" && (T(s) || T(n))) | ||
| Ae(e, t.slice(2), s, o); | ||
| function Tt(e, t, n, s, o, r) { | ||
| if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Ne[t] && (n = e[t]), !(s === n || Oe[t] || t[0] == "_")) | ||
| if (e.localName === "slot" && t === "assignNode" && "assign" in e) | ||
| e.assign(s); | ||
| else if (t[0] == "o" && t[1] == "n" && (T(s) || T(n))) | ||
| Fe(e, t.slice(2), s, r); | ||
| else if (t == "ref") | ||
@@ -537,13 +534,13 @@ s && (T(s) ? s(e) : s.current = e); | ||
| n = n || "", s = s || ""; | ||
| const u = R(n), i = R(s); | ||
| const u = Y(n), f = Y(s); | ||
| if (u) | ||
| for (const l in n) | ||
| if (i) | ||
| !(l in s) && wt(a, l, null); | ||
| if (f) | ||
| !(l in s) && Pt(a, l, null); | ||
| else | ||
| break; | ||
| if (i) | ||
| if (f) | ||
| for (const l in s) { | ||
| const c = s[l]; | ||
| u && n[l] === c || wt(a, l, c); | ||
| u && n[l] === c || Pt(a, l, c); | ||
| } | ||
@@ -554,13 +551,13 @@ else | ||
| const a = t[0] == "$" ? t.slice(1) : t; | ||
| a === t && (!r && !we[t] && t in e || T(s) || T(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(a) : e.setAttribute( | ||
| a === t && (!o && !ke[t] && t in e || T(s) || T(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(a) : e.setAttribute( | ||
| a, | ||
| R(s) ? JSON.stringify(s) : s | ||
| Y(s) ? JSON.stringify(s) : s | ||
| ); | ||
| } | ||
| } | ||
| function Ae(e, t, n, s) { | ||
| if (s.handleEvent || (s.handleEvent = (r) => s[r.type].call(e, r)), n) { | ||
| function Fe(e, t, n, s) { | ||
| if (s.handleEvent || (s.handleEvent = (o) => s[o.type].call(e, o)), n) { | ||
| if (!s[t]) { | ||
| const r = n.capture || n.once || n.passive ? Object.assign({}, n) : null; | ||
| e.addEventListener(t, s, r); | ||
| const o = n.capture || n.once || n.passive ? Object.assign({}, n) : null; | ||
| e.addEventListener(t, s, o); | ||
| } | ||
@@ -571,27 +568,10 @@ s[t] = n; | ||
| } | ||
| function wt(e, t, n) { | ||
| function Pt(e, t, n) { | ||
| let s = "setProperty"; | ||
| n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n; | ||
| } | ||
| const Tt = {}; | ||
| function H(e, ...t) { | ||
| const n = (e.raw || e).reduce( | ||
| (s, r, o) => s + r + (t[o] || ""), | ||
| "" | ||
| ); | ||
| return Tt[n] = Tt[n] || Fe(n); | ||
| } | ||
| function Fe(e) { | ||
| if (xt.sheet) { | ||
| const t = new CSSStyleSheet(); | ||
| return t.replaceSync(e), t; | ||
| } else { | ||
| const t = document.createElement("style"); | ||
| return t.textContent = e, t; | ||
| } | ||
| } | ||
| const Re = Ht("host", { style: "display: contents" }), G = A("atomico/context"), $e = (e, t) => { | ||
| const n = _(); | ||
| De( | ||
| () => Lt( | ||
| const Ie = Zt("host", { style: "display: contents" }), Gt = "value", Le = (e, t) => { | ||
| const n = H(), s = It(); | ||
| Pe( | ||
| () => jt( | ||
| n.current, | ||
@@ -602,39 +582,39 @@ "ConnectContext", | ||
| */ | ||
| (s) => { | ||
| e === s.detail.id && (s.stopPropagation(), s.detail.connect(t)); | ||
| (o) => { | ||
| o.composedPath().at(0) !== o.currentTarget && e === o.detail.id && (o.stopPropagation(), o.detail.connect(s)); | ||
| } | ||
| ), | ||
| [e] | ||
| ); | ||
| }, Ie = (e) => { | ||
| ), s.current = t; | ||
| }, ut = (e) => { | ||
| const t = P("ConnectContext", { | ||
| bubbles: !0, | ||
| composed: !0 | ||
| }), n = () => { | ||
| let o; | ||
| }), [n, s] = it(() => { | ||
| if (W.ssr) return; | ||
| let r; | ||
| return t({ | ||
| id: e, | ||
| /** | ||
| * @param {import("core").Ref} parentContext | ||
| */ | ||
| connect(a) { | ||
| o = a; | ||
| r = a; | ||
| } | ||
| }), o; | ||
| }, [s, r] = ct( | ||
| n | ||
| ); | ||
| return U(() => { | ||
| s || (e[G] || (e[G] = customElements.whenDefined( | ||
| new e().localName | ||
| )), e[G].then( | ||
| () => r(n) | ||
| )); | ||
| }, [e]), s; | ||
| }, Ue = (e) => { | ||
| const t = Ie(e), n = $t(); | ||
| return U(() => { | ||
| if (t) | ||
| return Lt(t, "UpdatedValue", n); | ||
| }, [t]), (t || e).value; | ||
| }, Le = (e) => { | ||
| const t = j( | ||
| () => ($e(t, _().current), Re), | ||
| }), r; | ||
| }), o = Lt(); | ||
| return I(() => { | ||
| Me.then( | ||
| () => t({ | ||
| id: e, | ||
| connect: s | ||
| }) | ||
| ); | ||
| }, [e]), I(() => { | ||
| if (n) | ||
| return n.on(o); | ||
| }, [n]), n?.current || e[Gt]; | ||
| }, Qt = (e) => { | ||
| const t = k( | ||
| ({ value: n }) => (Le(t, n), Ie), | ||
| { | ||
@@ -644,3 +624,2 @@ props: { | ||
| type: Object, | ||
| event: { type: "UpdatedValue" }, | ||
| value: () => e | ||
@@ -651,32 +630,68 @@ } | ||
| ); | ||
| return t.value = e, t; | ||
| }, p = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Ht(e, t)), I = p, Wt = H`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, Jt = H`.vh{position:absolute;transform:scale(0)}`; | ||
| function lt() { | ||
| return t[Gt] = e, t; | ||
| }; | ||
| Qt({ | ||
| /** | ||
| * | ||
| * @param {string} type | ||
| * @param {string} id | ||
| */ | ||
| dispatch(e, t) { | ||
| } | ||
| }); | ||
| const Mt = {}; | ||
| function K(e, ...t) { | ||
| const n = (e.raw || e).reduce( | ||
| (s, o, r) => s + o + (t[r] || ""), | ||
| "" | ||
| ); | ||
| return Mt[n] = Mt[n] || xe(n); | ||
| } | ||
| function xe(e) { | ||
| if (W.sheet) { | ||
| const t = new CSSStyleSheet(); | ||
| return t.replaceSync(e), t; | ||
| } else { | ||
| const t = document.createElement("style"); | ||
| return t.textContent = e, t; | ||
| } | ||
| } | ||
| const h = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Zt(e, t)), M = h, ft = K`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, dt = K`.vh{position:absolute;transform:scale(0)}`; | ||
| function ht() { | ||
| const e = /* @__PURE__ */ new Date(); | ||
| return new v(e.getFullYear(), e.getMonth() + 1, e.getDate()); | ||
| return new C(e.getFullYear(), e.getMonth() + 1, e.getDate()); | ||
| } | ||
| function ut(e, t = 0) { | ||
| const n = w(e), s = n.getUTCDay(), r = (s < t ? 7 : 0) + s - t; | ||
| return n.setUTCDate(n.getUTCDate() - r), v.from(n); | ||
| const _e = 864e5; | ||
| function je(e) { | ||
| const t = w(e); | ||
| t.setDate(t.getUTCDate() + 3 - (t.getUTCDay() + 6) % 7); | ||
| const n = new Date(t.getUTCFullYear(), 0, 4); | ||
| return 1 + Math.round( | ||
| ((t.getTime() - n.getTime()) / _e - 3 + (n.getUTCDay() + 6) % 7) / 7 | ||
| ); | ||
| } | ||
| function Zt(e, t = 0) { | ||
| return ut(e, t).add({ days: 6 }); | ||
| function mt(e, t = 0) { | ||
| const n = w(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t; | ||
| return n.setUTCDate(n.getUTCDate() - o), C.from(n); | ||
| } | ||
| function Xt(e) { | ||
| return v.from(new Date(Date.UTC(e.year, e.month, 0))); | ||
| function Vt(e, t = 0) { | ||
| return mt(e, t).add({ days: 6 }); | ||
| } | ||
| function K(e, t, n) { | ||
| return t && v.compare(e, t) < 0 ? t : n && v.compare(e, n) > 0 ? n : e; | ||
| function te(e) { | ||
| return C.from(new Date(Date.UTC(e.year, e.month, 0))); | ||
| } | ||
| const _e = { days: 1 }; | ||
| function je(e, t = 0) { | ||
| let n = ut(e.toPlainDate(), t); | ||
| const s = Zt(Xt(e), t), r = []; | ||
| for (; v.compare(n, s) < 0; ) { | ||
| const o = []; | ||
| function J(e, t, n) { | ||
| return t && C.compare(e, t) < 0 ? t : n && C.compare(e, n) > 0 ? n : e; | ||
| } | ||
| const Be = { days: 1 }; | ||
| function qe(e, t = 0) { | ||
| let n = mt(e.toPlainDate(), t); | ||
| const s = Vt(te(e), t), o = []; | ||
| for (; C.compare(n, s) < 0; ) { | ||
| const r = []; | ||
| for (let a = 0; a < 7; a++) | ||
| o.push(n), n = n.add(_e); | ||
| r.push(o); | ||
| r.push(n), n = n.add(Be); | ||
| o.push(r); | ||
| } | ||
| return r; | ||
| return o; | ||
| } | ||
@@ -686,4 +701,4 @@ function w(e) { | ||
| } | ||
| const Ye = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Q = (e, t) => e.toString().padStart(t, "0"); | ||
| class v { | ||
| const ze = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, V = (e, t) => e.toString().padStart(t, "0"); | ||
| class C { | ||
| constructor(t, n, s) { | ||
@@ -698,16 +713,16 @@ this.year = t, this.month = n, this.day = s; | ||
| if ("days" in t) | ||
| return n.setUTCDate(this.day + t.days), v.from(n); | ||
| let { year: s, month: r } = this; | ||
| "months" in t ? (r = this.month + t.months, n.setUTCMonth(r - 1)) : (s = this.year + t.years, n.setUTCFullYear(s)); | ||
| const o = v.from(w({ year: s, month: r, day: 1 })); | ||
| return K(v.from(n), o, Xt(o)); | ||
| return n.setUTCDate(this.day + t.days), C.from(n); | ||
| let { year: s, month: o } = this; | ||
| "months" in t ? (o = this.month + t.months, n.setUTCMonth(o - 1)) : (s = this.year + t.years, n.setUTCFullYear(s)); | ||
| const r = C.from(w({ year: s, month: o, day: 1 })); | ||
| return J(C.from(n), r, te(r)); | ||
| } | ||
| toString() { | ||
| return `${Q(this.year, 4)}-${Q(this.month, 2)}-${Q(this.day, 2)}`; | ||
| return `${V(this.year, 4)}-${V(this.month, 2)}-${V(this.day, 2)}`; | ||
| } | ||
| toPlainYearMonth() { | ||
| return new W(this.year, this.month); | ||
| return new Z(this.year, this.month); | ||
| } | ||
| equals(t) { | ||
| return v.compare(this, t) === 0; | ||
| return C.compare(this, t) === 0; | ||
| } | ||
@@ -719,13 +734,13 @@ static compare(t, n) { | ||
| if (typeof t == "string") { | ||
| const n = t.match(Ye); | ||
| const n = t.match(ze); | ||
| if (!n) | ||
| throw new TypeError(t); | ||
| const [, s, r, o] = n; | ||
| return new v( | ||
| const [, s, o, r] = n; | ||
| return new C( | ||
| parseInt(s, 10), | ||
| parseInt(r, 10), | ||
| parseInt(o, 10) | ||
| parseInt(o, 10), | ||
| parseInt(r, 10) | ||
| ); | ||
| } | ||
| return new v( | ||
| return new C( | ||
| t.getUTCFullYear(), | ||
@@ -737,3 +752,3 @@ t.getUTCMonth() + 1, | ||
| } | ||
| class W { | ||
| class Z { | ||
| constructor(t, n) { | ||
@@ -744,3 +759,3 @@ this.year = t, this.month = n; | ||
| const n = w(this), s = (t.months ?? 0) + (t.years ?? 0) * 12; | ||
| return n.setUTCMonth(n.getUTCMonth() + s), new W(n.getUTCFullYear(), n.getUTCMonth() + 1); | ||
| return n.setUTCMonth(n.getUTCMonth() + s), new Z(n.getUTCFullYear(), n.getUTCMonth() + 1); | ||
| } | ||
@@ -751,3 +766,3 @@ equals(t) { | ||
| toPlainDate() { | ||
| return new v(this.year, this.month, 1); | ||
| return new C(this.year, this.month, 1); | ||
| } | ||
@@ -763,25 +778,25 @@ } | ||
| function N(e) { | ||
| const [t, n] = it(e); | ||
| return [C(() => z(v, t), [t]), (o) => n(o?.toString())]; | ||
| const [t, n] = lt(e); | ||
| return [S(() => z(C, t), [t]), (r) => n(r?.toString())]; | ||
| } | ||
| function Be(e) { | ||
| const [t = "", n] = it(e); | ||
| return [C(() => { | ||
| const [o, a] = t.split("/"), u = z(v, o), i = z(v, a); | ||
| return u && i ? [u, i] : []; | ||
| }, [t]), (o) => n(`${o[0]}/${o[1]}`)]; | ||
| function He(e) { | ||
| const [t = "", n] = lt(e); | ||
| return [S(() => { | ||
| const [r, a] = t.split("/"), u = z(C, r), f = z(C, a); | ||
| return u && f ? [u, f] : []; | ||
| }, [t]), (r) => n(`${r[0]}/${r[1]}`)]; | ||
| } | ||
| function qe(e) { | ||
| const [t = "", n] = it(e); | ||
| return [C(() => { | ||
| const o = []; | ||
| function We(e) { | ||
| const [t = "", n] = lt(e); | ||
| return [S(() => { | ||
| const r = []; | ||
| for (const a of t.trim().split(/\s+/)) { | ||
| const u = z(v, a); | ||
| u && o.push(u); | ||
| const u = z(C, a); | ||
| u && r.push(u); | ||
| } | ||
| return o; | ||
| }, [t]), (o) => n(o.join(" "))]; | ||
| return r; | ||
| }, [t]), (r) => n(r.join(" "))]; | ||
| } | ||
| function L(e, t) { | ||
| return C( | ||
| function $(e, t) { | ||
| return S( | ||
| () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }), | ||
@@ -791,64 +806,64 @@ [t, e] | ||
| } | ||
| function Ct(e, t, n) { | ||
| const s = L(e, n); | ||
| return C(() => { | ||
| const r = [], o = /* @__PURE__ */ new Date(); | ||
| function Nt(e, t, n) { | ||
| const s = $(e, n); | ||
| return S(() => { | ||
| const o = [], r = /* @__PURE__ */ new Date(); | ||
| for (var a = 0; a < 7; a++) { | ||
| const u = (o.getUTCDay() - t + 7) % 7; | ||
| r[u] = s.format(o), o.setUTCDate(o.getUTCDate() + 1); | ||
| const u = (r.getUTCDay() - t + 7) % 7; | ||
| o[u] = s.format(r), r.setUTCDate(r.getUTCDate() + 1); | ||
| } | ||
| return r; | ||
| return o; | ||
| }, [t, s]); | ||
| } | ||
| const Pt = (e, t, n) => K(e, t, n) === e, Nt = (e) => e.target.matches(":dir(ltr)"), xe = { month: "long", day: "numeric" }, ze = { month: "long" }, He = { weekday: "long" }, V = { bubbles: !0 }; | ||
| function Ke({ props: e, context: t }) { | ||
| const kt = (e, t, n) => J(e, t, n) === e, Ot = (e) => e.target.matches(":dir(ltr)"), Ke = { month: "long", day: "numeric" }, Je = { month: "long" }, Ze = { weekday: "long" }, tt = { bubbles: !0 }; | ||
| function Xe({ props: e, context: t }) { | ||
| const { offset: n } = e, { | ||
| firstDayOfWeek: s, | ||
| isDateDisallowed: r, | ||
| min: o, | ||
| isDateDisallowed: o, | ||
| min: r, | ||
| max: a, | ||
| today: u, | ||
| page: i, | ||
| page: f, | ||
| locale: l, | ||
| focusedDate: c, | ||
| formatWeekday: d | ||
| } = t, f = u ?? lt(), m = Ct(He, s, l), E = C( | ||
| } = t, i = u ?? ht(), m = Nt(Ze, s, l), b = S( | ||
| () => ({ weekday: d }), | ||
| [d] | ||
| ), g = Ct(E, s, l), y = L(xe, l), h = L(ze, l), S = C( | ||
| () => i.start.add({ months: n }), | ||
| [i, n] | ||
| ), J = C( | ||
| () => je(S, s), | ||
| [S, s] | ||
| ), Gt = P("focusday", V), Qt = P("selectday", V), Vt = P("hoverday", V); | ||
| function pt(b) { | ||
| Gt(K(b, o, a)); | ||
| ), g = Nt(b, s, l), y = $(Ke, l), p = $(Je, l), v = S( | ||
| () => f.start.add({ months: n }), | ||
| [f, n] | ||
| ), X = S( | ||
| () => qe(v, s), | ||
| [v, s] | ||
| ), se = P("focusday", tt), oe = P("selectday", tt), re = P("hoverday", tt); | ||
| function Dt(D) { | ||
| se(J(D, r, a)); | ||
| } | ||
| function te(b) { | ||
| let D; | ||
| switch (b.key) { | ||
| function ae(D) { | ||
| let E; | ||
| switch (D.key) { | ||
| case "ArrowRight": | ||
| D = c.add({ days: Nt(b) ? 1 : -1 }); | ||
| E = c.add({ days: Ot(D) ? 1 : -1 }); | ||
| break; | ||
| case "ArrowLeft": | ||
| D = c.add({ days: Nt(b) ? -1 : 1 }); | ||
| E = c.add({ days: Ot(D) ? -1 : 1 }); | ||
| break; | ||
| case "ArrowDown": | ||
| D = c.add({ days: 7 }); | ||
| E = c.add({ days: 7 }); | ||
| break; | ||
| case "ArrowUp": | ||
| D = c.add({ days: -7 }); | ||
| E = c.add({ days: -7 }); | ||
| break; | ||
| case "PageUp": | ||
| D = c.add(b.shiftKey ? { years: -1 } : { months: -1 }); | ||
| E = c.add(D.shiftKey ? { years: -1 } : { months: -1 }); | ||
| break; | ||
| case "PageDown": | ||
| D = c.add(b.shiftKey ? { years: 1 } : { months: 1 }); | ||
| E = c.add(D.shiftKey ? { years: 1 } : { months: 1 }); | ||
| break; | ||
| case "Home": | ||
| D = ut(c, s); | ||
| E = mt(c, s); | ||
| break; | ||
| case "End": | ||
| D = Zt(c, s); | ||
| E = Vt(c, s); | ||
| break; | ||
@@ -858,30 +873,29 @@ default: | ||
| } | ||
| pt(D), b.preventDefault(); | ||
| Dt(E), D.preventDefault(); | ||
| } | ||
| function ee(b) { | ||
| const D = S.equals(b); | ||
| if (!t.showOutsideDays && !D) | ||
| function ce(D) { | ||
| const E = v.equals(D); | ||
| if (!t.showOutsideDays && !E) | ||
| return; | ||
| const ne = b.equals(c), bt = b.equals(f), Y = w(b), B = r?.(Y), gt = !Pt(b, o, a); | ||
| let vt = "", k; | ||
| const ie = D.equals(c), Ct = D.equals(i), _ = w(D), j = o?.(_), Et = !kt(D, r, a); | ||
| let wt = "", O; | ||
| if (t.type === "range") { | ||
| const [F, Z] = t.value, Et = F?.equals(b), Dt = Z?.equals(b); | ||
| k = F && Z && Pt(b, F, Z), vt = `${Et ? "range-start" : ""} ${Dt ? "range-end" : ""} ${k && !Et && !Dt ? "range-inner" : ""}`; | ||
| } else | ||
| t.type === "multi" ? k = t.value.some((F) => F.equals(b)) : k = t.value?.equals(b); | ||
| const [R, G] = t.value, vt = R?.equals(D), St = G?.equals(D); | ||
| O = R && G && kt(D, R, G), wt = `${vt ? "range-start" : ""} ${St ? "range-end" : ""} ${O && !vt && !St ? "range-inner" : ""}`; | ||
| } else t.type === "multi" ? O = t.value.some((R) => R.equals(D)) : O = t.value?.equals(D); | ||
| return { | ||
| part: `${`button day day-${Y.getDay()} ${// we don't want outside days to ever be shown as selected | ||
| D ? k ? "selected" : "" : "outside"} ${B ? "disallowed" : ""} ${bt ? "today" : ""} ${t.getDayParts?.(Y) ?? ""}`} ${vt}`, | ||
| tabindex: D && ne ? 0 : -1, | ||
| disabled: gt, | ||
| "aria-disabled": B ? "true" : void 0, | ||
| "aria-pressed": D && k, | ||
| "aria-current": bt ? "date" : void 0, | ||
| "aria-label": y.format(Y), | ||
| onkeydown: te, | ||
| part: `${`button day day-${_.getDay()} ${// we don't want outside days to ever be shown as selected | ||
| E ? O ? "selected" : "" : "outside"} ${j ? "disallowed" : ""} ${Ct ? "today" : ""} ${t.getDayParts?.(_) ?? ""}`} ${wt}`, | ||
| tabindex: E && ie ? 0 : -1, | ||
| disabled: Et, | ||
| "aria-disabled": j ? "true" : void 0, | ||
| "aria-pressed": E && O, | ||
| "aria-current": Ct ? "date" : void 0, | ||
| "aria-label": y.format(_), | ||
| onkeydown: ae, | ||
| onclick() { | ||
| B || Qt(b), pt(b); | ||
| j || oe(D), Dt(D); | ||
| }, | ||
| onmouseover() { | ||
| !B && !gt && Vt(b); | ||
| !j && !Et && re(D); | ||
| } | ||
@@ -891,41 +905,57 @@ }; | ||
| return { | ||
| weeks: J, | ||
| yearMonth: S, | ||
| weeks: X, | ||
| yearMonth: v, | ||
| daysLong: m, | ||
| daysVisible: g, | ||
| formatter: h, | ||
| getDayProps: ee | ||
| formatter: p, | ||
| getDayProps: ce | ||
| }; | ||
| } | ||
| const tt = lt(), ft = Le({ | ||
| const et = ht(), x = Qt({ | ||
| type: "date", | ||
| firstDayOfWeek: 1, | ||
| focusedDate: tt, | ||
| page: { start: tt.toPlainYearMonth(), end: tt.toPlainYearMonth() } | ||
| focusedDate: et, | ||
| page: { start: et.toPlainYearMonth(), end: et.toPlainYearMonth() } | ||
| }); | ||
| customElements.define("calendar-ctx", ft); | ||
| const We = (e, t) => (t + e) % 7, Je = j( | ||
| customElements.define("calendar-ctx", x); | ||
| const Ge = (e, t) => (t + e) % 7, Qe = k( | ||
| (e) => { | ||
| const t = Ue(ft), n = ae(), s = Ke({ props: e, context: t }); | ||
| function r() { | ||
| const t = ut(x), n = It(), s = Xe({ props: e, context: t }); | ||
| function o() { | ||
| n.current.querySelector("button[tabindex='0']")?.focus(); | ||
| } | ||
| return /* @__PURE__ */ I("host", { shadowDom: !0, focus: r, children: [ | ||
| /* @__PURE__ */ p("div", { id: "h", part: "heading", children: s.formatter.format(w(s.yearMonth)) }), | ||
| /* @__PURE__ */ I("table", { ref: n, "aria-labelledby": "h", part: "table", children: [ | ||
| /* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { part: "tr head", children: s.daysLong.map((o, a) => /* @__PURE__ */ I( | ||
| "th", | ||
| { | ||
| part: `th day day-${We(t.firstDayOfWeek, a)}`, | ||
| scope: "col", | ||
| children: [ | ||
| /* @__PURE__ */ p("span", { class: "vh", children: o }), | ||
| /* @__PURE__ */ p("span", { "aria-hidden": "true", children: s.daysVisible[a] }) | ||
| ] | ||
| } | ||
| )) }) }), | ||
| /* @__PURE__ */ p("tbody", { children: s.weeks.map((o, a) => /* @__PURE__ */ p("tr", { part: "tr week", children: o.map((u, i) => { | ||
| const l = s.getDayProps(u); | ||
| return /* @__PURE__ */ p("td", { part: "td", children: l && /* @__PURE__ */ p("button", { ...l, children: u.day }) }, i); | ||
| }) }, a)) }) | ||
| return /* @__PURE__ */ M("host", { shadowDom: !0, focus: o, children: [ | ||
| /* @__PURE__ */ h("div", { id: "h", part: "heading", children: s.formatter.format(w(s.yearMonth)) }), | ||
| /* @__PURE__ */ M("table", { ref: n, "aria-labelledby": "h", part: "table", children: [ | ||
| /* @__PURE__ */ M("colgroup", { children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("col", { part: "col-weeknumber" }), | ||
| /* @__PURE__ */ h("col", { part: "col-1" }), | ||
| /* @__PURE__ */ h("col", { part: "col-2" }), | ||
| /* @__PURE__ */ h("col", { part: "col-3" }), | ||
| /* @__PURE__ */ h("col", { part: "col-4" }), | ||
| /* @__PURE__ */ h("col", { part: "col-5" }), | ||
| /* @__PURE__ */ h("col", { part: "col-6" }), | ||
| /* @__PURE__ */ h("col", { part: "col-7" }) | ||
| ] }), | ||
| /* @__PURE__ */ h("thead", { children: /* @__PURE__ */ M("tr", { part: "tr head", children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("th", { part: "th weeknumber", children: /* @__PURE__ */ h("slot", { name: "weeknumber", children: /* @__PURE__ */ h("span", { "aria-label": "Week", children: "#" }) }) }), | ||
| s.daysLong.map((r, a) => /* @__PURE__ */ M( | ||
| "th", | ||
| { | ||
| part: `th day day-${Ge(t.firstDayOfWeek, a)}`, | ||
| scope: "col", | ||
| children: [ | ||
| /* @__PURE__ */ h("span", { class: "vh", children: r }), | ||
| /* @__PURE__ */ h("span", { "aria-hidden": "true", children: s.daysVisible[a] }) | ||
| ] | ||
| } | ||
| )) | ||
| ] }) }), | ||
| /* @__PURE__ */ h("tbody", { children: s.weeks.map((r, a) => /* @__PURE__ */ M("tr", { part: "tr week", children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("th", { class: "num", part: "th weeknumber", scope: "row", children: je(r[0]) }), | ||
| r.map((u, f) => { | ||
| const l = s.getDayProps(u); | ||
| return /* @__PURE__ */ h("td", { part: "td", children: l && /* @__PURE__ */ h("button", { class: "num", ...l, children: u.day }) }, f); | ||
| }) | ||
| ] }, a)) }) | ||
| ] }) | ||
@@ -942,11 +972,11 @@ ] }); | ||
| styles: [ | ||
| Wt, | ||
| Jt, | ||
| H`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{font-weight:700;block-size:2.25rem}td{padding-inline:0}button{color:inherit;font-size:inherit;background:transparent;border:0;font-variant-numeric:tabular-nums;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled,[aria-disabled])){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}` | ||
| ft, | ||
| dt, | ||
| K`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{inline-size:2.25rem;block-size:2.25rem}td{padding-inline:0}.num{font-variant-numeric:tabular-nums}button{color:inherit;font-size:inherit;background:transparent;border:0;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled,[aria-disabled])){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}` | ||
| ] | ||
| } | ||
| ); | ||
| customElements.define("calendar-month", Je); | ||
| function kt(e) { | ||
| return /* @__PURE__ */ p( | ||
| customElements.define("calendar-month", Qe); | ||
| function At(e) { | ||
| return /* @__PURE__ */ h( | ||
| "button", | ||
@@ -957,28 +987,28 @@ { | ||
| "aria-disabled": e.onclick ? null : "true", | ||
| children: /* @__PURE__ */ p("slot", { name: e.name, children: e.children }) | ||
| children: /* @__PURE__ */ h("slot", { name: e.name, children: e.children }) | ||
| } | ||
| ); | ||
| } | ||
| function dt(e) { | ||
| function yt(e) { | ||
| const t = w(e.page.start), n = w(e.page.end); | ||
| return /* @__PURE__ */ I("div", { role: "group", "aria-labelledby": "h", part: "container", children: [ | ||
| /* @__PURE__ */ p("div", { id: "h", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, n) }), | ||
| /* @__PURE__ */ I("div", { part: "header", children: [ | ||
| /* @__PURE__ */ p(kt, { name: "previous", onclick: e.previous, children: "Previous" }), | ||
| /* @__PURE__ */ p("slot", { part: "heading", name: "heading", children: /* @__PURE__ */ p("div", { "aria-hidden": "true", children: e.format.formatRange(t, n) }) }), | ||
| /* @__PURE__ */ p(kt, { name: "next", onclick: e.next, children: "Next" }) | ||
| ] }), | ||
| /* @__PURE__ */ p( | ||
| ft, | ||
| { | ||
| value: e, | ||
| onselectday: e.onSelect, | ||
| onfocusday: e.onFocus, | ||
| onhoverday: e.onHover, | ||
| children: /* @__PURE__ */ p("slot", {}) | ||
| } | ||
| ) | ||
| ] }); | ||
| return /* @__PURE__ */ h( | ||
| x, | ||
| { | ||
| value: e, | ||
| onselectday: e.onSelect, | ||
| onfocusday: e.onFocus, | ||
| onhoverday: e.onHover, | ||
| children: /* @__PURE__ */ M("div", { role: "group", "aria-labelledby": "h", part: "container", children: [ | ||
| /* @__PURE__ */ h("div", { id: "h", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, n) }), | ||
| /* @__PURE__ */ M("div", { part: "header", children: [ | ||
| /* @__PURE__ */ h(At, { name: "previous", onclick: e.previous, children: "Previous" }), | ||
| /* @__PURE__ */ h("slot", { part: "heading", name: "heading", children: /* @__PURE__ */ h("div", { "aria-hidden": "true", children: e.format.formatRange(t, n) }) }), | ||
| /* @__PURE__ */ h(At, { name: "next", onclick: e.next, children: "Next" }) | ||
| ] }), | ||
| /* @__PURE__ */ h("slot", { part: "months" }) | ||
| ] }) | ||
| } | ||
| ); | ||
| } | ||
| const ht = { | ||
| const pt = { | ||
| value: { | ||
@@ -1037,16 +1067,20 @@ type: String, | ||
| value: () => "months" | ||
| }, | ||
| showWeekNumbers: { | ||
| type: Boolean, | ||
| value: !1 | ||
| } | ||
| }, mt = [ | ||
| Wt, | ||
| Jt, | ||
| H`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}button{display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.5}` | ||
| ], Ze = { year: "numeric" }, Xe = { year: "numeric", month: "long" }; | ||
| function et(e, t) { | ||
| }, bt = [ | ||
| ft, | ||
| dt, | ||
| K`:host{display:block;inline-size:fit-content}:host::part(container){display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}:host::part(button){display:flex;align-items:center;justify-content:center}:host::part(button disabled){cursor:default;opacity:.5}` | ||
| ], Ve = { year: "numeric" }, tn = { year: "numeric", month: "long" }; | ||
| function nt(e, t) { | ||
| return (t.year - e.year) * 12 + t.month - e.month; | ||
| } | ||
| const Ot = (e, t) => (e = t === 12 ? new W(e.year, 1) : e, { | ||
| const $t = (e, t) => (e = t === 12 ? new Z(e.year, 1) : e, { | ||
| start: e, | ||
| end: e.add({ months: t - 1 }) | ||
| }); | ||
| function Ge({ | ||
| function en({ | ||
| pageBy: e, | ||
@@ -1056,28 +1090,28 @@ focusedDate: t, | ||
| max: s, | ||
| min: r, | ||
| goto: o | ||
| min: o, | ||
| goto: r | ||
| }) { | ||
| const a = e === "single" ? 1 : n, [u, i] = ct( | ||
| () => Ot(t.toPlainYearMonth(), n) | ||
| ), l = (d) => i(Ot(u.start.add({ months: d }), n)), c = (d) => { | ||
| const f = et(u.start, d.toPlainYearMonth()); | ||
| return f >= 0 && f < n; | ||
| const a = e === "single" ? 1 : n, [u, f] = it( | ||
| () => $t(t.toPlainYearMonth(), n) | ||
| ), l = (d) => f($t(u.start.add({ months: d }), n)), c = (d) => { | ||
| const i = nt(u.start, d.toPlainYearMonth()); | ||
| return i >= 0 && i < n; | ||
| }; | ||
| return U(() => { | ||
| return I(() => { | ||
| if (c(t)) | ||
| return; | ||
| const d = et(t.toPlainYearMonth(), u.start); | ||
| o(t.add({ months: d })); | ||
| }, [u.start]), U(() => { | ||
| const d = nt(t.toPlainYearMonth(), u.start); | ||
| r(t.add({ months: d })); | ||
| }, [u.start]), I(() => { | ||
| if (c(t)) | ||
| return; | ||
| const d = et(u.start, t.toPlainYearMonth()); | ||
| const d = nt(u.start, t.toPlainYearMonth()); | ||
| l(d === -1 ? -a : d === n ? a : Math.floor(d / n) * n); | ||
| }, [t, a, n]), { | ||
| page: u, | ||
| previous: !r || !c(r) ? () => l(-a) : void 0, | ||
| previous: !o || !c(o) ? () => l(-a) : void 0, | ||
| next: !s || !c(s) ? () => l(a) : void 0 | ||
| }; | ||
| } | ||
| function yt({ | ||
| function gt({ | ||
| months: e, | ||
@@ -1087,36 +1121,36 @@ pageBy: t, | ||
| focusedDate: s, | ||
| setFocusedDate: r | ||
| setFocusedDate: o | ||
| }) { | ||
| const [o] = N("min"), [a] = N("max"), [u] = N("today"), i = P("focusday"), l = P("change"), c = C( | ||
| () => K(s ?? u ?? lt(), o, a), | ||
| [s, u, o, a] | ||
| const [r] = N("min"), [a] = N("max"), [u] = N("today"), f = P("focusday"), l = P("change"), c = S( | ||
| () => J(s ?? u ?? ht(), r, a), | ||
| [s, u, r, a] | ||
| ); | ||
| function d(h) { | ||
| r(h), i(w(h)); | ||
| function d(p) { | ||
| o(p), f(w(p)); | ||
| } | ||
| const { next: f, previous: m, page: E } = Ge({ | ||
| const { next: i, previous: m, page: b } = en({ | ||
| pageBy: t, | ||
| focusedDate: c, | ||
| months: e, | ||
| min: o, | ||
| min: r, | ||
| max: a, | ||
| goto: d | ||
| }), g = _(); | ||
| function y(h) { | ||
| const S = h?.target ?? "day"; | ||
| S === "day" ? g.current.querySelectorAll("calendar-month").forEach((J) => J.focus(h)) : g.current.shadowRoot.querySelector(`[part~='${S}']`).focus(h); | ||
| }), g = H(); | ||
| function y(p) { | ||
| const v = p?.target ?? "day"; | ||
| v === "day" ? g.current.querySelectorAll("calendar-month").forEach((X) => X.focus(p)) : g.current.shadowRoot.querySelector(`[part~='${v}']`).focus(p); | ||
| } | ||
| return { | ||
| format: L(Ze, n), | ||
| formatVerbose: L(Xe, n), | ||
| page: E, | ||
| format: $(Ve, n), | ||
| formatVerbose: $(tn, n), | ||
| page: b, | ||
| focusedDate: c, | ||
| dispatch: l, | ||
| onFocus(h) { | ||
| h.stopPropagation(), d(h.detail), setTimeout(y); | ||
| onFocus(p) { | ||
| p.stopPropagation(), d(p.detail), setTimeout(y); | ||
| }, | ||
| min: o, | ||
| min: r, | ||
| max: a, | ||
| today: u, | ||
| next: f, | ||
| next: i, | ||
| previous: m, | ||
@@ -1126,17 +1160,17 @@ focus: y | ||
| } | ||
| const Qe = j( | ||
| const nn = k( | ||
| (e) => { | ||
| const [t, n] = N("value"), [s = t, r] = N("focusedDate"), o = yt({ | ||
| const [t, n] = N("value"), [s = t, o] = N("focusedDate"), r = gt({ | ||
| ...e, | ||
| focusedDate: s, | ||
| setFocusedDate: r | ||
| setFocusedDate: o | ||
| }); | ||
| function a(u) { | ||
| n(u.detail), o.dispatch(); | ||
| n(u.detail), r.dispatch(); | ||
| } | ||
| return /* @__PURE__ */ p("host", { shadowDom: !0, focus: o.focus, children: /* @__PURE__ */ p( | ||
| dt, | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ h( | ||
| yt, | ||
| { | ||
| ...e, | ||
| ...o, | ||
| ...r, | ||
| type: "date", | ||
@@ -1148,36 +1182,116 @@ value: t, | ||
| }, | ||
| { props: ht, styles: mt } | ||
| { props: pt, styles: bt } | ||
| ); | ||
| customElements.define("calendar-date", Qe); | ||
| const Mt = (e, t) => v.compare(e, t) < 0 ? [e, t] : [t, e], Ve = j( | ||
| customElements.define("calendar-date", nn); | ||
| function ee(e) { | ||
| return /* @__PURE__ */ M(Jt, { children: [ | ||
| /* @__PURE__ */ h("label", { part: "label", for: "s", children: /* @__PURE__ */ h("slot", { name: "label", children: e.label }) }), | ||
| /* @__PURE__ */ h("select", { id: "s", part: "select", onchange: e.onChange, children: e.options.map((t) => /* @__PURE__ */ h("option", { part: "option", ...t })) }) | ||
| ] }); | ||
| } | ||
| const ne = [ft, dt]; | ||
| function sn(e, t) { | ||
| return Array.from({ length: e }, (n, s) => t(s)); | ||
| } | ||
| function on(e) { | ||
| const { min: t, max: n, focusedDate: s } = ut(x), o = P("focusday", { bubbles: !0 }), r = s.toPlainYearMonth(), a = r.year, u = Math.floor(e.maxYears / 2), f = a - u, l = a + (e.maxYears - u - 1), c = Math.max(f, t?.year ?? -1 / 0), d = Math.min(l, n?.year ?? 1 / 0), i = sn(d - c + 1, (b) => { | ||
| const g = c + b; | ||
| return { | ||
| label: `${g}`, | ||
| value: `${g}`, | ||
| selected: g === r.year | ||
| }; | ||
| }); | ||
| function m(b) { | ||
| const y = parseInt(b.currentTarget.value) - r.year; | ||
| o(s.add({ years: y })); | ||
| } | ||
| return { options: i, onChange: m }; | ||
| } | ||
| const rn = k( | ||
| (e) => { | ||
| const [t, n] = Be("value"), [s = t[0], r] = N("focusedDate"), o = yt({ | ||
| const t = on(e); | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, children: /* @__PURE__ */ h(ee, { label: "Year", ...t }) }); | ||
| }, | ||
| { | ||
| props: { | ||
| maxYears: { type: Number, value: 20 } | ||
| }, | ||
| styles: ne | ||
| } | ||
| ); | ||
| customElements.define("calendar-select-year", rn); | ||
| function an(e) { | ||
| const { min: t, max: n, focusedDate: s, locale: o } = ut(x), r = P("focusday", { bubbles: !0 }), a = S( | ||
| () => ({ month: e.formatMonth }), | ||
| [e.formatMonth] | ||
| ), u = $(a, o), f = S(() => { | ||
| const i = [], m = /* @__PURE__ */ new Date(); | ||
| for (var b = 0; b < 12; b++) { | ||
| const g = (m.getUTCMonth() + 12) % 12; | ||
| i[g] = u.format(m), m.setUTCMonth(m.getUTCMonth() + 1); | ||
| } | ||
| return i; | ||
| }, [u]), l = s.toPlainYearMonth(), c = f.map((i, m) => { | ||
| const b = m + 1, g = l.add({ months: b - l.month }).toPlainDate(), y = t != null && C.compare(g, t) < 0 || n != null && C.compare(g, n) > 0; | ||
| return { | ||
| label: i, | ||
| value: `${b}`, | ||
| disabled: y, | ||
| selected: b === l.month | ||
| }; | ||
| }); | ||
| function d(i) { | ||
| const b = parseInt(i.currentTarget.value) - l.month; | ||
| r(s.add({ months: b })); | ||
| } | ||
| return { options: c, onChange: d }; | ||
| } | ||
| const cn = k( | ||
| (e) => { | ||
| const t = an(e); | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, children: /* @__PURE__ */ h(ee, { label: "Month", ...t }) }); | ||
| }, | ||
| { | ||
| props: { | ||
| formatMonth: { | ||
| type: String, | ||
| value: () => "long" | ||
| } | ||
| }, | ||
| styles: ne | ||
| } | ||
| ); | ||
| customElements.define("calendar-select-month", cn); | ||
| const Ut = (e, t) => C.compare(e, t) < 0 ? [e, t] : [t, e], ln = k( | ||
| (e) => { | ||
| const [t, n] = He("value"), [s = t[0], o] = N("focusedDate"), r = gt({ | ||
| ...e, | ||
| focusedDate: s, | ||
| setFocusedDate: r | ||
| }), a = P("rangestart"), u = P("rangeend"), [i, l] = N( | ||
| setFocusedDate: o | ||
| }), a = P("rangestart"), u = P("rangeend"), [f, l] = N( | ||
| "tentative" | ||
| ), [c, d] = ct(); | ||
| U(() => d(void 0), [i]); | ||
| function f(y) { | ||
| o.onFocus(y), m(y); | ||
| ), [c, d] = it(); | ||
| I(() => d(void 0), [f]); | ||
| function i(y) { | ||
| r.onFocus(y), m(y); | ||
| } | ||
| function m(y) { | ||
| y.stopPropagation(), i && d(y.detail); | ||
| y.stopPropagation(), f && d(y.detail); | ||
| } | ||
| function E(y) { | ||
| const h = y.detail; | ||
| y.stopPropagation(), i ? (n(Mt(i, h)), l(void 0), u(w(h)), o.dispatch()) : (l(h), a(w(h))); | ||
| function b(y) { | ||
| const p = y.detail; | ||
| y.stopPropagation(), f ? (n(Ut(f, p)), l(void 0), u(w(p)), r.dispatch()) : (l(p), a(w(p))); | ||
| } | ||
| const g = i ? Mt(i, c ?? i) : t; | ||
| return /* @__PURE__ */ p("host", { shadowDom: !0, focus: o.focus, children: /* @__PURE__ */ p( | ||
| dt, | ||
| const g = f ? Ut(f, c ?? f) : t; | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ h( | ||
| yt, | ||
| { | ||
| ...e, | ||
| ...o, | ||
| ...r, | ||
| type: "range", | ||
| value: g, | ||
| onFocus: f, | ||
| onFocus: i, | ||
| onHover: m, | ||
| onSelect: E | ||
| onSelect: b | ||
| } | ||
@@ -1188,3 +1302,3 @@ ) }); | ||
| props: { | ||
| ...ht, | ||
| ...pt, | ||
| tentative: { | ||
@@ -1195,22 +1309,22 @@ type: String, | ||
| }, | ||
| styles: mt | ||
| styles: bt | ||
| } | ||
| ); | ||
| customElements.define("calendar-range", Ve); | ||
| const tn = j( | ||
| customElements.define("calendar-range", ln); | ||
| const un = k( | ||
| (e) => { | ||
| const [t, n] = qe("value"), [s = t[0], r] = N("focusedDate"), o = yt({ | ||
| const [t, n] = We("value"), [s = t[0], o] = N("focusedDate"), r = gt({ | ||
| ...e, | ||
| focusedDate: s, | ||
| setFocusedDate: r | ||
| setFocusedDate: o | ||
| }); | ||
| function a(u) { | ||
| const i = [...t], l = t.findIndex((c) => c.equals(u.detail)); | ||
| l < 0 ? i.push(u.detail) : i.splice(l, 1), n(i), o.dispatch(); | ||
| const f = [...t], l = t.findIndex((c) => c.equals(u.detail)); | ||
| l < 0 ? f.push(u.detail) : f.splice(l, 1), n(f), r.dispatch(); | ||
| } | ||
| return /* @__PURE__ */ p("host", { shadowDom: !0, focus: o.focus, children: /* @__PURE__ */ p( | ||
| dt, | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ h( | ||
| yt, | ||
| { | ||
| ...e, | ||
| ...o, | ||
| ...r, | ||
| type: "multi", | ||
@@ -1222,10 +1336,12 @@ value: t, | ||
| }, | ||
| { props: ht, styles: mt } | ||
| { props: pt, styles: bt } | ||
| ); | ||
| customElements.define("calendar-multi", tn); | ||
| customElements.define("calendar-multi", un); | ||
| export { | ||
| Qe as CalendarDate, | ||
| Je as CalendarMonth, | ||
| tn as CalendarMulti, | ||
| Ve as CalendarRange | ||
| nn as CalendarDate, | ||
| Qe as CalendarMonth, | ||
| un as CalendarMulti, | ||
| ln as CalendarRange, | ||
| cn as CalendarSelectMonth, | ||
| rn as CalendarSelectYear | ||
| }; |
+17
-14
| { | ||
| "name": "cally", | ||
| "version": "0.8.0", | ||
| "version": "0.9.0", | ||
| "description": "small, feature-rich calendar components", | ||
@@ -37,21 +37,24 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "atomico": "^1.76.1" | ||
| "atomico": "^1.79.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@astrojs/check": "^0.5.9", | ||
| "@astrojs/check": "^0.9.4", | ||
| "@atomico/tsconfig": "^1.1.2", | ||
| "@atomico/vite": "^2.17.8", | ||
| "@atomico/vite": "^2.21.1", | ||
| "@open-wc/testing": "^4.0.0", | ||
| "@types/mocha": "^10.0.6", | ||
| "@web/dev-server-esbuild": "^1.0.2", | ||
| "@web/test-runner": "^0.18.0", | ||
| "@types/mocha": "^10.0.10", | ||
| "@web/dev-server-esbuild": "^1.0.4", | ||
| "@web/test-runner": "^0.20.0", | ||
| "@web/test-runner-commands": "^0.9.0", | ||
| "@web/test-runner-playwright": "^0.11.0", | ||
| "@web/test-runner-visual-regression": "^0.9.0", | ||
| "astro": "^4.5.10", | ||
| "postcss-nesting": "^12.1.1", | ||
| "prettier": "^3.2.5", | ||
| "typescript": "^5.3.3", | ||
| "vite": "^5.1.4", | ||
| "vite-plugin-dts": "^3.7.3" | ||
| "@web/test-runner-visual-regression": "^0.10.0", | ||
| "astro": "^5.5.6", | ||
| "hastscript": "^9.0.1", | ||
| "postcss-nesting": "^13.0.1", | ||
| "prettier": "^3.5.3", | ||
| "rehype-autolink-headings": "^7.1.0", | ||
| "rehype-slug": "^6.0.0", | ||
| "typescript": "^5.8.2", | ||
| "vite": "^6.2.4", | ||
| "vite-plugin-dts": "^4.5.3" | ||
| }, | ||
@@ -58,0 +61,0 @@ "overrides": { |
+2
-2
@@ -5,4 +5,4 @@ # Cally | ||
| - **Small bundle size** - less than 8.5KB min/gzip | ||
| - **Full feature set** - single dates, ranges, display multiple months | ||
| - **Small bundle size** - less than 9KB min/gzip | ||
| - **Full feature set** - single dates, multiple dates, ranges, display multiple months | ||
| - **HTML-friendly** - easy to author, framework-independent | ||
@@ -9,0 +9,0 @@ - **Minimal dependencies** - just one |
59060
8.53%1895
7.98%19
18.75%Updated