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