@swiftwc/ui 0.0.0-dev.95 → 0.0.0-dev.96
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/client/index.js +7 -7
- package/generated/components/alert-dialog.d.ts +1 -1
- package/generated/components/alert-dialog.js +1 -1
- package/generated/components/content-unavailable.js +11 -11
- package/generated/components/date-picker.js +15 -15
- package/generated/components/fine-tooltip.js +2 -1
- package/generated/components/image-view.js +3 -2
- package/generated/components/label-view.d.ts +4 -0
- package/generated/components/label-view.js +11 -7
- package/generated/components/labeled-content.d.ts +5 -0
- package/generated/components/labeled-content.js +18 -12
- package/generated/components/menu-view.js +12 -12
- package/generated/components/navigation-title.js +2 -1
- package/generated/components/picker-view.d.ts +1 -1
- package/generated/components/picker-view.js +51 -50
- package/generated/components/progress-view.js +20 -19
- package/generated/components/scroll-view.js +14 -14
- package/generated/components/section-view.js +11 -11
- package/generated/components/table-view.js +34 -34
- package/generated/components/text-field.d.ts +2 -0
- package/generated/components/text-field.js +13 -11
- package/generated/components/toggle-view.js +30 -13
- package/generated/components/tool-bar.js +27 -27
- package/generated/internal/utils/cash/index.d.ts +4 -3
- package/generated/internal/utils/cash/index.js +4 -2
- package/generated/internal/utils/ensure-placeholder.js +2 -1
- package/generated/morphdom/index.d.ts +4 -2
- package/generated/morphdom/index.js +4 -2
- package/generated/morphdom/morph.d.ts +2 -2
- package/generated/morphdom/morph.js +3 -2
- package/generated/morphdom/query-morph.d.ts +2 -2
- package/generated/morphdom/query-morph.js +1 -1
- package/generated/morphdom/render-to-string.d.ts +12 -0
- package/generated/morphdom/render-to-string.js +48 -0
- package/generated/morphdom/unsafe-html.d.ts +2 -0
- package/generated/morphdom/unsafe-html.js +4 -0
- package/generated/tpl/html.js +4 -0
- package/generated/tpl/index.d.ts +2 -0
- package/generated/tpl/index.js +2 -0
- package/generated/tpl/is-template-result.d.ts +3 -0
- package/generated/tpl/is-template-result.js +1 -0
- package/package.json +1 -1
- package/web-components.html-data/en.json +64 -116
- package/generated/morphdom/html.d.ts +0 -8
- package/generated/morphdom/html.js +0 -37
|
@@ -19,7 +19,7 @@ for (const [k, Ctor] of Object.entries(Components)) {
|
|
|
19
19
|
// const testEl = document.createElement('template')
|
|
20
20
|
// testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
|
|
21
21
|
// const testNode = testEl.content.firstElementChild,
|
|
22
|
-
if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
|
|
22
|
+
if (!($(html `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
|
|
23
23
|
polyfills.set(is, Ctor);
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
@@ -119,7 +119,7 @@ const handleHelp = ({ target, relatedTarget }) => {
|
|
|
119
119
|
if (relatedTarget instanceof HTMLElement && trigger.contains(relatedTarget))
|
|
120
120
|
return;
|
|
121
121
|
const newAnchorName = `--help-${self.crypto.randomUUID()}`;
|
|
122
|
-
const tooltip = $(`<fine-tooltip></fine-tooltip>`, '>1');
|
|
122
|
+
const tooltip = $(html `<fine-tooltip></fine-tooltip>`, '>1');
|
|
123
123
|
trigger.style.setProperty('anchor-name', newAnchorName);
|
|
124
124
|
tooltip.style.setProperty('position-anchor', newAnchorName);
|
|
125
125
|
document.body.appendChild(tooltip);
|
|
@@ -236,26 +236,26 @@ export const alert = (title, message, actions, options) => {
|
|
|
236
236
|
};
|
|
237
237
|
export const confirmationDialog = async (trigger, title, message, actions, options) => {
|
|
238
238
|
const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
|
|
239
|
-
const dialog = $(`<dialog is="confirmation-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
|
|
239
|
+
const dialog = $(html `<dialog is="confirmation-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(html `<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
|
|
240
240
|
trigger.style.setProperty('anchor-name', newAnchorName, 'important'); //$.prop('anchor-name', newAnchorName, trigger, 'important')
|
|
241
241
|
dialog.style.setProperty('position-anchor', newAnchorName); //$.prop('position-anchor', newAnchorName, dialog)
|
|
242
242
|
if (title && false !== options?.titleVisibility) {
|
|
243
|
-
const label = $(`<label-view font="headline"></label-view>`, '>1');
|
|
243
|
+
const label = $(html `<label-view font="headline"></label-view>`, '>1');
|
|
244
244
|
label.setAttribute('title', title);
|
|
245
245
|
vStack.insertAdjacentElement('beforeend', label);
|
|
246
246
|
}
|
|
247
247
|
if (message && false !== options?.titleVisibility) {
|
|
248
|
-
const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
|
|
248
|
+
const label = $(html `<label-view foreground="secondary" font="callout"></label-view>`, '>1');
|
|
249
249
|
label.setAttribute('title', message);
|
|
250
250
|
vStack.insertAdjacentElement('beforeend', label);
|
|
251
251
|
}
|
|
252
252
|
for (const [index, action] of (actions ?? []).entries()) {
|
|
253
|
-
const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
253
|
+
const btn = $(html `<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
254
254
|
btn.setAttribute('value', `${index}`);
|
|
255
255
|
if (action?.role)
|
|
256
256
|
btn.setAttribute('role', action.role);
|
|
257
257
|
if (action.label || action.image) {
|
|
258
|
-
const label = $(`<label-view></label-view>`, '>1');
|
|
258
|
+
const label = $(html `<label-view></label-view>`, '>1');
|
|
259
259
|
if (action.label)
|
|
260
260
|
label.setAttribute('title', action.label);
|
|
261
261
|
if (action.image)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DialogBase } from '../namespace-browser/base';
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @summary A dialog that shows a message. Use it from the client module like `void alert('Save failed.')`.
|
|
4
4
|
*/
|
|
5
5
|
export declare class AlertDialog extends DialogBase {
|
|
6
6
|
#private;
|
|
@@ -3,7 +3,7 @@ import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
|
3
3
|
import { devFlags, onoff, touchGlass } from '../internal/utils';
|
|
4
4
|
import { DialogBase } from '../namespace-browser/base';
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
6
|
+
* @summary A dialog that shows a message. Use it from the client module like `void alert('Save failed.')`.
|
|
7
7
|
*/
|
|
8
8
|
export class AlertDialog extends DialogBase {
|
|
9
9
|
constructor() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { I18n } from '../i18n';
|
|
2
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
3
|
import { $, devFlags, onoff } from '../internal/utils';
|
|
4
|
+
import { html } from '../tpl';
|
|
4
5
|
/**
|
|
5
6
|
* @summary A message with a title and extra information that you show when part of your app can’t be used.
|
|
6
7
|
*
|
|
@@ -23,16 +24,15 @@ export class ContentUnavailable extends HTMLElement {
|
|
|
23
24
|
}
|
|
24
25
|
static #template;
|
|
25
26
|
static get template() {
|
|
26
|
-
return (this.#template ??= $(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</div>`));
|
|
27
|
+
return (this.#template ??= $(html `<div part="root content-unavailable-title-stack">
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</div>
|
|
30
|
+
<div part="root content-unavailable-description-stack">
|
|
31
|
+
<slot name="description"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
<div part="root content-unavailable-actions-stack">
|
|
34
|
+
<slot name="actions"></slot>
|
|
35
|
+
</div>`));
|
|
36
36
|
}
|
|
37
37
|
#shadowRoot;
|
|
38
38
|
#slots;
|
|
@@ -70,7 +70,7 @@ export class ContentUnavailable extends HTMLElement {
|
|
|
70
70
|
console.debug(`${ContentUnavailable.name} ⚡️ connect`);
|
|
71
71
|
}
|
|
72
72
|
#renderSearch = (search) => {
|
|
73
|
-
const titleLabel = this.querySelector(':scope>:not([slot])') ?? this.appendChild($(`<label-view><i class="ph ph-magnifying-glass" slot="icon" foreground="secondary"></i></label-view>`, '>1')), descText = this.querySelector(':scope>[slot=description]') ?? this.appendChild($(`<label-view foreground="secondary" slot="description"></label-view>`, '>1'));
|
|
73
|
+
const titleLabel = this.querySelector(':scope>:not([slot])') ?? this.appendChild($(html `<label-view><i class="ph ph-magnifying-glass" slot="icon" foreground="secondary"></i></label-view>`, '>1')), descText = this.querySelector(':scope>[slot=description]') ?? this.appendChild($(html `<label-view foreground="secondary" slot="description"></label-view>`, '>1'));
|
|
74
74
|
if (search) {
|
|
75
75
|
const interpolate = (text, vars) => text.replaceAll(/\{(\w+)\}/g, (_, key) => vars[key] ?? '');
|
|
76
76
|
titleLabel.setAttribute('title', interpolate(I18n.t('SearchUnavailableContent').Label, { search }));
|
|
@@ -4,7 +4,8 @@ import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
|
4
4
|
import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
|
|
5
5
|
import { MutationObserverSet } from '../internal/class/mutation-observer-set';
|
|
6
6
|
import { $, clamp, devFlags, kebabCase, onoff, set } from '../internal/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { queryMorph } from '../morphdom';
|
|
8
|
+
import { html } from '../tpl';
|
|
8
9
|
const datePickerStyles = ['graphical', 'field', 'automatic'];
|
|
9
10
|
/**
|
|
10
11
|
* @summary A control that selects an absolute date.
|
|
@@ -53,20 +54,19 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
53
54
|
if (!_a.#templates.has(this.datePickerStyle))
|
|
54
55
|
switch (this.datePickerStyle) {
|
|
55
56
|
default:
|
|
56
|
-
_a.#templates.set(this.datePickerStyle, $(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</label>`));
|
|
57
|
+
_a.#templates.set(this.datePickerStyle, $(html `<label part="root date-picker-stack">
|
|
58
|
+
<div part="root date-picker-label-stack">
|
|
59
|
+
<slot name="label"></slot>
|
|
60
|
+
</div>
|
|
61
|
+
<div part="root date-picker-input-stack">
|
|
62
|
+
<input type="text" name="month" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="12" part="root input date-picker-form-input" />
|
|
63
|
+
<span part="root date-picker-separator"></span>
|
|
64
|
+
<input type="text" name="day" inputmode="numeric" pattern="d*" minlength="1" maxlength="2" min="1" max="31" part="root input date-picker-form-input" />
|
|
65
|
+
<span part="root date-picker-separator"></span>
|
|
66
|
+
<input type="text" name="year" inputmode="numeric" pattern="d*" minlength="4" maxlength="4" min="0" max="9999" part="root input date-picker-form-input" />
|
|
67
|
+
</div>
|
|
68
|
+
<slot name="validity-options" hidden></slot>
|
|
69
|
+
</label>`));
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
return _a.#templates.get(this.datePickerStyle);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
3
|
import { $, devFlags, onoff } from '../internal/utils';
|
|
4
|
+
import { html } from '../tpl';
|
|
4
5
|
export class FineTooltip extends HTMLElement {
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
@@ -40,7 +41,7 @@ export class FineTooltip extends HTMLElement {
|
|
|
40
41
|
return trigger ?? undefined;
|
|
41
42
|
}
|
|
42
43
|
#render = (str) => {
|
|
43
|
-
const label = this.querySelector(':scope>label-view') ?? this.appendChild($(`<label-view></label-view>`, '>1'));
|
|
44
|
+
const label = this.querySelector(':scope>label-view') ?? this.appendChild($(html `<label-view></label-view>`, '>1'));
|
|
44
45
|
if (str)
|
|
45
46
|
label.setAttribute('title', str);
|
|
46
47
|
else
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $, devFlags } from '../internal/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { queryMorph } from '../morphdom';
|
|
3
|
+
import { html } from '../tpl';
|
|
3
4
|
/**
|
|
4
5
|
* @summary A view that displays an image.
|
|
5
6
|
*
|
|
@@ -10,7 +11,7 @@ export class ImageView extends HTMLElement {
|
|
|
10
11
|
}
|
|
11
12
|
static #template;
|
|
12
13
|
static get template() {
|
|
13
|
-
return (this.#template ??= $(
|
|
14
|
+
return (this.#template ??= $(html `<slot></slot>`));
|
|
14
15
|
}
|
|
15
16
|
#shadowRoot;
|
|
16
17
|
constructor() {
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
* @slot — Any children without a `slot` attribute are placed in the title block.
|
|
12
12
|
* @slot icon — Use the `slot="icon"` attribute to place childen in the icon block.
|
|
13
13
|
*
|
|
14
|
+
* @cssprop --label-gap — The gap between the icon and the title.
|
|
15
|
+
* @cssprop --label-image-size — The size of the icon.
|
|
16
|
+
* @cssprop --label-padding-inline — The padding inline of the label.
|
|
17
|
+
*
|
|
14
18
|
*/
|
|
15
19
|
export declare class LabelView extends HTMLElement {
|
|
16
20
|
#private;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $, devFlags } from '../internal/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { queryMorph } from '../morphdom';
|
|
3
|
+
import { html } from '../tpl';
|
|
3
4
|
/**
|
|
4
5
|
* @summary A view that labels items with an icon and a title.
|
|
5
6
|
*
|
|
@@ -13,6 +14,10 @@ import { html, queryMorph } from '../morphdom';
|
|
|
13
14
|
* @slot — Any children without a `slot` attribute are placed in the title block.
|
|
14
15
|
* @slot icon — Use the `slot="icon"` attribute to place childen in the icon block.
|
|
15
16
|
*
|
|
17
|
+
* @cssprop --label-gap — The gap between the icon and the title.
|
|
18
|
+
* @cssprop --label-image-size — The size of the icon.
|
|
19
|
+
* @cssprop --label-padding-inline — The padding inline of the label.
|
|
20
|
+
*
|
|
16
21
|
*/
|
|
17
22
|
export class LabelView extends HTMLElement {
|
|
18
23
|
static get observedAttributes() {
|
|
@@ -21,17 +26,17 @@ export class LabelView extends HTMLElement {
|
|
|
21
26
|
'title',
|
|
22
27
|
'line-limit',
|
|
23
28
|
/**
|
|
24
|
-
* @type {tail}
|
|
29
|
+
* @type {"tail"}
|
|
25
30
|
*/
|
|
26
31
|
'truncation-mode',
|
|
27
32
|
];
|
|
28
33
|
}
|
|
29
34
|
static #template;
|
|
30
35
|
static get template() {
|
|
31
|
-
return (this.#template ??= $(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`
|
|
36
|
+
return (this.#template ??= $(html `
|
|
37
|
+
<slot name="icon"></slot>
|
|
38
|
+
<slot></slot>
|
|
39
|
+
`));
|
|
35
40
|
// String.raw`
|
|
36
41
|
// <div part="root label-image-stack">
|
|
37
42
|
// <slot name="image"></slot>
|
|
@@ -39,7 +44,6 @@ export class LabelView extends HTMLElement {
|
|
|
39
44
|
// <div part="root label-title-stack">
|
|
40
45
|
// <slot></slot>
|
|
41
46
|
// </div>`
|
|
42
|
-
));
|
|
43
47
|
}
|
|
44
48
|
#shadowRoot;
|
|
45
49
|
// #reflectScheduled = false
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* @slot label — Use the `slot="label"` attribute to place childen in the label block.
|
|
6
6
|
* @slot header
|
|
7
7
|
* @slot footer
|
|
8
|
+
*
|
|
9
|
+
* @csspart labeled-content-container
|
|
10
|
+
* @csspart labeled-content-stack
|
|
11
|
+
* @csspart labeled-content-label-stack
|
|
12
|
+
* @csspart labeled-content-value-stack
|
|
8
13
|
*/
|
|
9
14
|
export declare class LabeledContent extends HTMLElement {
|
|
10
15
|
#private;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $, devFlags } from '../internal/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { queryMorph } from '../morphdom';
|
|
3
|
+
import { html } from '../tpl';
|
|
3
4
|
/**
|
|
4
5
|
* @summary A container view that pairs a label with a value.
|
|
5
6
|
*
|
|
@@ -7,6 +8,11 @@ import { html, queryMorph } from '../morphdom';
|
|
|
7
8
|
* @slot label — Use the `slot="label"` attribute to place childen in the label block.
|
|
8
9
|
* @slot header
|
|
9
10
|
* @slot footer
|
|
11
|
+
*
|
|
12
|
+
* @csspart labeled-content-container
|
|
13
|
+
* @csspart labeled-content-stack
|
|
14
|
+
* @csspart labeled-content-label-stack
|
|
15
|
+
* @csspart labeled-content-value-stack
|
|
10
16
|
*/
|
|
11
17
|
export class LabeledContent extends HTMLElement {
|
|
12
18
|
static get observedAttributes() {
|
|
@@ -24,19 +30,19 @@ export class LabeledContent extends HTMLElement {
|
|
|
24
30
|
}
|
|
25
31
|
static #template;
|
|
26
32
|
static get template() {
|
|
27
|
-
return (this.#template ??= $(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
return (this.#template ??= $(html `
|
|
34
|
+
<div part="root labeled-content-container">
|
|
35
|
+
<slot name="header"></slot>
|
|
36
|
+
<div part="root labeled-content-stack">
|
|
37
|
+
<div part="root labeled-content-label-stack">
|
|
38
|
+
<slot name="label"></slot>
|
|
39
|
+
</div>
|
|
40
|
+
<div part="root labeled-content-value-stack">
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</div>
|
|
36
43
|
</div>
|
|
44
|
+
<slot name="footer"></slot>
|
|
37
45
|
</div>
|
|
38
|
-
<slot name="footer"></slot>
|
|
39
|
-
</div>
|
|
40
46
|
`));
|
|
41
47
|
}
|
|
42
48
|
#shadowRoot;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
3
|
import { $, devFlags, onoff, touchGlass } from '../internal/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { queryMorph } from '../morphdom';
|
|
5
|
+
import { html } from '../tpl';
|
|
5
6
|
/**
|
|
6
7
|
* @summary A control that opens a menu of actions.
|
|
7
8
|
*
|
|
@@ -14,17 +15,16 @@ export class MenuView extends HTMLElement {
|
|
|
14
15
|
}
|
|
15
16
|
static #template;
|
|
16
17
|
static get template() {
|
|
17
|
-
return (this.#template ??= $(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</dialog>`));
|
|
18
|
+
return (this.#template ??= $(html `<button type="button" part="root button menu-summary">
|
|
19
|
+
<slot name="label"></slot>
|
|
20
|
+
</button>
|
|
21
|
+
<dialog part="root menu-dialog" autofocus inert>
|
|
22
|
+
<form part="root menu-form" method="dialog" novalidate>
|
|
23
|
+
<div part="root menu-scrollable">
|
|
24
|
+
<slot></slot>
|
|
25
|
+
</div>
|
|
26
|
+
</form>
|
|
27
|
+
</dialog>`));
|
|
28
28
|
}
|
|
29
29
|
#shadowRoot;
|
|
30
30
|
#dialog;
|
|
@@ -7,7 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var NavigationTitle_1;
|
|
8
8
|
import { microtaskOnConnected } from '../internal/decorators';
|
|
9
9
|
import { devFlags } from '../internal/utils';
|
|
10
|
-
import {
|
|
10
|
+
import { queryMorph } from '../morphdom';
|
|
11
|
+
import { html } from '../tpl';
|
|
11
12
|
/**
|
|
12
13
|
* @summary A container view.
|
|
13
14
|
*
|
|
@@ -14,7 +14,7 @@ export type Dictionary = DictEntry[];
|
|
|
14
14
|
*
|
|
15
15
|
* @attr {menu|inline|navigation-link|sheet|automatic} picker-style
|
|
16
16
|
*
|
|
17
|
-
* @attr
|
|
17
|
+
* @attr help — Adds a help tooltip to the trigger of the picker, if style supports one
|
|
18
18
|
*
|
|
19
19
|
* @attr {DictEntry[]} dictionary — Renders all options using this array
|
|
20
20
|
*
|
|
@@ -6,7 +6,7 @@ import { MutationObserverSet } from '../internal/class/mutation-observer-set';
|
|
|
6
6
|
import { NavigationPath } from '../internal/class/navigation-path';
|
|
7
7
|
import { queryInsertPosition, startViewTransition } from '../internal/privateNamespace';
|
|
8
8
|
import { $, devFlags, kebabCase, onoff } from '../internal/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { queryMorph } from '../morphdom';
|
|
10
10
|
import { html, render } from '../tpl';
|
|
11
11
|
const pickerStyles = ['menu', 'inline', 'navigation-link', 'sheet', 'automatic'];
|
|
12
12
|
const update = (path, node, overwrite = true) => {
|
|
@@ -120,7 +120,7 @@ const collectLeafValues = (node) => (node.children.length ? node.children.flatMa
|
|
|
120
120
|
*
|
|
121
121
|
* @attr {menu|inline|navigation-link|sheet|automatic} picker-style
|
|
122
122
|
*
|
|
123
|
-
* @attr
|
|
123
|
+
* @attr help — Adds a help tooltip to the trigger of the picker, if style supports one
|
|
124
124
|
*
|
|
125
125
|
* @attr {DictEntry[]} dictionary — Renders all options using this array
|
|
126
126
|
*
|
|
@@ -173,7 +173,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
173
173
|
#spawnPage = (elements, tag, parentGroupId, searchable = false, title) => {
|
|
174
174
|
if (devFlags.debug)
|
|
175
175
|
console.debug(`${_a.name} #spawnPage`);
|
|
176
|
-
const body = $(`<${'sheet-view' === tag ? 'dialog is="sheet-view"' : 'body-view'}><scroll-view><v-stack placement="leading fill"><list-view preferred-expanded-style="inset"></list-view></v-stack></scroll-view><tool-bar><tool-bar-item slot="top-bar-leading"><button type="button" tabindex="0"><label-view system-image="${'sheet-view' === tag ? 'x' : 'caret-left'}"></label-view></button></tool-bar-item></tool-bar></${'sheet-view' === tag ? 'dialog' : 'body-view'}>`, '>1'), sv = body.querySelector('scroll-view'), list = body.querySelector('list-view'), backBtn = body.querySelector('button');
|
|
176
|
+
const body = $(html `<${'sheet-view' === tag ? 'dialog is="sheet-view"' : 'body-view'}><scroll-view><v-stack placement="leading fill"><list-view preferred-expanded-style="inset"></list-view></v-stack></scroll-view><tool-bar><tool-bar-item slot="top-bar-leading"><button type="button" tabindex="0"><label-view system-image="${'sheet-view' === tag ? 'x' : 'caret-left'}"></label-view></button></tool-bar-item></tool-bar></${'sheet-view' === tag ? 'dialog' : 'body-view'}>`, '>1'), sv = body.querySelector('scroll-view'), list = body.querySelector('list-view'), backBtn = body.querySelector('button');
|
|
177
177
|
if (title)
|
|
178
178
|
sv?.setAttribute('navigation-inline-title', title);
|
|
179
179
|
if (searchable) {
|
|
@@ -372,7 +372,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
372
372
|
case 'sheet':
|
|
373
373
|
case 'navigation-link': {
|
|
374
374
|
// current value label only
|
|
375
|
-
const currentValueLabel = this.querySelector(':scope>label-view:not([slot])') ?? this.appendChild($(`<label-view></label-view>`, '>1'));
|
|
375
|
+
const currentValueLabel = this.querySelector(':scope>label-view:not([slot])') ?? this.appendChild($(html `<label-view></label-view>`, '>1'));
|
|
376
376
|
// reset state
|
|
377
377
|
// if (currentValueLabel) {
|
|
378
378
|
// renderLabelIcon(currentValueLabel, 'dots-three') // overwritten
|
|
@@ -406,7 +406,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
406
406
|
break;
|
|
407
407
|
}
|
|
408
408
|
case 'menu': {
|
|
409
|
-
const menu = this.querySelector(':scope>menu-view:not([slot])') ?? this.appendChild($(`<menu-view></menu-view>`, '>1'));
|
|
409
|
+
const menu = this.querySelector(':scope>menu-view:not([slot])') ?? this.appendChild($(html `<menu-view></menu-view>`, '>1'));
|
|
410
410
|
// reset state
|
|
411
411
|
menu.innerHTML = '';
|
|
412
412
|
menu.tabIndex = 0;
|
|
@@ -414,7 +414,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
414
414
|
for (const el of this.querySelectorAll(':scope>:not([slot])'))
|
|
415
415
|
if (menu !== el)
|
|
416
416
|
el.remove();
|
|
417
|
-
const currentValueLabel = menu.querySelector(':scope>label-view[slot=label]') ?? menu.appendChild($(`<label-view slot="label"></label-view>`, '>1'));
|
|
417
|
+
const currentValueLabel = menu.querySelector(':scope>label-view[slot=label]') ?? menu.appendChild($(html `<label-view slot="label"></label-view>`, '>1'));
|
|
418
418
|
// if (currentValueLabel) {
|
|
419
419
|
// renderLabelIcon(currentValueLabel, 'dots-three') // overwritten
|
|
420
420
|
// renderLabelTitle(currentValueLabel, this.#currentValueLabel) // overwritten
|
|
@@ -426,8 +426,8 @@ export class PickerView extends FormAssociatedBase {
|
|
|
426
426
|
}
|
|
427
427
|
case 'inline':
|
|
428
428
|
default: {
|
|
429
|
-
const sectionTpl = `<section-view></section-view>`;
|
|
430
|
-
const inlineList = this.querySelector(':scope>list-view:not([slot])') ?? this.appendChild($(`<list-view>${sectionTpl}</list-view>`, '>1')), section = inlineList.querySelector(':scope>section-view') ?? inlineList.appendChild($(sectionTpl, '>1'));
|
|
429
|
+
const sectionTpl = html `<section-view></section-view>`;
|
|
430
|
+
const inlineList = this.querySelector(':scope>list-view:not([slot])') ?? this.appendChild($(html `<list-view>${sectionTpl}</list-view>`, '>1')), section = inlineList.querySelector(':scope>section-view') ?? inlineList.appendChild($(sectionTpl, '>1'));
|
|
431
431
|
// reset state
|
|
432
432
|
section.innerHTML = '';
|
|
433
433
|
// clear all siblings
|
|
@@ -437,8 +437,10 @@ export class PickerView extends FormAssociatedBase {
|
|
|
437
437
|
// add label as a plain element
|
|
438
438
|
const value = this.getAttribute(this.constructor.ATTR.LABEL);
|
|
439
439
|
if (value) {
|
|
440
|
-
const hStack = $(`<h-stack distribution="leading" template="auto spacer"
|
|
441
|
-
|
|
440
|
+
const hStack = $(html `<h-stack distribution="leading" template="auto spacer"
|
|
441
|
+
><label-view data-role="check" style="visibility: hidden"><image-view slot="icon" system-name="check"></image-view></label-view><label-view><span></span></label-view
|
|
442
|
+
></h-stack>`, '>1');
|
|
443
|
+
queryMorph('label-view:nth-child(2)', html `<label-view>${value ? html `<span>${value}</span>` : null}</label-view>`, hStack);
|
|
442
444
|
// if (label) renderLabelTitle(label, value) //label.setAttribute('title', value)
|
|
443
445
|
section.insertAdjacentElement('beforeend', hStack);
|
|
444
446
|
}
|
|
@@ -503,32 +505,32 @@ export class PickerView extends FormAssociatedBase {
|
|
|
503
505
|
switch (this.pickerStyle) {
|
|
504
506
|
case 'sheet':
|
|
505
507
|
case 'navigation-link':
|
|
506
|
-
_a.#templates.set(this.pickerStyle, $(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
508
|
+
_a.#templates.set(this.pickerStyle, $(html `
|
|
509
|
+
<label part="root picker-stack">
|
|
510
|
+
<div part="root picker-label-stack">
|
|
511
|
+
<slot name="label"></slot>
|
|
512
|
+
</div>
|
|
513
|
+
<div part="root picker-input-stack">
|
|
514
|
+
<slot></slot>
|
|
515
|
+
</div>
|
|
516
|
+
<slot name="list" hidden></slot>
|
|
517
|
+
<slot name="validity-options" hidden></slot>
|
|
518
|
+
</label>
|
|
519
|
+
`));
|
|
518
520
|
break;
|
|
519
521
|
case 'menu':
|
|
520
|
-
_a.#templates.set(this.pickerStyle, $(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
522
|
+
_a.#templates.set(this.pickerStyle, $(html `
|
|
523
|
+
<label part="root picker-stack">
|
|
524
|
+
<div part="root picker-label-stack">
|
|
525
|
+
<slot name="label"></slot>
|
|
526
|
+
</div>
|
|
527
|
+
<div part="root picker-input-stack">
|
|
528
|
+
<slot></slot>
|
|
529
|
+
</div>
|
|
530
|
+
<slot name="list" hidden></slot>
|
|
531
|
+
<slot name="validity-options" hidden></slot>
|
|
532
|
+
</label>
|
|
533
|
+
`));
|
|
532
534
|
// break
|
|
533
535
|
// case 'compact':
|
|
534
536
|
// PickerView.#templates.set(
|
|
@@ -577,17 +579,16 @@ export class PickerView extends FormAssociatedBase {
|
|
|
577
579
|
// break
|
|
578
580
|
case 'inline':
|
|
579
581
|
default:
|
|
580
|
-
_a.#templates.set(this.pickerStyle, $(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
</label>`));
|
|
582
|
+
_a.#templates.set(this.pickerStyle, $(html ` <label part="root picker-stack">
|
|
583
|
+
<div part="root picker-label-stack">
|
|
584
|
+
<slot name="label"></slot>
|
|
585
|
+
</div>
|
|
586
|
+
<div part="root picker-input-stack">
|
|
587
|
+
<slot></slot>
|
|
588
|
+
</div>
|
|
589
|
+
<slot name="list" hidden></slot>
|
|
590
|
+
<slot name="validity-options" hidden></slot>
|
|
591
|
+
</label>`));
|
|
591
592
|
break;
|
|
592
593
|
}
|
|
593
594
|
return _a.#templates.get(this.pickerStyle);
|
|
@@ -985,7 +986,7 @@ export class PickerView extends FormAssociatedBase {
|
|
|
985
986
|
#reflectLabel(value) {
|
|
986
987
|
if (devFlags.debug)
|
|
987
988
|
console.debug(`${_a.name} #reflectLabel`);
|
|
988
|
-
queryMorph('[slot=label]',
|
|
989
|
+
queryMorph('[slot=label]', html `<label-view slot="label">${value ? html `<span>${value}</span>` : null}</label-view>`, this);
|
|
989
990
|
this.#renderSlotted([]);
|
|
990
991
|
}
|
|
991
992
|
#reflectSelectionOnButtons() {
|
|
@@ -1033,8 +1034,8 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1033
1034
|
// if (!cvl) currentValueLabel.setAttribute('foreground', 'secondary')
|
|
1034
1035
|
// else currentValueLabel.removeAttribute('foreground')
|
|
1035
1036
|
const title = this.#currentValueLabel || this.#selection || this.getAttribute(this.constructor.ATTR.PLACEHOLDER), systemImage = this.#currentValueIcon || this.getAttribute(this.constructor.ATTR.PLACEHOLDER_ICON);
|
|
1036
|
-
queryMorph(':not([slot])',
|
|
1037
|
-
queryMorph('[slot=icon]',
|
|
1037
|
+
queryMorph(':not([slot])', html `<span>${title}</span>`, currentValueLabel, { removeIf: !title });
|
|
1038
|
+
queryMorph('[slot=icon]', html `<image-view slot="icon" system-name="${systemImage}"></image-view>`, currentValueLabel, { removeIf: !systemImage });
|
|
1038
1039
|
// morph(
|
|
1039
1040
|
// htmx`<label-view>${systemImage ? htmx`<image-view slot="icon" system-name="${systemImage}"></image-view>` : null}${title ? htmx`<span>${title}</span>` : null}</label-view>`,
|
|
1040
1041
|
// currentValueLabel
|
|
@@ -1048,8 +1049,8 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1048
1049
|
// if (!cvl) currentValueLabel.setAttribute('foreground', 'secondary')
|
|
1049
1050
|
// else currentValueLabel.removeAttribute('foreground')
|
|
1050
1051
|
const title = this.#currentValueLabel || this.#selection || this.getAttribute(this.constructor.ATTR.PLACEHOLDER), systemImage = this.#currentValueIcon || this.getAttribute(this.constructor.ATTR.PLACEHOLDER_ICON);
|
|
1051
|
-
queryMorph(':not([slot])',
|
|
1052
|
-
queryMorph('[slot=icon]',
|
|
1052
|
+
queryMorph(':not([slot])', html `<span>${title}</span>`, currentValueLabel, { removeIf: !title });
|
|
1053
|
+
queryMorph('[slot=icon]', html `<image-view slot="icon" system-name="${systemImage}"></image-view>`, currentValueLabel, { removeIf: !systemImage });
|
|
1053
1054
|
// morph(
|
|
1054
1055
|
// htmx`<label-view slot="label">${systemImage ? htmx`<image-view slot="icon" system-name="${systemImage}"></image-view>` : null}${title ? htmx`<span>${title}</span>` : null}</label-view>`,
|
|
1055
1056
|
// currentValueLabel
|