@webquark/core 1.1.0-dev.7 → 1.1.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cjs/{action.props-B87W5tRu.js → action.props-N0urQtdP.js} +1 -1
- package/dist/cjs/{chevron-up-Dysp_9UJ.js → chevron-up-D4t2OSHA.js} +2 -2
- package/dist/cjs/{data-table-cell-BAv6IIYx.js → data-table-cell-8uUCk2Qz.js} +5 -0
- package/dist/cjs/{field-CbUc_AWx.js → field-CsrQGhG-.js} +1 -1
- package/dist/cjs/form-field-adapter-D0CJ6poh.js +51 -0
- package/dist/cjs/form-field-state-P63wN30v.js +51 -0
- package/dist/cjs/form-submit-action-C6c4aq6C.js +227 -0
- package/dist/cjs/image-crop-BZD5Cxd7.js +53 -0
- package/dist/cjs/{index-D_tObBJa.js → index-DWXhKHCB.js} +25 -26
- package/dist/cjs/index.cjs.js +8 -3
- package/dist/cjs/leaflet-maplibre-gl-JIaCQ-7v.js +1025 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{map.types-DNrz8rJh.js → map.types-BWymIRql.js} +1 -1
- package/dist/cjs/q-accordion.cjs.entry.js +2 -2
- package/dist/cjs/q-alert.cjs.entry.js +1 -1
- package/dist/cjs/q-avatar.cjs.entry.js +2 -2
- package/dist/cjs/q-banner.cjs.entry.js +1 -1
- package/dist/cjs/q-button_2.cjs.entry.js +111 -24
- package/dist/cjs/q-card.cjs.entry.js +2 -2
- package/dist/cjs/q-carousel.cjs.entry.js +400 -13
- package/dist/cjs/q-chip.cjs.entry.js +2 -2
- package/dist/cjs/q-conversation-bubble.cjs.entry.js +1 -1
- package/dist/cjs/q-data-table.cjs.entry.js +73 -11
- package/dist/cjs/q-dialog.cjs.entry.js +3 -3
- package/dist/cjs/q-dropdown.cjs.entry.js +64 -11
- package/dist/cjs/q-form.cjs.entry.js +774 -287
- package/dist/cjs/q-grid.cjs.entry.js +3 -3
- package/dist/cjs/q-icon.cjs.entry.js +143 -89
- package/dist/cjs/q-image-comparison.cjs.entry.js +201 -0
- package/dist/cjs/q-inline.cjs.entry.js +3 -3
- package/dist/cjs/q-input_2.cjs.entry.js +90 -22
- package/dist/cjs/q-link.cjs.entry.js +2 -2
- package/dist/cjs/q-map.cjs.entry.js +119 -22
- package/dist/cjs/q-media.cjs.entry.js +3 -3
- package/dist/cjs/q-navbar.cjs.entry.js +3 -3
- package/dist/cjs/q-pagination.cjs.entry.js +2 -2
- package/dist/cjs/q-panel.cjs.entry.js +6 -6
- package/dist/cjs/q-quantity-selector.cjs.entry.js +5 -5
- package/dist/cjs/q-radio-group.cjs.entry.js +48 -11
- package/dist/cjs/q-reel.cjs.entry.js +3 -3
- package/dist/cjs/q-scrollable.cjs.entry.js +4 -4
- package/dist/cjs/q-section.cjs.entry.js +2 -2
- package/dist/cjs/q-sidepanel.cjs.entry.js +145 -25
- package/dist/cjs/q-stack.cjs.entry.js +3 -3
- package/dist/cjs/q-step-diagram-item.cjs.entry.js +2 -2
- package/dist/cjs/q-step-diagram.cjs.entry.js +3 -3
- package/dist/cjs/q-syntax-box.cjs.entry.js +418 -301
- package/dist/cjs/q-tabs.cjs.entry.js +2 -2
- package/dist/cjs/q-textarea.cjs.entry.js +66 -21
- package/dist/cjs/q-thumbnail.cjs.entry.js +3 -3
- package/dist/cjs/q-toast.cjs.entry.js +1 -1
- package/dist/cjs/q-toggle.cjs.entry.js +58 -12
- package/dist/cjs/q-toolbar.cjs.entry.js +4 -4
- package/dist/cjs/registry-C3IYlNMp.js +323 -0
- package/dist/cjs/{tokens-DDfS79n9.js → tokens-RMRaIOqv.js} +12 -3
- package/dist/cjs/webquark.cjs.js +3 -3
- package/dist/collection/assets/icons/spinner.svg +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/actions/button/button.js +250 -14
- package/dist/collection/components/actions/button/test/button-slots.cmp.test.js +70 -0
- package/dist/collection/components/content/carousel/carousel.css +91 -5
- package/dist/collection/components/content/carousel/carousel.js +511 -20
- package/dist/collection/components/content/carousel/internals/autoplay.js +64 -0
- package/dist/collection/components/content/carousel/internals/slide-state.js +50 -0
- package/dist/collection/components/content/carousel/test/transitions.cmp.test.js +328 -0
- package/dist/collection/components/data-display/accordion/accordion.js +1 -1
- package/dist/collection/components/data-display/data-table/data-table-cell.js +4 -0
- package/dist/collection/components/data-display/data-table/data-table.css +73 -0
- package/dist/collection/components/data-display/data-table/data-table.js +117 -3
- package/dist/collection/components/data-display/data-table/internals/render-table-body.js +15 -3
- package/dist/collection/components/data-display/data-table/internals/render-table-head.js +1 -1
- package/dist/collection/components/data-display/data-table/internals/table-model.js +9 -1
- package/dist/collection/components/data-display/data-table/test/row-gutter.cmp.test.js +104 -0
- package/dist/collection/components/data-display/data-table/test/two-line-rows.cmp.test.js +164 -0
- package/dist/collection/components/data-display/map/internals/marker-presentation.js +51 -2
- package/dist/collection/components/data-display/map/internals/markers.js +16 -1
- package/dist/collection/components/data-display/map/map.css +31 -0
- package/dist/collection/components/data-display/map/map.js +96 -15
- package/dist/collection/components/data-display/map/map.types.js +1 -1
- package/dist/collection/components/data-display/map/test/map.cmp.test.js +187 -0
- package/dist/collection/components/data-display/pagination/pagination.js +1 -1
- package/dist/collection/components/data-display/syntax-box/internals/value-sync.js +6 -23
- package/dist/collection/components/data-display/syntax-box/internals/value-sync.unit.test.js +25 -0
- package/dist/collection/components/data-display/syntax-box/syntax-box.css +7 -0
- package/dist/collection/components/data-display/syntax-box/syntax-box.js +78 -23
- package/dist/collection/components/data-display/syntax-box/test/format-fixtures.js +20 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-box.cmp.test.js +241 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-fixtures.js +14 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-format.cmp.test.js +157 -0
- package/dist/collection/components/indicators/step-diagram/step-diagram.js +2 -2
- package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.js +1 -1
- package/dist/collection/components/inputs/dropdown/dropdown.js +64 -10
- package/dist/collection/components/inputs/form/form.js +203 -100
- package/dist/collection/components/inputs/form/internals/controls.js +121 -27
- package/dist/collection/components/inputs/form/internals/enter-behavior.js +14 -25
- package/dist/collection/components/inputs/form/internals/field-state.js +129 -0
- package/dist/collection/components/inputs/form/internals/reset.js +50 -0
- package/dist/collection/components/inputs/form/internals/submission.js +140 -0
- package/dist/collection/components/inputs/form/internals/values.js +176 -153
- package/dist/collection/components/inputs/form/internals/values.unit.test.js +59 -0
- package/dist/collection/components/inputs/form/test/form-reset-state.cmp.test.js +559 -0
- package/dist/collection/components/inputs/form/test/form-submit-transport.cmp.test.js +352 -0
- package/dist/collection/components/inputs/form/test/form-submit.cmp.test.js +438 -0
- package/dist/collection/components/inputs/form/test/form-values.cmp.test.js +440 -0
- package/dist/collection/components/inputs/input/input.js +91 -20
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.js +4 -4
- package/dist/collection/components/inputs/radio-group/radio-group.js +51 -9
- package/dist/collection/components/inputs/textarea/textarea.js +70 -18
- package/dist/collection/components/inputs/toggle/toggle.js +57 -10
- package/dist/collection/components/layout/grid/grid.js +1 -1
- package/dist/collection/components/layout/inline/inline.js +1 -1
- package/dist/collection/components/layout/navbar/navbar.js +2 -2
- package/dist/collection/components/layout/panel/panel.js +4 -4
- package/dist/collection/components/layout/scrollable/scrollable.js +3 -3
- package/dist/collection/components/layout/section/section.js +1 -1
- package/dist/collection/components/layout/sidepanel/internals/drawer.js +42 -4
- package/dist/collection/components/layout/sidepanel/sidepanel.css +145 -14
- package/dist/collection/components/layout/sidepanel/sidepanel.js +99 -10
- package/dist/collection/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.js +120 -0
- package/dist/collection/components/layout/sidepanel/test/panel-transitions.cmp.test.js +180 -0
- package/dist/collection/components/layout/stack/stack.js +1 -1
- package/dist/collection/components/layout/tabs/tabs.js +1 -1
- package/dist/collection/components/layout/toolbar/toolbar.js +2 -2
- package/dist/collection/components/media/avatar/avatar.js +1 -1
- package/dist/collection/components/media/icon/internals/fetch-icon.js +33 -4
- package/dist/collection/components/media/icon/internals/fetch-icon.unit.test.js +51 -0
- package/dist/collection/components/media/icon/internals/policy.js +184 -0
- package/dist/collection/components/media/icon/internals/policy.unit.test.js +65 -0
- package/dist/collection/components/media/icon/internals/registry-lucide.unit.test.js +78 -0
- package/dist/collection/components/media/icon/internals/registry.js +33 -82
- package/dist/collection/components/media/icon/internals/sanitize-svg.js +80 -57
- package/dist/collection/components/media/icon/internals/url.js +31 -27
- package/dist/collection/components/media/icon/internals/url.unit.test.js +34 -0
- package/dist/collection/components/media/icon/test/icon-fixtures.js +47 -0
- package/dist/collection/components/media/icon/test/icon.cmp.test.js +223 -0
- package/dist/collection/components/media/image-comparison/image-comparison.css +124 -0
- package/dist/collection/components/media/image-comparison/image-comparison.js +468 -0
- package/dist/collection/components/media/image-comparison/test/image-comparison.cmp.test.js +234 -0
- package/dist/collection/components/media/media/media.js +22 -22
- package/dist/collection/components/media/reel/reel.js +2 -2
- package/dist/collection/components/media/thumbnail/thumbnail.js +2 -2
- package/dist/collection/components/overlays/dialog/dialog.js +2 -2
- package/dist/collection/components/overlays/tooltip/internals/positioning.js +20 -5
- package/dist/collection/components/overlays/tooltip/tooltip.css +5 -1
- package/dist/collection/components/overlays/tooltip/tooltip.js +9 -3
- package/dist/collection/index.js +2 -1
- package/dist/collection/playground/assets/comparison-after.svg +1 -0
- package/dist/collection/playground/assets/comparison-before.svg +1 -0
- package/dist/collection/playground/playground.bundled.js +16 -7
- package/dist/collection/theme/test/foundation.cmp.test.js +6 -0
- package/dist/collection/theme/tokens.js +12 -3
- package/dist/collection/utils/form-field-adapter.js +44 -0
- package/dist/collection/utils/form-field-state.js +45 -0
- package/dist/collection/utils/form-reset-action.js +60 -0
- package/dist/collection/utils/form-submit-action.js +151 -0
- package/dist/collection/utils/form-submit-action.unit.test.js +15 -0
- package/dist/collection/utils/formatter.js +137 -158
- package/dist/collection/utils/formatter.unit.test.js +69 -51
- package/dist/collection/utils/image-crop.js +47 -0
- package/dist/collection/utils/image-crop.unit.test.js +57 -0
- package/dist/collection/utils/syntax.js +210 -81
- package/dist/collection/utils/syntax.unit.test.js +134 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-CtUn83Rs.js → p-6PPZ2sIO.js} +1 -1
- package/dist/{webquark/p-CyPFM3XV.js → components/p-B4Mg1xEw.js} +1 -1
- package/dist/components/{p-BeFSyZjp.js → p-BH4gQWub.js} +1 -1
- package/dist/components/p-BOdNg0jc.js +1 -0
- package/dist/components/p-BcL0NVv0.js +1 -0
- package/dist/{playground/build/p-CGcC-mvi.js → components/p-BofcK-7Z.js} +1 -1
- package/dist/components/p-C6vxokHH.js +1 -0
- package/dist/components/p-CGml_DQ8.js +1 -0
- package/dist/components/{p-CuJIyOwp.js → p-CKuPOxKN.js} +1 -1
- package/dist/components/p-CN1ut2Lb.js +1 -0
- package/dist/components/p-C_RztzNv.js +5 -0
- package/dist/components/p-CoIMrUb3.js +1 -0
- package/dist/components/{p-g9vOVxQ4.js → p-DKrPmn2y.js} +2 -2
- package/dist/components/p-DT6k8Yhx.js +1 -0
- package/dist/components/p-Dfp_If-_.js +1 -0
- package/dist/components/p-DstNl_WY.js +1 -0
- package/dist/components/p-GHhpSfZU.js +1 -0
- package/dist/components/p-SzKf4WZF.js +1 -0
- package/dist/components/p-ye27qtRo.js +1 -0
- package/dist/components/q-accordion.js +1 -1
- package/dist/components/q-alert.js +1 -1
- package/dist/components/q-avatar.js +1 -1
- package/dist/components/q-banner.js +1 -1
- package/dist/components/q-button.js +1 -1
- package/dist/components/q-card.js +1 -1
- package/dist/components/q-carousel.js +1 -1
- package/dist/components/q-chip.js +1 -1
- package/dist/components/q-conversation-bubble.js +1 -1
- package/dist/components/q-data-table.js +1 -1
- package/dist/components/q-dialog.js +1 -1
- package/dist/components/q-dropdown.js +1 -1
- package/dist/components/q-form.js +1 -1
- package/dist/components/q-grid.js +1 -1
- package/dist/components/q-icon.js +1 -1
- package/dist/components/q-image-comparison.d.ts +11 -0
- package/dist/components/q-image-comparison.js +1 -0
- package/dist/components/q-inline.js +1 -1
- package/dist/components/q-input.js +1 -1
- package/dist/components/q-link.js +1 -1
- package/dist/components/q-map.js +1 -1
- package/dist/components/q-media.js +1 -1
- package/dist/components/q-navbar.js +1 -1
- package/dist/components/q-pagination.js +1 -1
- package/dist/components/q-panel.js +1 -1
- package/dist/components/q-progress.js +1 -1
- package/dist/components/q-quantity-selector.js +1 -1
- package/dist/components/q-radio-group.js +1 -1
- package/dist/components/q-reel.js +1 -1
- package/dist/components/q-scrollable.js +1 -1
- package/dist/components/q-section.js +1 -1
- package/dist/components/q-sidepanel.js +5 -5
- package/dist/components/q-stack.js +1 -1
- package/dist/components/q-step-diagram-item.js +1 -1
- package/dist/components/q-step-diagram.js +1 -1
- package/dist/components/q-syntax-box.js +5 -5
- package/dist/components/q-tabs.js +1 -1
- package/dist/components/q-textarea.js +1 -1
- package/dist/components/q-thumbnail.js +1 -1
- package/dist/components/q-toast.js +1 -1
- package/dist/components/q-toggle.js +1 -1
- package/dist/components/q-toolbar.js +1 -1
- package/dist/components/q-tooltip.js +1 -1
- package/dist/esm/{action.props-BypnAgOy.js → action.props-CpnGza8z.js} +1 -1
- package/dist/esm/{chevron-up-g9vOVxQ4.js → chevron-up-DKrPmn2y.js} +2 -2
- package/dist/esm/{data-table-cell-DmqVhVoj.js → data-table-cell-SzKf4WZF.js} +5 -1
- package/dist/esm/{field-dFy4PXKT.js → field-zfD6OQ02.js} +1 -1
- package/dist/esm/form-field-adapter-CGml_DQ8.js +46 -0
- package/dist/esm/form-field-state-DstNl_WY.js +47 -0
- package/dist/esm/form-submit-action-CoEIvDqE.js +213 -0
- package/dist/esm/image-crop-BcL0NVv0.js +49 -0
- package/dist/esm/{index-tSny_c7b.js → index-B5ElFlHv.js} +25 -26
- package/dist/esm/index.js +4 -3
- package/dist/esm/leaflet-maplibre-gl-BvKlNmWf.js +1020 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{map.types-WJHaLJS_.js → map.types-CoIMrUb3.js} +1 -1
- package/dist/esm/q-accordion.entry.js +2 -2
- package/dist/esm/q-alert.entry.js +1 -1
- package/dist/esm/q-avatar.entry.js +2 -2
- package/dist/esm/q-banner.entry.js +1 -1
- package/dist/esm/q-button_2.entry.js +111 -24
- package/dist/esm/q-card.entry.js +2 -2
- package/dist/esm/q-carousel.entry.js +400 -13
- package/dist/esm/q-chip.entry.js +2 -2
- package/dist/esm/q-conversation-bubble.entry.js +1 -1
- package/dist/esm/q-data-table.entry.js +73 -11
- package/dist/esm/q-dialog.entry.js +3 -3
- package/dist/esm/q-dropdown.entry.js +64 -11
- package/dist/esm/q-form.entry.js +774 -287
- package/dist/esm/q-grid.entry.js +3 -3
- package/dist/esm/q-icon.entry.js +143 -89
- package/dist/esm/q-image-comparison.entry.js +199 -0
- package/dist/esm/q-inline.entry.js +3 -3
- package/dist/esm/q-input_2.entry.js +90 -22
- package/dist/esm/q-link.entry.js +2 -2
- package/dist/esm/q-map.entry.js +119 -22
- package/dist/esm/q-media.entry.js +3 -3
- package/dist/esm/q-navbar.entry.js +3 -3
- package/dist/esm/q-pagination.entry.js +2 -2
- package/dist/esm/q-panel.entry.js +6 -6
- package/dist/esm/q-quantity-selector.entry.js +5 -5
- package/dist/esm/q-radio-group.entry.js +48 -11
- package/dist/esm/q-reel.entry.js +3 -3
- package/dist/esm/q-scrollable.entry.js +4 -4
- package/dist/esm/q-section.entry.js +2 -2
- package/dist/esm/q-sidepanel.entry.js +146 -26
- package/dist/esm/q-stack.entry.js +3 -3
- package/dist/esm/q-step-diagram-item.entry.js +2 -2
- package/dist/esm/q-step-diagram.entry.js +3 -3
- package/dist/esm/q-syntax-box.entry.js +418 -301
- package/dist/esm/q-tabs.entry.js +2 -2
- package/dist/esm/q-textarea.entry.js +66 -21
- package/dist/esm/q-thumbnail.entry.js +3 -3
- package/dist/esm/q-toast.entry.js +1 -1
- package/dist/esm/q-toggle.entry.js +58 -12
- package/dist/esm/q-toolbar.entry.js +4 -4
- package/dist/esm/registry-GHhpSfZU.js +308 -0
- package/dist/esm/{tokens-CyPFM3XV.js → tokens-B4Mg1xEw.js} +12 -3
- package/dist/esm/webquark.js +4 -4
- package/dist/playground/assets/comparison-after.svg +1 -0
- package/dist/playground/assets/comparison-before.svg +1 -0
- package/dist/playground/assets/icons/check-preview.png +0 -0
- package/dist/playground/assets/icons/spinner.svg +1 -1
- package/dist/playground/build/index.esm.js +1 -1
- package/dist/playground/build/{p-781d3459.entry.js → p-023f8437.entry.js} +1 -1
- package/dist/playground/build/{p-ca240b8b.entry.js → p-030ecde3.entry.js} +1 -1
- package/dist/playground/build/p-04c8cb9e.entry.js +1 -0
- package/dist/playground/build/{p-81f64d6f.entry.js → p-059daa8a.entry.js} +1 -1
- package/dist/playground/build/{p-964d27e0.entry.js → p-09cca7b9.entry.js} +1 -1
- package/dist/playground/build/p-0aa74ad6.entry.js +1 -0
- package/dist/playground/build/p-0ae43d6c.entry.js +1 -0
- package/dist/playground/build/p-0c3aac3f.entry.js +1 -0
- package/dist/playground/build/p-144ef339.entry.js +1 -0
- package/dist/playground/build/p-1d1f7bc3.entry.js +1 -0
- package/dist/playground/build/p-296fbdb1.entry.js +1 -0
- package/dist/playground/build/p-36118d90.entry.js +1 -0
- package/dist/playground/build/{p-82810ead.entry.js → p-3bc4629c.entry.js} +1 -1
- package/dist/playground/build/{p-25c3b776.entry.js → p-48fb5228.entry.js} +1 -1
- package/dist/playground/build/{p-b4dfadea.entry.js → p-4d61b70d.entry.js} +1 -1
- package/dist/playground/build/p-5f232b44.entry.js +13 -0
- package/dist/playground/build/{p-b9e83fa3.entry.js → p-64096386.entry.js} +1 -1
- package/dist/playground/build/{p-e6603d17.entry.js → p-6bfffa79.entry.js} +1 -1
- package/dist/{webquark/p-fed7219c.entry.js → playground/build/p-6e28cfe2.entry.js} +1 -1
- package/dist/playground/build/{p-e1c8a9aa.entry.js → p-70d9ffde.entry.js} +1 -1
- package/dist/{webquark/p-d0c55860.entry.js → playground/build/p-8ece2c62.entry.js} +1 -1
- package/dist/playground/build/p-90b0858c.entry.js +1 -0
- package/dist/playground/build/p-91fff6b6.entry.js +1 -0
- package/dist/playground/build/p-923dac41.entry.js +1 -0
- package/dist/playground/build/p-97a89cae.entry.js +1 -0
- package/dist/playground/build/{p-362c5608.entry.js → p-99d785ca.entry.js} +1 -1
- package/dist/playground/build/{p-5453eac7.entry.js → p-9e78b796.entry.js} +1 -1
- package/dist/playground/build/{p-b08d0ed8.entry.js → p-9ff7e5a4.entry.js} +1 -1
- package/dist/{components/p-CyPFM3XV.js → playground/build/p-B4Mg1xEw.js} +1 -1
- package/dist/playground/build/p-B5ElFlHv.js +3 -0
- package/dist/playground/build/p-BOdNg0jc.js +1 -0
- package/dist/playground/build/p-BcL0NVv0.js +1 -0
- package/dist/playground/build/p-CGml_DQ8.js +1 -0
- package/dist/playground/build/p-C_RztzNv.js +5 -0
- package/dist/playground/build/p-CoIMrUb3.js +1 -0
- package/dist/{webquark/p-g9vOVxQ4.js → playground/build/p-DKrPmn2y.js} +2 -2
- package/dist/playground/build/p-DWO-pleQ.js +1 -0
- package/dist/{components/p-COMoSatC.js → playground/build/p-Dhsn99q4.js} +1 -1
- package/dist/playground/build/p-DstNl_WY.js +1 -0
- package/dist/playground/build/p-GHhpSfZU.js +1 -0
- package/dist/playground/build/p-SzKf4WZF.js +1 -0
- package/dist/playground/build/p-c523ec6f.entry.js +1 -0
- package/dist/playground/build/p-d0253d64.entry.js +1 -0
- package/dist/playground/build/p-d0fbd2b1.entry.js +1 -0
- package/dist/{webquark/p-9b4271ea.entry.js → playground/build/p-dd115868.entry.js} +1 -1
- package/dist/playground/build/{p-5eeb922e.entry.js → p-f1bac94c.entry.js} +1 -1
- package/dist/playground/build/{p-17011e71.entry.js → p-f4f97e74.entry.js} +1 -1
- package/dist/playground/build/p-f63b7214.entry.js +1 -0
- package/dist/{webquark/p-9227780b.entry.js → playground/build/p-f98f9439.entry.js} +1 -1
- package/dist/playground/build/{p-ae4e5ec4.entry.js → p-f9ad63ff.entry.js} +1 -1
- package/dist/playground/build/p-fe200f68.entry.js +1 -0
- package/dist/playground/build/p-fe8c634a.entry.js +13 -0
- package/dist/{webquark/p-151a555e.entry.js → playground/build/p-fec6fe0a.entry.js} +1 -1
- package/dist/playground/build/webquark.css +1 -1
- package/dist/playground/build/webquark.esm.js +1 -1
- package/dist/playground/playground/components.manifest.json +1 -0
- package/dist/playground/playground/specs/q-carousel.sandbox.json +15 -0
- package/dist/playground/playground/specs/q-data-table.sandbox.json +24 -0
- package/dist/playground/playground/specs/q-icon.sandbox.json +17 -1
- package/dist/playground/playground/specs/q-image-comparison.sandbox.json +24 -0
- package/dist/playground/playground/specs/q-syntax-box.sandbox.json +68 -24
- package/dist/playground/playground.js +16 -7
- package/dist/types/components/actions/button/button.d.ts +26 -0
- package/dist/types/components/actions/button/test/button-slots.cmp.test.d.ts +1 -0
- package/dist/types/components/content/carousel/carousel.d.ts +71 -4
- package/dist/types/components/content/carousel/carousel.types.d.ts +5 -0
- package/dist/types/components/content/carousel/internals/autoplay.d.ts +22 -0
- package/dist/types/components/content/carousel/internals/slide-state.d.ts +8 -0
- package/dist/types/components/content/carousel/test/transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/data-table/data-table-cell.d.ts +2 -0
- package/dist/types/components/data-display/data-table/data-table.d.ts +18 -1
- package/dist/types/components/data-display/data-table/data-table.types.d.ts +3 -0
- package/dist/types/components/data-display/data-table/internals/render-table-body.d.ts +1 -0
- package/dist/types/components/data-display/data-table/internals/table-model.d.ts +5 -1
- package/dist/types/components/data-display/data-table/test/row-gutter.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/data-table/test/two-line-rows.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/map/map.d.ts +7 -3
- package/dist/types/components/data-display/map/map.types.d.ts +11 -1
- package/dist/types/components/data-display/syntax-box/internals/value-sync.d.ts +1 -4
- package/dist/types/components/data-display/syntax-box/internals/value-sync.unit.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/syntax-box.d.ts +9 -3
- package/dist/types/components/data-display/syntax-box/test/format-fixtures.d.ts +6 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-box.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-fixtures.d.ts +9 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-format.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/dropdown/dropdown.d.ts +5 -0
- package/dist/types/components/inputs/form/form.d.ts +12 -7
- package/dist/types/components/inputs/form/form.types.d.ts +2 -0
- package/dist/types/components/inputs/form/internals/controls.d.ts +3 -0
- package/dist/types/components/inputs/form/internals/field-state.d.ts +19 -0
- package/dist/types/components/inputs/form/internals/reset.d.ts +3 -0
- package/dist/types/components/inputs/form/internals/submission.d.ts +17 -0
- package/dist/types/components/inputs/form/internals/values.d.ts +6 -1
- package/dist/types/components/inputs/form/internals/values.unit.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-reset-state.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-submit-transport.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-submit.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-values.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/input/input.d.ts +7 -1
- package/dist/types/components/inputs/radio-group/radio-group.d.ts +4 -0
- package/dist/types/components/inputs/textarea/textarea.d.ts +6 -1
- package/dist/types/components/inputs/toggle/toggle.d.ts +5 -0
- package/dist/types/components/layout/sidepanel/sidepanel.d.ts +9 -0
- package/dist/types/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/layout/sidepanel/test/panel-transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/fetch-icon.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/policy.d.ts +19 -0
- package/dist/types/components/media/icon/internals/policy.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/registry-lucide.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/sanitize-svg.d.ts +1 -1
- package/dist/types/components/media/icon/internals/url.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/test/icon-fixtures.d.ts +4 -0
- package/dist/types/components/media/icon/test/icon.cmp.test.d.ts +1 -0
- package/dist/types/components/media/image-comparison/image-comparison.d.ts +63 -0
- package/dist/types/components/media/image-comparison/test/image-comparison.cmp.test.d.ts +1 -0
- package/dist/types/components/media/media/media.d.ts +1 -1
- package/dist/types/components/overlays/tooltip/internals/positioning.d.ts +1 -1
- package/dist/types/components/overlays/tooltip/tooltip.d.ts +5 -0
- package/dist/types/components.d.ts +436 -23
- package/dist/types/index.d.ts +6 -3
- package/dist/types/utils/form-field-adapter.d.ts +17 -0
- package/dist/types/utils/form-field-state.d.ts +4 -0
- package/dist/types/utils/form-reset-action.d.ts +5 -0
- package/dist/types/utils/form-submit-action.d.ts +17 -0
- package/dist/types/utils/form-submit-action.unit.test.d.ts +1 -0
- package/dist/types/utils/formatter.d.ts +10 -19
- package/dist/types/utils/image-crop.d.ts +30 -0
- package/dist/types/utils/image-crop.unit.test.d.ts +1 -0
- package/dist/types/utils/syntax.d.ts +11 -7
- package/dist/types/utils/syntax.unit.test.d.ts +1 -0
- package/dist/webquark/index.esm.js +1 -1
- package/dist/webquark/{p-781d3459.entry.js → p-023f8437.entry.js} +1 -1
- package/dist/webquark/{p-ca240b8b.entry.js → p-030ecde3.entry.js} +1 -1
- package/dist/webquark/p-04c8cb9e.entry.js +1 -0
- package/dist/webquark/{p-81f64d6f.entry.js → p-059daa8a.entry.js} +1 -1
- package/dist/webquark/{p-964d27e0.entry.js → p-09cca7b9.entry.js} +1 -1
- package/dist/webquark/p-0aa74ad6.entry.js +1 -0
- package/dist/webquark/p-0ae43d6c.entry.js +1 -0
- package/dist/webquark/p-0c3aac3f.entry.js +1 -0
- package/dist/webquark/p-144ef339.entry.js +1 -0
- package/dist/webquark/p-1d1f7bc3.entry.js +1 -0
- package/dist/webquark/p-296fbdb1.entry.js +1 -0
- package/dist/webquark/p-36118d90.entry.js +1 -0
- package/dist/webquark/{p-82810ead.entry.js → p-3bc4629c.entry.js} +1 -1
- package/dist/webquark/{p-25c3b776.entry.js → p-48fb5228.entry.js} +1 -1
- package/dist/webquark/{p-b4dfadea.entry.js → p-4d61b70d.entry.js} +1 -1
- package/dist/webquark/p-5f232b44.entry.js +13 -0
- package/dist/webquark/{p-b9e83fa3.entry.js → p-64096386.entry.js} +1 -1
- package/dist/webquark/{p-e6603d17.entry.js → p-6bfffa79.entry.js} +1 -1
- package/dist/{playground/build/p-fed7219c.entry.js → webquark/p-6e28cfe2.entry.js} +1 -1
- package/dist/webquark/{p-e1c8a9aa.entry.js → p-70d9ffde.entry.js} +1 -1
- package/dist/{playground/build/p-d0c55860.entry.js → webquark/p-8ece2c62.entry.js} +1 -1
- package/dist/webquark/p-90b0858c.entry.js +1 -0
- package/dist/webquark/p-91fff6b6.entry.js +1 -0
- package/dist/webquark/p-923dac41.entry.js +1 -0
- package/dist/webquark/p-97a89cae.entry.js +1 -0
- package/dist/webquark/{p-362c5608.entry.js → p-99d785ca.entry.js} +1 -1
- package/dist/webquark/{p-5453eac7.entry.js → p-9e78b796.entry.js} +1 -1
- package/dist/webquark/{p-b08d0ed8.entry.js → p-9ff7e5a4.entry.js} +1 -1
- package/dist/{playground/build/p-CyPFM3XV.js → webquark/p-B4Mg1xEw.js} +1 -1
- package/dist/webquark/p-B5ElFlHv.js +3 -0
- package/dist/webquark/p-BOdNg0jc.js +1 -0
- package/dist/webquark/p-BcL0NVv0.js +1 -0
- package/dist/webquark/p-CGml_DQ8.js +1 -0
- package/dist/webquark/p-C_RztzNv.js +5 -0
- package/dist/webquark/p-CoIMrUb3.js +1 -0
- package/dist/{playground/build/p-g9vOVxQ4.js → webquark/p-DKrPmn2y.js} +2 -2
- package/dist/webquark/p-DWO-pleQ.js +1 -0
- package/dist/webquark/{p-CGcC-mvi.js → p-Dhsn99q4.js} +1 -1
- package/dist/webquark/p-DstNl_WY.js +1 -0
- package/dist/webquark/p-GHhpSfZU.js +1 -0
- package/dist/webquark/p-SzKf4WZF.js +1 -0
- package/dist/webquark/p-c523ec6f.entry.js +1 -0
- package/dist/webquark/p-d0253d64.entry.js +1 -0
- package/dist/webquark/p-d0fbd2b1.entry.js +1 -0
- package/dist/{playground/build/p-9b4271ea.entry.js → webquark/p-dd115868.entry.js} +1 -1
- package/dist/webquark/{p-5eeb922e.entry.js → p-f1bac94c.entry.js} +1 -1
- package/dist/webquark/{p-17011e71.entry.js → p-f4f97e74.entry.js} +1 -1
- package/dist/webquark/p-f63b7214.entry.js +1 -0
- package/dist/{playground/build/p-9227780b.entry.js → webquark/p-f98f9439.entry.js} +1 -1
- package/dist/webquark/{p-ae4e5ec4.entry.js → p-f9ad63ff.entry.js} +1 -1
- package/dist/webquark/p-fe200f68.entry.js +1 -0
- package/dist/webquark/p-fe8c634a.entry.js +13 -0
- package/dist/{playground/build/p-151a555e.entry.js → webquark/p-fec6fe0a.entry.js} +1 -1
- package/dist/webquark/webquark.css +1 -1
- package/dist/webquark/webquark.esm.js +1 -1
- package/package.json +16 -19
- package/scripts/webquark-serve.js +9 -7
- package/scripts/wq-switch/README.md +113 -109
- package/scripts/wq-switch/dist/index.js +106 -82
- package/scripts/wq-switch/dist/setup.js +80 -60
- package/dist/cjs/leaflet-maplibre-gl-BJKExsns.js +0 -1031
- package/dist/cjs/registry-BhkCNgxt.js +0 -179
- package/dist/components/p-2_cpBb8_.js +0 -1
- package/dist/components/p-BfZVatS6.js +0 -1
- package/dist/components/p-BvBRW3dl.js +0 -1
- package/dist/components/p-CFuqfXuv.js +0 -9
- package/dist/components/p-Cn_ChUpc.js +0 -1
- package/dist/components/p-DmqVhVoj.js +0 -1
- package/dist/components/p-DwnH6_NQ.js +0 -1
- package/dist/components/p-WJHaLJS_.js +0 -1
- package/dist/components/p-_X1v1o3K.js +0 -1
- package/dist/esm/leaflet-maplibre-gl-BVDAAs7w.js +0 -1026
- package/dist/esm/registry-BvBRW3dl.js +0 -173
- package/dist/playground/build/p-04799ed0.entry.js +0 -1
- package/dist/playground/build/p-0610d5b2.entry.js +0 -1
- package/dist/playground/build/p-160cb4e4.entry.js +0 -1
- package/dist/playground/build/p-1cf51c80.entry.js +0 -1
- package/dist/playground/build/p-3d674223.entry.js +0 -1
- package/dist/playground/build/p-4fff116c.entry.js +0 -1
- package/dist/playground/build/p-675d0d03.entry.js +0 -13
- package/dist/playground/build/p-70c4f92f.entry.js +0 -1
- package/dist/playground/build/p-72dc1231.entry.js +0 -1
- package/dist/playground/build/p-736b1c8c.entry.js +0 -1
- package/dist/playground/build/p-96922229.entry.js +0 -1
- package/dist/playground/build/p-BLvl8YLq.js +0 -1
- package/dist/playground/build/p-BvBRW3dl.js +0 -1
- package/dist/playground/build/p-CFuqfXuv.js +0 -9
- package/dist/playground/build/p-DmqVhVoj.js +0 -1
- package/dist/playground/build/p-WJHaLJS_.js +0 -1
- package/dist/playground/build/p-b7ac65c6.entry.js +0 -1
- package/dist/playground/build/p-bba3c7b4.entry.js +0 -1
- package/dist/playground/build/p-bf47c46a.entry.js +0 -13
- package/dist/playground/build/p-c448b4ce.entry.js +0 -1
- package/dist/playground/build/p-cb5ebd01.entry.js +0 -1
- package/dist/playground/build/p-e762a4b7.entry.js +0 -1
- package/dist/playground/build/p-fb76473e.entry.js +0 -1
- package/dist/playground/build/p-tSny_c7b.js +0 -3
- package/dist/webquark/p-04799ed0.entry.js +0 -1
- package/dist/webquark/p-0610d5b2.entry.js +0 -1
- package/dist/webquark/p-160cb4e4.entry.js +0 -1
- package/dist/webquark/p-1cf51c80.entry.js +0 -1
- package/dist/webquark/p-3d674223.entry.js +0 -1
- package/dist/webquark/p-4fff116c.entry.js +0 -1
- package/dist/webquark/p-675d0d03.entry.js +0 -13
- package/dist/webquark/p-70c4f92f.entry.js +0 -1
- package/dist/webquark/p-72dc1231.entry.js +0 -1
- package/dist/webquark/p-736b1c8c.entry.js +0 -1
- package/dist/webquark/p-96922229.entry.js +0 -1
- package/dist/webquark/p-BLvl8YLq.js +0 -1
- package/dist/webquark/p-BvBRW3dl.js +0 -1
- package/dist/webquark/p-CFuqfXuv.js +0 -9
- package/dist/webquark/p-DmqVhVoj.js +0 -1
- package/dist/webquark/p-WJHaLJS_.js +0 -1
- package/dist/webquark/p-b7ac65c6.entry.js +0 -1
- package/dist/webquark/p-bba3c7b4.entry.js +0 -1
- package/dist/webquark/p-bf47c46a.entry.js +0 -13
- package/dist/webquark/p-c448b4ce.entry.js +0 -1
- package/dist/webquark/p-cb5ebd01.entry.js +0 -1
- package/dist/webquark/p-e762a4b7.entry.js +0 -1
- package/dist/webquark/p-fb76473e.entry.js +0 -1
- package/dist/webquark/p-tSny_c7b.js +0 -3
|
@@ -1,24 +1,121 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var tokens = require('./tokens-
|
|
3
|
+
var index = require('./index-DWXhKHCB.js');
|
|
4
|
+
var tokens = require('./tokens-RMRaIOqv.js');
|
|
5
|
+
var formFieldAdapter = require('./form-field-adapter-D0CJ6poh.js');
|
|
6
|
+
var formFieldState = require('./form-field-state-P63wN30v.js');
|
|
7
|
+
var formSubmitAction = require('./form-submit-action-C6c4aq6C.js');
|
|
5
8
|
|
|
6
9
|
const skippedInputTypes = new Set(['button', 'checkbox', 'color', 'file', 'hidden', 'image', 'radio', 'range', 'reset', 'submit']);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
const customFieldTags = new Set(['q-input', 'q-textarea', 'q-dropdown', 'q-radio-group', 'q-toggle', 'q-syntax-box']);
|
|
11
|
+
const actionInputTypes = new Set(['button', 'image', 'reset', 'submit']);
|
|
12
|
+
function supported(element) {
|
|
13
|
+
const tag = element.tagName.toLowerCase();
|
|
14
|
+
if (tag === 'input')
|
|
15
|
+
return !actionInputTypes.has(element.type);
|
|
16
|
+
return tag === 'textarea' || tag === 'select' || customFieldTags.has(tag);
|
|
17
|
+
}
|
|
18
|
+
function nearestForm(control) {
|
|
19
|
+
for (let parent = control.parentElement; parent; parent = parent.parentElement) {
|
|
20
|
+
if (parent.tagName === 'FORM' || parent.tagName === 'Q-FORM')
|
|
21
|
+
return parent;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Named form controls can shadow form.elements; use the native getter. */
|
|
26
|
+
function nativeMembers(formEl) {
|
|
27
|
+
if (!formEl)
|
|
28
|
+
return [];
|
|
29
|
+
const prototype = formEl.ownerDocument.defaultView?.HTMLFormElement?.prototype;
|
|
30
|
+
const getter = prototype && Object.getOwnPropertyDescriptor(prototype, 'elements')?.get;
|
|
31
|
+
const elements = getter ? getter.call(formEl) : formEl.elements;
|
|
32
|
+
return elements ? Array.from(elements) : [];
|
|
33
|
+
}
|
|
34
|
+
function candidates(formEl, hostEl) {
|
|
35
|
+
const found = new Set();
|
|
36
|
+
hostEl.querySelectorAll('*').forEach(element => {
|
|
37
|
+
if (supported(element))
|
|
38
|
+
found.add(element);
|
|
39
|
+
});
|
|
40
|
+
nativeMembers(formEl).forEach(element => {
|
|
41
|
+
if (supported(element))
|
|
42
|
+
found.add(element);
|
|
43
|
+
});
|
|
44
|
+
return Array.from(found).sort((left, right) => {
|
|
45
|
+
const position = left.compareDocumentPosition(right);
|
|
46
|
+
if (position & Node.DOCUMENT_POSITION_DISCONNECTED)
|
|
47
|
+
return 0;
|
|
48
|
+
return position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : position & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
20
49
|
});
|
|
21
|
-
|
|
50
|
+
}
|
|
51
|
+
function owned(control, formEl, hostEl) {
|
|
52
|
+
const custom = formFieldAdapter.readFormField(control);
|
|
53
|
+
if (customFieldTags.has(control.tagName.toLowerCase()) && !custom)
|
|
54
|
+
return false;
|
|
55
|
+
const owner = custom ? custom.owner() : control.form;
|
|
56
|
+
if (owner)
|
|
57
|
+
return owner === formEl;
|
|
58
|
+
if (control.hasAttribute('form'))
|
|
59
|
+
return false;
|
|
60
|
+
return nearestForm(control) === hostEl;
|
|
61
|
+
}
|
|
62
|
+
/** Light DOM and actual native association only; never inspect consumer shadow roots. */
|
|
63
|
+
function getFormControls(formEl, hostEl) {
|
|
64
|
+
return candidates(formEl, hostEl).filter(control => owned(control, formEl, hostEl));
|
|
65
|
+
}
|
|
66
|
+
async function awaitFormControls(formEl, hostEl, signal) {
|
|
67
|
+
const deadline = Date.now() + formFieldAdapter.FORM_FIELD_READY_TIMEOUT_MS;
|
|
68
|
+
const possiblyOwned = (control) => {
|
|
69
|
+
if (formFieldAdapter.readFormField(control))
|
|
70
|
+
return owned(control, formEl, hostEl);
|
|
71
|
+
if (nativeMembers(formEl).includes(control))
|
|
72
|
+
return true;
|
|
73
|
+
return !control.hasAttribute('form') && nearestForm(control) === hostEl;
|
|
74
|
+
};
|
|
75
|
+
while (true) {
|
|
76
|
+
if (signal?.aborted)
|
|
77
|
+
return;
|
|
78
|
+
const pending = candidates(formEl, hostEl).filter(control => control.isConnected && customFieldTags.has(control.tagName.toLowerCase()) &&
|
|
79
|
+
possiblyOwned(control) && !formFieldAdapter.readFormField(control));
|
|
80
|
+
if (!pending.length)
|
|
81
|
+
return;
|
|
82
|
+
const remaining = deadline - Date.now();
|
|
83
|
+
if (remaining <= 0) {
|
|
84
|
+
const error = new Error(`Form fields did not become ready within ${formFieldAdapter.FORM_FIELD_READY_TIMEOUT_MS}ms.`);
|
|
85
|
+
error.name = 'TimeoutError';
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
const batch = new AbortController();
|
|
89
|
+
const abort = () => batch.abort();
|
|
90
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
91
|
+
try {
|
|
92
|
+
await Promise.all(pending.map(async (control) => {
|
|
93
|
+
const canceled = new AbortController();
|
|
94
|
+
const stop = () => canceled.abort();
|
|
95
|
+
const observer = new MutationObserver(() => {
|
|
96
|
+
if (!control.isConnected || !possiblyOwned(control))
|
|
97
|
+
stop();
|
|
98
|
+
});
|
|
99
|
+
batch.signal.addEventListener('abort', stop, { once: true });
|
|
100
|
+
const roots = new Set([hostEl.getRootNode(), formEl?.getRootNode()].filter(Boolean));
|
|
101
|
+
try {
|
|
102
|
+
for (const root of roots)
|
|
103
|
+
observer.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['form', 'id'] });
|
|
104
|
+
if (!control.isConnected || !possiblyOwned(control))
|
|
105
|
+
stop();
|
|
106
|
+
await formFieldAdapter.awaitFormField(control, canceled.signal, remaining);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
observer.disconnect();
|
|
110
|
+
batch.signal.removeEventListener('abort', stop);
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
signal?.removeEventListener('abort', abort);
|
|
116
|
+
batch.abort();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
22
119
|
}
|
|
23
120
|
function shouldSkipControl(control, tagName = control.tagName.toLowerCase()) {
|
|
24
121
|
return tagName === 'q-syntax-box' && !control.editable;
|
|
@@ -35,10 +132,6 @@ function getControlFromEvent(ev, formEl, hostEl) {
|
|
|
35
132
|
if (targetControl)
|
|
36
133
|
return targetControl;
|
|
37
134
|
}
|
|
38
|
-
const activeElement = getDeepActiveElement(hostEl);
|
|
39
|
-
if (activeElement instanceof HTMLElement) {
|
|
40
|
-
return controls.find((control) => controlContainsTarget(control, activeElement));
|
|
41
|
-
}
|
|
42
135
|
return undefined;
|
|
43
136
|
}
|
|
44
137
|
function focusAdjacentControl(current, formEl, hostEl, direction) {
|
|
@@ -57,16 +150,22 @@ function focusAdjacentControl(current, formEl, hostEl, direction) {
|
|
|
57
150
|
return true;
|
|
58
151
|
}
|
|
59
152
|
function getFocusableTextControls(formEl, hostEl) {
|
|
60
|
-
return
|
|
153
|
+
return getFormControls(formEl, hostEl).filter((control) => isFocusableTextControl(control));
|
|
61
154
|
}
|
|
62
155
|
function isFocusableTextControl(control) {
|
|
63
156
|
const tagName = control.tagName.toLowerCase();
|
|
64
|
-
if (control
|
|
157
|
+
if (formFieldState.isFieldDisabled(control, Boolean(control.disabled)) || control.closest('[hidden],[inert],[aria-hidden="true"]'))
|
|
158
|
+
return false;
|
|
159
|
+
const style = control.ownerDocument.defaultView?.getComputedStyle(control);
|
|
160
|
+
if (style?.display === 'none' || style?.visibility === 'hidden' || style?.visibility === 'collapse')
|
|
161
|
+
return false;
|
|
162
|
+
// Stencil's mock DOM has no layout geometry; real browsers also exclude hidden ancestors.
|
|
163
|
+
if (typeof control.getClientRects === 'function' && !control.getClientRects().length)
|
|
65
164
|
return false;
|
|
66
165
|
if (shouldSkipControl(control, tagName))
|
|
67
166
|
return false;
|
|
68
167
|
if (tagName === 'q-input')
|
|
69
|
-
return
|
|
168
|
+
return !skippedInputTypes.has(control.type ?? 'text');
|
|
70
169
|
if (control instanceof HTMLInputElement) {
|
|
71
170
|
return !skippedInputTypes.has(control.type);
|
|
72
171
|
}
|
|
@@ -75,224 +174,542 @@ function isFocusableTextControl(control) {
|
|
|
75
174
|
function controlContainsTarget(control, target) {
|
|
76
175
|
return control === target || control.contains(target) || Boolean(control.shadowRoot?.contains(target));
|
|
77
176
|
}
|
|
78
|
-
function getDeepActiveElement(hostEl) {
|
|
79
|
-
let activeElement = hostEl.ownerDocument.activeElement;
|
|
80
|
-
while (activeElement?.shadowRoot?.activeElement) {
|
|
81
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
|
82
|
-
}
|
|
83
|
-
return activeElement;
|
|
84
|
-
}
|
|
85
177
|
|
|
86
|
-
const nativeInteractiveTags = new Set(['a', 'button', 'select', 'textarea']);
|
|
87
178
|
function handleEnterBehavior({ ev, enterBehavior, formEl, hostEl, requestSubmit }) {
|
|
88
|
-
if (ev.key !== 'Enter' ||
|
|
179
|
+
if (ev.key !== 'Enter' || ev.defaultPrevented || ev.ctrlKey || ev.altKey || ev.metaKey || ev.isComposing || ev.keyCode === 229)
|
|
89
180
|
return false;
|
|
90
|
-
if (
|
|
181
|
+
if (ev.composedPath().some(target => target instanceof HTMLElement && target !== hostEl &&
|
|
182
|
+
(target.isContentEditable || ['A', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName))))
|
|
183
|
+
return false;
|
|
184
|
+
const current = getControlFromEvent(ev, formEl, hostEl);
|
|
185
|
+
if (!current)
|
|
91
186
|
return false;
|
|
92
187
|
ev.preventDefault();
|
|
93
188
|
if (enterBehavior === 'none')
|
|
94
189
|
return true;
|
|
95
|
-
|
|
96
|
-
|
|
190
|
+
if (enterBehavior === 'focus-next' && focusAdjacentControl(current, formEl, hostEl, ev.shiftKey ? -1 : 1))
|
|
191
|
+
return true;
|
|
192
|
+
if (enterBehavior === 'focus-next' && ev.shiftKey)
|
|
97
193
|
return true;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
194
|
+
const action = formSubmitAction.defaultSubmitAction(formEl, hostEl);
|
|
195
|
+
if (action)
|
|
196
|
+
formSubmitAction.activateSubmitAction(action);
|
|
197
|
+
else
|
|
101
198
|
requestSubmit();
|
|
102
|
-
}
|
|
103
199
|
return true;
|
|
104
200
|
}
|
|
105
|
-
|
|
106
|
-
|
|
201
|
+
|
|
202
|
+
/** Radio exclusivity belongs to the native owner, tree and name, not q-form. */
|
|
203
|
+
function nativeRadioGroups(fields) {
|
|
204
|
+
const result = [];
|
|
205
|
+
for (const field of fields) {
|
|
206
|
+
const input = field.control;
|
|
207
|
+
const owner = input.form || null;
|
|
208
|
+
const root = input.getRootNode();
|
|
209
|
+
let group = result.find(candidate => candidate.owner === owner && candidate.root === root && candidate.name === field.name);
|
|
210
|
+
if (!group) {
|
|
211
|
+
group = { owner, root, name: field.name, fields: [] };
|
|
212
|
+
result.push(group);
|
|
213
|
+
}
|
|
214
|
+
group.fields.push(field);
|
|
215
|
+
}
|
|
216
|
+
return result.map(group => group.fields);
|
|
217
|
+
}
|
|
218
|
+
function effectiveDisabled(control) {
|
|
219
|
+
return Boolean(control.disabled || control.matches(':disabled'));
|
|
220
|
+
}
|
|
221
|
+
function enabledOption(option) {
|
|
222
|
+
return !option.disabled && !(option.parentElement?.tagName === 'OPTGROUP' && option.parentElement.disabled);
|
|
223
|
+
}
|
|
224
|
+
function nativeDatalistParticipation(control) {
|
|
225
|
+
if (!control.closest('datalist'))
|
|
107
226
|
return true;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
227
|
+
try {
|
|
228
|
+
const document = control.ownerDocument;
|
|
229
|
+
const form = document.createElement('form');
|
|
230
|
+
const list = document.createElement('datalist');
|
|
231
|
+
const input = document.createElement('input');
|
|
232
|
+
input.name = '_q_datalist_probe';
|
|
233
|
+
input.value = '1';
|
|
234
|
+
list.append(input);
|
|
235
|
+
form.append(list);
|
|
236
|
+
return new FormData(form).has(input.name);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
120
241
|
}
|
|
121
|
-
|
|
122
|
-
function
|
|
123
|
-
if (!formEl)
|
|
124
|
-
return new FormData();
|
|
125
|
-
let formData;
|
|
242
|
+
/** Let the browser serialize a detached native copy; never move consumer fields. */
|
|
243
|
+
function nativeTextEntries(control, fallback) {
|
|
126
244
|
try {
|
|
127
|
-
|
|
245
|
+
const form = control.ownerDocument.createElement('form');
|
|
246
|
+
const clone = control.cloneNode(false);
|
|
247
|
+
clone.removeAttribute('form');
|
|
248
|
+
clone.value = control.value;
|
|
249
|
+
if (control.tagName === 'INPUT')
|
|
250
|
+
clone.checked = control.checked;
|
|
251
|
+
clone.dir = control.matches(':dir(rtl)') ? 'rtl' : 'ltr';
|
|
252
|
+
form.append(clone);
|
|
253
|
+
const entries = [];
|
|
254
|
+
new FormData(form).forEach((value, name) => entries.push([name, value]));
|
|
255
|
+
return entries;
|
|
128
256
|
}
|
|
129
257
|
catch {
|
|
130
|
-
|
|
258
|
+
// Mock/non-browser DOMs cannot construct FormData from a native form.
|
|
259
|
+
return fallback;
|
|
131
260
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
261
|
+
}
|
|
262
|
+
function snapshotField(control) {
|
|
263
|
+
const custom = formFieldAdapter.readFormField(control);
|
|
264
|
+
custom?.reconcile();
|
|
265
|
+
const name = control.getAttribute('name') ?? '';
|
|
266
|
+
const disabled = effectiveDisabled(control);
|
|
267
|
+
const active = (custom?.active() ?? true) && nativeDatalistParticipation(control);
|
|
268
|
+
const state = { control, name, kind: custom?.kind ?? 'text', disabled, active, entries: [], model: null, custom };
|
|
269
|
+
if (custom) {
|
|
270
|
+
state.model = custom.value();
|
|
271
|
+
if (name && active && !disabled && state.model !== null && (state.kind !== 'toggle' || state.model === true)) {
|
|
272
|
+
state.entries.push([name, String(state.model)]);
|
|
273
|
+
}
|
|
274
|
+
return state;
|
|
275
|
+
}
|
|
276
|
+
if (control.tagName === 'INPUT') {
|
|
277
|
+
const input = control;
|
|
278
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
279
|
+
state.kind = input.type;
|
|
280
|
+
state.model = input.checked ? input.value : null;
|
|
136
281
|
}
|
|
282
|
+
else if (input.type === 'file') {
|
|
283
|
+
state.kind = 'file';
|
|
284
|
+
if (name && active && !disabled) {
|
|
285
|
+
const files = Array.from(input.files ?? []);
|
|
286
|
+
const FileConstructor = input.ownerDocument.defaultView?.File ?? File;
|
|
287
|
+
const values = files.length ? files : [new FileConstructor([], '', { type: 'application/octet-stream' })];
|
|
288
|
+
state.entries = values.map(file => [name, file]);
|
|
289
|
+
}
|
|
290
|
+
return state;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
state.model = input.value;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else if (control.tagName === 'SELECT') {
|
|
297
|
+
const select = control;
|
|
298
|
+
state.kind = select.multiple ? 'multiselect' : 'selection';
|
|
299
|
+
const options = Array.from(select.selectedOptions).filter(enabledOption);
|
|
300
|
+
state.model = options[0]?.value ?? null;
|
|
301
|
+
if (name && active && !disabled)
|
|
302
|
+
state.entries = options.map(option => [name, option.value]);
|
|
303
|
+
return state;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
state.model = control.value;
|
|
307
|
+
}
|
|
308
|
+
if (name && active && !disabled && state.model !== null) {
|
|
309
|
+
state.entries.push([name, String(state.model)]);
|
|
310
|
+
const dirname = control.getAttribute('dirname');
|
|
311
|
+
const input = control;
|
|
312
|
+
const supportsDirection = control.tagName === 'TEXTAREA' || ['hidden', 'text', 'search', 'tel', 'url', 'email', 'password'].includes(input.type);
|
|
313
|
+
if (dirname && supportsDirection)
|
|
314
|
+
state.entries.push([dirname, control.matches(':dir(rtl)') ? 'rtl' : 'ltr']);
|
|
315
|
+
state.entries = nativeTextEntries(control, state.entries);
|
|
316
|
+
}
|
|
317
|
+
return state;
|
|
318
|
+
}
|
|
319
|
+
function validateField(control, report) {
|
|
320
|
+
const custom = formFieldAdapter.readFormField(control);
|
|
321
|
+
custom?.reconcile();
|
|
322
|
+
if (effectiveDisabled(control) || (custom && !custom.active()))
|
|
323
|
+
return true;
|
|
324
|
+
if (custom)
|
|
325
|
+
return custom.validate(report);
|
|
326
|
+
const native = control;
|
|
327
|
+
const validate = report ? native.reportValidity : native.checkValidity;
|
|
328
|
+
return typeof validate === 'function' ? validate.call(native) : true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function collectionStates(formEl, hostEl) {
|
|
332
|
+
return getFormControls(formEl, hostEl).map(snapshotField).filter(field => field.active && field.name);
|
|
333
|
+
}
|
|
334
|
+
/** Assignment uses owned names, independent of successful-entry participation. */
|
|
335
|
+
function assignmentStates(formEl, hostEl) {
|
|
336
|
+
return getFormControls(formEl, hostEl)
|
|
337
|
+
.filter(control => Boolean(control.getAttribute('name')) && !shouldSkipControl(control))
|
|
338
|
+
.map(snapshotField);
|
|
339
|
+
}
|
|
340
|
+
function groups(fields) {
|
|
341
|
+
const result = new Map();
|
|
342
|
+
for (const field of fields) {
|
|
343
|
+
const group = result.get(field.name) ?? [];
|
|
344
|
+
group.push(field);
|
|
345
|
+
result.set(field.name, group);
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
349
|
+
function formDataFrom(fields) {
|
|
350
|
+
const data = new FormData();
|
|
351
|
+
for (const field of fields) {
|
|
352
|
+
for (const [name, value] of field.entries)
|
|
353
|
+
data.append(name, value);
|
|
354
|
+
}
|
|
355
|
+
return data;
|
|
356
|
+
}
|
|
357
|
+
function collectValues(formEl, hostEl, formData) {
|
|
358
|
+
const fields = collectionStates(formEl, hostEl);
|
|
359
|
+
const data = formDataFrom(fields);
|
|
360
|
+
return projectValues(fields, data);
|
|
361
|
+
}
|
|
362
|
+
function collectFormState(formEl, hostEl, extraFields = []) {
|
|
363
|
+
const fields = [...collectionStates(formEl, hostEl), ...extraFields].sort((a, b) => {
|
|
364
|
+
const position = a.control.compareDocumentPosition(b.control);
|
|
365
|
+
return position & Node.DOCUMENT_POSITION_DISCONNECTED ? 0 : position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : position & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
137
366
|
});
|
|
138
|
-
|
|
367
|
+
const formData = formDataFrom(fields);
|
|
368
|
+
return { values: projectValues(fields, formData), formData };
|
|
139
369
|
}
|
|
140
|
-
function
|
|
370
|
+
function projectValues(fields, data) {
|
|
141
371
|
const values = {};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
372
|
+
const entries = new Map();
|
|
373
|
+
data.forEach((value, name) => {
|
|
374
|
+
const group = entries.get(name) ?? [];
|
|
375
|
+
group.push(value);
|
|
376
|
+
entries.set(name, group);
|
|
146
377
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
378
|
+
const put = (name, value) => Object.defineProperty(values, name, { value, enumerable: true, writable: true, configurable: true });
|
|
379
|
+
const fieldGroups = groups(fields);
|
|
380
|
+
for (const [name, group] of fieldGroups) {
|
|
381
|
+
const eligible = group.filter(field => !field.disabled);
|
|
382
|
+
if (!eligible.length)
|
|
383
|
+
continue;
|
|
384
|
+
if (group.every(field => field.kind === 'toggle')) {
|
|
385
|
+
const booleans = eligible.map(field => Boolean(field.model));
|
|
386
|
+
put(name, group.length === 1 ? booleans[0] : booleans);
|
|
387
|
+
entries.delete(name);
|
|
388
|
+
continue;
|
|
155
389
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
390
|
+
const successful = entries.get(name) ?? [];
|
|
391
|
+
const radios = group.every(field => field.kind === 'radio');
|
|
392
|
+
const arrayShape = group.some(field => field.kind === 'multiselect' || (field.kind === 'file' && field.control.multiple)) ||
|
|
393
|
+
(radios ? nativeRadioGroups(group).length > 1 : group.length > 1);
|
|
394
|
+
const emptyArray = group.every(field => field.kind === 'checkbox' || field.kind === 'multiselect');
|
|
395
|
+
if (successful.length || (arrayShape && emptyArray))
|
|
396
|
+
put(name, arrayShape ? successful : successful.length > 1 ? successful : successful[0]);
|
|
397
|
+
entries.delete(name);
|
|
398
|
+
}
|
|
399
|
+
// Includes native dirname and, later, the submission transaction's extra entries.
|
|
400
|
+
for (const [name, successful] of entries)
|
|
401
|
+
put(name, successful.length > 1 ? successful : successful[0]);
|
|
160
402
|
return values;
|
|
161
403
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
164
|
-
return;
|
|
165
|
-
Object.entries(values).forEach(([name, value]) => {
|
|
166
|
-
const controls = getNamedControls(formEl, hostEl).filter((control) => control.getAttribute('name') === name);
|
|
167
|
-
const nextValue = Array.isArray(value) ? value[0] : value;
|
|
168
|
-
controls.forEach((control) => {
|
|
169
|
-
if (control instanceof HTMLInputElement && control.type === 'checkbox') {
|
|
170
|
-
control.checked = toBoolean(nextValue);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (control.tagName.toLowerCase() === 'q-toggle') {
|
|
174
|
-
control.checked = toBoolean(nextValue);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if ('value' in control) {
|
|
178
|
-
control.value = nextValue;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
404
|
+
function fail(name, reason) {
|
|
405
|
+
throw new TypeError(`Cannot assign form field "${name}": ${reason}`);
|
|
182
406
|
}
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
407
|
+
function textValue(value, name) {
|
|
408
|
+
if (value === null)
|
|
409
|
+
return '';
|
|
410
|
+
if (typeof value === 'string' || typeof value === 'boolean')
|
|
411
|
+
return String(value);
|
|
412
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
413
|
+
return String(value);
|
|
414
|
+
return fail(name, 'expected text, a finite number, Boolean or null');
|
|
415
|
+
}
|
|
416
|
+
function identity(value, name) {
|
|
417
|
+
if (typeof value === 'string')
|
|
418
|
+
return value;
|
|
419
|
+
if (value === null)
|
|
420
|
+
return null;
|
|
421
|
+
return fail(name, 'expected an option identity string or null');
|
|
422
|
+
}
|
|
423
|
+
function identities(value, name) {
|
|
424
|
+
if (value === null)
|
|
425
|
+
return [];
|
|
426
|
+
if (typeof value === 'string')
|
|
427
|
+
return [value];
|
|
428
|
+
if (Array.isArray(value) && value.every(item => typeof item === 'string'))
|
|
429
|
+
return value;
|
|
430
|
+
return fail(name, 'expected option identity strings or null');
|
|
431
|
+
}
|
|
432
|
+
function toBoolean(value, name) {
|
|
433
|
+
if (typeof value === 'boolean')
|
|
434
|
+
return value;
|
|
435
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
436
|
+
return value !== 0;
|
|
437
|
+
if (typeof value === 'string')
|
|
438
|
+
return ['true', '1', 'on', 'yes'].includes(value.toLowerCase());
|
|
439
|
+
if (value === null)
|
|
440
|
+
return false;
|
|
441
|
+
return fail(name, 'expected a Boolean-compatible scalar');
|
|
442
|
+
}
|
|
443
|
+
function assignScalar(field, value) {
|
|
444
|
+
return () => {
|
|
445
|
+
if (field.custom) {
|
|
446
|
+
field.custom.assign(value);
|
|
447
|
+
field.custom.reconcile();
|
|
188
448
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const input = control;
|
|
192
|
-
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
193
|
-
input.checked = input.defaultChecked;
|
|
194
|
-
}
|
|
195
|
-
else if (input.type !== 'file') {
|
|
196
|
-
input.value = input.getAttribute('value') ?? input.defaultValue ?? '';
|
|
197
|
-
}
|
|
198
|
-
return;
|
|
449
|
+
else {
|
|
450
|
+
field.control.value = String(value);
|
|
199
451
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function prepareGroup(name, fields, value) {
|
|
455
|
+
const kinds = new Set(fields.map(field => field.kind));
|
|
456
|
+
const scalarGroup = fields.every(field => field.kind === 'text' || field.kind === 'selection');
|
|
457
|
+
if (kinds.size > 1 && !scalarGroup)
|
|
458
|
+
return fail(name, 'mixed control kinds have an ambiguous assignment shape');
|
|
459
|
+
const kind = fields[0].kind;
|
|
460
|
+
if (kind === 'file') {
|
|
461
|
+
if (value !== null && value !== '' && !(Array.isArray(value) && value.length === 0))
|
|
462
|
+
return fail(name, 'file controls support clearing only');
|
|
463
|
+
return fields.map(field => () => { field.control.value = ''; });
|
|
464
|
+
}
|
|
465
|
+
if (kind === 'radio') {
|
|
466
|
+
const radioGroups = nativeRadioGroups(fields);
|
|
467
|
+
if (Array.isArray(value) && radioGroups.length === 1)
|
|
468
|
+
return fail(name, 'a lone native radio group takes one identity');
|
|
469
|
+
const positional = Array.isArray(value) ? value : radioGroups.map(() => value);
|
|
470
|
+
if (positional.length !== radioGroups.length)
|
|
471
|
+
return fail(name, 'radio array length must match the native group count');
|
|
472
|
+
return radioGroups.flatMap((group, index) => {
|
|
473
|
+
const selected = identity(positional[index], name);
|
|
474
|
+
const match = group.find(field => field.control.value === selected);
|
|
475
|
+
return group.map(field => () => { field.control.checked = field === match; });
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (kind === 'checkbox') {
|
|
479
|
+
if (fields.length === 1 && typeof value === 'boolean')
|
|
480
|
+
return [() => { fields[0].control.checked = value; }];
|
|
481
|
+
const selected = identities(value, name);
|
|
482
|
+
return fields.map(field => () => { const input = field.control; input.checked = selected.includes(input.value); });
|
|
483
|
+
}
|
|
484
|
+
if (kind === 'multiselect') {
|
|
485
|
+
if (fields.length !== 1)
|
|
486
|
+
return fail(name, 'repeated multiselect containers have an ambiguous assignment shape');
|
|
487
|
+
const selected = identities(value, name);
|
|
488
|
+
const select = fields[0].control;
|
|
489
|
+
return [() => { Array.from(select.options).forEach(option => { option.selected = selected.includes(option.value); }); }];
|
|
490
|
+
}
|
|
491
|
+
if (kind === 'toggle') {
|
|
492
|
+
if (fields.length === 1) {
|
|
493
|
+
if (Array.isArray(value))
|
|
494
|
+
return fail(name, 'a lone toggle takes one scalar');
|
|
495
|
+
return [assignScalar(fields[0], toBoolean(value, name))];
|
|
204
496
|
}
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
Array.from(select.options).forEach(option => {
|
|
208
|
-
option.selected = option.defaultSelected;
|
|
209
|
-
});
|
|
497
|
+
if (!Array.isArray(value) || value.length !== fields.length || !value.every(item => typeof item === 'boolean')) {
|
|
498
|
+
return fail(name, 'repeated toggles take one Boolean per owned toggle');
|
|
210
499
|
}
|
|
500
|
+
return fields.map((field, index) => assignScalar(field, value[index]));
|
|
501
|
+
}
|
|
502
|
+
if (kind === 'selection' && fields.length === 1 && Array.isArray(value))
|
|
503
|
+
return fail(name, 'a lone selection takes one identity string or null');
|
|
504
|
+
const positional = Array.isArray(value) ? value : fields.map(() => value);
|
|
505
|
+
if (positional.length !== fields.length)
|
|
506
|
+
return fail(name, 'positional array length must match the owned field count');
|
|
507
|
+
return fields.map((field, index) => {
|
|
508
|
+
const item = positional[index];
|
|
509
|
+
const next = field.kind === 'selection' ? identity(item, name) ?? '' : textValue(item, name);
|
|
510
|
+
return assignScalar(field, next);
|
|
211
511
|
});
|
|
212
512
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
513
|
+
/** Validate the entire partial update before mutating any control. */
|
|
514
|
+
function applyValues(formEl, hostEl, values) {
|
|
515
|
+
const owned = groups(assignmentStates(formEl, hostEl));
|
|
516
|
+
const assignments = [];
|
|
517
|
+
for (const [name, value] of Object.entries(values)) {
|
|
518
|
+
const fields = owned.get(name);
|
|
519
|
+
if (fields?.length)
|
|
520
|
+
assignments.push(...prepareGroup(name, fields, value));
|
|
521
|
+
}
|
|
522
|
+
for (const apply of assignments)
|
|
523
|
+
apply();
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function resetNative(control) {
|
|
527
|
+
const native = control;
|
|
528
|
+
const clone = native.cloneNode(true);
|
|
529
|
+
clone.removeAttribute('form');
|
|
530
|
+
const form = native.ownerDocument.createElement('form');
|
|
531
|
+
form.append(clone);
|
|
532
|
+
native.ownerDocument.defaultView.HTMLFormElement.prototype.reset.call(form);
|
|
533
|
+
if (native.tagName === 'SELECT') {
|
|
534
|
+
const source = clone;
|
|
535
|
+
const select = native;
|
|
536
|
+
if (select.multiple) {
|
|
537
|
+
Array.from(select.options).forEach((option, index) => {
|
|
538
|
+
option.selected = source.options[index].selected;
|
|
539
|
+
});
|
|
233
540
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return;
|
|
541
|
+
else {
|
|
542
|
+
select.selectedIndex = source.selectedIndex;
|
|
237
543
|
}
|
|
238
544
|
}
|
|
239
|
-
if (tagName === '
|
|
240
|
-
|
|
241
|
-
if (!option.disabled)
|
|
242
|
-
formData.append(name, option.value);
|
|
243
|
-
});
|
|
244
|
-
return;
|
|
545
|
+
else if (native.tagName === 'INPUT' && ['checkbox', 'radio'].includes(native.type)) {
|
|
546
|
+
native.checked = clone.checked;
|
|
245
547
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (value !== null)
|
|
249
|
-
formData.append(name, String(value));
|
|
250
|
-
return;
|
|
548
|
+
else {
|
|
549
|
+
native.value = clone.value;
|
|
251
550
|
}
|
|
252
|
-
formData.append(name, value);
|
|
253
551
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
552
|
+
/** Native reset already handles natively owned fields. Reset only logical fields. */
|
|
553
|
+
function resetLogicalControls(formEl, hostEl) {
|
|
554
|
+
for (const control of getFormControls(formEl, hostEl)) {
|
|
555
|
+
if (shouldSkipControl(control))
|
|
556
|
+
continue;
|
|
557
|
+
const custom = formFieldAdapter.readFormField(control);
|
|
558
|
+
const owner = custom?.owner() ?? control.form;
|
|
559
|
+
if (owner)
|
|
560
|
+
continue;
|
|
561
|
+
if (custom) {
|
|
562
|
+
custom.reset();
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
resetNative(control);
|
|
566
|
+
}
|
|
259
567
|
}
|
|
260
|
-
values[key] = value;
|
|
261
568
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (value === undefined)
|
|
266
|
-
return null;
|
|
267
|
-
return value;
|
|
569
|
+
function reconcileControls(formEl, hostEl) {
|
|
570
|
+
for (const control of getFormControls(formEl, hostEl)) {
|
|
571
|
+
formFieldAdapter.readFormField(control)?.reconcile();
|
|
268
572
|
}
|
|
269
|
-
return null;
|
|
270
573
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
574
|
+
|
|
575
|
+
/** Suppress navigation now; distinguish later per-event cancellation until dispatch ends. */
|
|
576
|
+
function cancelSubmitAndAwaitDispatch(event) {
|
|
577
|
+
const alreadyCanceled = event.defaultPrevented;
|
|
578
|
+
const preventDefault = event.preventDefault;
|
|
579
|
+
preventDefault.call(event);
|
|
580
|
+
if (alreadyCanceled)
|
|
581
|
+
return Promise.resolve(true);
|
|
582
|
+
const ownPrevent = Object.getOwnPropertyDescriptor(event, 'preventDefault');
|
|
583
|
+
const ownReturn = Object.getOwnPropertyDescriptor(event, 'returnValue');
|
|
584
|
+
let prototype = event;
|
|
585
|
+
let returnValue;
|
|
586
|
+
while (prototype && !returnValue) {
|
|
587
|
+
returnValue = Object.getOwnPropertyDescriptor(prototype, 'returnValue');
|
|
588
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
589
|
+
}
|
|
590
|
+
let canceled = false;
|
|
591
|
+
const restore = () => {
|
|
592
|
+
if (ownPrevent)
|
|
593
|
+
Object.defineProperty(event, 'preventDefault', ownPrevent);
|
|
594
|
+
else
|
|
595
|
+
delete event.preventDefault;
|
|
596
|
+
if (ownReturn)
|
|
597
|
+
Object.defineProperty(event, 'returnValue', ownReturn);
|
|
598
|
+
else
|
|
599
|
+
delete event.returnValue;
|
|
600
|
+
};
|
|
601
|
+
try {
|
|
602
|
+
Object.defineProperty(event, 'preventDefault', {
|
|
603
|
+
configurable: true,
|
|
604
|
+
writable: true,
|
|
605
|
+
value: function () {
|
|
606
|
+
if (this === event && event.cancelable)
|
|
607
|
+
canceled = true;
|
|
608
|
+
return preventDefault.call(this);
|
|
609
|
+
},
|
|
610
|
+
});
|
|
611
|
+
if (returnValue?.get && returnValue.set)
|
|
612
|
+
Object.defineProperty(event, 'returnValue', {
|
|
613
|
+
configurable: true,
|
|
614
|
+
get: function () { return returnValue.get.call(this); },
|
|
615
|
+
set: function (value) {
|
|
616
|
+
if (this === event && !value && event.cancelable)
|
|
617
|
+
canceled = true;
|
|
618
|
+
returnValue.set.call(this, value);
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
restore();
|
|
624
|
+
return Promise.reject(error);
|
|
625
|
+
}
|
|
626
|
+
// A trusted native callback can run microtasks before later submit listeners.
|
|
627
|
+
// A task boundary waits for the entire dispatch, then restores both descriptors.
|
|
628
|
+
return new Promise((resolve, reject) => setTimeout(() => {
|
|
629
|
+
try {
|
|
630
|
+
restore();
|
|
631
|
+
resolve(canceled);
|
|
275
632
|
}
|
|
276
|
-
|
|
277
|
-
|
|
633
|
+
catch (error) {
|
|
634
|
+
reject(error);
|
|
278
635
|
}
|
|
636
|
+
}, 0));
|
|
637
|
+
}
|
|
638
|
+
function submitterFields({ submitter, coordinates = [0, 0] }) {
|
|
639
|
+
if (!submitter)
|
|
640
|
+
return [];
|
|
641
|
+
const name = formSubmitAction.submitAttribute(submitter, 'name', 'name') ?? '';
|
|
642
|
+
const image = submitter.type === 'image';
|
|
643
|
+
const value = formSubmitAction.submitAttribute(submitter, 'value', 'value') ?? '';
|
|
644
|
+
const entries = image ? [[name ? `${name}.x` : 'x', String(coordinates[0])], [name ? `${name}.y` : 'y', String(coordinates[1])]] : name ? [[name, value]] : [];
|
|
645
|
+
return entries.map(([key, entry]) => ({ control: submitter, name: key, kind: 'text', disabled: false, active: true, entries: [[key, entry]], model: entry }));
|
|
646
|
+
}
|
|
647
|
+
function submissionSettings(base, submitter) {
|
|
648
|
+
if (!submitter)
|
|
649
|
+
return { ...base };
|
|
650
|
+
return {
|
|
651
|
+
action: formSubmitAction.submitAttribute(submitter, 'formAction', 'formaction') ?? base.action,
|
|
652
|
+
method: formSubmitAction.submitAttribute(submitter, 'formMethod', 'formmethod') ?? base.method,
|
|
653
|
+
enctype: formSubmitAction.submitAttribute(submitter, 'formEnctype', 'formenctype') ?? base.enctype,
|
|
654
|
+
target: formSubmitAction.submitAttribute(submitter, 'formTarget', 'formtarget') ?? base.target,
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
/** Use native attribute normalization, including invalid/empty override defaults. */
|
|
658
|
+
function normalizedMethod(form, method) {
|
|
659
|
+
const probe = form.ownerDocument.createElement('form');
|
|
660
|
+
probe.setAttribute('method', method);
|
|
661
|
+
return probe.method;
|
|
662
|
+
}
|
|
663
|
+
function closeSubmissionDialog(host, activation) {
|
|
664
|
+
const view = host.ownerDocument.defaultView;
|
|
665
|
+
let node = host;
|
|
666
|
+
while (node) {
|
|
667
|
+
if (node instanceof view.HTMLDialogElement) {
|
|
668
|
+
const submitter = activation.submitter;
|
|
669
|
+
const value = submitter && submitter.type === 'image' ? (activation.coordinates ?? [0, 0]).join(',') : submitter ? formSubmitAction.submitAttribute(submitter, 'value', 'value') ?? '' : '';
|
|
670
|
+
view.HTMLDialogElement.prototype.close.call(node, value);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
node = node.parentNode ?? (node instanceof view.ShadowRoot ? node.host : null);
|
|
279
674
|
}
|
|
280
|
-
|
|
281
|
-
const value = control.value;
|
|
282
|
-
if (value === undefined)
|
|
283
|
-
return null;
|
|
284
|
-
return value;
|
|
285
|
-
}
|
|
286
|
-
return null;
|
|
675
|
+
throw new view.DOMException('method="dialog" requires an actual native dialog ancestor.', 'NotSupportedError');
|
|
287
676
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
677
|
+
/** Scoped replacement of the native entry list; later formdata listeners remain native. */
|
|
678
|
+
function deliverForm(form, data, settings) {
|
|
679
|
+
const saved = ['action', 'method', 'enctype', 'target'].map(name => [name, form.getAttribute(name)]);
|
|
680
|
+
const root = form.getRootNode();
|
|
681
|
+
let consumed = false;
|
|
682
|
+
const replace = (event) => {
|
|
683
|
+
if (event.target !== form || consumed)
|
|
684
|
+
return;
|
|
685
|
+
consumed = true;
|
|
686
|
+
const entries = event.formData;
|
|
687
|
+
const names = new Set();
|
|
688
|
+
entries.forEach((_value, name) => names.add(name));
|
|
689
|
+
for (const name of names)
|
|
690
|
+
entries.delete(name);
|
|
691
|
+
data.forEach((value, name) => entries.append(name, value));
|
|
692
|
+
};
|
|
693
|
+
root.addEventListener('formdata', replace, true);
|
|
694
|
+
try {
|
|
695
|
+
for (const [name] of saved) {
|
|
696
|
+
const value = settings[name];
|
|
697
|
+
if (value === undefined)
|
|
698
|
+
form.removeAttribute(name);
|
|
699
|
+
else
|
|
700
|
+
form.setAttribute(name, value);
|
|
701
|
+
}
|
|
702
|
+
form.ownerDocument.defaultView.HTMLFormElement.prototype.submit.call(form);
|
|
703
|
+
}
|
|
704
|
+
finally {
|
|
705
|
+
root.removeEventListener('formdata', replace, true);
|
|
706
|
+
for (const [name, value] of saved) {
|
|
707
|
+
if (value === null)
|
|
708
|
+
form.removeAttribute(name);
|
|
709
|
+
else
|
|
710
|
+
form.setAttribute(name, value);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
296
713
|
}
|
|
297
714
|
|
|
298
715
|
const formCss = () => `:host{display:block;box-sizing:border-box}.form-shell{display:flex;flex-direction:column;gap:var(--q-form-gap, var(--q-space-xl, 1.5rem));width:100%;color:var(--q-form-fg, var(--q-fg-base, #172033));font-family:var(--q-font-family, inherit)}.form-header.is-hidden,.form-actions.is-hidden{display:none}.form-title{margin:0;color:var(--q-form-title-color, var(--q-fg-base, #172033));font-size:var(--q-form-title-size, var(--q-font-size-lg, 1rem));font-weight:var(--q-font-weight-bold, 600);line-height:1.3}form{display:flex;flex-direction:column;gap:var(--q-form-gap, var(--q-space-xl, 1.5rem));width:100%;margin:0}.form-body{display:flex;flex-direction:column;gap:var(--q-form-field-gap, 12px);min-width:0}.form-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:var(--q-form-action-gap, var(--q-space-sm, .5rem));padding-top:var(--q-form-actions-padding-top, 4px)}:host{min-width:0}.q-label-hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip-path:inset(50%);white-space:nowrap;border:0 !important}.q-field-feedback{display:block;min-block-size:var(--_q-feedback-min, var(--q-context-feedback-min, 0px));font-family:var(--q-font-family, inherit);font-size:var(--q-field-feedback-font, var(--q-field-text-size, .75rem));font-weight:400;line-height:var(--q-field-text-line, 1rem);color:var(--q-fg-muted, #9ca3af);overflow-wrap:anywhere;margin:min(var(--q-space-xs, .25rem), var(--_q-feedback-min, var(--q-context-feedback-min, 0px))) 0 0}.q-field-feedback:not(:empty){margin-top:var(--q-space-xs, .25rem)}.q-field-feedback.error-msg{color:var(--_q-field-error-color, var(--q-color-danger, #f87171))}[part='label']:not(.q-label-hidden){font-family:var(--q-font-family, inherit);font-size:var(--q-field-label-font, var(--q-field-text-size, .75rem));font-weight:600;line-height:var(--q-field-text-line, 1rem);margin-bottom:var(--q-space-xs, .25rem);overflow-wrap:anywhere}`;
|
|
@@ -331,55 +748,92 @@ const QForm = class {
|
|
|
331
748
|
formEl;
|
|
332
749
|
headerSlot;
|
|
333
750
|
actionsSlot;
|
|
334
|
-
handledButtonClicks = new WeakSet();
|
|
335
751
|
titleId = `q-form-title-${++formIds}`;
|
|
336
|
-
|
|
752
|
+
resetTask;
|
|
753
|
+
resetRequest;
|
|
337
754
|
submitTask;
|
|
755
|
+
submitGeneration = 0;
|
|
756
|
+
submitAbort;
|
|
338
757
|
// ========================= [3] LIFECYCLE & WATCHERS ==========================
|
|
339
758
|
componentDidLoad() {
|
|
340
759
|
this.updateHeaderSlotState();
|
|
341
760
|
this.updateActionsSlotState();
|
|
342
|
-
|
|
761
|
+
}
|
|
762
|
+
disconnectedCallback() {
|
|
763
|
+
this.submitGeneration++;
|
|
764
|
+
this.submitAbort?.abort();
|
|
343
765
|
}
|
|
344
766
|
// ============================ [4] EXPOSED METHODS ============================
|
|
345
767
|
/** Returns values collected from named native and WebQuark form controls. */
|
|
346
768
|
async getValues() {
|
|
769
|
+
await awaitFormControls(this.formEl, this.el);
|
|
770
|
+
await formSubmitAction.awaitResetActions(this.el);
|
|
771
|
+
await (this.resetRequest ?? this.resetTask);
|
|
347
772
|
return collectValues(this.formEl, this.el);
|
|
348
773
|
}
|
|
349
774
|
/** Applies values to matching named native and WebQuark form controls. */
|
|
350
775
|
async setValues(values) {
|
|
776
|
+
await awaitFormControls(this.formEl, this.el);
|
|
777
|
+
await formSubmitAction.awaitResetActions(this.el);
|
|
778
|
+
await (this.resetRequest ?? this.resetTask);
|
|
351
779
|
applyValues(this.formEl, this.el, values);
|
|
352
780
|
}
|
|
353
781
|
/** Resets the native form and associated controls. */
|
|
354
782
|
async resetForm() {
|
|
355
|
-
if (
|
|
356
|
-
return;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
783
|
+
if (this.resetRequest)
|
|
784
|
+
return this.resetRequest;
|
|
785
|
+
if (this.resetTask)
|
|
786
|
+
return this.resetTask;
|
|
787
|
+
const request = this.performReset();
|
|
788
|
+
this.resetRequest = request;
|
|
789
|
+
try {
|
|
790
|
+
await request;
|
|
360
791
|
}
|
|
361
|
-
|
|
362
|
-
this.
|
|
792
|
+
finally {
|
|
793
|
+
if (this.resetRequest === request)
|
|
794
|
+
this.resetRequest = undefined;
|
|
363
795
|
}
|
|
364
|
-
|
|
365
|
-
|
|
796
|
+
}
|
|
797
|
+
/** Checks current owned fields without displaying validation messages. */
|
|
798
|
+
async checkValidity() {
|
|
799
|
+
return this.reportControlValidity(false);
|
|
800
|
+
}
|
|
801
|
+
/** Reports current owned field constraints and returns aggregate validity. */
|
|
802
|
+
async reportValidity() {
|
|
803
|
+
return this.reportControlValidity(true);
|
|
366
804
|
}
|
|
367
805
|
/** Requests native form submission, falling back to dispatching a submit event. */
|
|
368
806
|
async submitForm() {
|
|
369
|
-
this.
|
|
807
|
+
if (!this.submitTask)
|
|
808
|
+
this.requestSubmit();
|
|
370
809
|
await this.submitTask;
|
|
371
810
|
}
|
|
372
811
|
// =================== [5] EVENT HANDLERS & INTERNAL METHODS ===================
|
|
373
|
-
|
|
374
|
-
this.
|
|
812
|
+
async performReset() {
|
|
813
|
+
await awaitFormControls(this.formEl, this.el);
|
|
814
|
+
if (this.resetTask)
|
|
815
|
+
return this.resetTask;
|
|
816
|
+
if (!this.formEl)
|
|
817
|
+
return;
|
|
818
|
+
reconcileControls(this.formEl, this.el);
|
|
819
|
+
const nativeReset = this.formEl.ownerDocument.defaultView.HTMLFormElement.prototype.reset;
|
|
820
|
+
nativeReset.call(this.formEl);
|
|
821
|
+
await this.resetTask;
|
|
375
822
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
823
|
+
handleComposedClick(ev) {
|
|
824
|
+
const action = ev.composedPath().find(target => target instanceof HTMLButtonElement || target instanceof HTMLInputElement);
|
|
825
|
+
// Read native image offsetX/Y inside its own shadow tree. Outside that tree
|
|
826
|
+
// the click is retargeted to q-form and offsets are relative to the host.
|
|
827
|
+
if (action?.getRootNode() === this.formEl?.getRootNode() && ev.currentTarget === this.el)
|
|
828
|
+
return;
|
|
829
|
+
if (action?.type === 'reset') {
|
|
830
|
+
if (!action.form && !action.hasAttribute('form'))
|
|
831
|
+
formSubmitAction.scheduleResetAction(action, ev);
|
|
379
832
|
return;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
833
|
+
}
|
|
834
|
+
// q-button owns its bridge, including cancellation of qClick and late click listeners.
|
|
835
|
+
if (action && !ev.composedPath().some(target => target instanceof HTMLElement && target.tagName === 'Q-BUTTON'))
|
|
836
|
+
formSubmitAction.scheduleSubmitAction(action, ev);
|
|
383
837
|
}
|
|
384
838
|
handleKeyDown(ev) {
|
|
385
839
|
handleEnterBehavior({
|
|
@@ -391,43 +845,8 @@ const QForm = class {
|
|
|
391
845
|
});
|
|
392
846
|
}
|
|
393
847
|
requestSubmit() {
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
if (typeof this.formEl.requestSubmit === 'function') {
|
|
397
|
-
this.formEl.requestSubmit();
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
this.dispatchSubmitEvent();
|
|
401
|
-
}
|
|
402
|
-
handleComposedFormAction(ev, sourceEvent) {
|
|
403
|
-
if (this.handledButtonClicks.has(sourceEvent))
|
|
404
|
-
return;
|
|
405
|
-
const action = this.getFormActionFromComposedPath(sourceEvent.composedPath());
|
|
406
|
-
if (!action || !this.formEl)
|
|
407
|
-
return;
|
|
408
|
-
this.handledButtonClicks.add(sourceEvent);
|
|
409
|
-
ev.preventDefault();
|
|
410
|
-
if (action === 'reset') {
|
|
411
|
-
this.formEl.reset();
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
this.dispatchSubmitEvent();
|
|
415
|
-
}
|
|
416
|
-
dispatchSubmitEvent() {
|
|
417
|
-
this.formEl?.dispatchEvent(new globalThis.Event('submit', { bubbles: true, cancelable: true }));
|
|
418
|
-
}
|
|
419
|
-
getFormActionFromComposedPath(path) {
|
|
420
|
-
for (const target of path) {
|
|
421
|
-
if (!(target instanceof HTMLElement))
|
|
422
|
-
continue;
|
|
423
|
-
if (target.tagName.toLowerCase() !== 'q-button')
|
|
424
|
-
continue;
|
|
425
|
-
const control = target;
|
|
426
|
-
const type = (control.type || target.getAttribute('type') || '').toLowerCase();
|
|
427
|
-
if (type === 'submit' || type === 'reset')
|
|
428
|
-
return type;
|
|
429
|
-
}
|
|
430
|
-
return undefined;
|
|
848
|
+
if (this.formEl)
|
|
849
|
+
formSubmitAction.dispatchFormSubmit(this.formEl);
|
|
431
850
|
}
|
|
432
851
|
handleHeaderSlotChange = () => {
|
|
433
852
|
this.updateHeaderSlotState();
|
|
@@ -453,61 +872,129 @@ const QForm = class {
|
|
|
453
872
|
});
|
|
454
873
|
}
|
|
455
874
|
handleSubmit = (ev) => {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (this.preventDefault) {
|
|
875
|
+
if (ev.target !== this.formEl)
|
|
876
|
+
return;
|
|
877
|
+
if (ev.defaultPrevented || this.submitTask || !this.formEl) {
|
|
460
878
|
ev.preventDefault();
|
|
461
|
-
}
|
|
462
|
-
if (!this.noValidate && !(await this.reportControlValidity())) {
|
|
463
879
|
return;
|
|
464
880
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
881
|
+
// Cancels synchronously and observes later native submit listener calls.
|
|
882
|
+
const dispatch = cancelSubmitAndAwaitDispatch(ev);
|
|
883
|
+
const form = this.formEl;
|
|
884
|
+
const generation = this.submitGeneration;
|
|
885
|
+
const activation = formSubmitAction.readSubmitActivation(ev);
|
|
886
|
+
const abort = new AbortController();
|
|
887
|
+
this.submitAbort = abort;
|
|
888
|
+
formSubmitAction.setFormSubmitting(form, true);
|
|
889
|
+
const task = this.processSubmit(ev, form, generation, activation, abort.signal, dispatch);
|
|
890
|
+
this.submitTask = task;
|
|
891
|
+
void task.catch(error => console.error(error));
|
|
892
|
+
void task.finally(() => {
|
|
893
|
+
if (this.submitTask === task)
|
|
894
|
+
this.submitTask = undefined;
|
|
895
|
+
if (this.submitAbort === abort)
|
|
896
|
+
this.submitAbort = undefined;
|
|
897
|
+
formSubmitAction.setFormSubmitting(form, false);
|
|
898
|
+
}).catch(() => { });
|
|
899
|
+
};
|
|
900
|
+
currentSubmission(form, generation, activation) {
|
|
901
|
+
if (!this.el.isConnected || this.formEl !== form || this.submitGeneration !== generation)
|
|
479
902
|
return false;
|
|
903
|
+
const submitter = activation.submitter;
|
|
904
|
+
return !submitter || (submitter.isConnected && formSubmitAction.isSubmitAction(submitter) && [form, this.el].includes(formSubmitAction.submitOwner(submitter)));
|
|
905
|
+
}
|
|
906
|
+
async processSubmit(ev, form, generation, activation, signal, dispatch) {
|
|
907
|
+
if (await dispatch)
|
|
908
|
+
return;
|
|
909
|
+
await awaitFormControls(form, this.el, signal);
|
|
910
|
+
await formSubmitAction.awaitResetActions(this.el);
|
|
911
|
+
await (this.resetRequest ?? this.resetTask);
|
|
912
|
+
if (!this.currentSubmission(form, generation, activation))
|
|
913
|
+
return;
|
|
914
|
+
reconcileControls(form, this.el);
|
|
915
|
+
if (!this.noValidate && !formSubmitAction.submitterNoValidate(activation.submitter)) {
|
|
916
|
+
for (const control of getFormControls(form, this.el))
|
|
917
|
+
if (!validateField(control, true))
|
|
918
|
+
return;
|
|
480
919
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
920
|
+
if (!this.currentSubmission(form, generation, activation))
|
|
921
|
+
return;
|
|
922
|
+
const { values, formData } = collectFormState(form, this.el, submitterFields(activation));
|
|
923
|
+
const settings = submissionSettings({ action: this.action, method: this.method, enctype: this.enctype, target: this.target }, activation.submitter);
|
|
924
|
+
const emitted = this.qSubmit.emit({ values, formData, form, originalEvent: ev, submitter: activation.submitter });
|
|
925
|
+
if (emitted.defaultPrevented || this.preventDefault || !this.currentSubmission(form, generation, activation))
|
|
926
|
+
return;
|
|
927
|
+
if (normalizedMethod(form, settings.method) === 'dialog')
|
|
928
|
+
closeSubmissionDialog(this.el, activation);
|
|
929
|
+
else
|
|
930
|
+
deliverForm(form, formData, settings);
|
|
931
|
+
}
|
|
932
|
+
async reportControlValidity(report = true) {
|
|
933
|
+
await awaitFormControls(this.formEl, this.el);
|
|
934
|
+
await formSubmitAction.awaitResetActions(this.el);
|
|
935
|
+
await (this.resetRequest ?? this.resetTask);
|
|
936
|
+
if (this.formEl)
|
|
937
|
+
reconcileControls(this.formEl, this.el);
|
|
938
|
+
for (const control of getFormControls(this.formEl, this.el)) {
|
|
939
|
+
if (!validateField(control, report))
|
|
492
940
|
return false;
|
|
493
|
-
}
|
|
494
941
|
}
|
|
495
942
|
return true;
|
|
496
943
|
}
|
|
497
944
|
handleReset = (ev) => {
|
|
498
945
|
if (!this.formEl)
|
|
499
946
|
return;
|
|
500
|
-
this.
|
|
947
|
+
if (this.resetTask) {
|
|
948
|
+
ev.preventDefault();
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const form = this.formEl;
|
|
952
|
+
let complete;
|
|
953
|
+
let fail;
|
|
954
|
+
const task = new Promise((resolve, reject) => {
|
|
955
|
+
complete = resolve;
|
|
956
|
+
fail = reject;
|
|
957
|
+
});
|
|
958
|
+
this.resetTask = task;
|
|
959
|
+
const emitted = this.qReset.emit({
|
|
501
960
|
form: this.formEl,
|
|
502
961
|
originalEvent: ev,
|
|
503
962
|
});
|
|
963
|
+
if (emitted.defaultPrevented)
|
|
964
|
+
ev.preventDefault();
|
|
965
|
+
// Native reset dispatch can flush microtasks before later listeners run.
|
|
966
|
+
// Preserve resetTask while waiting for their final cancellation decision.
|
|
967
|
+
setTimeout(async () => {
|
|
968
|
+
try {
|
|
969
|
+
if (!ev.defaultPrevented && this.el.isConnected) {
|
|
970
|
+
await awaitFormControls(form, this.el);
|
|
971
|
+
if (!ev.defaultPrevented && this.el.isConnected && this.formEl === form) {
|
|
972
|
+
resetLogicalControls(form, this.el);
|
|
973
|
+
reconcileControls(form, this.el);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
complete();
|
|
977
|
+
}
|
|
978
|
+
catch (error) {
|
|
979
|
+
fail(error);
|
|
980
|
+
}
|
|
981
|
+
finally {
|
|
982
|
+
if (this.resetTask === task)
|
|
983
|
+
this.resetTask = undefined;
|
|
984
|
+
}
|
|
985
|
+
}, 0);
|
|
986
|
+
void task.catch(error => console.error(error));
|
|
504
987
|
};
|
|
505
988
|
// ===================== [6] RENDER (Visual Template Only) =====================
|
|
506
989
|
render() {
|
|
507
990
|
const hasHeaderContent = Boolean(this.label) || this.hasHeaderSlot;
|
|
508
991
|
const formLabelledBy = !this.ariaLabel && this.label && !this.hasHeaderSlot ? this.titleId : undefined;
|
|
509
992
|
const formAriaLabel = this.ariaLabel?.trim() || (this.label && this.hasHeaderSlot ? this.label : undefined);
|
|
510
|
-
return (index.h(index.Host, { key: '
|
|
993
|
+
return (index.h(index.Host, { key: '76cfae88993ca1d4d3bddf8db9774d7f1c271af0', style: { ...tokens.controlScope(this.size), '--q-context-feedback-min': this.reserveFeedback === undefined ? '' : 'initial', '--_q-context-feedback-reserve': this.reserveFeedback === undefined ? '' : this.reserveFeedback ? '1' : '0' } }, index.h("div", { key: 'c4dc7354c13b92319c0f2abee59ab33afa8d224d', class: "form-shell" }, index.h("div", { key: 'd9fbe8631b008190edc80b08f7a608f08895fb41', class: { 'form-header': true, 'is-hidden': !hasHeaderContent, 'q-label-hidden': this.labelHidden }, part: "header" }, index.h("slot", { key: '23d7d70ef8914340767380ea9970952a97e16de6', name: "header", ref: (el) => (this.headerSlot = el), onSlotchange: this.handleHeaderSlotChange }, this.label && index.h("h2", { key: '7eff4f812a857135fa4402b0da45cd101a2f37f2', id: this.titleId, class: "form-title" }, this.label))), index.h("form", { key: '4e41eb0b4c3984b90f7d01a60582a81b00b73c78', ref: (el) => (this.formEl = el), action: this.action, method: this.method, autocomplete: this.autocomplete, enctype: this.enctype, target: this.target, noValidate: this.noValidate, "aria-labelledby": formLabelledBy, "aria-label": formAriaLabel, part: "form", onSubmit: this.handleSubmit, onClick: (ev) => {
|
|
994
|
+
const image = ev.target;
|
|
995
|
+
if (image instanceof HTMLInputElement && image.type === 'image' && image.getRootNode() === this.formEl?.getRootNode())
|
|
996
|
+
this.handleComposedClick(ev);
|
|
997
|
+
}, onReset: this.handleReset }, index.h("div", { key: '2d24a3a6d69f4601222a0461c947edd193ad9e5f', class: "form-body", part: "body" }, index.h("slot", { key: '64e0d617813c0e3be6fa217301b7d16cca4ea34d' })), index.h("div", { key: 'ee63ded8ea9ead32c31357a7740c4ec8086e29f9', class: { 'form-actions': true, 'is-hidden': !this.hasActionsSlot }, part: "actions" }, index.h("slot", { key: 'df3705b761a7c4fbbac1e418115ac0d01ceff089', name: "actions", ref: (el) => (this.actionsSlot = el), onSlotchange: this.handleActionsSlotChange }))))));
|
|
511
998
|
}
|
|
512
999
|
};
|
|
513
1000
|
QForm.style = formCss();
|