@swiftwc/ui 0.0.0-dev.94 → 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/body-view.d.ts +1 -1
- package/generated/components/body-view.js +1 -1
- package/generated/components/confirmation-dialog.d.ts +1 -2
- package/generated/components/confirmation-dialog.js +1 -2
- package/generated/components/content-unavailable.js +11 -11
- package/generated/components/date-picker.js +17 -17
- package/generated/components/disclosure-group.d.ts +4 -1
- package/generated/components/disclosure-group.js +5 -1
- package/generated/components/fine-tooltip.js +2 -1
- package/generated/components/form-view.d.ts +2 -0
- package/generated/components/form-view.js +2 -0
- package/generated/components/h-stack.d.ts +2 -2
- package/generated/components/h-stack.js +2 -2
- package/generated/components/image-view.d.ts +4 -0
- package/generated/components/image-view.js +7 -2
- package/generated/components/label-view.d.ts +7 -3
- package/generated/components/label-view.js +14 -10
- package/generated/components/labeled-content.d.ts +13 -0
- package/generated/components/labeled-content.js +26 -12
- package/generated/components/list-view.d.ts +2 -0
- package/generated/components/list-view.js +2 -0
- package/generated/components/menu-view.js +12 -12
- package/generated/components/navigation-large-title.d.ts +7 -0
- package/generated/components/navigation-large-title.js +7 -0
- package/generated/components/navigation-split-view.d.ts +1 -1
- package/generated/components/navigation-split-view.js +1 -1
- package/generated/components/navigation-stack.d.ts +1 -1
- package/generated/components/navigation-stack.js +1 -1
- package/generated/components/navigation-title.d.ts +5 -0
- package/generated/components/navigation-title.js +7 -1
- package/generated/components/picker-view.d.ts +1 -1
- package/generated/components/picker-view.js +51 -50
- package/generated/components/progress-view.d.ts +1 -1
- package/generated/components/progress-view.js +21 -20
- package/generated/components/scroll-view-proxy.d.ts +1 -1
- package/generated/components/scroll-view-proxy.js +1 -1
- package/generated/components/scroll-view.d.ts +2 -0
- package/generated/components/scroll-view.js +16 -14
- package/generated/components/section-view.js +11 -11
- package/generated/components/sheet-view.d.ts +3 -0
- package/generated/components/sheet-view.js +3 -0
- package/generated/components/sidebar-toggle.d.ts +3 -0
- package/generated/components/sidebar-toggle.js +3 -0
- package/generated/components/sidebar-view.d.ts +3 -0
- package/generated/components/sidebar-view.js +3 -0
- package/generated/components/tab-bar.d.ts +1 -1
- package/generated/components/tab-bar.js +1 -1
- package/generated/components/tab-item.d.ts +3 -0
- package/generated/components/tab-item.js +3 -0
- package/generated/components/tab-view.d.ts +1 -0
- package/generated/components/tab-view.js +1 -0
- package/generated/components/table-view.d.ts +1 -1
- package/generated/components/table-view.js +35 -35
- package/generated/components/text-field.d.ts +2 -0
- package/generated/components/text-field.js +16 -14
- package/generated/components/toggle-view.js +30 -13
- package/generated/components/tool-bar-item-group.d.ts +1 -1
- package/generated/components/tool-bar-item-group.js +1 -1
- package/generated/components/tool-bar-item.d.ts +1 -1
- package/generated/components/tool-bar-item.js +1 -1
- package/generated/components/tool-bar.d.ts +1 -1
- package/generated/components/tool-bar.js +28 -28
- package/generated/components/v-stack.d.ts +2 -2
- package/generated/components/v-stack.js +2 -2
- 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 +6 -4
- package/web-components.css-data/en.json +28 -0
- package/web-components.html-data/en.json +179 -117
- package/generated/morphdom/html.d.ts +0 -8
- package/generated/morphdom/html.js +0 -37
|
@@ -3,10 +3,11 @@ import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
|
3
3
|
import { CSSStyleObserver } from '../internal/class/css-style-observer';
|
|
4
4
|
import { MutationObserverSet } from '../internal/class/mutation-observer-set';
|
|
5
5
|
import { $, devFlags, listActive, onoff } from '../internal/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { queryMorph } from '../morphdom';
|
|
7
7
|
import { Snapshot } from '../snapshot';
|
|
8
|
+
import { html } from '../tpl';
|
|
8
9
|
/**
|
|
9
|
-
* @summary
|
|
10
|
+
* @summary A container view that arranges data in rows and columns, optionally letting the user select one or more of them.
|
|
10
11
|
*
|
|
11
12
|
* @attr {title:trailing:subtitle|trailing:title:subtitle|title:subtitle:trailing|*} preferred-compact-template — Sets the template areas when the table is in compact mode
|
|
12
13
|
*
|
|
@@ -24,35 +25,34 @@ export class TableView extends HTMLElement {
|
|
|
24
25
|
#compactToolbarItem;
|
|
25
26
|
static #template;
|
|
26
27
|
static get template() {
|
|
27
|
-
return (this.#template ??= $(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return (this.#template ??= $(html `<div part="root table-container">
|
|
29
|
+
<div part="root table-header-stack">
|
|
30
|
+
<div part="root table-header-leading-stack">
|
|
31
|
+
<slot name="header-leading"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
<div part="root table-header-principal-stack">
|
|
34
|
+
<slot name="header-principal"></slot>
|
|
35
|
+
</div>
|
|
36
|
+
<div part="root table-header-trailing-stack">
|
|
37
|
+
<slot name="header-trailing"></slot>
|
|
38
|
+
</div>
|
|
32
39
|
</div>
|
|
33
|
-
<div part="root table-
|
|
34
|
-
<slot name="
|
|
40
|
+
<div part="root table-column-stack">
|
|
41
|
+
<slot name="column"></slot>
|
|
35
42
|
</div>
|
|
36
|
-
<
|
|
37
|
-
|
|
43
|
+
<slot><p>empty</p></slot>
|
|
44
|
+
<div part="root table-footer-stack">
|
|
45
|
+
<div part="root table-footer-leading-stack">
|
|
46
|
+
<slot name="footer-leading"></slot>
|
|
47
|
+
</div>
|
|
48
|
+
<div part="root table-footer-principal-stack">
|
|
49
|
+
<slot name="footer-principal"></slot>
|
|
50
|
+
</div>
|
|
51
|
+
<div part="root table-footer-trailing-stack">
|
|
52
|
+
<slot name="footer-trailing"></slot>
|
|
53
|
+
</div>
|
|
38
54
|
</div>
|
|
39
|
-
</div
|
|
40
|
-
<div part="root table-column-stack">
|
|
41
|
-
<slot name="column"></slot>
|
|
42
|
-
</div>
|
|
43
|
-
<slot><p>empty</p></slot>
|
|
44
|
-
<div part="root table-footer-stack">
|
|
45
|
-
<div part="root table-footer-leading-stack">
|
|
46
|
-
<slot name="footer-leading"></slot>
|
|
47
|
-
</div>
|
|
48
|
-
<div part="root table-footer-principal-stack">
|
|
49
|
-
<slot name="footer-principal"></slot>
|
|
50
|
-
</div>
|
|
51
|
-
<div part="root table-footer-trailing-stack">
|
|
52
|
-
<slot name="footer-trailing"></slot>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</div>`));
|
|
55
|
+
</div>`));
|
|
56
56
|
}
|
|
57
57
|
#shadowRoot;
|
|
58
58
|
#slots = new Map();
|
|
@@ -102,7 +102,7 @@ export class TableView extends HTMLElement {
|
|
|
102
102
|
if (devFlags.debug)
|
|
103
103
|
console.debug(`${_a.name} ⚡️ mutation`);
|
|
104
104
|
if (!this.#compactToolbarItem) {
|
|
105
|
-
this.#compactToolbarItem = $(`<menu-view tabindex="0" slot="header-trailing"></menu-view>`, '>1');
|
|
105
|
+
this.#compactToolbarItem = $(html `<menu-view tabindex="0" slot="header-trailing"></menu-view>`, '>1');
|
|
106
106
|
CleanupRegistry.unregister(this, 'compact_toolbar');
|
|
107
107
|
CleanupRegistry.register(this, onoff('click', this.#handleMenuClick, this.#compactToolbarItem).on(), 'compact_toolbar');
|
|
108
108
|
}
|
|
@@ -110,12 +110,12 @@ export class TableView extends HTMLElement {
|
|
|
110
110
|
for (const node of this.#slots?.get('column')?.assignedElements({ flatten: true }) ?? []) {
|
|
111
111
|
if (!node.matches('[is=table-column]'))
|
|
112
112
|
continue;
|
|
113
|
-
const btn = $(`<button type="button" tabindex="0">
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
const btn = $(html `<button type="button" tabindex="0">
|
|
114
|
+
<v-stack spacing="0" alignment="leading">
|
|
115
|
+
<label-view></label-view>
|
|
116
|
+
<label-view font="callout" foreground="secondary"></label-view>
|
|
117
|
+
</v-stack>
|
|
118
|
+
</button>`, '>1'), title = btn.querySelector('label-view:first-child') ?? undefined, subTitle = btn.querySelector('label-view:last-child') ?? undefined;
|
|
119
119
|
queryMorph(':not([slot])', html `<span>${node.textContent.trim()}</span>`, title, { removeIf: !node.textContent.trim() });
|
|
120
120
|
queryMorph(':not([slot])', html `<span>${node.ariaSort ?? ''}</span>`, subTitle, { removeIf: !(node.ariaSort ?? '') });
|
|
121
121
|
this.#compactToolbarItem.appendChild(btn);
|
|
@@ -4,6 +4,8 @@ export type KeyboardType = (typeof keyboardTypes)[number];
|
|
|
4
4
|
/**
|
|
5
5
|
* @summary A control that displays an editable text area.
|
|
6
6
|
*
|
|
7
|
+
* @fires {{ detail: { text: string } }} commit — Triggered when user interacts with the input area
|
|
8
|
+
*
|
|
7
9
|
* @slot label
|
|
8
10
|
* @slot validity-options
|
|
9
11
|
*/
|
|
@@ -4,11 +4,14 @@ 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 { $, compareBigDecimals, devFlags, kebabCase, onoff, set } from '../internal/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { queryMorph } from '../morphdom';
|
|
8
|
+
import { html } from '../tpl';
|
|
8
9
|
const keyboardTypes = ['decimal-pad', 'number-pad', 'default'];
|
|
9
10
|
/**
|
|
10
11
|
* @summary A control that displays an editable text area.
|
|
11
12
|
*
|
|
13
|
+
* @fires {{ detail: { text: string } }} commit — Triggered when user interacts with the input area
|
|
14
|
+
*
|
|
12
15
|
* @slot label
|
|
13
16
|
* @slot validity-options
|
|
14
17
|
*/
|
|
@@ -25,7 +28,7 @@ export class TextField extends FormAssociatedBase {
|
|
|
25
28
|
'text',
|
|
26
29
|
'text-input-autocapitalization',
|
|
27
30
|
/**
|
|
28
|
-
* @type {
|
|
31
|
+
* @type {boolean}
|
|
29
32
|
*/
|
|
30
33
|
'disable-autocorrection',
|
|
31
34
|
/**
|
|
@@ -33,27 +36,26 @@ export class TextField extends FormAssociatedBase {
|
|
|
33
36
|
*/
|
|
34
37
|
'keyboard-type',
|
|
35
38
|
/**
|
|
36
|
-
* @type {
|
|
39
|
+
* @type {boolean}
|
|
37
40
|
*/
|
|
38
41
|
'required',
|
|
39
42
|
/**
|
|
40
|
-
* @type {
|
|
43
|
+
* @type {boolean}
|
|
41
44
|
*/
|
|
42
45
|
'disabled',
|
|
43
46
|
];
|
|
44
47
|
}
|
|
45
48
|
static #template;
|
|
46
49
|
static get template() {
|
|
47
|
-
return (this.#template ??= $(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</label>`));
|
|
50
|
+
return (this.#template ??= $(html `<label part="root text-field-stack">
|
|
51
|
+
<div part="root text-field-label-stack">
|
|
52
|
+
<slot name="label"></slot>
|
|
53
|
+
</div>
|
|
54
|
+
<div part="root text-field-input-stack">
|
|
55
|
+
<input type="text" part="root input text-field-form-input" />
|
|
56
|
+
</div>
|
|
57
|
+
<slot name="validity-options" hidden></slot>
|
|
58
|
+
</label>`));
|
|
57
59
|
}
|
|
58
60
|
#renderValidityMsgs = (entries) => {
|
|
59
61
|
if (devFlags.debug)
|
|
@@ -3,7 +3,8 @@ import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
|
3
3
|
import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
|
|
4
4
|
import { MutationObserverSet } from '../internal/class/mutation-observer-set';
|
|
5
5
|
import { $, devFlags, kebabCase, onoff } from '../internal/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { queryMorph } from '../morphdom';
|
|
7
|
+
import { html } from '../tpl';
|
|
7
8
|
const toggleStyles = ['switch', 'button'];
|
|
8
9
|
/**
|
|
9
10
|
* @summary A control that switches between on and off states.
|
|
@@ -15,21 +16,37 @@ const toggleStyles = ['switch', 'button'];
|
|
|
15
16
|
*/
|
|
16
17
|
export class ToggleView extends FormAssociatedBase {
|
|
17
18
|
static get observedAttributes() {
|
|
18
|
-
return [
|
|
19
|
+
return [
|
|
20
|
+
'label',
|
|
21
|
+
'name',
|
|
22
|
+
'value',
|
|
23
|
+
/**
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
*/
|
|
26
|
+
'is-on',
|
|
27
|
+
'keyboard-type',
|
|
28
|
+
/**
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
'required',
|
|
32
|
+
/**
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
'disabled',
|
|
36
|
+
];
|
|
19
37
|
}
|
|
20
38
|
static #template;
|
|
21
39
|
static get template() {
|
|
22
|
-
return (this.#template ??= $(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</label>`));
|
|
40
|
+
return (this.#template ??= $(html `<label part="root toggle-stack">
|
|
41
|
+
<div part="root toggle-label-stack">
|
|
42
|
+
<slot name="label"></slot>
|
|
43
|
+
</div>
|
|
44
|
+
<div part="root toggle-input-stack">
|
|
45
|
+
<!--<input type="checkbox" part="root input toggle-form-input">-->
|
|
46
|
+
<div part="root toggle-form-input" tabindex="0"></div>
|
|
47
|
+
</div>
|
|
48
|
+
<slot name="validity-options" hidden></slot>
|
|
49
|
+
</label>`));
|
|
33
50
|
}
|
|
34
51
|
#renderValidityMsgs = (entries) => {
|
|
35
52
|
if (devFlags.debug)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A
|
|
2
|
+
* @summary A container view that groups items together in the toolbar or navigation bar.
|
|
3
3
|
*/
|
|
4
4
|
export declare class ToolBarItemGroup extends HTMLElement {
|
|
5
5
|
constructor();
|
|
@@ -9,7 +9,7 @@ import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
|
9
9
|
import { adaptiveSlot } from '../internal/decorators';
|
|
10
10
|
import { devFlags } from '../internal/utils';
|
|
11
11
|
/**
|
|
12
|
-
* A
|
|
12
|
+
* @summary A container view that groups items together in the toolbar or navigation bar.
|
|
13
13
|
*/
|
|
14
14
|
let ToolBarItemGroup = ToolBarItemGroup_1 = class ToolBarItemGroup extends HTMLElement {
|
|
15
15
|
constructor() {
|
|
@@ -10,7 +10,7 @@ import { adaptiveSlot } from '../internal/decorators';
|
|
|
10
10
|
import { devFlags, ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
|
|
11
11
|
import { Snapshot } from '../snapshot';
|
|
12
12
|
/**
|
|
13
|
-
* @summary A
|
|
13
|
+
* @summary A view placed in the toolbar or navigation bar.
|
|
14
14
|
*/
|
|
15
15
|
let ToolBarItem = ToolBarItem_1 = class ToolBarItem extends HTMLElement {
|
|
16
16
|
static get observedAttributes() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @summary
|
|
2
|
+
* @summary A list of items placed into the toolbar or navigation bar around your content.
|
|
3
3
|
*
|
|
4
4
|
* @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
5
5
|
* @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
|
|
3
3
|
import { $, devFlags } from '../internal/utils';
|
|
4
|
+
import { html } from '../tpl';
|
|
4
5
|
const observers = new ResizeObserverSingleton();
|
|
5
6
|
/**
|
|
6
|
-
* @summary
|
|
7
|
+
* @summary A list of items placed into the toolbar or navigation bar around your content.
|
|
7
8
|
*
|
|
8
9
|
* @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
9
10
|
* @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
|
|
@@ -20,33 +21,32 @@ export class ToolBar extends HTMLElement {
|
|
|
20
21
|
static #template;
|
|
21
22
|
static get template() {
|
|
22
23
|
// <!--exportparts="toolbar-leading-stack,toolbar-principal-stack,toolbar-trailing-stack"-->
|
|
23
|
-
return (this.#template ??= $(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
</div>`));
|
|
24
|
+
return (this.#template ??= $(html `<div part="root top-bar">
|
|
25
|
+
<div part="root toolbar-leading-stack">
|
|
26
|
+
<slot name="cancellation-action"></slot>
|
|
27
|
+
<slot name="destructive-action"></slot>
|
|
28
|
+
<slot name="top-bar-leading"></slot>
|
|
29
|
+
</div>
|
|
30
|
+
<div part="root toolbar-principal-stack">
|
|
31
|
+
<slot name="top-bar-principal"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
<div part="root toolbar-trailing-stack">
|
|
34
|
+
<slot name="top-bar-trailing"></slot>
|
|
35
|
+
<slot name="primary-action"></slot>
|
|
36
|
+
<slot name="confirmation-action"></slot>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<div part="root bottom-bar">
|
|
40
|
+
<div part="root toolbar-leading-stack">
|
|
41
|
+
<slot name="bottom-bar-leading"></slot>
|
|
42
|
+
</div>
|
|
43
|
+
<div part="root toolbar-principal-stack">
|
|
44
|
+
<slot name="bottom-bar-principal"></slot>
|
|
45
|
+
</div>
|
|
46
|
+
<div part="root toolbar-trailing-stack">
|
|
47
|
+
<slot name="bottom-bar-trailing"></slot>
|
|
48
|
+
</div>
|
|
49
|
+
</div>`));
|
|
50
50
|
}
|
|
51
51
|
#shadowRoot;
|
|
52
52
|
get #scrollView() {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @attr {leading|"leading fill"|center|trailing|fill|space-between} distribution — The distribution of cols
|
|
5
5
|
*
|
|
6
|
-
* @attr {@
|
|
6
|
+
* @attr {@Template} template — The main-axis grid template
|
|
7
7
|
*
|
|
8
|
-
* @attr {@
|
|
8
|
+
* @attr {@Spacing} spacing — The gap between the primary axis
|
|
9
9
|
*
|
|
10
10
|
* @attr {@inlineSet} alignment — The cross-axis alignment
|
|
11
11
|
* @attr {@blockSet} distribution — The main-axis alignment
|
|
@@ -4,9 +4,9 @@ import { devFlags } from '../internal/utils';
|
|
|
4
4
|
*
|
|
5
5
|
* @attr {leading|"leading fill"|center|trailing|fill|space-between} distribution — The distribution of cols
|
|
6
6
|
*
|
|
7
|
-
* @attr {@
|
|
7
|
+
* @attr {@Template} template — The main-axis grid template
|
|
8
8
|
*
|
|
9
|
-
* @attr {@
|
|
9
|
+
* @attr {@Spacing} spacing — The gap between the primary axis
|
|
10
10
|
*
|
|
11
11
|
* @attr {@inlineSet} alignment — The cross-axis alignment
|
|
12
12
|
* @attr {@blockSet} distribution — The main-axis alignment
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TemplateResult } from '../../../tpl';
|
|
1
2
|
import ancestors from './ancestors';
|
|
2
3
|
import next from './next';
|
|
3
4
|
import nextAll from './next-all';
|
|
@@ -7,9 +8,9 @@ import prop from './prop';
|
|
|
7
8
|
import siblings from './siblings';
|
|
8
9
|
declare const DEFAULT: ">1";
|
|
9
10
|
interface CashFn {
|
|
10
|
-
(
|
|
11
|
-
<T extends Element = Element>(
|
|
12
|
-
<T extends Element = Element>(
|
|
11
|
+
(markup: TemplateResult): DocumentFragment;
|
|
12
|
+
<T extends Element = Element>(markup: TemplateResult, selector: typeof DEFAULT): T;
|
|
13
|
+
<T extends Element = Element>(markup: TemplateResult, selector: string): T;
|
|
13
14
|
prop: typeof prop;
|
|
14
15
|
nextAll: typeof nextAll;
|
|
15
16
|
prevAll: typeof prevAll;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renderToString } from '../../../morphdom';
|
|
1
2
|
import ancestors from './ancestors';
|
|
2
3
|
import next from './next';
|
|
3
4
|
import nextAll from './next-all';
|
|
@@ -6,8 +7,9 @@ import prevAll from './prev-all';
|
|
|
6
7
|
import prop from './prop';
|
|
7
8
|
import siblings from './siblings';
|
|
8
9
|
const DEFAULT = '>1';
|
|
9
|
-
const cash = ((
|
|
10
|
-
|
|
10
|
+
const cash = ((markup, selector) => {
|
|
11
|
+
// NOTE: Use also runtime check isTemplateResult()??
|
|
12
|
+
const template = Object.assign(document.createElement('template'), { innerHTML: renderToString(markup).toString() });
|
|
11
13
|
if (!selector)
|
|
12
14
|
return template.content;
|
|
13
15
|
if (selector === DEFAULT)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { default as html } from './html';
|
|
2
|
-
export * from './html';
|
|
3
1
|
export { default as morph } from './morph';
|
|
4
2
|
export * from './morph';
|
|
5
3
|
export { default as queryMorph } from './query-morph';
|
|
6
4
|
export * from './query-morph';
|
|
5
|
+
export { default as renderToString } from './render-to-string';
|
|
6
|
+
export * from './render-to-string';
|
|
7
|
+
export { default as unsafeHtml } from './unsafe-html';
|
|
8
|
+
export * from './unsafe-html';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { default as html } from './html';
|
|
2
|
-
export * from './html';
|
|
3
1
|
export { default as morph } from './morph';
|
|
4
2
|
export * from './morph';
|
|
5
3
|
export { default as queryMorph } from './query-morph';
|
|
6
4
|
export * from './query-morph';
|
|
5
|
+
export { default as renderToString } from './render-to-string';
|
|
6
|
+
export * from './render-to-string';
|
|
7
|
+
export { default as unsafeHtml } from './unsafe-html';
|
|
8
|
+
export * from './unsafe-html';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function (
|
|
1
|
+
import type { TemplateResult } from '../tpl';
|
|
2
|
+
export default function (markup: TemplateResult, fromEl?: Element, options?: {
|
|
3
3
|
cb: () => void;
|
|
4
4
|
}): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import morphdom from '../internal/vendor/morphdom';
|
|
2
|
-
|
|
2
|
+
import renderToString from './render-to-string';
|
|
3
|
+
export default function (markup, fromEl, options) {
|
|
3
4
|
if (!fromEl)
|
|
4
5
|
return;
|
|
5
|
-
morphdom(fromEl,
|
|
6
|
+
morphdom(fromEl, renderToString(markup).toString(), {
|
|
6
7
|
onBeforeElUpdated: (fromEl, toEl) => !fromEl.isEqualNode(toEl),
|
|
7
8
|
onBeforeElChildrenUpdated: (fromEl, toEl) => !toEl.matches('image-view,navigation-title'), // NOTE: image-view will alter it's contents! This is required to not empty it up again!
|
|
8
9
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function (scopedSelector: string, template:
|
|
1
|
+
import type { TemplateResult } from '../tpl';
|
|
2
|
+
export default function (scopedSelector: string, template: TemplateResult, container?: Element, options?: {
|
|
3
3
|
cb?: () => boolean;
|
|
4
4
|
removeIf?: boolean;
|
|
5
5
|
}): void;
|
|
@@ -5,7 +5,7 @@ export default function (scopedSelector, template, container, options) {
|
|
|
5
5
|
return;
|
|
6
6
|
if ('boolean' === typeof options?.removeIf && options?.removeIf)
|
|
7
7
|
return container?.querySelector(`:scope>${scopedSelector}`)?.remove();
|
|
8
|
-
const fromEl = container?.querySelector(`:scope>${scopedSelector}`) ?? container?.appendChild($(template
|
|
8
|
+
const fromEl = container?.querySelector(`:scope>${scopedSelector}`) ?? container?.appendChild($(template, '>1'));
|
|
9
9
|
if (!fromEl)
|
|
10
10
|
return;
|
|
11
11
|
morph(template, fromEl);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TemplateResult } from '../tpl';
|
|
2
|
+
export declare class TrustedMarkup {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
constructor(value: string);
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Flatten a TemplateResult (from `html`) into an escaped TrustedMarkup
|
|
9
|
+
* string. Use this only at morph/queryMorph call sites — anywhere feeding
|
|
10
|
+
* `render()` should keep passing the raw TemplateResult straight through.
|
|
11
|
+
*/
|
|
12
|
+
export default function renderToString(template: TemplateResult): TrustedMarkup;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isTemplateResult } from '../tpl';
|
|
2
|
+
// morph.ts and queryMorph.ts only need something with `.toString()` that
|
|
3
|
+
// yields a safe, escaped HTML string — this is that, built on top of the
|
|
4
|
+
// same TemplateResult instead of a separate tag function.
|
|
5
|
+
// values built via `raw` itself are trusted markup; wrap them so `stringify`
|
|
6
|
+
// knows to skip escaping — same idea as lit-html's `unsafeHTML`
|
|
7
|
+
export class TrustedMarkup {
|
|
8
|
+
value;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return this.value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const ESCAPE_MAP = {
|
|
17
|
+
'&': '&',
|
|
18
|
+
'<': '<',
|
|
19
|
+
'>': '>',
|
|
20
|
+
'"': '"',
|
|
21
|
+
"'": ''',
|
|
22
|
+
};
|
|
23
|
+
function escapeHtml(str) {
|
|
24
|
+
return str.replace(/[&<>"']/g, (ch) => ESCAPE_MAP[ch]);
|
|
25
|
+
}
|
|
26
|
+
function stringifyValue(value) {
|
|
27
|
+
if (value === null || value === undefined || value === false)
|
|
28
|
+
return '';
|
|
29
|
+
if (value instanceof TrustedMarkup)
|
|
30
|
+
return value.value;
|
|
31
|
+
if (isTemplateResult(value))
|
|
32
|
+
return renderToString(value).value;
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value.map(stringifyValue).join('');
|
|
35
|
+
return escapeHtml(String(value));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Flatten a TemplateResult (from `html`) into an escaped TrustedMarkup
|
|
39
|
+
* string. Use this only at morph/queryMorph call sites — anywhere feeding
|
|
40
|
+
* `render()` should keep passing the raw TemplateResult straight through.
|
|
41
|
+
*/
|
|
42
|
+
export default function renderToString(template) {
|
|
43
|
+
let out = template.strings[0];
|
|
44
|
+
for (let i = 0; i < template.values.length; i++) {
|
|
45
|
+
out += stringifyValue(template.values[i]) + template.strings[i + 1];
|
|
46
|
+
}
|
|
47
|
+
return new TrustedMarkup(out.replace(/>\s+</g, '><').trim());
|
|
48
|
+
}
|
package/generated/tpl/html.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Purely structural — captures strings/values as-is. render.ts relies on
|
|
2
|
+
// `strings` identity (TemplateStringsArray) for its template cache, so this
|
|
3
|
+
// must stay exactly this shape: no wrapping, no cloning, no new object
|
|
4
|
+
// allocation beyond the literal { strings, values }.
|
|
1
5
|
export default function (strings, ...values) {
|
|
2
6
|
return { strings, values };
|
|
3
7
|
}
|
package/generated/tpl/index.d.ts
CHANGED
package/generated/tpl/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default (v) => !!v && typeof v === 'object' && 'strings' in v && 'values' in v;
|