element-vir 26.14.4 → 26.14.5

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/README.md CHANGED
@@ -188,7 +188,9 @@ export const MyWithUpdateState = defineElement()({
188
188
  return html`
189
189
  <span
190
190
  ${listen('click', () => {
191
- updateState({username: 'new name!'});
191
+ updateState({
192
+ username: 'new name!',
193
+ });
192
194
  })}
193
195
  >
194
196
  Hello there ${state.username}!
@@ -278,7 +280,14 @@ export const MyWithEvents = defineElement()({
278
280
  <button ${listen('click', () => dispatch(new events.logoutClick()))}>log out</button>
279
281
  <button
280
282
  ${listen('click', () =>
281
- dispatch(new events.randomNumber(randomInteger({min: 0, max: 1_000_000}))),
283
+ dispatch(
284
+ new events.randomNumber(
285
+ randomInteger({
286
+ min: 0,
287
+ max: 1_000_000,
288
+ }),
289
+ ),
290
+ ),
282
291
  )}
283
292
  >
284
293
  generate random number
@@ -314,7 +323,9 @@ export const MyWithEventListening = defineElement()({
314
323
  console.info('logout triggered');
315
324
  })}
316
325
  ${listen(MyWithEvents.events.randomNumber, (event) => {
317
- updateState({myNumber: event.detail});
326
+ updateState({
327
+ myNumber: event.detail,
328
+ });
318
329
  })}
319
330
  ></${MyWithEvents}>
320
331
  <span>${state.myNumber}</span>
@@ -360,7 +371,14 @@ export const MyWithCustomEvents = defineElement()({
360
371
  >
361
372
  <div
362
373
  ${listen('click', () => {
363
- dispatch(new MyCustomActionEvent(randomInteger({min: 0, max: 1_000_000})));
374
+ dispatch(
375
+ new MyCustomActionEvent(
376
+ randomInteger({
377
+ min: 0,
378
+ max: 1_000_000,
379
+ }),
380
+ ),
381
+ );
364
382
  })}
365
383
  ></div>
366
384
  </div>
@@ -50,7 +50,10 @@ export type DeclarativeElementInit<TagName extends CustomElementTagName, Inputs
50
50
  state?: (params: Omit<RenderParams<TagName, Inputs, any, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>, 'state' | 'updateState'>) => Extract<keyof State, keyof HTMLElement> extends never ? Extract<keyof State, keyof Inputs> extends never ? State : `ERROR: Cannot define an element state property that clashes with input properties: ${Extract<keyof State, keyof Inputs> extends string | number | bigint | boolean | null | undefined ? Extract<keyof State, keyof Inputs> : ''}` : `ERROR: Cannot define an element state property that clashes with native HTMLElement properties: ${Extract<keyof State, keyof HTMLElement>}`;
51
51
  /** Called as part of the first render call, before the first render call. */
52
52
  init?: InitCallback<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds> | undefined;
53
+ /** Called whenever an element updates. This creates the element's HTML. */
53
54
  render: RenderCallback<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
55
+ /** Called whenever an element is detached from the DOM. */
54
56
  cleanup?: InitCallback<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds> | undefined;
57
+ /** Extra element definition options. */
55
58
  options?: Partial<DeclarativeElementDefinitionOptions> | undefined;
56
59
  };
@@ -85,7 +85,10 @@ function internalDefineElement(init) {
85
85
  const slotNamesMap = createStringNameMap(init.tagName, 'slot', init.slotNames);
86
86
  const testIdsMap = createStringNameMap(init.tagName, 'test-id', init.testIds);
87
87
  const calculatedStyles = typeof init.styles === 'function'
88
- ? init.styles(createStylesCallbackInput({ hostClassNames, cssVars }))
88
+ ? init.styles(createStylesCallbackInput({
89
+ hostClassNames,
90
+ cssVars,
91
+ }))
89
92
  : init.styles || css ``;
90
93
  const typedRenderCallback = init.render;
91
94
  function typedAssignCallback(...[inputs]) {
@@ -169,8 +172,12 @@ function internalDefineElement(init) {
169
172
  inputs: renderParams.inputs,
170
173
  });
171
174
  this._lastRenderedProps = {
172
- inputs: { ...renderParams.inputs },
173
- state: { ...renderParams.state },
175
+ inputs: {
176
+ ...renderParams.inputs,
177
+ },
178
+ state: {
179
+ ...renderParams.state,
180
+ },
174
181
  };
175
182
  return renderResult;
176
183
  }
@@ -29,7 +29,10 @@ export function applyHostClasses({ host, hostClassesInit, hostClassNames, state,
29
29
  const maybeCallback = hostClassesInit[hostClassKey];
30
30
  const hostClassName = hostClassNames[hostClassKey];
31
31
  if (typeof maybeCallback === 'function') {
32
- const shouldApplyHostClass = maybeCallback({ state, inputs });
32
+ const shouldApplyHostClass = maybeCallback({
33
+ state,
34
+ inputs,
35
+ });
33
36
  if (shouldApplyHostClass) {
34
37
  host.classList.add(hostClassName);
35
38
  }
@@ -13,7 +13,10 @@ export const MyWithCustomEvents = defineElement()({
13
13
  >
14
14
  <div
15
15
  ${listen('click', () => {
16
- dispatch(new MyCustomActionEvent(randomInteger({ min: 0, max: 1_000_000 })));
16
+ dispatch(new MyCustomActionEvent(randomInteger({
17
+ min: 0,
18
+ max: 1_000_000,
19
+ })));
17
20
  })}
18
21
  ></div>
19
22
  </div>
@@ -16,7 +16,9 @@ export const MyWithEventListening = defineElement()({
16
16
  console.info('logout triggered');
17
17
  })}
18
18
  ${listen(MyWithEvents.events.randomNumber, (event) => {
19
- updateState({ myNumber: event.detail });
19
+ updateState({
20
+ myNumber: event.detail,
21
+ });
20
22
  })}
21
23
  ></${MyWithEvents}>
22
24
  <span>${state.myNumber}</span>
@@ -11,7 +11,10 @@ export const MyWithEvents = defineElement()({
11
11
  return html `
12
12
  <button ${listen('click', () => dispatch(new events.logoutClick()))}>log out</button>
13
13
  <button
14
- ${listen('click', () => dispatch(new events.randomNumber(randomInteger({ min: 0, max: 1_000_000 }))))}
14
+ ${listen('click', () => dispatch(new events.randomNumber(randomInteger({
15
+ min: 0,
16
+ max: 1_000_000,
17
+ }))))}
15
18
  >
16
19
  generate random number
17
20
  </button>
@@ -16,7 +16,9 @@ export const MyWithUpdateState = defineElement()({
16
16
  return html `
17
17
  <span
18
18
  ${listen('click', () => {
19
- updateState({ username: 'new name!' });
19
+ updateState({
20
+ username: 'new name!',
21
+ });
20
22
  })}
21
23
  >
22
24
  Hello there ${state.username}!
@@ -39,13 +39,22 @@ export function setMappedTemplate(templateStringsKey, values, valueToSet) {
39
39
  function getNestedValues(map, keys, index = 0) {
40
40
  const { currentTemplateAndNested, reason } = getCurrentKeyAndValue(map, keys, index);
41
41
  if (!currentTemplateAndNested) {
42
- return { value: currentTemplateAndNested, reason };
42
+ return {
43
+ value: currentTemplateAndNested,
44
+ reason,
45
+ };
43
46
  }
44
47
  if (index === keys.length - 1) {
45
- return { value: currentTemplateAndNested, reason: `reached end of keys array` };
48
+ return {
49
+ value: currentTemplateAndNested,
50
+ reason: `reached end of keys array`,
51
+ };
46
52
  }
47
53
  if (!currentTemplateAndNested.nested) {
48
- return { value: undefined, reason: `map at key index ${index} did not have nested maps` };
54
+ return {
55
+ value: undefined,
56
+ reason: `map at key index ${index} did not have nested maps`,
57
+ };
49
58
  }
50
59
  return getNestedValues(currentTemplateAndNested.nested, keys, index + 1);
51
60
  }
@@ -73,20 +82,33 @@ function getCurrentKeyAndValue(map, keys, index) {
73
82
  reason: `value at key at index ${index} was undefined`,
74
83
  };
75
84
  }
76
- return { currentKey, currentTemplateAndNested, reason: `key and value exists` };
85
+ return {
86
+ currentKey,
87
+ currentTemplateAndNested,
88
+ reason: `key and value exists`,
89
+ };
77
90
  }
78
91
  function setNestedValues(map, keys, valueToSet, index = 0) {
79
92
  const { currentTemplateAndNested, currentKey, reason } = getCurrentKeyAndValue(map, keys, index);
80
93
  if (!currentKey) {
81
- return { result: false, reason };
94
+ return {
95
+ result: false,
96
+ reason,
97
+ };
82
98
  }
83
- const nestedAndTemplate = currentTemplateAndNested ?? { nested: undefined, template: undefined };
99
+ const nestedAndTemplate = currentTemplateAndNested ?? {
100
+ nested: undefined,
101
+ template: undefined,
102
+ };
84
103
  if (!currentTemplateAndNested) {
85
104
  map.set(currentKey, nestedAndTemplate);
86
105
  }
87
106
  if (index === keys.length - 1) {
88
107
  nestedAndTemplate.template = valueToSet;
89
- return { result: true, reason: `set value at end of keys array` };
108
+ return {
109
+ result: true,
110
+ reason: `set value at end of keys array`,
111
+ };
90
112
  }
91
113
  const nestedWeakMap = nestedAndTemplate.nested ?? new WeakMap();
92
114
  if (!nestedAndTemplate.nested) {
@@ -16,7 +16,9 @@ export function mapHtmlValues(inputTemplateStrings, inputValues) {
16
16
  const replacement = {
17
17
  tagName: currentValue,
18
18
  tagInterpolationKey: getOrSet(tagNameKeys, currentValue, () => {
19
- return { tagName: currentValue };
19
+ return {
20
+ tagName: currentValue,
21
+ };
20
22
  }),
21
23
  };
22
24
  return replacement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "element-vir",
3
- "version": "26.14.4",
3
+ "version": "26.14.5",
4
4
  "keywords": [
5
5
  "custom",
6
6
  "web",
@@ -46,7 +46,7 @@
46
46
  "lit-css-vars": "^3.5.0",
47
47
  "lit-html": "^3.3.2",
48
48
  "object-shape-tester": "^6.11.0",
49
- "observavir": "^2.3.1",
49
+ "observavir": "^2.3.2",
50
50
  "typed-event-target": "^4.1.0"
51
51
  },
52
52
  "devDependencies": {