@zeyos/zx 2.1.0 → 2.2.1
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/CHANGELOG.md +51 -0
- package/README.md +15 -0
- package/dist/types/compat/base.d.ts +156 -0
- package/dist/types/compat/globals.d.ts +20 -0
- package/dist/types/compat/index.d.ts +128 -0
- package/dist/types/compat/map/basic.d.ts +175 -0
- package/dist/types/compat/map/data.d.ts +102 -0
- package/dist/types/compat/map/date-time.d.ts +80 -0
- package/dist/types/compat/map/factory.d.ts +9 -0
- package/dist/types/compat/map/form.d.ts +98 -0
- package/dist/types/compat/map/helpers.d.ts +12 -0
- package/dist/types/compat/map/http.d.ts +36 -0
- package/dist/types/compat/map/layout.d.ts +106 -0
- package/dist/types/compat/map/options.d.ts +80 -0
- package/dist/types/compat/map/select.d.ts +95 -0
- package/dist/types/compat/map/stubs.d.ts +32 -0
- package/dist/types/compat/map/utilities.d.ts +37 -0
- package/dist/types/compat-entry.d.ts +5 -0
- package/dist/types/components/badge/badge.d.ts +46 -0
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +200 -0
- package/dist/types/components/button/button.d.ts +42 -0
- package/dist/types/components/check-button/check-button.d.ts +98 -0
- package/dist/types/components/checklist/checklist.d.ts +143 -0
- package/dist/types/components/checklist/field-adapter.d.ts +5 -0
- package/dist/types/components/context-menu/context-menu.d.ts +130 -0
- package/dist/types/components/copy/copy-button.d.ts +48 -0
- package/dist/types/components/copy/copy-input.d.ts +91 -0
- package/dist/types/components/data-filter/data-filter.d.ts +250 -0
- package/dist/types/components/data-filter/filter-core.d.ts +52 -0
- package/dist/types/components/date-picker/date-picker.d.ts +137 -0
- package/dist/types/components/date-picker/date-range-picker.d.ts +350 -0
- package/dist/types/components/date-picker/field-adapter.d.ts +6 -0
- package/dist/types/components/date-picker/month-picker.d.ts +75 -0
- package/dist/types/components/date-picker/range-field-adapter.d.ts +7 -0
- package/dist/types/components/date-picker/time-picker.d.ts +127 -0
- package/dist/types/components/datebox/date-range-box.d.ts +218 -0
- package/dist/types/components/datebox/datebox.d.ts +160 -0
- package/dist/types/components/datebox/field-adapter.d.ts +5 -0
- package/dist/types/components/dialog/dialog.d.ts +284 -0
- package/dist/types/components/dropdown/dropdown.d.ts +118 -0
- package/dist/types/components/empty-state/empty-state.d.ts +38 -0
- package/dist/types/components/field/field.d.ts +231 -0
- package/dist/types/components/field-upload/field-adapter.d.ts +5 -0
- package/dist/types/components/field-upload/field-upload.d.ts +213 -0
- package/dist/types/components/fieldset/fieldset.d.ts +125 -0
- package/dist/types/components/finder/finder.d.ts +252 -0
- package/dist/types/components/form/form.d.ts +194 -0
- package/dist/types/components/groupbox/groupbox.d.ts +89 -0
- package/dist/types/components/layout/layout.d.ts +132 -0
- package/dist/types/components/loading/inline-loading.d.ts +86 -0
- package/dist/types/components/loading/progress-bar.d.ts +168 -0
- package/dist/types/components/loading/spinner.d.ts +34 -0
- package/dist/types/components/master-panel/master-panel.d.ts +112 -0
- package/dist/types/components/menu-button/menu-button.d.ts +142 -0
- package/dist/types/components/message/message.d.ts +212 -0
- package/dist/types/components/modal/modal.d.ts +105 -0
- package/dist/types/components/multi-value-editor/field-adapter.d.ts +5 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +66 -0
- package/dist/types/components/navigation-bar/navigation-bar.d.ts +229 -0
- package/dist/types/components/number-field/field-adapter.d.ts +5 -0
- package/dist/types/components/number-field/number-field.d.ts +292 -0
- package/dist/types/components/pagination/pagination.d.ts +267 -0
- package/dist/types/components/panel/panel.d.ts +194 -0
- package/dist/types/components/permission/permission.d.ts +93 -0
- package/dist/types/components/rating/field-adapter.d.ts +5 -0
- package/dist/types/components/rating/rating.d.ts +213 -0
- package/dist/types/components/search/search.d.ts +98 -0
- package/dist/types/components/select/field-adapter.d.ts +5 -0
- package/dist/types/components/select/filter.d.ts +11 -0
- package/dist/types/components/select/select.d.ts +235 -0
- package/dist/types/components/skeleton/skeleton.d.ts +97 -0
- package/dist/types/components/slider/field-adapter.d.ts +5 -0
- package/dist/types/components/slider/slider.d.ts +216 -0
- package/dist/types/components/split-view/split-view.d.ts +335 -0
- package/dist/types/components/stepper/stepper.d.ts +314 -0
- package/dist/types/components/stepper/steps.d.ts +131 -0
- package/dist/types/components/tabbox/tabbox.d.ts +230 -0
- package/dist/types/components/table/sort.d.ts +49 -0
- package/dist/types/components/table/table.d.ts +872 -0
- package/dist/types/components/tag-picker/field-adapter.d.ts +5 -0
- package/dist/types/components/tag-picker/tag-picker.d.ts +375 -0
- package/dist/types/components/timebox/field-adapter.d.ts +5 -0
- package/dist/types/components/timebox/timebox.d.ts +121 -0
- package/dist/types/components/toggle/field-adapter.d.ts +5 -0
- package/dist/types/components/toggle/toggle.d.ts +94 -0
- package/dist/types/components/toolbar/toolbar.d.ts +230 -0
- package/dist/types/components/tooltip/tooltip.d.ts +183 -0
- package/dist/types/components/tree/hierarchy.d.ts +113 -0
- package/dist/types/components/tree/tree.d.ts +383 -0
- package/dist/types/components/truncate/truncate.d.ts +61 -0
- package/dist/types/components/value-list/field-adapter.d.ts +5 -0
- package/dist/types/components/value-list/value-list.d.ts +143 -0
- package/dist/types/core/breakpoint.d.ts +68 -0
- package/dist/types/core/component.d.ts +115 -0
- package/dist/types/core/date.d.ts +50 -0
- package/dist/types/core/dom.d.ts +86 -0
- package/dist/types/core/export.d.ts +70 -0
- package/dist/types/core/fontawesome.d.ts +107 -0
- package/dist/types/core/format.d.ts +107 -0
- package/dist/types/core/http.d.ts +122 -0
- package/dist/types/core/i18n.d.ts +35 -0
- package/dist/types/core/icons.d.ts +137 -0
- package/dist/types/core/keyboard.d.ts +72 -0
- package/dist/types/core/position.d.ts +45 -0
- package/dist/types/core/storage.d.ts +46 -0
- package/dist/types/core/util.d.ts +117 -0
- package/dist/types/elements/define.d.ts +73 -0
- package/dist/types/elements/reflect.d.ts +27 -0
- package/dist/types/index.d.ts +79 -0
- package/dist/types/zeyos/connect.d.ts +65 -0
- package/dist/types/zeyos/form.d.ts +140 -0
- package/dist/types/zeyos/icons.d.ts +104 -0
- package/dist/types/zeyos/index.d.ts +12 -0
- package/dist/types/zeyos/modules.d.ts +110 -0
- package/dist/types/zeyos/query.d.ts +157 -0
- package/dist/types/zeyos/schema.d.ts +79 -0
- package/dist/types/zeyos/select.d.ts +167 -0
- package/dist/types/zeyos/table.d.ts +205 -0
- package/dist/zx-compat.esm.js +375 -39
- package/dist/zx-compat.esm.min.js +1 -1
- package/dist/zx-compat.global.js +372 -73
- package/dist/zx-compat.global.min.js +3 -3
- package/dist/zx-zeyos.esm.js +355 -49
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +68 -6
- package/dist/zx.esm.js +359 -73
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +359 -73
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +48 -2
- package/docs/llms.md +31 -0
- package/package.json +37 -9
- package/src/compat/base.js +291 -0
- package/src/compat/globals.js +165 -0
- package/src/compat/index.js +84 -0
- package/src/compat/map/basic.js +464 -0
- package/src/compat/map/data.js +232 -0
- package/src/compat/map/date-time.js +177 -0
- package/src/compat/map/factory.js +45 -0
- package/src/compat/map/form.js +330 -0
- package/src/compat/map/helpers.js +46 -0
- package/src/compat/map/http.js +117 -0
- package/src/compat/map/layout.js +256 -0
- package/src/compat/map/options.js +267 -0
- package/src/compat/map/select.js +198 -0
- package/src/compat/map/stubs.js +26 -0
- package/src/compat/map/utilities.js +113 -0
- package/src/compat-entry.js +11 -0
- package/src/components/badge/badge.css +147 -0
- package/src/components/badge/badge.js +92 -0
- package/src/components/breadcrumb/breadcrumb.css +105 -0
- package/src/components/breadcrumb/breadcrumb.js +331 -0
- package/src/components/button/button.css +104 -0
- package/src/components/button/button.js +76 -0
- package/src/components/check-button/check-button.css +66 -0
- package/src/components/check-button/check-button.js +167 -0
- package/src/components/checklist/checklist.css +65 -0
- package/src/components/checklist/checklist.js +282 -0
- package/src/components/checklist/field-adapter.js +46 -0
- package/src/components/context-menu/context-menu.css +54 -0
- package/src/components/context-menu/context-menu.js +334 -0
- package/src/components/copy/copy-button.css +27 -0
- package/src/components/copy/copy-button.js +78 -0
- package/src/components/copy/copy-input.css +59 -0
- package/src/components/copy/copy-input.js +123 -0
- package/src/components/data-filter/data-filter.css +53 -0
- package/src/components/data-filter/data-filter.js +400 -0
- package/src/components/data-filter/filter-core.js +128 -0
- package/src/components/date-picker/date-picker.css +181 -0
- package/src/components/date-picker/date-picker.js +500 -0
- package/src/components/date-picker/date-range-picker.css +264 -0
- package/src/components/date-picker/date-range-picker.js +990 -0
- package/src/components/date-picker/field-adapter.js +36 -0
- package/src/components/date-picker/month-picker.js +223 -0
- package/src/components/date-picker/range-field-adapter.js +31 -0
- package/src/components/date-picker/time-picker.css +191 -0
- package/src/components/date-picker/time-picker.js +406 -0
- package/src/components/datebox/date-range-box.css +128 -0
- package/src/components/datebox/date-range-box.js +492 -0
- package/src/components/datebox/datebox.css +108 -0
- package/src/components/datebox/datebox.js +358 -0
- package/src/components/datebox/field-adapter.js +34 -0
- package/src/components/dialog/dialog.css +74 -0
- package/src/components/dialog/dialog.js +450 -0
- package/src/components/dropdown/dropdown.css +24 -0
- package/src/components/dropdown/dropdown.js +288 -0
- package/src/components/empty-state/empty-state.css +80 -0
- package/src/components/empty-state/empty-state.js +92 -0
- package/src/components/field/field.css +127 -0
- package/src/components/field/field.js +605 -0
- package/src/components/field-upload/field-adapter.js +21 -0
- package/src/components/field-upload/field-upload.css +108 -0
- package/src/components/field-upload/field-upload.js +475 -0
- package/src/components/fieldset/fieldset.css +37 -0
- package/src/components/fieldset/fieldset.js +307 -0
- package/src/components/finder/finder.css +98 -0
- package/src/components/finder/finder.js +509 -0
- package/src/components/form/form.css +32 -0
- package/src/components/form/form.js +302 -0
- package/src/components/groupbox/groupbox.css +51 -0
- package/src/components/groupbox/groupbox.js +199 -0
- package/src/components/layout/layout.css +117 -0
- package/src/components/layout/layout.js +136 -0
- package/src/components/loading/inline-loading.css +34 -0
- package/src/components/loading/inline-loading.js +140 -0
- package/src/components/loading/progress-bar.css +115 -0
- package/src/components/loading/progress-bar.js +259 -0
- package/src/components/loading/spinner.css +58 -0
- package/src/components/loading/spinner.js +57 -0
- package/src/components/master-panel/master-panel.css +51 -0
- package/src/components/master-panel/master-panel.js +203 -0
- package/src/components/menu-button/menu-button.css +49 -0
- package/src/components/menu-button/menu-button.js +294 -0
- package/src/components/message/message.css +122 -0
- package/src/components/message/message.js +499 -0
- package/src/components/modal/modal.css +47 -0
- package/src/components/modal/modal.js +203 -0
- package/src/components/multi-value-editor/field-adapter.js +44 -0
- package/src/components/multi-value-editor/multi-value-editor.css +56 -0
- package/src/components/multi-value-editor/multi-value-editor.js +170 -0
- package/src/components/navigation-bar/navigation-bar.css +130 -0
- package/src/components/navigation-bar/navigation-bar.js +450 -0
- package/src/components/number-field/field-adapter.js +40 -0
- package/src/components/number-field/number-field.css +77 -0
- package/src/components/number-field/number-field.js +545 -0
- package/src/components/pagination/pagination.css +95 -0
- package/src/components/pagination/pagination.js +481 -0
- package/src/components/panel/panel.css +123 -0
- package/src/components/panel/panel.js +336 -0
- package/src/components/permission/permission.css +47 -0
- package/src/components/permission/permission.js +198 -0
- package/src/components/rating/field-adapter.js +34 -0
- package/src/components/rating/rating.css +97 -0
- package/src/components/rating/rating.js +395 -0
- package/src/components/search/search.css +70 -0
- package/src/components/search/search.js +193 -0
- package/src/components/select/field-adapter.js +24 -0
- package/src/components/select/filter.js +39 -0
- package/src/components/select/select.css +180 -0
- package/src/components/select/select.js +663 -0
- package/src/components/skeleton/skeleton.css +76 -0
- package/src/components/skeleton/skeleton.js +139 -0
- package/src/components/slider/field-adapter.js +36 -0
- package/src/components/slider/slider.css +181 -0
- package/src/components/slider/slider.js +399 -0
- package/src/components/split-view/split-view.css +139 -0
- package/src/components/split-view/split-view.js +806 -0
- package/src/components/stepper/stepper.css +234 -0
- package/src/components/stepper/stepper.js +459 -0
- package/src/components/stepper/steps.js +131 -0
- package/src/components/tabbox/tabbox.css +281 -0
- package/src/components/tabbox/tabbox.js +484 -0
- package/src/components/table/sort.js +85 -0
- package/src/components/table/table.css +364 -0
- package/src/components/table/table.js +1711 -0
- package/src/components/tag-picker/field-adapter.js +35 -0
- package/src/components/tag-picker/tag-picker.css +169 -0
- package/src/components/tag-picker/tag-picker.js +837 -0
- package/src/components/timebox/field-adapter.js +24 -0
- package/src/components/timebox/timebox.css +51 -0
- package/src/components/timebox/timebox.js +276 -0
- package/src/components/toggle/field-adapter.js +24 -0
- package/src/components/toggle/toggle.css +66 -0
- package/src/components/toggle/toggle.js +150 -0
- package/src/components/toolbar/toolbar.css +81 -0
- package/src/components/toolbar/toolbar.js +511 -0
- package/src/components/tooltip/tooltip.css +36 -0
- package/src/components/tooltip/tooltip.js +420 -0
- package/src/components/tree/hierarchy.js +151 -0
- package/src/components/tree/tree.css +99 -0
- package/src/components/tree/tree.js +784 -0
- package/src/components/truncate/truncate.css +20 -0
- package/src/components/truncate/truncate.js +92 -0
- package/src/components/value-list/field-adapter.js +24 -0
- package/src/components/value-list/value-list.css +108 -0
- package/src/components/value-list/value-list.js +336 -0
- package/src/core/breakpoint.js +150 -0
- package/src/core/component.js +292 -0
- package/src/core/date.js +216 -0
- package/src/core/dom.js +260 -0
- package/src/core/export.js +204 -0
- package/src/core/fontawesome.js +177 -0
- package/src/core/format.js +283 -0
- package/src/core/http.js +246 -0
- package/src/core/i18n.js +83 -0
- package/src/core/icons.js +283 -0
- package/src/core/keyboard.js +240 -0
- package/src/core/position.js +177 -0
- package/src/core/storage.js +175 -0
- package/src/core/util.js +336 -0
- package/src/elements/define.js +715 -0
- package/src/elements/reflect.js +79 -0
- package/src/index.js +131 -0
- package/src/zeyos/connect.js +142 -0
- package/src/zeyos/form.js +254 -0
- package/src/zeyos/icons.js +92 -0
- package/src/zeyos/index.js +21 -0
- package/src/zeyos/modules.js +269 -0
- package/src/zeyos/query.js +199 -0
- package/src/zeyos/schema.js +474 -0
- package/src/zeyos/select.js +175 -0
- package/src/zeyos/table.js +272 -0
- package/styles/base.css +124 -0
- package/styles/icons.css +34 -0
- package/styles/tokens/dark.css +84 -0
- package/styles/tokens/density.css +9 -0
- package/styles/tokens/global.css +80 -0
- package/styles/tokens/modules.css +109 -0
- package/styles/tokens/semantic.css +49 -0
- package/styles/zx.css +61 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
import { h } from '../../core/dom.js';
|
|
3
|
+
import { icon } from '../../core/icons.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} SearchOptions
|
|
7
|
+
* @property {string} [placeholder=''] Input placeholder.
|
|
8
|
+
* @property {string} [value=''] Initial query.
|
|
9
|
+
* @property {boolean} [clearable=true] Whether to show a clear control.
|
|
10
|
+
* @property {number} [debounce=250] Input debounce in milliseconds.
|
|
11
|
+
* @property {(event: CustomEvent<{value: string}>) => void} [oninput] Input callback.
|
|
12
|
+
* @property {(event: CustomEvent<{value: string}>) => void} [onsubmit] Submit callback.
|
|
13
|
+
* @property {(event: CustomEvent<Record<string, never>>) => void} [onclear] Clear callback.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Search field with embedded submit and optional clear controls.
|
|
18
|
+
* @fires Search#input
|
|
19
|
+
* @fires Search#submit
|
|
20
|
+
* @fires Search#clear
|
|
21
|
+
* @extends {Component<SearchOptions>}
|
|
22
|
+
*/
|
|
23
|
+
export class Search extends Component {
|
|
24
|
+
static cssName = 'search';
|
|
25
|
+
|
|
26
|
+
/** @type {Readonly<SearchOptions>} */
|
|
27
|
+
static defaults = {
|
|
28
|
+
placeholder: '',
|
|
29
|
+
value: '',
|
|
30
|
+
clearable: true,
|
|
31
|
+
debounce: 250
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @returns {HTMLElement} */
|
|
35
|
+
render() {
|
|
36
|
+
const created = !this.el;
|
|
37
|
+
const root = /** @type {HTMLElement} */ (this.el ?? h('form'));
|
|
38
|
+
this._createdRoot = created;
|
|
39
|
+
this._original = created ? null : snapshot(root);
|
|
40
|
+
this._inputTimer = null;
|
|
41
|
+
root.setAttribute('role', 'search');
|
|
42
|
+
const input = h('input', {
|
|
43
|
+
class: 'zx-search__input',
|
|
44
|
+
ref: 'input',
|
|
45
|
+
type: 'search',
|
|
46
|
+
placeholder: String(this.options.placeholder),
|
|
47
|
+
value: String(this.options.value),
|
|
48
|
+
ariaLabel: String(this.options.placeholder || 'Search')
|
|
49
|
+
});
|
|
50
|
+
const clear = this.options.clearable ? h('button', {
|
|
51
|
+
class: 'zx-search__clear',
|
|
52
|
+
ref: 'clear',
|
|
53
|
+
type: 'button',
|
|
54
|
+
ariaLabel: 'Clear search',
|
|
55
|
+
title: 'Clear search'
|
|
56
|
+
}, icon('x', { size: 15 })) : null;
|
|
57
|
+
const submit = h('button', {
|
|
58
|
+
class: 'zx-search__submit',
|
|
59
|
+
ref: 'submit',
|
|
60
|
+
type: root.localName === 'form' ? 'submit' : 'button',
|
|
61
|
+
ariaLabel: 'Submit search',
|
|
62
|
+
title: 'Search'
|
|
63
|
+
}, icon('search', { size: 16 }));
|
|
64
|
+
root.replaceChildren(...[input, clear, submit].filter(Boolean));
|
|
65
|
+
this._syncClear();
|
|
66
|
+
|
|
67
|
+
this.listen(input, 'input', () => {
|
|
68
|
+
this._syncClear();
|
|
69
|
+
this._scheduleInput();
|
|
70
|
+
});
|
|
71
|
+
if (root.localName === 'form') {
|
|
72
|
+
this.listen(root, 'submit', (event) => {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
this.emit('submit', { value: this.get() });
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
this.listen(input, 'keydown', (event) => {
|
|
78
|
+
if (event.key !== 'Enter') return;
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
this.emit('submit', { value: this.get() });
|
|
81
|
+
});
|
|
82
|
+
this.listen(submit, 'click', () => this.emit('submit', { value: this.get() }));
|
|
83
|
+
}
|
|
84
|
+
if (clear) this.listen(clear, 'click', () => this.clear());
|
|
85
|
+
return root;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the current query.
|
|
90
|
+
* @returns {string}
|
|
91
|
+
*/
|
|
92
|
+
get() {
|
|
93
|
+
return /** @type {HTMLInputElement} */ (this.refs.input).value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sets the current query.
|
|
98
|
+
* @param {string} value Next query.
|
|
99
|
+
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `input`.
|
|
100
|
+
* @returns {this}
|
|
101
|
+
*/
|
|
102
|
+
set(value, { silent = false } = {}) {
|
|
103
|
+
if (this._inputTimer !== null) {
|
|
104
|
+
clearTimeout(this._inputTimer);
|
|
105
|
+
this._inputTimer = null;
|
|
106
|
+
}
|
|
107
|
+
/** @type {HTMLInputElement} */ (this.refs.input).value = String(value);
|
|
108
|
+
this._syncClear();
|
|
109
|
+
if (!silent) this._scheduleInput();
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Focuses the input.
|
|
115
|
+
* @returns {this}
|
|
116
|
+
*/
|
|
117
|
+
focus() {
|
|
118
|
+
/** @type {HTMLInputElement} */ (this.refs.input).focus();
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Clears the query and reports both the value update and clear action.
|
|
124
|
+
* @returns {this}
|
|
125
|
+
* @fires Search#input
|
|
126
|
+
* @fires Search#clear
|
|
127
|
+
*/
|
|
128
|
+
clear() {
|
|
129
|
+
this.set('');
|
|
130
|
+
this.emit('clear');
|
|
131
|
+
this.focus();
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** @returns {void} */
|
|
136
|
+
destroy() {
|
|
137
|
+
if (this._cleaned) return;
|
|
138
|
+
this._cleaned = true;
|
|
139
|
+
if (this._inputTimer !== null) clearTimeout(this._inputTimer);
|
|
140
|
+
super.destroy();
|
|
141
|
+
if (!this._createdRoot && this._original) restore(this.el, this._original);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** @returns {void} */
|
|
145
|
+
_scheduleInput() {
|
|
146
|
+
if (this._inputTimer !== null) clearTimeout(this._inputTimer);
|
|
147
|
+
const delay = Math.max(0, Number(this.options.debounce) || 0);
|
|
148
|
+
this._inputTimer = setTimeout(() => {
|
|
149
|
+
this._inputTimer = null;
|
|
150
|
+
this.emit('input', { value: this.get() });
|
|
151
|
+
}, delay);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** @returns {void} */
|
|
155
|
+
_syncClear() {
|
|
156
|
+
if (this.refs.clear) {
|
|
157
|
+
/** @type {HTMLButtonElement} */ (this.refs.clear).hidden = this.get() === '';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Debounced query update.
|
|
164
|
+
* @event Search#input
|
|
165
|
+
* @type {CustomEvent<{value: string}>}
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Search submission.
|
|
170
|
+
* @event Search#submit
|
|
171
|
+
* @type {CustomEvent<{value: string}>}
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Explicit clear action.
|
|
176
|
+
* @event Search#clear
|
|
177
|
+
* @type {CustomEvent<Record<string, never>>}
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/** @param {Element} element @returns {{attributes: [string, string][], children: Node[]}} */
|
|
181
|
+
function snapshot(element) {
|
|
182
|
+
return {
|
|
183
|
+
attributes: Array.from(element.attributes, (attribute) => [attribute.name, attribute.value]),
|
|
184
|
+
children: Array.from(element.childNodes)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** @param {Element} element @param {{attributes: [string, string][], children: Node[]}} state */
|
|
189
|
+
function restore(element, state) {
|
|
190
|
+
for (const attribute of Array.from(element.attributes)) element.removeAttribute(attribute.name);
|
|
191
|
+
for (const [name, value] of state.attributes) element.setAttribute(name, value);
|
|
192
|
+
element.replaceChildren(...state.children);
|
|
193
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Field } from '../field/field.js';
|
|
2
|
+
import { Select } from './select.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Registers the Select-backed `zxselect` field type.
|
|
6
|
+
* @returns {void}
|
|
7
|
+
*/
|
|
8
|
+
export function registerSelectFieldAdapter() {
|
|
9
|
+
Field.register('zxselect', (field, options) => {
|
|
10
|
+
const select = field.own(new Select(null, {
|
|
11
|
+
...(options.props ?? {}),
|
|
12
|
+
value: options.value
|
|
13
|
+
}));
|
|
14
|
+
field.listen(select.el, 'change', (event) => event.stopImmediatePropagation());
|
|
15
|
+
select.on('change', (event) => field.emit('change', { value: event.detail.value }));
|
|
16
|
+
return {
|
|
17
|
+
el: select.el,
|
|
18
|
+
get: () => select.value,
|
|
19
|
+
set: (value) => select.set(value, { silent: true }),
|
|
20
|
+
focus: () => select.focus(),
|
|
21
|
+
setDisabled: (disabled) => disabled ? select.disable() : select.enable()
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns items whose searchable values contain every query word.
|
|
3
|
+
* Matching is case- and diacritic-insensitive.
|
|
4
|
+
*
|
|
5
|
+
* @template T
|
|
6
|
+
* @param {T[]} items Items to search.
|
|
7
|
+
* @param {string} query User-entered search text.
|
|
8
|
+
* @param {Array<string|((item: T) => unknown)>} keys Searchable object keys or value readers.
|
|
9
|
+
* @returns {T[]} Matching items in their original order.
|
|
10
|
+
*/
|
|
11
|
+
export function matchItems(items, query, keys) {
|
|
12
|
+
const words = normalize(query).split(/\s+/).filter(Boolean);
|
|
13
|
+
if (words.length === 0) return items.slice();
|
|
14
|
+
|
|
15
|
+
return items.filter((item) => {
|
|
16
|
+
const values = searchableValues(item, keys).map(normalize);
|
|
17
|
+
return words.every((word) => values.some((value) => value.includes(word)));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @template T
|
|
23
|
+
* @param {T} item
|
|
24
|
+
* @param {Array<string|((item: T) => unknown)>} keys
|
|
25
|
+
* @returns {unknown[]}
|
|
26
|
+
*/
|
|
27
|
+
function searchableValues(item, keys) {
|
|
28
|
+
if (item === null || typeof item !== 'object') return [item];
|
|
29
|
+
if (!Array.isArray(keys) || keys.length === 0) return [item];
|
|
30
|
+
return keys.map((key) => typeof key === 'function' ? key(item) : item[key]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @param {unknown} value @returns {string} */
|
|
34
|
+
function normalize(value) {
|
|
35
|
+
return String(value ?? '')
|
|
36
|
+
.normalize('NFD')
|
|
37
|
+
.replace(/\p{M}+/gu, '')
|
|
38
|
+
.toLocaleLowerCase();
|
|
39
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
.zx-select {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
inline-size: 100%;
|
|
4
|
+
min-inline-size: 0;
|
|
5
|
+
color: var(--zx-color-text);
|
|
6
|
+
font-size: var(--zx-control-font-size);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.zx-select__control {
|
|
10
|
+
display: grid;
|
|
11
|
+
grid-template-columns: minmax(0, 1fr) auto auto auto;
|
|
12
|
+
align-items: center;
|
|
13
|
+
min-block-size: var(--zx-control-height);
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
border: 1px solid var(--zx-color-border-control);
|
|
16
|
+
border-radius: var(--zx-control-radius);
|
|
17
|
+
background: var(--zx-color-bg-control);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.zx-select__control:has(.zx-select__input:focus-visible) {
|
|
21
|
+
box-shadow: var(--zx-focus-ring);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.zx-select__input {
|
|
25
|
+
inline-size: 100%;
|
|
26
|
+
min-inline-size: 0;
|
|
27
|
+
min-block-size: calc(var(--zx-control-height) - 2px) !important;
|
|
28
|
+
border: 0 !important;
|
|
29
|
+
border-radius: 0 !important;
|
|
30
|
+
background: none !important;
|
|
31
|
+
box-shadow: none !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.zx-select__input:read-only {
|
|
35
|
+
cursor: default;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.zx-select__clear,
|
|
39
|
+
.zx-select__toggle {
|
|
40
|
+
display: grid;
|
|
41
|
+
place-items: center;
|
|
42
|
+
inline-size: var(--zx-control-height);
|
|
43
|
+
min-block-size: calc(var(--zx-control-height) - 2px) !important;
|
|
44
|
+
border: 0 !important;
|
|
45
|
+
border-radius: 0 !important;
|
|
46
|
+
background: none !important;
|
|
47
|
+
color: var(--zx-color-text-muted);
|
|
48
|
+
padding: 0 !important;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.zx-select__clear:hover,
|
|
52
|
+
.zx-select__toggle:hover {
|
|
53
|
+
color: var(--zx-color-text);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.zx-select__clear[hidden],
|
|
57
|
+
.zx-select__loading[hidden] {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.zx-select__loading {
|
|
62
|
+
inline-size: 14px;
|
|
63
|
+
block-size: 14px;
|
|
64
|
+
border: 2px solid var(--zx-color-border);
|
|
65
|
+
border-block-start-color: var(--zx-color-accent);
|
|
66
|
+
border-radius: var(--zx-radius-full);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.zx-select[aria-disabled="true"] .zx-select__control {
|
|
70
|
+
background: var(--zx-color-bg-page);
|
|
71
|
+
color: var(--zx-color-text-muted);
|
|
72
|
+
cursor: default;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.zx-select__panel {
|
|
76
|
+
z-index: 20;
|
|
77
|
+
inline-size: max-content;
|
|
78
|
+
max-inline-size: calc(100vw - var(--zx-space-4));
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
border: 1px solid var(--zx-color-border-strong);
|
|
81
|
+
border-radius: var(--zx-radius-md);
|
|
82
|
+
background: var(--zx-color-bg-raised);
|
|
83
|
+
box-shadow: var(--zx-overlay-shadow);
|
|
84
|
+
color: var(--zx-color-text);
|
|
85
|
+
padding: var(--zx-space-1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.zx-select__list {
|
|
89
|
+
min-inline-size: 0;
|
|
90
|
+
overflow-y: auto;
|
|
91
|
+
overscroll-behavior: contain;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.zx-select__option {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: var(--zx-space-2);
|
|
98
|
+
min-block-size: var(--zx-control-height);
|
|
99
|
+
border-radius: var(--zx-radius-sm);
|
|
100
|
+
cursor: default;
|
|
101
|
+
padding: var(--zx-space-1) var(--zx-control-pad-x);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.zx-select__option-content {
|
|
105
|
+
min-inline-size: 0;
|
|
106
|
+
flex: 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.zx-select__option[data-active="true"] {
|
|
110
|
+
background: var(--zx-color-bg-hover);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.zx-select__option:hover {
|
|
114
|
+
background: var(--zx-color-bg-hover);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.zx-select__option[aria-selected="true"] {
|
|
118
|
+
background: var(--zx-color-bg-selected);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.zx-select__option > svg,
|
|
122
|
+
.zx-select__option > .zx-icon {
|
|
123
|
+
flex: none;
|
|
124
|
+
color: var(--zx-color-accent);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.zx-select__group {
|
|
128
|
+
position: sticky;
|
|
129
|
+
z-index: 1;
|
|
130
|
+
inset-block-start: 0;
|
|
131
|
+
background: var(--zx-color-bg-raised);
|
|
132
|
+
color: var(--zx-color-text-muted);
|
|
133
|
+
font-size: var(--zx-text-xs);
|
|
134
|
+
font-weight: 700;
|
|
135
|
+
letter-spacing: 0.04em;
|
|
136
|
+
padding: var(--zx-space-2) var(--zx-control-pad-x) var(--zx-space-1);
|
|
137
|
+
text-transform: uppercase;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.zx-select__empty {
|
|
141
|
+
color: var(--zx-color-text-muted);
|
|
142
|
+
padding: var(--zx-space-3) var(--zx-control-pad-x);
|
|
143
|
+
text-align: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.zx-select__priority {
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
gap: var(--zx-space-2);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.zx-select__priority-icon {
|
|
153
|
+
inline-size: 10px;
|
|
154
|
+
block-size: 10px;
|
|
155
|
+
flex: none;
|
|
156
|
+
border-radius: var(--zx-radius-sm);
|
|
157
|
+
background: var(--zx-color-warning);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.zx-select__priority-icon[data-level="0"],
|
|
161
|
+
.zx-select__priority-icon[data-level="1"] {
|
|
162
|
+
background: var(--zx-color-success);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.zx-select__priority-icon[data-level="3"],
|
|
166
|
+
.zx-select__priority-icon[data-level="4"] {
|
|
167
|
+
background: var(--zx-color-danger);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
171
|
+
.zx-select__loading {
|
|
172
|
+
animation: zx-select-spin var(--zx-dur-slow) linear infinite;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@keyframes zx-select-spin {
|
|
177
|
+
to {
|
|
178
|
+
transform: rotate(1turn);
|
|
179
|
+
}
|
|
180
|
+
}
|