@swiftwc/ui 0.0.0-dev.35 → 0.0.0-dev.36

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.
@@ -4,6 +4,7 @@ import { I18n } from '../i18n';
4
4
  import { NavigationPath } from '../internal/class/navigation-path';
5
5
  import { $, kebabCase, onoff } from '../internal/utils';
6
6
  import { Snapshot } from '../snapshot';
7
+ //#region polyfills
7
8
  export const polyfills = new Map();
8
9
  for (const [k, Ctor] of Object.entries(Components)) {
9
10
  const is = kebabCase(k);
@@ -101,6 +102,7 @@ if (0 < polyfills.size) {
101
102
  }
102
103
  // SECTION: Safari polyfill
103
104
  document.addEventListener('touchstart', () => { }, { passive: true });
105
+ //#endregion
104
106
  // SECTION
105
107
  const handleHelp = ({ target, relatedTarget }) => {
106
108
  if (!(target instanceof HTMLElement && target))
@@ -164,7 +166,7 @@ if (mediaQueryList.matches)
164
166
  ['pointerout', handleDone],
165
167
  ])
166
168
  document.addEventListener(k, v, { passive: true });
167
- // SECTION: Transitions
169
+ //#region Transitions
168
170
  const cleanup = (lm, type) => {
169
171
  let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
170
172
  if (['backwards', 'forwards'].includes(type ?? ''))
@@ -315,6 +317,8 @@ export const startViewTransition = async (target, type = 'forwards', updateCallb
315
317
  await updateCallback();
316
318
  }
317
319
  };
320
+ //#endregion
321
+ //#region fns
318
322
  export const alert = async (title, message, actions, options) => {
319
323
  await navigator.locks.request('alert:', async () => {
320
324
  const dialog = $(`<dialog is="alert-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
@@ -410,6 +414,8 @@ export const confirmationDialog = async (trigger, title, message, actions, optio
410
414
  // // controller.signal.addEventListener('abort', onAbort, { once: true })
411
415
  // })
412
416
  };
417
+ //#endregion
413
418
  void Snapshot.waitReady; // void Snapshot.setOwnConfig()
414
- // SECTION
419
+ //#region exports
415
420
  export { I18n, lifecycleObserver, NavigationPath, Snapshot };
421
+ //#endregion
@@ -10,12 +10,12 @@ export declare class DatePicker extends FormAssociatedBase {
10
10
  disconnectedCallback(): void;
11
11
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
12
12
  get datePickerStyle(): DatePickerStyle;
13
- get selection(): {
13
+ get selectedDate(): {
14
14
  year: string;
15
15
  month: string;
16
16
  day: string;
17
17
  };
18
- set selection(v: {
18
+ set selectedDate(v: {
19
19
  year: string;
20
20
  month: string;
21
21
  day: string;
@@ -69,7 +69,7 @@ export class DatePicker extends FormAssociatedBase {
69
69
  if (!this.hasAttribute('selection'))
70
70
  return;
71
71
  const [y = '', m = '', d = ''] = (this.getAttribute('selection') ?? '').split(/\D+/);
72
- this.selection = { year: y, month: m, day: d };
72
+ this.selectedDate = { year: y, month: m, day: d };
73
73
  this.#sendValueToForm(false);
74
74
  }
75
75
  disconnectedCallback() {
@@ -80,7 +80,7 @@ export class DatePicker extends FormAssociatedBase {
80
80
  switch (name) {
81
81
  case 'selection':
82
82
  const [y = '', m = '', d = ''] = (newValue ?? '').split(/\D+/);
83
- this.selection = { year: y, month: m, day: d };
83
+ this.selectedDate = { year: y, month: m, day: d };
84
84
  break;
85
85
  case 'required':
86
86
  for (const input of this.#inputs)
@@ -162,7 +162,7 @@ export class DatePicker extends FormAssociatedBase {
162
162
  break;
163
163
  }
164
164
  }
165
- get selection() {
165
+ get selectedDate() {
166
166
  const map = Object.fromEntries(this.#inputs.map(({ name, value }) => [name, value]));
167
167
  return {
168
168
  year: map.year ?? '',
@@ -170,7 +170,7 @@ export class DatePicker extends FormAssociatedBase {
170
170
  day: map.day ?? '',
171
171
  };
172
172
  }
173
- set selection(v) {
173
+ set selectedDate(v) {
174
174
  for (const input of this.#inputs) {
175
175
  const nv = v[input.name] ?? '', pattern = /^(\d+)?$/;
176
176
  let finalValue = pattern.test(nv) ? nv : '', parsedValue = parseInt(finalValue);
@@ -217,7 +217,7 @@ export class DatePicker extends FormAssociatedBase {
217
217
  else
218
218
  this.setValidity({});
219
219
  }
220
- const selection = `${this.selection.year}-${this.selection.month}-${this.selection.day}`;
220
+ const selection = `${this.selectedDate.year}-${this.selectedDate.month}-${this.selectedDate.day}`;
221
221
  const entries = new FormData();
222
222
  entries.append(this.name, selection);
223
223
  this.#internals.setFormValue(entries);
@@ -431,7 +431,7 @@ export class DatePicker extends FormAssociatedBase {
431
431
  input.toggleAttribute('disabled', !disabled);
432
432
  };
433
433
  formResetCallback = () => {
434
- this.selection = {
434
+ this.selectedDate = {
435
435
  year: '',
436
436
  month: '',
437
437
  day: '',
@@ -1,15 +1,20 @@
1
1
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
2
  import { listActive, onoff } from '../internal/utils';
3
3
  export class ListView extends HTMLElement {
4
- // static formAssociated = true
5
- // #internals
6
- // #options
7
- // #focusedIndex = 0
8
- // #selected = new Set()
4
+ // static #template: DocumentFragment
5
+ // static get template() {
6
+ // return (this.#template ??= $(
7
+ // String.raw`
8
+ // <slot name="searchable"></slot>
9
+ // <slot></slot>
10
+ // `
11
+ // ))
12
+ // }
13
+ // #shadowRoot
9
14
  constructor() {
10
15
  super();
11
- // this.#internals = this.attachInternals()
12
- // this.tabIndex = 0
16
+ // this.#shadowRoot = this.attachShadow({ mode: 'closed' })
17
+ // this.#shadowRoot.appendChild(document.importNode((this.constructor as typeof ListView).template, true))
13
18
  }
14
19
  disconnectedCallback() {
15
20
  console.debug(`${ListView.name} ⚡️ disconnect`);
@@ -18,12 +23,5 @@ export class ListView extends HTMLElement {
18
23
  connectedCallback() {
19
24
  console.debug(`${ListView.name} ⚡️ connect`);
20
25
  CleanupRegistry.register(this, onoff(listActive(this), this).on());
21
- // this.setAttribute('role', 'listbox')
22
- // this.setAttribute('aria-multiselectable', 'true')
23
- // this.#options = Array.from(this.querySelectorAll('[option]'))
24
- // this.addEventListener('pointerleave', this.#onCancel)
25
- // this.addEventListener('click', this.#onClick)
26
- // this.addEventListener('keydown', this.#onKeyDown)
27
- // this.#updateOptionAttributes()
28
26
  }
29
27
  }
@@ -1956,6 +1956,9 @@
1956
1956
  place-content: safe center;
1957
1957
  gap: 1rem;
1958
1958
  }
1959
+ :where(h-stack[template="auto spacer"]) {
1960
+ grid-template-columns: auto minmax(0, 1fr);
1961
+ }
1959
1962
  :where(h-stack[template="spacer auto"]) {
1960
1963
  grid-template-columns: minmax(0, 1fr) auto;
1961
1964
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftwc/ui",
3
- "version": "0.0.0-dev.35",
3
+ "version": "0.0.0-dev.36",
4
4
  "description": "Elegant SwiftUI-inspired web components for standalone web apps and web extensions.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,7 +3,7 @@
3
3
  @use 'sass:string';
4
4
  @use 'sass:list';
5
5
 
6
- $h-stack-templates: ((minmax(0, 1fr) auto), (auto minmax(0, 1fr) auto auto), (auto minmax(0, 1fr) auto), (repeat(4, minmax(0, 1fr))), (repeat(2, minmax(0, 1fr)) auto));
6
+ $h-stack-templates: ((auto minmax(0, 1fr)), (minmax(0, 1fr) auto), (auto minmax(0, 1fr) auto auto), (auto minmax(0, 1fr) auto), (repeat(4, minmax(0, 1fr))), (repeat(2, minmax(0, 1fr)) auto));
7
7
 
8
8
  @layer #{vars.$components-layer} {
9
9
  h-stack {
@@ -494,7 +494,6 @@
494
494
  }
495
495
  }
496
496
  }
497
- // }
498
497
  }
499
498
  // }
500
499
  // [is='disclosure-group'] summary [slot='marker'] {
@@ -505,6 +504,17 @@
505
504
  // --itempadistart: calc(calc(var(--root-font-size) * 1px) * var(--list--accessory-size) + var(--list--item-padding-inline-start, 0px));
506
505
  // }
507
506
  // }
507
+
508
+ // // SECTION: add searchable
509
+ // > [slot='searchable'] {
510
+ // :where(&) {
511
+ // position: sticky;
512
+
513
+ // top: 20px
514
+
515
+ // background: red;
516
+ // }
517
+ // }
508
518
  }
509
519
  }
510
520