@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,383 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
export type TreeNode = import('./hierarchy.js').TreeNode;
|
|
3
|
+
export type TreeOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Nested nodes.
|
|
6
|
+
*/
|
|
7
|
+
items?: TreeNode[];
|
|
8
|
+
/**
|
|
9
|
+
* Node ID property or reader.
|
|
10
|
+
*/
|
|
11
|
+
valueKey?: string | ((node: TreeNode) => unknown);
|
|
12
|
+
/**
|
|
13
|
+
* Node label property or reader.
|
|
14
|
+
*/
|
|
15
|
+
labelKey?: string | ((node: TreeNode) => string);
|
|
16
|
+
/**
|
|
17
|
+
* Property holding child nodes.
|
|
18
|
+
*/
|
|
19
|
+
childrenKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Initially expanded node IDs.
|
|
22
|
+
*/
|
|
23
|
+
expanded?: unknown[];
|
|
24
|
+
/**
|
|
25
|
+
* Selection mode.
|
|
26
|
+
*/
|
|
27
|
+
selection?: false | 'single' | 'multi';
|
|
28
|
+
/**
|
|
29
|
+
* Initially selected node IDs.
|
|
30
|
+
*/
|
|
31
|
+
selected?: unknown[];
|
|
32
|
+
/**
|
|
33
|
+
* Whether to render tri-state checkboxes.
|
|
34
|
+
*/
|
|
35
|
+
checkboxes?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Initially checked node IDs.
|
|
38
|
+
*/
|
|
39
|
+
checked?: unknown[];
|
|
40
|
+
/**
|
|
41
|
+
* Whether to render folder and file icons.
|
|
42
|
+
*/
|
|
43
|
+
icons?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Label renderer.
|
|
46
|
+
*/
|
|
47
|
+
renderLabel?: ((node: TreeNode) => Node | string) | null;
|
|
48
|
+
/**
|
|
49
|
+
* Lazy child loader.
|
|
50
|
+
*/
|
|
51
|
+
load?: ((node: TreeNode) => Promise<TreeNode[]> | TreeNode[]) | null;
|
|
52
|
+
/**
|
|
53
|
+
* Label substring the tree is filtered by.
|
|
54
|
+
*/
|
|
55
|
+
filter?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible name of the tree.
|
|
58
|
+
*/
|
|
59
|
+
label?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Text shown when the tree is empty.
|
|
62
|
+
*/
|
|
63
|
+
emptyText?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Scroll height in pixels or any CSS length.
|
|
66
|
+
*/
|
|
67
|
+
height?: number | string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Localized messages.
|
|
70
|
+
*/
|
|
71
|
+
msg?: Record<string, string> | Record<string, Record<string, string>>;
|
|
72
|
+
/**
|
|
73
|
+
* Selection listener.
|
|
74
|
+
*/
|
|
75
|
+
onselect?: (event: CustomEvent<{
|
|
76
|
+
node: TreeNode;
|
|
77
|
+
id: unknown;
|
|
78
|
+
ids: unknown[];
|
|
79
|
+
}>) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Expand listener.
|
|
82
|
+
*/
|
|
83
|
+
onexpand?: (event: CustomEvent<{
|
|
84
|
+
node: TreeNode;
|
|
85
|
+
id: unknown;
|
|
86
|
+
}>) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Collapse listener.
|
|
89
|
+
*/
|
|
90
|
+
oncollapse?: (event: CustomEvent<{
|
|
91
|
+
node: TreeNode;
|
|
92
|
+
id: unknown;
|
|
93
|
+
}>) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Activation listener.
|
|
96
|
+
*/
|
|
97
|
+
onactivate?: (event: CustomEvent<{
|
|
98
|
+
node: TreeNode;
|
|
99
|
+
id: unknown;
|
|
100
|
+
}>) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Check listener.
|
|
103
|
+
*/
|
|
104
|
+
oncheck?: (event: CustomEvent<{
|
|
105
|
+
ids: unknown[];
|
|
106
|
+
node: TreeNode | null;
|
|
107
|
+
}>) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Loader-failure listener.
|
|
110
|
+
*/
|
|
111
|
+
onerror?: (event: CustomEvent<{
|
|
112
|
+
error: Error;
|
|
113
|
+
node: TreeNode;
|
|
114
|
+
id: unknown;
|
|
115
|
+
}>) => void;
|
|
116
|
+
};
|
|
117
|
+
/** @typedef {import('./hierarchy.js').TreeNode} TreeNode */
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {Object} TreeOptions
|
|
120
|
+
* @property {TreeNode[]} [items=[]] Nested nodes.
|
|
121
|
+
* @property {string|((node: TreeNode) => unknown)} [valueKey='ID'] Node ID property or reader.
|
|
122
|
+
* @property {string|((node: TreeNode) => string)} [labelKey='name'] Node label property or reader.
|
|
123
|
+
* @property {string} [childrenKey='children'] Property holding child nodes.
|
|
124
|
+
* @property {unknown[]} [expanded=[]] Initially expanded node IDs.
|
|
125
|
+
* @property {false|'single'|'multi'} [selection='single'] Selection mode.
|
|
126
|
+
* @property {unknown[]} [selected=[]] Initially selected node IDs.
|
|
127
|
+
* @property {boolean} [checkboxes=false] Whether to render tri-state checkboxes.
|
|
128
|
+
* @property {unknown[]} [checked=[]] Initially checked node IDs.
|
|
129
|
+
* @property {boolean} [icons=true] Whether to render folder and file icons.
|
|
130
|
+
* @property {((node: TreeNode) => Node|string)|null} [renderLabel=null] Label renderer.
|
|
131
|
+
* @property {((node: TreeNode) => Promise<TreeNode[]>|TreeNode[])|null} [load=null] Lazy child loader.
|
|
132
|
+
* @property {string} [filter=''] Label substring the tree is filtered by.
|
|
133
|
+
* @property {string} [label='Tree'] Accessible name of the tree.
|
|
134
|
+
* @property {string} [emptyText='Nothing to show'] Text shown when the tree is empty.
|
|
135
|
+
* @property {number|string|null} [height=null] Scroll height in pixels or any CSS length.
|
|
136
|
+
* @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
|
|
137
|
+
* @property {(event: CustomEvent<{node: TreeNode, id: unknown, ids: unknown[]}>) => void} [onselect] Selection listener.
|
|
138
|
+
* @property {(event: CustomEvent<{node: TreeNode, id: unknown}>) => void} [onexpand] Expand listener.
|
|
139
|
+
* @property {(event: CustomEvent<{node: TreeNode, id: unknown}>) => void} [oncollapse] Collapse listener.
|
|
140
|
+
* @property {(event: CustomEvent<{node: TreeNode, id: unknown}>) => void} [onactivate] Activation listener.
|
|
141
|
+
* @property {(event: CustomEvent<{ids: unknown[], node: TreeNode|null}>) => void} [oncheck] Check listener.
|
|
142
|
+
* @property {(event: CustomEvent<{error: Error, node: TreeNode, id: unknown}>) => void} [onerror] Loader-failure listener.
|
|
143
|
+
*/
|
|
144
|
+
/**
|
|
145
|
+
* Hierarchical tree implementing the APG tree pattern.
|
|
146
|
+
*
|
|
147
|
+
* Rows are rendered as a flat list carrying `aria-level` / `aria-setsize` / `aria-posinset`
|
|
148
|
+
* rather than nested `role="group"` containers — the flattened variant the APG allows. It keeps
|
|
149
|
+
* roving tabindex, arrow-key movement, and virtualization-friendly re-rendering simple.
|
|
150
|
+
*
|
|
151
|
+
* @fires TreeView#select
|
|
152
|
+
* @fires TreeView#expand
|
|
153
|
+
* @fires TreeView#collapse
|
|
154
|
+
* @fires TreeView#activate
|
|
155
|
+
* @fires TreeView#check
|
|
156
|
+
* @fires TreeView#error
|
|
157
|
+
* @extends {Component<TreeOptions>}
|
|
158
|
+
*/
|
|
159
|
+
export declare class TreeView extends Component<TreeOptions> {
|
|
160
|
+
_items: any[] | import("./hierarchy.js").TreeNode[];
|
|
161
|
+
_rows: any[] | {
|
|
162
|
+
node: import("./hierarchy.js").TreeNode;
|
|
163
|
+
id: unknown;
|
|
164
|
+
level: number;
|
|
165
|
+
parent: import("./hierarchy.js").TreeNode | null;
|
|
166
|
+
posinset: number;
|
|
167
|
+
setsize: number;
|
|
168
|
+
}[];
|
|
169
|
+
_expanded: Set<any>;
|
|
170
|
+
_selected: Set<any> | Set<unknown>;
|
|
171
|
+
_checked: Set<any>;
|
|
172
|
+
/** @type {Map<unknown, Promise<boolean>>} In-flight lazy loads, keyed by node ID. */
|
|
173
|
+
_loading: Map<unknown, Promise<boolean>>;
|
|
174
|
+
_focusId: any;
|
|
175
|
+
_filter: string;
|
|
176
|
+
_createdRoot: boolean;
|
|
177
|
+
_snapshot: import("../../core/dom.js").TargetSnapshot;
|
|
178
|
+
_readers: import("./hierarchy.js").NodeReaders;
|
|
179
|
+
_childrenKey: string;
|
|
180
|
+
_handleTypeahead: (event: KeyboardEvent | string) => void;
|
|
181
|
+
static cssName: string;
|
|
182
|
+
/** @type {TreeOptions} */
|
|
183
|
+
static defaults: TreeOptions;
|
|
184
|
+
/** @returns {HTMLElement} */
|
|
185
|
+
render(): HTMLElement;
|
|
186
|
+
/**
|
|
187
|
+
* Replaces the whole tree.
|
|
188
|
+
* @param {TreeNode[]} items Nested nodes.
|
|
189
|
+
* @returns {this}
|
|
190
|
+
*/
|
|
191
|
+
setItems(items: TreeNode[]): this;
|
|
192
|
+
/**
|
|
193
|
+
* Returns the working copy of the tree, including lazily loaded children.
|
|
194
|
+
* @returns {TreeNode[]}
|
|
195
|
+
*/
|
|
196
|
+
getItems(): TreeNode[];
|
|
197
|
+
/**
|
|
198
|
+
* Looks a node up by ID.
|
|
199
|
+
* @param {unknown} id Node ID.
|
|
200
|
+
* @returns {TreeNode|null}
|
|
201
|
+
*/
|
|
202
|
+
getNode(id: unknown): TreeNode | null;
|
|
203
|
+
/**
|
|
204
|
+
* Returns the chain of nodes from a root down to the given node.
|
|
205
|
+
* @param {unknown} id Node ID.
|
|
206
|
+
* @returns {TreeNode[]}
|
|
207
|
+
*/
|
|
208
|
+
getPath(id: unknown): TreeNode[];
|
|
209
|
+
/**
|
|
210
|
+
* Filters the tree by a label substring, keeping the ancestors of every match.
|
|
211
|
+
* @param {string} query Search text; an empty string restores the full tree.
|
|
212
|
+
* @returns {this}
|
|
213
|
+
*/
|
|
214
|
+
setFilter(query: string): this;
|
|
215
|
+
/**
|
|
216
|
+
* Expands one branch, loading its children first when a lazy loader is configured.
|
|
217
|
+
* @param {unknown} id Node ID.
|
|
218
|
+
* @returns {Promise<this>}
|
|
219
|
+
* @fires TreeView#expand
|
|
220
|
+
*/
|
|
221
|
+
expand(id: unknown): Promise<this>;
|
|
222
|
+
/**
|
|
223
|
+
* Collapses one branch.
|
|
224
|
+
* @param {unknown} id Node ID.
|
|
225
|
+
* @returns {this}
|
|
226
|
+
* @fires TreeView#collapse
|
|
227
|
+
*/
|
|
228
|
+
collapse(id: unknown): this;
|
|
229
|
+
/**
|
|
230
|
+
* Expands or collapses one branch.
|
|
231
|
+
* @param {unknown} id Node ID.
|
|
232
|
+
* @returns {Promise<this>}
|
|
233
|
+
*/
|
|
234
|
+
toggle(id: unknown): Promise<this>;
|
|
235
|
+
/**
|
|
236
|
+
* Expands every already-loaded branch.
|
|
237
|
+
* @returns {this}
|
|
238
|
+
*/
|
|
239
|
+
expandAll(): this;
|
|
240
|
+
/** Collapses every branch. @returns {this} */
|
|
241
|
+
collapseAll(): this;
|
|
242
|
+
/**
|
|
243
|
+
* Expands every ancestor of a node so the node becomes visible.
|
|
244
|
+
* @param {unknown} id Node ID.
|
|
245
|
+
* @returns {this}
|
|
246
|
+
*/
|
|
247
|
+
reveal(id: unknown): this;
|
|
248
|
+
/**
|
|
249
|
+
* Selects one node, replacing the selection in single mode.
|
|
250
|
+
* @param {unknown} id Node ID.
|
|
251
|
+
* @param {{silent?: boolean, additive?: boolean}} [options={}] Selection behavior.
|
|
252
|
+
* @returns {this}
|
|
253
|
+
* @fires TreeView#select
|
|
254
|
+
*/
|
|
255
|
+
select(id: unknown, { silent, additive }?: {
|
|
256
|
+
silent?: boolean;
|
|
257
|
+
additive?: boolean;
|
|
258
|
+
}): this;
|
|
259
|
+
/**
|
|
260
|
+
* Returns the selected node IDs.
|
|
261
|
+
* @returns {unknown[]}
|
|
262
|
+
*/
|
|
263
|
+
getSelection(): unknown[];
|
|
264
|
+
/**
|
|
265
|
+
* Replaces the selection.
|
|
266
|
+
* @param {unknown[]} ids Node IDs.
|
|
267
|
+
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `select`.
|
|
268
|
+
* @returns {this}
|
|
269
|
+
*/
|
|
270
|
+
setSelection(ids: unknown[], { silent }?: {
|
|
271
|
+
silent?: boolean;
|
|
272
|
+
}): this;
|
|
273
|
+
/** Clears the selection. @returns {this} */
|
|
274
|
+
clearSelection(): this;
|
|
275
|
+
/**
|
|
276
|
+
* Returns the checked node IDs.
|
|
277
|
+
* @param {{leavesOnly?: boolean}} [options={}] Set `leavesOnly` to skip fully checked branches.
|
|
278
|
+
* @returns {unknown[]}
|
|
279
|
+
*/
|
|
280
|
+
getChecked({ leavesOnly }?: {
|
|
281
|
+
leavesOnly?: boolean;
|
|
282
|
+
}): unknown[];
|
|
283
|
+
/**
|
|
284
|
+
* Replaces the checked set, propagating each ID down its sub-tree.
|
|
285
|
+
* @param {unknown[]} ids Node IDs.
|
|
286
|
+
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `check`.
|
|
287
|
+
* @returns {this}
|
|
288
|
+
* @fires TreeView#check
|
|
289
|
+
*/
|
|
290
|
+
setChecked(ids: unknown[], { silent }?: {
|
|
291
|
+
silent?: boolean;
|
|
292
|
+
}): this;
|
|
293
|
+
/**
|
|
294
|
+
* Checks or unchecks one node and its sub-tree.
|
|
295
|
+
* @param {unknown} id Node ID.
|
|
296
|
+
* @param {boolean} checked Next state.
|
|
297
|
+
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `check`.
|
|
298
|
+
* @returns {this}
|
|
299
|
+
* @fires TreeView#check
|
|
300
|
+
*/
|
|
301
|
+
check(id: unknown, checked: boolean, { silent }?: {
|
|
302
|
+
silent?: boolean;
|
|
303
|
+
}): this;
|
|
304
|
+
/**
|
|
305
|
+
* Moves DOM focus to a node, revealing it first.
|
|
306
|
+
* @param {unknown} id Node ID.
|
|
307
|
+
* @returns {this}
|
|
308
|
+
*/
|
|
309
|
+
focusNode(id: unknown): this;
|
|
310
|
+
/** @returns {TreeNode[]} */
|
|
311
|
+
_visibleItems(): TreeNode[];
|
|
312
|
+
/** Rebuilds every row from the current tree, expansion set, and filter. @returns {void} */
|
|
313
|
+
_renderRows(): void;
|
|
314
|
+
/**
|
|
315
|
+
* @param {{node: TreeNode, id: unknown, level: number, posinset: number, setsize: number}} row Row spec.
|
|
316
|
+
* @returns {HTMLElement}
|
|
317
|
+
*/
|
|
318
|
+
_renderRow(row: {
|
|
319
|
+
node: TreeNode;
|
|
320
|
+
id: unknown;
|
|
321
|
+
level: number;
|
|
322
|
+
posinset: number;
|
|
323
|
+
setsize: number;
|
|
324
|
+
}): HTMLElement;
|
|
325
|
+
/** Applies expansion, selection, check, loading, and roving-tabindex state to every row. */
|
|
326
|
+
_syncRows(): void;
|
|
327
|
+
/** @param {MouseEvent} event @returns {void} */
|
|
328
|
+
_onClick(event: MouseEvent): void;
|
|
329
|
+
/** @param {MouseEvent} event @returns {void} */
|
|
330
|
+
_onDoubleClick(event: MouseEvent): void;
|
|
331
|
+
/** @param {KeyboardEvent} event @returns {void} */
|
|
332
|
+
_onKeydown(event: KeyboardEvent): void;
|
|
333
|
+
/**
|
|
334
|
+
* Expands every sibling branch of a row, the APG `*` shortcut.
|
|
335
|
+
* @param {{parent: TreeNode|null}} row Focused row.
|
|
336
|
+
* @returns {void}
|
|
337
|
+
*/
|
|
338
|
+
_expandSiblings(row: {
|
|
339
|
+
parent: TreeNode | null;
|
|
340
|
+
}): void;
|
|
341
|
+
/**
|
|
342
|
+
* Loads a branch's children through the configured loader, once.
|
|
343
|
+
* @param {TreeNode} node Branch node.
|
|
344
|
+
* @param {unknown} id Node ID.
|
|
345
|
+
* @returns {Promise<void>}
|
|
346
|
+
*/
|
|
347
|
+
_ensureChildren(node: TreeNode, id: unknown): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* @param {unknown} id Node ID.
|
|
350
|
+
* @param {boolean} checked Next state.
|
|
351
|
+
* @param {{silent?: boolean}} options Behavior.
|
|
352
|
+
* @returns {TreeNode|null}
|
|
353
|
+
*/
|
|
354
|
+
_applyCheck(id: unknown, checked: boolean, { silent }: {
|
|
355
|
+
silent?: boolean;
|
|
356
|
+
}): TreeNode | null;
|
|
357
|
+
/**
|
|
358
|
+
* Derives a node's tri-state check state from its descendants.
|
|
359
|
+
* @param {TreeNode} node Node to inspect.
|
|
360
|
+
* @returns {'checked'|'partial'|'unchecked'}
|
|
361
|
+
*/
|
|
362
|
+
_checkState(node: TreeNode): 'checked' | 'partial' | 'unchecked';
|
|
363
|
+
/**
|
|
364
|
+
* The visible rows starting just after the focused one, wrapping around.
|
|
365
|
+
* @returns {{node: TreeNode, id: unknown}[]}
|
|
366
|
+
*/
|
|
367
|
+
_rotatedRows(): {
|
|
368
|
+
node: TreeNode;
|
|
369
|
+
id: unknown;
|
|
370
|
+
}[];
|
|
371
|
+
/** @param {Element} element @returns {number} */
|
|
372
|
+
_rowIndex(element: Element): number;
|
|
373
|
+
/** @param {unknown} id @returns {Element|null} */
|
|
374
|
+
_rowElement(id: unknown): Element | null;
|
|
375
|
+
/** @param {number} index @returns {void} */
|
|
376
|
+
_focusRow(index: number): void;
|
|
377
|
+
/** @param {unknown} id @returns {void} */
|
|
378
|
+
_focusNodeId(id: unknown): void;
|
|
379
|
+
/** @param {string} key @param {string} fallback @returns {string} */
|
|
380
|
+
_message(key: string, fallback: string): string;
|
|
381
|
+
/** Restores an enhanced target to the markup it had before the takeover. @returns {void} */
|
|
382
|
+
destroy(): void;
|
|
383
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type TruncateOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Lines to keep. One line ends in an ellipsis; more clamp the block.
|
|
4
|
+
*/
|
|
5
|
+
lines?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Whether a native `title` tooltip is set — and kept up to date —
|
|
8
|
+
* while the text is actually cut off, so the full value stays reachable on hover.
|
|
9
|
+
*/
|
|
10
|
+
title?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type TruncateController = {
|
|
13
|
+
/**
|
|
14
|
+
* Re-measures and returns whether the text is currently cut off.
|
|
15
|
+
*/
|
|
16
|
+
update: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the text was cut off at the last measurement.
|
|
19
|
+
*/
|
|
20
|
+
isTruncated: () => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Removes the classes, the observer, and any title this set.
|
|
23
|
+
*/
|
|
24
|
+
destroy: () => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} TruncateOptions
|
|
28
|
+
* @property {number} [lines=1] Lines to keep. One line ends in an ellipsis; more clamp the block.
|
|
29
|
+
* @property {boolean} [title=true] Whether a native `title` tooltip is set — and kept up to date —
|
|
30
|
+
* while the text is actually cut off, so the full value stays reachable on hover.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {Object} TruncateController
|
|
34
|
+
* @property {() => boolean} update Re-measures and returns whether the text is currently cut off.
|
|
35
|
+
* @property {() => boolean} isTruncated Whether the text was cut off at the last measurement.
|
|
36
|
+
* @property {() => void} destroy Removes the classes, the observer, and any title this set.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Clamps an element's text to a number of lines, and gives the cut-off text back on hover.
|
|
40
|
+
*
|
|
41
|
+
* The `title` half is what makes this more than a CSS class. A table cell that silently drops the
|
|
42
|
+
* end of a value is a data-loss bug wearing a layout costume; a tooltip that is always present is
|
|
43
|
+
* noise. Measuring on every resize means the tooltip appears exactly when the text is short of
|
|
44
|
+
* room and disappears when the column is widened.
|
|
45
|
+
*
|
|
46
|
+
* @param {Element|string} target Element or selector to clamp.
|
|
47
|
+
* @param {TruncateOptions} [options={}] Truncation options.
|
|
48
|
+
* @returns {TruncateController}
|
|
49
|
+
*/
|
|
50
|
+
export declare function truncate(target: Element | string, options?: TruncateOptions): TruncateController;
|
|
51
|
+
/**
|
|
52
|
+
* Whether an element's text overflows the box it is in.
|
|
53
|
+
*
|
|
54
|
+
* Both axes are checked because the two clamping modes overflow differently: a single line runs
|
|
55
|
+
* out of width, a multi-line clamp runs out of height. The one-pixel tolerance absorbs the
|
|
56
|
+
* sub-pixel difference between scroll and client sizes that fractional zoom levels produce.
|
|
57
|
+
*
|
|
58
|
+
* @param {Element} element Element to measure.
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/
|
|
61
|
+
export declare function isTruncated(element: Element): boolean;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
export type ValueListOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Initial ordered values.
|
|
5
|
+
*/
|
|
6
|
+
values?: unknown[];
|
|
7
|
+
/**
|
|
8
|
+
* Input placeholder.
|
|
9
|
+
*/
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether values can be removed.
|
|
13
|
+
*/
|
|
14
|
+
deletable?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether values can be reordered.
|
|
17
|
+
*/
|
|
18
|
+
sortable?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether duplicate strings are rejected.
|
|
21
|
+
*/
|
|
22
|
+
unique?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Value validator.
|
|
25
|
+
*/
|
|
26
|
+
validate?: ((value: string) => boolean | string) | null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} ValueListOptions
|
|
30
|
+
* @property {unknown[]} [values=[]] Initial ordered values.
|
|
31
|
+
* @property {string} [placeholder=''] Input placeholder.
|
|
32
|
+
* @property {boolean} [deletable=true] Whether values can be removed.
|
|
33
|
+
* @property {boolean} [sortable=true] Whether values can be reordered.
|
|
34
|
+
* @property {boolean} [unique=true] Whether duplicate strings are rejected.
|
|
35
|
+
* @property {((value: string) => boolean|string)|null} [validate=null] Value validator.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Tag/chip editor. It uses the APG listbox/option focus model: each chip is an option, arrow keys
|
|
39
|
+
* move focus, Ctrl+Left/Right reorders, and Delete/Backspace removes the focused option.
|
|
40
|
+
* @fires ValueList#change
|
|
41
|
+
* @fires ValueList#add
|
|
42
|
+
* @fires ValueList#remove
|
|
43
|
+
* @extends {Component<ValueListOptions>}
|
|
44
|
+
*/
|
|
45
|
+
export declare class ValueList extends Component<ValueListOptions> {
|
|
46
|
+
_ownedNodes: any[];
|
|
47
|
+
_disabled: boolean;
|
|
48
|
+
_dragIndex: number;
|
|
49
|
+
_initialState: string;
|
|
50
|
+
_initialDisabled: string;
|
|
51
|
+
_values: string[];
|
|
52
|
+
_list: HTMLElement;
|
|
53
|
+
_input: HTMLElement;
|
|
54
|
+
_status: HTMLElement;
|
|
55
|
+
_instructions: HTMLElement;
|
|
56
|
+
static cssName: string;
|
|
57
|
+
/** @type {ValueListOptions} */
|
|
58
|
+
static defaults: ValueListOptions;
|
|
59
|
+
/** @returns {HTMLElement} */
|
|
60
|
+
render(): HTMLElement;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a copy of the ordered values.
|
|
63
|
+
* @returns {string[]}
|
|
64
|
+
*/
|
|
65
|
+
getValues(): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Replaces all values.
|
|
68
|
+
* @param {unknown[]} values New values.
|
|
69
|
+
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
70
|
+
* @returns {this}
|
|
71
|
+
*/
|
|
72
|
+
setValues(values: unknown[], { silent }?: {
|
|
73
|
+
silent?: boolean;
|
|
74
|
+
}): this;
|
|
75
|
+
/**
|
|
76
|
+
* Validates and appends one value.
|
|
77
|
+
* @param {unknown} value Value to append.
|
|
78
|
+
* @returns {boolean} Whether the value was added.
|
|
79
|
+
* @fires ValueList#add
|
|
80
|
+
* @fires ValueList#change
|
|
81
|
+
*/
|
|
82
|
+
addValue(value: unknown): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Removes the first matching value.
|
|
85
|
+
* @param {unknown} value Value to remove.
|
|
86
|
+
* @returns {boolean} Whether a value was removed.
|
|
87
|
+
* @fires ValueList#remove
|
|
88
|
+
* @fires ValueList#change
|
|
89
|
+
*/
|
|
90
|
+
removeValue(value: unknown): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Focuses the value input.
|
|
93
|
+
* @returns {this}
|
|
94
|
+
*/
|
|
95
|
+
focus(): this;
|
|
96
|
+
/**
|
|
97
|
+
* Enables editing.
|
|
98
|
+
* @returns {this}
|
|
99
|
+
*/
|
|
100
|
+
enable(): this;
|
|
101
|
+
/**
|
|
102
|
+
* Disables editing, removal, and reordering.
|
|
103
|
+
* @returns {this}
|
|
104
|
+
*/
|
|
105
|
+
disable(): this;
|
|
106
|
+
/** @returns {void} */
|
|
107
|
+
_renderChips(focusIndex?: number): void;
|
|
108
|
+
/** @param {KeyboardEvent} event @returns {void} */
|
|
109
|
+
_handleInputKeydown(event: KeyboardEvent): void;
|
|
110
|
+
/** @param {KeyboardEvent} event @returns {void} */
|
|
111
|
+
_handleChipKeydown(event: KeyboardEvent): void;
|
|
112
|
+
/** @param {MouseEvent} event @returns {void} */
|
|
113
|
+
_handleChipClick(event: MouseEvent): void;
|
|
114
|
+
/** @param {DragEvent} event @returns {void} */
|
|
115
|
+
_handleDragStart(event: DragEvent): void;
|
|
116
|
+
/** @param {DragEvent} event @returns {void} */
|
|
117
|
+
_handleDrop(event: DragEvent): void;
|
|
118
|
+
/** @returns {void} */
|
|
119
|
+
_finishDrag(): void;
|
|
120
|
+
/** @param {number} start @param {number} end @param {boolean} focus @returns {void} */
|
|
121
|
+
_move(start: number, end: number, focus: boolean): void;
|
|
122
|
+
/** @param {number} index @param {number} [focusIndex=-1] @returns {void} */
|
|
123
|
+
_removeAt(index: number, focusIndex?: number): void;
|
|
124
|
+
/** @param {string} message @returns {void} */
|
|
125
|
+
_showError(message: string): void;
|
|
126
|
+
/** @returns {void} */
|
|
127
|
+
destroy(): void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Values changed event.
|
|
131
|
+
* @event ValueList#change
|
|
132
|
+
* @type {CustomEvent<{values: string[]}>
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* Value added event.
|
|
136
|
+
* @event ValueList#add
|
|
137
|
+
* @type {CustomEvent<{value: string}>
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* Value removed event.
|
|
141
|
+
* @event ValueList#remove
|
|
142
|
+
* @type {CustomEvent<{value: string}>
|
|
143
|
+
*/
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named width thresholds, and a way to react to one being crossed.
|
|
3
|
+
*
|
|
4
|
+
* The scale lives here rather than in the token layer because a CSS custom property cannot be
|
|
5
|
+
* used inside a media query, so a `--zx-bp-*` token would be a value no stylesheet could read.
|
|
6
|
+
* Zx's own layout utilities avoid the problem entirely — `.zx-grid` reflows on intrinsic track
|
|
7
|
+
* widths, not on breakpoints — which leaves this module for the cases only script can decide:
|
|
8
|
+
* rendering a Table as cards below a width, collapsing a MasterPanel, choosing a chart density.
|
|
9
|
+
* @module zx/core/breakpoint
|
|
10
|
+
*/
|
|
11
|
+
export type BreakpointName = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
/** @typedef {'xs'|'sm'|'md'|'lg'|'xl'} BreakpointName */
|
|
13
|
+
/**
|
|
14
|
+
* Lower bound of each named breakpoint, in pixels. A width below `sm` is `xs`.
|
|
15
|
+
* @type {Readonly<Record<Exclude<BreakpointName, 'xs'>, number>>}
|
|
16
|
+
*/
|
|
17
|
+
export declare const breakpoints: Readonly<Record<Exclude<BreakpointName, 'xs'>, number>>;
|
|
18
|
+
/**
|
|
19
|
+
* The breakpoint a width falls into.
|
|
20
|
+
* @param {number} width Width in pixels.
|
|
21
|
+
* @returns {BreakpointName}
|
|
22
|
+
*/
|
|
23
|
+
export declare function breakpointOf(width: number): BreakpointName;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a width has reached a named breakpoint. `matchBreakpoint('md', 900)` is the script
|
|
26
|
+
* equivalent of `@media (min-width: 768px)`.
|
|
27
|
+
* @param {BreakpointName} name Breakpoint to test against.
|
|
28
|
+
* @param {number} width Width in pixels.
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export declare function matchBreakpoint(name: BreakpointName, width: number): boolean;
|
|
32
|
+
export type BreakpointOptions = {
|
|
33
|
+
/**
|
|
34
|
+
* What to measure. An Element is watched with a
|
|
35
|
+
* `ResizeObserver`, which is what a component inside a split pane or a modal needs — the
|
|
36
|
+
* viewport width says nothing about the space it actually has.
|
|
37
|
+
*/
|
|
38
|
+
target?: Element | Window;
|
|
39
|
+
};
|
|
40
|
+
export type BreakpointController = {
|
|
41
|
+
/**
|
|
42
|
+
* The breakpoint as last measured.
|
|
43
|
+
*/
|
|
44
|
+
current: () => BreakpointName;
|
|
45
|
+
/**
|
|
46
|
+
* Stops observing.
|
|
47
|
+
*/
|
|
48
|
+
destroy: () => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {Object} BreakpointOptions
|
|
52
|
+
* @property {Element|Window} [target=window] What to measure. An Element is watched with a
|
|
53
|
+
* `ResizeObserver`, which is what a component inside a split pane or a modal needs — the
|
|
54
|
+
* viewport width says nothing about the space it actually has.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {Object} BreakpointController
|
|
58
|
+
* @property {() => BreakpointName} current The breakpoint as last measured.
|
|
59
|
+
* @property {() => void} destroy Stops observing.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Calls back whenever the observed width crosses into another breakpoint, and once immediately
|
|
63
|
+
* with the current one.
|
|
64
|
+
* @param {(name: BreakpointName, width: number) => void} handler Called on every change.
|
|
65
|
+
* @param {BreakpointOptions} [options={}] What to observe.
|
|
66
|
+
* @returns {BreakpointController}
|
|
67
|
+
*/
|
|
68
|
+
export declare function onBreakpoint(handler: (name: BreakpointName, width: number) => void, options?: BreakpointOptions): BreakpointController;
|