@threadlabs/looma 0.5.0 → 0.5.2
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/README.md +1 -1
- package/components/shared/input-modality.d.ts +8 -0
- package/components/shared/input-modality.js +2 -0
- package/components/ui-button/ui-button.html +42 -1
- package/components/ui-combobox/ui-combobox.html +12 -4
- package/components/ui-dialog/ui-dialog.html +13 -0
- package/components/ui-editor-insert-table-grid/ui-editor-insert-table-grid.html +1 -1
- package/components/ui-editor-mention-menu/ui-editor-mention-menu.html +1 -1
- package/components/ui-editor-table-context-menu/ui-editor-table-context-menu.html +6 -2
- package/components/ui-editor-table-overlay/ui-editor-table-overlay.html +20 -4
- package/components/ui-editor-table-toolbar/ui-editor-table-toolbar.html +8 -4
- package/components/ui-form-field/ui-form-field.html +18 -7
- package/components/ui-icon/ui-icon.html +5 -1
- package/components/ui-icon-button/ui-icon-button.html +44 -1
- package/components/ui-popover/ui-popover.js +10 -2
- package/components/ui-search-shell/ui-search-shell.html +7 -0
- package/components/ui-search-shell/ui-search-shell.js +9 -0
- package/components/ui-tabs/ui-tabs.html +1 -1
- package/components/ui-toast-region/ui-toast-region.html +1 -1
- package/components/ui-tree-item/ui-tree-item.html +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/styles/ui-affordance-scope.css +1 -1
- package/styles/ui-avatar-group.css +1 -1
- package/styles/ui-avatar.css +1 -1
- package/styles/ui-badge.css +1 -1
- package/styles/ui-button.css +42 -2
- package/styles/ui-callout.css +1 -1
- package/styles/ui-checkbox.css +1 -1
- package/styles/ui-cluster.css +1 -1
- package/styles/ui-combobox.css +1 -1
- package/styles/ui-container.css +1 -1
- package/styles/ui-context-menu.css +1 -1
- package/styles/ui-dialog.css +18 -1
- package/styles/ui-disclosure.css +1 -1
- package/styles/ui-editable.css +1 -1
- package/styles/ui-editor-insert-table-grid.css +1 -1
- package/styles/ui-editor-mention-menu.css +1 -1
- package/styles/ui-editor-slash-menu.css +1 -1
- package/styles/ui-editor-table-context-menu.css +1 -1
- package/styles/ui-editor-table-overlay.css +1 -1
- package/styles/ui-editor-table-toolbar.css +1 -1
- package/styles/ui-editor-toolbar.css +1 -1
- package/styles/ui-floating-action-button.css +1 -1
- package/styles/ui-form-field.css +24 -10
- package/styles/ui-grid.css +1 -1
- package/styles/ui-icon-button.css +52 -2
- package/styles/ui-icon.css +1 -1
- package/styles/ui-input.css +1 -1
- package/styles/ui-menu-item.css +1 -1
- package/styles/ui-menu.css +1 -1
- package/styles/ui-popover.css +1 -1
- package/styles/ui-radio-group.css +1 -1
- package/styles/ui-radio.css +1 -1
- package/styles/ui-reel.css +1 -1
- package/styles/ui-search-result-row.css +1 -1
- package/styles/ui-search-shell.css +11 -2
- package/styles/ui-select.css +1 -1
- package/styles/ui-separator.css +1 -1
- package/styles/ui-sidebar.css +1 -1
- package/styles/ui-stack.css +1 -1
- package/styles/ui-switch.css +1 -1
- package/styles/ui-switcher.css +1 -1
- package/styles/ui-tabs.css +1 -1
- package/styles/ui-textarea.css +1 -1
- package/styles/ui-toast-region.css +1 -1
- package/styles/ui-tooltip.css +1 -1
- package/styles/ui-top-bar.css +1 -1
- package/styles/ui-tree-item.css +10 -2
- package/styles/ui-tree.css +1 -1
- package/vanilla/UiAffordanceScope.d.ts +1 -1
- package/vanilla/UiAffordanceScope.js +2 -2
- package/vanilla/UiAvatar.d.ts +1 -1
- package/vanilla/UiAvatar.js +2 -2
- package/vanilla/UiAvatarGroup.d.ts +1 -1
- package/vanilla/UiAvatarGroup.js +2 -2
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +2 -2
- package/vanilla/UiButton.d.ts +3 -1
- package/vanilla/UiButton.js +3 -3
- package/vanilla/UiCallout.d.ts +1 -1
- package/vanilla/UiCallout.js +2 -2
- package/vanilla/UiCheckbox.d.ts +1 -1
- package/vanilla/UiCheckbox.js +2 -2
- package/vanilla/UiCluster.d.ts +1 -1
- package/vanilla/UiCluster.js +2 -2
- package/vanilla/UiCombobox.d.ts +1 -1
- package/vanilla/UiCombobox.js +3 -3
- package/vanilla/UiContainer.d.ts +1 -1
- package/vanilla/UiContainer.js +2 -2
- package/vanilla/UiContextMenu.d.ts +1 -1
- package/vanilla/UiContextMenu.js +2 -2
- package/vanilla/UiDialog.d.ts +1 -1
- package/vanilla/UiDialog.js +2 -2
- package/vanilla/UiDisclosure.d.ts +1 -1
- package/vanilla/UiDisclosure.js +2 -2
- package/vanilla/UiEditable.d.ts +1 -1
- package/vanilla/UiEditable.js +2 -2
- package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
- package/vanilla/UiEditorInsertTableGrid.js +3 -3
- package/vanilla/UiEditorMentionMenu.d.ts +1 -1
- package/vanilla/UiEditorMentionMenu.js +3 -3
- package/vanilla/UiEditorSlashMenu.d.ts +1 -1
- package/vanilla/UiEditorSlashMenu.js +2 -2
- package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
- package/vanilla/UiEditorTableContextMenu.js +3 -3
- package/vanilla/UiEditorTableOverlay.d.ts +1 -1
- package/vanilla/UiEditorTableOverlay.js +3 -3
- package/vanilla/UiEditorTableToolbar.d.ts +1 -1
- package/vanilla/UiEditorTableToolbar.js +3 -3
- package/vanilla/UiEditorToolbar.d.ts +1 -1
- package/vanilla/UiEditorToolbar.js +2 -2
- package/vanilla/UiFloatingActionButton.d.ts +1 -1
- package/vanilla/UiFloatingActionButton.js +2 -2
- package/vanilla/UiFormField.d.ts +1 -1
- package/vanilla/UiFormField.js +15 -6
- package/vanilla/UiGrid.d.ts +1 -1
- package/vanilla/UiGrid.js +2 -2
- package/vanilla/UiIcon.d.ts +1 -1
- package/vanilla/UiIcon.js +3 -3
- package/vanilla/UiIconButton.d.ts +1 -1
- package/vanilla/UiIconButton.js +2 -2
- package/vanilla/UiInput.d.ts +1 -1
- package/vanilla/UiInput.js +2 -2
- package/vanilla/UiMenu.d.ts +1 -1
- package/vanilla/UiMenu.js +2 -2
- package/vanilla/UiMenuItem.d.ts +1 -1
- package/vanilla/UiMenuItem.js +2 -2
- package/vanilla/UiPopover.d.ts +1 -1
- package/vanilla/UiPopover.js +2 -2
- package/vanilla/UiRadio.d.ts +1 -1
- package/vanilla/UiRadio.js +2 -2
- package/vanilla/UiRadioGroup.d.ts +1 -1
- package/vanilla/UiRadioGroup.js +2 -2
- package/vanilla/UiReel.d.ts +1 -1
- package/vanilla/UiReel.js +2 -2
- package/vanilla/UiSearchResultRow.d.ts +1 -1
- package/vanilla/UiSearchResultRow.js +2 -2
- package/vanilla/UiSearchShell.d.ts +1 -1
- package/vanilla/UiSearchShell.js +2 -2
- package/vanilla/UiSelect.d.ts +1 -1
- package/vanilla/UiSelect.js +2 -2
- package/vanilla/UiSeparator.d.ts +1 -1
- package/vanilla/UiSeparator.js +2 -2
- package/vanilla/UiSidebar.d.ts +1 -1
- package/vanilla/UiSidebar.js +2 -2
- package/vanilla/UiStack.d.ts +1 -1
- package/vanilla/UiStack.js +2 -2
- package/vanilla/UiSwitch.d.ts +1 -1
- package/vanilla/UiSwitch.js +2 -2
- package/vanilla/UiSwitcher.d.ts +1 -1
- package/vanilla/UiSwitcher.js +2 -2
- package/vanilla/UiTabs.d.ts +1 -1
- package/vanilla/UiTabs.js +3 -3
- package/vanilla/UiTextarea.d.ts +1 -1
- package/vanilla/UiTextarea.js +2 -2
- package/vanilla/UiToastRegion.d.ts +1 -1
- package/vanilla/UiToastRegion.js +3 -3
- package/vanilla/UiTooltip.d.ts +1 -1
- package/vanilla/UiTooltip.js +2 -2
- package/vanilla/UiTopBar.d.ts +1 -1
- package/vanilla/UiTopBar.js +1 -1
- package/vanilla/UiTree.d.ts +1 -1
- package/vanilla/UiTree.js +2 -2
- package/vanilla/UiTreeItem.d.ts +1 -1
- package/vanilla/UiTreeItem.js +2 -2
- package/vue/UiAffordanceScope.d.ts +2 -2
- package/vue/UiAffordanceScope.vue +92 -73
- package/vue/UiAvatar.d.ts +7 -7
- package/vue/UiAvatar.vue +145 -105
- package/vue/UiAvatarGroup.d.ts +4 -4
- package/vue/UiAvatarGroup.vue +134 -118
- package/vue/UiBadge.d.ts +4 -4
- package/vue/UiBadge.vue +113 -114
- package/vue/UiButton.d.ts +10 -6
- package/vue/UiButton.vue +289 -220
- package/vue/UiCallout.d.ts +2 -2
- package/vue/UiCallout.vue +154 -87
- package/vue/UiCheckbox.d.ts +14 -10
- package/vue/UiCheckbox.vue +228 -162
- package/vue/UiCluster.d.ts +2 -2
- package/vue/UiCluster.vue +53 -60
- package/vue/UiCombobox.d.ts +36 -32
- package/vue/UiCombobox.vue +1005 -416
- package/vue/UiContainer.d.ts +2 -2
- package/vue/UiContainer.vue +48 -51
- package/vue/UiContextMenu.d.ts +6 -4
- package/vue/UiContextMenu.vue +205 -116
- package/vue/UiDialog.d.ts +11 -9
- package/vue/UiDialog.vue +287 -212
- package/vue/UiDisclosure.d.ts +8 -6
- package/vue/UiDisclosure.vue +248 -159
- package/vue/UiEditable.d.ts +16 -12
- package/vue/UiEditable.vue +325 -205
- package/vue/UiEditorInsertTableGrid.d.ts +8 -8
- package/vue/UiEditorInsertTableGrid.vue +216 -157
- package/vue/UiEditorMentionMenu.d.ts +9 -9
- package/vue/UiEditorMentionMenu.vue +265 -222
- package/vue/UiEditorSlashMenu.d.ts +7 -7
- package/vue/UiEditorSlashMenu.vue +286 -240
- package/vue/UiEditorTableContextMenu.d.ts +5 -5
- package/vue/UiEditorTableContextMenu.vue +306 -193
- package/vue/UiEditorTableOverlay.d.ts +2 -2
- package/vue/UiEditorTableOverlay.vue +609 -369
- package/vue/UiEditorTableToolbar.d.ts +7 -7
- package/vue/UiEditorTableToolbar.vue +443 -268
- package/vue/UiEditorToolbar.d.ts +2 -2
- package/vue/UiEditorToolbar.vue +134 -121
- package/vue/UiFloatingActionButton.d.ts +6 -6
- package/vue/UiFloatingActionButton.vue +100 -99
- package/vue/UiFormField.d.ts +6 -6
- package/vue/UiFormField.vue +112 -80
- package/vue/UiGrid.d.ts +2 -2
- package/vue/UiGrid.vue +51 -57
- package/vue/UiIcon.d.ts +2 -2
- package/vue/UiIcon.vue +118 -89
- package/vue/UiIconButton.d.ts +11 -11
- package/vue/UiIconButton.vue +285 -206
- package/vue/UiInput.d.ts +9 -9
- package/vue/UiInput.vue +153 -127
- package/vue/UiMenu.d.ts +8 -6
- package/vue/UiMenu.vue +217 -143
- package/vue/UiMenuItem.d.ts +4 -4
- package/vue/UiMenuItem.vue +52 -46
- package/vue/UiPopover.d.ts +8 -6
- package/vue/UiPopover.vue +197 -137
- package/vue/UiRadio.d.ts +14 -10
- package/vue/UiRadio.vue +183 -117
- package/vue/UiRadioGroup.d.ts +14 -12
- package/vue/UiRadioGroup.vue +172 -111
- package/vue/UiReel.d.ts +3 -3
- package/vue/UiReel.vue +77 -77
- package/vue/UiSearchResultRow.d.ts +4 -4
- package/vue/UiSearchResultRow.vue +124 -115
- package/vue/UiSearchShell.d.ts +10 -8
- package/vue/UiSearchShell.vue +245 -176
- package/vue/UiSelect.d.ts +9 -9
- package/vue/UiSelect.vue +162 -134
- package/vue/UiSeparator.d.ts +2 -2
- package/vue/UiSeparator.vue +22 -27
- package/vue/UiSidebar.d.ts +20 -18
- package/vue/UiSidebar.vue +312 -224
- package/vue/UiStack.d.ts +3 -3
- package/vue/UiStack.vue +64 -70
- package/vue/UiSwitch.d.ts +12 -8
- package/vue/UiSwitch.vue +218 -150
- package/vue/UiSwitcher.d.ts +3 -3
- package/vue/UiSwitcher.vue +73 -75
- package/vue/UiTabs.d.ts +10 -8
- package/vue/UiTabs.vue +251 -210
- package/vue/UiTextarea.d.ts +11 -11
- package/vue/UiTextarea.vue +155 -128
- package/vue/UiToastRegion.d.ts +10 -8
- package/vue/UiToastRegion.vue +261 -198
- package/vue/UiTooltip.d.ts +14 -12
- package/vue/UiTooltip.vue +241 -177
- package/vue/UiTopBar.vue +51 -42
- package/vue/UiTree.d.ts +8 -6
- package/vue/UiTree.vue +157 -70
- package/vue/UiTreeItem.d.ts +24 -22
- package/vue/UiTreeItem.vue +456 -339
- package/vue/chunks/UiAffordanceScope.js +9 -16
- package/vue/chunks/UiAvatar.js +23 -29
- package/vue/chunks/UiAvatarGroup.js +16 -39
- package/vue/chunks/UiBadge.js +3 -12
- package/vue/chunks/UiButton.js +15 -18
- package/vue/chunks/UiCallout.js +8 -17
- package/vue/chunks/UiCheckbox.js +37 -40
- package/vue/chunks/UiCluster.js +3 -12
- package/vue/chunks/UiCombobox.js +224 -266
- package/vue/chunks/UiContainer.js +3 -12
- package/vue/chunks/UiContextMenu.js +39 -34
- package/vue/chunks/UiDialog.js +36 -39
- package/vue/chunks/UiDisclosure.js +43 -48
- package/vue/chunks/UiEditable.js +55 -57
- package/vue/chunks/UiEditorInsertTableGrid.js +55 -73
- package/vue/chunks/UiEditorMentionMenu.js +40 -81
- package/vue/chunks/UiEditorSlashMenu.js +28 -52
- package/vue/chunks/UiEditorTableContextMenu.js +32 -56
- package/vue/chunks/UiEditorTableOverlay.js +58 -82
- package/vue/chunks/UiEditorTableToolbar.js +61 -85
- package/vue/chunks/UiEditorToolbar.js +4 -13
- package/vue/chunks/UiFloatingActionButton.js +7 -21
- package/vue/chunks/UiFormField.js +15 -12
- package/vue/chunks/UiGrid.js +3 -12
- package/vue/chunks/UiIcon.js +20 -43
- package/vue/chunks/UiIconButton.js +16 -28
- package/vue/chunks/UiInput.js +20 -25
- package/vue/chunks/UiMenu.js +29 -33
- package/vue/chunks/UiMenuItem.js +4 -10
- package/vue/chunks/UiPopover.js +28 -29
- package/vue/chunks/UiRadio.js +36 -39
- package/vue/chunks/UiRadioGroup.js +30 -34
- package/vue/chunks/UiReel.js +6 -15
- package/vue/chunks/UiSearchResultRow.js +6 -19
- package/vue/chunks/UiSearchShell.js +25 -28
- package/vue/chunks/UiSelect.js +20 -23
- package/vue/chunks/UiSeparator.js +2 -8
- package/vue/chunks/UiSidebar.js +39 -44
- package/vue/chunks/UiStack.js +6 -15
- package/vue/chunks/UiSwitch.js +35 -38
- package/vue/chunks/UiSwitcher.js +6 -15
- package/vue/chunks/UiTabs.js +47 -85
- package/vue/chunks/UiTextarea.js +21 -26
- package/vue/chunks/UiToastRegion.js +38 -72
- package/vue/chunks/UiTooltip.js +34 -35
- package/vue/chunks/UiTopBar.js +1 -1
- package/vue/chunks/UiTree.js +20 -15
- package/vue/chunks/UiTreeItem.js +85 -102
- package/vue/components.css +3994 -3764
- package/vue/index.d.ts +1 -0
- package/vue/index.js +2 -1
package/vue/UiEditable.vue
CHANGED
|
@@ -1,267 +1,387 @@
|
|
|
1
|
-
<!-- Generated by HTML Next 1.0.0-alpha.
|
|
1
|
+
<!-- Generated by HTML Next 1.0.0-alpha.2 for Vue 3.5. Do not edit. -->
|
|
2
2
|
<script setup lang="ts">
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
computed,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onMounted,
|
|
7
|
+
ref,
|
|
8
|
+
shallowRef,
|
|
9
|
+
useTemplateRef,
|
|
10
|
+
watchEffect,
|
|
11
|
+
} from 'vue'
|
|
12
|
+
import * as controllerModule from '../components/ui-editable/ui-editable.js'
|
|
5
13
|
|
|
6
|
-
defineOptions({ inheritAttrs: false })
|
|
14
|
+
defineOptions({ inheritAttrs: false })
|
|
7
15
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
hint: "",
|
|
27
|
-
label: "Edit value",
|
|
28
|
-
value: "",
|
|
29
|
-
});
|
|
16
|
+
const props = withDefaults(
|
|
17
|
+
defineProps<{
|
|
18
|
+
actions?: boolean
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
edit?: boolean
|
|
21
|
+
hint?: string
|
|
22
|
+
label?: string
|
|
23
|
+
value?: string
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
actions: false,
|
|
27
|
+
disabled: false,
|
|
28
|
+
edit: false,
|
|
29
|
+
hint: '',
|
|
30
|
+
label: 'Edit value',
|
|
31
|
+
value: '',
|
|
32
|
+
},
|
|
33
|
+
)
|
|
30
34
|
const emit = defineEmits<{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
'update:edit': [value: boolean]
|
|
36
|
+
'update:value': [value: string]
|
|
37
|
+
input: [
|
|
38
|
+
detail: { readonly value: string; readonly trigger: 'keyboard' | 'pointer' | 'programmatic' },
|
|
39
|
+
]
|
|
40
|
+
change: [
|
|
41
|
+
detail: {
|
|
42
|
+
readonly value: string
|
|
43
|
+
readonly previousValue: string
|
|
44
|
+
readonly trigger: 'keyboard' | 'pointer' | 'programmatic'
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
'edit-change': [
|
|
48
|
+
detail: {
|
|
49
|
+
readonly edit: boolean
|
|
50
|
+
readonly reason:
|
|
51
|
+
| 'activate'
|
|
52
|
+
| 'commit'
|
|
53
|
+
| 'cancel'
|
|
54
|
+
| 'light-dismiss'
|
|
55
|
+
| 'escape'
|
|
56
|
+
| 'programmatic'
|
|
57
|
+
readonly trigger: 'keyboard' | 'pointer' | 'programmatic'
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
}>()
|
|
61
|
+
|
|
62
|
+
const root = ref<HTMLElement | null>(null)
|
|
63
|
+
const previewElement = useTemplateRef<HTMLElement>('preview')
|
|
64
|
+
const inputElement = useTemplateRef<HTMLElement>('input')
|
|
65
|
+
const internalEdit = ref(false)
|
|
66
|
+
const internalValue = ref('')
|
|
67
|
+
const draft = ref('')
|
|
68
|
+
|
|
69
|
+
/** The values the styles' :host-state() rules test. */
|
|
70
|
+
const hostState = computed(() =>
|
|
71
|
+
[
|
|
72
|
+
internalEdit.value && 'internalEdit',
|
|
73
|
+
props.disabled && 'disabled',
|
|
74
|
+
].filter(Boolean).join(' ')
|
|
75
|
+
)
|
|
40
76
|
|
|
41
77
|
/** Dispatches a component event to Vue listeners and, for controllers and page code, on the root. */
|
|
42
|
-
|
|
43
|
-
const declared
|
|
78
|
+
function dispatch(name: string, detail?: unknown): boolean {
|
|
79
|
+
const declared: Record<string, EventInit | undefined> = {
|
|
80
|
+
input: { bubbles: true, composed: true, cancelable: false },
|
|
81
|
+
change: { bubbles: true, composed: true, cancelable: false },
|
|
82
|
+
'edit-change': { bubbles: true, composed: true, cancelable: false },
|
|
83
|
+
}
|
|
44
84
|
const checks: Record<string, (detail: unknown) => boolean> = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
input: (detail) =>
|
|
86
|
+
detail !== null && typeof detail === 'object' && !Array.isArray(detail)
|
|
87
|
+
&& typeof (detail as Record<string, unknown>)['value'] === 'string'
|
|
88
|
+
&& ((detail as Record<string, unknown>)['trigger'] === 'keyboard'
|
|
89
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'pointer'
|
|
90
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'programmatic')
|
|
91
|
+
&& Object.keys(detail as object).every((key) => ['value', 'trigger'].includes(key)),
|
|
92
|
+
change: (detail) =>
|
|
93
|
+
detail !== null && typeof detail === 'object' && !Array.isArray(detail)
|
|
94
|
+
&& typeof (detail as Record<string, unknown>)['value'] === 'string'
|
|
95
|
+
&& typeof (detail as Record<string, unknown>)['previousValue'] === 'string'
|
|
96
|
+
&& ((detail as Record<string, unknown>)['trigger'] === 'keyboard'
|
|
97
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'pointer'
|
|
98
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'programmatic')
|
|
99
|
+
&& Object.keys(detail as object).every((key) =>
|
|
100
|
+
['value', 'previousValue', 'trigger'].includes(key)
|
|
101
|
+
),
|
|
102
|
+
'edit-change': (detail) =>
|
|
103
|
+
detail !== null && typeof detail === 'object' && !Array.isArray(detail)
|
|
104
|
+
&& typeof (detail as Record<string, unknown>)['edit'] === 'boolean'
|
|
105
|
+
&& ((detail as Record<string, unknown>)['reason'] === 'activate'
|
|
106
|
+
|| (detail as Record<string, unknown>)['reason'] === 'commit'
|
|
107
|
+
|| (detail as Record<string, unknown>)['reason'] === 'cancel'
|
|
108
|
+
|| (detail as Record<string, unknown>)['reason'] === 'light-dismiss'
|
|
109
|
+
|| (detail as Record<string, unknown>)['reason'] === 'escape'
|
|
110
|
+
|| (detail as Record<string, unknown>)['reason'] === 'programmatic')
|
|
111
|
+
&& ((detail as Record<string, unknown>)['trigger'] === 'keyboard'
|
|
112
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'pointer'
|
|
113
|
+
|| (detail as Record<string, unknown>)['trigger'] === 'programmatic')
|
|
114
|
+
&& Object.keys(detail as object).every((key) => ['edit', 'reason', 'trigger'].includes(key)),
|
|
115
|
+
}
|
|
49
116
|
if (detail !== undefined && checks[name] !== undefined && !checks[name]!(detail)) {
|
|
50
|
-
throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`)
|
|
117
|
+
throw new TypeError(`HR002: Event \`${name}\` detail does not satisfy its declared type.`)
|
|
51
118
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
119
|
+
const emitEvent = emit as (name: string, detail: unknown) => void
|
|
120
|
+
emitEvent(name, detail)
|
|
121
|
+
if (detail !== null && typeof detail === 'object' && 'edit' in detail) {
|
|
122
|
+
emitEvent('update:edit', (detail as Record<string, unknown>)['edit'])
|
|
123
|
+
}
|
|
124
|
+
if (detail !== null && typeof detail === 'object' && 'value' in detail) {
|
|
125
|
+
emitEvent('update:value', (detail as Record<string, unknown>)['value'])
|
|
126
|
+
}
|
|
127
|
+
return root.value?.dispatchEvent(
|
|
128
|
+
new CustomEvent(name, { bubbles: true, composed: true, ...declared[name], detail }),
|
|
129
|
+
) ?? true
|
|
130
|
+
}
|
|
63
131
|
|
|
64
132
|
function read(name: string): unknown {
|
|
65
|
-
if (name ===
|
|
66
|
-
if (name ===
|
|
67
|
-
if (name ===
|
|
68
|
-
return (props as Record<string, unknown>)[name]
|
|
133
|
+
if (name === 'internalEdit') return internalEdit.value
|
|
134
|
+
if (name === 'internalValue') return internalValue.value
|
|
135
|
+
if (name === 'draft') return draft.value
|
|
136
|
+
return (props as Record<string, unknown>)[name]
|
|
69
137
|
}
|
|
70
138
|
|
|
71
139
|
function write(name: string, value: unknown): boolean {
|
|
72
|
-
if (name ===
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
140
|
+
if (name === 'internalEdit') {
|
|
141
|
+
internalEdit.value = value as never
|
|
142
|
+
return true
|
|
143
|
+
}
|
|
144
|
+
if (name === 'internalValue') {
|
|
145
|
+
internalValue.value = value as never
|
|
146
|
+
return true
|
|
147
|
+
}
|
|
148
|
+
if (name === 'draft') {
|
|
149
|
+
draft.value = value as never
|
|
150
|
+
return true
|
|
151
|
+
}
|
|
152
|
+
throw new TypeError(`Only declared state is writable; \`${name}\` is not.`)
|
|
76
153
|
}
|
|
77
154
|
|
|
78
|
-
const stops: Array<() => void> = []
|
|
155
|
+
const stops: Array<() => void> = []
|
|
79
156
|
const host = {
|
|
80
|
-
get element(): Element {
|
|
157
|
+
get element(): Element {
|
|
158
|
+
return root.value as Element
|
|
159
|
+
},
|
|
81
160
|
state: new Proxy({} as Record<string, unknown>, {
|
|
82
|
-
get: (_target, name) => typeof name ===
|
|
83
|
-
set: (_target, name, value) => typeof name ===
|
|
161
|
+
get: (_target, name) => typeof name === 'string' ? read(name) : undefined,
|
|
162
|
+
set: (_target, name, value) => typeof name === 'string' && write(name, value),
|
|
84
163
|
}),
|
|
85
|
-
refs:
|
|
164
|
+
refs: {
|
|
165
|
+
get preview(): Element {
|
|
166
|
+
return previewElement.value as Element
|
|
167
|
+
},
|
|
168
|
+
get input(): Element {
|
|
169
|
+
return inputElement.value as Element
|
|
170
|
+
},
|
|
171
|
+
} as Readonly<Record<string, Element>>,
|
|
86
172
|
elements: new Proxy({} as Record<string, Element | RadioNodeList | undefined>, {
|
|
87
173
|
get: (_target, name) => {
|
|
88
|
-
if (typeof name !==
|
|
89
|
-
const form = root.value instanceof HTMLFormElement
|
|
90
|
-
|
|
174
|
+
if (typeof name !== 'string' || root.value === null) return undefined
|
|
175
|
+
const form = root.value instanceof HTMLFormElement
|
|
176
|
+
? root.value
|
|
177
|
+
: root.value.querySelector('form')
|
|
178
|
+
return form?.elements.namedItem(name)
|
|
179
|
+
?? root.value.querySelector(`[name="${CSS.escape(name)}"]`) ?? undefined
|
|
91
180
|
},
|
|
92
181
|
}),
|
|
93
182
|
signal<T>(initialValue: T) {
|
|
94
|
-
const value = shallowRef(initialValue)
|
|
183
|
+
const value = shallowRef(initialValue)
|
|
95
184
|
return {
|
|
96
185
|
get: (): T => value.value,
|
|
97
|
-
set: (next: T): void => {
|
|
98
|
-
|
|
99
|
-
|
|
186
|
+
set: (next: T): void => {
|
|
187
|
+
if (!Object.is(value.value, next)) value.value = next
|
|
188
|
+
},
|
|
189
|
+
update: (next: (current: T) => T): void => {
|
|
190
|
+
const updated = next(value.value)
|
|
191
|
+
if (!Object.is(value.value, updated)) value.value = updated
|
|
192
|
+
},
|
|
193
|
+
}
|
|
100
194
|
},
|
|
101
195
|
computed<T>(compute: () => T) {
|
|
102
|
-
const value = computed(compute)
|
|
103
|
-
return { get: (): T => value.value }
|
|
196
|
+
const value = computed(compute)
|
|
197
|
+
return { get: (): T => value.value }
|
|
104
198
|
},
|
|
105
199
|
effect(run: () => void | (() => void)): () => void {
|
|
106
200
|
const stop = watchEffect((onCleanup) => {
|
|
107
|
-
const cleanup = run()
|
|
108
|
-
if (typeof cleanup ===
|
|
109
|
-
}, { flush:
|
|
110
|
-
stops.push(stop)
|
|
111
|
-
return stop
|
|
201
|
+
const cleanup = run()
|
|
202
|
+
if (typeof cleanup === 'function') onCleanup(cleanup)
|
|
203
|
+
}, { flush: 'post' })
|
|
204
|
+
stops.push(stop)
|
|
205
|
+
return stop
|
|
112
206
|
},
|
|
113
207
|
on(event: string, listener: EventListener): () => void {
|
|
114
|
-
const element = root.value
|
|
115
|
-
element?.addEventListener(event, listener)
|
|
116
|
-
const off = (): void => element?.removeEventListener(event, listener)
|
|
117
|
-
stops.push(off)
|
|
118
|
-
return off
|
|
208
|
+
const element = root.value
|
|
209
|
+
element?.addEventListener(event, listener)
|
|
210
|
+
const off = (): void => element?.removeEventListener(event, listener)
|
|
211
|
+
stops.push(off)
|
|
212
|
+
return off
|
|
119
213
|
},
|
|
120
214
|
dispatch,
|
|
121
|
-
}
|
|
215
|
+
}
|
|
122
216
|
|
|
123
|
-
let cleanup: void | (() => void)
|
|
124
|
-
let ready: Promise<void> | undefined
|
|
217
|
+
let cleanup: void | (() => void)
|
|
218
|
+
let ready: Promise<void> | undefined
|
|
125
219
|
onMounted(() => {
|
|
126
|
-
ready = Promise.resolve(controllerModule.default(host as never)).then((result) => {
|
|
127
|
-
|
|
220
|
+
ready = Promise.resolve(controllerModule.default(host as never)).then((result) => {
|
|
221
|
+
cleanup = result
|
|
222
|
+
})
|
|
223
|
+
})
|
|
128
224
|
onBeforeUnmount(() => {
|
|
129
|
-
for (const stop of stops.splice(0)) stop()
|
|
130
|
-
if (typeof cleanup ===
|
|
131
|
-
})
|
|
225
|
+
for (const stop of stops.splice(0)) stop()
|
|
226
|
+
if (typeof cleanup === 'function') cleanup()
|
|
227
|
+
})
|
|
132
228
|
</script>
|
|
133
229
|
|
|
134
230
|
<template>
|
|
135
|
-
<div
|
|
231
|
+
<div
|
|
232
|
+
data-component="ui-editable"
|
|
233
|
+
v-bind="$attrs"
|
|
234
|
+
:data-ui-editable-state="hostState || undefined"
|
|
235
|
+
ref="root"
|
|
236
|
+
>
|
|
237
|
+
<div class="field">
|
|
238
|
+
<button class="preview" type="button" :disabled="disabled" ref="preview">
|
|
239
|
+
<span class="text">{{ internalValue }}</span>
|
|
240
|
+
<span v-if="hint" class="hint" aria-hidden="true">{{ hint }}</span>
|
|
241
|
+
</button>
|
|
242
|
+
<input
|
|
243
|
+
class="input"
|
|
244
|
+
type="text"
|
|
245
|
+
:value.prop="draft"
|
|
246
|
+
:aria-label="label"
|
|
247
|
+
:disabled="disabled || !internalEdit"
|
|
248
|
+
ref="input"
|
|
249
|
+
>
|
|
250
|
+
</div>
|
|
251
|
+
<div v-if="actions" class="actions">
|
|
252
|
+
<button class="save" type="button">Save</button>
|
|
253
|
+
<button class="cancel" type="button">Cancel</button>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
136
256
|
</template>
|
|
137
257
|
|
|
138
258
|
<style scoped>
|
|
139
259
|
[data-component~="ui-editable"] {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-wrap: wrap;
|
|
262
|
+
align-items: center;
|
|
263
|
+
gap: var(--ui-space-2);
|
|
264
|
+
min-inline-size: 0;
|
|
265
|
+
color: var(--ui-text-primary);
|
|
266
|
+
}
|
|
147
267
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
268
|
+
/* The value and the input share one grid cell with identical box metrics, so switching between
|
|
269
|
+
* display and edit never changes the control's size or moves the text. */
|
|
270
|
+
.field {
|
|
271
|
+
display: inline-grid;
|
|
272
|
+
min-inline-size: 8rem;
|
|
273
|
+
max-inline-size: 100%;
|
|
274
|
+
}
|
|
155
275
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
276
|
+
.preview,
|
|
277
|
+
.input {
|
|
278
|
+
grid-area: 1 / 1;
|
|
279
|
+
box-sizing: border-box;
|
|
280
|
+
min-block-size: var(--ui-control-size-sm, 2rem);
|
|
281
|
+
margin: 0;
|
|
282
|
+
padding: var(--ui-space-1) var(--ui-space-2);
|
|
283
|
+
border: 1px solid transparent;
|
|
284
|
+
border-radius: var(--ui-radius-2);
|
|
285
|
+
font: inherit;
|
|
286
|
+
line-height: var(--ui-line-height-md);
|
|
287
|
+
color: inherit;
|
|
288
|
+
transition:
|
|
289
|
+
background-color var(--ui-motion-fast) var(--ui-motion-ease),
|
|
290
|
+
border-color var(--ui-motion-fast) var(--ui-motion-ease),
|
|
291
|
+
box-shadow var(--ui-motion-fast) var(--ui-motion-ease);
|
|
292
|
+
}
|
|
173
293
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
294
|
+
.preview {
|
|
295
|
+
display: inline-flex;
|
|
296
|
+
gap: var(--ui-space-2);
|
|
297
|
+
align-items: center;
|
|
298
|
+
background: transparent;
|
|
299
|
+
text-align: start;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
}
|
|
182
302
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
303
|
+
.preview:hover:not(:disabled) {
|
|
304
|
+
background: var(--ui-surface-muted);
|
|
305
|
+
}
|
|
186
306
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
307
|
+
.preview:focus-visible {
|
|
308
|
+
outline: none;
|
|
309
|
+
box-shadow: var(--ui-focus-halo);
|
|
310
|
+
}
|
|
191
311
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
312
|
+
.hint {
|
|
313
|
+
color: var(--ui-text-secondary);
|
|
314
|
+
font-size: var(--ui-font-size-sm);
|
|
315
|
+
}
|
|
196
316
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
317
|
+
/* Contained so it takes the value's width instead of its own default input width. */
|
|
318
|
+
.input {
|
|
319
|
+
contain: inline-size;
|
|
320
|
+
inline-size: 100%;
|
|
321
|
+
min-inline-size: 0;
|
|
322
|
+
visibility: hidden;
|
|
323
|
+
background: var(--ui-control-surface, var(--ui-surface-elevated));
|
|
324
|
+
}
|
|
205
325
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
326
|
+
.input:focus {
|
|
327
|
+
outline: none;
|
|
328
|
+
border-color: var(--ui-control-focus, var(--ui-accent-solid));
|
|
329
|
+
box-shadow:
|
|
330
|
+
var(--ui-control-inset),
|
|
331
|
+
var(--ui-control-focus-halo-shadow);
|
|
332
|
+
}
|
|
213
333
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
334
|
+
.input::selection {
|
|
335
|
+
background: color-mix(in srgb, var(--ui-accent-solid) 20%, transparent);
|
|
336
|
+
}
|
|
217
337
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
338
|
+
[data-component~="ui-editable"][data-ui-editable-state~="internalEdit"] .preview {
|
|
339
|
+
visibility: hidden;
|
|
340
|
+
}
|
|
341
|
+
[data-component~="ui-editable"][data-ui-editable-state~="internalEdit"] .input {
|
|
342
|
+
visibility: visible;
|
|
343
|
+
}
|
|
224
344
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
345
|
+
.actions {
|
|
346
|
+
display: none;
|
|
347
|
+
gap: var(--ui-space-1);
|
|
348
|
+
}
|
|
349
|
+
[data-component~="ui-editable"][data-ui-editable-state~="internalEdit"] .actions {
|
|
350
|
+
display: inline-flex;
|
|
351
|
+
}
|
|
232
352
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
353
|
+
.actions button {
|
|
354
|
+
min-block-size: var(--ui-control-size-sm, 2rem);
|
|
355
|
+
padding: 0 var(--ui-space-3);
|
|
356
|
+
border: 1px solid var(--ui-border-strong);
|
|
357
|
+
border-radius: var(--ui-radius-2);
|
|
358
|
+
background: var(--ui-surface-elevated);
|
|
359
|
+
background-image: var(--ui-raised-highlight, none);
|
|
360
|
+
box-shadow: var(--ui-raised, none);
|
|
361
|
+
color: inherit;
|
|
362
|
+
font: inherit;
|
|
363
|
+
font-size: var(--ui-font-size-sm);
|
|
364
|
+
cursor: pointer;
|
|
365
|
+
}
|
|
246
366
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
367
|
+
.actions .save {
|
|
368
|
+
border-color: var(--ui-accent-solid);
|
|
369
|
+
background: var(--ui-accent-solid);
|
|
370
|
+
color: var(--ui-text-on-accent);
|
|
371
|
+
}
|
|
252
372
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
373
|
+
.actions button:focus-visible {
|
|
374
|
+
outline: none;
|
|
375
|
+
box-shadow: var(--ui-focus-halo);
|
|
376
|
+
}
|
|
257
377
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
378
|
+
[data-component~="ui-editable"][data-ui-editable-state~="disabled"] .preview {
|
|
379
|
+
color: var(--ui-text-muted);
|
|
380
|
+
cursor: not-allowed;
|
|
381
|
+
}
|
|
262
382
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
383
|
+
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
384
|
+
[data-component~="ui-editable"][hidden] {
|
|
385
|
+
display: none;
|
|
386
|
+
}
|
|
267
387
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
-
headerRow?: boolean
|
|
3
|
-
maxCols?: number
|
|
4
|
-
maxRows?: number
|
|
5
|
-
open?: boolean
|
|
2
|
+
headerRow?: boolean;
|
|
3
|
+
maxCols?: number;
|
|
4
|
+
maxRows?: number;
|
|
5
|
+
open?: boolean;
|
|
6
6
|
};
|
|
7
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
8
|
insert: (detail: {
|
|
@@ -17,10 +17,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
17
17
|
readonly withHeaderRow: boolean;
|
|
18
18
|
}) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
|
-
open: boolean
|
|
21
|
-
headerRow: boolean
|
|
22
|
-
maxCols: number
|
|
23
|
-
maxRows: number
|
|
20
|
+
open: boolean;
|
|
21
|
+
headerRow: boolean;
|
|
22
|
+
maxCols: number;
|
|
23
|
+
maxRows: number;
|
|
24
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
25
|
declare const _default: typeof __VLS_export;
|
|
26
26
|
export default _default;
|