+3
-466
@@ -1,25 +0,5 @@ | ||
| declare interface Atomico<Props, PropsForInstance, Base> | ||
| extends AtomicoStatic<Props> { | ||
| new ( | ||
| props?: JSXProxy< | ||
| DOMTag<DOMThis<Base>, Props>, | ||
| AtomicoThis<PropsForInstance, Base> | ||
| > | ||
| ): AtomicoThis<PropsForInstance, Base>; | ||
| } | ||
| import { Atomico } from 'atomico/types/dom'; | ||
| import { DaysOfWeek } from '../utils/date.js'; | ||
| import { Pagination } from '../calendar-base/useCalendarBase.js'; | ||
| declare interface AtomicoStatic<Props> extends HTMLElement { | ||
| styles: Sheets[]; | ||
| props: SchemaInfer<Props>; | ||
| /** | ||
| * Meta property, allows associating the component's | ||
| * props in typescript to external environments. | ||
| */ | ||
| readonly "##props": Props; | ||
| /** | ||
| * Allows to identify a constructor created with Atomico | ||
| */ | ||
| readonly "##atomico": true; | ||
| } | ||
| declare type AtomicoThis<Props = {}, Base = HTMLElement> = Props & | ||
@@ -212,189 +192,4 @@ DOMThis<Base> & { | ||
| declare type CheckEvent<CurrentEvent, True> = CurrentEvent extends Event ? True : never; | ||
| declare type ComponentProps<T extends abstract new (...args: any) => any> = Simplify<Partial<Omit<InstanceType<T>, keyof HTMLElement | keyof AtomicoThis>>>; | ||
| declare type DaysOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6; | ||
| declare interface DOM$Attrs { | ||
| [prop: `\$${string}`]: Nullable<string>; | ||
| } | ||
| declare type DOMCleanKeys = | ||
| | keyof DOMGenericProperties | ||
| | `add${string}` | ||
| | `get${string}` | ||
| | `set${string}` | ||
| | `has${string}` | ||
| | `matches${string}` | ||
| | `remove${string}` | ||
| | `replace${string}` | ||
| | `querySelector${string}` | ||
| | `offset${string}` | ||
| | `append${string}` | ||
| | `request${string}` | ||
| | `scroll${string}` | ||
| | `is${string}` | ||
| | `toggle${string}` | ||
| | `webkit${string}` | ||
| | `insert${string}` | ||
| | `client${string}` | ||
| | `child${string}` | ||
| | `${string}_${string}` | ||
| | `${string}HTML` | ||
| | `${string}Child` | ||
| | `${string}Validity` | ||
| | `${string}Capture` | ||
| | `${string}ElementSibling` | ||
| | "classList" | ||
| | "attributes" | ||
| | "normalize" | ||
| | "closest" | ||
| | "localName" | ||
| | "contains" | ||
| | "animate" | ||
| | "attachShadow" | ||
| | "outerText" | ||
| | "attachInternals" | ||
| | "click" | ||
| | "tagName" | ||
| | "focus" | ||
| | "submit" | ||
| | "accessKeyLabel" | ||
| | "elements" | ||
| | "isContentEditable" | ||
| | "innerText" | ||
| | "prepend" | ||
| | "namespaceURI" | ||
| | "blur" | ||
| | "dataset" | ||
| | "shadowRoot" | ||
| | keyof Omit<ChildNode, "textContent">; | ||
| declare type DOMCustomTarget<Target> = { customTarget: Target }; | ||
| declare type DOMEvent< | ||
| Target = HTMLElement, | ||
| CurrentEvent = Event | ||
| > = Target extends string | ||
| ? CurrentEvent extends AtomicoStatic<any> | ||
| ? DOMGetEvent<Target, CurrentEvent> | ||
| : DOMEventType<Target, CurrentEvent> | ||
| : DOMTarget<DOMThis<Target>, CurrentEvent>; | ||
| declare type DOMEventHandler<Target, Handler> = Handler extends ( | ||
| ev: infer CurrentEvent | ||
| ) => any | ||
| ? CurrentEvent extends Event | ||
| ? (ev: DOMEvent<Target, CurrentEvent>) => any | ||
| : Handler | ||
| : Handler; | ||
| /** | ||
| * @todo Rename Handler to Listener | ||
| */ | ||
| declare type DOMEventHandlerKeys<P> = { | ||
| [I in keyof P]-?: NonNullable<P[I]> extends DOMEventHandlerValue<infer E> | ||
| ? CheckEvent<E, I> | ||
| : P[I] extends { value: DOMEventHandlerValue<infer E> } | ||
| ? CheckEvent<E, I> | ||
| : never; | ||
| }[keyof P]; | ||
| declare interface DOMEventHandlerType extends FunctionConstructor {} | ||
| declare interface DOMEventHandlerValue<CurrentEvent> { | ||
| (event: CurrentEvent): any; | ||
| } | ||
| declare type DOMEvents<Target> = { | ||
| [Prop in keyof Target]?: Prop extends `on${string}` | ||
| ? DOMEventHandler<Target, Target[Prop]> | ||
| : Target[Prop]; | ||
| }; | ||
| declare type DOMEventTarget<CurrentEvent, CurrentTarget, Target> = { | ||
| [I in keyof CurrentEvent]: I extends "currentTarget" | ||
| ? CurrentTarget | ||
| : I extends "target" | ||
| ? Target | ||
| : CurrentEvent[I]; | ||
| }; | ||
| declare type DOMEventType<Type extends string, CurrentEvent> = { | ||
| [I in keyof "0" as `on${Type}`]: { | ||
| type: DOMEventHandlerType; | ||
| value: DOMEventHandlerValue<CurrentEvent>; | ||
| }; | ||
| }; | ||
| declare interface DOMGenericProperties { | ||
| style?: string | Partial<CSSStyleDeclaration> | object; | ||
| class?: string; | ||
| id?: string; | ||
| slot?: string; | ||
| part?: string; | ||
| is?: string; | ||
| tabindex?: string | number; | ||
| role?: string; | ||
| shadowDom?: boolean | Partial<ShadowRootInit>; | ||
| staticNode?: boolean; | ||
| cloneNode?: boolean; | ||
| width?: string | number; | ||
| height?: string | number; | ||
| key?: any; | ||
| children?: any; | ||
| } | ||
| declare type DOMGetEvent< | ||
| Type extends string, | ||
| Element extends AtomicoStatic<any> | ||
| > = Element extends { | ||
| "##props": infer Props; | ||
| } | ||
| ? `on${Type}` extends keyof Props | ||
| ? DOMGetEventBefore<NonNullable<Props[`on${Type}`]>, DOMThis<Element>> | ||
| : Event | ||
| : Event; | ||
| declare type DOMGetEventBefore<Value, Target> = Value extends DOMEventHandlerValue< | ||
| infer Event | ||
| > | ||
| ? DOMEvent<HTMLElement, Event & DOMCustomTarget<Target>> | ||
| : null; | ||
| declare type DOMRef<Target> = { | ||
| ref?: DOMRefValue<Target>; | ||
| }; | ||
| declare type DOMRefValue<Target> = FillObject | ((target: Target) => any); | ||
| declare type DOMTag<Element, Props = null> = Props extends null | ||
| ? PropsNullable< | ||
| Omit<DOMEvents<Element>, DOMCleanKeys> & | ||
| DOMGenericProperties & | ||
| DOMRef<Element> | ||
| > & | ||
| DOM$Attrs & | ||
| DOMUnknown | ||
| : PropsNullable< | ||
| Props & | ||
| Omit<DOMEvents<Element & Props>, keyof Props | DOMCleanKeys> & | ||
| DOMGenericProperties & | ||
| DOMRef<Element & Props> | ||
| > & | ||
| DOM$Attrs & | ||
| DOMUnknown; | ||
| declare type DOMTarget< | ||
| Target, | ||
| CurrentEvent, | ||
| Targets = Element | Node | ||
| > = CurrentEvent extends { | ||
| customTarget: infer EventTarget; | ||
| } | ||
| ? DOMTarget<Target, Omit<CurrentEvent, "customTarget">, EventTarget> | ||
| : DOMEventTarget<CurrentEvent, Target, Targets>; | ||
| declare type DOMThis<Element> = Element extends new ( | ||
@@ -406,184 +201,2 @@ ...args: any[] | ||
| declare interface DOMUnknown { | ||
| [prop: string]: any; | ||
| } | ||
| declare type EventInit_2 = CustomEventInit<any> & { | ||
| type: string; | ||
| base?: typeof CustomEvent | typeof Event; | ||
| }; | ||
| declare type FillArray = any[]; | ||
| declare type FillConstructor = abstract new (...args: any) => any; | ||
| declare type FillFunction = (...args: any[]) => any; | ||
| /** | ||
| * Interface to fill in unknown properties like any | null | undefined | ||
| */ | ||
| declare interface FillObject { | ||
| [index: string]: any; | ||
| } | ||
| declare type FillPromise = Promise<any>; | ||
| declare type GetTypeSelf<value extends TypesSelfValues> = { | ||
| [I in keyof SelfConstructors]-?: value extends InstanceType< | ||
| SelfConstructors[I] | ||
| > | ||
| ? keyof value extends keyof InstanceType<SelfConstructors[I]> | ||
| ? SelfConstructors[I] | ||
| : never | ||
| : never; | ||
| }[keyof SelfConstructors]; | ||
| declare type JSXProxy<Props, This> = { | ||
| [I in keyof Props]?: I extends `on${string}` | ||
| ? NonNullable<Props[I]> extends DOMEventHandlerValue<infer CurrentEvent> | ||
| ? Nullable< | ||
| ( | ||
| ev: DOMEventTarget<CurrentEvent, This, Element | Node> | ||
| ) => any | ||
| > | ||
| : Props[I] | ||
| : I extends "ref" | ||
| ? DOMRefValue<This> | ||
| : Props[I]; | ||
| }; | ||
| declare type Nullable<T> = NonNullable<T> | undefined | null; | ||
| declare type Pagination = "single" | "months"; | ||
| declare type PropsNullable<Data> = { | ||
| [I in keyof Data]?: Nullable<Data[I]>; | ||
| }; | ||
| declare type SafeGlobal = | ||
| | "Event" | ||
| | "URL" | ||
| | "Range" | ||
| | "Image" | ||
| | "Crypto" | ||
| | "File" | ||
| | "Date" | ||
| | "Set" | ||
| | "Map" | ||
| | "RegExp" | ||
| | "Animation" | ||
| | `${string}Event` | ||
| | `Event${string}` | ||
| | `Clipboard${string}` | ||
| | `Animation${string}` | ||
| | `Form${string}` | ||
| | `Font${string}` | ||
| | `DOM${string}` | ||
| | `Touch${string}` | ||
| | `Mutation${string}` | ||
| | `Intersection${string}` | ||
| | `Message${string}` | ||
| | `HTML${string}` | ||
| | `SVG${string}` | ||
| | `Audio${string}` | ||
| | `Document${string}` | ||
| | `Weak${string}` | ||
| | `CSS${string}` | ||
| | `File${string}`; | ||
| declare type SchemaAny<Type> = | ||
| | SchemaReflect<{ | ||
| value: Type; | ||
| }> | ||
| | SchemaReflect<{ | ||
| value: () => Type; | ||
| }> | ||
| | SchemaReflect<{}>; | ||
| declare type SchemaBase = SchemaEvent & { | ||
| attr?: string; | ||
| }; | ||
| declare type SchemaEvent = { | ||
| event?: EventInit_2; | ||
| }; | ||
| declare type SchemaInfer<Props> = Required< | ||
| Omit< | ||
| { | ||
| [I in keyof Props]: Type<Props[I]>; | ||
| }, | ||
| DOMEventHandlerKeys<Props> | ||
| > | ||
| >; | ||
| declare type SchemaOnlyPropWrapper<Constructor, Type> = | ||
| | SchemaProp<{ | ||
| type: Constructor; | ||
| }> | ||
| | SchemaProp<{ | ||
| type: Constructor; | ||
| value: Type; | ||
| }> | ||
| | SchemaProp<{ | ||
| type: Constructor; | ||
| value: () => Type; | ||
| }>; | ||
| declare type SchemaProp<type> = SchemaEvent & type; | ||
| declare type SchemaReflect<type> = SchemaBase & { | ||
| reflect?: boolean; | ||
| } & type; | ||
| declare type SchemaReflectWrapper<Constructor, Type> = | ||
| | SchemaReflect<{ | ||
| type: Constructor; | ||
| }> | ||
| | SchemaReflect<{ | ||
| type: Constructor; | ||
| value: Type; | ||
| }> | ||
| | SchemaReflect<{ | ||
| type: Constructor; | ||
| value: () => Type; | ||
| }>; | ||
| declare type SchemaTypeCustom = | ||
| | TypeCustom<FillFunction> | ||
| | SchemaReflectWrapper<TypeCustom<FillFunction>, any>; | ||
| declare type Self = typeof window; | ||
| declare type SelfConstructors = Pick< | ||
| Self, | ||
| { | ||
| [I in keyof Self]-?: I extends string | ||
| ? I extends Capitalize<I> | ||
| ? Self[I] extends FillConstructor | ||
| ? Self[I] extends SelfIgnore | ||
| ? never | ||
| : I extends SafeGlobal | ||
| ? I | ||
| : never | ||
| : never | ||
| : never | ||
| : never; | ||
| }[keyof Self] | ||
| >; | ||
| declare type SelfIgnore = | ||
| | StringConstructor | ||
| | NumberConstructor | ||
| | BooleanConstructor | ||
| | FunctionConstructor | ||
| | ObjectConstructor | ||
| | PromiseConstructor | ||
| | SymbolConstructor | ||
| | ArrayConstructor; | ||
| declare type Sheet = CSSStyleSheet | HTMLStyleElement; | ||
| declare type Sheets = Sheet | Sheet[] | Sheets[]; | ||
| declare type Simplify<T> = { | ||
@@ -593,78 +206,2 @@ [K in keyof T]: T[K]; | ||
| declare type Type<type> = type extends string | ||
| ? TypeString<type> | ||
| : type extends number | ||
| ? TypeNumber<type> | ||
| : type extends boolean | ||
| ? TypeBoolean | ||
| : type extends TypeCustom<FillFunction> | ||
| ? SchemaTypeCustom | ||
| : type extends FillPromise | ||
| ? TypePromise<type> | ||
| : type extends symbol | ||
| ? TypeSymbol<type> | ||
| : type extends FillArray | ||
| ? TypeArray<type> | ||
| : type extends DOMStringMap | ||
| ? TypeObject<type> | ||
| : type extends TypesSelfValues | ||
| ? GetTypeSelf<type> extends never | ||
| ? TypesDiscard<type> | ||
| : TypeConstructor<GetTypeSelf<type>> | ||
| : TypesDiscard<type>; | ||
| declare type TypeAny<type = any> = null | SchemaAny<type>; | ||
| declare type TypeArray<type extends FillArray> = | ||
| | ArrayConstructor | ||
| | SchemaReflectWrapper<ArrayConstructor, type>; | ||
| declare type TypeBoolean = | ||
| | BooleanConstructor | ||
| | SchemaReflectWrapper<BooleanConstructor, true | false>; | ||
| declare type TypeConstructor<type extends FillConstructor> = | ||
| | type | ||
| | SchemaOnlyPropWrapper<type, InstanceType<type>>; | ||
| declare type TypeCustom<Map extends FillFunction> = { | ||
| name: "Custom"; | ||
| map: Map; | ||
| serialize?: (value: ReturnType<Map>) => string; | ||
| }; | ||
| declare type TypeFunction<type extends FillFunction> = | ||
| | FunctionConstructor | ||
| | SchemaOnlyPropWrapper<FunctionConstructor, type>; | ||
| declare type TypeNumber<type extends number> = | ||
| | NumberConstructor | ||
| | SchemaReflectWrapper<NumberConstructor, type>; | ||
| declare type TypeObject<type extends FillObject> = | ||
| | ObjectConstructor | ||
| | SchemaReflectWrapper<ObjectConstructor, type>; | ||
| declare type TypePromise<type extends FillPromise> = | ||
| | PromiseConstructor | ||
| | SchemaOnlyPropWrapper<PromiseConstructor, type>; | ||
| declare type TypesDiscard<type> = type extends FillFunction | ||
| ? TypeFunction<type> | ||
| : type extends FillObject | ||
| ? TypeObject<type> | ||
| : TypeAny<type>; | ||
| declare type TypesSelfValues = { | ||
| [I in keyof SelfConstructors]-?: InstanceType<SelfConstructors[I]>; | ||
| }[keyof SelfConstructors]; | ||
| declare type TypeString<type extends string> = | ||
| | StringConstructor | ||
| | SchemaReflectWrapper<StringConstructor, type>; | ||
| declare type TypeSymbol<type extends symbol> = | ||
| | SymbolConstructor | ||
| | SchemaOnlyPropWrapper<SymbolConstructor, type>; | ||
| export { } | ||
@@ -671,0 +208,0 @@ // this is just a hacky workaround to ensure the global declarations make it into the dts rollup |
+188
-181
@@ -35,6 +35,6 @@ class le { | ||
| 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 ue = Symbol.for("Atomico.suspense"), Yt = Symbol.for("Atomico.effect"), fe = Symbol.for("Atomico.layoutEffect"), Ft = Symbol.for("Atomico.insertionEffect"), R = (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) => { | ||
| }, It = (e) => R((t = Rt(e)) => t), W = () => R((e = Rt(A.c.host)) => e), Lt = () => A.c.update, de = (e, t, n = 0) => { | ||
| let s = {}, o = !1; | ||
@@ -62,3 +62,3 @@ const r = () => o, a = (l, c) => { | ||
| })), isSuspense: r }; | ||
| }, L = Symbol.for; | ||
| }, x = Symbol.for; | ||
| function xt(e, t) { | ||
@@ -73,3 +73,3 @@ const n = e.length; | ||
| } | ||
| 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 || {}); | ||
| const M = (e) => typeof e == "function", F = (e) => typeof e == "object", { isArray: he } = Array, ot = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {}); | ||
| function _t(e, t) { | ||
@@ -109,4 +109,4 @@ let n; | ||
| } | ||
| const q = "Custom", ye = null, pe = { true: 1, "": 1, 1: 1 }; | ||
| function be(e, t, n, s, o) { | ||
| const z = "Custom", ye = null, pe = { true: 1, "": 1, 1: 1 }; | ||
| function ge(e, t, n, s, o) { | ||
| const { | ||
@@ -117,4 +117,4 @@ type: r, | ||
| 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; | ||
| attr: l = be(t) | ||
| } = n?.name != z && F(n) && n != ye ? n : { type: n }, c = r?.name === z && r.map, d = f != null ? r == Function || !M(f) ? () => f : f : null; | ||
| Object.defineProperty(e, t, { | ||
@@ -129,13 +129,13 @@ configurable: !0, | ||
| d && r != Boolean && i == null && (i = d()); | ||
| const { error: b, value: g } = (c ? Ee : we)( | ||
| const { error: g, value: b } = (c ? Ee : ve)( | ||
| r, | ||
| i | ||
| ); | ||
| if (b && g != null) | ||
| if (g && b != null) | ||
| throw new qt( | ||
| this, | ||
| `The value defined for prop '${t}' must be of type '${r.name}'`, | ||
| g | ||
| b | ||
| ); | ||
| m != g && (this._props[t] = g ?? void 0, this.update(), u && zt(this, u), this.updated.then(() => { | ||
| m != b && (this._props[t] = b ?? void 0, this.update(), u && zt(this, u), this.updated.then(() => { | ||
| a && (this._ignoreAttr = l, De(this, r, l, this[t]), this._ignoreAttr = null); | ||
@@ -152,6 +152,6 @@ })); | ||
| } | ||
| 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( | ||
| const zt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), be = (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 === 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 : ( | ||
| t?.name === z && t?.serialize ? t?.serialize(s) : F(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 == z ? t : ( | ||
| // TODO: If when defining reflect the prop can also be of type string? | ||
@@ -165,3 +165,3 @@ new e(t) | ||
| } | ||
| }, 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 ? { | ||
| }, ve = (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, | ||
@@ -176,6 +176,6 @@ error: {}.toString.call(t) !== `[object ${e.name}]` | ||
| } : { value: t, error: !0 }; | ||
| let ve = 0; | ||
| let we = 0; | ||
| const Se = (e) => { | ||
| const t = (e?.dataset || {})?.hydrate || ""; | ||
| return t || "c" + ve++; | ||
| return t || "c" + we++; | ||
| }, k = (e, t = HTMLElement) => { | ||
@@ -212,4 +212,4 @@ 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; | ||
| ); | ||
| let m, b = !0; | ||
| const g = ot(this); | ||
| let m, g = !0; | ||
| const b = ot(this); | ||
| this.update = () => (m || (m = !0, this.updated = (this.updated || this.mounted).then(() => { | ||
@@ -219,3 +219,3 @@ try { | ||
| return y && //@ts-ignore | ||
| y.render(this, this.symbolId, g), m = !1, b && !i.isSuspense() && (b = !1, !g && Te(this)), p(); | ||
| y.render(this, this.symbolId, b), m = !1, g && !i.isSuspense() && (g = !1, !b && Te(this)), p(); | ||
| } finally { | ||
@@ -248,9 +248,9 @@ m = !1; | ||
| if (c === this._ignoreAttr || d === i) return; | ||
| const { prop: m, type: b } = n[c]; | ||
| const { prop: m, type: g } = n[c]; | ||
| try { | ||
| this[m] = Ce(b, i); | ||
| this[m] = Ce(g, i); | ||
| } catch { | ||
| throw new me( | ||
| this, | ||
| `The value defined as attr '${c}' cannot be parsed by type '${b.name}'`, | ||
| `The value defined as attr '${c}' cannot be parsed by type '${g.name}'`, | ||
| i | ||
@@ -268,3 +268,3 @@ ); | ||
| for (const d in a) | ||
| be(this.prototype, d, a[d], n, s); | ||
| ge(this.prototype, d, a[d], n, s); | ||
| return Object.keys(n).concat(c); | ||
@@ -285,3 +285,3 @@ } | ||
| const Ht = (e) => (t, n) => { | ||
| U( | ||
| R( | ||
| /** | ||
@@ -291,10 +291,10 @@ * Clean the effect hook | ||
| */ | ||
| ([s, o] = []) => ((o || !o) && (o && xt(o, n) ? s = s || !0 : (T(s) && s(), s = null)), [s, n]), | ||
| ([s, o] = []) => ((o || !o) && (o && xt(o, n) ? s = s || !0 : (M(s) && s(), s = null)), [s, n]), | ||
| /** | ||
| * @returns {any} | ||
| */ | ||
| ([s, o], r) => r ? (T(s) && s(), []) : [s || t(), o], | ||
| ([s, o], r) => r ? (M(s) && s(), []) : [s || t(), o], | ||
| e | ||
| ); | ||
| }, I = Ht(Yt), Pe = Ht(Ft); | ||
| }, L = Ht(Yt), Me = Ht(Ft); | ||
| class Wt extends Array { | ||
@@ -332,12 +332,12 @@ /** | ||
| const t = Lt(); | ||
| return U( | ||
| return R( | ||
| (n = new Wt(e, (s, o, r) => { | ||
| s = T(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t()); | ||
| s = M(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t()); | ||
| })) => n | ||
| ); | ||
| }, S = (e, t) => { | ||
| const [n] = U(([s, o, r = 0] = []) => ((!o || o && !xt(o, t)) && (s = e()), [s, t, r])); | ||
| const [n] = R(([s, o, r = 0] = []) => ((!o || o && !xt(o, t)) && (s = e()), [s, t, r])); | ||
| return n; | ||
| }, lt = (e) => { | ||
| const { current: t } = H(); | ||
| const { current: t } = W(); | ||
| if (!(e in t)) | ||
@@ -349,9 +349,9 @@ throw new qt( | ||
| ); | ||
| return U( | ||
| return R( | ||
| (n = new Wt(t[e], (s, o) => { | ||
| s = T(s) ? s(t[e]) : s, t[e] = s; | ||
| s = M(s) ? s(t[e]) : s, t[e] = s; | ||
| })) => (n[0] = t[e], n) | ||
| ); | ||
| }, P = (e, t = {}) => { | ||
| const n = H(); | ||
| }, N = (e, t = {}) => { | ||
| const n = W(); | ||
| return n[e] || (n[e] = (s = t.detail) => zt(n.current, { | ||
@@ -362,9 +362,9 @@ type: e, | ||
| })), n[e]; | ||
| }, rt = L("atomico/options"); | ||
| }, rt = x("atomico/options"); | ||
| globalThis[rt] = globalThis[rt] || { | ||
| sheet: !!document.adoptedStyleSheets | ||
| }; | ||
| const W = globalThis[rt], Me = new Promise((e) => { | ||
| W.ssr || (document.readyState === "loading" ? jt(document, "DOMContentLoaded", e) : e()); | ||
| }), Ne = { | ||
| const K = globalThis[rt], Ne = new Promise((e) => { | ||
| K.ssr || (document.readyState === "loading" ? jt(document, "DOMContentLoaded", e) : e()); | ||
| }), Pe = { | ||
| checked: 1, | ||
@@ -389,6 +389,6 @@ value: 1, | ||
| key: 1 | ||
| }, B = {}, at = []; | ||
| }, q = {}, at = []; | ||
| class ct extends Text { | ||
| } | ||
| const Ae = L("atomico/id"), F = L("atomico/type"), Q = L("atomico/ref"), Kt = L("atomico/vnode"), Jt = () => { | ||
| const Ae = x("atomico/id"), I = x("atomico/type"), Q = x("atomico/ref"), Kt = x("atomico/vnode"), Jt = () => { | ||
| }; | ||
@@ -399,3 +399,3 @@ function $e(e, t, n) { | ||
| const Zt = (e, t, ...n) => { | ||
| const s = t || B; | ||
| const s = t || q; | ||
| let { children: o } = s; | ||
@@ -412,5 +412,5 @@ if (o = o ?? (n.length ? n : at), e === Jt) | ||
| ); | ||
| const a = W.render || $e; | ||
| const a = K.render || $e; | ||
| return { | ||
| [F]: Kt, | ||
| [I]: Kt, | ||
| type: e, | ||
@@ -436,3 +436,3 @@ props: s, | ||
| let r; | ||
| if (t && t[n] && t[n].vnode == e || e[F] != Kt) | ||
| if (t && t[n] && t[n].vnode == e || e[I] != Kt) | ||
| return t; | ||
@@ -446,5 +446,5 @@ (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( | ||
| ))); | ||
| const a = t[n] ? t[n] : B, { vnode: u = B, cycle: f = 0 } = a; | ||
| const a = t[n] ? t[n] : q, { vnode: u = q, cycle: f = 0 } = a; | ||
| let { fragment: l, handlers: c } = a; | ||
| const { children: d = at, props: i = B } = u; | ||
| const { children: d = at, props: i = q } = u; | ||
| if (c = r ? {} : c || {}, e.static && !r) return t; | ||
@@ -495,15 +495,15 @@ if (e.shadow && !t.shadowRoot && // @ts-ignore | ||
| if (e && _t(e, (m) => { | ||
| if (typeof m == "object" && !m[F]) | ||
| if (typeof m == "object" && !m[I]) | ||
| return; | ||
| 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; | ||
| const g = m[I] && m.key, b = l && g != null && l.get(g); | ||
| i != f && i === b ? d.delete(i) : i = i == f ? f : i.nextSibling; | ||
| const y = l ? b : i; | ||
| let p = y; | ||
| if (m[F]) | ||
| if (m[I]) | ||
| p = Xt(m, y, s, o, r); | ||
| else { | ||
| const v = m + ""; | ||
| !(p instanceof Text) || p instanceof ct ? p = new Text(v) : p.data != v && (p.data = v); | ||
| const w = m + ""; | ||
| !(p instanceof Text) || p instanceof ct ? p = new Text(w) : p.data != w && (p.data = w); | ||
| } | ||
| 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)); | ||
| 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)), g != null && (c = c || /* @__PURE__ */ new Map(), c.set(g, p)); | ||
| }), i = i == f ? f : i.nextSibling, t && i != f) | ||
@@ -523,17 +523,17 @@ for (; i != f; ) { | ||
| 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 (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Pe[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))) | ||
| else if (t[0] == "o" && t[1] == "n" && (M(s) || M(n))) | ||
| Fe(e, t.slice(2), s, r); | ||
| else if (t == "ref") | ||
| s && (T(s) ? s(e) : s.current = e); | ||
| s && (M(s) ? s(e) : s.current = e); | ||
| else if (t == "style") { | ||
| const { style: a } = e; | ||
| n = n || "", s = s || ""; | ||
| const u = Y(n), f = Y(s); | ||
| const u = F(n), f = F(s); | ||
| if (u) | ||
| for (const l in n) | ||
| if (f) | ||
| !(l in s) && Pt(a, l, null); | ||
| !(l in s) && Mt(a, l, null); | ||
| else | ||
@@ -544,3 +544,3 @@ break; | ||
| const c = s[l]; | ||
| u && n[l] === c || Pt(a, l, c); | ||
| u && n[l] === c || Mt(a, l, c); | ||
| } | ||
@@ -551,5 +551,5 @@ else | ||
| const a = t[0] == "$" ? t.slice(1) : t; | ||
| a === t && (!o && !ke[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 || M(s) || M(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(a) : e.setAttribute( | ||
| a, | ||
| Y(s) ? JSON.stringify(s) : s | ||
| F(s) ? JSON.stringify(s) : s | ||
| ); | ||
@@ -568,3 +568,3 @@ } | ||
| } | ||
| function Pt(e, t, n) { | ||
| function Mt(e, t, n) { | ||
| let s = "setProperty"; | ||
@@ -574,4 +574,4 @@ n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n; | ||
| const Ie = Zt("host", { style: "display: contents" }), Gt = "value", Le = (e, t) => { | ||
| const n = H(), s = It(); | ||
| Pe( | ||
| const n = W(), s = It(); | ||
| Me( | ||
| () => jt( | ||
@@ -590,7 +590,7 @@ n.current, | ||
| }, ut = (e) => { | ||
| const t = P("ConnectContext", { | ||
| const t = N("ConnectContext", { | ||
| bubbles: !0, | ||
| composed: !0 | ||
| }), [n, s] = it(() => { | ||
| if (W.ssr) return; | ||
| if (K.ssr) return; | ||
| let r; | ||
@@ -607,4 +607,4 @@ return t({ | ||
| }), o = Lt(); | ||
| return I(() => { | ||
| Me.then( | ||
| return L(() => { | ||
| Ne.then( | ||
| () => t({ | ||
@@ -615,3 +615,3 @@ id: e, | ||
| ); | ||
| }, [e]), I(() => { | ||
| }, [e]), L(() => { | ||
| if (n) | ||
@@ -643,4 +643,4 @@ return n.on(o); | ||
| }); | ||
| const Mt = {}; | ||
| function K(e, ...t) { | ||
| const Nt = {}; | ||
| function J(e, ...t) { | ||
| const n = (e.raw || e).reduce( | ||
@@ -650,6 +650,6 @@ (s, o, r) => s + o + (t[r] || ""), | ||
| ); | ||
| return Mt[n] = Mt[n] || xe(n); | ||
| return Nt[n] = Nt[n] || xe(n); | ||
| } | ||
| function xe(e) { | ||
| if (W.sheet) { | ||
| if (K.sheet) { | ||
| const t = new CSSStyleSheet(); | ||
@@ -662,3 +662,3 @@ return t.replaceSync(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)}`; | ||
| const h = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Zt(e, t)), T = h, ft = J`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, dt = J`.vh{position:absolute;transform:scale(0)}`; | ||
| function ht() { | ||
@@ -670,3 +670,3 @@ const e = /* @__PURE__ */ new Date(); | ||
| function je(e) { | ||
| const t = w(e); | ||
| const t = v(e); | ||
| t.setDate(t.getUTCDate() + 3 - (t.getUTCDay() + 6) % 7); | ||
@@ -679,3 +679,3 @@ const n = new Date(t.getUTCFullYear(), 0, 4); | ||
| function mt(e, t = 0) { | ||
| const n = w(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t; | ||
| const n = v(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t; | ||
| return n.setUTCDate(n.getUTCDate() - o), C.from(n); | ||
@@ -689,3 +689,3 @@ } | ||
| } | ||
| function J(e, t, n) { | ||
| function Z(e, t, n) { | ||
| return t && C.compare(e, t) < 0 ? t : n && C.compare(e, n) > 0 ? n : e; | ||
@@ -705,3 +705,3 @@ } | ||
| } | ||
| function w(e) { | ||
| function v(e) { | ||
| return new Date(Date.UTC(e.year, e.month - 1, e.day ?? 1)); | ||
@@ -718,3 +718,3 @@ } | ||
| add(t) { | ||
| const n = w(this); | ||
| const n = v(this); | ||
| if ("days" in t) | ||
@@ -724,4 +724,4 @@ return n.setUTCDate(this.day + t.days), C.from(n); | ||
| "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)); | ||
| const r = C.from(v({ year: s, month: o, day: 1 })); | ||
| return Z(C.from(n), r, te(r)); | ||
| } | ||
@@ -732,3 +732,3 @@ toString() { | ||
| toPlainYearMonth() { | ||
| return new Z(this.year, this.month); | ||
| return new $(this.year, this.month); | ||
| } | ||
@@ -760,3 +760,3 @@ equals(t) { | ||
| } | ||
| class Z { | ||
| class $ { | ||
| constructor(t, n) { | ||
@@ -766,4 +766,4 @@ this.year = t, this.month = n; | ||
| add(t) { | ||
| const n = w(this), s = (t.months ?? 0) + (t.years ?? 0) * 12; | ||
| return n.setUTCMonth(n.getUTCMonth() + s), new Z(n.getUTCFullYear(), n.getUTCMonth() + 1); | ||
| const n = v(this), s = (t.months ?? 0) + (t.years ?? 0) * 12; | ||
| return n.setUTCMonth(n.getUTCMonth() + s), new $(n.getUTCFullYear(), n.getUTCMonth() + 1); | ||
| } | ||
@@ -776,4 +776,7 @@ equals(t) { | ||
| } | ||
| static compare(t, n) { | ||
| return t.year < n.year ? -1 : t.year > n.year ? 1 : t.month < n.month ? -1 : t.month > n.month ? 1 : 0; | ||
| } | ||
| } | ||
| function z(e, t) { | ||
| function H(e, t) { | ||
| if (t) | ||
@@ -785,5 +788,5 @@ try { | ||
| } | ||
| function N(e) { | ||
| function P(e) { | ||
| const [t, n] = lt(e); | ||
| return [S(() => z(C, t), [t]), (r) => n(r?.toString())]; | ||
| return [S(() => H(C, t), [t]), (r) => n(r?.toString())]; | ||
| } | ||
@@ -793,3 +796,3 @@ function He(e) { | ||
| return [S(() => { | ||
| const [r, a] = t.split("/"), u = z(C, r), f = z(C, a); | ||
| const [r, a] = t.split("/"), u = H(C, r), f = H(C, a); | ||
| return u && f ? [u, f] : []; | ||
@@ -803,3 +806,3 @@ }, [t]), (r) => n(`${r[0]}/${r[1]}`)]; | ||
| for (const a of t.trim().split(/\s+/)) { | ||
| const u = z(C, a); | ||
| const u = H(C, a); | ||
| u && r.push(u); | ||
@@ -810,3 +813,3 @@ } | ||
| } | ||
| function $(e, t) { | ||
| function U(e, t) { | ||
| return S( | ||
@@ -817,4 +820,4 @@ () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }), | ||
| } | ||
| function Nt(e, t, n) { | ||
| const s = $(e, n); | ||
| function Pt(e, t, n) { | ||
| const s = U(e, n); | ||
| return S(() => { | ||
@@ -829,3 +832,3 @@ const o = [], r = /* @__PURE__ */ new Date(); | ||
| } | ||
| 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 }; | ||
| const kt = (e, t, n) => Z(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 }) { | ||
@@ -842,14 +845,14 @@ const { offset: n } = e, { | ||
| formatWeekday: d | ||
| } = t, i = u ?? ht(), m = Nt(Ze, s, l), b = S( | ||
| } = t, i = u ?? ht(), m = Pt(Ze, s, l), g = S( | ||
| () => ({ weekday: d }), | ||
| [d] | ||
| ), g = Nt(b, s, l), y = $(Ke, l), p = $(Je, l), v = S( | ||
| ), b = Pt(g, s, l), y = U(Ke, l), p = U(Je, l), w = 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); | ||
| () => qe(w, s), | ||
| [w, s] | ||
| ), se = N("focusday", tt), oe = N("selectday", tt), re = N("hoverday", tt); | ||
| function Dt(D) { | ||
| se(J(D, r, a)); | ||
| se(Z(D, r, a)); | ||
| } | ||
@@ -889,26 +892,26 @@ function ae(D) { | ||
| function ce(D) { | ||
| const E = v.equals(D); | ||
| const E = w.equals(D); | ||
| if (!t.showOutsideDays && !E) | ||
| return; | ||
| const ie = D.equals(c), Ct = D.equals(i), _ = w(D), j = o?.(_), Et = !kt(D, r, a); | ||
| let wt = "", O; | ||
| const ie = D.equals(c), Ct = D.equals(i), j = v(D), B = o?.(j), Et = !kt(D, r, a); | ||
| let vt = "", O; | ||
| if (t.type === "range") { | ||
| 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); | ||
| const [Y, G] = t.value, wt = Y?.equals(D), St = G?.equals(D); | ||
| O = Y && G && kt(D, Y, G), vt = `${wt ? "range-start" : ""} ${St ? "range-end" : ""} ${O && !wt && !St ? "range-inner" : ""}`; | ||
| } else t.type === "multi" ? O = t.value.some((Y) => Y.equals(D)) : O = t.value?.equals(D); | ||
| return { | ||
| 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}`, | ||
| part: `${`button day day-${j.getDay()} ${// we don't want outside days to ever be shown as selected | ||
| E ? O ? "selected" : "" : "outside"} ${B ? "disallowed" : ""} ${Ct ? "today" : ""} ${t.getDayParts?.(j) ?? ""}`} ${vt}`, | ||
| tabindex: E && ie ? 0 : -1, | ||
| disabled: Et, | ||
| "aria-disabled": j ? "true" : void 0, | ||
| "aria-disabled": B ? "true" : void 0, | ||
| "aria-pressed": E && O, | ||
| "aria-current": Ct ? "date" : void 0, | ||
| "aria-label": y.format(_), | ||
| "aria-label": y.format(j), | ||
| onkeydown: ae, | ||
| onclick() { | ||
| j || oe(D), Dt(D); | ||
| B || oe(D), Dt(D); | ||
| }, | ||
| onmouseover() { | ||
| !j && !Et && re(D); | ||
| !B && !Et && re(D); | ||
| } | ||
@@ -919,5 +922,5 @@ }; | ||
| weeks: X, | ||
| yearMonth: v, | ||
| yearMonth: w, | ||
| daysLong: m, | ||
| daysVisible: g, | ||
| daysVisible: b, | ||
| formatter: p, | ||
@@ -927,3 +930,3 @@ getDayProps: ce | ||
| } | ||
| const et = ht(), x = Qt({ | ||
| const et = ht(), _ = Qt({ | ||
| type: "date", | ||
@@ -934,13 +937,13 @@ firstDayOfWeek: 1, | ||
| }); | ||
| customElements.define("calendar-ctx", x); | ||
| customElements.define("calendar-ctx", _); | ||
| const Ge = (e, t) => (t + e) % 7, Qe = k( | ||
| (e) => { | ||
| const t = ut(x), n = It(), s = Xe({ props: e, context: t }); | ||
| const t = ut(_), n = It(), s = Xe({ props: e, context: t }); | ||
| function o() { | ||
| n.current.querySelector("button[tabindex='0']")?.focus(); | ||
| } | ||
| 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: [ | ||
| return /* @__PURE__ */ T("host", { shadowDom: !0, focus: o, children: [ | ||
| /* @__PURE__ */ h("div", { id: "h", part: "heading", children: s.formatter.format(v(s.yearMonth)) }), | ||
| /* @__PURE__ */ T("table", { ref: n, "aria-labelledby": "h", part: "table", children: [ | ||
| /* @__PURE__ */ T("colgroup", { children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("col", { part: "col-weeknumber" }), | ||
@@ -955,5 +958,8 @@ /* @__PURE__ */ h("col", { part: "col-1" }), | ||
| ] }), | ||
| /* @__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( | ||
| /* @__PURE__ */ h("thead", { children: /* @__PURE__ */ T("tr", { part: "tr head", children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("th", { part: "th weeknumber", children: /* @__PURE__ */ T("slot", { name: "weeknumber", children: [ | ||
| /* @__PURE__ */ h("span", { class: "vh", children: "Week" }), | ||
| /* @__PURE__ */ h("span", { "aria-hidden": "true", children: "#" }) | ||
| ] }) }), | ||
| s.daysLong.map((r, a) => /* @__PURE__ */ T( | ||
| "th", | ||
@@ -970,3 +976,3 @@ { | ||
| ] }) }), | ||
| /* @__PURE__ */ h("tbody", { children: s.weeks.map((r, a) => /* @__PURE__ */ M("tr", { part: "tr week", children: [ | ||
| /* @__PURE__ */ h("tbody", { children: s.weeks.map((r, a) => /* @__PURE__ */ T("tr", { part: "tr week", children: [ | ||
| t.showWeekNumbers && /* @__PURE__ */ h("th", { class: "num", part: "th weeknumber", scope: "row", children: je(r[0]) }), | ||
@@ -991,3 +997,3 @@ r.map((u, f) => { | ||
| 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}` | ||
| J`: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}` | ||
| ] | ||
@@ -1009,5 +1015,5 @@ } | ||
| function yt(e) { | ||
| const t = w(e.page.start), n = w(e.page.end); | ||
| const t = v(e.page.start), n = v(e.page.end); | ||
| return /* @__PURE__ */ h( | ||
| x, | ||
| _, | ||
| { | ||
@@ -1018,5 +1024,5 @@ value: e, | ||
| onhoverday: e.onHover, | ||
| children: /* @__PURE__ */ M("div", { role: "group", "aria-labelledby": "h", part: "container", children: [ | ||
| children: /* @__PURE__ */ T("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__ */ T("div", { part: "header", children: [ | ||
| /* @__PURE__ */ h(At, { name: "previous", onclick: e.previous, children: "Previous" }), | ||
@@ -1090,6 +1096,6 @@ /* @__PURE__ */ h("slot", { part: "heading", name: "heading", children: /* @__PURE__ */ h("div", { "aria-hidden": "true", children: e.format.formatRange(t, n) }) }), | ||
| } | ||
| }, bt = [ | ||
| }, gt = [ | ||
| 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}` | ||
| J`: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" }; | ||
@@ -1099,3 +1105,3 @@ function nt(e, t) { | ||
| } | ||
| const $t = (e, t) => (e = t === 12 ? new Z(e.year, 1) : e, { | ||
| const $t = (e, t) => (e = t === 12 ? new $(e.year, 1) : e, { | ||
| start: e, | ||
@@ -1118,3 +1124,3 @@ end: e.add({ months: t - 1 }) | ||
| }; | ||
| return I(() => { | ||
| return L(() => { | ||
| if (c(t)) | ||
@@ -1124,3 +1130,3 @@ return; | ||
| r(t.add({ months: d })); | ||
| }, [u.start]), I(() => { | ||
| }, [u.start]), L(() => { | ||
| if (c(t)) | ||
@@ -1136,3 +1142,3 @@ return; | ||
| } | ||
| function gt({ | ||
| function bt({ | ||
| months: e, | ||
@@ -1144,10 +1150,10 @@ pageBy: t, | ||
| }) { | ||
| const [r] = N("min"), [a] = N("max"), [u] = N("today"), f = P("focusday"), l = P("change"), c = S( | ||
| () => J(s ?? u ?? ht(), r, a), | ||
| const [r] = P("min"), [a] = P("max"), [u] = P("today"), f = N("focusday"), l = N("change"), c = S( | ||
| () => Z(s ?? u ?? ht(), r, a), | ||
| [s, u, r, a] | ||
| ); | ||
| function d(p) { | ||
| o(p), f(w(p)); | ||
| o(p), f(v(p)); | ||
| } | ||
| const { next: i, previous: m, page: b } = en({ | ||
| const { next: i, previous: m, page: g } = en({ | ||
| pageBy: t, | ||
@@ -1159,11 +1165,11 @@ focusedDate: c, | ||
| goto: d | ||
| }), g = H(); | ||
| }), b = W(); | ||
| 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); | ||
| const w = p?.target ?? "day"; | ||
| w === "day" ? b.current.querySelectorAll("calendar-month").forEach((X) => X.focus(p)) : b.current.shadowRoot.querySelector(`[part~='${w}']`).focus(p); | ||
| } | ||
| return { | ||
| format: $(Ve, n), | ||
| formatVerbose: $(tn, n), | ||
| page: b, | ||
| format: U(Ve, n), | ||
| formatVerbose: U(tn, n), | ||
| page: g, | ||
| focusedDate: c, | ||
@@ -1184,3 +1190,3 @@ dispatch: l, | ||
| (e) => { | ||
| const [t, n] = N("value"), [s = t, o] = N("focusedDate"), r = gt({ | ||
| const [t, n] = P("value"), [s = t, o] = P("focusedDate"), r = bt({ | ||
| ...e, | ||
@@ -1204,7 +1210,7 @@ focusedDate: s, | ||
| }, | ||
| { props: pt, styles: bt } | ||
| { props: pt, styles: gt } | ||
| ); | ||
| customElements.define("calendar-date", nn); | ||
| function ee(e) { | ||
| return /* @__PURE__ */ M(Jt, { children: [ | ||
| return /* @__PURE__ */ T(Jt, { children: [ | ||
| /* @__PURE__ */ h("label", { part: "label", for: "s", children: /* @__PURE__ */ h("slot", { name: "label", children: e.label }) }), | ||
@@ -1219,12 +1225,12 @@ /* @__PURE__ */ h("select", { id: "s", part: "select", onchange: e.onChange, children: e.options.map((t) => /* @__PURE__ */ h("option", { part: "option", ...t })) }) | ||
| 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; | ||
| const { min: t, max: n, focusedDate: s } = ut(_), o = N("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, (g) => { | ||
| const b = c + g; | ||
| return { | ||
| label: `${g}`, | ||
| value: `${g}`, | ||
| selected: g === r.year | ||
| label: `${b}`, | ||
| value: `${b}`, | ||
| selected: b === r.year | ||
| }; | ||
| }); | ||
| function m(b) { | ||
| const y = parseInt(b.currentTarget.value) - r.year; | ||
| function m(g) { | ||
| const y = parseInt(g.currentTarget.value) - r.year; | ||
| o(s.add({ years: y })); | ||
@@ -1248,24 +1254,25 @@ } | ||
| function an(e) { | ||
| const { min: t, max: n, focusedDate: s, locale: o } = ut(x), r = P("focusday", { bubbles: !0 }), a = S( | ||
| const { min: t, max: n, focusedDate: s, locale: o } = ut(_), r = N("focusday", { bubbles: !0 }), a = S( | ||
| () => ({ month: e.formatMonth }), | ||
| [e.formatMonth] | ||
| ), u = $(a, o), f = S(() => { | ||
| ), u = 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); | ||
| m.setUTCDate(1); | ||
| for (var g = 0; g < 12; g++) { | ||
| const b = (m.getUTCMonth() + 12) % 12; | ||
| i[b] = 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; | ||
| const g = m + 1, b = l.add({ months: g - l.month }), y = t != null && $.compare(b, t) < 0 || n != null && $.compare(b, n) > 0; | ||
| return { | ||
| label: i, | ||
| value: `${b}`, | ||
| value: `${g}`, | ||
| disabled: y, | ||
| selected: b === l.month | ||
| selected: g === l.month | ||
| }; | ||
| }); | ||
| function d(i) { | ||
| const b = parseInt(i.currentTarget.value) - l.month; | ||
| r(s.add({ months: b })); | ||
| const g = parseInt(i.currentTarget.value) - l.month; | ||
| r(s.add({ months: g })); | ||
| } | ||
@@ -1292,10 +1299,10 @@ return { options: c, onChange: d }; | ||
| (e) => { | ||
| const [t, n] = He("value"), [s = t[0], o] = N("focusedDate"), r = gt({ | ||
| const [t, n] = He("value"), [s = t[0], o] = P("focusedDate"), r = bt({ | ||
| ...e, | ||
| focusedDate: s, | ||
| setFocusedDate: o | ||
| }), a = P("rangestart"), u = P("rangeend"), [f, l] = N( | ||
| }), a = N("rangestart"), u = N("rangeend"), [f, l] = P( | ||
| "tentative" | ||
| ), [c, d] = it(); | ||
| I(() => d(void 0), [f]); | ||
| L(() => d(void 0), [f]); | ||
| function i(y) { | ||
@@ -1307,7 +1314,7 @@ r.onFocus(y), m(y); | ||
| } | ||
| function b(y) { | ||
| function g(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))); | ||
| y.stopPropagation(), f ? (n(Ut(f, p)), l(void 0), u(v(p)), r.dispatch()) : (l(p), a(v(p))); | ||
| } | ||
| const g = f ? Ut(f, c ?? f) : t; | ||
| const b = f ? Ut(f, c ?? f) : t; | ||
| return /* @__PURE__ */ h("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ h( | ||
@@ -1319,6 +1326,6 @@ yt, | ||
| type: "range", | ||
| value: g, | ||
| value: b, | ||
| onFocus: i, | ||
| onHover: m, | ||
| onSelect: b | ||
| onSelect: g | ||
| } | ||
@@ -1335,3 +1342,3 @@ ) }); | ||
| }, | ||
| styles: bt | ||
| styles: gt | ||
| } | ||
@@ -1342,3 +1349,3 @@ ); | ||
| (e) => { | ||
| const [t, n] = We("value"), [s = t[0], o] = N("focusedDate"), r = gt({ | ||
| const [t, n] = We("value"), [s = t[0], o] = P("focusedDate"), r = bt({ | ||
| ...e, | ||
@@ -1363,3 +1370,3 @@ focusedDate: s, | ||
| }, | ||
| { props: pt, styles: bt } | ||
| { props: pt, styles: gt } | ||
| ); | ||
@@ -1366,0 +1373,0 @@ customElements.define("calendar-multi", un); |
+10
-20
| { | ||
| "name": "cally", | ||
| "version": "0.9.0", | ||
| "version": "0.9.1", | ||
| "description": "small, feature-rich calendar components", | ||
@@ -28,9 +28,7 @@ "license": "MIT", | ||
| "build": "vite build && npm run astro:build", | ||
| "test": "wtr", | ||
| "test": "vitest run", | ||
| "test:ui": "vitest --ui", | ||
| "astro:dev": "astro dev --root ./docs", | ||
| "astro:build": "astro check --root ./docs && astro build --root ./docs", | ||
| "astro:preview": "astro preview --root ./docs", | ||
| "preversion": "npm test", | ||
| "version": "npm run build", | ||
| "postversion": "git push origin main --tags && npm publish" | ||
| "astro:preview": "astro preview --root ./docs" | ||
| }, | ||
@@ -44,11 +42,8 @@ "dependencies": { | ||
| "@atomico/vite": "^2.21.1", | ||
| "@open-wc/testing": "^4.0.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.10.0", | ||
| "@vitest/browser": "^4.0.16", | ||
| "@vitest/browser-playwright": "^4.0.16", | ||
| "@vitest/ui": "^4.0.16", | ||
| "astro": "^5.5.6", | ||
| "hastscript": "^9.0.1", | ||
| "playwright": "^1.50.1", | ||
| "postcss-nesting": "^13.0.1", | ||
@@ -60,10 +55,5 @@ "prettier": "^3.5.3", | ||
| "vite": "^6.2.4", | ||
| "vite-plugin-dts": "^4.5.3" | ||
| }, | ||
| "overrides": { | ||
| "playwright": { | ||
| ".": "1.50.1", | ||
| "@web/test-runner-playwright": "0.11.0" | ||
| } | ||
| "vite-plugin-dts": "^4.5.3", | ||
| "vitest": "^4.0.16" | ||
| } | ||
| } |
17
-10.53%48105
-18.55%1502
-20.74%