@patternfly/pfe-core 3.0.0 → 4.0.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.
- package/controllers/activedescendant-controller.d.ts +99 -0
- package/controllers/activedescendant-controller.js +230 -0
- package/controllers/activedescendant-controller.js.map +1 -0
- package/controllers/at-focus-controller.d.ts +56 -0
- package/controllers/at-focus-controller.js +168 -0
- package/controllers/at-focus-controller.js.map +1 -0
- package/controllers/cascade-controller.d.ts +7 -2
- package/controllers/cascade-controller.js +6 -1
- package/controllers/cascade-controller.js.map +1 -1
- package/controllers/combobox-controller.d.ts +117 -0
- package/controllers/combobox-controller.js +611 -0
- package/controllers/combobox-controller.js.map +1 -0
- package/controllers/css-variable-controller.js +1 -1
- package/controllers/css-variable-controller.js.map +1 -1
- package/controllers/floating-dom-controller.d.ts +8 -1
- package/controllers/floating-dom-controller.js +12 -5
- package/controllers/floating-dom-controller.js.map +1 -1
- package/controllers/internals-controller.d.ts +26 -9
- package/controllers/internals-controller.js +45 -13
- package/controllers/internals-controller.js.map +1 -1
- package/controllers/light-dom-controller.js +2 -2
- package/controllers/light-dom-controller.js.map +1 -1
- package/controllers/listbox-controller.d.ts +118 -33
- package/controllers/listbox-controller.js +347 -154
- package/controllers/listbox-controller.js.map +1 -1
- package/controllers/logger.d.ts +13 -10
- package/controllers/logger.js +15 -11
- package/controllers/logger.js.map +1 -1
- package/controllers/overflow-controller.js +10 -6
- package/controllers/overflow-controller.js.map +1 -1
- package/controllers/perf-controller.js.map +1 -1
- package/controllers/property-observer-controller.d.ts +13 -16
- package/controllers/property-observer-controller.js +54 -25
- package/controllers/property-observer-controller.js.map +1 -1
- package/controllers/roving-tabindex-controller.d.ts +12 -61
- package/controllers/roving-tabindex-controller.js +57 -203
- package/controllers/roving-tabindex-controller.js.map +1 -1
- package/controllers/scroll-spy-controller.d.ts +4 -1
- package/controllers/scroll-spy-controller.js +9 -6
- package/controllers/scroll-spy-controller.js.map +1 -1
- package/controllers/slot-controller.d.ts +12 -16
- package/controllers/slot-controller.js +17 -20
- package/controllers/slot-controller.js.map +1 -1
- package/controllers/style-controller.js +3 -1
- package/controllers/style-controller.js.map +1 -1
- package/controllers/tabs-aria-controller.d.ts +2 -0
- package/controllers/tabs-aria-controller.js +2 -0
- package/controllers/tabs-aria-controller.js.map +1 -1
- package/controllers/test/combobox-controller.spec.d.ts +1 -0
- package/controllers/test/combobox-controller.spec.js +282 -0
- package/controllers/test/combobox-controller.spec.js.map +1 -0
- package/controllers/timestamp-controller.js +7 -2
- package/controllers/timestamp-controller.js.map +1 -1
- package/core.d.ts +0 -23
- package/core.js +1 -38
- package/core.js.map +1 -1
- package/custom-elements.json +3844 -1369
- package/decorators/bound.d.ts +3 -1
- package/decorators/bound.js +3 -1
- package/decorators/bound.js.map +1 -1
- package/decorators/cascades.d.ts +2 -1
- package/decorators/cascades.js +2 -1
- package/decorators/cascades.js.map +1 -1
- package/decorators/deprecation.d.ts +6 -5
- package/decorators/deprecation.js +6 -5
- package/decorators/deprecation.js.map +1 -1
- package/decorators/initializer.js.map +1 -1
- package/decorators/listen.d.ts +8 -0
- package/decorators/listen.js +22 -0
- package/decorators/listen.js.map +1 -0
- package/decorators/observed.d.ts +12 -16
- package/decorators/observed.js +39 -44
- package/decorators/observed.js.map +1 -1
- package/decorators/observes.d.ts +15 -0
- package/decorators/observes.js +30 -0
- package/decorators/observes.js.map +1 -0
- package/decorators/time.d.ts +1 -0
- package/decorators/time.js +6 -9
- package/decorators/time.js.map +1 -1
- package/decorators/trace.d.ts +4 -1
- package/decorators/trace.js +4 -1
- package/decorators/trace.js.map +1 -1
- package/decorators.d.ts +2 -0
- package/decorators.js +2 -0
- package/decorators.js.map +1 -1
- package/functions/arraysAreEquivalent.d.ts +9 -0
- package/functions/arraysAreEquivalent.js +28 -0
- package/functions/arraysAreEquivalent.js.map +1 -0
- package/functions/containsDeep.d.ts +2 -0
- package/functions/containsDeep.js +2 -0
- package/functions/containsDeep.js.map +1 -1
- package/functions/context.d.ts +3 -4
- package/functions/context.js +6 -2
- package/functions/context.js.map +1 -1
- package/functions/debounce.js.map +1 -1
- package/functions/isElementInView.d.ts +4 -6
- package/functions/isElementInView.js +9 -11
- package/functions/isElementInView.js.map +1 -1
- package/package.json +7 -4
package/decorators/bound.d.ts
CHANGED
package/decorators/bound.js
CHANGED
package/decorators/bound.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bound.js","sourceRoot":"","sources":["bound.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B
|
|
1
|
+
{"version":3,"file":"bound.js","sourceRoot":"","sources":["bound.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,KAAK,CAAC,CAAU,EAAE,GAAW,EAAE,UAA8B;IAC3E,IAAI,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,+CAA+C,GAAG,IAAK,CAAgB,CAAC,IAAI,oBAAoB,CAAC,CAAC;IACxH,CAAC,CAAC,oBAAoB;IACtB,OAAO;QACL,YAAY;QACZ,GAAG;YACD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1E,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["const configurable = true;\n\n/**\n * Binds a class method to the instance\n * @param _\n * @param key\n * @param descriptor\n * @example Binding an event listener\n * ```ts\n * private mo = new MutationObserver(this.onMutation);\n *\n * @bound onMutation(records: MutationRecord[]) {\n * this.count = this.children.length;\n * }\n * ```\n */\nexport function bound(_: unknown, key: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n if (typeof descriptor?.value !== 'function') {\n throw new TypeError(`Only methods can be decorated with @bound. <${key ?? (_ as () => void).name}> is not a method!`);\n } /* c8 ignore next */\n return {\n configurable,\n get() {\n const value = descriptor.value.bind(this);\n Object.defineProperty(this, key, { value, configurable, writable: true });\n return value;\n },\n };\n}\n"]}
|
package/decorators/cascades.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactiveElement } from 'lit';
|
|
2
2
|
/**
|
|
3
3
|
* Cascades the decorated attribute to children
|
|
4
|
-
* @
|
|
4
|
+
* @param items
|
|
5
|
+
* @deprecated use context, especially via `@patternfly/pfe-core/functions/context.js`;
|
|
5
6
|
*/
|
|
6
7
|
export declare function cascades<T extends ReactiveElement>(...items: string[]): PropertyDecorator;
|
package/decorators/cascades.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CascadeController } from '../controllers/cascade-controller.js';
|
|
2
2
|
/**
|
|
3
3
|
* Cascades the decorated attribute to children
|
|
4
|
-
* @
|
|
4
|
+
* @param items
|
|
5
|
+
* @deprecated use context, especially via `@patternfly/pfe-core/functions/context.js`;
|
|
5
6
|
*/
|
|
6
7
|
export function cascades(...items) {
|
|
7
8
|
return function (proto, key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascades.js","sourceRoot":"","sources":["cascades.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE
|
|
1
|
+
{"version":3,"file":"cascades.js","sourceRoot":"","sources":["cascades.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAA4B,GAAG,KAAe;IACpE,OAAO,UAAS,KAAQ,EAAE,GAAqB;QAC5C,KAAK,CAAC,WAAsC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;YAC/D,MAAM,QAAQ,GAAG,CAAoB,CAAC;YACtC,6DAA6D;YAC7D,6DAA6D;YAC7D,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/C,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7E,CAAC;YAED,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAsB,CAAC;AACzB,CAAC","sourcesContent":["import type { ReactiveElement } from 'lit';\n\nimport { CascadeController } from '../controllers/cascade-controller.js';\n\n/**\n * Cascades the decorated attribute to children\n * @param items\n * @deprecated use context, especially via `@patternfly/pfe-core/functions/context.js`;\n */\nexport function cascades<T extends ReactiveElement>(...items: string[]): PropertyDecorator {\n return function(proto: T, key: string & keyof T) {\n (proto.constructor as typeof ReactiveElement).addInitializer(x => {\n const instance = x as ReactiveElement;\n // You can have multiple `@cascades` decorators on an element\n // and it will only get one CascadeController for all of them\n if (!CascadeController.instances.has(instance)) {\n CascadeController.instances.set(instance, new CascadeController(instance));\n }\n\n CascadeController.instances.get(instance)?.initProp(key, items);\n });\n } as PropertyDecorator;\n}\n"]}
|
|
@@ -5,12 +5,13 @@ export type DeprecationDeclaration<K extends PropertyKey> = PropertyDeclaration
|
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Aliases the decorated field to an existing property, and logs a warning if it is used
|
|
8
|
+
* @param options alias is a drop in replacement
|
|
8
9
|
* @example deprecating an attribute
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* @property({ reflect: true, attribute: 'color-palette'})
|
|
12
|
+
* colorPalette: ColorPalette = 'base';
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* @deprecation('colorPalette') color?: ColorPalette;
|
|
15
|
+
* ```
|
|
15
16
|
*/
|
|
16
17
|
export declare function deprecation<K extends PropertyKey>(options: DeprecationDeclaration<K>): <T extends ReactiveElement, L extends PropertyKey>(proto: Partial<Record<K | L, T>>, key: string & keyof T) => void;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Logger } from '../controllers/logger.js';
|
|
2
2
|
/**
|
|
3
3
|
* Aliases the decorated field to an existing property, and logs a warning if it is used
|
|
4
|
+
* @param options alias is a drop in replacement
|
|
4
5
|
* @example deprecating an attribute
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* @property({ reflect: true, attribute: 'color-palette'})
|
|
8
|
+
* colorPalette: ColorPalette = 'base';
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* @deprecation('colorPalette') color?: ColorPalette;
|
|
11
|
+
* ```
|
|
11
12
|
*/
|
|
12
13
|
export function deprecation(options) {
|
|
13
14
|
return function (proto, key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecation.js","sourceRoot":"","sources":["deprecation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAOlD
|
|
1
|
+
{"version":3,"file":"deprecation.js","sourceRoot":"","sources":["deprecation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAOlD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACzB,OAAkC;IAElC,OAAO,UACL,KAAgC,EAChC,GAAqB;QAErB,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,OAAO,CAAC;QACjD,MAAM,KAAK,GAAI,KAAK,CAAC,WAAsC,CAAC;QAC5D,MAAM,WAAW,GAAG,KAAK,C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it';\n\nimport { Logger } from '../controllers/logger.js';\n\nexport type DeprecationDeclaration<K extends PropertyKey> = PropertyDeclaration & {\n alias: string & K;\n attribute: string;\n};\n\n/**\n * Aliases the decorated field to an existing property, and logs a warning if it is used\n * @param options alias is a drop in replacement\n * @example deprecating an attribute\n * ```ts\n * @property({ reflect: true, attribute: 'color-palette'})\n * colorPalette: ColorPalette = 'base';\n *\n * @deprecation('colorPalette') color?: ColorPalette;\n * ```\n */\nexport function deprecation<K extends PropertyKey>(\n options: DeprecationDeclaration<K>,\n) {\n return function<T extends ReactiveElement, L extends PropertyKey>(\n proto: Partial<Record<K | L, T>>,\n key: string & keyof T\n ): void {\n const { alias, ...deprecationOptions } = options;\n const klass = (proto.constructor as typeof ReactiveElement);\n const declaration = klass.getPropertyOptions(alias);\n klass.createProperty(key, { ...declaration, ...deprecationOptions });\n klass.addInitializer(instance => {\n instance.addController(new Deprecation(instance as T, options, key));\n });\n };\n}\n\nclass Deprecation<T extends ReactiveElement, K extends PropertyKey> implements ReactiveController {\n private logger: Logger;\n\n private logged = false;\n\n constructor(\n private host: T,\n private options: DeprecationDeclaration<K>,\n private deprecatedKey: string & keyof T\n ) {\n this.logger = new Logger(host);\n }\n\n hostUpdate() {\n const { deprecatedKey, options: { alias } } = this;\n if (this.host[deprecatedKey]) {\n if (this.host[alias as keyof T] !== this.host[deprecatedKey]) {\n if (!this.logged) {\n this.logger.warn(`${deprecatedKey} is deprecated, use ${alias} instead`);\n this.logged = true;\n }\n this.host[alias as keyof T] = this.host[deprecatedKey];\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializer.js","sourceRoot":"","sources":["initializer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAA4B,OAAiB;IACtE,OAAO,UAAS,KAAQ,EAAE,GAAW;QACnC,qCAAqC;QACpC,KAAK,CAAC,WAAsC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YACtE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAc,CAA0B,CAAC;YACnE,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,QAA2B,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAC7F,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACzB,UAAU,CAAC,aAAa,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactiveElement } from 'lit';\nimport type { Options } from '../controllers/light-dom-controller.js';\n\nimport { LightDOMController } from '../controllers/light-dom-controller.js';\n\n/**\n * Runs the decorated method in `connectedCallback`,\n * provided the element has light children, and sets\n * up a mutation observer to re-run the callback,\n * unless opted-out with `{ observe: false }`\n * @param options Set `observe` to `false` to skip mutation observer setup, or pass a MutationObserverInit as options\n */\nexport function initializer<T extends ReactiveElement>(options?: Options) {\n return function(proto: T, key: string) {\n // @TODO: allow multiple initializers\n (proto.constructor as typeof ReactiveElement).addInitializer(instance => {\n const initializer = proto[key as keyof T] as unknown as () => void;\n const controller = new LightDOMController(instance as ReactiveElement, initializer, options);\n if (instance.isConnected) {\n controller.hostConnected();\n }\n });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"initializer.js","sourceRoot":"","sources":["initializer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAA4B,OAAiB;IACtE,OAAO,UAAS,KAAQ,EAAE,GAAW;QACnC,qCAAqC;QACpC,KAAK,CAAC,WAAsC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YACtE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAc,CAA0B,CAAC;YACnE,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,QAA2B,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;YAC7F,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACzB,UAAU,CAAC,aAAa,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactiveElement } from 'lit';\nimport type { Options } from '../controllers/light-dom-controller.js';\n\nimport { LightDOMController } from '../controllers/light-dom-controller.js';\n\n/**\n * Runs the decorated method in `connectedCallback`,\n * provided the element has light children, and sets\n * up a mutation observer to re-run the callback,\n * unless opted-out with `{ observe: false }`\n * @param options Set `observe` to `false` to skip mutation observer setup, or pass a MutationObserverInit as options\n */\nexport function initializer<T extends ReactiveElement>(options?: Options) {\n return function(proto: T, key: string): void {\n // @TODO: allow multiple initializers\n (proto.constructor as typeof ReactiveElement).addInitializer(instance => {\n const initializer = proto[key as keyof T] as unknown as () => void;\n const controller = new LightDOMController(instance as ReactiveElement, initializer, options);\n if (instance.isConnected) {\n controller.hostConnected();\n }\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Listens for a given event on the custom element.
|
|
4
|
+
* equivalent to calling `this.addEventListener` in the constructor
|
|
5
|
+
* @param type event type e.g. `click`
|
|
6
|
+
* @param options event listener options object e.g. `{ passive: true }`
|
|
7
|
+
*/
|
|
8
|
+
export declare function listen<P extends LitElement>(type: keyof HTMLElementEventMap, options?: AddEventListenerOptions): (proto: LitElement, methodName: string) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Listens for a given event on the custom element.
|
|
3
|
+
* equivalent to calling `this.addEventListener` in the constructor
|
|
4
|
+
* @param type event type e.g. `click`
|
|
5
|
+
* @param options event listener options object e.g. `{ passive: true }`
|
|
6
|
+
*/
|
|
7
|
+
export function listen(type, options) {
|
|
8
|
+
return function (proto, methodName) {
|
|
9
|
+
const origConnected = proto.connectedCallback;
|
|
10
|
+
const origDisconnected = proto.disconnectedCallback;
|
|
11
|
+
const listener = proto[methodName];
|
|
12
|
+
proto.connectedCallback = function () {
|
|
13
|
+
origConnected?.call(this);
|
|
14
|
+
this.addEventListener(type, listener, options);
|
|
15
|
+
};
|
|
16
|
+
proto.disconnectedCallback = function () {
|
|
17
|
+
origDisconnected?.call(this);
|
|
18
|
+
this.removeEventListener(type, listener, options);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=listen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen.js","sourceRoot":"","sources":["listen.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CACpB,IAA+B,EAC/B,OAAiC;IAEjC,OAAO,UACL,KAAiB,EACjB,UAAkB;QAElB,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAC9C,MAAM,gBAAgB,GAAG,KAAK,CAAC,oBAAoB,CAAC;QACpD,MAAM,QAAQ,GAAI,KAAW,CAAC,UAAqB,CAAkB,CAAC;QACtE,KAAK,CAAC,iBAAiB,GAAG;YACxB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC;QACF,KAAK,CAAC,oBAAoB,GAAG;YAC3B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { LitElement } from 'lit';\n\n/**\n * Listens for a given event on the custom element.\n * equivalent to calling `this.addEventListener` in the constructor\n * @param type event type e.g. `click`\n * @param options event listener options object e.g. `{ passive: true }`\n */\nexport function listen<P extends LitElement>(\n type: keyof HTMLElementEventMap,\n options?: AddEventListenerOptions,\n) {\n return function(\n proto: LitElement,\n methodName: string,\n ): void {\n const origConnected = proto.connectedCallback;\n const origDisconnected = proto.disconnectedCallback;\n const listener = (proto as P)[methodName as keyof P] as EventListener;\n proto.connectedCallback = function() {\n origConnected?.call(this);\n this.addEventListener(type, listener, options);\n };\n proto.disconnectedCallback = function() {\n origDisconnected?.call(this);\n this.removeEventListener(type, listener, options);\n };\n };\n}\n"]}
|
package/decorators/observed.d.ts
CHANGED
|
@@ -6,28 +6,24 @@ type TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void;
|
|
|
6
6
|
* Works on any class field. When using on lit observed properties,
|
|
7
7
|
* Make sure `@observed` is to the left (i.e. called after) the `@property`
|
|
8
8
|
* or `@state` decorator.
|
|
9
|
-
*
|
|
10
9
|
* @example observing a lit property
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* protected _fooChanged(oldValue?: string, newValue?: string) {}
|
|
15
|
-
* ```
|
|
10
|
+
* ```ts
|
|
11
|
+
* @observed @property() foo = 'bar';
|
|
16
12
|
*
|
|
13
|
+
* protected _fooChanged(oldValue?: string, newValue?: string) {}
|
|
14
|
+
* ```
|
|
17
15
|
* @example using a custom callback
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* _myCallback(_, size) {...}
|
|
22
|
-
* ```
|
|
16
|
+
* ```ts
|
|
17
|
+
* @observed('_myCallback') size = 'lg';
|
|
23
18
|
*
|
|
19
|
+
* _myCallback(_, size) {...}
|
|
20
|
+
* ```
|
|
24
21
|
* @example using an arrow function
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* @observed((oldVal, newVal) => console.log(`Size changed from ${oldVal} to ${newVal}`))
|
|
24
|
+
* ```
|
|
28
25
|
*/
|
|
26
|
+
export declare function observed<T extends ReactiveElement, V>(cb: ChangeCallback<T, V>): TypedFieldDecorator<T>;
|
|
29
27
|
export declare function observed<T extends ReactiveElement>(methodName: string): TypedFieldDecorator<T>;
|
|
30
|
-
export declare function observed<T extends ReactiveElement>(cb: ChangeCallback<T>): TypedFieldDecorator<T>;
|
|
31
28
|
export declare function observed<T extends ReactiveElement>(proto: T, key: string): void;
|
|
32
|
-
export declare function observeProperty<T extends ReactiveElement>(proto: T, key: string & keyof T, callbackOrMethod?: ChangeCallback<T>): void;
|
|
33
29
|
export {};
|
package/decorators/observed.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyObserverController } from '../controllers/property-observer-controller.js';
|
|
2
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
2
3
|
export function observed(...as) {
|
|
3
|
-
/** @observed('_myCustomChangeCallback') */
|
|
4
4
|
if (as.length === 1) {
|
|
5
|
-
const [
|
|
6
|
-
return
|
|
7
|
-
proto.constructor
|
|
8
|
-
.addInitializer(x => new PropertyObserverController(x));
|
|
9
|
-
observeProperty(proto, key, methodNameOrCallback);
|
|
10
|
-
};
|
|
5
|
+
const [methodNameOrCb] = as;
|
|
6
|
+
return configuredDecorator(methodNameOrCb);
|
|
11
7
|
}
|
|
12
8
|
else {
|
|
13
|
-
|
|
14
|
-
proto.constructor
|
|
15
|
-
.addInitializer(x => new PropertyObserverController(x));
|
|
16
|
-
observeProperty(proto, key);
|
|
9
|
+
return executeBareDecorator(...as);
|
|
17
10
|
}
|
|
18
11
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @param proto element prototype
|
|
14
|
+
* @param propertyName propertyName
|
|
15
|
+
* @example ```typescript
|
|
16
|
+
* @observed @property() foo?: string;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function executeBareDecorator(proto, propertyName) {
|
|
20
|
+
const klass = proto.constructor;
|
|
21
|
+
klass.addInitializer(x => initialize(x, propertyName, x[`_${propertyName}Changed`]));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param methodNameOrCb string name of callback or function
|
|
25
|
+
* @example ```typescript
|
|
26
|
+
* @observed('_myCallback') @property() foo?: string;
|
|
27
|
+
* @observed((old) => console.log(old)) @property() bar?: string;
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function configuredDecorator(methodNameOrCb) {
|
|
31
|
+
return function (proto, key) {
|
|
32
|
+
const propertyName = key;
|
|
33
|
+
const klass = proto.constructor;
|
|
34
|
+
if (typeof methodNameOrCb === 'function') {
|
|
35
|
+
const callback = methodNameOrCb;
|
|
36
|
+
klass.addInitializer(x => initialize(x, propertyName, callback));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
klass.addInitializer(x => initialize(x, propertyName, x[methodNameOrCb]));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function initialize(instance, propertyName, callback) {
|
|
44
|
+
const controller = new PropertyObserverController(instance, { propertyName, callback });
|
|
45
|
+
instance.addController(controller);
|
|
51
46
|
}
|
|
52
47
|
//# sourceMappingURL=observed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observed.js","sourceRoot":"","sources":["observed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"observed.js","sourceRoot":"","sources":["observed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0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EAC9B,QAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,0BAA0B,CAAI,QAAa,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type { ReactiveElement } from 'lit';\nimport type { ChangeCallback } from '../controllers/property-observer-controller.js';\n\nimport { PropertyObserverController } from '../controllers/property-observer-controller.js';\n\ntype TypedFieldDecorator<T> = (proto: T, key: string | keyof T) => void ;\n\n// eslint-disable-next-line jsdoc/require-param\n/**\n * Calls a _fooChanged method on the instance when the value changes.\n * Works on any class field. When using on lit observed properties,\n * Make sure `@observed` is to the left (i.e. called after) the `@property`\n * or `@state` decorator.\n * @example observing a lit property\n * ```ts\n * @observed @property() foo = 'bar';\n *\n * protected _fooChanged(oldValue?: string, newValue?: string) {}\n * ```\n * @example using a custom callback\n * ```ts\n * @observed('_myCallback') size = 'lg';\n *\n * _myCallback(_, size) {...}\n * ```\n * @example using an arrow function\n * ```ts\n * @observed((oldVal, newVal) => console.log(`Size changed from ${oldVal} to ${newVal}`))\n * ```\n */\nexport function observed<T extends ReactiveElement, V>(\n cb: ChangeCallback<T, V>,\n): TypedFieldDecorator<T>;\nexport function observed<T extends ReactiveElement>(methodName: string): TypedFieldDecorator<T>;\nexport function observed<T extends ReactiveElement>(proto: T, key: string): void;\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function observed<T extends ReactiveElement>(...as: any[]): void | TypedFieldDecorator<T> {\n if (as.length === 1) {\n const [methodNameOrCb] = as;\n return configuredDecorator(methodNameOrCb);\n } else {\n return executeBareDecorator(...as as [T, string & keyof T]);\n }\n}\n\n/**\n * @param proto element prototype\n * @param propertyName propertyName\n * @example ```typescript\n * @observed @property() foo?: string;\n * ```\n */\nfunction executeBareDecorator<T extends ReactiveElement>(proto: T, propertyName: string & keyof T) {\n const klass = proto.constructor as typeof ReactiveElement;\n klass.addInitializer(x => initialize(\n x as T,\n propertyName,\n x[`_${propertyName}Changed` as keyof typeof x] as ChangeCallback<T>,\n ));\n}\n\n/**\n * @param methodNameOrCb string name of callback or function\n * @example ```typescript\n * @observed('_myCallback') @property() foo?: string;\n * @observed((old) => console.log(old)) @property() bar?: string;\n * ```\n */\nfunction configuredDecorator<T extends ReactiveElement>(\n methodNameOrCb: string | ChangeCallback<T>,\n): TypedFieldDecorator<T> {\n return function(proto, key) {\n const propertyName = key as string & keyof T;\n const klass = proto.constructor as typeof ReactiveElement;\n if (typeof methodNameOrCb === 'function') {\n const callback = methodNameOrCb;\n klass.addInitializer(x => initialize(x as T, propertyName, callback));\n } else {\n klass.addInitializer(x => initialize(\n x as T,\n propertyName,\n x[methodNameOrCb as keyof ReactiveElement] as ChangeCallback<T>,\n ));\n }\n };\n}\n\nfunction initialize<T extends ReactiveElement>(\n instance: T,\n propertyName: string & keyof T,\n callback: ChangeCallback<T>,\n) {\n const controller = new PropertyObserverController<T>(instance as T, { propertyName, callback });\n instance.addController(controller);\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactiveElement } from 'lit';
|
|
2
|
+
import { type PropertyObserverOptions } from '@patternfly/pfe-core/controllers/property-observer-controller.js';
|
|
3
|
+
/**
|
|
4
|
+
* Observes changes on the given property and calls the decorated method
|
|
5
|
+
* with the old and new values when it changes. In cases where the decorated method
|
|
6
|
+
* needs to access uninitialized class fields, You may need to wait for the element to connect
|
|
7
|
+
* before running your effects. In that case, you can optionally specify which
|
|
8
|
+
* lifecycle state to wait for. e.g.:
|
|
9
|
+
* - `waitFor: 'firstUpdate'` waits until the first update cycle has completed
|
|
10
|
+
* - `waitFor: 'updated'` waits until the next update cycle has completed
|
|
11
|
+
* - `waitFor: 'connected'` waits until the element connects
|
|
12
|
+
* @param propertyName property to react to
|
|
13
|
+
* @param [options] options including lifecycle to wait on.
|
|
14
|
+
*/
|
|
15
|
+
export declare function observes<T extends ReactiveElement>(propertyName: string & keyof T, options?: Partial<Exclude<PropertyObserverOptions<T>, 'callback' | 'propertyName'>>): (proto: T, methodName: string) => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PropertyObserverController, } from '@patternfly/pfe-core/controllers/property-observer-controller.js';
|
|
2
|
+
/**
|
|
3
|
+
* Observes changes on the given property and calls the decorated method
|
|
4
|
+
* with the old and new values when it changes. In cases where the decorated method
|
|
5
|
+
* needs to access uninitialized class fields, You may need to wait for the element to connect
|
|
6
|
+
* before running your effects. In that case, you can optionally specify which
|
|
7
|
+
* lifecycle state to wait for. e.g.:
|
|
8
|
+
* - `waitFor: 'firstUpdate'` waits until the first update cycle has completed
|
|
9
|
+
* - `waitFor: 'updated'` waits until the next update cycle has completed
|
|
10
|
+
* - `waitFor: 'connected'` waits until the element connects
|
|
11
|
+
* @param propertyName property to react to
|
|
12
|
+
* @param [options] options including lifecycle to wait on.
|
|
13
|
+
*/
|
|
14
|
+
export function observes(propertyName, options) {
|
|
15
|
+
return function (proto, methodName) {
|
|
16
|
+
const callback = proto[methodName];
|
|
17
|
+
if (typeof callback !== 'function') {
|
|
18
|
+
throw new Error('@observes must decorate a class method');
|
|
19
|
+
}
|
|
20
|
+
const klass = proto.constructor;
|
|
21
|
+
klass.addInitializer(instance => {
|
|
22
|
+
instance.addController(new PropertyObserverController(instance, {
|
|
23
|
+
...options,
|
|
24
|
+
propertyName,
|
|
25
|
+
callback,
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=observes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observes.js","sourceRoot":"","sources":["observes.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,GAG3B,MAAM,kEAAkE,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,YAA8B,EAC9B,OAAmF;IAEnF,OAAO,UAAS,KAAQ,EAAE,UAAkB;QAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAqB,CAAsB,CAAC;QACnE,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAqC,CAAC;QAC1D,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YAC9B,QAAQ,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAa,EAAE;gBACnE,GAAG,OAAO;gBACV,YAAY;gBACZ,QAAQ;aACT,CAAC,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactiveElement } from 'lit';\n\nimport {\n PropertyObserverController,\n type ChangeCallback,\n type PropertyObserverOptions,\n} from '@patternfly/pfe-core/controllers/property-observer-controller.js';\n\n/**\n * Observes changes on the given property and calls the decorated method\n * with the old and new values when it changes. In cases where the decorated method\n * needs to access uninitialized class fields, You may need to wait for the element to connect\n * before running your effects. In that case, you can optionally specify which\n * lifecycle state to wait for. e.g.:\n * - `waitFor: 'firstUpdate'` waits until the first update cycle has completed\n * - `waitFor: 'updated'` waits until the next update cycle has completed\n * - `waitFor: 'connected'` waits until the element connects\n * @param propertyName property to react to\n * @param [options] options including lifecycle to wait on.\n */\nexport function observes<T extends ReactiveElement>(\n propertyName: string & keyof T,\n options?: Partial<Exclude<PropertyObserverOptions<T>, 'callback' | 'propertyName'>>,\n) {\n return function(proto: T, methodName: string): void {\n const callback = proto[methodName as keyof T] as ChangeCallback<T>;\n if (typeof callback !== 'function') {\n throw new Error('@observes must decorate a class method');\n }\n const klass = proto.constructor as typeof ReactiveElement;\n klass.addInitializer(instance => {\n instance.addController(new PropertyObserverController(instance as T, {\n ...options,\n propertyName,\n callback,\n }));\n });\n };\n}\n\n"]}
|
package/decorators/time.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tracks the time a method takes to complete using the [performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)
|
|
3
|
+
* @param tag - short string to identify the method name
|
|
3
4
|
*/
|
|
4
5
|
export declare function time(tag?: string): (_: unknown, key: string, descriptor: PropertyDescriptor) => void;
|
package/decorators/time.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tracks the time a method takes to complete using the [performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)
|
|
3
|
+
* @param tag - short string to identify the method name
|
|
3
4
|
*/
|
|
4
5
|
export function time(tag) {
|
|
5
6
|
return function (_, key, descriptor) {
|
|
@@ -11,17 +12,13 @@ export function time(tag) {
|
|
|
11
12
|
const TAG = tag ?? `${this.constructor.name}-${key}`;
|
|
12
13
|
const START_TAG = `start-${TAG}`;
|
|
13
14
|
const END_TAG = `end-${TAG}`;
|
|
14
|
-
|
|
15
|
-
performance.mark(START_TAG);
|
|
16
|
-
}
|
|
15
|
+
performance.mark(START_TAG);
|
|
17
16
|
const x = f.call(this, ...args);
|
|
18
17
|
const ret = () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.log(Array.from(performance.getEntriesByName(TAG)).pop());
|
|
24
|
-
}
|
|
18
|
+
performance.mark(END_TAG);
|
|
19
|
+
performance.measure(TAG, START_TAG, END_TAG);
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log(Array.from(performance.getEntriesByName(TAG)).pop());
|
|
25
22
|
return x;
|
|
26
23
|
};
|
|
27
24
|
if (x instanceof Promise) {
|
package/decorators/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["time.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["time.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,IAAI,CAA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API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)\n * @param tag - short string to identify the method name\n */\nexport function time(tag?: string) {\n return function(\n _: unknown,\n key: string,\n descriptor: PropertyDescriptor,\n ): void {\n const { value: f } = descriptor ?? {};\n\n if (!(typeof f === 'function')) {\n throw new Error('@time() may only decorate class methods');\n }\n\n descriptor.value = function(...args: any[]) {\n const TAG = tag ?? `${this.constructor.name}-${key}`;\n const START_TAG = `start-${TAG}`;\n const END_TAG = `end-${TAG}`;\n\n performance.mark(START_TAG);\n\n const x = f.call(this, ...args);\n\n const ret = () => {\n performance.mark(END_TAG);\n performance.measure(TAG, START_TAG, END_TAG);\n // eslint-disable-next-line no-console\n console.log(Array.from(performance.getEntriesByName(TAG)).pop());\n return x;\n };\n\n if (x instanceof Promise) {\n return x.then(ret);\n } else {\n return ret();\n }\n };\n };\n}\n"]}
|
package/decorators/trace.d.ts
CHANGED
package/decorators/trace.js
CHANGED
package/decorators/trace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["trace.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["trace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,OAAO,UACL,CAAU,EACV,GAAW,EACX,UAA8B;QAE9B,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC;QAChC,UAAU,CAAC,KAAK,GAAG,UAAS,GAAG,IAAW;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;YAEhC,MAAM,GAAG,GAAG,GAAG,EAAE;gBACf,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC3B,OAAO,CAAC,CAAC;YACX,CAAC,CAAC;YAEF,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC;gBACzB,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,EAAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Logs the result of a class method\n * @param tag log tag, prepended to outputs\n */\nexport function trace(tag?: string) {\n return function(\n _: unknown,\n key: string,\n descriptor: PropertyDescriptor,\n ): void {\n const { value: f } = descriptor;\n descriptor.value = function(...args: any[]) {\n const x = f.call(this, ...args);\n\n const ret = () => {\n // eslint-disable-next-line no-console\n console.log(tag ?? key, x);\n return x;\n };\n\n if (x instanceof Promise) {\n return x.then(ret);\n } else {\n return ret();\n }\n };\n };\n}\n"]}
|
package/decorators.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './decorators/bound.js';
|
|
|
2
2
|
export * from './decorators/cascades.js';
|
|
3
3
|
export * from './decorators/deprecation.js';
|
|
4
4
|
export * from './decorators/initializer.js';
|
|
5
|
+
export * from './decorators/listen.js';
|
|
5
6
|
export * from './decorators/observed.js';
|
|
7
|
+
export * from './decorators/observes.js';
|
|
6
8
|
export * from './decorators/time.js';
|
|
7
9
|
export * from './decorators/trace.js';
|
package/decorators.js
CHANGED
|
@@ -2,7 +2,9 @@ export * from './decorators/bound.js';
|
|
|
2
2
|
export * from './decorators/cascades.js';
|
|
3
3
|
export * from './decorators/deprecation.js';
|
|
4
4
|
export * from './decorators/initializer.js';
|
|
5
|
+
export * from './decorators/listen.js';
|
|
5
6
|
export * from './decorators/observed.js';
|
|
7
|
+
export * from './decorators/observes.js';
|
|
6
8
|
export * from './decorators/time.js';
|
|
7
9
|
export * from './decorators/trace.js';
|
|
8
10
|
//# sourceMappingURL=decorators.js.map
|
package/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["decorators.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './decorators/bound.js';\nexport * from './decorators/cascades.js';\nexport * from './decorators/deprecation.js';\nexport * from './decorators/initializer.js';\nexport * from './decorators/observed.js';\nexport * from './decorators/time.js';\nexport * from './decorators/trace.js';\n"]}
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["decorators.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './decorators/bound.js';\nexport * from './decorators/cascades.js';\nexport * from './decorators/deprecation.js';\nexport * from './decorators/initializer.js';\nexport * from './decorators/listen.js';\nexport * from './decorators/observed.js';\nexport * from './decorators/observes.js';\nexport * from './decorators/time.js';\nexport * from './decorators/trace.js';\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the two arrays are equivalent
|
|
3
|
+
* Arrays are equivalent when they are both empty, or when their lengths are equal and each of
|
|
4
|
+
* their members is equal (===) to the corresponding member in the other array.
|
|
5
|
+
* If either argument is not an array, the result will be strict equivalence (===)
|
|
6
|
+
* @param a first array
|
|
7
|
+
* @param b second array
|
|
8
|
+
*/
|
|
9
|
+
export declare function arraysAreEquivalent(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the two arrays are equivalent
|
|
3
|
+
* Arrays are equivalent when they are both empty, or when their lengths are equal and each of
|
|
4
|
+
* their members is equal (===) to the corresponding member in the other array.
|
|
5
|
+
* If either argument is not an array, the result will be strict equivalence (===)
|
|
6
|
+
* @param a first array
|
|
7
|
+
* @param b second array
|
|
8
|
+
*/
|
|
9
|
+
export function arraysAreEquivalent(a, b) {
|
|
10
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
11
|
+
return a === b;
|
|
12
|
+
}
|
|
13
|
+
else if (a.length !== b.length) { // lengths are different
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
else if (!a.length && !b.length) { // both are empty
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
else { // multi and length of both is equal
|
|
20
|
+
for (const [i, element] of a.entries()) {
|
|
21
|
+
if (element !== b[i]) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=arraysAreEquivalent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arraysAreEquivalent.js","sourceRoot":"","sources":["arraysAreEquivalent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAU,EAAE,CAAU;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;SAAM,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,wBAAwB;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,iBAAiB;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC,CAAC,oCAAoC;QAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACvC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * Whether the two arrays are equivalent\n * Arrays are equivalent when they are both empty, or when their lengths are equal and each of\n * their members is equal (===) to the corresponding member in the other array.\n * If either argument is not an array, the result will be strict equivalence (===)\n * @param a first array\n * @param b second array\n */\nexport function arraysAreEquivalent(a: unknown, b: unknown): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return a === b;\n } else if (a.length !== b.length) { // lengths are different\n return false;\n } else if (!a.length && !b.length) { // both are empty\n return true;\n } else { // multi and length of both is equal\n for (const [i, element] of a.entries()) {\n if (element !== b[i]) {\n return false;\n }\n }\n return true;\n }\n}\n"]}
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* Whether or not the container contains the node,
|
|
3
3
|
* and if not, whether the node is contained by any element
|
|
4
4
|
* slotted in to the container
|
|
5
|
+
* @param container haystack
|
|
6
|
+
* @param node needle
|
|
5
7
|
*/
|
|
6
8
|
export declare function containsDeep(container: Element, node: Node): boolean;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Whether or not the container contains the node,
|
|
3
3
|
* and if not, whether the node is contained by any element
|
|
4
4
|
* slotted in to the container
|
|
5
|
+
* @param container haystack
|
|
6
|
+
* @param node needle
|
|
5
7
|
*/
|
|
6
8
|
export function containsDeep(container, node) {
|
|
7
9
|
if (container.contains(node)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containsDeep.js","sourceRoot":"","sources":["containsDeep.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"containsDeep.js","sourceRoot":"","sources":["containsDeep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAkB,EAClB,IAAU;IAEV,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5D,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC;gBACzC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtB,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["/**\n * Whether or not the container contains the node,\n * and if not, whether the node is contained by any element\n * slotted in to the container\n * @param container haystack\n * @param node needle\n */\nexport function containsDeep(\n container: Element,\n node: Node,\n): boolean {\n if (container.contains(node)) {\n return true;\n } else {\n for (const slot of container.querySelectorAll('slot') ?? []) {\n for (const el of slot.assignedElements()) {\n if (el.contains(node)) {\n return true;\n }\n }\n }\n return false;\n }\n}\n"]}
|
package/functions/context.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { createContext } from '@lit/context';
|
|
1
|
+
import { createContext, type Context } from '@lit/context';
|
|
2
2
|
/**
|
|
3
3
|
* In order to prevent late-upgrading-context-consumers from 'missing'
|
|
4
4
|
* their rightful context providers, we must set up a `ContextRoot` on the body.
|
|
5
5
|
* Always use this function when creating contexts that are shared with child elements.
|
|
6
|
+
* @param args createContext args
|
|
6
7
|
*/
|
|
7
|
-
export declare function createContextWithRoot<T>(...args: Parameters<typeof createContext>):
|
|
8
|
-
__context__: T;
|
|
9
|
-
};
|
|
8
|
+
export declare function createContextWithRoot<T>(...args: Parameters<typeof createContext>): Context<unknown, T>;
|