@fluid-topics/ft-wc-utils 0.3.71 → 1.0.0-alpha.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.
Files changed (43) hide show
  1. package/build/CacheRegistry.d.ts +1 -2
  2. package/build/CacheRegistry.js +0 -1
  3. package/build/CancelablePromise.d.ts +0 -1
  4. package/build/CancelablePromise.js +0 -1
  5. package/build/Debouncer.d.ts +0 -1
  6. package/build/Debouncer.js +0 -1
  7. package/build/FtCssVariables.d.ts +3 -4
  8. package/build/FtCssVariables.js +0 -1
  9. package/build/FtLitElement.d.ts +9 -17
  10. package/build/FtLitElement.js +21 -42
  11. package/build/ParametrizedLabelResolver.d.ts +1 -2
  12. package/build/ParametrizedLabelResolver.js +1 -2
  13. package/build/ScopedRegistryLitElement.d.ts +22 -0
  14. package/build/ScopedRegistryLitElement.js +23 -0
  15. package/build/decorators.d.ts +0 -1
  16. package/build/decorators.js +0 -1
  17. package/build/deep-equal.d.ts +0 -1
  18. package/build/deep-equal.js +0 -1
  19. package/build/delay.d.ts +0 -1
  20. package/build/delay.js +0 -1
  21. package/build/designSystemVariables.d.ts +0 -1
  22. package/build/designSystemVariables.js +0 -1
  23. package/build/events.d.ts +1 -2
  24. package/build/events.js +0 -1
  25. package/build/generic-types.d.ts +2 -2
  26. package/build/generic-types.js +0 -1
  27. package/build/globals.d.ts +0 -1
  28. package/build/globals.js +0 -1
  29. package/build/globals.min.js +23 -33
  30. package/build/index.d.ts +1 -2
  31. package/build/index.js +1 -1
  32. package/build/mixins.d.ts +0 -1
  33. package/build/mixins.js +0 -1
  34. package/build/redux.d.ts +16 -22
  35. package/build/redux.js +55 -90
  36. package/build/revivers.d.ts +0 -1
  37. package/build/revivers.js +0 -1
  38. package/build/rollup-globals.d.ts +0 -1
  39. package/build/rollup-globals.js +0 -1
  40. package/build/silent-define.d.ts +0 -1
  41. package/build/silent-define.js +0 -1
  42. package/build/silent-define.min.js +1 -1
  43. package/package.json +4 -5
package/build/redux.d.ts CHANGED
@@ -1,30 +1,27 @@
1
1
  import { FtLitElement } from "./FtLitElement";
2
2
  import { Action, AnyAction, CaseReducerActions, CreateSliceOptions, Dispatch, Observable, Reducer, Slice, SliceCaseReducers, Store, Unsubscribe } from "@reduxjs/toolkit";
3
3
  import { Optional } from "./generic-types";
4
- export declare type ReduxSelector<T, U extends FtLitElementRedux> = (rootState: T, element: U) => unknown;
5
- interface ReduxProperty<T, U extends FtLitElementRedux> {
6
- selector: ReduxSelector<T, U>;
4
+ import { PropertyDeclaration } from "lit";
5
+ export type ReduxSelector<State, Element extends FtLitElementRedux> = (rootState: State, element: Element) => unknown;
6
+ interface ReduxProperty<State, Element extends FtLitElementRedux> {
7
7
  store?: string;
8
+ selector: ReduxSelector<State, Element>;
8
9
  }
9
- export interface ReduxPropertyInit<T, U extends FtLitElementRedux> {
10
+ export interface ReduxPropertyInit<State, Element extends FtLitElementRedux> extends PropertyDeclaration {
10
11
  store?: string;
11
- selector?: ReduxSelector<T, U>;
12
- hasChanged?: (value: U, oldValue: U) => boolean;
13
- attribute?: string | boolean;
12
+ selector?: ReduxSelector<State, Element>;
14
13
  }
15
- export declare const redux: <T, U extends FtLitElementRedux>(selectorOrInit?: ReduxSelector<T, U> | ReduxPropertyInit<T, U> | undefined, hasChanged?: ((value: U, oldValue: U) => boolean) | undefined) => (proto: Object, name: string) => void;
14
+ export declare const redux: <State, Element_1 extends FtLitElementRedux>(propertyInit?: ReduxPropertyInit<State, Element_1> | undefined) => (proto: Object, name: string) => void;
15
+ declare const internalStoresUnsubscribers: unique symbol;
16
+ declare const internalStores: unique symbol;
16
17
  export declare class FtLitElementRedux extends FtLitElement {
17
18
  reduxProperties?: Map<string, ReduxProperty<unknown, FtLitElementRedux>>;
18
- private readonly internalStoresUnsubscribers;
19
- private readonly internalStores;
19
+ private readonly [internalStoresUnsubscribers];
20
+ private readonly [internalStores];
20
21
  private getUnnamedStore;
21
- /**@deprecated*/
22
- get store(): any;
23
- /**@deprecated*/
24
- protected set store(store: Optional<Store>);
25
- getStore<ReturnType = Optional<Store>>(name?: string): ReturnType;
26
- protected addStore(store: Store, name?: string): void;
27
- protected removeStore(storeOrName: Store | string): void;
22
+ getStore<ReturnType = Optional<FtReduxStore>>(name?: string): ReturnType;
23
+ protected addStore(store: FtReduxStore, name?: string): void;
24
+ protected removeStore(storeOrName: FtReduxStore | string): void;
28
25
  private setupStore;
29
26
  private setupStores;
30
27
  private updateFromStores;
@@ -52,16 +49,13 @@ export declare class FtReduxStore<State = any, CR extends SliceCaseReducers<Stat
52
49
  getState(): State;
53
50
  replaceReducer(nextReducer: Reducer<State, A>): void;
54
51
  subscribe(listener: () => void): Unsubscribe;
55
- actions: CaseReducerActions<CR>;
52
+ actions: CaseReducerActions<CR, string>;
56
53
  get name(): string;
57
- get reducer(): Reducer<State, AnyAction>;
54
+ get reducer(): Reducer<State>;
58
55
  get caseReducers(): { [Type in keyof CR]: CR[Type] extends {
59
56
  reducer: infer Reducer_1;
60
57
  } ? Reducer_1 : CR[Type]; };
61
58
  getInitialState(): State;
62
59
  }
63
- /**@deprecated Use FtReduxStore.get instead*/
64
- export declare function getStore(slice: Slice, name?: string): Store;
65
60
  export declare function clearAllStores(): void;
66
61
  export {};
67
- //# sourceMappingURL=redux.d.ts.map
package/build/redux.js CHANGED
@@ -1,84 +1,64 @@
1
+ var _a, _b;
1
2
  import { FtLitElement } from "./FtLitElement";
2
3
  import { configureStore, createSlice } from "@reduxjs/toolkit";
3
4
  import { deepEqual } from "./deep-equal";
4
- const isReduxPropertyInit = (o) => {
5
- return typeof o === "object" && (Object.keys(o).length === 0
6
- || typeof o.store === "string"
7
- || o.selector != null
8
- || typeof o.hasChanged === "function"
9
- || o.attribute != null);
10
- };
11
- export const redux = (// TODO next major version: Remove compat
12
- selectorOrInit, hasChanged) => {
13
- var _a;
14
- const init = isReduxPropertyInit(selectorOrInit) ? selectorOrInit : {};
15
- hasChanged = (_a = hasChanged !== null && hasChanged !== void 0 ? hasChanged : init.hasChanged) !== null && _a !== void 0 ? _a : ((a, b) => !deepEqual(a, b));
5
+ import { property } from "lit/decorators.js";
6
+ export const redux = (propertyInit) => {
7
+ const init = propertyInit !== null && propertyInit !== void 0 ? propertyInit : {};
16
8
  return (proto, name) => {
17
- var _a, _b;
18
- proto.constructor.createProperty(name, {
19
- hasChanged,
20
- attribute: (_a = init.attribute) !== null && _a !== void 0 ? _a : false
21
- });
9
+ var _c;
10
+ const litPropertyInit = {
11
+ hasChanged: ((a, b) => !deepEqual(a, b)),
12
+ attribute: false,
13
+ ...init
14
+ };
15
+ property(litPropertyInit)(proto, name);
22
16
  const reduxProto = proto;
23
17
  reduxProto.reduxProperties = reduxProto.reduxProperties || new Map();
24
- const selector = (_b = (isReduxPropertyInit(selectorOrInit) ? init.selector : selectorOrInit)) !== null && _b !== void 0 ? _b : (s => s[name]);
25
- reduxProto.reduxProperties.set(name, { selector, store: init.store });
18
+ reduxProto.reduxProperties.set(name, {
19
+ selector: (_c = init.selector) !== null && _c !== void 0 ? _c : ((s) => s[name]),
20
+ store: init.store
21
+ });
26
22
  };
27
23
  };
24
+ const internalStoresUnsubscribers = Symbol("internalStoresUnsubscribers");
25
+ const internalStores = Symbol("internalStores");
28
26
  export class FtLitElementRedux extends FtLitElement {
29
27
  constructor() {
30
28
  super(...arguments);
31
- this.internalStoresUnsubscribers = new Map();
32
- this.internalStores = new Map();
29
+ this[_a] = new Map();
30
+ this[_b] = new Map();
33
31
  }
34
32
  getUnnamedStore() {
35
- if (this.internalStores.size > 1) {
33
+ if (this[internalStores].size > 1) {
36
34
  throw new Error("Cannot resolve unnamed store when multiple stores are configured.");
37
35
  }
38
- return [...this.internalStores.values()][0];
39
- }
40
- /**@deprecated*/
41
- get store() {
42
- return this.getUnnamedStore(); // Compatibility with use of setter and getter without override TODO next major version: Remove compat
43
- }
44
- /**@deprecated*/
45
- set store(store) {
46
- this.unsubscribeFromStores();
47
- this.internalStores.clear();
48
- if (store) {
49
- this.addStore(store);
50
- }
36
+ return [...this[internalStores].values()][0];
51
37
  }
52
38
  getStore(name) {
53
- var _a;
54
39
  return (name == null
55
- ? ((_a = this.getUnnamedStore()) !== null && _a !== void 0 ? _a : this.store) // Compatibility with getter override TODO next major version: Remove compat
56
- : this.internalStores.get(name));
40
+ ? this.getUnnamedStore()
41
+ : this[internalStores].get(name));
57
42
  }
58
43
  addStore(store, name) {
59
- name = name !== null && name !== void 0 ? name : (isFtReduxStore(store) ? store.name : "ft-lit-element-redux-default-store");
44
+ name = name !== null && name !== void 0 ? name : store.name;
60
45
  this.unsubscribeFromStore(name);
61
46
  this.setupStore(name, store);
62
47
  }
63
48
  removeStore(storeOrName) {
64
- const name = typeof storeOrName === "string" ? storeOrName : (isFtReduxStore(storeOrName) ? storeOrName.name : "ft-lit-element-redux-default-store");
49
+ const name = typeof storeOrName === "string" ? storeOrName : storeOrName.name;
65
50
  this.unsubscribeFromStore(name);
66
- this.internalStores.delete(name);
51
+ this[internalStores].delete(name);
67
52
  }
68
53
  setupStore(name, store) {
69
- this.internalStores.set(name, store);
70
- this.updateFromStores();
54
+ this[internalStores].set(name, store);
71
55
  this.subscribeToStore(name, store);
56
+ this.updateFromStores();
72
57
  }
73
58
  setupStores() {
74
59
  this.unsubscribeFromStores();
75
- if (this.internalStores.size === 0 && this.store != null) { // Compatibility with getter override TODO next major version: Remove compat
76
- this.addStore(this.store);
77
- }
78
- else {
79
- this.updateFromStores();
80
- this.internalStores.forEach((store, name) => this.subscribeToStore(name, store));
81
- }
60
+ this[internalStores].forEach((store, name) => this.subscribeToStore(name, store));
61
+ this.updateFromStores();
82
62
  }
83
63
  updateFromStores() {
84
64
  if (this.reduxProperties) {
@@ -94,17 +74,17 @@ export class FtLitElementRedux extends FtLitElement {
94
74
  }
95
75
  }
96
76
  subscribeToStore(name, store) {
97
- this.internalStoresUnsubscribers.set(name, store.subscribe(() => this.updateFromStores()));
77
+ this[internalStoresUnsubscribers].set(name, store.subscribe(() => this.updateFromStores()));
98
78
  this.onStoreAvailable(name);
99
79
  }
100
80
  unsubscribeFromStores() {
101
- Object.keys(this.internalStoresUnsubscribers).forEach(key => this.unsubscribeFromStore(key));
81
+ Object.keys(this[internalStoresUnsubscribers]).forEach(key => this.unsubscribeFromStore(key));
102
82
  }
103
83
  unsubscribeFromStore(name) {
104
- if (this.internalStoresUnsubscribers.has(name)) {
105
- this.internalStoresUnsubscribers.get(name)();
84
+ if (this[internalStoresUnsubscribers].has(name)) {
85
+ this[internalStoresUnsubscribers].get(name)();
106
86
  }
107
- this.internalStoresUnsubscribers.delete(name);
87
+ this[internalStoresUnsubscribers].delete(name);
108
88
  }
109
89
  onStoreAvailable(name) {
110
90
  }
@@ -117,11 +97,29 @@ export class FtLitElementRedux extends FtLitElement {
117
97
  super.disconnectedCallback();
118
98
  }
119
99
  }
100
+ _a = internalStoresUnsubscribers, _b = internalStores;
120
101
  function isFtReduxStore(o) {
121
- var _a;
122
- return (_a = o) === null || _a === void 0 ? void 0 : _a.isFtReduxStore;
102
+ var _c;
103
+ return (_c = o === null || o === void 0 ? void 0 : o.isFtReduxStore) !== null && _c !== void 0 ? _c : false;
123
104
  }
124
105
  export class FtReduxStore {
106
+ static get(nameOrOptions) {
107
+ if (!window.ftReduxStores) {
108
+ window.ftReduxStores = {};
109
+ }
110
+ const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions.name;
111
+ const options = typeof nameOrOptions === "string" ? undefined : nameOrOptions;
112
+ const maybeExistingStore = window.ftReduxStores[name];
113
+ if (isFtReduxStore(maybeExistingStore)) {
114
+ return maybeExistingStore;
115
+ }
116
+ if (options == null) {
117
+ return undefined;
118
+ }
119
+ const reduxSlice = createSlice(options);
120
+ const reduxStore = configureStore({ reducer: reduxSlice.reducer });
121
+ return window.ftReduxStores[options.name] = new FtReduxStore(reduxSlice, reduxStore);
122
+ }
125
123
  constructor(reduxSlice, reduxStore) {
126
124
  this.reduxSlice = reduxSlice;
127
125
  this.reduxStore = reduxStore;
@@ -141,26 +139,6 @@ export class FtReduxStore {
141
139
  }
142
140
  });
143
141
  }
144
- static get(nameOrOptions) {
145
- if (!window.ftReduxStores) {
146
- window.ftReduxStores = {};
147
- }
148
- const name = typeof nameOrOptions === "string" ? nameOrOptions : nameOrOptions.name;
149
- const options = typeof nameOrOptions === "string" ? undefined : nameOrOptions;
150
- const maybeExistingStore = window.ftReduxStores[name];
151
- if (isFtReduxStore(maybeExistingStore)) {
152
- return maybeExistingStore;
153
- }
154
- if (options == null) {
155
- return undefined;
156
- }
157
- const reduxSlice = createSlice(options);
158
- if (maybeExistingStore) { // TODO next major version: Remove compat
159
- return new FtReduxStore(reduxSlice, maybeExistingStore);
160
- }
161
- const reduxStore = configureStore({ reducer: reduxSlice.reducer });
162
- return window.ftReduxStores[options.name] = new FtReduxStore(reduxSlice, reduxStore);
163
- }
164
142
  // Implement Store
165
143
  get dispatch() {
166
144
  throw new Error("Don't use this method, actions are automatically dispatched when called.");
@@ -190,19 +168,6 @@ export class FtReduxStore {
190
168
  return this.reduxSlice.getInitialState();
191
169
  }
192
170
  }
193
- // TODO next major version: Remove this
194
- /**@deprecated Use FtReduxStore.get instead*/
195
- export function getStore(slice, name) {
196
- if (!window.ftReduxStores) {
197
- window.ftReduxStores = {};
198
- }
199
- const storeName = name || slice.name;
200
- if (!window.ftReduxStores[storeName]) {
201
- window.ftReduxStores[storeName] = configureStore({ reducer: slice.reducer });
202
- }
203
- return window.ftReduxStores[storeName];
204
- }
205
171
  export function clearAllStores() {
206
172
  window.ftReduxStores = {};
207
173
  }
208
- //# sourceMappingURL=redux.js.map
@@ -1,3 +1,2 @@
1
1
  export declare function dateReviver(...dateKeys: string[]): (key: string, value: any) => any;
2
2
  export declare function parseDate(value: string): Date;
3
- //# sourceMappingURL=revivers.d.ts.map
package/build/revivers.js CHANGED
@@ -15,4 +15,3 @@ export function parseDate(value) {
15
15
  .replace(/^(.+)(\+\d{2})(\d{2})$/, (s, date, h, m) => date + h + ":" + m);
16
16
  return new Date(value);
17
17
  }
18
- //# sourceMappingURL=revivers.js.map
@@ -7,4 +7,3 @@ export declare const rollupGlobals: {
7
7
  "lit/directives/unsafe-html.js": string;
8
8
  "@fluid-topics/ft-wc-utils": string;
9
9
  };
10
- //# sourceMappingURL=rollup-globals.d.ts.map
@@ -7,4 +7,3 @@ export const rollupGlobals = {
7
7
  "lit/directives/unsafe-html.js": "ftGlobals.litUnsafeHTML",
8
8
  "@fluid-topics/ft-wc-utils": "ftGlobals.wcUtils"
9
9
  };
10
- //# sourceMappingURL=rollup-globals.js.map
@@ -1,2 +1 @@
1
1
  import "../lib/scoped-custom-element-registry.js";
2
- //# sourceMappingURL=silent-define.d.ts.map
@@ -15,4 +15,3 @@ catch (e) {
15
15
  }
16
16
  };
17
17
  }
18
- //# sourceMappingURL=silent-define.js.map
@@ -14,4 +14,4 @@
14
14
  *
15
15
  * @see https://github.com/webcomponents/polyfills/tree/master/packages/scoped-custom-element-registry
16
16
  */
17
- if(!ShadowRoot.prototype.createElement){const t=window.HTMLElement,e=window.customElements.define,n=window.customElements.get,s=window.customElements,o=new WeakMap,i=new WeakMap,c=new WeakMap,r=new WeakMap;let a;window.CustomElementRegistry=class{constructor(){this._definitionsByTag=new Map,this._definitionsByClass=new Map,this._whenDefinedPromises=new Map,this._awaitingUpgrade=new Map}define(t,o){if(t=t.toLowerCase(),void 0!==this._getDefinition(t))throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);if(void 0!==this._definitionsByClass.get(o))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");const r=o.prototype.attributeChangedCallback,a=new Set(o.observedAttributes||[]);w(o,a,r);const l={elementClass:o,connectedCallback:o.prototype.connectedCallback,disconnectedCallback:o.prototype.disconnectedCallback,adoptedCallback:o.prototype.adoptedCallback,attributeChangedCallback:r,formAssociated:o.formAssociated,formAssociatedCallback:o.prototype.formAssociatedCallback,formDisabledCallback:o.prototype.formDisabledCallback,formResetCallback:o.prototype.formResetCallback,formStateRestoreCallback:o.prototype.formStateRestoreCallback,observedAttributes:a};this._definitionsByTag.set(t,l),this._definitionsByClass.set(o,l);let h=n.call(s,t);h||(h=d(t),e.call(s,t,h)),this===window.customElements&&(c.set(o,l),l.standInClass=h);const u=this._awaitingUpgrade.get(t);if(u){this._awaitingUpgrade.delete(t);for(const t of u)i.delete(t),m(t,l,!0)}const f=this._whenDefinedPromises.get(t);return void 0!==f&&(f.resolve(o),this._whenDefinedPromises.delete(t)),o}upgrade(){b.push(this),s.upgrade.apply(s,arguments),b.pop()}get(t){return this._definitionsByTag.get(t)?.elementClass}_getDefinition(t){return this._definitionsByTag.get(t)}whenDefined(t){const e=this._getDefinition(t);if(void 0!==e)return Promise.resolve(e.elementClass);let n=this._whenDefinedPromises.get(t);return void 0===n&&(n={},n.promise=new Promise((t=>n.resolve=t)),this._whenDefinedPromises.set(t,n)),n.promise}_upgradeWhenDefined(t,e,n){let s=this._awaitingUpgrade.get(e);s||this._awaitingUpgrade.set(e,s=new Set),n?s.add(t):s.delete(t)}},window.HTMLElement=function(){let e=a;if(e)return a=void 0,e;const n=c.get(this.constructor);if(!n)throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)");return e=Reflect.construct(t,[],n.standInClass),Object.setPrototypeOf(e,this.constructor.prototype),o.set(e,n),e},window.HTMLElement.prototype=t.prototype;const l=t=>t===document||t instanceof ShadowRoot,h=t=>{let e=t.getRootNode();if(!l(e)){const t=b[b.length-1];if(t instanceof CustomElementRegistry)return t;e=t.getRootNode(),l(e)||(e=r.get(e)?.getRootNode()||document)}return e.customElements},d=e=>class{static get formAssociated(){return!0}constructor(){const n=Reflect.construct(t,[],this.constructor);Object.setPrototypeOf(n,HTMLElement.prototype);const s=h(n)||window.customElements,o=s._getDefinition(e);return o?m(n,o):i.set(n,s),n}connectedCallback(){const t=o.get(this);t?t.connectedCallback&&t.connectedCallback.apply(this,arguments):i.get(this)._upgradeWhenDefined(this,e,!0)}disconnectedCallback(){const t=o.get(this);t?t.disconnectedCallback&&t.disconnectedCallback.apply(this,arguments):i.get(this)._upgradeWhenDefined(this,e,!1)}adoptedCallback(){o.get(this)?.adoptedCallback?.apply(this,arguments)}formAssociatedCallback(){const t=o.get(this);t&&t.formAssociated&&t?.formAssociatedCallback?.apply(this,arguments)}formDisabledCallback(){const t=o.get(this);t?.formAssociated&&t?.formDisabledCallback?.apply(this,arguments)}formResetCallback(){const t=o.get(this);t?.formAssociated&&t?.formResetCallback?.apply(this,arguments)}formStateRestoreCallback(){const t=o.get(this);t?.formAssociated&&t?.formStateRestoreCallback?.apply(this,arguments)}},w=(t,e,n)=>{if(0===e.size||void 0===n)return;const s=t.prototype.setAttribute;s&&(t.prototype.setAttribute=function(t,o){const i=t.toLowerCase();if(e.has(i)){const t=this.getAttribute(i);s.call(this,i,o),n.call(this,i,t,o)}else s.call(this,i,o)});const o=t.prototype.removeAttribute;o&&(t.prototype.removeAttribute=function(t){const s=t.toLowerCase();if(e.has(s)){const t=this.getAttribute(s);o.call(this,s),n.call(this,s,t,null)}else o.call(this,s)})},u=e=>{const n=Object.getPrototypeOf(e);if(n!==window.HTMLElement)return n===t||"HTMLElement"===n?.prototype?.constructor?.name?Object.setPrototypeOf(e,window.HTMLElement):u(n)},m=(t,e,n=!1)=>{Object.setPrototypeOf(t,e.elementClass.prototype),o.set(t,e),a=t;try{new e.elementClass}catch(t){u(e.elementClass),new e.elementClass}e.observedAttributes.forEach((n=>{t.hasAttribute(n)&&e.attributeChangedCallback.call(t,n,null,t.getAttribute(n))})),n&&e.connectedCallback&&t.isConnected&&e.connectedCallback.call(t)},f=Element.prototype.attachShadow;Element.prototype.attachShadow=function(t){const e=f.apply(this,arguments);return t.customElements&&(e.customElements=t.customElements),e};let b=[document];const E=(t,e,n)=>{const s=(n?Object.getPrototypeOf(n):t.prototype)[e];t.prototype[e]=function(){b.push(this);const t=s.apply(n||this,arguments);return void 0!==t&&r.set(t,this),b.pop(),t}};E(ShadowRoot,"createElement",document),E(ShadowRoot,"importNode",document),E(Element,"insertAdjacentHTML");const M=(t,e)=>{const n=Object.getOwnPropertyDescriptor(t.prototype,e);Object.defineProperty(t.prototype,e,{...n,set(t){b.push(this),n.set.call(this,t),b.pop()}})};if(M(Element,"innerHTML"),M(ShadowRoot,"innerHTML"),Object.defineProperty(window,"customElements",{value:new CustomElementRegistry,configurable:!0,writable:!0}),window.ElementInternals&&window.ElementInternals.prototype.setFormValue){const t=new WeakMap,e=HTMLElement.prototype.attachInternals,n=["setFormValue","setValidity","checkValidity","reportValidity"];HTMLElement.prototype.attachInternals=function(...n){const s=e.call(this,...n);return t.set(s,this),s},n.forEach((e=>{const n=window.ElementInternals.prototype,s=n[e];n[e]=function(...e){const n=t.get(this);if(!0!==o.get(n).formAssociated)throw new DOMException(`Failed to execute ${s} on 'ElementInternals': The target element is not a form-associated custom element.`);s?.call(this,...e)}}));class s extends Array{constructor(t){super(...t),this._elements=t}get value(){return this._elements.find((t=>!0===t.checked))?.value||""}}class i{constructor(t){const e=new Map;t.forEach(((t,n)=>{const s=t.getAttribute("name"),o=e.get(s)||[];this[+n]=t,o.push(t),e.set(s,o)})),this.length=t.length,e.forEach(((t,e)=>{t&&(1===t.length?this[e]=t[0]:this[e]=new s(t))}))}namedItem(t){return this[t]}}const c=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"elements");Object.defineProperty(HTMLFormElement.prototype,"elements",{get:function(){const t=c.get.call(this,[]),e=[];for(const n of t){const t=o.get(n);t&&!0!==t.formAssociated||e.push(n)}return new i(e)}})}}try{window.customElements.define("custom-element",null)}catch(t){const e=window.customElements.define;window.customElements.define=(t,n,s)=>{try{e.bind(window.customElements)(t,n,s)}catch(e){console.info(t,n,s,e)}}}}();
17
+ if(!ShadowRoot.prototype.createElement){const t=window.HTMLElement,e=window.customElements.define,n=window.customElements.get,s=window.customElements,o=new WeakMap,i=new WeakMap,c=new WeakMap,r=new WeakMap;let a;window.CustomElementRegistry=class{constructor(){this._definitionsByTag=new Map,this._definitionsByClass=new Map,this._whenDefinedPromises=new Map,this._awaitingUpgrade=new Map}define(t,o){if(t=t.toLowerCase(),void 0!==this._getDefinition(t))throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);if(void 0!==this._definitionsByClass.get(o))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");const r=o.prototype.attributeChangedCallback,a=new Set(o.observedAttributes||[]);w(o,a,r);const l={elementClass:o,connectedCallback:o.prototype.connectedCallback,disconnectedCallback:o.prototype.disconnectedCallback,adoptedCallback:o.prototype.adoptedCallback,attributeChangedCallback:r,formAssociated:o.formAssociated,formAssociatedCallback:o.prototype.formAssociatedCallback,formDisabledCallback:o.prototype.formDisabledCallback,formResetCallback:o.prototype.formResetCallback,formStateRestoreCallback:o.prototype.formStateRestoreCallback,observedAttributes:a};this._definitionsByTag.set(t,l),this._definitionsByClass.set(o,l);let h=n.call(s,t);h||(h=d(t),e.call(s,t,h)),this===window.customElements&&(c.set(o,l),l.standInClass=h);const u=this._awaitingUpgrade.get(t);if(u){this._awaitingUpgrade.delete(t);for(const t of u)i.delete(t),m(t,l,!0)}const f=this._whenDefinedPromises.get(t);return void 0!==f&&(f.resolve(o),this._whenDefinedPromises.delete(t)),o}upgrade(){b.push(this),s.upgrade.apply(s,arguments),b.pop()}get(t){const e=this._definitionsByTag.get(t);return e?.elementClass}_getDefinition(t){return this._definitionsByTag.get(t)}whenDefined(t){const e=this._getDefinition(t);if(void 0!==e)return Promise.resolve(e.elementClass);let n=this._whenDefinedPromises.get(t);return void 0===n&&(n={},n.promise=new Promise((t=>n.resolve=t)),this._whenDefinedPromises.set(t,n)),n.promise}_upgradeWhenDefined(t,e,n){let s=this._awaitingUpgrade.get(e);s||this._awaitingUpgrade.set(e,s=new Set),n?s.add(t):s.delete(t)}},window.HTMLElement=function(){let e=a;if(e)return a=void 0,e;const n=c.get(this.constructor);if(!n)throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)");return e=Reflect.construct(t,[],n.standInClass),Object.setPrototypeOf(e,this.constructor.prototype),o.set(e,n),e},window.HTMLElement.prototype=t.prototype;const l=t=>t===document||t instanceof ShadowRoot,h=t=>{let e=t.getRootNode();if(!l(e)){const t=b[b.length-1];if(t instanceof CustomElementRegistry)return t;e=t.getRootNode(),l(e)||(e=r.get(e)?.getRootNode()||document)}return e.customElements},d=e=>class{static get formAssociated(){return!0}constructor(){const n=Reflect.construct(t,[],this.constructor);Object.setPrototypeOf(n,HTMLElement.prototype);const s=h(n)||window.customElements,o=s._getDefinition(e);return o?m(n,o):i.set(n,s),n}connectedCallback(){const t=o.get(this);t?t.connectedCallback&&t.connectedCallback.apply(this,arguments):i.get(this)._upgradeWhenDefined(this,e,!0)}disconnectedCallback(){const t=o.get(this);t?t.disconnectedCallback&&t.disconnectedCallback.apply(this,arguments):i.get(this)._upgradeWhenDefined(this,e,!1)}adoptedCallback(){const t=o.get(this);t?.adoptedCallback?.apply(this,arguments)}formAssociatedCallback(){const t=o.get(this);t&&t.formAssociated&&t?.formAssociatedCallback?.apply(this,arguments)}formDisabledCallback(){const t=o.get(this);t?.formAssociated&&t?.formDisabledCallback?.apply(this,arguments)}formResetCallback(){const t=o.get(this);t?.formAssociated&&t?.formResetCallback?.apply(this,arguments)}formStateRestoreCallback(){const t=o.get(this);t?.formAssociated&&t?.formStateRestoreCallback?.apply(this,arguments)}},w=(t,e,n)=>{if(0===e.size||void 0===n)return;const s=t.prototype.setAttribute;s&&(t.prototype.setAttribute=function(t,o){const i=t.toLowerCase();if(e.has(i)){const t=this.getAttribute(i);s.call(this,i,o),n.call(this,i,t,o)}else s.call(this,i,o)});const o=t.prototype.removeAttribute;o&&(t.prototype.removeAttribute=function(t){const s=t.toLowerCase();if(e.has(s)){const t=this.getAttribute(s);o.call(this,s),n.call(this,s,t,null)}else o.call(this,s)})},u=e=>{const n=Object.getPrototypeOf(e);if(n!==window.HTMLElement)return n===t||"HTMLElement"===n?.prototype?.constructor?.name?Object.setPrototypeOf(e,window.HTMLElement):u(n)},m=(t,e,n=!1)=>{Object.setPrototypeOf(t,e.elementClass.prototype),o.set(t,e),a=t;try{new e.elementClass}catch(t){u(e.elementClass),new e.elementClass}e.observedAttributes.forEach((n=>{t.hasAttribute(n)&&e.attributeChangedCallback.call(t,n,null,t.getAttribute(n))})),n&&e.connectedCallback&&t.isConnected&&e.connectedCallback.call(t)},f=Element.prototype.attachShadow;Element.prototype.attachShadow=function(t){const e=f.apply(this,arguments);return t.customElements&&(e.customElements=t.customElements),e};let b=[document];const E=(t,e,n=void 0)=>{const s=(n?Object.getPrototypeOf(n):t.prototype)[e];t.prototype[e]=function(){b.push(this);const t=s.apply(n||this,arguments);return void 0!==t&&r.set(t,this),b.pop(),t}};E(ShadowRoot,"createElement",document),E(ShadowRoot,"importNode",document),E(Element,"insertAdjacentHTML");const M=(t,e)=>{const n=Object.getOwnPropertyDescriptor(t.prototype,e);Object.defineProperty(t.prototype,e,{...n,set(t){b.push(this),n.set.call(this,t),b.pop()}})};if(M(Element,"innerHTML"),M(ShadowRoot,"innerHTML"),Object.defineProperty(window,"customElements",{value:new CustomElementRegistry,configurable:!0,writable:!0}),window.ElementInternals&&window.ElementInternals.prototype.setFormValue){const t=new WeakMap,e=HTMLElement.prototype.attachInternals,n=["setFormValue","setValidity","checkValidity","reportValidity"];HTMLElement.prototype.attachInternals=function(...n){const s=e.call(this,...n);return t.set(s,this),s},n.forEach((e=>{const n=window.ElementInternals.prototype,s=n[e];n[e]=function(...e){const n=t.get(this);if(!0!==o.get(n).formAssociated)throw new DOMException(`Failed to execute ${s} on 'ElementInternals': The target element is not a form-associated custom element.`);s?.call(this,...e)}}));class s extends Array{constructor(t){super(...t),this._elements=t}get value(){return this._elements.find((t=>!0===t.checked))?.value||""}}class i{constructor(t){const e=new Map;t.forEach(((t,n)=>{const s=t.getAttribute("name"),o=e.get(s)||[];this[+n]=t,o.push(t),e.set(s,o)})),this.length=t.length,e.forEach(((t,e)=>{t&&(1===t.length?this[e]=t[0]:this[e]=new s(t))}))}namedItem(t){return this[t]}}const c=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"elements");Object.defineProperty(HTMLFormElement.prototype,"elements",{get:function(){const t=c.get.call(this,[]),e=[];for(const n of t){const t=o.get(n);t&&!0!==t.formAssociated||e.push(n)}return new i(e)}})}}try{window.customElements.define("custom-element",null)}catch(t){const e=window.customElements.define;window.customElements.define=(t,n,s)=>{try{e.bind(window.customElements)(t,n,s)}catch(e){console.info(t,n,s,e)}}}}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "0.3.71",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -13,9 +13,8 @@
13
13
  "lib/*"
14
14
  ],
15
15
  "dependencies": {
16
- "@lit-labs/scoped-registry-mixin": "1.0.1",
17
- "@reduxjs/toolkit": "^1.6.2",
18
- "lit": "2.2.8"
16
+ "@reduxjs/toolkit": "1.9.5",
17
+ "lit": "2.7.2"
19
18
  },
20
- "gitHead": "aeaa883cc0e3596e6cc75d282aa99de3c603f6a2"
19
+ "gitHead": "bb54c217f788a915a443db6f496f02e176d05306"
21
20
  }