@webquark/browser 1.1.0-dev.9 → 1.1.1-dev.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/dist/cjs/{action.props-N0urQtdP.js → action.props-CNe2JXR5.js} +1 -1
- package/dist/cjs/{dom-Dk77oFF6.js → dom-BYrqRYna.js} +1 -1
- package/dist/cjs/{field-CsrQGhG-.js → field-BRAR56Ex.js} +1 -1
- package/dist/cjs/{form-control-validity-D1ukC0_e.js → form-control-validity-BkilGb3E.js} +3 -3
- package/dist/cjs/{index-DWXhKHCB.js → index-BN-WdOQM.js} +17 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/q-accordion.cjs.entry.js +2 -2
- package/dist/cjs/q-alert.cjs.entry.js +2 -2
- 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_3.cjs.entry.js +907 -0
- package/dist/cjs/q-card.cjs.entry.js +3 -3
- package/dist/cjs/q-carousel.cjs.entry.js +120 -18
- package/dist/cjs/q-chip.cjs.entry.js +2 -2
- package/dist/cjs/q-control-group.cjs.entry.js +64 -0
- package/dist/cjs/q-conversation-bubble.cjs.entry.js +1 -1
- package/dist/cjs/q-data-table.cjs.entry.js +4 -4
- package/dist/cjs/q-dialog.cjs.entry.js +4 -4
- package/dist/cjs/q-divider.cjs.entry.js +26 -0
- package/dist/cjs/q-dropdown.cjs.entry.js +320 -104
- package/dist/cjs/q-form.cjs.entry.js +17 -7
- package/dist/cjs/q-grid.cjs.entry.js +3 -3
- package/dist/cjs/q-icon.cjs.entry.js +1 -1
- package/dist/cjs/q-image-comparison.cjs.entry.js +2 -2
- package/dist/cjs/q-inline.cjs.entry.js +3 -3
- package/dist/cjs/q-input_2.cjs.entry.js +10 -8
- package/dist/cjs/q-link.cjs.entry.js +2 -2
- package/dist/cjs/q-map.cjs.entry.js +2 -2
- package/dist/cjs/q-media.cjs.entry.js +2 -2
- 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 +7 -7
- package/dist/cjs/q-quantity-selector.cjs.entry.js +6 -6
- package/dist/cjs/q-radio-group.cjs.entry.js +4 -4
- package/dist/cjs/q-reel.cjs.entry.js +24 -24
- package/dist/cjs/q-section.cjs.entry.js +2 -2
- package/dist/cjs/q-sidepanel.cjs.entry.js +5 -4
- package/dist/cjs/q-slider.cjs.entry.js +122 -0
- 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 +4 -4
- package/dist/cjs/q-syntax-box.cjs.entry.js +180 -719
- package/dist/cjs/q-syntax-view.cjs.entry.js +65 -0
- package/dist/cjs/q-tabs.cjs.entry.js +2 -2
- package/dist/cjs/q-textarea.cjs.entry.js +8 -6
- 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 +7 -7
- package/dist/cjs/q-toolbar.cjs.entry.js +4 -4
- package/dist/cjs/syntax-content-BmSExDiW.js +910 -0
- package/dist/cjs/{tokens-RMRaIOqv.js → tokens-BMrfol_M.js} +4 -1
- package/dist/cjs/webquark.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +6 -1
- package/dist/collection/components/actions/button/button.css +49 -9
- package/dist/collection/components/actions/button/{button.utils.unit.test.js → test/button.utils.unit.test.js} +1 -1
- package/dist/collection/components/communication/alert/alert.css +4 -1
- package/dist/collection/components/content/carousel/carousel.css +7 -0
- package/dist/collection/components/content/carousel/carousel.js +256 -10
- package/dist/collection/components/content/carousel/internals/autoplay.js +31 -6
- package/dist/collection/components/content/carousel/test/transitions.cmp.test.js +122 -0
- package/dist/collection/components/data-display/accordion/accordion.js +1 -1
- package/dist/collection/components/data-display/data-table/data-table.js +3 -3
- package/dist/collection/components/data-display/map/map.js +1 -1
- package/dist/collection/components/data-display/map/test/map.cmp.test.js +1 -1
- package/dist/collection/components/data-display/pagination/pagination.js +1 -1
- package/dist/collection/components/data-display/syntax-box/internals/formatters/css.js +4 -0
- package/dist/collection/components/data-display/syntax-box/internals/formatters/formatter.js +20 -0
- package/dist/collection/{utils → components/data-display/syntax-box/internals/formatters}/formatter.unit.test.js +38 -11
- package/dist/collection/components/data-display/syntax-box/internals/formatters/html.js +4 -0
- package/dist/collection/components/data-display/syntax-box/internals/formatters/javascript.js +4 -0
- package/dist/collection/{utils/formatter.js → components/data-display/syntax-box/internals/formatters/json.js} +2 -20
- package/dist/collection/components/data-display/syntax-box/internals/formatters/languages.js +15 -0
- package/dist/collection/components/data-display/syntax-box/internals/formatters/util/prettier.js +17 -0
- package/dist/collection/{utils → components/data-display/syntax-box/internals}/syntax.unit.test.js +1 -1
- package/dist/collection/components/data-display/syntax-box/internals/views.js +29 -0
- package/dist/collection/components/data-display/syntax-box/internals/views.unit.test.js +19 -0
- package/dist/collection/components/data-display/syntax-box/syntax-box.css +107 -36
- package/dist/collection/components/data-display/syntax-box/syntax-box.js +179 -637
- package/dist/collection/components/data-display/syntax-box/syntax-content.js +748 -0
- package/dist/collection/components/data-display/syntax-box/syntax-ui.js +8 -0
- package/dist/collection/components/data-display/syntax-box/test/format-fixtures.js +2 -2
- package/dist/collection/components/data-display/syntax-box/test/syntax-box.cmp.test.js +1 -1
- package/dist/collection/components/data-display/syntax-box/test/syntax-format.cmp.test.js +20 -20
- package/dist/collection/components/data-display/syntax-box/test/syntax-views.cmp.test.js +228 -0
- package/dist/collection/components/data-display/syntax-view/syntax-view.js +64 -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.css +148 -0
- package/dist/collection/components/inputs/dropdown/dropdown.js +422 -104
- package/dist/collection/components/inputs/dropdown/test/dropdown.cmp.test.js +28 -0
- package/dist/collection/components/inputs/dropdown/test/fit-options.cmp.test.js +120 -0
- package/dist/collection/components/inputs/dropdown/test/multiple.cmp.test.js +124 -0
- package/dist/collection/components/inputs/dropdown/test/search-mode.cmp.test.js +186 -0
- package/dist/collection/components/inputs/form/form.js +2 -2
- package/dist/collection/components/inputs/form/internals/controls.js +2 -2
- package/dist/collection/components/inputs/form/internals/field-state.js +6 -1
- package/dist/collection/components/inputs/form/internals/values.js +5 -0
- package/dist/collection/components/inputs/form/test/form-submit.cmp.test.js +14 -8
- package/dist/collection/components/inputs/input/input.css +42 -0
- package/dist/collection/components/inputs/input/input.js +31 -3
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.css +22 -0
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.js +4 -4
- package/dist/collection/components/inputs/radio-group/radio-group.js +2 -2
- package/dist/collection/components/inputs/slider/slider.css +44 -0
- package/dist/collection/components/inputs/slider/slider.js +383 -0
- package/dist/collection/components/inputs/slider/test/slider.cmp.test.js +45 -0
- package/dist/collection/components/inputs/textarea/textarea.css +20 -0
- package/dist/collection/components/inputs/textarea/textarea.js +30 -2
- package/dist/collection/components/inputs/toggle/test/toggle-layout.cmp.test.js +69 -0
- package/dist/collection/components/inputs/toggle/toggle.css +27 -0
- package/dist/collection/components/inputs/toggle/toggle.js +3 -3
- package/dist/collection/components/layout/control-group/control-group.css +108 -0
- package/dist/collection/components/layout/control-group/control-group.js +142 -0
- package/dist/collection/components/layout/control-group/test/control-group.cmp.test.js +163 -0
- package/dist/collection/components/layout/divider/divider.css +40 -0
- package/dist/collection/components/layout/divider/divider.js +121 -0
- package/dist/collection/components/layout/divider/test/divider.cmp.test.js +105 -0
- 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/nav-items.js +2 -2
- package/dist/collection/components/layout/sidepanel/sidepanel.js +3 -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/image-comparison/image-comparison.js +1 -1
- package/dist/collection/components/media/media/media.js +1 -1
- package/dist/collection/components/media/reel/reel.js +23 -23
- package/dist/collection/components/media/reel/test/focus.cmp.test.js +33 -0
- 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/tooltip.js +2 -2
- package/dist/collection/theme/test/input-width.cmp.test.js +117 -0
- package/dist/collection/theme/test/presets.unit.test.js +58 -0
- package/dist/collection/theme/tokens.js +4 -1
- package/dist/collection/utils/dom.js +1 -1
- package/dist/collection/utils/form-control-validity.js +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/p-B610wOGe.js +1 -0
- package/dist/components/p-BGlbV43y.js +13 -0
- package/dist/components/{p-Dfp_If-_.js → p-BKWL9zOn.js} +1 -1
- package/dist/components/p-BxxU73QQ.js +1 -0
- package/dist/components/{p-Cg0Mv7Vb.js → p-CVEQfA-v.js} +1 -1
- package/dist/components/p-CpbWWDiY.js +1 -0
- package/dist/{webquark/p-Dhsn99q4.js → components/p-D2fczi8m.js} +1 -1
- package/dist/components/{p-6PPZ2sIO.js → p-D5vpGqZ9.js} +1 -1
- package/dist/components/p-DQIYo8zC.js +1 -0
- package/dist/components/p-DX6PCIPS.js +1 -0
- package/dist/components/p-DY9D4z7Z.js +1 -0
- package/dist/components/p-DbzjRzhu.js +1 -0
- package/dist/components/{p-DQhiqYeq.js → p-DkanItP3.js} +1 -1
- package/dist/components/{p-CKuPOxKN.js → p-RX4DjgmV.js} +1 -1
- package/dist/components/{p-DlIn_ZWk.js → p-Ts5oOvg8.js} +1 -1
- package/dist/components/p-u1Qz6OcP.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-control-group.d.ts +11 -0
- package/dist/components/q-control-group.js +1 -0
- 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-divider.d.ts +11 -0
- package/dist/components/q-divider.js +1 -0
- 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.js +1 -1
- 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 +2 -2
- package/dist/components/q-slider.d.ts +11 -0
- package/dist/components/q-slider.js +1 -0
- 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 +1 -13
- package/dist/components/q-syntax-view.d.ts +11 -0
- package/dist/components/q-syntax-view.js +1 -0
- 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-CpnGza8z.js → action.props-CbSH7c-q.js} +1 -1
- package/dist/esm/{dom-ByfrUWx1.js → dom-B610wOGe.js} +2 -2
- package/dist/esm/{field-zfD6OQ02.js → field-D5xUxo11.js} +1 -1
- package/dist/esm/{form-control-validity-Bj2RJb2E.js → form-control-validity-BxxU73QQ.js} +3 -3
- package/dist/esm/{form-submit-action-CoEIvDqE.js → form-submit-action-BjjfVWyu.js} +1 -1
- package/dist/esm/{index-B5ElFlHv.js → index-CIMzZPQO.js} +16 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/q-accordion.entry.js +2 -2
- package/dist/esm/q-alert.entry.js +2 -2
- package/dist/esm/q-avatar.entry.js +2 -2
- package/dist/esm/q-banner.entry.js +1 -1
- package/dist/esm/q-button_3.entry.js +903 -0
- package/dist/esm/q-card.entry.js +3 -3
- package/dist/esm/q-carousel.entry.js +120 -18
- package/dist/esm/q-chip.entry.js +2 -2
- package/dist/esm/q-control-group.entry.js +62 -0
- package/dist/esm/q-conversation-bubble.entry.js +1 -1
- package/dist/esm/q-data-table.entry.js +4 -4
- package/dist/esm/q-dialog.entry.js +4 -4
- package/dist/esm/q-divider.entry.js +24 -0
- package/dist/esm/q-dropdown.entry.js +320 -104
- package/dist/esm/q-form.entry.js +18 -8
- package/dist/esm/q-grid.entry.js +3 -3
- package/dist/esm/q-icon.entry.js +1 -1
- package/dist/esm/q-image-comparison.entry.js +2 -2
- package/dist/esm/q-inline.entry.js +3 -3
- package/dist/esm/q-input_2.entry.js +10 -8
- package/dist/esm/q-link.entry.js +2 -2
- package/dist/esm/q-map.entry.js +2 -2
- package/dist/esm/q-media.entry.js +2 -2
- 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 +7 -7
- package/dist/esm/q-quantity-selector.entry.js +6 -6
- package/dist/esm/q-radio-group.entry.js +4 -4
- package/dist/esm/q-reel.entry.js +24 -24
- package/dist/esm/q-section.entry.js +2 -2
- package/dist/esm/q-sidepanel.entry.js +5 -4
- package/dist/esm/q-slider.entry.js +120 -0
- 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 +4 -4
- package/dist/esm/q-syntax-box.entry.js +180 -719
- package/dist/esm/q-syntax-view.entry.js +63 -0
- package/dist/esm/q-tabs.entry.js +2 -2
- package/dist/esm/q-textarea.entry.js +8 -6
- 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 +7 -7
- package/dist/esm/q-toolbar.entry.js +4 -4
- package/dist/esm/syntax-content-Cr9kSbmA.js +903 -0
- package/dist/esm/{tokens-B4Mg1xEw.js → tokens-DbzjRzhu.js} +4 -1
- package/dist/esm/webquark.js +3 -3
- package/dist/formatters/prettier/LICENSE +7 -0
- package/dist/formatters/prettier/THIRD-PARTY-NOTICES.md +7941 -0
- package/dist/formatters/prettier/html-fragment.mjs +1 -0
- package/dist/formatters/prettier/html-fragment.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/angular.mjs +1 -0
- package/dist/formatters/prettier/languages/angular.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/css.mjs +1 -0
- package/dist/formatters/prettier/languages/css.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/flow.mjs +1 -0
- package/dist/formatters/prettier/languages/flow.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/graphql.mjs +1 -0
- package/dist/formatters/prettier/languages/graphql.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/handlebars.mjs +1 -0
- package/dist/formatters/prettier/languages/handlebars.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/html.mjs +1 -0
- package/dist/formatters/prettier/languages/html.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/javascript.mjs +1 -0
- package/dist/formatters/prettier/languages/javascript.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/json-stringify.mjs +1 -0
- package/dist/formatters/prettier/languages/json-stringify.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/json.mjs +1 -0
- package/dist/formatters/prettier/languages/json.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/json5.mjs +1 -0
- package/dist/formatters/prettier/languages/json5.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/jsonc.mjs +1 -0
- package/dist/formatters/prettier/languages/jsonc.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/jsx.mjs +1 -0
- package/dist/formatters/prettier/languages/jsx.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/less.mjs +1 -0
- package/dist/formatters/prettier/languages/less.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/lwc.mjs +1 -0
- package/dist/formatters/prettier/languages/lwc.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/markdown.mjs +1 -0
- package/dist/formatters/prettier/languages/markdown.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/mdx.mjs +1 -0
- package/dist/formatters/prettier/languages/mdx.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/mjml.mjs +1 -0
- package/dist/formatters/prettier/languages/mjml.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/postcss.mjs +1 -0
- package/dist/formatters/prettier/languages/postcss.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/scss.mjs +1 -0
- package/dist/formatters/prettier/languages/scss.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/tsx.mjs +1 -0
- package/dist/formatters/prettier/languages/tsx.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/typescript.mjs +1 -0
- package/dist/formatters/prettier/languages/typescript.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/vue.mjs +1 -0
- package/dist/formatters/prettier/languages/vue.mjs.gz +0 -0
- package/dist/formatters/prettier/languages/yaml.mjs +1 -0
- package/dist/formatters/prettier/languages/yaml.mjs.gz +0 -0
- package/dist/formatters/prettier/manifest.json +87 -0
- package/dist/formatters/prettier/plugins/acorn.mjs +17 -0
- package/dist/formatters/prettier/plugins/acorn.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/angular.mjs +7 -0
- package/dist/formatters/prettier/plugins/angular.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/babel.mjs +16 -0
- package/dist/formatters/prettier/plugins/babel.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/estree.mjs +44 -0
- package/dist/formatters/prettier/plugins/estree.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/flow.mjs +7 -0
- package/dist/formatters/prettier/plugins/flow.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/glimmer.mjs +37 -0
- package/dist/formatters/prettier/plugins/glimmer.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/graphql.mjs +17 -0
- package/dist/formatters/prettier/plugins/graphql.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/html.mjs +25 -0
- package/dist/formatters/prettier/plugins/html.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/markdown.mjs +70 -0
- package/dist/formatters/prettier/plugins/markdown.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/meriyah.mjs +9 -0
- package/dist/formatters/prettier/plugins/meriyah.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/postcss.mjs +62 -0
- package/dist/formatters/prettier/plugins/postcss.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/typescript.mjs +22 -0
- package/dist/formatters/prettier/plugins/typescript.mjs.gz +0 -0
- package/dist/formatters/prettier/plugins/yaml.mjs +150 -0
- package/dist/formatters/prettier/plugins/yaml.mjs.gz +0 -0
- package/dist/formatters/prettier/runtime.d.mts +2 -0
- package/dist/formatters/prettier/runtime.mjs +1 -0
- package/dist/formatters/prettier/runtime.mjs.gz +0 -0
- package/dist/formatters/prettier/standalone.mjs +29 -0
- package/dist/formatters/prettier/standalone.mjs.gz +0 -0
- package/dist/playground/components/theme-designer/dimension-tokens.js +9 -0
- package/dist/playground/components/theme-designer/token-row.js +60 -0
- package/dist/playground/dom-factory.js +76 -0
- package/dist/playground/utils/color.js +15 -0
- package/dist/playground/utils/dom.js +38 -0
- package/dist/playground/utils/index.js +2 -0
- package/dist/types/components/content/carousel/carousel.d.ts +23 -2
- package/dist/types/components/content/carousel/carousel.types.d.ts +6 -0
- package/dist/types/components/content/carousel/internals/autoplay.d.ts +5 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/css.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/formatter.d.ts +10 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/formatter.types.d.ts +4 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/html.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/javascript.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/json.d.ts +6 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/languages.d.ts +27 -0
- package/dist/types/components/data-display/syntax-box/internals/formatters/util/prettier.d.ts +3 -0
- package/dist/types/{utils → components/data-display/syntax-box/internals}/syntax.d.ts +1 -1
- package/dist/types/components/data-display/syntax-box/internals/syntax.unit.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/internals/views.d.ts +11 -0
- package/dist/types/components/data-display/syntax-box/internals/views.unit.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/syntax-box.d.ts +66 -63
- package/dist/types/components/data-display/syntax-box/syntax-box.types.d.ts +1 -1
- package/dist/types/components/data-display/syntax-box/syntax-content.d.ts +41 -0
- package/dist/types/components/data-display/syntax-box/syntax-ui.d.ts +15 -0
- package/dist/types/components/data-display/syntax-box/test/format-fixtures.d.ts +1 -1
- package/dist/types/components/data-display/syntax-box/test/syntax-views.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-view/syntax-view.d.ts +48 -0
- package/dist/types/components/inputs/dropdown/dropdown.d.ts +45 -1
- package/dist/types/components/inputs/dropdown/test/fit-options.cmp.test.d.ts +3 -0
- package/dist/types/components/inputs/dropdown/test/multiple.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/dropdown/test/search-mode.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/internals/field-state.d.ts +1 -1
- package/dist/types/components/inputs/input/input.d.ts +3 -0
- package/dist/types/components/inputs/slider/slider.d.ts +45 -0
- package/dist/types/components/inputs/slider/test/slider.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/textarea/textarea.d.ts +3 -1
- package/dist/types/components/inputs/toggle/test/toggle-layout.cmp.test.d.ts +1 -0
- package/dist/types/components/layout/control-group/control-group.d.ts +20 -0
- package/dist/types/components/layout/control-group/test/control-group.cmp.test.d.ts +7 -0
- package/dist/types/components/layout/divider/divider.d.ts +15 -0
- package/dist/types/components/layout/divider/test/divider.cmp.test.d.ts +1 -0
- package/dist/types/components/layout/sidepanel/sidepanel.d.ts +2 -0
- package/dist/types/components/layout/sidepanel/sidepanel.types.d.ts +1 -0
- package/dist/types/components/media/reel/reel.d.ts +3 -3
- package/dist/types/components/media/reel/test/focus.cmp.test.d.ts +1 -0
- package/dist/types/components.d.ts +591 -13
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/components/theme-designer/dimension-tokens.d.ts +3 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/components/theme-designer/token-row.d.ts +14 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/dom-factory.d.ts +13 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/color.d.ts +2 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/dom.d.ts +15 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/theme/test/input-width.cmp.test.d.ts +3 -0
- package/dist/types/theme/test/presets.unit.test.d.ts +1 -0
- package/dist/types/theme/tokens.d.ts +9 -0
- package/dist/types/utils/form-control-validity.d.ts +2 -1
- package/dist/types/utils/form-field-adapter.d.ts +3 -3
- package/dist/webquark/p-014c2f4a.entry.js +1 -0
- package/dist/webquark/p-0389577c.entry.js +1 -0
- package/dist/webquark/p-041e17c1.entry.js +1 -0
- package/dist/webquark/p-0479c571.entry.js +1 -0
- package/dist/webquark/p-0ebca9be.entry.js +1 -0
- package/dist/webquark/{p-fe8c634a.entry.js → p-1bf375f7.entry.js} +2 -2
- package/dist/webquark/{p-6bfffa79.entry.js → p-20dc3ab5.entry.js} +1 -1
- package/dist/webquark/p-28d3348f.entry.js +1 -0
- package/dist/webquark/p-35c177d3.entry.js +1 -0
- package/dist/webquark/{p-99d785ca.entry.js → p-3a60086d.entry.js} +1 -1
- package/dist/webquark/{p-3bc4629c.entry.js → p-3ab798aa.entry.js} +1 -1
- package/dist/webquark/{p-9e78b796.entry.js → p-3b580baf.entry.js} +1 -1
- package/dist/webquark/{p-888e46a8.entry.js → p-3b65f787.entry.js} +1 -1
- package/dist/webquark/p-4bf610f8.entry.js +1 -0
- package/dist/webquark/{p-4d61b70d.entry.js → p-4d30227e.entry.js} +1 -1
- package/dist/webquark/{p-70d9ffde.entry.js → p-4de536ae.entry.js} +1 -1
- package/dist/webquark/{p-90b0858c.entry.js → p-4e4d70c9.entry.js} +1 -1
- package/dist/webquark/p-4efeb7c9.entry.js +1 -0
- package/dist/webquark/{p-dd115868.entry.js → p-51b3d71b.entry.js} +1 -1
- package/dist/webquark/p-778b6bbb.entry.js +1 -0
- package/dist/webquark/{p-f63b7214.entry.js → p-7da78b2f.entry.js} +1 -1
- package/dist/webquark/{p-9ff7e5a4.entry.js → p-7f8f986b.entry.js} +1 -1
- package/dist/webquark/p-8253c742.entry.js +1 -0
- package/dist/webquark/{p-059daa8a.entry.js → p-9a1ddeb7.entry.js} +1 -1
- package/dist/webquark/p-B610wOGe.js +1 -0
- package/dist/webquark/p-BxxU73QQ.js +1 -0
- package/dist/webquark/p-CIMzZPQO.js +3 -0
- package/dist/webquark/p-CfR85WgM.js +13 -0
- package/dist/{components/p-BofcK-7Z.js → webquark/p-D8p28N9s.js} +1 -1
- package/dist/webquark/p-DbzjRzhu.js +1 -0
- package/dist/webquark/{p-BOdNg0jc.js → p-DeOEN0si.js} +1 -1
- package/dist/webquark/{p-d0fbd2b1.entry.js → p-a2b1de23.entry.js} +1 -1
- package/dist/webquark/{p-48fb5228.entry.js → p-a55edc17.entry.js} +1 -1
- package/dist/webquark/p-a8808020.entry.js +1 -0
- package/dist/webquark/{p-f4f97e74.entry.js → p-b1084b3c.entry.js} +1 -1
- package/dist/webquark/{p-36118d90.entry.js → p-b6c4dff4.entry.js} +1 -1
- package/dist/webquark/p-b962e950.entry.js +1 -0
- package/dist/webquark/{p-023f8437.entry.js → p-bc369cd6.entry.js} +1 -1
- package/dist/webquark/p-c119a8ea.entry.js +1 -0
- package/dist/webquark/p-c6b77e9a.entry.js +1 -0
- package/dist/webquark/{p-030ecde3.entry.js → p-ca1c03b4.entry.js} +1 -1
- package/dist/webquark/{p-8ece2c62.entry.js → p-ce436162.entry.js} +1 -1
- package/dist/webquark/{p-0aa74ad6.entry.js → p-d0a47a7c.entry.js} +1 -1
- package/dist/webquark/{p-fec6fe0a.entry.js → p-e1fbc8fc.entry.js} +1 -1
- package/dist/webquark/{p-09cca7b9.entry.js → p-e32833ce.entry.js} +1 -1
- package/dist/webquark/p-e369a4aa.entry.js +1 -0
- package/dist/webquark/p-e4430c61.entry.js +1 -0
- package/dist/webquark/{p-f9ad63ff.entry.js → p-e9c0052b.entry.js} +1 -1
- package/dist/webquark/{p-f1bac94c.entry.js → p-f5c4ca18.entry.js} +1 -1
- package/dist/webquark/{p-64096386.entry.js → p-f6683126.entry.js} +1 -1
- package/dist/webquark/{p-DWO-pleQ.js → p-ojSDiptZ.js} +1 -1
- package/dist/webquark/webquark.css +1 -1
- package/dist/webquark/webquark.esm.js +1 -1
- package/package.json +6 -2
- package/dist/cjs/q-button_2.cjs.entry.js +0 -462
- package/dist/cjs/q-scrollable.cjs.entry.js +0 -449
- package/dist/components/p-B4Mg1xEw.js +0 -1
- package/dist/components/p-BH4gQWub.js +0 -1
- package/dist/components/p-Bj2RJb2E.js +0 -1
- package/dist/components/p-ByfrUWx1.js +0 -1
- package/dist/components/p-CN1ut2Lb.js +0 -1
- package/dist/components/p-ye27qtRo.js +0 -1
- package/dist/esm/q-button_2.entry.js +0 -459
- package/dist/esm/q-scrollable.entry.js +0 -447
- package/dist/types/utils/formatter.d.ts +0 -15
- package/dist/webquark/p-04c8cb9e.entry.js +0 -1
- package/dist/webquark/p-0ae43d6c.entry.js +0 -1
- package/dist/webquark/p-0c3aac3f.entry.js +0 -1
- package/dist/webquark/p-144ef339.entry.js +0 -1
- package/dist/webquark/p-296fbdb1.entry.js +0 -1
- package/dist/webquark/p-5f232b44.entry.js +0 -13
- package/dist/webquark/p-6e28cfe2.entry.js +0 -1
- package/dist/webquark/p-91fff6b6.entry.js +0 -1
- package/dist/webquark/p-923dac41.entry.js +0 -1
- package/dist/webquark/p-97a89cae.entry.js +0 -1
- package/dist/webquark/p-B4Mg1xEw.js +0 -1
- package/dist/webquark/p-B5ElFlHv.js +0 -3
- package/dist/webquark/p-Bj2RJb2E.js +0 -1
- package/dist/webquark/p-ByfrUWx1.js +0 -1
- package/dist/webquark/p-c523ec6f.entry.js +0 -1
- package/dist/webquark/p-d0253d64.entry.js +0 -1
- package/dist/webquark/p-f98f9439.entry.js +0 -1
- package/dist/webquark/p-fe200f68.entry.js +0 -1
- /package/dist/{types/components/actions/button/button.utils.unit.test.d.ts → collection/components/data-display/syntax-box/internals/formatters/formatter.types.js} +0 -0
- /package/dist/collection/{utils → components/data-display/syntax-box/internals}/syntax.js +0 -0
- /package/dist/types/{utils/formatter.unit.test.d.ts → components/actions/button/test/button.utils.unit.test.d.ts} +0 -0
- /package/dist/types/{utils/syntax.unit.test.d.ts → components/data-display/syntax-box/internals/formatters/formatter.unit.test.d.ts} +0 -0
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-BN-WdOQM.js');
|
|
4
|
+
var formFieldAdapter = require('./form-field-adapter-D0CJ6poh.js');
|
|
5
|
+
var formFieldState = require('./form-field-state-P63wN30v.js');
|
|
6
|
+
var formControlValidity = require('./form-control-validity-BkilGb3E.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license @lucide/icons v1.54.0 - ISC
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the ISC license.
|
|
12
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const Braces = {
|
|
16
|
+
name: "braces",
|
|
17
|
+
size: 24,
|
|
18
|
+
node: [
|
|
19
|
+
[
|
|
20
|
+
"path",
|
|
21
|
+
{ d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1", key: "ezmyqa" }
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",
|
|
27
|
+
key: "e1hn23"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
],
|
|
31
|
+
aliases: ["curly-braces"]
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @license @lucide/icons v1.54.0 - ISC
|
|
36
|
+
*
|
|
37
|
+
* This source code is licensed under the ISC license.
|
|
38
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const Check = {
|
|
42
|
+
name: "check",
|
|
43
|
+
size: 24,
|
|
44
|
+
node: [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @license @lucide/icons v1.54.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
const Copy = {
|
|
55
|
+
name: "copy",
|
|
56
|
+
size: 24,
|
|
57
|
+
node: [
|
|
58
|
+
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
|
|
59
|
+
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Stencil can load the box and its child views from independently bundled entry points.
|
|
64
|
+
const registryKey = Symbol.for('@webquark/browser:syntax-views:v1');
|
|
65
|
+
const runtime = globalThis;
|
|
66
|
+
const { syntaxBoxes, syntaxScrollRestorers, syntaxVisibility } = runtime[registryKey] ??= {
|
|
67
|
+
syntaxBoxes: new WeakMap(),
|
|
68
|
+
syntaxScrollRestorers: new WeakMap(),
|
|
69
|
+
syntaxVisibility: new WeakMap(),
|
|
70
|
+
};
|
|
71
|
+
function syntaxOwner(view) {
|
|
72
|
+
return syntaxBoxes.get(view) ?? (view.localName === 'q-syntax-view' && view.parentElement
|
|
73
|
+
? syntaxBoxes.get(view.parentElement)
|
|
74
|
+
: undefined);
|
|
75
|
+
}
|
|
76
|
+
function revealSyntaxEditor(editor) {
|
|
77
|
+
const ancestors = [];
|
|
78
|
+
for (let node = editor; node; node = node.parentElement) {
|
|
79
|
+
if (node === editor || node.localName === 'q-syntax-view')
|
|
80
|
+
ancestors.push(node);
|
|
81
|
+
}
|
|
82
|
+
for (const view of ancestors.reverse())
|
|
83
|
+
syntaxOwner(view)?.select(view);
|
|
84
|
+
}
|
|
85
|
+
function ownContentNodes(host) {
|
|
86
|
+
return Array.from(host.childNodes).filter(node => node.nodeType === 3 ||
|
|
87
|
+
(node instanceof Element && !node.slot && node.localName !== 'q-syntax-view'));
|
|
88
|
+
}
|
|
89
|
+
function hasSlottedSource(host) {
|
|
90
|
+
return ownContentNodes(host).some(node => node.nodeType === 1 || Boolean(node.textContent?.trim()));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function renderSyntaxActions(actions) {
|
|
94
|
+
return (index.h("div", { class: "panel-actions", ref: actions.ref }, index.h("slot", { name: "actions" }), actions.editable && actions.formatLabel && (index.h("q-button", { class: "format-btn", ariaLabel: actions.formatLabel, variant: "ghost", size: "sm", disabled: actions.disabled, onClick: actions.onFormat }, index.h("q-icon", { slot: "icon-left", definition: Braces, name: "braces", size: "sm" }), index.h("q-tooltip", { slot: "icon-left", position: "bottom", content: actions.formatLabel }))), actions.copyable && (index.h("q-button", { variant: "ghost", size: "sm", ariaLabel: actions.copyFeedback, disabled: actions.disabled, onClick: actions.onCopy }, index.h("q-icon", { slot: "icon-left", definition: actions.copied ? Check : Copy, name: actions.copied ? 'check' : 'copy', size: "sm" }), index.h("q-tooltip", { slot: "icon-left", position: "bottom", content: actions.copyFeedback })))));
|
|
95
|
+
}
|
|
96
|
+
function renderSyntaxScroller(body, height, ref) {
|
|
97
|
+
return index.h("q-scrollable", { height: height, ref: ref }, body);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getSyntaxBoxCopyText(code, fallbackText) {
|
|
101
|
+
return code !== undefined ? code : fallbackText || '';
|
|
102
|
+
}
|
|
103
|
+
async function writeClipboardText(text) {
|
|
104
|
+
if (!navigator.clipboard || typeof navigator.clipboard.writeText !== 'function') {
|
|
105
|
+
throw new Error('Clipboard API unavailable');
|
|
106
|
+
}
|
|
107
|
+
await navigator.clipboard.writeText(text);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getSyntaxBoxEditorKeyAction(event, value, start, end) {
|
|
111
|
+
if (event.key === 'Escape') {
|
|
112
|
+
return { type: 'blur' };
|
|
113
|
+
}
|
|
114
|
+
if (event.key !== 'Tab' || event.shiftKey || event.ctrlKey || event.metaKey || event.altKey) {
|
|
115
|
+
return { type: 'none' };
|
|
116
|
+
}
|
|
117
|
+
const spaces = ' ';
|
|
118
|
+
return {
|
|
119
|
+
type: 'indent',
|
|
120
|
+
value: value.substring(0, start) + spaces + value.substring(end),
|
|
121
|
+
caret: start + spaces.length,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const MAX_JSON_FORMAT_INPUT = 1_048_576;
|
|
126
|
+
const MAX_JSON_FORMAT_OUTPUT = 2_097_152;
|
|
127
|
+
const MAX_JSON_FORMAT_DEPTH = 128;
|
|
128
|
+
class FormatLimitError extends Error {
|
|
129
|
+
}
|
|
130
|
+
/** Validates JSON grammar while emitting original tokens, never JavaScript values. */
|
|
131
|
+
function layoutJson(source) {
|
|
132
|
+
if (source.length > MAX_JSON_FORMAT_INPUT) {
|
|
133
|
+
throw new FormatLimitError();
|
|
134
|
+
}
|
|
135
|
+
let index = 0;
|
|
136
|
+
let outputLength = 0;
|
|
137
|
+
const parts = [];
|
|
138
|
+
const emit = (text) => {
|
|
139
|
+
outputLength += text.length;
|
|
140
|
+
if (outputLength > MAX_JSON_FORMAT_OUTPUT) {
|
|
141
|
+
throw new FormatLimitError();
|
|
142
|
+
}
|
|
143
|
+
parts.push(text);
|
|
144
|
+
};
|
|
145
|
+
const whitespace = () => {
|
|
146
|
+
while (/[\x20\t\r\n]/.test(source.charAt(index)) && index < source.length) {
|
|
147
|
+
index++;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const requireCharacter = (character) => {
|
|
151
|
+
if (source[index++] !== character) {
|
|
152
|
+
throw new SyntaxError('Invalid JSON.');
|
|
153
|
+
}
|
|
154
|
+
whitespace();
|
|
155
|
+
};
|
|
156
|
+
const stringToken = () => {
|
|
157
|
+
const start = index;
|
|
158
|
+
if (source[index++] !== '"') {
|
|
159
|
+
throw new SyntaxError('Invalid JSON string.');
|
|
160
|
+
}
|
|
161
|
+
while (index < source.length) {
|
|
162
|
+
const character = source[index++];
|
|
163
|
+
if (character === '"') {
|
|
164
|
+
return source.slice(start, index);
|
|
165
|
+
}
|
|
166
|
+
if (character.charCodeAt(0) < 0x20) {
|
|
167
|
+
throw new SyntaxError('Invalid JSON string.');
|
|
168
|
+
}
|
|
169
|
+
if (character === '\\') {
|
|
170
|
+
const escaped = source[index++];
|
|
171
|
+
if (escaped === 'u') {
|
|
172
|
+
if (!/^[\da-fA-F]{4}$/.test(source.slice(index, index + 4))) {
|
|
173
|
+
throw new SyntaxError('Invalid JSON escape.');
|
|
174
|
+
}
|
|
175
|
+
index += 4;
|
|
176
|
+
}
|
|
177
|
+
else if (!escaped || !'"\\/bfnrt'.includes(escaped)) {
|
|
178
|
+
throw new SyntaxError('Invalid JSON escape.');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
throw new SyntaxError('Unterminated JSON string.');
|
|
183
|
+
};
|
|
184
|
+
const newline = (depth) => emit('\n' + ' '.repeat(depth));
|
|
185
|
+
const value = (depth) => {
|
|
186
|
+
whitespace();
|
|
187
|
+
const character = source[index];
|
|
188
|
+
if (character === '{' || character === '[') {
|
|
189
|
+
if (depth >= MAX_JSON_FORMAT_DEPTH) {
|
|
190
|
+
throw new FormatLimitError();
|
|
191
|
+
}
|
|
192
|
+
const object = character === '{';
|
|
193
|
+
const close = object ? '}' : ']';
|
|
194
|
+
index++;
|
|
195
|
+
emit(character);
|
|
196
|
+
whitespace();
|
|
197
|
+
if (source[index] === close) {
|
|
198
|
+
index++;
|
|
199
|
+
emit(close);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
newline(depth + 1);
|
|
203
|
+
while (true) {
|
|
204
|
+
if (object) {
|
|
205
|
+
emit(stringToken());
|
|
206
|
+
whitespace();
|
|
207
|
+
requireCharacter(':');
|
|
208
|
+
emit(': ');
|
|
209
|
+
}
|
|
210
|
+
value(depth + 1);
|
|
211
|
+
whitespace();
|
|
212
|
+
if (source[index] === close) {
|
|
213
|
+
index++;
|
|
214
|
+
newline(depth);
|
|
215
|
+
emit(close);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
requireCharacter(',');
|
|
219
|
+
emit(',');
|
|
220
|
+
newline(depth + 1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (character === '"') {
|
|
224
|
+
emit(stringToken());
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
for (const literal of ['true', 'false', 'null']) {
|
|
228
|
+
if (source.startsWith(literal, index)) {
|
|
229
|
+
index += literal.length;
|
|
230
|
+
emit(literal);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const start = index;
|
|
235
|
+
while (index < source.length && /[\d.eE+-]/.test(source[index])) {
|
|
236
|
+
index++;
|
|
237
|
+
}
|
|
238
|
+
const token = source.slice(start, index);
|
|
239
|
+
if (!/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(token)) {
|
|
240
|
+
throw new SyntaxError('Invalid JSON value.');
|
|
241
|
+
}
|
|
242
|
+
emit(token);
|
|
243
|
+
};
|
|
244
|
+
value(0);
|
|
245
|
+
whitespace();
|
|
246
|
+
if (index !== source.length) {
|
|
247
|
+
throw new SyntaxError('Trailing JSON content.');
|
|
248
|
+
}
|
|
249
|
+
return parts.join('');
|
|
250
|
+
}
|
|
251
|
+
function formatJsonSource(code) {
|
|
252
|
+
try {
|
|
253
|
+
const formatted = layoutJson(code);
|
|
254
|
+
return { code: formatted, status: formatted === code ? 'unchanged' : 'formatted' };
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
return { code, status: error instanceof FormatLimitError ? 'unsupported' : 'invalid' };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// The keys are the language values accepted by both Syntax Box and Syntax View.
|
|
262
|
+
const formatterLanguages = {
|
|
263
|
+
html: 'HTML', javascript: 'JavaScript', css: 'CSS', json: 'JSON',
|
|
264
|
+
typescript: 'TypeScript', jsx: 'JSX', tsx: 'TSX', flow: 'Flow',
|
|
265
|
+
json5: 'JSON5', jsonc: 'JSON with Comments', 'json-stringify': 'JSON.stringify',
|
|
266
|
+
postcss: 'PostCSS', less: 'Less', scss: 'SCSS',
|
|
267
|
+
angular: 'Angular', vue: 'Vue', lwc: 'Lightning Web Components', mjml: 'MJML',
|
|
268
|
+
handlebars: 'Handlebars', graphql: 'GraphQL', markdown: 'Markdown', mdx: 'MDX', yaml: 'YAML',
|
|
269
|
+
};
|
|
270
|
+
function formatterLanguage(value) {
|
|
271
|
+
const key = typeof value === 'string' ? value.toLowerCase() : '';
|
|
272
|
+
if (key === 'js')
|
|
273
|
+
return 'javascript';
|
|
274
|
+
return Object.prototype.hasOwnProperty.call(formatterLanguages, key) ? key : undefined;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function formatPrettierSource(code, language) {
|
|
278
|
+
let format;
|
|
279
|
+
try {
|
|
280
|
+
const formatter = await import('../formatters/prettier/runtime.mjs');
|
|
281
|
+
format = await formatter.loadFormatter(language);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return { code, status: 'unavailable' };
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const formatted = await format(code);
|
|
288
|
+
return { code: formatted, status: formatted === code ? 'unchanged' : 'formatted' };
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
return { code, status: error instanceof SyntaxError ? 'invalid' : 'failed' };
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function formatSource(code, language) {
|
|
296
|
+
const selected = formatterLanguage(language);
|
|
297
|
+
if (!selected)
|
|
298
|
+
return { code, status: 'unsupported' };
|
|
299
|
+
return selected === 'json' ? formatJsonSource(code) : formatPrettierSource(code, selected);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Each token and gap is an unchanged slice of the source; generated markup is never scanned. */
|
|
303
|
+
function scan(text, pattern, classify) {
|
|
304
|
+
const tokens = [];
|
|
305
|
+
let offset = 0;
|
|
306
|
+
let match;
|
|
307
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
308
|
+
if (offset < match.index)
|
|
309
|
+
tokens.push({ text: text.slice(offset, match.index) });
|
|
310
|
+
tokens.push({ text: match[0], className: classify(match) });
|
|
311
|
+
offset = match.index + match[0].length;
|
|
312
|
+
}
|
|
313
|
+
if (offset < text.length)
|
|
314
|
+
tokens.push({ text: text.slice(offset) });
|
|
315
|
+
return tokens;
|
|
316
|
+
}
|
|
317
|
+
/** Keep unhighlighted runs together so long edits do not create a text node per character. */
|
|
318
|
+
function tokenWriter(text) {
|
|
319
|
+
const tokens = [];
|
|
320
|
+
let plainStart = 0;
|
|
321
|
+
return {
|
|
322
|
+
emit(start, end, className) {
|
|
323
|
+
if (plainStart < start)
|
|
324
|
+
tokens.push({ text: text.slice(plainStart, start) });
|
|
325
|
+
tokens.push({ text: text.slice(start, end), className });
|
|
326
|
+
plainStart = end;
|
|
327
|
+
},
|
|
328
|
+
finish() {
|
|
329
|
+
if (plainStart < text.length)
|
|
330
|
+
tokens.push({ text: text.slice(plainStart) });
|
|
331
|
+
return tokens;
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function isLetter(char) {
|
|
336
|
+
return char >= 'a' && char <= 'z' || char >= 'A' && char <= 'Z';
|
|
337
|
+
}
|
|
338
|
+
function isDigit(char) {
|
|
339
|
+
return char >= '0' && char <= '9';
|
|
340
|
+
}
|
|
341
|
+
function isWord(char) {
|
|
342
|
+
return isLetter(char) || isDigit(char) || char === '_';
|
|
343
|
+
}
|
|
344
|
+
function skipWhitespace(text, offset) {
|
|
345
|
+
while (offset < text.length && /\s/.test(text[offset]))
|
|
346
|
+
offset++;
|
|
347
|
+
return offset;
|
|
348
|
+
}
|
|
349
|
+
function quotedEnd(text, start, escaped) {
|
|
350
|
+
const quote = text[start];
|
|
351
|
+
let offset = start + 1;
|
|
352
|
+
while (offset < text.length) {
|
|
353
|
+
if (escaped && text[offset] === '\\')
|
|
354
|
+
offset = Math.min(text.length, offset + 2);
|
|
355
|
+
else if (text[offset++] === quote)
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
return offset;
|
|
359
|
+
}
|
|
360
|
+
/** Consume each name once instead of retrying an attribute lookahead at every suffix. */
|
|
361
|
+
function tokenizeHtml(text) {
|
|
362
|
+
const writer = tokenWriter(text);
|
|
363
|
+
let offset = 0;
|
|
364
|
+
while (offset < text.length) {
|
|
365
|
+
const start = offset;
|
|
366
|
+
const char = text[offset];
|
|
367
|
+
if (text.startsWith('<!--', offset)) {
|
|
368
|
+
const end = text.indexOf('-->', offset + 4);
|
|
369
|
+
offset = end === -1 ? text.length : end + 3;
|
|
370
|
+
writer.emit(start, offset, 'code-comment');
|
|
371
|
+
}
|
|
372
|
+
else if (char === '<' && isLetter(text[offset + (text[offset + 1] === '/' ? 2 : 1)])) {
|
|
373
|
+
offset += text[offset + 1] === '/' ? 3 : 2;
|
|
374
|
+
while (offset < text.length && (isWord(text[offset]) || text[offset] === ':' || text[offset] === '-'))
|
|
375
|
+
offset++;
|
|
376
|
+
writer.emit(start, offset, 'code-tag');
|
|
377
|
+
}
|
|
378
|
+
else if (char === '"' || char === "'") {
|
|
379
|
+
// HTML uses entities for embedded quotes; a backslash does not escape its delimiter.
|
|
380
|
+
offset = quotedEnd(text, start, false);
|
|
381
|
+
writer.emit(start, offset, 'code-value');
|
|
382
|
+
}
|
|
383
|
+
else if (char === '>' || char === '/' && text[offset + 1] === '>') {
|
|
384
|
+
offset += char === '/' ? 2 : 1;
|
|
385
|
+
writer.emit(start, offset, 'code-tag');
|
|
386
|
+
}
|
|
387
|
+
else if (isWord(char) || char === ':' || char === '-') {
|
|
388
|
+
offset++;
|
|
389
|
+
while (offset < text.length && (isWord(text[offset]) || text[offset] === ':' || text[offset] === '-'))
|
|
390
|
+
offset++;
|
|
391
|
+
if (text[skipWhitespace(text, offset)] === '=')
|
|
392
|
+
writer.emit(start, offset, 'code-attr');
|
|
393
|
+
}
|
|
394
|
+
else
|
|
395
|
+
offset++;
|
|
396
|
+
}
|
|
397
|
+
return writer.finish();
|
|
398
|
+
}
|
|
399
|
+
const JAVASCRIPT_KEYWORDS = new Set([
|
|
400
|
+
'const', 'let', 'var', 'function', 'return', 'if', 'else', 'for', 'while', 'do', 'switch', 'case',
|
|
401
|
+
'break', 'continue', 'class', 'export', 'import', 'from', 'new', 'this', 'typeof', 'instanceof',
|
|
402
|
+
'try', 'catch', 'finally', 'throw', 'async', 'await', 'null', 'undefined', 'true', 'false',
|
|
403
|
+
]);
|
|
404
|
+
/** Consume strings/comments before identifiers so their contents are never scanned as code. */
|
|
405
|
+
function tokenizeJavascript(text) {
|
|
406
|
+
const writer = tokenWriter(text);
|
|
407
|
+
let offset = 0;
|
|
408
|
+
while (offset < text.length) {
|
|
409
|
+
const start = offset;
|
|
410
|
+
const char = text[offset];
|
|
411
|
+
if (char === '/' && text[offset + 1] === '/') {
|
|
412
|
+
offset += 2;
|
|
413
|
+
while (offset < text.length && !/[\r\n\u2028\u2029]/.test(text[offset]))
|
|
414
|
+
offset++;
|
|
415
|
+
writer.emit(start, offset, 'code-comment');
|
|
416
|
+
}
|
|
417
|
+
else if (char === '/' && text[offset + 1] === '*') {
|
|
418
|
+
const end = text.indexOf('*/', offset + 2);
|
|
419
|
+
offset = end === -1 ? text.length : end + 2;
|
|
420
|
+
writer.emit(start, offset, 'code-comment');
|
|
421
|
+
}
|
|
422
|
+
else if (char === '"' || char === "'" || char === '`') {
|
|
423
|
+
offset = quotedEnd(text, start, true);
|
|
424
|
+
writer.emit(start, offset, 'code-value');
|
|
425
|
+
}
|
|
426
|
+
else if (isLetter(char) || char === '_' || char === '$') {
|
|
427
|
+
offset++;
|
|
428
|
+
while (offset < text.length && (isWord(text[offset]) || text[offset] === '$'))
|
|
429
|
+
offset++;
|
|
430
|
+
if (JAVASCRIPT_KEYWORDS.has(text.slice(start, offset)))
|
|
431
|
+
writer.emit(start, offset, 'code-tag');
|
|
432
|
+
else if (text[skipWhitespace(text, offset)] === '(')
|
|
433
|
+
writer.emit(start, offset, 'code-attr');
|
|
434
|
+
}
|
|
435
|
+
else if (isDigit(char)) {
|
|
436
|
+
while (offset < text.length && isDigit(text[offset]))
|
|
437
|
+
offset++;
|
|
438
|
+
if (text[offset] === '.' && isDigit(text[offset + 1])) {
|
|
439
|
+
offset++;
|
|
440
|
+
while (offset < text.length && isDigit(text[offset]))
|
|
441
|
+
offset++;
|
|
442
|
+
}
|
|
443
|
+
if (isWord(text[offset]) || text[offset] === '$') {
|
|
444
|
+
// An unfinished number/identifier is one plain run, not a highlighted suffix.
|
|
445
|
+
while (offset < text.length && (isWord(text[offset]) || text[offset] === '$'))
|
|
446
|
+
offset++;
|
|
447
|
+
}
|
|
448
|
+
else
|
|
449
|
+
writer.emit(start, offset, 'code-number');
|
|
450
|
+
}
|
|
451
|
+
else
|
|
452
|
+
offset++;
|
|
453
|
+
}
|
|
454
|
+
return writer.finish();
|
|
455
|
+
}
|
|
456
|
+
/** Consume CSS once, including incomplete edits; never retry a selector suffix. */
|
|
457
|
+
function tokenizeCss(text) {
|
|
458
|
+
const tokens = [];
|
|
459
|
+
let mode = 'selector';
|
|
460
|
+
let depth = 0;
|
|
461
|
+
let offset = 0;
|
|
462
|
+
const emit = (start, end, className) => {
|
|
463
|
+
if (end > start)
|
|
464
|
+
tokens.push({ text: text.slice(start, end), className });
|
|
465
|
+
};
|
|
466
|
+
while (offset < text.length) {
|
|
467
|
+
const start = offset;
|
|
468
|
+
const char = text[offset];
|
|
469
|
+
if (char === '/' && text[offset + 1] === '*') {
|
|
470
|
+
const end = text.indexOf('*/', offset + 2);
|
|
471
|
+
offset = end === -1 ? text.length : end + 2;
|
|
472
|
+
emit(start, offset, 'code-comment');
|
|
473
|
+
}
|
|
474
|
+
else if (char === '"' || char === "'") {
|
|
475
|
+
offset++;
|
|
476
|
+
while (offset < text.length) {
|
|
477
|
+
if (text[offset] === '\\')
|
|
478
|
+
offset = Math.min(text.length, offset + 2);
|
|
479
|
+
else if (text[offset++] === char)
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
emit(start, offset, 'code-value');
|
|
483
|
+
}
|
|
484
|
+
else if (char === '{' || char === '}' || char === ';' || (char === ':' && mode === 'property')) {
|
|
485
|
+
offset++;
|
|
486
|
+
emit(start, offset);
|
|
487
|
+
if (char === '{') {
|
|
488
|
+
depth++;
|
|
489
|
+
mode = 'property';
|
|
490
|
+
}
|
|
491
|
+
else if (char === '}') {
|
|
492
|
+
depth = Math.max(0, depth - 1);
|
|
493
|
+
mode = depth ? 'property' : 'selector';
|
|
494
|
+
}
|
|
495
|
+
else if (char === ';')
|
|
496
|
+
mode = depth ? 'property' : 'selector';
|
|
497
|
+
else
|
|
498
|
+
mode = 'value';
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// Each character belongs to exactly one run or lexical token.
|
|
502
|
+
while (offset < text.length) {
|
|
503
|
+
const next = text[offset];
|
|
504
|
+
if (next === '"' || next === "'" || next === '{' || next === '}' || next === ';' ||
|
|
505
|
+
(next === ':' && mode === 'property') || (next === '/' && text[offset + 1] === '*'))
|
|
506
|
+
break;
|
|
507
|
+
offset++;
|
|
508
|
+
}
|
|
509
|
+
emit(start, offset, mode === 'selector' ? 'code-tag' : mode === 'property' ? 'code-attr' : 'code-value');
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return tokens;
|
|
513
|
+
}
|
|
514
|
+
function tokenizeSyntax(text, language) {
|
|
515
|
+
switch (language) {
|
|
516
|
+
case 'html':
|
|
517
|
+
return tokenizeHtml(text);
|
|
518
|
+
case 'javascript':
|
|
519
|
+
return tokenizeJavascript(text);
|
|
520
|
+
case 'css':
|
|
521
|
+
return tokenizeCss(text);
|
|
522
|
+
case 'json':
|
|
523
|
+
return scan(text, /("(?:[^"\\]|\\[\s\S])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\b(?:true|false|null)\b)/g, match => match[1] ? /^\s*:/.test(text.slice(match.index + match[0].length)) ? 'code-tag' : 'code-value' : 'code-attr');
|
|
524
|
+
default:
|
|
525
|
+
return text ? [{ text }] : [];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** Missing editable content is empty; supplied source is never reformatted. */
|
|
530
|
+
function normalizeSyntaxBoxValue(value, options) {
|
|
531
|
+
return options.editable ? value ?? '' : value;
|
|
532
|
+
}
|
|
533
|
+
function resolveInitialSyntaxBoxValue(options) {
|
|
534
|
+
const code = normalizeSyntaxBoxValue(options.code ?? options.value, options);
|
|
535
|
+
// Preserve the existing read-only behavior when both aliases were supplied differently.
|
|
536
|
+
const value = options.editable ? code : options.value ?? code;
|
|
537
|
+
return { code, value, initialValue: code ?? '' };
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const withSyntaxContent = (Base) => {
|
|
541
|
+
const SyntaxContent = class extends Base {
|
|
542
|
+
constructor(hostRef) {
|
|
543
|
+
super();
|
|
544
|
+
index.registerInstance(this, hostRef);
|
|
545
|
+
}
|
|
546
|
+
/** Mirrored with `value`; prefer `code` for domain usage. */
|
|
547
|
+
code;
|
|
548
|
+
/** Form-value alias mirrored with `code` for compatibility. */
|
|
549
|
+
value;
|
|
550
|
+
/** Title in panel mode and tab label for a composed view. */
|
|
551
|
+
heading;
|
|
552
|
+
/** Accessible name for the editor; falls back to `heading`, then the language. */
|
|
553
|
+
ariaLabel = null;
|
|
554
|
+
variant = 'panel';
|
|
555
|
+
/** Explicit content height. Panel mode defaults to 110px; plain mode defaults to auto. */
|
|
556
|
+
height;
|
|
557
|
+
copyable = false;
|
|
558
|
+
editable = false;
|
|
559
|
+
/** Form field name used when the component is editable. */
|
|
560
|
+
name;
|
|
561
|
+
/** Marks the editable textarea as required for form validation. */
|
|
562
|
+
required = false;
|
|
563
|
+
/** Selects the formatter. HTML, JavaScript, CSS, and JSON also receive syntax highlighting. */
|
|
564
|
+
language = 'html';
|
|
565
|
+
/** Disables editing and panel actions. */
|
|
566
|
+
disabled = false;
|
|
567
|
+
/** Emitted when editable content is committed by the native change event or by formatting. */
|
|
568
|
+
qChange;
|
|
569
|
+
/** Emitted on each editable content input and after formatting. */
|
|
570
|
+
qInput;
|
|
571
|
+
// ======================== [2] INTERNAL STATE & REFS ========================
|
|
572
|
+
disabledState = false;
|
|
573
|
+
get isDisabled() {
|
|
574
|
+
return formFieldState.isFieldDisabled(this.el, this.disabled);
|
|
575
|
+
}
|
|
576
|
+
copied = false;
|
|
577
|
+
copyFailed = false;
|
|
578
|
+
formatMessage;
|
|
579
|
+
initialValue;
|
|
580
|
+
scrollPending = false;
|
|
581
|
+
copyRevision = 0;
|
|
582
|
+
formatRevision = 0;
|
|
583
|
+
copiedTimeoutId;
|
|
584
|
+
scrollableEl;
|
|
585
|
+
preEl;
|
|
586
|
+
contentEl;
|
|
587
|
+
actionsEl;
|
|
588
|
+
validationAnchor;
|
|
589
|
+
// ========================= [3] LIFECYCLE & WATCHERS =========================
|
|
590
|
+
watchCode(newCode) {
|
|
591
|
+
this.formatRevision++;
|
|
592
|
+
this.formatMessage = undefined;
|
|
593
|
+
const finalCode = normalizeSyntaxBoxValue(newCode, {
|
|
594
|
+
editable: this.editable,
|
|
595
|
+
});
|
|
596
|
+
if (finalCode !== newCode) {
|
|
597
|
+
this.code = finalCode;
|
|
598
|
+
}
|
|
599
|
+
if (this.value !== finalCode) {
|
|
600
|
+
this.value = finalCode;
|
|
601
|
+
}
|
|
602
|
+
this.syncFormValue(finalCode);
|
|
603
|
+
}
|
|
604
|
+
watchValue(newValue) {
|
|
605
|
+
this.formatRevision++;
|
|
606
|
+
this.formatMessage = undefined;
|
|
607
|
+
const finalVal = normalizeSyntaxBoxValue(newValue, {
|
|
608
|
+
editable: this.editable,
|
|
609
|
+
});
|
|
610
|
+
if (finalVal !== newValue) {
|
|
611
|
+
this.value = finalVal;
|
|
612
|
+
}
|
|
613
|
+
if (this.code !== finalVal) {
|
|
614
|
+
this.code = finalVal;
|
|
615
|
+
}
|
|
616
|
+
this.syncFormValue(finalVal);
|
|
617
|
+
}
|
|
618
|
+
watchLanguage() {
|
|
619
|
+
this.formatRevision++;
|
|
620
|
+
this.formatMessage = undefined;
|
|
621
|
+
}
|
|
622
|
+
watchConstraints() {
|
|
623
|
+
this.syncValidity();
|
|
624
|
+
}
|
|
625
|
+
watchEditable() {
|
|
626
|
+
this.formatRevision++;
|
|
627
|
+
if (this.editable)
|
|
628
|
+
this.watchCode(this.code);
|
|
629
|
+
this.syncFormValue(this.code);
|
|
630
|
+
}
|
|
631
|
+
componentWillLoad() {
|
|
632
|
+
const initial = resolveInitialSyntaxBoxValue({
|
|
633
|
+
code: this.code,
|
|
634
|
+
value: this.value,
|
|
635
|
+
editable: this.editable,
|
|
636
|
+
});
|
|
637
|
+
this.code = initial.code;
|
|
638
|
+
this.value = initial.value;
|
|
639
|
+
this.initialValue = initial.code;
|
|
640
|
+
this.syncFormValue(this.code);
|
|
641
|
+
}
|
|
642
|
+
formDisabledCallback() {
|
|
643
|
+
this.syncValidity();
|
|
644
|
+
}
|
|
645
|
+
componentDidLoad() {
|
|
646
|
+
syntaxScrollRestorers.set(this.el, () => this.resumeScroll());
|
|
647
|
+
syntaxVisibility.set(this.el, () => this.syncVisibility());
|
|
648
|
+
formFieldAdapter.registerFormField(this.el, {
|
|
649
|
+
kind: 'text',
|
|
650
|
+
owner: () => this.internals?.form ?? null,
|
|
651
|
+
active: () => this.editable,
|
|
652
|
+
value: () => this.code ?? '',
|
|
653
|
+
assign: value => { this.value = value; },
|
|
654
|
+
reconcile: () => {
|
|
655
|
+
const textarea = this.el.shadowRoot?.querySelector('textarea');
|
|
656
|
+
if (textarea && textarea.value !== (this.code ?? ''))
|
|
657
|
+
textarea.value = this.code ?? '';
|
|
658
|
+
this.syncFormValue(this.code);
|
|
659
|
+
this.syncValidity();
|
|
660
|
+
},
|
|
661
|
+
reset: () => this.formResetCallback(),
|
|
662
|
+
validate: report => this.validate(report),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
componentDidRender() {
|
|
666
|
+
this.syncVisibility();
|
|
667
|
+
this.syncLogSpacing();
|
|
668
|
+
}
|
|
669
|
+
syncLogSpacing = () => {
|
|
670
|
+
const slot = this.el.shadowRoot?.querySelector('.slotted-body > slot');
|
|
671
|
+
const hasLog = slot?.assignedElements().some(element => element.getAttribute('role') === 'log');
|
|
672
|
+
this.el.classList.toggle('q-syntax-log-content', Boolean(hasLog));
|
|
673
|
+
};
|
|
674
|
+
syncVisibility() {
|
|
675
|
+
const inactive = syntaxOwner(this.el)?.visible(this.el) === false;
|
|
676
|
+
if (inactive)
|
|
677
|
+
this.formatRevision++;
|
|
678
|
+
if (this.contentEl)
|
|
679
|
+
this.contentEl.inert = inactive;
|
|
680
|
+
if (this.actionsEl)
|
|
681
|
+
this.actionsEl.inert = inactive;
|
|
682
|
+
if (this.validationAnchor)
|
|
683
|
+
this.validationAnchor.hidden = !inactive;
|
|
684
|
+
this.syncValidity();
|
|
685
|
+
}
|
|
686
|
+
disconnectedCallback() {
|
|
687
|
+
this.formatRevision++;
|
|
688
|
+
this.copyRevision++;
|
|
689
|
+
this.clearCopiedTimeout();
|
|
690
|
+
}
|
|
691
|
+
formResetCallback() {
|
|
692
|
+
this.formatRevision++;
|
|
693
|
+
this.formatMessage = undefined;
|
|
694
|
+
this.code = this.initialValue;
|
|
695
|
+
this.value = this.initialValue;
|
|
696
|
+
this.syncFormValue(this.code);
|
|
697
|
+
this.syncValidity();
|
|
698
|
+
}
|
|
699
|
+
// ========================== [4] EXPOSED METHODS ==========================
|
|
700
|
+
/** Programmatically scrolls the read-only code body to the bottom when it is wrapped by q-scrollable. */
|
|
701
|
+
async scrollToBottom() {
|
|
702
|
+
const owner = syntaxOwner(this.el);
|
|
703
|
+
this.scrollPending = Boolean(owner && !owner.visible(this.el));
|
|
704
|
+
if (!this.scrollPending)
|
|
705
|
+
await this.scrollableEl?.scrollToBottom();
|
|
706
|
+
}
|
|
707
|
+
resumeScroll() {
|
|
708
|
+
if (this.scrollPending)
|
|
709
|
+
void this.scrollToBottom();
|
|
710
|
+
}
|
|
711
|
+
/** Returns whether editable content satisfies native constraints. */
|
|
712
|
+
async checkValidity() {
|
|
713
|
+
return this.validate(false);
|
|
714
|
+
}
|
|
715
|
+
/** Reports editable constraint violations and reveals the editor in its owning box. */
|
|
716
|
+
async reportValidity() {
|
|
717
|
+
return this.validate(true);
|
|
718
|
+
}
|
|
719
|
+
validate(report) {
|
|
720
|
+
this.syncValidity();
|
|
721
|
+
const textarea = this.el.shadowRoot?.querySelector('textarea');
|
|
722
|
+
if (report && this.editable && textarea?.validity.valid === false) {
|
|
723
|
+
revealSyntaxEditor(this.el);
|
|
724
|
+
textarea.focus({ preventScroll: true });
|
|
725
|
+
}
|
|
726
|
+
return report
|
|
727
|
+
? this.internals?.reportValidity?.() ?? textarea?.reportValidity?.() ?? true
|
|
728
|
+
: this.internals?.checkValidity?.() ?? textarea?.checkValidity?.() ?? true;
|
|
729
|
+
}
|
|
730
|
+
// =================== [5] EVENT HANDLERS & INTERNAL METHODS ===================
|
|
731
|
+
syncFormValue(value) {
|
|
732
|
+
if (!this.internals || typeof this.internals.setFormValue !== 'function')
|
|
733
|
+
return;
|
|
734
|
+
this.internals.setFormValue(this.editable ? value || '' : null);
|
|
735
|
+
this.syncValidity();
|
|
736
|
+
}
|
|
737
|
+
syncValidity() {
|
|
738
|
+
const disabled = formFieldState.syncFieldHost(this.el, this.disabled, this.name, this.required);
|
|
739
|
+
if (this.disabledState !== disabled)
|
|
740
|
+
this.disabledState = disabled;
|
|
741
|
+
const textarea = this.el.shadowRoot?.querySelector('textarea');
|
|
742
|
+
if (textarea) {
|
|
743
|
+
textarea.disabled = disabled;
|
|
744
|
+
textarea.required = this.required;
|
|
745
|
+
textarea.readOnly = this.el.hasAttribute('readonly');
|
|
746
|
+
if (textarea.value !== (this.code ?? ''))
|
|
747
|
+
textarea.value = this.code ?? '';
|
|
748
|
+
}
|
|
749
|
+
this.internals?.setFormValue?.(this.editable && !disabled ? this.code ?? '' : null);
|
|
750
|
+
if (!this.internals || !textarea || !this.editable) {
|
|
751
|
+
if (typeof this.internals?.setValidity === 'function') {
|
|
752
|
+
this.internals.setValidity({});
|
|
753
|
+
}
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
formControlValidity.syncNativeControlValidity({
|
|
757
|
+
internals: this.internals,
|
|
758
|
+
control: textarea,
|
|
759
|
+
anchor: this.validationAnchor && !this.validationAnchor.hidden ? this.validationAnchor : textarea,
|
|
760
|
+
disabled: this.isDisabled,
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
clearCopiedTimeout() {
|
|
764
|
+
if (this.copiedTimeoutId !== undefined) {
|
|
765
|
+
clearTimeout(this.copiedTimeoutId);
|
|
766
|
+
this.copiedTimeoutId = undefined;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
scheduleCopyStateReset() {
|
|
770
|
+
this.clearCopiedTimeout();
|
|
771
|
+
this.copiedTimeoutId = setTimeout(() => {
|
|
772
|
+
this.copied = false;
|
|
773
|
+
this.copyFailed = false;
|
|
774
|
+
this.copiedTimeoutId = undefined;
|
|
775
|
+
}, 1500);
|
|
776
|
+
}
|
|
777
|
+
copyCode = async () => {
|
|
778
|
+
if (this.isDisabled)
|
|
779
|
+
return;
|
|
780
|
+
const revision = ++this.copyRevision;
|
|
781
|
+
const fallback = ownContentNodes(this.el).map(node => node.textContent ?? '').join('');
|
|
782
|
+
const codeToCopy = getSyntaxBoxCopyText(this.code, fallback);
|
|
783
|
+
try {
|
|
784
|
+
await writeClipboardText(codeToCopy);
|
|
785
|
+
if (!this.el.isConnected || revision !== this.copyRevision)
|
|
786
|
+
return;
|
|
787
|
+
this.copied = true;
|
|
788
|
+
this.copyFailed = false;
|
|
789
|
+
}
|
|
790
|
+
catch {
|
|
791
|
+
if (!this.el.isConnected || revision !== this.copyRevision)
|
|
792
|
+
return;
|
|
793
|
+
this.copied = false;
|
|
794
|
+
this.copyFailed = true;
|
|
795
|
+
}
|
|
796
|
+
this.scheduleCopyStateReset();
|
|
797
|
+
};
|
|
798
|
+
handleScroll = (e) => {
|
|
799
|
+
const textarea = e.target;
|
|
800
|
+
if (this.preEl) {
|
|
801
|
+
this.preEl.scrollLeft = textarea.scrollLeft;
|
|
802
|
+
this.preEl.scrollTop = textarea.scrollTop;
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
handleInput = (ev) => {
|
|
806
|
+
const target = ev.target;
|
|
807
|
+
this.code = target.value;
|
|
808
|
+
this.value = target.value;
|
|
809
|
+
this.qInput.emit(this.code);
|
|
810
|
+
};
|
|
811
|
+
handleChange = (ev) => {
|
|
812
|
+
const target = ev.target;
|
|
813
|
+
this.code = target.value;
|
|
814
|
+
this.value = target.value;
|
|
815
|
+
this.qChange.emit(this.code);
|
|
816
|
+
};
|
|
817
|
+
handleKeyDown = (ev) => {
|
|
818
|
+
const textarea = ev.target;
|
|
819
|
+
const action = getSyntaxBoxEditorKeyAction(ev, textarea.value, textarea.selectionStart, textarea.selectionEnd);
|
|
820
|
+
if (action.type === 'none') {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (action.type === 'blur') {
|
|
824
|
+
textarea.blur();
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
ev.preventDefault();
|
|
828
|
+
this.code = action.value;
|
|
829
|
+
this.value = action.value;
|
|
830
|
+
this.qInput.emit(this.code);
|
|
831
|
+
requestAnimationFrame(() => {
|
|
832
|
+
textarea.selectionStart = textarea.selectionEnd = action.caret;
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
handleFormat = async () => {
|
|
836
|
+
const language = formatterLanguage(this.language);
|
|
837
|
+
if (this.isDisabled || !this.editable || !language || !this.code)
|
|
838
|
+
return;
|
|
839
|
+
const revision = ++this.formatRevision;
|
|
840
|
+
const source = this.code;
|
|
841
|
+
const pending = formatSource(source, language);
|
|
842
|
+
const result = pending instanceof Promise ? await pending : pending;
|
|
843
|
+
if (revision !== this.formatRevision || this.code !== source || !this.el.isConnected || this.isDisabled)
|
|
844
|
+
return;
|
|
845
|
+
const label = formatterLanguages[language];
|
|
846
|
+
if (result.status === 'unavailable') {
|
|
847
|
+
this.formatMessage = `Could not load the ${label} formatter. Reload and try again.`;
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
if (result.status === 'failed') {
|
|
851
|
+
this.formatMessage = `Could not format this ${label} source.`;
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
this.code = result.code;
|
|
855
|
+
this.value = result.code;
|
|
856
|
+
this.formatMessage = result.status === 'invalid' ? `Invalid ${label}; source unchanged.`
|
|
857
|
+
: result.status === 'unsupported' ? `${label} formatting limit reached; source unchanged.` : undefined;
|
|
858
|
+
this.qInput.emit(result.code);
|
|
859
|
+
this.qChange.emit(result.code);
|
|
860
|
+
};
|
|
861
|
+
getCopyTooltipContent() {
|
|
862
|
+
if (this.copyFailed)
|
|
863
|
+
return 'Copy failed';
|
|
864
|
+
if (this.copied)
|
|
865
|
+
return 'Copied!';
|
|
866
|
+
return 'Copy';
|
|
867
|
+
}
|
|
868
|
+
// ===================== [6] RENDER (Visual Template Only) =====================
|
|
869
|
+
renderContent(variant) {
|
|
870
|
+
const resolvedHeight = this.height !== undefined ? this.height : variant === 'panel' ? '110px' : 'auto';
|
|
871
|
+
const isScrollable = resolvedHeight !== 'auto' && resolvedHeight !== '';
|
|
872
|
+
const formatFeedback = this.editable ? this.formatMessage : undefined;
|
|
873
|
+
const highlighted = tokenizeSyntax(this.code ?? '', this.language).map(token => token.className ? index.h("span", { class: token.className }, token.text) : token.text);
|
|
874
|
+
const content = this.editable || this.code !== undefined ? (this.editable ? (index.h("div", { class: "editor-area", style: { height: resolvedHeight } }, index.h("span", { id: "syntax-box-keyboard-help", class: "visually-hidden" }, "Press Escape to leave the code editor. Press Tab to insert two spaces."), index.h("textarea", { class: "editor-textarea", value: this.code ?? '', name: this.name, disabled: this.isDisabled, required: this.required, "aria-label": this.ariaLabel?.trim() || this.heading?.trim() || `${this.language.toUpperCase()} code editor`, "aria-describedby": "syntax-box-keyboard-help", onInput: this.handleInput, onChange: this.handleChange, onScroll: this.handleScroll, onKeyDown: this.handleKeyDown }), index.h("pre", { class: "code-body", ref: el => (this.preEl = el) }, index.h("code", null, highlighted)))) : (index.h("pre", { class: "code-body" }, index.h("code", null, highlighted)))) : (index.h("div", { class: "slotted-body" }, index.h("slot", { onSlotchange: this.syncLogSpacing })));
|
|
875
|
+
const bodyContent = isScrollable && !this.editable
|
|
876
|
+
? renderSyntaxScroller(content, resolvedHeight, el => { this.scrollableEl = el; })
|
|
877
|
+
: content;
|
|
878
|
+
return [
|
|
879
|
+
this.editable && index.h("span", { class: "validation-anchor", tabindex: -1, ref: el => { this.validationAnchor = el; }, onFocus: () => {
|
|
880
|
+
revealSyntaxEditor(this.el);
|
|
881
|
+
this.el.shadowRoot?.querySelector('textarea')?.focus({ preventScroll: true });
|
|
882
|
+
} }),
|
|
883
|
+
index.h("div", { class: "view-content", ref: el => { this.contentEl = el; } }, variant === 'panel' && formatFeedback && index.h("div", { class: "format-feedback", role: "status" }, formatFeedback), bodyContent),
|
|
884
|
+
];
|
|
885
|
+
}
|
|
886
|
+
renderActions() {
|
|
887
|
+
const language = formatterLanguage(this.language);
|
|
888
|
+
return renderSyntaxActions({
|
|
889
|
+
editable: this.editable,
|
|
890
|
+
copyable: this.copyable,
|
|
891
|
+
disabled: this.isDisabled,
|
|
892
|
+
formatLabel: language && `Format ${formatterLanguages[language]}`,
|
|
893
|
+
copied: this.copied,
|
|
894
|
+
copyFeedback: this.getCopyTooltipContent(),
|
|
895
|
+
onFormat: this.handleFormat,
|
|
896
|
+
onCopy: this.copyCode,
|
|
897
|
+
ref: el => { this.actionsEl = el; },
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
// An exported anonymous mixin cannot include private fields in its emitted declaration.
|
|
902
|
+
return SyntaxContent;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
exports.hasSlottedSource = hasSlottedSource;
|
|
906
|
+
exports.syntaxBoxes = syntaxBoxes;
|
|
907
|
+
exports.syntaxOwner = syntaxOwner;
|
|
908
|
+
exports.syntaxScrollRestorers = syntaxScrollRestorers;
|
|
909
|
+
exports.syntaxVisibility = syntaxVisibility;
|
|
910
|
+
exports.withSyntaxContent = withSyntaxContent;
|