cally 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cally.d.ts +567 -0
  2. package/dist/cally.js +470 -485
  3. package/package.json +56 -44
@@ -0,0 +1,567 @@
1
+ declare interface Atomico<Props, PropsForInstance, Base>
2
+ extends AtomicoStatic<Props> {
3
+ new (
4
+ props?: JSXProxy<
5
+ DOMTag<DOMThis<Base>, Props>,
6
+ AtomicoThis<PropsForInstance, Base>
7
+ >
8
+ ): AtomicoThis<PropsForInstance, Base>;
9
+ }
10
+
11
+ declare interface AtomicoStatic<Props> extends HTMLElement {
12
+ styles: Sheets[];
13
+ props: SchemaInfer<Props>;
14
+ /**
15
+ * Meta property, allows associating the component's
16
+ * props in typescript to external environments.
17
+ */
18
+ readonly "##props": Props;
19
+ /**
20
+ * Allows to identify a constructor created with Atomico
21
+ */
22
+ readonly "##atomico": true;
23
+ }
24
+
25
+ declare type AtomicoThis<Props = {}, Base = HTMLElement> = Props &
26
+ DOMThis<Base> & {
27
+ update(): Promise<void>;
28
+ updated: Promise<void>;
29
+ mounted: Promise<void>;
30
+ unmounted: Promise<void>;
31
+ readonly symbolId: unique symbol;
32
+ };
33
+
34
+ export declare const CalendarDate: Atomico<{
35
+ months: number;
36
+ value: string;
37
+ firstDayOfWeek: DaysOfWeek;
38
+ isDateDisallowed: (date: Date) => boolean;
39
+ min: string;
40
+ max: string;
41
+ locale: string | undefined;
42
+ showOutsideDays: boolean;
43
+ onChange: (event: Event) => any;
44
+ } & {}, {
45
+ months: number;
46
+ value: string;
47
+ firstDayOfWeek: DaysOfWeek;
48
+ isDateDisallowed: (date: Date) => boolean;
49
+ min: string;
50
+ max: string;
51
+ locale: string | undefined;
52
+ showOutsideDays: boolean;
53
+ onChange: (event: Event) => any;
54
+ } & {}, {
55
+ new (): HTMLElement;
56
+ prototype: HTMLElement;
57
+ }>;
58
+
59
+ export declare type CalendarDateProps = ComponentProps<typeof CalendarDate>;
60
+
61
+ export declare const CalendarMonth: Atomico<{
62
+ offset: number;
63
+ onSelectDay: (event: CustomEvent<string>) => any;
64
+ onFocusDay: (event: CustomEvent<string>) => any;
65
+ onHoverDay: (event: CustomEvent<string>) => any;
66
+ } & {}, {
67
+ offset: number;
68
+ onSelectDay: (event: CustomEvent<string>) => any;
69
+ onFocusDay: (event: CustomEvent<string>) => any;
70
+ onHoverDay: (event: CustomEvent<string>) => any;
71
+ } & {}, {
72
+ new (): HTMLElement;
73
+ prototype: HTMLElement;
74
+ }>;
75
+
76
+ export declare type CalendarMonthProps = ComponentProps<typeof CalendarMonth>;
77
+
78
+ export declare const CalendarRange: Atomico<{
79
+ months: number;
80
+ value: string;
81
+ firstDayOfWeek: DaysOfWeek;
82
+ isDateDisallowed: (date: Date) => boolean;
83
+ min: string;
84
+ max: string;
85
+ locale: string | undefined;
86
+ showOutsideDays: boolean;
87
+ onChange: (event: Event) => any;
88
+ } & {}, {
89
+ months: number;
90
+ value: string;
91
+ firstDayOfWeek: DaysOfWeek;
92
+ isDateDisallowed: (date: Date) => boolean;
93
+ min: string;
94
+ max: string;
95
+ locale: string | undefined;
96
+ showOutsideDays: boolean;
97
+ onChange: (event: Event) => any;
98
+ } & {}, {
99
+ new (): HTMLElement;
100
+ prototype: HTMLElement;
101
+ }>;
102
+
103
+ export declare type CalendarRangeProps = ComponentProps<typeof CalendarRange>;
104
+
105
+ declare type CheckEvent<CurrentEvent, True> = CurrentEvent extends Event ? True : never;
106
+
107
+ declare type ComponentProps<T extends abstract new (...args: any) => any> = Simplify<Partial<Omit<InstanceType<T>, keyof HTMLElement | keyof AtomicoThis>>>;
108
+
109
+ declare type DaysOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
110
+
111
+ declare interface DOM$Attrs {
112
+ [prop: `\$${string}`]: Nullable<string>;
113
+ }
114
+
115
+ declare type DOMCleanKeys =
116
+ | keyof DOMGenericProperties
117
+ | `add${string}`
118
+ | `get${string}`
119
+ | `set${string}`
120
+ | `has${string}`
121
+ | `matches${string}`
122
+ | `remove${string}`
123
+ | `replace${string}`
124
+ | `querySelector${string}`
125
+ | `offset${string}`
126
+ | `append${string}`
127
+ | `request${string}`
128
+ | `scroll${string}`
129
+ | `is${string}`
130
+ | `toggle${string}`
131
+ | `webkit${string}`
132
+ | `insert${string}`
133
+ | `client${string}`
134
+ | `child${string}`
135
+ | `${string}_${string}`
136
+ | `${string}HTML`
137
+ | `${string}Child`
138
+ | `${string}Validity`
139
+ | `${string}Capture`
140
+ | `${string}ElementSibling`
141
+ | "classList"
142
+ | "attributes"
143
+ | "normalize"
144
+ | "closest"
145
+ | "localName"
146
+ | "contains"
147
+ | "animate"
148
+ | "attachShadow"
149
+ | "outerText"
150
+ | "attachInternals"
151
+ | "click"
152
+ | "tagName"
153
+ | "focus"
154
+ | "submit"
155
+ | "accessKeyLabel"
156
+ | "elements"
157
+ | "isContentEditable"
158
+ | "innerText"
159
+ | "prepend"
160
+ | "namespaceURI"
161
+ | "blur"
162
+ | "dataset"
163
+ | "shadowRoot"
164
+ | keyof Omit<ChildNode, "textContent">;
165
+
166
+ declare type DOMCustomTarget<Target> = { customTarget: Target };
167
+
168
+ declare type DOMEvent<
169
+ Target = HTMLElement,
170
+ CurrentEvent = Event
171
+ > = Target extends string
172
+ ? CurrentEvent extends AtomicoStatic<any>
173
+ ? DOMGetEvent<Target, CurrentEvent>
174
+ : DOMEventType<Target, CurrentEvent>
175
+ : DOMTarget<DOMThis<Target>, CurrentEvent>;
176
+
177
+ declare type DOMEventHandler<Target, Handler> = Handler extends (
178
+ ev: infer CurrentEvent
179
+ ) => any
180
+ ? CurrentEvent extends Event
181
+ ? (ev: DOMEvent<Target, CurrentEvent>) => any
182
+ : Handler
183
+ : Handler;
184
+
185
+ /**
186
+ * @todo Rename Handler to Listener
187
+ */
188
+
189
+ declare type DOMEventHandlerKeys<P> = {
190
+ [I in keyof P]-?: NonNullable<P[I]> extends DOMEventHandlerValue<infer E>
191
+ ? CheckEvent<E, I>
192
+ : P[I] extends { value: DOMEventHandlerValue<infer E> }
193
+ ? CheckEvent<E, I>
194
+ : never;
195
+ }[keyof P];
196
+
197
+ declare interface DOMEventHandlerType extends FunctionConstructor {}
198
+
199
+ declare interface DOMEventHandlerValue<CurrentEvent> {
200
+ (event: CurrentEvent): any;
201
+ }
202
+
203
+ declare type DOMEvents<Target> = {
204
+ [Prop in keyof Target]?: Prop extends `on${string}`
205
+ ? DOMEventHandler<Target, Target[Prop]>
206
+ : Target[Prop];
207
+ };
208
+
209
+ declare type DOMEventTarget<CurrentEvent, CurrentTarget, Target> = {
210
+ [I in keyof CurrentEvent]: I extends "currentTarget"
211
+ ? CurrentTarget
212
+ : I extends "target"
213
+ ? Target
214
+ : CurrentEvent[I];
215
+ };
216
+
217
+ declare type DOMEventType<Type extends string, CurrentEvent> = {
218
+ [I in keyof "0" as `on${Type}`]: {
219
+ type: DOMEventHandlerType;
220
+ value: DOMEventHandlerValue<CurrentEvent>;
221
+ };
222
+ };
223
+
224
+ declare interface DOMGenericProperties {
225
+ style?: string | Partial<CSSStyleDeclaration> | object;
226
+ class?: string;
227
+ id?: string;
228
+ slot?: string;
229
+ part?: string;
230
+ is?: string;
231
+ tabindex?: string | number;
232
+ role?: string;
233
+ shadowDom?: boolean | Partial<ShadowRootInit>;
234
+ staticNode?: boolean;
235
+ cloneNode?: boolean;
236
+ width?: string | number;
237
+ height?: string | number;
238
+ key?: any;
239
+ children?: any;
240
+ }
241
+
242
+ declare type DOMGetEvent<
243
+ Type extends string,
244
+ Element extends AtomicoStatic<any>
245
+ > = Element extends {
246
+ "##props": infer Props;
247
+ }
248
+ ? `on${Type}` extends keyof Props
249
+ ? DOMGetEventBefore<NonNullable<Props[`on${Type}`]>, DOMThis<Element>>
250
+ : Event
251
+ : Event;
252
+
253
+ declare type DOMGetEventBefore<Value, Target> = Value extends DOMEventHandlerValue<
254
+ infer Event
255
+ >
256
+ ? DOMEvent<HTMLElement, Event & DOMCustomTarget<Target>>
257
+ : null;
258
+
259
+ declare type DOMRef<Target> = {
260
+ ref?: DOMRefValue<Target>;
261
+ };
262
+
263
+ declare type DOMRefValue<Target> = FillObject | ((target: Target) => any);
264
+
265
+ declare type DOMTag<Element, Props = null> = Props extends null
266
+ ? PropsNullable<
267
+ Omit<DOMEvents<Element>, DOMCleanKeys> &
268
+ DOMGenericProperties &
269
+ DOMRef<Element>
270
+ > &
271
+ DOM$Attrs &
272
+ DOMUnknown
273
+ : PropsNullable<
274
+ Props &
275
+ Omit<DOMEvents<Element & Props>, keyof Props | DOMCleanKeys> &
276
+ DOMGenericProperties &
277
+ DOMRef<Element & Props>
278
+ > &
279
+ DOM$Attrs &
280
+ DOMUnknown;
281
+
282
+ declare type DOMTarget<
283
+ Target,
284
+ CurrentEvent,
285
+ Targets = Element | Node
286
+ > = CurrentEvent extends {
287
+ customTarget: infer EventTarget;
288
+ }
289
+ ? DOMTarget<Target, Omit<CurrentEvent, "customTarget">, EventTarget>
290
+ : DOMEventTarget<CurrentEvent, Target, Targets>;
291
+
292
+ declare type DOMThis<Element> = Element extends new (
293
+ ...args: any[]
294
+ ) => infer This
295
+ ? This
296
+ : Element;
297
+
298
+ declare interface DOMUnknown {
299
+ [prop: string]: any;
300
+ }
301
+
302
+ declare type EventInit_2 = CustomEventInit<any> & {
303
+ type: string;
304
+ base?: typeof CustomEvent | typeof Event;
305
+ };
306
+
307
+ declare type FillArray = any[];
308
+
309
+ declare type FillConstructor = abstract new (...args: any) => any;
310
+
311
+ declare type FillFunction = (...args: any[]) => any;
312
+
313
+ /**
314
+ * Interface to fill in unknown properties like any | null | undefined
315
+ */
316
+ declare interface FillObject {
317
+ [index: string]: any;
318
+ }
319
+
320
+ declare type FillPromise = Promise<any>;
321
+
322
+ declare type GetTypeSelf<value extends TypesSelfValues> = {
323
+ [I in keyof SelfConstructors]-?: value extends InstanceType<
324
+ SelfConstructors[I]
325
+ >
326
+ ? keyof value extends keyof InstanceType<SelfConstructors[I]>
327
+ ? SelfConstructors[I]
328
+ : never
329
+ : never;
330
+ }[keyof SelfConstructors];
331
+
332
+ declare type JSXProxy<Props, This> = {
333
+ [I in keyof Props]?: I extends `on${string}`
334
+ ? NonNullable<Props[I]> extends DOMEventHandlerValue<infer CurrentEvent>
335
+ ? Nullable<
336
+ (
337
+ ev: DOMEventTarget<CurrentEvent, This, Element | Node>
338
+ ) => any
339
+ >
340
+ : Props[I]
341
+ : I extends "ref"
342
+ ? DOMRefValue<This>
343
+ : Props[I];
344
+ };
345
+
346
+ declare type Nullable<T> = NonNullable<T> | undefined | null;
347
+
348
+ declare type PropsNullable<Data> = {
349
+ [I in keyof Data]?: Nullable<Data[I]>;
350
+ };
351
+
352
+ declare type SafeGlobal =
353
+ | "Event"
354
+ | "URL"
355
+ | "Range"
356
+ | "Image"
357
+ | "Crypto"
358
+ | "File"
359
+ | "Date"
360
+ | "Set"
361
+ | "Map"
362
+ | "RegExp"
363
+ | "Animation"
364
+ | `${string}Event`
365
+ | `Event${string}`
366
+ | `Clipboard${string}`
367
+ | `Animation${string}`
368
+ | `Form${string}`
369
+ | `Font${string}`
370
+ | `DOM${string}`
371
+ | `Touch${string}`
372
+ | `Mutation${string}`
373
+ | `Intersection${string}`
374
+ | `Message${string}`
375
+ | `HTML${string}`
376
+ | `SVG${string}`
377
+ | `Audio${string}`
378
+ | `Document${string}`
379
+ | `Weak${string}`
380
+ | `CSS${string}`
381
+ | `File${string}`;
382
+
383
+ declare type SchemaAny<Type> =
384
+ | SchemaReflect<{
385
+ value: Type;
386
+ }>
387
+ | SchemaReflect<{
388
+ value: () => Type;
389
+ }>
390
+ | SchemaReflect<{}>;
391
+
392
+ declare type SchemaBase = SchemaEvent & {
393
+ attr?: string;
394
+ };
395
+
396
+ declare type SchemaEvent = {
397
+ event?: EventInit_2;
398
+ };
399
+
400
+ declare type SchemaInfer<Props> = Required<
401
+ Omit<
402
+ {
403
+ [I in keyof Props]: Type<Props[I]>;
404
+ },
405
+ DOMEventHandlerKeys<Props>
406
+ >
407
+ >;
408
+
409
+ declare type SchemaOnlyPropWrapper<Constructor, Type> =
410
+ | SchemaProp<{
411
+ type: Constructor;
412
+ }>
413
+ | SchemaProp<{
414
+ type: Constructor;
415
+ value: Type;
416
+ }>
417
+ | SchemaProp<{
418
+ type: Constructor;
419
+ value: () => Type;
420
+ }>;
421
+
422
+ declare type SchemaProp<type> = SchemaEvent & type;
423
+
424
+ declare type SchemaReflect<type> = SchemaBase & {
425
+ reflect?: boolean;
426
+ } & type;
427
+
428
+ declare type SchemaReflectWrapper<Constructor, Type> =
429
+ | SchemaReflect<{
430
+ type: Constructor;
431
+ }>
432
+ | SchemaReflect<{
433
+ type: Constructor;
434
+ value: Type;
435
+ }>
436
+ | SchemaReflect<{
437
+ type: Constructor;
438
+ value: () => Type;
439
+ }>;
440
+
441
+ declare type SchemaTypeCustom =
442
+ | TypeCustom<FillFunction>
443
+ | SchemaReflectWrapper<TypeCustom<FillFunction>, any>;
444
+
445
+ declare type Self = typeof window;
446
+
447
+ declare type SelfConstructors = Pick<
448
+ Self,
449
+ {
450
+ [I in keyof Self]-?: I extends string
451
+ ? I extends Capitalize<I>
452
+ ? Self[I] extends FillConstructor
453
+ ? Self[I] extends SelfIgnore
454
+ ? never
455
+ : I extends SafeGlobal
456
+ ? I
457
+ : never
458
+ : never
459
+ : never
460
+ : never;
461
+ }[keyof Self]
462
+ >;
463
+
464
+ declare type SelfIgnore =
465
+ | StringConstructor
466
+ | NumberConstructor
467
+ | BooleanConstructor
468
+ | FunctionConstructor
469
+ | ObjectConstructor
470
+ | PromiseConstructor
471
+ | SymbolConstructor
472
+ | ArrayConstructor;
473
+
474
+ declare type Sheet = CSSStyleSheet | HTMLStyleElement;
475
+
476
+ declare type Sheets = Sheet | Sheet[] | Sheets[];
477
+
478
+ declare type Simplify<T> = {
479
+ [K in keyof T]: T[K];
480
+ } & {};
481
+
482
+ declare type Type<type> = type extends string
483
+ ? TypeString<type>
484
+ : type extends number
485
+ ? TypeNumber<type>
486
+ : type extends boolean
487
+ ? TypeBoolean
488
+ : type extends TypeCustom<FillFunction>
489
+ ? SchemaTypeCustom
490
+ : type extends FillPromise
491
+ ? TypePromise<type>
492
+ : type extends symbol
493
+ ? TypeSymbol<type>
494
+ : type extends FillArray
495
+ ? TypeArray<type>
496
+ : type extends DOMStringMap
497
+ ? TypeObject<type>
498
+ : type extends TypesSelfValues
499
+ ? GetTypeSelf<type> extends never
500
+ ? TypesDiscard<type>
501
+ : TypeConstructor<GetTypeSelf<type>>
502
+ : TypesDiscard<type>;
503
+
504
+ declare type TypeAny<type = any> = null | SchemaAny<type>;
505
+
506
+ declare type TypeArray<type extends FillArray> =
507
+ | ArrayConstructor
508
+ | SchemaReflectWrapper<ArrayConstructor, type>;
509
+
510
+ declare type TypeBoolean =
511
+ | BooleanConstructor
512
+ | SchemaReflectWrapper<BooleanConstructor, true | false>;
513
+
514
+ declare type TypeConstructor<type extends FillConstructor> =
515
+ | type
516
+ | SchemaOnlyPropWrapper<type, InstanceType<type>>;
517
+
518
+ declare type TypeCustom<Map extends FillFunction> = {
519
+ name: "Custom";
520
+ map: Map;
521
+ serialize?: (value: ReturnType<Map>) => string;
522
+ };
523
+
524
+ declare type TypeFunction<type extends FillFunction> =
525
+ | FunctionConstructor
526
+ | SchemaOnlyPropWrapper<FunctionConstructor, type>;
527
+
528
+ declare type TypeNumber<type extends number> =
529
+ | NumberConstructor
530
+ | SchemaReflectWrapper<NumberConstructor, type>;
531
+
532
+ declare type TypeObject<type extends FillObject> =
533
+ | ObjectConstructor
534
+ | SchemaReflectWrapper<ObjectConstructor, type>;
535
+
536
+ declare type TypePromise<type extends FillPromise> =
537
+ | PromiseConstructor
538
+ | SchemaOnlyPropWrapper<PromiseConstructor, type>;
539
+
540
+ declare type TypesDiscard<type> = type extends FillFunction
541
+ ? TypeFunction<type>
542
+ : type extends FillObject
543
+ ? TypeObject<type>
544
+ : TypeAny<type>;
545
+
546
+ declare type TypesSelfValues = {
547
+ [I in keyof SelfConstructors]-?: InstanceType<SelfConstructors[I]>;
548
+ }[keyof SelfConstructors];
549
+
550
+ declare type TypeString<type extends string> =
551
+ | StringConstructor
552
+ | SchemaReflectWrapper<StringConstructor, type>;
553
+
554
+ declare type TypeSymbol<type extends symbol> =
555
+ | SymbolConstructor
556
+ | SchemaOnlyPropWrapper<SymbolConstructor, type>;
557
+
558
+ export { }
559
+ // this is just a hacky workaround to ensure the global declarations make it into the dts rollup
560
+ // they get appended to the end of the file on vite build
561
+ declare global {
562
+ interface HTMLElementTagNameMap {
563
+ "calendar-month": InstanceType<typeof CalendarMonth>;
564
+ "calendar-date": InstanceType<typeof CalendarDate>;
565
+ "calendar-range": InstanceType<typeof CalendarRange>;
566
+ }
567
+ }