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

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 (94) hide show
  1. package/generated/client/index.d.ts +2 -9
  2. package/generated/client/index.js +5 -156
  3. package/generated/components/alert-dialog.js +18 -21
  4. package/generated/components/body-view.js +3 -2
  5. package/generated/components/bordered-button.js +4 -4
  6. package/generated/components/bordered-prominent-button.js +4 -4
  7. package/generated/components/borderless-button.js +4 -4
  8. package/generated/components/confirmation-dialog.js +18 -21
  9. package/generated/components/content-unavailable-view.js +4 -4
  10. package/generated/components/date-picker.d.ts +0 -10
  11. package/generated/components/date-picker.js +43 -30
  12. package/generated/components/disclosure-group.js +5 -5
  13. package/generated/components/fine-tooltip.js +4 -4
  14. package/generated/components/form-view.js +3 -3
  15. package/generated/components/glass-button.js +4 -4
  16. package/generated/components/glass-prominent-button.js +4 -4
  17. package/generated/components/index.d.ts +1 -0
  18. package/generated/components/index.js +1 -0
  19. package/generated/components/label-view.js +4 -4
  20. package/generated/components/list-view.js +3 -3
  21. package/generated/components/menu-view.js +14 -16
  22. package/generated/components/navigation-large-title.js +5 -5
  23. package/generated/components/navigation-split-view.js +4 -3
  24. package/generated/components/navigation-stack.js +4 -3
  25. package/generated/components/navigation-title.js +4 -4
  26. package/generated/components/picker-view.d.ts +2 -2
  27. package/generated/components/picker-view.js +314 -195
  28. package/generated/components/plain-button.js +3 -3
  29. package/generated/components/progress-view.js +6 -8
  30. package/generated/components/screen-view.js +2 -1
  31. package/generated/components/scroll-view-proxy.js +3 -2
  32. package/generated/components/scroll-view.js +15 -18
  33. package/generated/components/search-view.d.ts +8 -0
  34. package/generated/components/search-view.js +27 -0
  35. package/generated/components/section-view.js +4 -5
  36. package/generated/components/sheet-view.js +6 -34
  37. package/generated/components/sidebar-toggle.js +9 -10
  38. package/generated/components/sidebar-view.js +6 -8
  39. package/generated/components/sticky-container.js +3 -3
  40. package/generated/components/tab-bar.js +8 -10
  41. package/generated/components/tab-item.js +8 -8
  42. package/generated/components/tab-view.js +10 -11
  43. package/generated/components/table-view.js +19 -37
  44. package/generated/components/text-field.js +32 -17
  45. package/generated/components/tool-bar-item-group.js +17 -19
  46. package/generated/components/tool-bar-item.js +22 -23
  47. package/generated/components/tool-bar.d.ts +2 -2
  48. package/generated/components/tool-bar.js +7 -7
  49. package/generated/components/v-keyboard.js +5 -5
  50. package/generated/components/v-stack.js +3 -2
  51. package/generated/css/index.css +283 -272
  52. package/generated/events/picker-view.d.ts +6 -0
  53. package/generated/i18n/locales/el.d.ts +1 -0
  54. package/generated/i18n/locales/el.js +1 -0
  55. package/generated/i18n/locales/en.d.ts +1 -0
  56. package/generated/i18n/locales/en.js +1 -0
  57. package/generated/internal/class/css-style-observer.js +2 -2
  58. package/generated/internal/class/form-associated-base.d.ts +0 -4
  59. package/generated/internal/class/form-associated-base.js +21 -41
  60. package/generated/internal/class/mutation-observer-set.d.ts +9 -0
  61. package/generated/internal/class/mutation-observer-set.js +42 -0
  62. package/generated/internal/class/mutation-observer-singleton.js +18 -0
  63. package/generated/internal/class/navigation-view.js +3 -3
  64. package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
  65. package/generated/internal/decorators/adaptive-slot.js +47 -0
  66. package/generated/internal/decorators/custom-element.d.ts +1 -1
  67. package/generated/internal/decorators/custom-element.js +2 -1
  68. package/generated/internal/decorators/index.d.ts +4 -0
  69. package/generated/internal/decorators/index.js +4 -0
  70. package/generated/internal/privateNamespace.d.ts +10 -0
  71. package/generated/internal/privateNamespace.js +159 -1
  72. package/generated/internal/utils/debug.d.ts +1 -0
  73. package/generated/internal/utils/debug.js +3 -0
  74. package/generated/internal/utils/index.d.ts +3 -3
  75. package/generated/internal/utils/index.js +5 -3
  76. package/generated/namespace-browser/base.d.ts +9 -0
  77. package/generated/namespace-browser/base.js +23 -0
  78. package/generated/snapshot/index.d.ts +1 -1
  79. package/generated/snapshot/index.js +4 -4
  80. package/package.json +2 -1
  81. package/scss/_components.scss +2 -0
  82. package/scss/base/_root.scss +10 -8
  83. package/scss/colors/_index.scss +9 -12
  84. package/scss/components/_index.scss +2 -0
  85. package/scss/components/_menu-view.scss +11 -5
  86. package/scss/components/_picker-view.scss +11 -2
  87. package/scss/components/_scroll-view.scss +4 -0
  88. package/scss/components/_search-view.scss +18 -0
  89. package/scss/components/_sheet-view.scss +2 -1
  90. package/scss/components/_sticky-container.scss +1 -1
  91. package/scss/placeholders/_lists.scss +35 -35
  92. package/scss/utils/_index.scss +21 -7
  93. package/scss/utils/_stacks.scss +5 -43
  94. package/web-components.html-data/en.json +11 -0
@@ -1,8 +1,14 @@
1
1
  export type PickerSelectionDetail = {
2
2
  selection: string;
3
3
  };
4
+ export type PickerSearchableDetail = {
5
+ element: HTMLElement;
6
+ };
4
7
  declare global {
5
8
  interface HTMLElementEventMap {
6
9
  selection: CustomEvent<PickerSelectionDetail>;
10
+ 'picker:searchfocus': CustomEvent<PickerSearchableDetail>;
11
+ 'picker:searchblur': CustomEvent<PickerSearchableDetail>;
12
+ 'picker:searchinput': CustomEvent<PickerSearchableDetail>;
7
13
  }
8
14
  }
@@ -5,6 +5,7 @@ declare const _default: () => {
5
5
  readonly Description: "Ελέγξτε την ορθογραφία ή δοκιμάστε μια νέα αναζήτηση.";
6
6
  };
7
7
  readonly ButtonRole: {
8
+ readonly Back: "Πίσω";
8
9
  readonly Cancel: "Ακύρωση";
9
10
  readonly Close: "Κλείσιμο";
10
11
  readonly Confirm: "Τέλος";
@@ -6,6 +6,7 @@ export default defineTranslations(() => ({
6
6
  Description: 'Ελέγξτε την ορθογραφία ή δοκιμάστε μια νέα αναζήτηση.',
7
7
  },
8
8
  ButtonRole: {
9
+ Back: 'Πίσω',
9
10
  Cancel: 'Ακύρωση',
10
11
  Close: 'Κλείσιμο',
11
12
  Confirm: 'Τέλος',
@@ -5,6 +5,7 @@ declare const _default: () => {
5
5
  readonly Description: "Check the spelling or try a new search.";
6
6
  };
7
7
  readonly ButtonRole: {
8
+ readonly Back: "Back";
8
9
  readonly Cancel: "Cancel";
9
10
  readonly Close: "Close";
10
11
  readonly Confirm: "Confirm";
@@ -6,6 +6,7 @@ export default defineTranslations(() => ({
6
6
  Description: 'Check the spelling or try a new search.',
7
7
  },
8
8
  ButtonRole: {
9
+ Back: 'Back',
9
10
  Cancel: 'Cancel',
10
11
  Close: 'Close',
11
12
  Confirm: 'Confirm',
@@ -1,5 +1,5 @@
1
1
  var _a;
2
- import { onoff } from '../../internal/utils';
2
+ import { debug, onoff } from '../../internal/utils';
3
3
  export class CSSStyleObserver {
4
4
  #cleanups;
5
5
  #options;
@@ -16,7 +16,7 @@ export class CSSStyleObserver {
16
16
  this.#cleanups?.();
17
17
  }
18
18
  #handleTransitionrun = (callback, evt) => {
19
- console.debug(`${_a.name} ⚡️ ${evt?.type} (${evt.propertyName})`);
19
+ debug(`${_a.name} ⚡️ ${evt?.type} (${evt.propertyName})`);
20
20
  if (!this.#options?.properties.some((prop) => evt.propertyName.startsWith(prop)))
21
21
  return;
22
22
  callback?.(evt);
@@ -1,8 +1,4 @@
1
1
  export declare function getInternals(instance: FormAssociatedBase): ElementInternals;
2
- export declare function makeSlotchangeHandler(t: FormAssociatedBase): {
3
- types: string;
4
- listener: (evt: Event) => void;
5
- }[];
6
2
  export declare abstract class FormAssociatedBase extends HTMLElement {
7
3
  abstract setValidity(flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement): void;
8
4
  static get formAssociated(): boolean;
@@ -1,46 +1,28 @@
1
+ import { debug } from '../utils';
1
2
  import { CleanupRegistry } from './cleanup-registry';
2
- import { MutationObserverSingleton } from './mutation-observer-singleton';
3
3
  const internals = new WeakMap();
4
- const trackedElements = new WeakMap();
5
- const observers = new MutationObserverSingleton();
4
+ // const trackedElements = new WeakMap<FormAssociatedBase, Set<Element>>()
5
+ // const observers = new MutationObserverSingleton()
6
6
  export function getInternals(instance) {
7
7
  const i = internals.get(instance);
8
8
  if (!i)
9
9
  throw new Error('Not a FormAssociatedBase instance');
10
10
  return i;
11
11
  }
12
- export function makeSlotchangeHandler(t) {
13
- const handleSlotchange = (evt) => {
14
- console.debug(`${makeSlotchangeHandler.name} ⚡️ ${evt?.type}`);
15
- const slot = evt.target instanceof HTMLSlotElement && evt.target;
16
- if (!slot)
17
- return;
18
- const assigned = slot.assignedElements({ flatten: true });
19
- observers.syncObservations(trackedElements.get(t) ?? new Set(), assigned, handleTagMutation, ['value', 'label']);
20
- // for (const el of trackedElements.get(t) ?? [])
21
- // if (!assigned.includes(el)) {
22
- // observers.unobserve(el)
23
- // trackedElements.get(t)?.delete(el)
24
- // }
25
- // for (const el of assigned) {
26
- // if (!trackedElements.get(t)?.has(el))
27
- // observers.observe(el, handleTagMutation, {
28
- // attributes: true,
29
- // characterData: true,
30
- // subtree: true,
31
- // childList: true,
32
- // attributeFilter: ['value', 'label'],
33
- // })
34
- // trackedElements.get(t)?.add(el)
35
- // }
36
- if (0 < assigned.length)
37
- handleTagMutation();
38
- }, handleTagMutation = (entry) => {
39
- console.debug(`${handleTagMutation.name} ⚡️ mutation`);
40
- t.setValidity(t.validity, t.validationMessage);
41
- };
42
- return [{ types: 'slotchange', listener: handleSlotchange }];
43
- }
12
+ // export function makeSlotchangeHandler(t: FormAssociatedBase) {
13
+ // const handleSlotchange = ({ type, target: slot }: Event) => {
14
+ // debug(`${makeSlotchangeHandler.name} ⚡️ ${type}`)
15
+ // if (!(slot instanceof HTMLSlotElement && slot)) return
16
+ // const assigned = slot.assignedElements({ flatten: true })
17
+ // observers.syncObservations(trackedElements.get(t) ?? new Set(), assigned, handleTagMutation, ['value', 'label'])
18
+ // if (0 < assigned.length) handleTagMutation()
19
+ // },
20
+ // handleTagMutation = (entry?: MutationRecord) => {
21
+ // debug(`${handleTagMutation.name} ⚡️ mutation`)
22
+ // t.setValidity(t.validity, t.validationMessage)
23
+ // }
24
+ // return [{ types: 'slotchange', listener: handleSlotchange }]
25
+ // }
44
26
  export class FormAssociatedBase extends HTMLElement {
45
27
  static get formAssociated() {
46
28
  return true;
@@ -48,17 +30,15 @@ export class FormAssociatedBase extends HTMLElement {
48
30
  constructor() {
49
31
  super();
50
32
  internals.set(this, this.attachInternals());
51
- trackedElements.set(this, new Set());
33
+ // trackedElements.set(this, new Set<Element>())
52
34
  }
53
35
  disconnectedCallback() {
54
- console.debug(`${FormAssociatedBase.name} ⚡️ disconnect`);
36
+ debug(`${FormAssociatedBase.name} ⚡️ disconnect`);
55
37
  CleanupRegistry.unregister(this);
56
- observers.clearObservationsSet(trackedElements.get(this) ?? new Set());
57
- // for (const el of trackedElements.get(this) ?? []) observers.unobserve(el)
58
- // trackedElements.get(this)?.clear() // trackedElements.delete(this)
38
+ // observers.clearObservationsSet(trackedElements.get(this) ?? new Set())
59
39
  }
60
40
  connectedCallback() {
61
- console.debug(`${FormAssociatedBase.name} ⚡️ connect`);
41
+ debug(`${FormAssociatedBase.name} ⚡️ connect`);
62
42
  }
63
43
  get type() {
64
44
  return this.localName;
@@ -0,0 +1,9 @@
1
+ export declare class MutationObserverSet {
2
+ #private;
3
+ private callback;
4
+ constructor(callback: MutationCallback);
5
+ observe(target: Element, attributeFilter?: string[]): Promise<void>;
6
+ unobserve(target: Element): Promise<void>;
7
+ syncObservations(source: Element[], attributeFilter?: string[]): Promise<void>;
8
+ unobserveAll(): Promise<void>;
9
+ }
@@ -0,0 +1,42 @@
1
+ import { Snapshot } from '../../snapshot';
2
+ export class MutationObserverSet {
3
+ callback;
4
+ #observers = new Map();
5
+ constructor(callback) {
6
+ this.callback = callback;
7
+ }
8
+ async observe(target, attributeFilter) {
9
+ await Snapshot.waitReady;
10
+ if (this.#observers.has(target))
11
+ return;
12
+ const observer = new MutationObserver(this.callback);
13
+ observer.observe(target, {
14
+ attributes: true,
15
+ characterData: true,
16
+ subtree: true,
17
+ childList: true,
18
+ ...(attributeFilter && { attributeFilter }),
19
+ });
20
+ this.#observers.set(target, observer);
21
+ }
22
+ async unobserve(target) {
23
+ await Snapshot.waitReady;
24
+ this.#observers.get(target)?.disconnect();
25
+ this.#observers.delete(target);
26
+ }
27
+ async syncObservations(source, attributeFilter) {
28
+ await Snapshot.waitReady;
29
+ const sourceSet = new Set(source);
30
+ for (const el of [...this.#observers.keys()])
31
+ if (!sourceSet.has(el))
32
+ this.unobserve(el);
33
+ for (const el of source)
34
+ this.observe(el, attributeFilter);
35
+ }
36
+ async unobserveAll() {
37
+ await Snapshot.waitReady;
38
+ for (const obs of this.#observers.values())
39
+ obs.disconnect();
40
+ this.#observers.clear();
41
+ }
42
+ }
@@ -20,6 +20,24 @@ export class MutationObserverSingleton {
20
20
  this.#observers.delete(target);
21
21
  }
22
22
  /** Observes automatically all elements using a Set provided by outside. Calls renderCallback on EVERY change. */
23
+ // shortcur fot this
24
+ // #trackedElements = new Set<Element>()
25
+ // for (const el of this.#trackedElements)
26
+ // if (!assigned.includes(el)) {
27
+ // observers.unobserve(el)
28
+ // this.#trackedElements.delete(el)
29
+ // }
30
+ // for (const el of assigned) {
31
+ // if (!this.#trackedElements.has(el))
32
+ // observers.observe(el, this.#handleTagMutation, {
33
+ // attributes: true,
34
+ // characterData: true,
35
+ // subtree: true,
36
+ // childList: true,
37
+ // // attributeFilter: ['value', 'label'],
38
+ // })
39
+ // this.#trackedElements.add(el)
40
+ // }
23
41
  async syncObservations(set, nodes, renderCallback, attributeFilter) {
24
42
  for (const el of set)
25
43
  if (!nodes.includes(el)) {
@@ -1,7 +1,7 @@
1
1
  var _a;
2
2
  import { lifecycleObserver } from '../../buses';
3
3
  import { CleanupRegistry } from '../../internal/class/cleanup-registry';
4
- import { frame, onoff } from '../utils';
4
+ import { debug, frame, onoff } from '../utils';
5
5
  export class NavigationView extends HTMLElement {
6
6
  static get observedAttributes() {
7
7
  return ['hidden'];
@@ -56,7 +56,7 @@ export class NavigationView extends HTMLElement {
56
56
  // consume it (important so it doesn’t leak to next change)
57
57
  this.#recentBefore = undefined;
58
58
  }
59
- console.debug(`${_a.name} 💡 ${eventType}`);
59
+ debug(`${_a.name} 💡 ${eventType}`);
60
60
  frame(this).then(() => {
61
61
  // if (!r) return
62
62
  target.dispatchEvent(new CustomEvent(eventType, { detail: { tag: this.id }, bubbles: true, composed: true }));
@@ -65,7 +65,7 @@ export class NavigationView extends HTMLElement {
65
65
  }
66
66
  }
67
67
  #handleBeforeTabRevealOrSwap = (evt) => {
68
- console.debug(`${_a.name} ⚡️ ${evt?.type}`);
68
+ debug(`${_a.name} ⚡️ ${evt?.type}`);
69
69
  if (this.id !== evt.detail?.tag)
70
70
  return;
71
71
  this.#recentBefore = {
@@ -0,0 +1 @@
1
+ export default function (filter?: (el: HTMLElement) => boolean): <T extends CustomElementConstructor>(Base: T, _context?: ClassDecoratorContext<T>) => void;
@@ -0,0 +1,47 @@
1
+ import { Snapshot } from '../../snapshot';
2
+ import { CleanupRegistry } from '../class/cleanup-registry';
3
+ import { debug, onoff } from '../utils';
4
+ export default function (filter) {
5
+ const handleMediaChange = (el, { type, matches }) => {
6
+ debug(`${el.localName} ⚡️ ${type}`);
7
+ if (matches) {
8
+ if (!el.matches(`[slot="cancellation-action"],[slot="primary-action"],[slot="confirmation-action"],[slot="destructive-action"]`))
9
+ return;
10
+ const newSlot = ['destructive-action'].includes(el.slot) ? 'bottom-bar-leading' : 'bottom-bar-trailing';
11
+ if (el.slot !== newSlot)
12
+ el.dataset.previousSlot = el.slot;
13
+ el.slot = newSlot;
14
+ }
15
+ else {
16
+ if (!el.matches(`[data-previous-slot]`))
17
+ return;
18
+ el.slot = el.dataset.previousSlot ?? '';
19
+ delete el.dataset.previousSlot;
20
+ }
21
+ };
22
+ return function (Base, _context) {
23
+ const originalConnected = Base.prototype.connectedCallback, originalDisconnected = Base.prototype.disconnectedCallback;
24
+ Base.prototype.connectedCallback = function () {
25
+ console.debug(`decorator:[${this.localName}] ⚡️ connect`);
26
+ originalConnected?.call(this);
27
+ if (filter && !filter(this))
28
+ return;
29
+ if (!this.closest('[is=sheet-view]'))
30
+ return;
31
+ if (!self.matchMedia('(pointer: fine)').matches)
32
+ return;
33
+ const handler1 = handleMediaChange.bind(null, this);
34
+ CleanupRegistry.register(this, onoff('fine_dialog_sheet:change', handler1, Snapshot.on).on(), 'adaptive-slot');
35
+ Snapshot.waitReady.then(() => {
36
+ handleMediaChange(this, new MediaQueryListEvent(`media-change`, {
37
+ matches: Snapshot.breakpoints?.get('fine_dialog_sheet'),
38
+ })); // Initial check
39
+ });
40
+ };
41
+ Base.prototype.disconnectedCallback = function () {
42
+ console.debug(`decorator:[${this.localName}] ⚡️ disconnect`);
43
+ originalDisconnected?.call(this);
44
+ CleanupRegistry.unregister(this, 'adaptive-slot');
45
+ };
46
+ };
47
+ }
@@ -1,4 +1,4 @@
1
- export declare function customElement<T extends {
1
+ export default function <T extends {
2
2
  new (...args: any[]): {};
3
3
  }>(constructor: T): {
4
4
  new (...args: any[]): {};
@@ -1,4 +1,5 @@
1
- export function customElement(constructor) {
1
+ // https://www.typescriptlang.org/docs/handbook/decorators.html
2
+ export default function (constructor) {
2
3
  return class extends constructor {
3
4
  };
4
5
  }
@@ -0,0 +1,4 @@
1
+ export { default as adaptiveSlot } from './adaptive-slot';
2
+ export * from './adaptive-slot';
3
+ export { default as customElement } from './custom-element';
4
+ export * from './custom-element';
@@ -0,0 +1,4 @@
1
+ export { default as adaptiveSlot } from './adaptive-slot';
2
+ export * from './adaptive-slot';
3
+ export { default as customElement } from './custom-element';
4
+ export * from './custom-element';
@@ -1,4 +1,14 @@
1
1
  import type * as Components from '../components';
2
+ import { NavigationPath } from '../internal/class/navigation-path';
3
+ type TransitionType = 'forwards' | 'backwards' | 'reload';
2
4
  export type NavigationHost = Components.BodyView | Components.SheetView | Components.NavigationStack | Components.NavigationSplitView;
3
5
  export type NavigationToolbarConfiguration = Components.ToolBarItem | Components.ToolBarItemGroup;
4
6
  export type NavigationPage = Components.SidebarView | Components.ScrollView;
7
+ export declare function queryInsertPosition(frame: NavigationHost): "afterend" | "beforebegin";
8
+ type UpdateCallback = () => void | Promise<void>;
9
+ type NavigateOptions = {
10
+ updateCallback?: UpdateCallback;
11
+ tos?: () => NavigationPath[];
12
+ };
13
+ export declare const startViewTransition: (target: HTMLElement, type?: TransitionType, updateCallbackOrOptions?: UpdateCallback | NavigateOptions) => Promise<void>;
14
+ export {};
@@ -1 +1,159 @@
1
- export {};
1
+ import { NavigationPath } from '../internal/class/navigation-path';
2
+ import { debug } from '../internal/utils';
3
+ import { Snapshot } from '../snapshot';
4
+ export function queryInsertPosition(frame) {
5
+ if ('NAVIGATION-SPLIT-VIEW' === frame?.tagName)
6
+ return 'beforebegin'; // lookFor = 'previousElementSibling'
7
+ else if ('NAVIGATION-SPLIT-VIEW' === frame?.parentElement?.tagName && frame?.parentElement.querySelector(':scope>[is=sidebar-view]') && 'BODY-VIEW' === frame?.tagName)
8
+ return 'beforebegin'; // lookFor = 'previousElementSibling'
9
+ return 'afterend'; // lookFor = 'nextElementSibling'
10
+ }
11
+ const cleanup = (lm, type) => {
12
+ let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
13
+ if (['backwards', 'forwards'].includes(type ?? ''))
14
+ for (let i = arr.length - 1; i >= 0; i--)
15
+ if (arr[i].startsWith('backwards' === type ? 'fw' : 'bw'))
16
+ arr.splice(i, 1);
17
+ for (const el of [...(lm?.querySelectorAll(arr.map((v) => `.${v}`).join(',')) ?? [])])
18
+ el.classList.remove(...arr);
19
+ };
20
+ export const startViewTransition = async (target, type = 'forwards', updateCallbackOrOptions = async () => { }) => {
21
+ debug(`startViewTransition (${type})`, target);
22
+ if (!(target instanceof HTMLElement))
23
+ throw new TypeError("Argument 1 ('target') to client.startViewTransition must be an instance of HTMLElement");
24
+ if (!['forwards', 'backwards', 'reload'].includes(type))
25
+ throw new TypeError("Argument 2 ('type') to client.startViewTransition must be of TransitionType");
26
+ const options = typeof updateCallbackOrOptions === 'function'
27
+ ? {
28
+ updateCallback: updateCallbackOrOptions,
29
+ }
30
+ : (updateCallbackOrOptions ?? {}), updateCallback = options.updateCallback ?? (async () => { });
31
+ await Snapshot.waitReady;
32
+ const from = new NavigationPath(target); //const from = closestBody(target) //event.target as HTMLElement)
33
+ if ('forwards' === type) {
34
+ await updateCallback(); // updatetheDOMSomehow
35
+ // Snapshot.getSnapshot(from)
36
+ // const root = getRootViewController(from)
37
+ // const oldPath = new NavigationPath(from)
38
+ const root = [from, ...from.parents()]
39
+ .map((item) => item.component)
40
+ .filter(Boolean)
41
+ .at(-1);
42
+ // const { toolBarConfig: oldToolbars } = getComputedView(from) // const { toolBarConfig: oldToolbars, slot: oldSLot, page: oldPage } = getComputedView(from) //
43
+ // console.log(88, oldPage, oldPath.page, oldSLot, oldPath.slot, oldToolbars, oldPath.toolBarConfig)
44
+ // const oldToolbars = Snapshot.toolbarItems
45
+ // const { toolBarConfig: oldToolbars, host: oldHost } = getComputedView(from)
46
+ const tos = options.tos?.() ?? [...from.children()].map((item) => item?.hydrate()), //queryBodyAll(oldSLot), //[...oldPath.children()].map((item) => item.body).filter(Boolean),//
47
+ to = tos.at(-1),
48
+ // to = newPath?.body, //tos.slice(-1)?.pop?.(), //Snapshot.leaf, //
49
+ // newHost = newPath?.component, //{ host: newHost } = getComputedView(to),
50
+ newToolbars = tos.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item),
51
+ // .map((item) => item.toolBarConfig)
52
+ // .flat()
53
+ // .filter(Boolean), //queryToolbarConfigAll(oldSLot),
54
+ modalViews = tos.map((item) => item.component).filter((item) => !!item && item.matches('dialog')); //[...queryHostAll(oldPage)].filter?.((item) => item?.matches('dialog'))
55
+ // toFrame = Snapshot.leafContainer, //queryHostAll(from).slice(-1)?.pop?.(),
56
+ // toToolbars = Snapshot.leafToolbarItems
57
+ // dialogFrames = [toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item): item is HTMLDialogElement => item instanceof HTMLDialogElement) //[toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item) => item?.matches('dialog'))
58
+ // if ('DIALOG' === newHost?.tagName) {
59
+ // ;(newHost as HTMLDialogElement).showModal()
60
+ // debug(`⚡️ view-transition-start (${type})`)
61
+ // await Promise.allSettled(newHost.getAnimations().map(({ finished }) => finished))
62
+ // debug(`⚡️ view-transition-end (${type})`)
63
+ // return
64
+ // }
65
+ // purge
66
+ cleanup(root, 'backwards');
67
+ // prepare old
68
+ from.body?.classList.add(Snapshot.config['vt-fwd-class-name']);
69
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
70
+ for (const oldToolbar of from.toolBarConfig ?? [])
71
+ oldToolbar.classList.add('fwn'); // prepare navbs
72
+ // prepare new
73
+ const toolbarExclusion = 0 < modalViews.length
74
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar,body-view ~ tool-bar)')
75
+ : (value, index, array) => value.parentElement?.matches('tool-bar:not(body-view ~ tool-bar)'), bodyExclusion = 0 < modalViews.length ? (item) => item.body?.matches('scroll-view:not(dialog scroll-view)') : (value, index, array) => value;
76
+ for (const bti of newToolbars?.filter?.(toolbarExclusion) ?? [])
77
+ bti.classList.add('fwnn'); // for (const ti of newToolbars ?? []) ti.classList.add('fwnn') //
78
+ for (const bt of tos?.filter?.(bodyExclusion) ?? []) {
79
+ bt.body?.classList.add('fwdd'); //to?.classList.add('fwdd')
80
+ bt.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: bt.body }, bubbles: true, composed: true }));
81
+ }
82
+ if (0 < modalViews.length) {
83
+ for await (const el of modalViews)
84
+ el.showModal();
85
+ debug(`⚡️ view-dialog-transition-start (${type})`);
86
+ await Promise.allSettled(modalViews?.[0].getAnimations().map(({ finished }) => finished));
87
+ debug(`⚡️ view-dialog-transition-end (${type})`);
88
+ }
89
+ else {
90
+ debug(`⚡️ view-transition-start (${type})`);
91
+ await Promise.allSettled([...(from.body?.getAnimations().map(({ finished }) => finished) ?? []), ...(to?.body?.getAnimations().map(({ finished }) => finished) ?? [])]);
92
+ debug(`⚡️ view-transition-end (${type})`);
93
+ }
94
+ if (0 < (to?.component?.querySelectorAll(`.${Snapshot.config?.['vt-fwd-class-name']},.bwd`) ?? []).length)
95
+ return;
96
+ cleanup(root);
97
+ }
98
+ else {
99
+ // Snapshot.getSnapshot(from)
100
+ // const oldPath = new NavigationPath(from)
101
+ const root = [from, ...from.parents()]
102
+ .map((item) => item.component)
103
+ .filter(Boolean)
104
+ .at(-1); // const root = getRootViewController(from)
105
+ //const { toolBarConfig: oldToolbars, host: oldHost, page: oldPage, slot: oldSlot } = getComputedView(from)
106
+ const froms = [...from.children()].map((item) => item?.hydrate());
107
+ const oldToolbars = froms.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item), oldBodies = froms.map((item) => item.body).filter((item) => !!item);
108
+ // console.log(99, queryToolbarConfigAll(oldSlot), oldToolbars)
109
+ // if most-top effect is closing a modal, skip everything
110
+ if ('DIALOG' === from.component?.tagName) {
111
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
112
+ from.component.close();
113
+ debug(`⚡️ view-dialog-transition-start (${type})`);
114
+ await Promise.allSettled(from.component.getAnimations().map(({ finished }) => finished));
115
+ debug(`⚡️ view-dialog-transition-end (${type})`);
116
+ if (from.component.matches('[open]'))
117
+ return;
118
+ await updateCallback();
119
+ return; // just close modal
120
+ }
121
+ const to = [...from.parents()].at(0)?.hydrate(); //closestBody(oldPath.component?.parentElement ?? undefined)
122
+ if (!to)
123
+ return debug('Can not go backwards.'); // nothing to go back to
124
+ const tv = to.body?.closest('tab-view');
125
+ if (tv && to.body?.matches('tab-view>navigation-stack:has(> navigation-stack,> navigation-split-view)>:scope'))
126
+ if ('bottom-bar' !== tv.tabBarPlacement)
127
+ return;
128
+ // const { toolBarConfig: newToolbars } = getComputedView(to.body)
129
+ // purge
130
+ cleanup(root, 'forwards');
131
+ // prepare new
132
+ for (const ti of to.toolBarConfig ?? [])
133
+ ti.classList.add('bwnn');
134
+ to.body?.classList.add('bwdd');
135
+ to.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: to.body }, bubbles: true, composed: true }));
136
+ // prepare old
137
+ const inbetweenModals = froms.map((item) => item.component).filter((item) => !!item && item.matches('dialog[open]')), //queryHostAll(oldPage).filter?.((item) => item.matches('dialog[open]')) ?? [], // FIXME: TEst this, added oldHost too
138
+ toolbarExclusion = 0 < inbetweenModals.length
139
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar)')
140
+ : (value, index, array) => value, bodyExclusion = 0 < inbetweenModals.length ? (item) => item?.matches('scroll-view:not(dialog scroll-view)') : (item) => item;
141
+ for (const ti of [...(from.toolBarConfig ?? []), ...(oldToolbars?.filter?.(toolbarExclusion) ?? [])])
142
+ ti.classList.add('bwn');
143
+ for (const nn of [from.body, ...oldBodies?.filter?.(bodyExclusion)]) {
144
+ nn?.classList.add('bwd'); //from?.classList.add('bwd')
145
+ nn?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: nn }, bubbles: true, composed: true }));
146
+ }
147
+ for (const el of inbetweenModals)
148
+ el.close(); // close old inbetween modals
149
+ // capture trans
150
+ debug(`⚡️ view-transition-start (${type})`);
151
+ await Promise.allSettled([...(from.body?.getAnimations().map(({ finished }) => finished) ?? []), ...(to.body?.getAnimations().map(({ finished }) => finished) ?? [])]);
152
+ debug(`⚡️ view-transition-end (${type})`);
153
+ if (to.body?.closest(`.bwd,.${Snapshot.config?.['vt-fwd-class-name']}`))
154
+ return;
155
+ cleanup(root);
156
+ // remove or hide
157
+ await updateCallback();
158
+ }
159
+ };
@@ -0,0 +1 @@
1
+ export default function debug(...data: any[]): void;
@@ -0,0 +1,3 @@
1
+ export default function debug(...data) {
2
+ return console.debug(...data); //console.debug('%c swift-wc', 'color:hsl(200,70%,45%);font-weight:600', ...data)
3
+ }
@@ -1,10 +1,11 @@
1
- import cash from './cash';
2
1
  export { default as add } from './add';
3
- export { default as ensurePlaceholder } from './ensure-placeholder';
2
+ export { default as $ } from './cash';
4
3
  export { default as clamp } from './clamp';
5
4
  export { default as compareBigDecimals } from './compare-big-decimals';
6
5
  export { default as cssTime } from './css-time';
7
6
  export { default as debounce } from './debounce';
7
+ export { default as debug } from './debug';
8
+ export { default as ensurePlaceholder } from './ensure-placeholder';
8
9
  export { default as frame } from './frame';
9
10
  export { default as isInside } from './is-inside';
10
11
  export { default as kebabCase } from './kebab-case';
@@ -16,4 +17,3 @@ export { default as sleep } from './sleep';
16
17
  export { default as slowHideShow } from './slow-hide-show';
17
18
  export { default as timeout } from './timeout';
18
19
  export { default as touchGlass } from './touch-glass';
19
- export declare const $: typeof cash;
@@ -1,11 +1,13 @@
1
1
  // import * as _intl from './intl'
2
- import cash from './cash';
2
+ // import cash from './cash'
3
3
  export { default as add } from './add';
4
- export { default as ensurePlaceholder } from './ensure-placeholder';
4
+ export { default as $ } from './cash';
5
5
  export { default as clamp } from './clamp';
6
6
  export { default as compareBigDecimals } from './compare-big-decimals';
7
7
  export { default as cssTime } from './css-time';
8
8
  export { default as debounce } from './debounce';
9
+ export { default as debug } from './debug';
10
+ export { default as ensurePlaceholder } from './ensure-placeholder';
9
11
  export { default as frame } from './frame';
10
12
  export { default as isInside } from './is-inside';
11
13
  export { default as kebabCase } from './kebab-case';
@@ -17,4 +19,4 @@ export { default as sleep } from './sleep';
17
19
  export { default as slowHideShow } from './slow-hide-show';
18
20
  export { default as timeout } from './timeout';
19
21
  export { default as touchGlass } from './touch-glass';
20
- export const $ = cash;
22
+ // export const $: typeof cash = cash
@@ -7,6 +7,15 @@ export declare abstract class DialogBase extends HTMLDialogElement {
7
7
  connectedCallback(): void;
8
8
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
9
9
  }
10
+ export declare abstract class InputBase extends HTMLInputElement {
11
+ static polyfillExtends: "input";
12
+ static polyfillConnectedCallback(el: HTMLInputElement): void;
13
+ static polyfillDisconnectedCallback(el: HTMLInputElement): void;
14
+ static polyfillAttributeChangedCallback(entries: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
15
+ disconnectedCallback(): void;
16
+ connectedCallback(): void;
17
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
18
+ }
10
19
  export declare abstract class ButtonBase extends HTMLButtonElement {
11
20
  static polyfillExtends: "button";
12
21
  static polyfillConnectedCallback(el: HTMLButtonElement): void;
@@ -21,6 +21,29 @@ export class DialogBase extends HTMLDialogElement {
21
21
  ctor.polyfillAttributeChangedCallback([entry]);
22
22
  }
23
23
  }
24
+ export class InputBase extends HTMLInputElement {
25
+ static polyfillExtends = 'input';
26
+ static polyfillConnectedCallback(el) { }
27
+ static polyfillDisconnectedCallback(el) { }
28
+ static polyfillAttributeChangedCallback(entries) { } //MutationRecord[]) {}
29
+ disconnectedCallback() {
30
+ const ctor = this.constructor;
31
+ ctor.polyfillDisconnectedCallback(this);
32
+ }
33
+ connectedCallback() {
34
+ const ctor = this.constructor;
35
+ ctor.polyfillConnectedCallback(this);
36
+ }
37
+ attributeChangedCallback(name, oldValue, newValue) {
38
+ const ctor = this.constructor;
39
+ const entry = {
40
+ attributeName: name,
41
+ oldValue,
42
+ target: this,
43
+ };
44
+ ctor.polyfillAttributeChangedCallback([entry]);
45
+ }
46
+ }
24
47
  export class ButtonBase extends HTMLButtonElement {
25
48
  static polyfillExtends = 'button';
26
49
  static polyfillConnectedCallback(el) { }
@@ -2,7 +2,7 @@ export declare class Snapshot {
2
2
  #private;
3
3
  static get breakpoints(): ReadonlyMap<string, boolean> | undefined;
4
4
  static on: EventTarget;
5
- static readonly waitReady: Promise<[unknown, void]>;
5
+ static readonly waitReady: Promise<[void, void]>;
6
6
  static waitReadyFor<T extends HTMLElement>(element: T): Promise<T | null>;
7
7
  static get config(): Record<string, string> | undefined;
8
8
  static setOwnConfig(): Promise<void>;