@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.
Files changed (90) hide show
  1. package/generated/client/index.js +7 -7
  2. package/generated/components/alert-dialog.d.ts +1 -1
  3. package/generated/components/alert-dialog.js +1 -1
  4. package/generated/components/body-view.d.ts +1 -1
  5. package/generated/components/body-view.js +1 -1
  6. package/generated/components/confirmation-dialog.d.ts +1 -2
  7. package/generated/components/confirmation-dialog.js +1 -2
  8. package/generated/components/content-unavailable.js +11 -11
  9. package/generated/components/date-picker.js +17 -17
  10. package/generated/components/disclosure-group.d.ts +4 -1
  11. package/generated/components/disclosure-group.js +5 -1
  12. package/generated/components/fine-tooltip.js +2 -1
  13. package/generated/components/form-view.d.ts +2 -0
  14. package/generated/components/form-view.js +2 -0
  15. package/generated/components/h-stack.d.ts +2 -2
  16. package/generated/components/h-stack.js +2 -2
  17. package/generated/components/image-view.d.ts +4 -0
  18. package/generated/components/image-view.js +7 -2
  19. package/generated/components/label-view.d.ts +7 -3
  20. package/generated/components/label-view.js +14 -10
  21. package/generated/components/labeled-content.d.ts +13 -0
  22. package/generated/components/labeled-content.js +26 -12
  23. package/generated/components/list-view.d.ts +2 -0
  24. package/generated/components/list-view.js +2 -0
  25. package/generated/components/menu-view.js +12 -12
  26. package/generated/components/navigation-large-title.d.ts +7 -0
  27. package/generated/components/navigation-large-title.js +7 -0
  28. package/generated/components/navigation-split-view.d.ts +1 -1
  29. package/generated/components/navigation-split-view.js +1 -1
  30. package/generated/components/navigation-stack.d.ts +1 -1
  31. package/generated/components/navigation-stack.js +1 -1
  32. package/generated/components/navigation-title.d.ts +5 -0
  33. package/generated/components/navigation-title.js +7 -1
  34. package/generated/components/picker-view.d.ts +1 -1
  35. package/generated/components/picker-view.js +51 -50
  36. package/generated/components/progress-view.d.ts +1 -1
  37. package/generated/components/progress-view.js +21 -20
  38. package/generated/components/scroll-view-proxy.d.ts +1 -1
  39. package/generated/components/scroll-view-proxy.js +1 -1
  40. package/generated/components/scroll-view.d.ts +2 -0
  41. package/generated/components/scroll-view.js +16 -14
  42. package/generated/components/section-view.js +11 -11
  43. package/generated/components/sheet-view.d.ts +3 -0
  44. package/generated/components/sheet-view.js +3 -0
  45. package/generated/components/sidebar-toggle.d.ts +3 -0
  46. package/generated/components/sidebar-toggle.js +3 -0
  47. package/generated/components/sidebar-view.d.ts +3 -0
  48. package/generated/components/sidebar-view.js +3 -0
  49. package/generated/components/tab-bar.d.ts +1 -1
  50. package/generated/components/tab-bar.js +1 -1
  51. package/generated/components/tab-item.d.ts +3 -0
  52. package/generated/components/tab-item.js +3 -0
  53. package/generated/components/tab-view.d.ts +1 -0
  54. package/generated/components/tab-view.js +1 -0
  55. package/generated/components/table-view.d.ts +1 -1
  56. package/generated/components/table-view.js +35 -35
  57. package/generated/components/text-field.d.ts +2 -0
  58. package/generated/components/text-field.js +16 -14
  59. package/generated/components/toggle-view.js +30 -13
  60. package/generated/components/tool-bar-item-group.d.ts +1 -1
  61. package/generated/components/tool-bar-item-group.js +1 -1
  62. package/generated/components/tool-bar-item.d.ts +1 -1
  63. package/generated/components/tool-bar-item.js +1 -1
  64. package/generated/components/tool-bar.d.ts +1 -1
  65. package/generated/components/tool-bar.js +28 -28
  66. package/generated/components/v-stack.d.ts +2 -2
  67. package/generated/components/v-stack.js +2 -2
  68. package/generated/internal/utils/cash/index.d.ts +4 -3
  69. package/generated/internal/utils/cash/index.js +4 -2
  70. package/generated/internal/utils/ensure-placeholder.js +2 -1
  71. package/generated/morphdom/index.d.ts +4 -2
  72. package/generated/morphdom/index.js +4 -2
  73. package/generated/morphdom/morph.d.ts +2 -2
  74. package/generated/morphdom/morph.js +3 -2
  75. package/generated/morphdom/query-morph.d.ts +2 -2
  76. package/generated/morphdom/query-morph.js +1 -1
  77. package/generated/morphdom/render-to-string.d.ts +12 -0
  78. package/generated/morphdom/render-to-string.js +48 -0
  79. package/generated/morphdom/unsafe-html.d.ts +2 -0
  80. package/generated/morphdom/unsafe-html.js +4 -0
  81. package/generated/tpl/html.js +4 -0
  82. package/generated/tpl/index.d.ts +2 -0
  83. package/generated/tpl/index.js +2 -0
  84. package/generated/tpl/is-template-result.d.ts +3 -0
  85. package/generated/tpl/is-template-result.js +1 -0
  86. package/package.json +6 -4
  87. package/web-components.css-data/en.json +28 -0
  88. package/web-components.html-data/en.json +179 -117
  89. package/generated/morphdom/html.d.ts +0 -8
  90. 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 { html, queryMorph } from '../morphdom';
6
+ import { queryMorph } from '../morphdom';
7
7
  import { Snapshot } from '../snapshot';
8
+ import { html } from '../tpl';
8
9
  /**
9
- * @summary Display selectable, sortable data arranged in rows and columns.
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 ??= $(String.raw `
28
- <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>
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-header-principal-stack">
34
- <slot name="header-principal"></slot>
40
+ <div part="root table-column-stack">
41
+ <slot name="column"></slot>
35
42
  </div>
36
- <div part="root table-header-trailing-stack">
37
- <slot name="header-trailing"></slot>
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
- <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;
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 { html, queryMorph } from '../morphdom';
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 {required}
39
+ * @type {boolean}
37
40
  */
38
41
  'required',
39
42
  /**
40
- * @type {disabled}
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 ??= $(String.raw `
48
- <label part="root text-field-stack">
49
- <div part="root text-field-label-stack">
50
- <slot name="label"></slot>
51
- </div>
52
- <div part="root text-field-input-stack">
53
- <input type="text" part="root input text-field-form-input">
54
- </div>
55
- <slot name="validity-options" hidden></slot>
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 { html, queryMorph } from '../morphdom';
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 ['label', 'name', 'value', 'is-on', 'keyboard-type', 'required', 'disabled'];
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 ??= $(String.raw `
23
- <label part="root toggle-stack">
24
- <div part="root toggle-label-stack">
25
- <slot name="label"></slot>
26
- </div>
27
- <div part="root toggle-input-stack">
28
- <!--<input type="checkbox" part="root input toggle-form-input">-->
29
- <div part="root toggle-form-input" tabindex="0"></div>
30
- </div>
31
- <slot name="validity-options" hidden></slot>
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 model that represents a group of `ToolbarItems` which can be placed in the toolbar or navigation bar.
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 model that represents a group of `ToolbarItems` which can be placed in the toolbar or navigation bar.
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() {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @summary A model that represents an item which can be placed in the toolbar or navigation bar.
2
+ * @summary A view placed in the toolbar or navigation bar.
3
3
  */
4
4
  export declare class ToolBarItem extends HTMLElement {
5
5
  #private;
@@ -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 model that represents an item which can be placed in the toolbar or navigation bar.
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 Populates the toolbar or navigation bar with the specified items.
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 Populates the toolbar or navigation bar with the specified items.
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 ??= $(String.raw `
24
- <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>`));
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 {@templateSet} template — The main-axis grid template
6
+ * @attr {@Template} template — The main-axis grid template
7
7
  *
8
- * @attr {@spacingSet} spacing — The gap between the primary axis
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 {@templateSet} template — The main-axis grid template
7
+ * @attr {@Template} template — The main-axis grid template
8
8
  *
9
- * @attr {@spacingSet} spacing — The gap between the primary axis
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
- (innerHTML: string): DocumentFragment;
11
- <T extends Element = Element>(innerHTML: string, selector: typeof DEFAULT): T;
12
- <T extends Element = Element>(innerHTML: string, selector: string): T;
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 = ((innerHTML, selector) => {
10
- const template = Object.assign(document.createElement('template'), { innerHTML });
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,5 +1,6 @@
1
1
  import { I18n } from '../../i18n';
2
- import { html, queryMorph } from '../../morphdom';
2
+ import { queryMorph } from '../../morphdom';
3
+ import { html } from '../../tpl';
3
4
  export default function (target, role, titleKey, config) {
4
5
  if (!target)
5
6
  return;
@@ -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 { TrustedMarkup } from './html';
2
- export default function (template: TrustedMarkup, fromEl?: Element, options?: {
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
- export default function (template, fromEl, options) {
2
+ import renderToString from './render-to-string';
3
+ export default function (markup, fromEl, options) {
3
4
  if (!fromEl)
4
5
  return;
5
- morphdom(fromEl, template.toString(), {
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 { TrustedMarkup } from './html';
2
- export default function (scopedSelector: string, template: TrustedMarkup, container?: Element, options?: {
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.toString(), '>1'));
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
+ '&': '&amp;',
18
+ '<': '&lt;',
19
+ '>': '&gt;',
20
+ '"': '&quot;',
21
+ "'": '&#39;',
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
+ }
@@ -0,0 +1,2 @@
1
+ import { TrustedMarkup } from './render-to-string';
2
+ export default function (value: string): TrustedMarkup;
@@ -0,0 +1,4 @@
1
+ import { TrustedMarkup } from './render-to-string';
2
+ export default function (value) {
3
+ return new TrustedMarkup(value);
4
+ }
@@ -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
  }
@@ -1,4 +1,6 @@
1
1
  export { default as html } from './html';
2
2
  export * from './html';
3
+ export { default as isTemplateResult } from './is-template-result';
4
+ export * from './is-template-result';
3
5
  export { default as render } from './render';
4
6
  export * from './render';
@@ -1,4 +1,6 @@
1
1
  export { default as html } from './html';
2
2
  export * from './html';
3
+ export { default as isTemplateResult } from './is-template-result';
4
+ export * from './is-template-result';
3
5
  export { default as render } from './render';
4
6
  export * from './render';
@@ -0,0 +1,3 @@
1
+ import type { TemplateResult } from './html';
2
+ declare const _default: (v: unknown) => v is TemplateResult;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export default (v) => !!v && typeof v === 'object' && 'strings' in v && 'values' in v;