@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,108 @@
|
|
|
1
|
+
.zx-field-upload {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: var(--zx-space-3);
|
|
4
|
+
min-inline-size: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.zx-field-upload__input {
|
|
8
|
+
position: absolute;
|
|
9
|
+
inline-size: 1px;
|
|
10
|
+
block-size: 1px;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
clip-path: inset(50%);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.zx-field-upload__dropzone {
|
|
16
|
+
display: grid;
|
|
17
|
+
place-items: center;
|
|
18
|
+
gap: var(--zx-space-1);
|
|
19
|
+
min-block-size: 8rem;
|
|
20
|
+
inline-size: 100%;
|
|
21
|
+
padding: var(--zx-space-5);
|
|
22
|
+
border: 1px dashed var(--zx-color-border-strong);
|
|
23
|
+
background: var(--zx-color-bg-surface);
|
|
24
|
+
text-align: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.zx-field-upload__dropzone:hover,
|
|
28
|
+
.zx-field-upload[data-state="dragover"] .zx-field-upload__dropzone {
|
|
29
|
+
border-color: var(--zx-color-accent);
|
|
30
|
+
background: var(--zx-color-bg-selected);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.zx-field-upload__prompt {
|
|
34
|
+
color: var(--zx-color-text);
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.zx-field-upload__hint,
|
|
39
|
+
.zx-field-upload__status,
|
|
40
|
+
.zx-field-upload__progress-text {
|
|
41
|
+
color: var(--zx-color-text-muted);
|
|
42
|
+
font-size: var(--zx-text-sm);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.zx-field-upload__preview:empty {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.zx-field-upload__image {
|
|
50
|
+
display: block;
|
|
51
|
+
max-inline-size: 12rem;
|
|
52
|
+
max-block-size: 9rem;
|
|
53
|
+
border: 1px solid var(--zx-color-border);
|
|
54
|
+
border-radius: var(--zx-radius-md);
|
|
55
|
+
object-fit: contain;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.zx-field-upload__progress-wrap {
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: minmax(0, 1fr) auto auto;
|
|
61
|
+
gap: var(--zx-space-3);
|
|
62
|
+
align-items: center;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.zx-field-upload__progress-wrap[hidden] {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.zx-field-upload__progress {
|
|
70
|
+
inline-size: 100%;
|
|
71
|
+
accent-color: var(--zx-color-accent);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.zx-field-upload__abort {
|
|
75
|
+
color: var(--zx-color-danger);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.zx-field-upload__abort[hidden] {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.zx-field-upload[data-state="error"] .zx-field-upload__dropzone {
|
|
83
|
+
border-color: var(--zx-color-danger);
|
|
84
|
+
background: var(--zx-color-danger-bg);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.zx-field-upload[data-state="error"] .zx-field-upload__status {
|
|
88
|
+
color: var(--zx-color-danger);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.zx-field-upload[data-state="success"] .zx-field-upload__dropzone {
|
|
92
|
+
border-color: var(--zx-color-success);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.zx-field-upload[data-state="success"] .zx-field-upload__status {
|
|
96
|
+
color: var(--zx-color-success);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.zx-field-upload[data-disabled="true"] {
|
|
100
|
+
opacity: 0.65;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
104
|
+
.zx-field-upload__dropzone {
|
|
105
|
+
transition: border-color var(--zx-dur-fast) var(--zx-ease),
|
|
106
|
+
background var(--zx-dur-fast) var(--zx-ease);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
import { h } from '../../core/dom.js';
|
|
3
|
+
import { uid } from '../../core/util.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} UploadTransport
|
|
7
|
+
* @property {(url: string, options: UploadTransportOptions) => Promise<unknown>} [upload] Upload method used by stubs.
|
|
8
|
+
* @property {(url: string, options: Record<string, unknown>) => Promise<unknown>} [request] Http-compatible request method.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} UploadTransportOptions
|
|
13
|
+
* @property {File[]} files Selected files.
|
|
14
|
+
* @property {string} paramName Multipart field name.
|
|
15
|
+
* @property {Record<string, unknown>} params Extra form values.
|
|
16
|
+
* @property {Record<string, string>} headers Request headers.
|
|
17
|
+
* @property {AbortSignal} signal Abort signal.
|
|
18
|
+
* @property {(percent: number) => void} onProgress Progress callback.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} FieldUploadOptions
|
|
23
|
+
* @property {string} [url=''] Upload endpoint.
|
|
24
|
+
* @property {string} [paramName='upload'] Multipart file field name.
|
|
25
|
+
* @property {Record<string, unknown>} [params={}] Extra multipart values.
|
|
26
|
+
* @property {Record<string, string>} [headers={}] Request headers.
|
|
27
|
+
* @property {boolean} [multiple=false] Allow multiple files.
|
|
28
|
+
* @property {string|null} [accept=null] Native accept filter.
|
|
29
|
+
* @property {number|null} [maxSize=null] Maximum size per file in bytes.
|
|
30
|
+
* @property {boolean} [autoUpload=true] Upload immediately after selection.
|
|
31
|
+
* @property {boolean} [preview=true] Show a preview for the first selected image.
|
|
32
|
+
* @property {UploadTransport|null} [http=null] Injected Http-compatible or stub upload transport.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Accessible click/drop upload area. Native requests intentionally use XMLHttpRequest because
|
|
37
|
+
* browser fetch upload streams still do not expose portable upload progress events.
|
|
38
|
+
* @fires FieldUpload#select
|
|
39
|
+
* @fires FieldUpload#progress
|
|
40
|
+
* @fires FieldUpload#success
|
|
41
|
+
* @fires FieldUpload#error
|
|
42
|
+
* @fires FieldUpload#abort
|
|
43
|
+
* @extends {Component<FieldUploadOptions>}
|
|
44
|
+
*/
|
|
45
|
+
export class FieldUpload extends Component {
|
|
46
|
+
static cssName = 'field-upload';
|
|
47
|
+
|
|
48
|
+
/** @type {FieldUploadOptions} */
|
|
49
|
+
static defaults = {
|
|
50
|
+
url: '',
|
|
51
|
+
paramName: 'upload',
|
|
52
|
+
params: {},
|
|
53
|
+
headers: {},
|
|
54
|
+
multiple: false,
|
|
55
|
+
accept: null,
|
|
56
|
+
maxSize: null,
|
|
57
|
+
autoUpload: true,
|
|
58
|
+
preview: true,
|
|
59
|
+
http: null
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** @returns {HTMLElement} */
|
|
63
|
+
render() {
|
|
64
|
+
const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
|
|
65
|
+
this.el = root;
|
|
66
|
+
this._ownedNodes = [];
|
|
67
|
+
this._files = [];
|
|
68
|
+
this._disabled = false;
|
|
69
|
+
this._running = false;
|
|
70
|
+
this._runId = 0;
|
|
71
|
+
this._xhr = null;
|
|
72
|
+
this._transportController = null;
|
|
73
|
+
this._previewUrl = null;
|
|
74
|
+
this._initialState = root.getAttribute('data-state');
|
|
75
|
+
this._initialDisabled = root.getAttribute('data-disabled');
|
|
76
|
+
const inputId = uid('zx-upload');
|
|
77
|
+
this._input = h('input', {
|
|
78
|
+
class: 'zx-field-upload__input',
|
|
79
|
+
id: inputId,
|
|
80
|
+
type: 'file',
|
|
81
|
+
multiple: Boolean(this.options.multiple),
|
|
82
|
+
accept: this.options.accept ?? undefined,
|
|
83
|
+
tabIndex: -1
|
|
84
|
+
});
|
|
85
|
+
this._dropzone = h('button', {
|
|
86
|
+
class: 'zx-field-upload__dropzone',
|
|
87
|
+
type: 'button',
|
|
88
|
+
ariaControls: inputId,
|
|
89
|
+
ariaLabel: this.options.multiple ? 'Choose files or drop them here' : 'Choose a file or drop it here'
|
|
90
|
+
},
|
|
91
|
+
h('span', { class: 'zx-field-upload__prompt' }, this.options.multiple ? 'Drop files here or choose files' : 'Drop a file here or choose a file'),
|
|
92
|
+
h('span', { class: 'zx-field-upload__hint' }, uploadHint(this.options)));
|
|
93
|
+
this._preview = h('div', { class: 'zx-field-upload__preview' });
|
|
94
|
+
this._progress = h('progress', {
|
|
95
|
+
class: 'zx-field-upload__progress',
|
|
96
|
+
max: 100,
|
|
97
|
+
value: 0,
|
|
98
|
+
ariaLabel: 'Upload progress'
|
|
99
|
+
});
|
|
100
|
+
this._progressText = h('span', { class: 'zx-field-upload__progress-text' }, '0%');
|
|
101
|
+
this._abort = h('button', {
|
|
102
|
+
class: 'zx-btn zx-field-upload__abort',
|
|
103
|
+
type: 'button'
|
|
104
|
+
}, 'Abort');
|
|
105
|
+
this._progressWrap = h('div', {
|
|
106
|
+
class: 'zx-field-upload__progress-wrap',
|
|
107
|
+
hidden: true
|
|
108
|
+
}, this._progress, this._progressText, this._abort);
|
|
109
|
+
this._status = h('div', {
|
|
110
|
+
class: 'zx-field-upload__status',
|
|
111
|
+
role: 'status',
|
|
112
|
+
ariaLive: 'polite'
|
|
113
|
+
});
|
|
114
|
+
this._ownedNodes.push(this._input, this._dropzone, this._preview, this._progressWrap, this._status);
|
|
115
|
+
root.append(...this._ownedNodes);
|
|
116
|
+
|
|
117
|
+
this.listen(this._dropzone, 'click', () => {
|
|
118
|
+
if (!this._disabled && !this._running) this._input.click();
|
|
119
|
+
});
|
|
120
|
+
this.listen(this._input, 'change', () => this._selectFiles(this._input.files));
|
|
121
|
+
this.listen(this._dropzone, 'dragenter', (event) => this._handleDragOver(event));
|
|
122
|
+
this.listen(this._dropzone, 'dragover', (event) => this._handleDragOver(event));
|
|
123
|
+
this.listen(this._dropzone, 'dragleave', (event) => {
|
|
124
|
+
if (!(event.relatedTarget instanceof Node) || !this._dropzone.contains(event.relatedTarget)) this._setState('idle');
|
|
125
|
+
});
|
|
126
|
+
this.listen(this._dropzone, 'drop', (event) => {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
if (this._disabled || this._running) return;
|
|
129
|
+
this._setState('idle');
|
|
130
|
+
this._selectFiles(event.dataTransfer?.files ?? []);
|
|
131
|
+
});
|
|
132
|
+
this.listen(this._abort, 'click', () => this.abort());
|
|
133
|
+
this.setDisabled(false);
|
|
134
|
+
return root;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Uploads supplied files, or the current selection when omitted.
|
|
139
|
+
* @param {File[]|FileList|null} [files=null] Optional files to select and upload.
|
|
140
|
+
* @returns {Promise<unknown|null>} Transport response, or null when no upload starts.
|
|
141
|
+
*/
|
|
142
|
+
async upload(files = null) {
|
|
143
|
+
if (files !== null && !this._setFiles(files)) return null;
|
|
144
|
+
if (this._disabled || this._running || this._files.length === 0) return null;
|
|
145
|
+
this._running = true;
|
|
146
|
+
this._runId += 1;
|
|
147
|
+
const runId = this._runId;
|
|
148
|
+
this._setState('uploading');
|
|
149
|
+
this._progressWrap.hidden = false;
|
|
150
|
+
this._abort.hidden = false;
|
|
151
|
+
this._setProgress(0);
|
|
152
|
+
this._status.textContent = 'Uploading…';
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
const response = this.options.http ? await this._uploadInjected() : await this._uploadXhr();
|
|
156
|
+
if (runId !== this._runId) return null;
|
|
157
|
+
this._running = false;
|
|
158
|
+
this._xhr = null;
|
|
159
|
+
this._transportController = null;
|
|
160
|
+
this._abort.hidden = true;
|
|
161
|
+
this._setProgress(100);
|
|
162
|
+
this._setState('success');
|
|
163
|
+
this._status.textContent = 'Upload complete.';
|
|
164
|
+
this.emit('success', { response });
|
|
165
|
+
return response;
|
|
166
|
+
} catch (caught) {
|
|
167
|
+
if (runId !== this._runId) return null;
|
|
168
|
+
const error = caught instanceof Error ? caught : new Error(String(caught));
|
|
169
|
+
if (error.name === 'AbortError') {
|
|
170
|
+
this._finishAbort();
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
this._running = false;
|
|
174
|
+
this._xhr = null;
|
|
175
|
+
this._transportController = null;
|
|
176
|
+
this._abort.hidden = true;
|
|
177
|
+
this._setState('error');
|
|
178
|
+
this._status.textContent = error.message;
|
|
179
|
+
this.emit('error', { error });
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Aborts the active upload.
|
|
186
|
+
* @returns {this}
|
|
187
|
+
* @fires FieldUpload#abort
|
|
188
|
+
*/
|
|
189
|
+
abort() {
|
|
190
|
+
if (!this._running) return this;
|
|
191
|
+
this._xhr?.abort();
|
|
192
|
+
this._transportController?.abort();
|
|
193
|
+
this._finishAbort();
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Clears selection, preview, progress, and status.
|
|
199
|
+
* @returns {this}
|
|
200
|
+
*/
|
|
201
|
+
clear() {
|
|
202
|
+
if (this._running) this.abort();
|
|
203
|
+
this._files = [];
|
|
204
|
+
this._input.value = '';
|
|
205
|
+
this._revokePreview();
|
|
206
|
+
this._preview.replaceChildren();
|
|
207
|
+
this._progress.value = 0;
|
|
208
|
+
this._progressText.textContent = '0%';
|
|
209
|
+
this._progressWrap.hidden = true;
|
|
210
|
+
this._status.textContent = '';
|
|
211
|
+
this._setState('idle');
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Enables or disables file selection and dropping.
|
|
217
|
+
* @param {boolean} disabled Disabled state.
|
|
218
|
+
* @returns {this}
|
|
219
|
+
*/
|
|
220
|
+
setDisabled(disabled) {
|
|
221
|
+
this._disabled = Boolean(disabled);
|
|
222
|
+
this._input.disabled = this._disabled;
|
|
223
|
+
this._dropzone.disabled = this._disabled;
|
|
224
|
+
this.el.dataset.disabled = String(this._disabled);
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** @param {FileList|File[]|ArrayLike<File>} files @returns {void} */
|
|
229
|
+
_selectFiles(files) {
|
|
230
|
+
if (!this._setFiles(files)) return;
|
|
231
|
+
this._input.value = '';
|
|
232
|
+
if (this.options.autoUpload) void this.upload();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** @param {FileList|File[]|ArrayLike<File>} files @returns {boolean} */
|
|
236
|
+
_setFiles(files) {
|
|
237
|
+
if (this._disabled || this._running) return false;
|
|
238
|
+
const selected = Array.from(files ?? []);
|
|
239
|
+
const normalized = this.options.multiple ? selected : selected.slice(0, 1);
|
|
240
|
+
if (normalized.length === 0) return false;
|
|
241
|
+
const invalid = normalized.find((file) => !matchesAccept(file, this.options.accept));
|
|
242
|
+
if (invalid) {
|
|
243
|
+
this._selectionError(new Error(`${invalid.name} is not an accepted file type.`));
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
const oversized = this.options.maxSize == null ? null : normalized.find((file) => file.size > Number(this.options.maxSize));
|
|
247
|
+
if (oversized) {
|
|
248
|
+
this._selectionError(new Error(`${oversized.name} exceeds the maximum file size.`));
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
this._files = normalized;
|
|
252
|
+
this._renderPreview();
|
|
253
|
+
this._status.textContent = normalized.map((file) => file.name).join(', ');
|
|
254
|
+
this._setState('selected');
|
|
255
|
+
this.emit('select', { files: this._files.slice() });
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** @param {DragEvent} event @returns {void} */
|
|
260
|
+
_handleDragOver(event) {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
if (!this._disabled && !this._running) this._setState('dragover');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** @returns {Promise<unknown>} */
|
|
266
|
+
_uploadInjected() {
|
|
267
|
+
const transport = this.options.http;
|
|
268
|
+
this._transportController = new AbortController();
|
|
269
|
+
const uploadOptions = {
|
|
270
|
+
files: this._files.slice(),
|
|
271
|
+
paramName: String(this.options.paramName),
|
|
272
|
+
params: { ...this.options.params },
|
|
273
|
+
headers: { ...this.options.headers },
|
|
274
|
+
signal: this._transportController.signal,
|
|
275
|
+
onProgress: (percent) => this._setProgress(percent)
|
|
276
|
+
};
|
|
277
|
+
if (typeof transport.upload === 'function') return transport.upload(String(this.options.url), uploadOptions);
|
|
278
|
+
if (typeof transport.request === 'function') {
|
|
279
|
+
return transport.request(String(this.options.url), {
|
|
280
|
+
method: 'POST',
|
|
281
|
+
data: uploadOptions.params,
|
|
282
|
+
files: uploadOptions.files,
|
|
283
|
+
headers: uploadOptions.headers,
|
|
284
|
+
signal: uploadOptions.signal,
|
|
285
|
+
onProgress: uploadOptions.onProgress,
|
|
286
|
+
paramName: uploadOptions.paramName
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return Promise.reject(new TypeError('Injected upload transport requires upload() or request()'));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** @returns {Promise<unknown>} */
|
|
293
|
+
_uploadXhr() {
|
|
294
|
+
if (typeof XMLHttpRequest !== 'function') return Promise.reject(new Error('XMLHttpRequest is not available'));
|
|
295
|
+
return new Promise((resolve, reject) => {
|
|
296
|
+
const xhr = new XMLHttpRequest();
|
|
297
|
+
this._xhr = xhr;
|
|
298
|
+
xhr.open('POST', String(this.options.url));
|
|
299
|
+
for (const [name, value] of Object.entries(this.options.headers ?? {})) xhr.setRequestHeader(name, String(value));
|
|
300
|
+
this.listen(xhr.upload, 'progress', (event) => {
|
|
301
|
+
if (event.lengthComputable) this._setProgress((event.loaded / event.total) * 100);
|
|
302
|
+
});
|
|
303
|
+
this.listen(xhr, 'load', () => {
|
|
304
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
305
|
+
reject(new Error(`Upload failed with HTTP ${xhr.status}`));
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
resolve(parseResponse(xhr.responseText));
|
|
309
|
+
});
|
|
310
|
+
this.listen(xhr, 'error', () => reject(new Error('Upload request failed')));
|
|
311
|
+
this.listen(xhr, 'abort', () => reject(abortError()));
|
|
312
|
+
xhr.send(createFormData(this._files, String(this.options.paramName), this.options.params));
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** @param {number} percent @returns {void} */
|
|
317
|
+
_setProgress(percent) {
|
|
318
|
+
const value = Math.max(0, Math.min(100, Number(percent) || 0));
|
|
319
|
+
this._progress.value = value;
|
|
320
|
+
this._progressText.textContent = `${Math.round(value)}%`;
|
|
321
|
+
this.emit('progress', { percent: value });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** @returns {void} */
|
|
325
|
+
_finishAbort() {
|
|
326
|
+
if (!this._running) return;
|
|
327
|
+
this._runId += 1;
|
|
328
|
+
this._running = false;
|
|
329
|
+
this._xhr = null;
|
|
330
|
+
this._transportController = null;
|
|
331
|
+
this._abort.hidden = true;
|
|
332
|
+
this._setState('idle');
|
|
333
|
+
this._status.textContent = 'Upload aborted.';
|
|
334
|
+
this.emit('abort', {});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** @param {Error} error @returns {void} */
|
|
338
|
+
_selectionError(error) {
|
|
339
|
+
this._setState('error');
|
|
340
|
+
this._status.textContent = error.message;
|
|
341
|
+
this.emit('error', { error });
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** @returns {void} */
|
|
345
|
+
_renderPreview() {
|
|
346
|
+
this._revokePreview();
|
|
347
|
+
this._preview.replaceChildren();
|
|
348
|
+
const file = this._files[0];
|
|
349
|
+
if (!this.options.preview || !file?.type?.startsWith('image/') || typeof URL === 'undefined' || typeof URL.createObjectURL !== 'function') return;
|
|
350
|
+
this._previewUrl = URL.createObjectURL(file);
|
|
351
|
+
this._preview.append(h('img', {
|
|
352
|
+
class: 'zx-field-upload__image',
|
|
353
|
+
src: this._previewUrl,
|
|
354
|
+
alt: `Preview of ${file.name}`
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** @returns {void} */
|
|
359
|
+
_revokePreview() {
|
|
360
|
+
if (this._previewUrl && typeof URL !== 'undefined' && typeof URL.revokeObjectURL === 'function') URL.revokeObjectURL(this._previewUrl);
|
|
361
|
+
this._previewUrl = null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** @param {string} state @returns {void} */
|
|
365
|
+
_setState(state) {
|
|
366
|
+
if (state === 'idle') this.el.removeAttribute('data-state');
|
|
367
|
+
else this.el.dataset.state = state;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** @returns {void} */
|
|
371
|
+
destroy() {
|
|
372
|
+
if (this._running) this.abort();
|
|
373
|
+
this._revokePreview();
|
|
374
|
+
for (const node of this._ownedNodes ?? []) node.remove();
|
|
375
|
+
if (this._initialState === null) this.el.removeAttribute('data-state');
|
|
376
|
+
else this.el.setAttribute('data-state', this._initialState);
|
|
377
|
+
if (this._initialDisabled === null) this.el.removeAttribute('data-disabled');
|
|
378
|
+
else this.el.setAttribute('data-disabled', this._initialDisabled);
|
|
379
|
+
super.destroy();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** @param {FieldUploadOptions} options @returns {string} */
|
|
384
|
+
function uploadHint(options) {
|
|
385
|
+
const parts = [];
|
|
386
|
+
if (options.accept) parts.push(String(options.accept));
|
|
387
|
+
if (options.maxSize != null) parts.push(`up to ${formatBytes(Number(options.maxSize))}`);
|
|
388
|
+
return parts.join(' · ') || 'Choose from this device';
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** @param {number} bytes @returns {string} */
|
|
392
|
+
function formatBytes(bytes) {
|
|
393
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
394
|
+
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
|
|
395
|
+
return `${Math.round(bytes / (1024 * 1024))} MB`;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** @param {File} file @param {string|null|undefined} accept @returns {boolean} */
|
|
399
|
+
function matchesAccept(file, accept) {
|
|
400
|
+
if (!accept) return true;
|
|
401
|
+
const type = String(file.type ?? '').toLowerCase();
|
|
402
|
+
return String(accept).split(',').map((value) => value.trim().toLowerCase()).filter(Boolean).some((rule) => {
|
|
403
|
+
if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);
|
|
404
|
+
if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));
|
|
405
|
+
return type === rule;
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** @param {File[]} files @param {string} paramName @param {Record<string, unknown>} params @returns {FormData} */
|
|
410
|
+
function createFormData(files, paramName, params) {
|
|
411
|
+
const form = new FormData();
|
|
412
|
+
for (const file of files) form.append(paramName, file);
|
|
413
|
+
for (const [name, value] of Object.entries(params ?? {})) appendFormValue(form, name, value);
|
|
414
|
+
return form;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** @param {FormData} form @param {string} name @param {unknown} value @returns {void} */
|
|
418
|
+
function appendFormValue(form, name, value) {
|
|
419
|
+
if (value == null) return;
|
|
420
|
+
if (Array.isArray(value)) {
|
|
421
|
+
for (const item of value) appendFormValue(form, name, item);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const isBlob = typeof Blob === 'function' && value instanceof Blob;
|
|
425
|
+
if (isBlob) form.append(name, value);
|
|
426
|
+
else form.append(name, typeof value === 'object' ? JSON.stringify(value) : String(value));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** @param {string} text @returns {unknown} */
|
|
430
|
+
function parseResponse(text) {
|
|
431
|
+
if (!text) return null;
|
|
432
|
+
try {
|
|
433
|
+
return JSON.parse(text);
|
|
434
|
+
} catch {
|
|
435
|
+
return text;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** @returns {Error} */
|
|
440
|
+
function abortError() {
|
|
441
|
+
if (typeof DOMException === 'function') return new DOMException('Upload aborted', 'AbortError');
|
|
442
|
+
const error = new Error('Upload aborted');
|
|
443
|
+
error.name = 'AbortError';
|
|
444
|
+
return error;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Files selected event.
|
|
449
|
+
* @event FieldUpload#select
|
|
450
|
+
* @type {CustomEvent<{files: File[]}>
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Upload progress event.
|
|
455
|
+
* @event FieldUpload#progress
|
|
456
|
+
* @type {CustomEvent<{percent: number}>
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Upload success event.
|
|
461
|
+
* @event FieldUpload#success
|
|
462
|
+
* @type {CustomEvent<{response: unknown}>
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Upload failure event.
|
|
467
|
+
* @event FieldUpload#error
|
|
468
|
+
* @type {CustomEvent<{error: Error}>
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Upload aborted event.
|
|
473
|
+
* @event FieldUpload#abort
|
|
474
|
+
* @type {CustomEvent<Record<string, never>>}
|
|
475
|
+
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.zx-fieldset {
|
|
2
|
+
min-inline-size: 0;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: var(--zx-space-5);
|
|
5
|
+
border: 1px solid var(--zx-color-border);
|
|
6
|
+
border-radius: var(--zx-radius-lg);
|
|
7
|
+
background: var(--zx-color-bg-surface);
|
|
8
|
+
container-type: inline-size;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.zx-fieldset__legend {
|
|
12
|
+
padding-inline: var(--zx-space-2);
|
|
13
|
+
color: var(--zx-color-text);
|
|
14
|
+
font-size: var(--zx-text-lg);
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.zx-fieldset__grid {
|
|
19
|
+
display: grid;
|
|
20
|
+
grid-template-columns: minmax(0, 1fr);
|
|
21
|
+
gap: var(--zx-space-4) var(--zx-space-5);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.zx-fieldset[data-columns="2"] .zx-fieldset__grid {
|
|
25
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.zx-fieldset[data-columns="3"] .zx-fieldset__grid {
|
|
29
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@container (max-width: 38rem) {
|
|
33
|
+
.zx-fieldset[data-columns="2"] .zx-fieldset__grid,
|
|
34
|
+
.zx-fieldset[data-columns="3"] .zx-fieldset__grid {
|
|
35
|
+
grid-template-columns: minmax(0, 1fr);
|
|
36
|
+
}
|
|
37
|
+
}
|