@neovici/cosmoz-utils 5.8.0 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/array.d.ts CHANGED
@@ -1 +1,6 @@
1
- export declare const array: (arr: unknown) => any[], without: (exclude: unknown, predicate?: <T>(obj: T) => T) => (list: unknown) => any[];
1
+ export declare function array(): [];
2
+ export declare function array(arr: null): [];
3
+ export declare function array<T>(arr: T[]): T[];
4
+ export declare function array<T>(arr: Iterable<T>): T[];
5
+ export declare function array<T = unknown>(arr: T): T[];
6
+ export declare const without: (exclude: unknown, predicate?: <T>(obj: T) => T) => (list: unknown) => unknown[];
package/dist/array.js CHANGED
@@ -1,8 +1,9 @@
1
+ /* eslint-disable func-style */
1
2
  import { identity } from './function';
2
3
  const isIterable = (x) => {
3
4
  return typeof x === 'object' && x !== null && Symbol.iterator in x;
4
5
  };
5
- export const array = (arr) => {
6
+ export function array(arr) {
6
7
  if (arr == null) {
7
8
  return [];
8
9
  }
@@ -16,9 +17,9 @@ export const array = (arr) => {
16
17
  return Array.from(arr);
17
18
  }
18
19
  return [arr];
19
- },
20
+ }
20
21
  // TODO: Improve definition
21
- without = (exclude, predicate = identity) => (list) => {
22
+ export const without = (exclude, predicate = identity) => (list) => {
22
23
  const excludes = array(exclude).map(predicate);
23
24
  return array(list).filter((value) => !excludes.includes(predicate(value)));
24
25
  };
@@ -10,7 +10,7 @@ export declare class UntilDirective extends AsyncDirective {
10
10
  private __values;
11
11
  private __weakThis;
12
12
  private __pauser;
13
- render(...args: Array<unknown>): unknown;
13
+ render(...args: Array<unknown>): {};
14
14
  update(_part: Part, args: Array<unknown>): unknown;
15
15
  disconnected(): void;
16
16
  reconnected(): void;
@@ -1,12 +1,12 @@
1
1
  import { AttributePart } from 'lit-html';
2
2
  import { Directive } from 'lit-html/directive.js';
3
- declare type OnMeasure = (rects: DOMRectReadOnly[]) => void;
4
- declare type Select = (el: HTMLElement) => HTMLElement[];
3
+ type OnMeasure = (rects: DOMRectReadOnly[]) => void;
4
+ type Select = <T extends Element>(el: T) => T[];
5
5
  declare class MeasureDirective extends Directive {
6
6
  _observer?: ResizeObserver;
7
7
  render(): symbol;
8
8
  update(part: AttributePart, [select, onMeasure]: [Select, OnMeasure]): symbol;
9
- measure(element: HTMLElement, select: Select, onMeasure: OnMeasure): symbol;
9
+ measure(element: Element, select: Select, onMeasure: OnMeasure): symbol;
10
10
  }
11
11
  export declare const measure: () => import("lit-html/directive.js").DirectiveResult<typeof MeasureDirective>;
12
12
  export {};
@@ -1,5 +1,5 @@
1
- declare type OrFn<T> = (...args: T[]) => boolean;
2
- declare type OnceFn<A, R> = (...args: A[]) => R;
3
- declare type OnceCheckFn<T> = (args: T[]) => boolean | undefined;
1
+ type OrFn<T> = (...args: T[]) => boolean;
2
+ type OnceFn<A, R> = (...args: A[]) => R;
3
+ type OnceCheckFn<T> = (args: T[]) => boolean | undefined;
4
4
  export declare const constant: <T>(v?: T | undefined) => () => T | undefined, constTrue: () => boolean | undefined, constUndefined: () => unknown, noop: () => unknown, identity: <T>(obj: T) => T, or: <A, F extends OrFn<A>>(...fns: F[]) => (...args: A[]) => boolean, once: <A, R, F extends OnceFn<A, R>>(fn: F, check?: OnceCheckFn<A>) => (...args: A[]) => any;
5
5
  export {};
@@ -1,5 +1,9 @@
1
1
  import { BaseScheduler, GenericRenderer, ComponentOrVirtualComponent } from 'haunted';
2
2
  import { ChildPart } from 'lit-html';
3
+ import { Rec } from './object';
4
+ export type Constructor<T> = new (...args: any[]) => T;
5
+ type Hook = <T>(a: T) => void;
6
+ type Obj = Rec<string>;
3
7
  declare class Scheduler<P extends object, T extends HTMLElement | ChildPart, R extends GenericRenderer<T, P>, H extends ComponentOrVirtualComponent<T, P>, C extends (result: unknown) => void> extends BaseScheduler<P, T, R, H> {
4
8
  _commit: C;
5
9
  constructor(renderer: R, host: H, commitCallback: C);
@@ -10,13 +14,10 @@ interface PElement extends HTMLElement {
10
14
  disconnectedCallback(): void;
11
15
  set<T>(path: string, value: T): void;
12
16
  setProperties<T>(props: T): void;
13
- _propertiesChanged<P, C, O>(currentProps: P, changedProps: C, oldProps: O): void;
17
+ _propertiesChanged<P extends Obj, C extends Obj, O>(currentProps: P, changedProps: C, oldProps: O): void;
14
18
  _hauntedUpdateFrameHandle: ReturnType<typeof requestAnimationFrame>;
15
- _onlyHauntedPropertiesChanged<T>(changedProps: T): boolean;
19
+ _onlyHauntedPropertiesChanged<T extends Obj>(changedProps: T): boolean;
16
20
  }
17
- export declare type Constructor<T> = new (...args: any[]) => T;
18
- declare type Hook = <T>(a: T) => void;
19
- declare type Obj = Record<string, any>;
20
21
  /**
21
22
  * Creates a mixin that mixes a haunted hook with a polymer component.
22
23
  *
@@ -41,6 +42,7 @@ export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) =>
41
42
  dir: string;
42
43
  draggable: boolean;
43
44
  hidden: boolean;
45
+ inert: boolean;
44
46
  innerText: string;
45
47
  lang: string;
46
48
  readonly offsetHeight: number;
@@ -180,12 +182,14 @@ export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) =>
180
182
  ariaChecked: string | null;
181
183
  ariaColCount: string | null;
182
184
  ariaColIndex: string | null;
185
+ ariaColIndexText: string | null;
183
186
  ariaColSpan: string | null;
184
187
  ariaCurrent: string | null;
185
188
  ariaDisabled: string | null;
186
189
  ariaExpanded: string | null;
187
190
  ariaHasPopup: string | null;
188
191
  ariaHidden: string | null;
192
+ ariaInvalid: string | null;
189
193
  ariaKeyShortcuts: string | null;
190
194
  ariaLabel: string | null;
191
195
  ariaLevel: string | null;
@@ -202,6 +206,7 @@ export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) =>
202
206
  ariaRoleDescription: string | null;
203
207
  ariaRowCount: string | null;
204
208
  ariaRowIndex: string | null;
209
+ ariaRowIndexText: string | null;
205
210
  ariaRowSpan: string | null;
206
211
  ariaSelected: string | null;
207
212
  ariaSetSize: string | null;
@@ -210,6 +215,7 @@ export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) =>
210
215
  ariaValueMin: string | null;
211
216
  ariaValueNow: string | null;
212
217
  ariaValueText: string | null;
218
+ role: string | null;
213
219
  animate(keyframes: PropertyIndexedKeyframes | Keyframe[] | null, options?: number | KeyframeAnimationOptions | undefined): Animation;
214
220
  getAnimations(options?: GetAnimationsOptions | undefined): Animation[];
215
221
  after(...nodes: (string | Node)[]): void;
@@ -247,7 +253,9 @@ export declare const hauntedPolymer: (outputPath: string | Hook, hook?: Hook) =>
247
253
  onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
248
254
  onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
249
255
  onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
256
+ onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
250
257
  onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
258
+ oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
251
259
  oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
252
260
  oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
253
261
  onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
@@ -1,3 +1,3 @@
1
- declare type UseHost = <T extends HTMLElement>() => T;
1
+ type UseHost = <T extends HTMLElement>() => T;
2
2
  export declare const useHost: UseHost;
3
3
  export {};
@@ -1,3 +1,4 @@
1
+ import { Rec } from '../object';
1
2
  /**
2
3
  * Copies properties of an Object into a memoized object.
3
4
  * Useful to create an object that does not change.
@@ -5,4 +6,4 @@
5
6
  * @param {Object} meta - The source object
6
7
  * @returns {Object} The memoized object.
7
8
  */
8
- export declare const useMeta: <T>(meta: T) => T;
9
+ export declare const useMeta: <T extends Rec<PropertyKey, any>>(meta: T) => T;
package/dist/object.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { identity } from './function';
2
- declare type Rec<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;
2
+ export type Rec<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;
3
3
  export declare function prop(): typeof identity;
4
4
  export declare function prop(a: '' | null | false | undefined | 0): typeof identity;
5
5
  export declare function prop<K extends PropertyKey>(key: K): <O extends Rec<K>>(obj: O) => O[K];
@@ -7,7 +7,7 @@ export declare const strProp: <K extends PropertyKey>(key: K) => <O extends Rec<
7
7
  export declare const transform: <K extends string, V, RK extends PropertyKey, RV>(obj: Record<K, V>, trans: (entries: [Extract<K, string>, V][]) => Iterable<readonly [RK, RV]>) => { [key in RK]: RV; };
8
8
  export declare const omit: <K extends PropertyKey>(keys: K[]) => <T extends Rec<PropertyKey, any>>(obj: T) => { [key in Exclude<keyof T, K>]: T[key]; };
9
9
  export declare const props: <K extends PropertyKey>(keys: K[]) => <T extends Rec<PropertyKey, any>>(obj: T) => { [key in K & keyof T]: T[key]; };
10
- declare type Merge<T1, T2> = {
10
+ type Merge<T1, T2> = {
11
11
  [key in Exclude<keyof T1, keyof T2>]: T1[key];
12
12
  } & {
13
13
  [key in Exclude<keyof T2, keyof T1>]: T2[key];
package/dist/promise.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- declare type Pfn<T> = (arg?: T) => void;
1
+ type Pfn<T> = (arg?: T) => void;
2
2
  export declare class ManagedPromise<T> extends Promise<T> {
3
3
  constructor(callback?: (resolve: Pfn<T>, reject: Pfn<T>) => void);
4
4
  resolve: Pfn<T>;
5
5
  }
6
6
  export declare const timeout$: (ms?: number) => Promise<unknown>;
7
- declare type Predicate<T extends Event> = (e: T) => boolean;
7
+ type Predicate<T extends Event> = (e: T) => boolean;
8
8
  export declare const event$: <E extends Event, P extends Predicate<E>>(target: EventTarget, type: string, predicate?: P | undefined, timeout?: number) => Promise<unknown>;
9
9
  export declare const limit$: <T extends [], P>(fn: (...args: T) => PromiseLike<P>, limit: number) => (...args: T) => Promise<P>;
10
10
  export declare const debounce$: <T extends [], P>(fn: (...args: T) => PromiseLike<P>, ms?: number) => (...args: T) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- declare type Creator<T extends [], R extends object> = (...args: T) => R;
1
+ type Creator<T extends [], R extends object> = (...args: T) => R;
2
2
  export interface Action<T = unknown> {
3
3
  type?: T;
4
4
  toString: () => string;
@@ -9,5 +9,5 @@ declare const action: <T, A extends [], R extends object>(type: T, create?: Crea
9
9
  }) & {
10
10
  type: T;
11
11
  toString(): T;
12
- }, type: <T>(action: Action<T>) => string | T;
12
+ }, type: <T>(action: Action<T>) => string | NonNullable<T>;
13
13
  export { action, type };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-utils",
3
- "version": "5.8.0",
3
+ "version": "5.8.1",
4
4
  "description": "Date, money and template management functions commonly needed in Cosmoz views.",
5
5
  "keywords": [
6
6
  "polymer",
@@ -77,7 +77,7 @@
77
77
  "@polymer/polymer": "^3.3.1",
78
78
  "@semantic-release/changelog": "^6.0.0",
79
79
  "@semantic-release/git": "^10.0.0",
80
- "@web/test-runner": "^0.13.0",
80
+ "@web/test-runner": "^0.15.0",
81
81
  "husky": "^8.0.0",
82
82
  "lit-html": "^2.0.0",
83
83
  "semantic-release": "^19.0.0",