@swiftwc/ui 0.0.0-dev.87 → 0.0.0-dev.89
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.
|
@@ -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 { html as htmx,
|
|
9
|
+
import { html as htmx, 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) => {
|
|
@@ -1031,9 +1031,12 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1031
1031
|
// if (!cvl) currentValueLabel.setAttribute('foreground', 'secondary')
|
|
1032
1032
|
// else currentValueLabel.removeAttribute('foreground')
|
|
1033
1033
|
const title = this.#currentValueLabel || this.#selection || this.getAttribute(this.constructor.ATTR.PLACEHOLDER), systemImage = this.#currentValueIcon || this.getAttribute(this.constructor.ATTR.PLACEHOLDER_ICON);
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
morph(
|
|
1034
|
+
queryMorph(':not([slot])', htmx `<span>${title}</span>`, currentValueLabel, { removeIf: !title }); //renderLabelTitle(currentValueLabel, this.#currentValueLabel || this.#selection || this.getAttribute((this.constructor as typeof PickerView).ATTR.PLACEHOLDER))
|
|
1035
|
+
queryMorph('[slot=icon]', htmx `<image-view slot="icon" system-name="${systemImage}"></image-view>`, currentValueLabel, { removeIf: !systemImage }); //renderLabelIcon(currentValueLabel, this.#currentValueIcon || this.getAttribute((this.constructor as typeof PickerView).ATTR.PLACEHOLDER_ICON))
|
|
1036
|
+
// morph(
|
|
1037
|
+
// htmx`<label-view>${systemImage ? htmx`<image-view slot="icon" system-name="${systemImage}"></image-view>` : null}${title ? htmx`<span>${title}</span>` : null}</label-view>`,
|
|
1038
|
+
// currentValueLabel
|
|
1039
|
+
// ) NOTE: not this bc/ help tooltip right now is added to trigger label and this mangles it
|
|
1037
1040
|
break;
|
|
1038
1041
|
}
|
|
1039
1042
|
case 'menu': {
|
|
@@ -1043,9 +1046,12 @@ export class PickerView extends FormAssociatedBase {
|
|
|
1043
1046
|
// if (!cvl) currentValueLabel.setAttribute('foreground', 'secondary')
|
|
1044
1047
|
// else currentValueLabel.removeAttribute('foreground')
|
|
1045
1048
|
const title = this.#currentValueLabel || this.#selection || this.getAttribute(this.constructor.ATTR.PLACEHOLDER), systemImage = this.#currentValueIcon || this.getAttribute(this.constructor.ATTR.PLACEHOLDER_ICON);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
morph(
|
|
1049
|
+
queryMorph(':not([slot])', htmx `<span>${title}</span>`, currentValueLabel, { removeIf: !title }); //renderLabelTitle(currentValueLabel, this.#currentValueLabel || this.#selection || this.getAttribute((this.constructor as typeof PickerView).ATTR.PLACEHOLDER))
|
|
1050
|
+
queryMorph('[slot=icon]', htmx `<image-view slot="icon" system-name="${systemImage}"></image-view>`, currentValueLabel, { removeIf: !systemImage }); //renderLabelIcon(currentValueLabel, this.#currentValueIcon || this.getAttribute((this.constructor as typeof PickerView).ATTR.PLACEHOLDER_ICON))
|
|
1051
|
+
// morph(
|
|
1052
|
+
// 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>`,
|
|
1053
|
+
// currentValueLabel
|
|
1054
|
+
// ) NOTE: not this bc/ help tooltip right now is added to trigger label and this mangles it
|
|
1049
1055
|
break;
|
|
1050
1056
|
}
|
|
1051
1057
|
case 'inline':
|
package/generated/css/index.css
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
--toolbar-cell-box-shadow: var(--control-clear-glass-box-shadow);
|
|
98
98
|
--menu-bg: var(--control-clear-glass-bg);
|
|
99
99
|
--menu-bg-dark: var(--control-clear-glass-bg-dark);
|
|
100
|
-
--menu-max-inline-size:
|
|
100
|
+
--menu-max-inline-size: 20rem;
|
|
101
101
|
--menu-max-block-size: 60vh;
|
|
102
102
|
--menu-spacing: 1rem;
|
|
103
103
|
--menu-host-offscreen-transform: scale(0);
|
|
@@ -1,54 +1,95 @@
|
|
|
1
1
|
import { I18n } from '../../i18n';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { html, queryMorph } from '../../morphdom';
|
|
3
|
+
// type ButtonRole = keyof ReturnType<typeof I18n.t<'ButtonRole'>>
|
|
4
|
+
// function renderPlaceholder(el: HTMLElement, role: string | null, titleKey?: ButtonRole, config?: Record<string, string>) {
|
|
5
|
+
// // if (!el.isConnected) return
|
|
6
|
+
// // self.requestAnimationFrame(() => {
|
|
7
|
+
// // if (!el.isConnected) return
|
|
8
|
+
// let title: string | undefined, systemImage: string | undefined
|
|
9
|
+
// // const label = el.querySelector(':scope>[slot=placeholder]') ?? el.appendChild($(`<label-view slot="placeholder"></label-view>`, '>1'))
|
|
10
|
+
// switch (role) {
|
|
11
|
+
// case 'cancel':
|
|
12
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Cancel //label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Cancel)
|
|
13
|
+
// systemImage = config?.['cancel-button-icon'] ?? '' //label.setAttribute('system-image', config?.['cancel-button-icon'] ?? '')
|
|
14
|
+
// break
|
|
15
|
+
// case 'close':
|
|
16
|
+
// if (el.closest('[is=alert-dialog]')) {
|
|
17
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').OK //.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').OK)
|
|
18
|
+
// } else {
|
|
19
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Close //label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Close)
|
|
20
|
+
// systemImage = config?.['close-button-icon'] ?? '' //label.setAttribute('system-image', config?.['close-button-icon'] ?? '')
|
|
21
|
+
// }
|
|
22
|
+
// break
|
|
23
|
+
// case 'confirm':
|
|
24
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Confirm //label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Confirm)
|
|
25
|
+
// systemImage = config?.['confirm-button-icon'] ?? '' //label.setAttribute('system-image', config?.['confirm-button-icon'] ?? '')
|
|
26
|
+
// break
|
|
27
|
+
// case 'confirmation-action':
|
|
28
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Confirm //label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Confirm)
|
|
29
|
+
// systemImage = config?.['confirm-button-icon'] ?? '' //label.setAttribute('system-image', config?.['confirm-button-icon'] ?? '')
|
|
30
|
+
// break
|
|
31
|
+
// case 'cancellation-action':
|
|
32
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Cancel //label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Cancel)
|
|
33
|
+
// systemImage = config?.['cancel-button-icon'] ?? '' //label.setAttribute('system-image', config?.['cancel-button-icon'] ?? '')
|
|
34
|
+
// break
|
|
35
|
+
// case 'destructive':
|
|
36
|
+
// title = titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Destructive // label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Destructive)
|
|
37
|
+
// systemImage = config?.['delete-button-icon'] ?? '' // label.setAttribute('system-image', config?.['delete-button-icon'] ?? '')
|
|
38
|
+
// break
|
|
39
|
+
// // default:
|
|
40
|
+
// // label?.remove()
|
|
41
|
+
// // break
|
|
42
|
+
// }
|
|
43
|
+
// queryMorph(
|
|
44
|
+
// '[slot=placeholder]',
|
|
45
|
+
// html`<label-view slot="placeholder">${systemImage ? html`<image-view slot="icon" system-name="${systemImage}"></image-view>` : null}${title ? html`<span>${title}</span>` : null}</label-view>`,
|
|
46
|
+
// el,
|
|
47
|
+
// { removeIf: !title }
|
|
48
|
+
// )
|
|
49
|
+
// // if (role) {
|
|
50
|
+
// // label.setAttribute('title', I18n.t('ButtonRole').Default.Destructive)
|
|
51
|
+
// // } else label?.remove()
|
|
52
|
+
// // })
|
|
53
|
+
// }
|
|
54
|
+
export default function (target, role, titleKey, config) {
|
|
55
|
+
if (!target)
|
|
56
|
+
return;
|
|
57
|
+
const overiderTitle = typeof titleKey === 'string' && titleKey in I18n.t('ButtonRole') ? titleKey : undefined;
|
|
58
|
+
// renderPlaceholder(target, role, overiderTitle, config)
|
|
59
|
+
let title, systemImage;
|
|
60
|
+
// const label = el.querySelector(':scope>[slot=placeholder]') ?? el.appendChild($(`<label-view slot="placeholder"></label-view>`, '>1'))
|
|
8
61
|
switch (role) {
|
|
9
62
|
case 'cancel':
|
|
10
|
-
|
|
11
|
-
|
|
63
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Cancel;
|
|
64
|
+
systemImage = config?.['cancel-button-icon'] ?? '';
|
|
12
65
|
break;
|
|
13
66
|
case 'close':
|
|
14
|
-
if (
|
|
15
|
-
|
|
67
|
+
if (target.closest('[is=alert-dialog]')) {
|
|
68
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').OK;
|
|
16
69
|
}
|
|
17
70
|
else {
|
|
18
|
-
|
|
19
|
-
|
|
71
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Close;
|
|
72
|
+
systemImage = config?.['close-button-icon'] ?? '';
|
|
20
73
|
}
|
|
21
74
|
break;
|
|
22
75
|
case 'confirm':
|
|
23
|
-
|
|
24
|
-
|
|
76
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Confirm;
|
|
77
|
+
systemImage = config?.['confirm-button-icon'] ?? '';
|
|
25
78
|
break;
|
|
26
79
|
case 'confirmation-action':
|
|
27
|
-
|
|
28
|
-
|
|
80
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Confirm;
|
|
81
|
+
systemImage = config?.['confirm-button-icon'] ?? '';
|
|
29
82
|
break;
|
|
30
83
|
case 'cancellation-action':
|
|
31
|
-
|
|
32
|
-
|
|
84
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Cancel;
|
|
85
|
+
systemImage = config?.['cancel-button-icon'] ?? '';
|
|
33
86
|
break;
|
|
34
87
|
case 'destructive':
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
break;
|
|
38
|
-
default:
|
|
39
|
-
label?.remove();
|
|
88
|
+
title = overiderTitle && overiderTitle in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[overiderTitle] : I18n.t('ButtonRole').Destructive;
|
|
89
|
+
systemImage = config?.['delete-button-icon'] ?? '';
|
|
40
90
|
break;
|
|
41
91
|
}
|
|
42
|
-
|
|
43
|
-
// label.setAttribute('title', I18n.t('ButtonRole').Default.Destructive)
|
|
44
|
-
// } else label?.remove()
|
|
45
|
-
// })
|
|
46
|
-
}
|
|
47
|
-
export default function (target, role, titleKey, config) {
|
|
48
|
-
if (!target)
|
|
49
|
-
return;
|
|
50
|
-
const overiderTitle = typeof titleKey === 'string' && titleKey in I18n.t('ButtonRole') ? titleKey : undefined;
|
|
51
|
-
renderPlaceholder(target, role, overiderTitle);
|
|
92
|
+
queryMorph('[slot=placeholder]', html `<label-view slot="placeholder">${systemImage ? html `<image-view slot="icon" system-name="${systemImage}"></image-view>` : null}${title ? html `<span>${title}</span>` : null}</label-view>`, target, { removeIf: !title });
|
|
52
93
|
// CleanupRegistry.unregister(target, 'i18n')
|
|
53
94
|
// CleanupRegistry.register(target, onoff('localechange', () => renderPlaceholder(target, role, overiderTitle), I18n.on).on(), 'i18n')
|
|
54
95
|
}
|
package/package.json
CHANGED
package/scss/base/_root.scss
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
--menu-bg: var(--control-clear-glass-bg); //--menu-bg: var(--liquid-glass-bg); //oklch(var(--sidebar-bg-lch) / var(--sidebar-bg-alpha));
|
|
192
192
|
--menu-bg-dark: var(--control-clear-glass-bg-dark); //--menu-bg-dark: var(--liquid-glass-bg-dark); //oklch(var(--sidebar-bg-lch-dark) / var(--sidebar-bg-alpha-dark));
|
|
193
193
|
|
|
194
|
-
--menu-max-inline-size:
|
|
194
|
+
--menu-max-inline-size: 20rem;
|
|
195
195
|
--menu-max-block-size: 60vh;
|
|
196
196
|
--menu-spacing: 1rem;
|
|
197
197
|
--menu-host-offscreen-transform: scale(0);
|