@swiftwc/ui 0.0.0-dev.34 → 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/internal/utils/ensure-placeholder.d.ts +1 -0
- package/generated/internal/utils/{button-role.js → ensure-placeholder.js} +7 -14
- package/generated/internal/utils/index.d.ts +1 -1
- package/generated/internal/utils/index.js +1 -1
- package/package.json +1 -1
- 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
|
}
|
|
@@ -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
|
|
@@ -48,15 +45,11 @@ function ensurePlaceholder(el, role, titleKey) {
|
|
|
48
45
|
// } else label?.remove()
|
|
49
46
|
// })
|
|
50
47
|
}
|
|
51
|
-
export default function (
|
|
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(host, new MutationObserver(() => ensurePlaceholder(target, role, overiderTitle)));
|
|
59
|
-
observing.get(host)?.observe(host, {
|
|
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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (host: HTMLElement, target: HTMLElement, role: string | null, titleKey?: string | null): void;
|