@swiftwc/ui 1.0.1-canary.0 → 1.0.1-canary.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.
@@ -29,7 +29,10 @@ for (const [k, Ctor] of Object.entries(Components)) {
29
29
  }
30
30
  debug(polyfills);
31
31
  if (0 < polyfills.size) {
32
- const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
32
+ const polyfillTagNamesCache = new Set(polyfills
33
+ .values()
34
+ .map((v) => String(v.polyfillExtends ?? '').toUpperCase())
35
+ .filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
33
36
  const handlers = new WeakMap();
34
37
  const observe = (el, polyfill) => {
35
38
  if (!Array.isArray(polyfill.observedAttributes))
@@ -197,7 +200,7 @@ export const alert = (title, message, actions, options) => {
197
200
  off?.();
198
201
  dialog?.close();
199
202
  // dialog?.remove()
200
- reason === undefined ? resolve(undefined) : reject(reason instanceof Error ? reason : new DOMException('Alert dismissed', 'AbortError'));
203
+ reason === undefined ? resolve(undefined) : reject(Error.isError(reason) ? reason : new DOMException('Alert dismissed', 'AbortError'));
201
204
  };
202
205
  if (options?.signal)
203
206
  if (options.signal.aborted)
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { I18n } from '../i18n';
3
2
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
4
3
  import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
@@ -37,7 +36,7 @@ export class DatePicker extends FormAssociatedBase {
37
36
  static #templates = new Map();
38
37
  // #lastRenderedStyle?: DatePickerStyle //string | null
39
38
  #renderValidityMsgs = (entries) => {
40
- debug(`${_a.name} ⚡️ mutation`);
39
+ debug(`${DatePicker.name} ⚡️ mutation`);
41
40
  this.setValidity(this.validity, this.validationMessage);
42
41
  };
43
42
  #shadowRoot;
@@ -50,32 +49,55 @@ export class DatePicker extends FormAssociatedBase {
50
49
  return getInternals(this);
51
50
  }
52
51
  get template() {
53
- if (!_a.#templates.has(this.datePickerStyle))
52
+ // if (!DatePicker.#templates.has(this.datePickerStyle))
53
+ // switch (this.datePickerStyle) {
54
+ // default:
55
+ // DatePicker.#templates.set(
56
+ // this.datePickerStyle,
57
+ // $(
58
+ // html`<label part="root date-picker-stack">
59
+ // <div part="root date-picker-label-stack">
60
+ // <slot name="label"></slot>
61
+ // </div>
62
+ // <div part="root date-picker-input-stack">
63
+ // <input type="text" name="month" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="12" part="root input date-picker-form-input" />
64
+ // <span part="root date-picker-separator"></span>
65
+ // <input type="text" name="day" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="31" part="root input date-picker-form-input" />
66
+ // <span part="root date-picker-separator"></span>
67
+ // <input type="text" name="year" inputmode="numeric" pattern="d*" minlength="4" maxlength="4" min="0" max="9999" part="root input date-picker-form-input" />
68
+ // </div>
69
+ // <slot name="validity-options" hidden></slot>
70
+ // </label>`
71
+ // )
72
+ // )
73
+ // break
74
+ // }
75
+ // return DatePicker.#templates.get(this.datePickerStyle)!
76
+ return DatePicker.#templates.getOrInsertComputed(this.datePickerStyle, () => {
54
77
  switch (this.datePickerStyle) {
55
78
  default:
56
- _a.#templates.set(this.datePickerStyle, $(html `<label part="root date-picker-stack">
57
- <div part="root date-picker-label-stack">
58
- <slot name="label"></slot>
59
- </div>
60
- <div part="root date-picker-input-stack">
61
- <input type="text" name="month" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="12" part="root input date-picker-form-input" />
62
- <span part="root date-picker-separator"></span>
63
- <input type="text" name="day" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="31" part="root input date-picker-form-input" />
64
- <span part="root date-picker-separator"></span>
65
- <input type="text" name="year" inputmode="numeric" pattern="d*" minlength="4" maxlength="4" min="0" max="9999" part="root input date-picker-form-input" />
66
- </div>
67
- <slot name="validity-options" hidden></slot>
68
- </label>`));
69
- break;
79
+ return $(html `<label part="root date-picker-stack">
80
+ <div part="root date-picker-label-stack">
81
+ <slot name="label"></slot>
82
+ </div>
83
+ <div part="root date-picker-input-stack">
84
+ <input type="text" name="month" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="12" part="root input date-picker-form-input" />
85
+ <span part="root date-picker-separator"></span>
86
+ <input type="text" name="day" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="31" part="root input date-picker-form-input" />
87
+ <span part="root date-picker-separator"></span>
88
+ <input type="text" name="year" inputmode="numeric" pattern="d*" minlength="4" maxlength="4" min="0" max="9999" part="root input date-picker-form-input" />
89
+ </div>
90
+ <slot name="validity-options" hidden></slot>
91
+ </label>`);
70
92
  }
71
- return _a.#templates.get(this.datePickerStyle);
93
+ });
72
94
  }
73
95
  constructor() {
74
96
  super();
75
97
  this.#shadowRoot = this.attachShadow({ mode: 'closed' });
76
98
  }
77
99
  attributeChangedCallback(name, oldValue, newValue) {
78
- debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
100
+ debug(`${DatePicker.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
79
101
  switch (name) {
80
102
  case 'selection':
81
103
  // nothing happens// const [y = '', m = '', d = ''] = (newValue ?? '').split(/\D+/)
@@ -128,7 +150,7 @@ export class DatePicker extends FormAssociatedBase {
128
150
  return datePickerStyles.includes(this.getAttribute('date-picker-style') ?? '') ? this.getAttribute('date-picker-style') : 'automatic';
129
151
  }
130
152
  #render() {
131
- debug(`${_a.name} ⚡️ #render (${this.datePickerStyle})`);
153
+ debug(`${DatePicker.name} ⚡️ #render (${this.datePickerStyle})`);
132
154
  // if (this.#lastRenderedStyle === this.datePickerStyle) return // skip if already applied
133
155
  // this.#lastRenderedStyle = this.datePickerStyle
134
156
  // clear shadow DOM
@@ -172,7 +194,7 @@ export class DatePicker extends FormAssociatedBase {
172
194
  }
173
195
  }
174
196
  #handleValiditiesSlotchange = ({ type, target: slot }) => {
175
- debug(`${_a.name} ⚡️ ${type}`);
197
+ debug(`${DatePicker.name} ⚡️ ${type}`);
176
198
  if (!(slot instanceof HTMLSlotElement))
177
199
  return;
178
200
  const assigned = slot.assignedElements();
@@ -192,15 +214,15 @@ export class DatePicker extends FormAssociatedBase {
192
214
  for (const input of this.#inputs) {
193
215
  const nv = v[input.name] ?? '', pattern = /^(\d+)?$/;
194
216
  let finalValue = pattern.test(nv) ? nv : '', parsedValue = parseInt(finalValue);
195
- if (_a.#min(input) > parsedValue)
217
+ if (DatePicker.#min(input) > parsedValue)
196
218
  finalValue = '';
197
- else if (_a.#max(input) < parsedValue)
219
+ else if (DatePicker.#max(input) < parsedValue)
198
220
  finalValue = '';
199
221
  input.value = finalValue;
200
222
  }
201
223
  }
202
224
  #handleClick = (evt) => {
203
- debug(`${_a.name} ⚡️ ${evt?.type}`);
225
+ debug(`${DatePicker.name} ⚡️ ${evt?.type}`);
204
226
  const { target } = evt;
205
227
  if (!(target instanceof HTMLElement))
206
228
  return;
@@ -243,7 +265,7 @@ export class DatePicker extends FormAssociatedBase {
243
265
  this.dispatchEvent(new CustomEvent('selection', { detail: { selection }, bubbles: true, composed: true }));
244
266
  };
245
267
  #handleInputPaste = (evt) => {
246
- debug(`${_a.name} ⚡️ ${evt?.type}`);
268
+ debug(`${DatePicker.name} ⚡️ ${evt?.type}`);
247
269
  const { target: input } = evt;
248
270
  if (!(input instanceof HTMLInputElement))
249
271
  return;
@@ -265,7 +287,7 @@ export class DatePicker extends FormAssociatedBase {
265
287
  this.#sendValueToForm();
266
288
  };
267
289
  #handleInputBeforeinput = (evt) => {
268
- debug(`${_a.name} ⚡️ ${evt?.type}`);
290
+ debug(`${DatePicker.name} ⚡️ ${evt?.type}`);
269
291
  const { target: input } = evt;
270
292
  if (!(input instanceof HTMLInputElement))
271
293
  return;
@@ -288,7 +310,7 @@ export class DatePicker extends FormAssociatedBase {
288
310
  }
289
311
  };
290
312
  #handleInputKeydown = ({ type, target, key }) => {
291
- debug(`${_a.name} ⚡️ ${type}`);
313
+ debug(`${DatePicker.name} ⚡️ ${type}`);
292
314
  if (!(target instanceof HTMLInputElement))
293
315
  return;
294
316
  const input = target;
@@ -307,25 +329,25 @@ export class DatePicker extends FormAssociatedBase {
307
329
  this.#inputs[index]?.focus();
308
330
  };
309
331
  #handleInputFocus = (evt) => {
310
- debug(`${_a.name} ⚡️ ${evt?.type}`);
332
+ debug(`${DatePicker.name} ⚡️ ${evt?.type}`);
311
333
  for (const input of this.#inputs)
312
334
  input.classList.toggle('focus', input === evt.target);
313
335
  };
314
336
  #handleInputBlur = ({ target, type }) => {
315
- debug(`${_a.name} ⚡️ ${type}`);
337
+ debug(`${DatePicker.name} ⚡️ ${type}`);
316
338
  if (!(target instanceof HTMLInputElement))
317
339
  return;
318
340
  const input = target;
319
341
  if (0 === input.value.length)
320
342
  return;
321
- const finalText = `${clamp(this.value[input.name] ?? '0', _a.#min(input), _a.#max(input))}`.padStart(parseInt(input.getAttribute('maxlength') ?? '0'), '0');
343
+ const finalText = `${clamp(this.value[input.name] ?? '0', DatePicker.#min(input), DatePicker.#max(input))}`.padStart(parseInt(input.getAttribute('maxlength') ?? '0'), '0');
322
344
  if (!set(input, 'value', finalText))
323
345
  return;
324
346
  // this.selection = this.selection
325
347
  this.#sendValueToForm();
326
348
  };
327
349
  #handleInputInput = (evt) => {
328
- debug(`${_a.name} ⚡️ ${evt?.type}`);
350
+ debug(`${DatePicker.name} ⚡️ ${evt?.type}`);
329
351
  this.#sendValueToForm();
330
352
  };
331
353
  /**
@@ -436,7 +458,7 @@ export class DatePicker extends FormAssociatedBase {
436
458
  message = kebabCase(key);
437
459
  break;
438
460
  }
439
- debug(`${_a.name} ⚡️ validity-change`);
461
+ debug(`${DatePicker.name} ⚡️ validity-change`);
440
462
  return this.#internals.setValidity(flags, this.#customValidity || message, anchor ?? this.#inputs.at(0));
441
463
  };
442
464
  setCustomValidity = (message) => {
@@ -465,4 +487,3 @@ export class DatePicker extends FormAssociatedBase {
465
487
  this.#sendValueToForm(false);
466
488
  }
467
489
  }
468
- _a = DatePicker;
@@ -49,12 +49,14 @@ export class DisclosureGroup extends DetailsBase {
49
49
  const newValue = details.open ? 'opening' : 'closing';
50
50
  if (newValue !== details.dataset.state)
51
51
  details.dataset.state = newValue;
52
- if (!toggleTimers.has(details))
53
- toggleTimers.set(details, timeout()); //if (!toggleTimeouts.has(details)) toggleTimeouts.set(details, null)
52
+ // if (!toggleTimers.has(details)) toggleTimers.set(details, timeout()) //if (!toggleTimeouts.has(details)) toggleTimeouts.set(details, null)
54
53
  // Cancel previous timeout for this instance
55
54
  //if (toggleTimeouts.has(details) && toggleTimeouts.get(details)) self.clearTimeout(toggleTimeouts.get(details))
56
55
  // Schedule a new hook
57
- toggleTimers.get(details).next(() => {
56
+ // toggleTimers.get(details)!.next(
57
+ toggleTimers
58
+ .getOrInsertComputed(details, () => timeout())
59
+ .next(() => {
58
60
  details.dataset.state = details.open ? 'open' : 'closed';
59
61
  details?.dispatchEvent(new CustomEvent(`is-${details.open ? 'expanded' : 'collapsed'}`, { bubbles: true, composed: true }));
60
62
  }, cssTime(`${details.computedStyleMap().get('--disclosure-group-animation-duration')}`));
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
2
  import { $, debug, onoff } from '../internal/utils';
4
3
  import { html } from '../tpl';
@@ -20,7 +19,7 @@ export class FineTooltip extends HTMLElement {
20
19
  this.#render(target.getAttribute(attributeName));
21
20
  };
22
21
  #handleMeasure = ([{ target, borderBoxSize }]) => {
23
- debug(`${_a.name} ⚡️ measure`);
22
+ debug(`${FineTooltip.name} ⚡️ measure`);
24
23
  if (target.hasAttribute('closing'))
25
24
  return;
26
25
  if (!(target instanceof HTMLElement))
@@ -50,7 +49,7 @@ export class FineTooltip extends HTMLElement {
50
49
  label.removeAttribute('title');
51
50
  };
52
51
  connectedCallback() {
53
- debug(`${_a.name} ⚡️ connect`);
52
+ debug(`${FineTooltip.name} ⚡️ connect`);
54
53
  this.removeAttribute('closing');
55
54
  this.popover = 'manual';
56
55
  this.inert = true;
@@ -59,7 +58,7 @@ export class FineTooltip extends HTMLElement {
59
58
  this.showPopover();
60
59
  }
61
60
  disconnectedCallback() {
62
- debug(`${_a.name} ⚡️ disconnect`);
61
+ debug(`${FineTooltip.name} ⚡️ disconnect`);
63
62
  this.#resizeObserver.unobserve(this);
64
63
  this.#mutationObserver?.disconnect();
65
64
  this.#mutationObserver2?.disconnect();
@@ -105,4 +104,3 @@ export class FineTooltip extends HTMLElement {
105
104
  });
106
105
  }
107
106
  }
108
- _a = FineTooltip;
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
2
  import { $, debug, onoff, touchGlass } from '../internal/utils';
4
3
  import { queryMorph } from '../morphdom';
@@ -34,14 +33,14 @@ export class MenuView extends HTMLElement {
34
33
  this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
35
34
  }
36
35
  attributeChangedCallback(name, oldValue, newValue) {
37
- debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
36
+ debug(`${MenuView.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
38
37
  switch (name) {
39
38
  case 'open':
40
39
  if (!this.#dialog)
41
40
  break;
42
41
  this.#dialog.inert = null === newValue;
43
42
  if (null === newValue && this.#dialog.open) {
44
- debug(`${_a.name} ⚡️ will-close`);
43
+ debug(`${MenuView.name} ⚡️ will-close`);
45
44
  this.setAttribute('closing', '');
46
45
  Promise.allSettled(this.#dialog.getAnimations().map(({ finished }) => finished)).then(() => {
47
46
  if (!this.hasAttribute('closing'))
@@ -51,7 +50,7 @@ export class MenuView extends HTMLElement {
51
50
  });
52
51
  }
53
52
  if ('' === newValue && !this.#dialog.open) {
54
- debug(`${_a.name} ⚡️ will-open`);
53
+ debug(`${MenuView.name} ⚡️ will-open`);
55
54
  this.removeAttribute('closing');
56
55
  const form = this.#shadowRoot.querySelector('form');
57
56
  form.scrollTop = 0;
@@ -64,14 +63,14 @@ export class MenuView extends HTMLElement {
64
63
  }
65
64
  }
66
65
  disconnectedCallback() {
67
- debug(`${_a.name} ⚡️ disconnect`);
66
+ debug(`${MenuView.name} ⚡️ disconnect`);
68
67
  const summaryPart = this.#shadowRoot.querySelector('[part*=menu-summary]'), dialogPart = this.#shadowRoot.querySelector('[part*=menu-dialog]');
69
68
  summaryPart?.style.removeProperty('anchor-name'); //$.prop('anchor-name', null, summaryPart)
70
69
  dialogPart?.style.removeProperty('position-anchor'); //$.prop('position-anchor', null, dialogPart)
71
70
  CleanupRegistry.unregister(this);
72
71
  }
73
72
  connectedCallback() {
74
- debug(`${_a.name} ⚡️ connect`);
73
+ debug(`${MenuView.name} ⚡️ connect`);
75
74
  this.#dialog = this.#shadowRoot.querySelector('dialog') ?? undefined;
76
75
  const trigger = this.#shadowRoot.querySelector('button') ?? undefined;
77
76
  CleanupRegistry.register(this, onoff('click', this.#handleTriggerClick, trigger).on());
@@ -95,7 +94,7 @@ export class MenuView extends HTMLElement {
95
94
  dialogPart?.style.setProperty('position-anchor', newAnchorName); // $.prop('position-anchor', newAnchorName, dialogPart) //
96
95
  }
97
96
  #handleDialogClick = ({ type, target }) => {
98
- debug(`${_a.name} ⚡️ ${type}`);
97
+ debug(`${MenuView.name} ⚡️ ${type}`);
99
98
  if (!(target instanceof HTMLElement))
100
99
  return;
101
100
  if (target.matches('dialog'))
@@ -112,20 +111,19 @@ export class MenuView extends HTMLElement {
112
111
  // event.stopPropagation() //NOTE: add this only if not nested, disposes all nicely if ommited
113
112
  };
114
113
  #handleTriggerClick = (evt) => {
115
- debug(`${_a.name} ⚡️ ${evt?.type}`);
114
+ debug(`${MenuView.name} ⚡️ ${evt?.type}`);
116
115
  this.toggleAttribute('open', true);
117
116
  };
118
117
  // intercept to modify open attr
119
118
  #handleDialogCancel = (evt) => {
120
- debug(`${_a.name} ⚡️ ${evt?.type}`);
119
+ debug(`${MenuView.name} ⚡️ ${evt?.type}`);
121
120
  if (!evt.cancelable)
122
121
  return;
123
122
  evt.preventDefault();
124
123
  this.toggleAttribute('open', false);
125
124
  };
126
125
  #handleDialogClose = (evt) => {
127
- debug(`${_a.name} ⚡️ ${evt?.type}`);
126
+ debug(`${MenuView.name} ⚡️ ${evt?.type}`);
128
127
  this.toggleAttribute('open', this.#shadowRoot.querySelector('dialog')?.open ?? false);
129
128
  };
130
129
  }
131
- _a = MenuView;
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
2
  import { CSSStyleObserver } from '../internal/class/css-style-observer';
4
3
  import { add, debug, frame, onoff, slowHideShow, timeout } from '../internal/utils';
@@ -82,13 +81,13 @@ export class NavigationLargeTitle extends HTMLElement {
82
81
  super();
83
82
  }
84
83
  disconnectedCallback() {
85
- debug(`${_a.name} ⚡️ disconnect`);
84
+ debug(`${NavigationLargeTitle.name} ⚡️ disconnect`);
86
85
  this.#clearScrollState();
87
86
  this.#styleObserver?.disconnect();
88
87
  CleanupRegistry.unregister(this);
89
88
  }
90
89
  connectedCallback() {
91
- debug(`${_a.name} ⚡️ connect`);
90
+ debug(`${NavigationLargeTitle.name} ⚡️ connect`);
92
91
  const root = this.closest('scroll-view') ?? undefined;
93
92
  if (!root)
94
93
  return;
@@ -111,7 +110,7 @@ export class NavigationLargeTitle extends HTMLElement {
111
110
  });
112
111
  }
113
112
  #handleStyleChange = () => {
114
- debug(`${_a.name} ⚡️ style`);
113
+ debug(`${NavigationLargeTitle.name} ⚡️ style`);
115
114
  const root = this.closest('scroll-view') ?? undefined;
116
115
  if (!root)
117
116
  return;
@@ -156,7 +155,7 @@ export class NavigationLargeTitle extends HTMLElement {
156
155
  // this.#applySlowness(root, isIntersecting)
157
156
  // }
158
157
  #handleIntersect = (entries, { root }) => {
159
- debug(`${_a.name} ⚡️ intersect (${entries?.at(0)?.isIntersecting})`);
158
+ debug(`${NavigationLargeTitle.name} ⚡️ intersect (${entries?.at(0)?.isIntersecting})`);
160
159
  if (!(root instanceof HTMLElement))
161
160
  return;
162
161
  for (const { isIntersecting } of entries)
@@ -180,4 +179,3 @@ export class NavigationLargeTitle extends HTMLElement {
180
179
  slowHideShow(isIntersecting ? 'show' : 'hide', this);
181
180
  };
182
181
  }
183
- _a = NavigationLargeTitle;