@swiftwc/ui 0.0.0-dev.11 → 0.0.0-dev.14

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.
@@ -14,6 +14,11 @@ for (const [k, Ctor] of Object.entries(Components)) {
14
14
  customElements.define(is, Ctor, { extends: Ctor.polyfillExtends });
15
15
  if (!(document.createElement(Ctor.polyfillExtends, { is }) instanceof Ctor))
16
16
  polyfills.set(is, Ctor);
17
+ // const testEl = document.createElement('template')
18
+ // testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
19
+ // const testNode = testEl.content.firstElementChild,
20
+ if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`) instanceof Ctor))
21
+ polyfills.set(is, Ctor);
17
22
  continue;
18
23
  }
19
24
  if (!customElements.get(is))
@@ -25,9 +25,9 @@ export class TabBar extends DialogBase {
25
25
  }), el).on());
26
26
  // })
27
27
  }
28
- static #handleClick = async (event) => {
29
- console.debug(`${TabBar.name} ⚡️ ${event?.type}`);
30
- if ('DIALOG' === event.target.tagName && 'tab-bar' === event.target.getAttribute('is'))
31
- event?.target?.close?.();
28
+ static #handleClick = async (evt) => {
29
+ console.debug(`${TabBar.name} ⚡️ ${evt?.type}`);
30
+ if ('DIALOG' === evt.target.tagName && 'tab-bar' === evt.target.getAttribute('is'))
31
+ evt?.target?.close?.();
32
32
  };
33
33
  }
@@ -6,8 +6,8 @@ export class ToolBarItem extends HTMLElement {
6
6
  }
7
7
  connectedCallback() {
8
8
  console.debug(`${ToolBarItem.name} ⚡️ connect`);
9
- CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, (event) => {
10
- if (event.target.closest('menu-view[open]'))
9
+ CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, (evt) => {
10
+ if (evt.target.closest('menu-view[open]'))
11
11
  return false;
12
12
  return true;
13
13
  }), this).on());
@@ -338,6 +338,7 @@
338
338
  @layer sw-base {
339
339
  :root {
340
340
  interpolate-size: allow-keywords;
341
+ touch-action: manipulation;
341
342
  }
342
343
  *,
343
344
  *::before,
@@ -4365,6 +4366,7 @@
4365
4366
  position: absolute;
4366
4367
  background-color: rgba(0, 0, 0, 0.4);
4367
4368
  pointer-events: none;
4369
+ touch-action: none;
4368
4370
  position-anchor: --tab-view-tabbar-selection;
4369
4371
  inset: anchor(--tab-view-tabbar-selection top) auto auto anchor(--tab-view-tabbar-selection left);
4370
4372
  inline-size: anchor-size();
@@ -4376,6 +4378,7 @@
4376
4378
  overscroll-behavior: contain;
4377
4379
  -webkit-overflow-scrolling: touch;
4378
4380
  pointer-events: all;
4381
+ touch-action: none;
4379
4382
  grid-auto-flow: column;
4380
4383
  grid-template-rows: minmax(0, 1fr);
4381
4384
  margin-inline: var(--safe-area-inset-left) var(--safe-area-inset-right);
@@ -4527,6 +4530,7 @@
4527
4530
  position: absolute;
4528
4531
  background-color: rgba(0, 0, 0, 0.4);
4529
4532
  pointer-events: none;
4533
+ touch-action: none;
4530
4534
  position-anchor: --tab-view-sidebar-selection;
4531
4535
  inset: anchor(--tab-view-sidebar-selection top) auto auto anchor(--tab-view-sidebar-selection left);
4532
4536
  inline-size: anchor-size();
@@ -1,28 +1,73 @@
1
- function onClick(event) {
2
- const el = event.target.closest('button,summary');
1
+ const touchList = new WeakMap();
2
+ function onDown(evt) {
3
+ const el = evt.target.closest('button,summary');
3
4
  if (!el)
4
5
  return;
6
+ touchList.set(el, setTimeout(() => {
7
+ if (!touchList.has(el))
8
+ return;
9
+ el.classList.add('active');
10
+ }, 70));
11
+ el.addEventListener('pointerleave', onLeave, { once: true, passive: true });
12
+ el.closest('scroll-view')?.addEventListener('scroll', onScroll, { once: true, passive: true });
13
+ }
14
+ function onOver(evt) {
15
+ const el = evt.target.closest('button,summary');
16
+ if (!el)
17
+ return;
18
+ if (0 === evt.buttons)
19
+ return;
5
20
  el.classList.add('active');
6
- el.addEventListener('pointerleave', onCancel);
21
+ el.removeEventListener('pointerover', onOver);
22
+ el.addEventListener('pointerleave', onLeave, { once: true, passive: true });
7
23
  }
8
- function onCancel(event) {
9
- const el = event.target.closest('button,summary');
24
+ function onLeave(evt) {
25
+ const el = evt.target.closest('button,summary');
10
26
  if (!el)
11
27
  return;
12
- self.requestAnimationFrame(() => {
13
- el.removeEventListener('pointerleave', onCancel);
28
+ el.addEventListener('pointerover', onOver, { once: true, passive: true });
29
+ // self.requestAnimationFrame(() => {
30
+ el.removeEventListener('pointerleave', onLeave);
31
+ el.closest('scroll-view')?.removeEventListener('scroll', onScroll);
32
+ el.classList.remove('active');
33
+ if (touchList.has(el))
34
+ clearTimeout(touchList.get(el));
35
+ touchList.delete(el);
36
+ // })
37
+ }
38
+ function onCancel(evt) {
39
+ const el = evt.target.closest('button,summary');
40
+ if (!el)
41
+ return;
42
+ // self.requestAnimationFrame(() => {
43
+ el.removeEventListener('pointerleave', onLeave);
44
+ el.removeEventListener('pointerover', onOver);
45
+ el.closest('scroll-view')?.removeEventListener('scroll', onScroll);
46
+ el.classList.remove('active');
47
+ if (touchList.has(el))
48
+ clearTimeout(touchList.get(el));
49
+ touchList.delete(el);
50
+ // })
51
+ }
52
+ function onScroll(evt) {
53
+ for (const el of evt.target.querySelectorAll('button,summary')) {
14
54
  el.classList.remove('active');
15
- });
55
+ if (touchList.has(el))
56
+ clearTimeout(touchList.get(el));
57
+ touchList.delete(el);
58
+ el.removeEventListener('pointerleave', onLeave);
59
+ el.removeEventListener('pointerover', onOver);
60
+ }
16
61
  }
17
- const makePointerDownHandler = (target) => {
18
- return onClick;
62
+ const makePointerdownHandler = (target) => {
63
+ return onDown;
19
64
  }, makePointerCancelHandler = (target) => {
20
65
  return onCancel;
21
66
  };
22
67
  export default function (t) {
23
- const onListener = makePointerDownHandler(t), offListener = makePointerCancelHandler(t);
68
+ const downListener = makePointerdownHandler(t), offListener = makePointerCancelHandler(t);
24
69
  return [
25
- { types: 'pointerdown', listener: onListener, addOptions: { passive: true } },
70
+ { types: 'pointerdown', listener: downListener, addOptions: { passive: true } },
26
71
  { types: 'pointerup pointercancel', listener: offListener, addOptions: { passive: true } },
27
72
  ];
28
73
  }
@@ -1,19 +1,19 @@
1
- const makePointerDownHandler = (target, targetCallback, checkCallback) => {
1
+ const makePointerdownHandler = (target, targetCallback, checkCallback) => {
2
2
  return function (evt) {
3
3
  // if (event.pointerType !== 'touch') return
4
4
  if (!checkCallback(evt))
5
5
  return;
6
6
  targetCallback(target).toggleAttribute('touch-glass', true);
7
7
  };
8
- }, makePointerCancelHandler = (target, targetCallback) => {
8
+ }, makePointercancelHandler = (target, targetCallback) => {
9
9
  return function (evt) {
10
10
  targetCallback(target).toggleAttribute('touch-glass', false);
11
11
  };
12
12
  };
13
13
  export default function (t, targetCallback, checkCallback) {
14
- const onListener = makePointerDownHandler(t, targetCallback, checkCallback), offListener = makePointerCancelHandler(t, targetCallback);
14
+ const downListener = makePointerdownHandler(t, targetCallback, checkCallback), cancelListener = makePointercancelHandler(t, targetCallback);
15
15
  return [
16
- { types: 'pointerdown', listener: onListener, addOptions: { passive: true } },
17
- { types: 'pointerup pointercancel pointerleave', listener: offListener, addOptions: { passive: true } },
16
+ { types: 'pointerdown', listener: downListener, addOptions: { passive: true } },
17
+ { types: 'pointerup pointercancel pointerleave', listener: cancelListener, addOptions: { passive: true } },
18
18
  ];
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftwc/ui",
3
- "version": "0.0.0-dev.11",
3
+ "version": "0.0.0-dev.14",
4
4
  "description": "Elegant SwiftUI-inspired web components for standalone web apps and web extensions.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "scripts": {
55
55
  "prebuild": "rm -rf generated",
56
- "build": "npm run build:ts && npm run build:scss",
56
+ "build": "npm run build:ts && npm run build:scss && npm run build:manifest && npm run build:barrels",
57
57
  "build:ts:watch": "npm run prebuild && tsc --watch",
58
58
  "build:ts": "tsc",
59
59
  "build:scss": "sass --style=expanded --no-source-map scss/index.scss generated/css/index.css",
@@ -11,6 +11,8 @@
11
11
 
12
12
  :root {
13
13
  interpolate-size: allow-keywords;
14
+
15
+ touch-action: manipulation; // Disabling double-tap to zoom removes the need for browsers to delay the generation of click events when the user taps the screen
14
16
  }
15
17
 
16
18
  *,
@@ -8,6 +8,7 @@
8
8
  position: absolute;
9
9
  background-color: rgba(0, 0, 0, 0.4);
10
10
  pointer-events: none;
11
+ touch-action: none;
11
12
 
12
13
  position-anchor: #{$anchor-name};
13
14
  // position-area: center;
@@ -161,6 +162,8 @@
161
162
 
162
163
  pointer-events: all;
163
164
 
165
+ touch-action: none; // important for backdrop pans!
166
+
164
167
  grid-auto-flow: column;
165
168
  grid-template-rows: minmax(0, 1fr);
166
169