@swiftwc/ui 0.0.0-dev.33 → 0.0.0-dev.35
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/generated/components/bordered-button.js +2 -2
- package/generated/components/bordered-prominent-button.js +2 -2
- package/generated/components/borderless-button.js +2 -2
- package/generated/components/glass-button.js +2 -2
- package/generated/components/glass-prominent-button.js +2 -2
- package/generated/components/tool-bar-item.d.ts +2 -1
- package/generated/components/tool-bar-item.js +19 -8
- package/generated/css/index.css +11 -4
- package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
- package/generated/internal/utils/{button-role.js → ensure-placeholder.js} +6 -13
- package/generated/internal/utils/index.d.ts +1 -1
- package/generated/internal/utils/index.js +1 -1
- package/package.json +1 -1
- package/scss/components/_confirmation-dialog.scss +12 -4
- package/generated/internal/utils/button-role.d.ts +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
@@ -31,7 +31,7 @@ export class BorderedButton extends ButtonBase {
|
|
|
31
31
|
case 'title-key':
|
|
32
32
|
case 'role':
|
|
33
33
|
Snapshot.waitReady.then(() => {
|
|
34
|
-
|
|
34
|
+
ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'));
|
|
35
35
|
});
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
@@ -31,7 +31,7 @@ export class BorderedProminentButton extends ButtonBase {
|
|
|
31
31
|
case 'title-key':
|
|
32
32
|
case 'role':
|
|
33
33
|
Snapshot.waitReady.then(() => {
|
|
34
|
-
|
|
34
|
+
ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'));
|
|
35
35
|
});
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
@@ -31,7 +31,7 @@ export class BorderlessButton extends ButtonBase {
|
|
|
31
31
|
case 'title-key':
|
|
32
32
|
case 'role':
|
|
33
33
|
Snapshot.waitReady.then(() => {
|
|
34
|
-
|
|
34
|
+
ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'));
|
|
35
35
|
});
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
@@ -31,7 +31,7 @@ export class GlassButton extends ButtonBase {
|
|
|
31
31
|
case 'title-key':
|
|
32
32
|
case 'role':
|
|
33
33
|
Snapshot.waitReady.then(() => {
|
|
34
|
-
|
|
34
|
+
ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'));
|
|
35
35
|
});
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
import { Snapshot } from '../snapshot';
|
|
5
5
|
/**
|
|
@@ -31,7 +31,7 @@ export class GlassProminentButton extends ButtonBase {
|
|
|
31
31
|
case 'title-key':
|
|
32
32
|
case 'role':
|
|
33
33
|
Snapshot.waitReady.then(() => {
|
|
34
|
-
|
|
34
|
+
ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'));
|
|
35
35
|
});
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare class ToolBarItem extends HTMLElement {
|
|
2
|
+
#private;
|
|
2
3
|
static get observedAttributes(): string[];
|
|
3
4
|
constructor();
|
|
4
|
-
connectedCallback(): void;
|
|
5
5
|
disconnectedCallback(): void;
|
|
6
|
+
connectedCallback(): void;
|
|
6
7
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
7
8
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
3
3
|
import { Snapshot } from '../snapshot';
|
|
4
4
|
export class ToolBarItem extends HTMLElement {
|
|
5
5
|
static get observedAttributes() {
|
|
6
6
|
return ['slot', 'data-previous-slot', 'title-key'];
|
|
7
7
|
}
|
|
8
|
+
#mutationObserver;
|
|
8
9
|
constructor() {
|
|
9
10
|
super();
|
|
10
11
|
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
console.debug(`${ToolBarItem.name} ⚡️ disconnect`);
|
|
14
|
+
this.#mutationObserver?.disconnect();
|
|
15
|
+
CleanupRegistry.unregister(this);
|
|
16
|
+
}
|
|
11
17
|
connectedCallback() {
|
|
12
18
|
console.debug(`${ToolBarItem.name} ⚡️ connect`);
|
|
13
19
|
CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, (evt) => {
|
|
@@ -32,20 +38,25 @@ export class ToolBarItem extends HTMLElement {
|
|
|
32
38
|
// ) // Initial check
|
|
33
39
|
// })
|
|
34
40
|
}
|
|
35
|
-
disconnectedCallback() {
|
|
36
|
-
console.debug(`${ToolBarItem.name} ⚡️ disconnect`);
|
|
37
|
-
CleanupRegistry.unregister(this);
|
|
38
|
-
}
|
|
39
41
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
40
42
|
console.debug(`${ToolBarItem.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
41
43
|
switch (name) {
|
|
42
44
|
case 'slot':
|
|
43
45
|
case 'data-previous-slot':
|
|
44
46
|
case 'title-key':
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
this.#mutationObserver?.disconnect();
|
|
48
|
+
const role = this.getAttribute('data-previous-slot') ?? this.getAttribute('slot') ?? '', tKey = this.getAttribute('title-key');
|
|
49
|
+
if (['confirmation-action', 'cancellation-action'].includes(role))
|
|
47
50
|
Snapshot.waitReady.then(() => {
|
|
48
|
-
|
|
51
|
+
ensurePlaceholder(this.querySelector(':scope>button'), role, tKey);
|
|
52
|
+
this.#mutationObserver = new MutationObserver((mutations) => {
|
|
53
|
+
for (const { target } of mutations)
|
|
54
|
+
if (target instanceof HTMLElement && target)
|
|
55
|
+
ensurePlaceholder(this.querySelector(':scope>button'), role, tKey);
|
|
56
|
+
});
|
|
57
|
+
this.#mutationObserver.observe(this, {
|
|
58
|
+
childList: true,
|
|
59
|
+
});
|
|
49
60
|
});
|
|
50
61
|
break;
|
|
51
62
|
}
|
package/generated/css/index.css
CHANGED
|
@@ -1710,7 +1710,7 @@
|
|
|
1710
1710
|
color: var(--text, );
|
|
1711
1711
|
touch-action: none;
|
|
1712
1712
|
position: fixed;
|
|
1713
|
-
inline-size:
|
|
1713
|
+
inline-size: var(--confirmation--dialog-inline-size, anchor-size());
|
|
1714
1714
|
block-size: fit-content;
|
|
1715
1715
|
height: auto;
|
|
1716
1716
|
max-inline-size: var(--confirmation--dialog-max-inline-size, );
|
|
@@ -1718,6 +1718,7 @@
|
|
|
1718
1718
|
margin-block: var(--confirmation--dialog-margin-block, );
|
|
1719
1719
|
margin-inline: var(--confirmation--dialog-margin-inline, );
|
|
1720
1720
|
transform: var(--confirmation--dialog-scale, );
|
|
1721
|
+
opacity: var(--confirmation--dialog-opacity, );
|
|
1721
1722
|
position-anchor: --confirmation-dialog;
|
|
1722
1723
|
position-area: center;
|
|
1723
1724
|
overflow: clip;
|
|
@@ -1727,24 +1728,30 @@
|
|
|
1727
1728
|
padding-block: 1rem;
|
|
1728
1729
|
padding-inline: 1rem;
|
|
1729
1730
|
gap: 1rem;
|
|
1730
|
-
--confirmation--dialog-scale: scale(0);
|
|
1731
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
1732
|
+
--confirmation--dialog-opacity: 0.8;
|
|
1731
1733
|
}
|
|
1732
1734
|
:where([is=confirmation-dialog][open]) {
|
|
1735
|
+
--confirmation--dialog-inline-size: min(20rem, 80vw);
|
|
1733
1736
|
--confirmation--dialog-max-inline-size: min(20rem, 80vw);
|
|
1734
1737
|
--confirmation--dialog-max-block-size: 80vh;
|
|
1735
1738
|
--confirmation--dialog-margin-block: max(env(safe-area-inset-top), var(--menu-spacing)) max(env(safe-area-inset-bottom), var(--menu-spacing));
|
|
1736
1739
|
--confirmation--dialog-margin-inline: max(env(safe-area-inset-left), var(--menu-spacing)) max(env(safe-area-inset-right), var(--menu-spacing));
|
|
1737
1740
|
--confirmation--dialog-scale: scale(1);
|
|
1741
|
+
--confirmation--dialog-opacity: 1;
|
|
1738
1742
|
}
|
|
1739
1743
|
@starting-style {
|
|
1740
1744
|
:where([is=confirmation-dialog][open]) {
|
|
1741
|
-
--confirmation--dialog-scale: scale(0);
|
|
1745
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
1746
|
+
--confirmation--dialog-opacity: 0.8;
|
|
1742
1747
|
}
|
|
1743
1748
|
}
|
|
1744
1749
|
:where([is=confirmation-dialog][closing]) {
|
|
1750
|
+
--confirmation--dialog-inline-size: anchor-size();
|
|
1745
1751
|
--confirmation--dialog-max-inline-size: anchor-size();
|
|
1746
1752
|
--confirmation--dialog-max-block-size: anchor-size();
|
|
1747
|
-
--confirmation--dialog-scale: scale(0);
|
|
1753
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
1754
|
+
--confirmation--dialog-opacity: 0;
|
|
1748
1755
|
}
|
|
1749
1756
|
}
|
|
1750
1757
|
@layer sw-components {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (target: HTMLElement | null, role: string | null, titleKey?: string | null): void;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { I18n } from '../../i18n';
|
|
2
2
|
import { Snapshot } from '../../snapshot';
|
|
3
|
-
import { CleanupRegistry } from '../class/cleanup-registry';
|
|
4
3
|
import { default as $ } from './cash';
|
|
5
|
-
|
|
6
|
-
const observing = new WeakMap();
|
|
7
|
-
function ensurePlaceholder(el, role, titleKey) {
|
|
4
|
+
function renderPlaceholder(el, role, titleKey) {
|
|
8
5
|
// if (!el.isConnected) return
|
|
9
6
|
// self.requestAnimationFrame(() => {
|
|
10
7
|
// if (!el.isConnected) return
|
|
@@ -49,14 +46,10 @@ function ensurePlaceholder(el, role, titleKey) {
|
|
|
49
46
|
// })
|
|
50
47
|
}
|
|
51
48
|
export default function (target, role, titleKey) {
|
|
49
|
+
if (!target)
|
|
50
|
+
return;
|
|
52
51
|
const overiderTitle = typeof titleKey === 'string' && titleKey in I18n.t('ButtonRole') ? titleKey : undefined;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
CleanupRegistry.unregister(target, 'i18n');
|
|
57
|
-
CleanupRegistry.register(target, onoff('localechange', () => ensurePlaceholder(target, role, overiderTitle), I18n.on).on(), 'i18n');
|
|
58
|
-
observing.set(target, new MutationObserver(() => ensurePlaceholder(target, role, overiderTitle)));
|
|
59
|
-
observing.get(target)?.observe(target, {
|
|
60
|
-
childList: true,
|
|
61
|
-
});
|
|
52
|
+
renderPlaceholder(target, role, overiderTitle);
|
|
53
|
+
// CleanupRegistry.unregister(target, 'i18n')
|
|
54
|
+
// CleanupRegistry.register(target, onoff('localechange', () => renderPlaceholder(target, role, overiderTitle), I18n.on).on(), 'i18n')
|
|
62
55
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cash from './cash';
|
|
2
2
|
export { default as add } from './add';
|
|
3
|
-
export { default as
|
|
3
|
+
export { default as ensurePlaceholder } from './ensure-placeholder';
|
|
4
4
|
export { default as clamp } from './clamp';
|
|
5
5
|
export { default as compareBigDecimals } from './compare-big-decimals';
|
|
6
6
|
export { default as cssTime } from './css-time';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// import * as _intl from './intl'
|
|
2
2
|
import cash from './cash';
|
|
3
3
|
export { default as add } from './add';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as ensurePlaceholder } from './ensure-placeholder';
|
|
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';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
position: fixed;
|
|
14
14
|
|
|
15
|
-
inline-size:
|
|
15
|
+
inline-size: var(--confirmation--dialog-inline-size, anchor-size());
|
|
16
16
|
block-size: fit-content;
|
|
17
17
|
height: auto; // safari
|
|
18
18
|
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
transform: var(--confirmation--dialog-scale,);
|
|
28
28
|
// transform-origin: top left;
|
|
29
29
|
|
|
30
|
+
opacity: var(--confirmation--dialog-opacity,);
|
|
31
|
+
|
|
30
32
|
position-anchor: --confirmation-dialog; // overriden
|
|
31
33
|
position-area: center;
|
|
32
34
|
|
|
@@ -41,11 +43,13 @@
|
|
|
41
43
|
gap: 1rem;
|
|
42
44
|
|
|
43
45
|
// finally
|
|
44
|
-
--confirmation--dialog-scale: scale(0);
|
|
46
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
47
|
+
--confirmation--dialog-opacity: 0.8;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
&[open] {
|
|
48
51
|
:where(&) {
|
|
52
|
+
--confirmation--dialog-inline-size: min(20rem, 80vw);
|
|
49
53
|
// --confirmation--dialog-min-inline-size: min(20rem, 80svw);
|
|
50
54
|
|
|
51
55
|
--confirmation--dialog-max-inline-size: min(20rem, 80vw);
|
|
@@ -55,21 +59,25 @@
|
|
|
55
59
|
--confirmation--dialog-margin-inline: max(env(safe-area-inset-left), var(--menu-spacing)) max(env(safe-area-inset-right), var(--menu-spacing));
|
|
56
60
|
|
|
57
61
|
--confirmation--dialog-scale: scale(1);
|
|
62
|
+
--confirmation--dialog-opacity: 1;
|
|
58
63
|
|
|
59
64
|
@starting-style {
|
|
60
|
-
--confirmation--dialog-scale: scale(0);
|
|
65
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
66
|
+
--confirmation--dialog-opacity: 0.8;
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
&[closing] {
|
|
66
72
|
:where(&) {
|
|
73
|
+
--confirmation--dialog-inline-size: anchor-size();
|
|
67
74
|
// --confirmation--dialog-min-inline-size: anchor-size();
|
|
68
75
|
|
|
69
76
|
--confirmation--dialog-max-inline-size: anchor-size();
|
|
70
77
|
--confirmation--dialog-max-block-size: anchor-size();
|
|
71
78
|
|
|
72
|
-
--confirmation--dialog-scale: scale(0);
|
|
79
|
+
--confirmation--dialog-scale: scale(0.7);
|
|
80
|
+
--confirmation--dialog-opacity: 0;
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (target: HTMLElement, role: string | null, titleKey?: string | null): void;
|