@elmethis/solid 0.1.0
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/LICENSE +21 -0
- package/README.md +118 -0
- package/lib/index.solid.cjs +25 -0
- package/lib/index.solid.mjs +5806 -0
- package/lib/style.css +2 -0
- package/lib-solid/components/a2ui/catalog/basic-catalog.jsx +207 -0
- package/lib-solid/components/a2ui/catalog/basic-catalog.jsx.map +1 -0
- package/lib-solid/components/a2ui/catalog/catalog-utils.js +23 -0
- package/lib-solid/components/a2ui/catalog/catalog-utils.js.map +1 -0
- package/lib-solid/components/a2ui/catalog/catalog.js +85 -0
- package/lib-solid/components/a2ui/catalog/catalog.js.map +1 -0
- package/lib-solid/components/a2ui/catalog/notion-block-catalog.jsx +217 -0
- package/lib-solid/components/a2ui/catalog/notion-block-catalog.jsx.map +1 -0
- package/lib-solid/components/a2ui/catalog/render-indexed-child.jsx +4 -0
- package/lib-solid/components/a2ui/catalog/render-indexed-child.jsx.map +1 -0
- package/lib-solid/components/a2ui/component-host.jsx +98 -0
- package/lib-solid/components/a2ui/component-host.jsx.map +1 -0
- package/lib-solid/components/a2ui/elm-a2ui.jsx +152 -0
- package/lib-solid/components/a2ui/elm-a2ui.jsx.map +1 -0
- package/lib-solid/components/a2ui/elm-a2ui.module.css +193 -0
- package/lib-solid/components/a2ui/stream-json-lines.js +45 -0
- package/lib-solid/components/a2ui/stream-json-lines.js.map +1 -0
- package/lib-solid/components/code/elm-code-block.jsx +40 -0
- package/lib-solid/components/code/elm-code-block.jsx.map +1 -0
- package/lib-solid/components/code/elm-code-block.module.css +45 -0
- package/lib-solid/components/code/elm-html-viewer.jsx +114 -0
- package/lib-solid/components/code/elm-html-viewer.jsx.map +1 -0
- package/lib-solid/components/code/elm-html-viewer.module.css +61 -0
- package/lib-solid/components/code/elm-html.jsx +178 -0
- package/lib-solid/components/code/elm-html.jsx.map +1 -0
- package/lib-solid/components/code/elm-html.module.css +5 -0
- package/lib-solid/components/code/elm-katex.jsx +14 -0
- package/lib-solid/components/code/elm-katex.jsx.map +1 -0
- package/lib-solid/components/code/elm-katex.module.css +4 -0
- package/lib-solid/components/code/elm-shiki-highlighter.jsx +74 -0
- package/lib-solid/components/code/elm-shiki-highlighter.jsx.map +1 -0
- package/lib-solid/components/code/elm-shiki-highlighter.module.css +25 -0
- package/lib-solid/components/containments/elm-collapse.jsx +31 -0
- package/lib-solid/components/containments/elm-collapse.jsx.map +1 -0
- package/lib-solid/components/containments/elm-collapse.module.css +47 -0
- package/lib-solid/components/containments/elm-modal.jsx +96 -0
- package/lib-solid/components/containments/elm-modal.jsx.map +1 -0
- package/lib-solid/components/containments/elm-modal.module.css +28 -0
- package/lib-solid/components/containments/elm-parallax.jsx +22 -0
- package/lib-solid/components/containments/elm-parallax.jsx.map +1 -0
- package/lib-solid/components/containments/elm-parallax.module.css +29 -0
- package/lib-solid/components/containments/elm-tabs.jsx +74 -0
- package/lib-solid/components/containments/elm-tabs.jsx.map +1 -0
- package/lib-solid/components/containments/elm-tabs.module.css +63 -0
- package/lib-solid/components/containments/elm-toggle.jsx +58 -0
- package/lib-solid/components/containments/elm-toggle.jsx.map +1 -0
- package/lib-solid/components/containments/elm-toggle.module.css +98 -0
- package/lib-solid/components/containments/elm-tooltip.jsx +61 -0
- package/lib-solid/components/containments/elm-tooltip.jsx.map +1 -0
- package/lib-solid/components/containments/elm-tooltip.module.css +23 -0
- package/lib-solid/components/fallback/elm-block-fallback.jsx +22 -0
- package/lib-solid/components/fallback/elm-block-fallback.jsx.map +1 -0
- package/lib-solid/components/fallback/elm-block-fallback.module.css +8 -0
- package/lib-solid/components/fallback/elm-rectangle-wave.jsx +8 -0
- package/lib-solid/components/fallback/elm-rectangle-wave.jsx.map +1 -0
- package/lib-solid/components/fallback/elm-rectangle-wave.module.css +35 -0
- package/lib-solid/components/fallback/elm-unsupported-block.jsx +19 -0
- package/lib-solid/components/fallback/elm-unsupported-block.jsx.map +1 -0
- package/lib-solid/components/fallback/elm-unsupported-block.module.css +26 -0
- package/lib-solid/components/form/elm-button-dropdown.jsx +121 -0
- package/lib-solid/components/form/elm-button-dropdown.jsx.map +1 -0
- package/lib-solid/components/form/elm-button-dropdown.module.css +83 -0
- package/lib-solid/components/form/elm-button.jsx +49 -0
- package/lib-solid/components/form/elm-button.jsx.map +1 -0
- package/lib-solid/components/form/elm-button.module.css +96 -0
- package/lib-solid/components/form/elm-checkbox.jsx +61 -0
- package/lib-solid/components/form/elm-checkbox.jsx.map +1 -0
- package/lib-solid/components/form/elm-checkbox.module.css +63 -0
- package/lib-solid/components/form/elm-select.jsx +98 -0
- package/lib-solid/components/form/elm-select.jsx.map +1 -0
- package/lib-solid/components/form/elm-select.module.css +108 -0
- package/lib-solid/components/form/elm-slider.jsx +298 -0
- package/lib-solid/components/form/elm-slider.jsx.map +1 -0
- package/lib-solid/components/form/elm-slider.module.css +236 -0
- package/lib-solid/components/form/elm-switch.jsx +37 -0
- package/lib-solid/components/form/elm-switch.jsx.map +1 -0
- package/lib-solid/components/form/elm-switch.module.css +59 -0
- package/lib-solid/components/form/elm-text-area.jsx +95 -0
- package/lib-solid/components/form/elm-text-area.jsx.map +1 -0
- package/lib-solid/components/form/elm-text-area.module.css +133 -0
- package/lib-solid/components/form/elm-text-field.jsx +129 -0
- package/lib-solid/components/form/elm-text-field.jsx.map +1 -0
- package/lib-solid/components/form/elm-text-field.module.css +158 -0
- package/lib-solid/components/form/elm-validation.jsx +27 -0
- package/lib-solid/components/form/elm-validation.jsx.map +1 -0
- package/lib-solid/components/form/elm-validation.module.css +9 -0
- package/lib-solid/components/icon/elm-copy-icon.jsx +34 -0
- package/lib-solid/components/icon/elm-copy-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-copy-icon.module.css +32 -0
- package/lib-solid/components/icon/elm-dot-loading-icon.jsx +19 -0
- package/lib-solid/components/icon/elm-dot-loading-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-dot-loading-icon.module.css +48 -0
- package/lib-solid/components/icon/elm-inline-icon.jsx +19 -0
- package/lib-solid/components/icon/elm-inline-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-inline-icon.module.css +38 -0
- package/lib-solid/components/icon/elm-language-icon.jsx +17 -0
- package/lib-solid/components/icon/elm-language-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-mdi-icon.jsx +27 -0
- package/lib-solid/components/icon/elm-mdi-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-mdi-icon.module.css +7 -0
- package/lib-solid/components/icon/elm-square-loading-icon.jsx +31 -0
- package/lib-solid/components/icon/elm-square-loading-icon.jsx.map +1 -0
- package/lib-solid/components/icon/elm-square-loading-icon.module.css +38 -0
- package/lib-solid/components/icon/elm-toggle-theme.jsx +146 -0
- package/lib-solid/components/icon/elm-toggle-theme.jsx.map +1 -0
- package/lib-solid/components/icon/elm-toggle-theme.module.css +15 -0
- package/lib-solid/components/icon/language-glyph.jsx +27 -0
- package/lib-solid/components/icon/language-glyph.jsx.map +1 -0
- package/lib-solid/components/media/elm-audio-player.jsx +275 -0
- package/lib-solid/components/media/elm-audio-player.jsx.map +1 -0
- package/lib-solid/components/media/elm-audio-player.module.css +433 -0
- package/lib-solid/components/media/elm-block-image.jsx +54 -0
- package/lib-solid/components/media/elm-block-image.jsx.map +1 -0
- package/lib-solid/components/media/elm-block-image.module.css +45 -0
- package/lib-solid/components/media/elm-file.jsx +65 -0
- package/lib-solid/components/media/elm-file.jsx.map +1 -0
- package/lib-solid/components/media/elm-file.module.css +33 -0
- package/lib-solid/components/navigation/elm-bookmark.jsx +44 -0
- package/lib-solid/components/navigation/elm-bookmark.jsx.map +1 -0
- package/lib-solid/components/navigation/elm-bookmark.module.css +88 -0
- package/lib-solid/components/navigation/elm-breadcrumb.jsx +26 -0
- package/lib-solid/components/navigation/elm-breadcrumb.jsx.map +1 -0
- package/lib-solid/components/navigation/elm-breadcrumb.module.css +44 -0
- package/lib-solid/components/navigation/elm-page-top.jsx +56 -0
- package/lib-solid/components/navigation/elm-page-top.jsx.map +1 -0
- package/lib-solid/components/navigation/elm-page-top.module.css +130 -0
- package/lib-solid/components/notion/elm-notion-callout.jsx +22 -0
- package/lib-solid/components/notion/elm-notion-callout.jsx.map +1 -0
- package/lib-solid/components/notion/elm-notion-callout.module.css +91 -0
- package/lib-solid/components/others/color-sample-copy.js +63 -0
- package/lib-solid/components/others/color-sample-copy.js.map +1 -0
- package/lib-solid/components/others/elm-color-primitive-sample.jsx +55 -0
- package/lib-solid/components/others/elm-color-primitive-sample.jsx.map +1 -0
- package/lib-solid/components/others/elm-color-primitive-sample.module.css +74 -0
- package/lib-solid/components/others/elm-color-semantic-sample.jsx +170 -0
- package/lib-solid/components/others/elm-color-semantic-sample.jsx.map +1 -0
- package/lib-solid/components/others/elm-color-semantic-sample.module.css +134 -0
- package/lib-solid/components/others/elm-markdown.jsx +133 -0
- package/lib-solid/components/others/elm-markdown.jsx.map +1 -0
- package/lib-solid/components/others/elm-markdown.module.css +6 -0
- package/lib-solid/components/others/use-wordle.jsx +247 -0
- package/lib-solid/components/others/use-wordle.jsx.map +1 -0
- package/lib-solid/components/others/use-wordle.module.css +192 -0
- package/lib-solid/components/others/wordle/validGuesses.js +10660 -0
- package/lib-solid/components/others/wordle/validGuesses.js.map +1 -0
- package/lib-solid/components/others/wordle/wordlist.js +5760 -0
- package/lib-solid/components/others/wordle/wordlist.js.map +1 -0
- package/lib-solid/components/table/elm-table-body.jsx +9 -0
- package/lib-solid/components/table/elm-table-body.jsx.map +1 -0
- package/lib-solid/components/table/elm-table-cell.jsx +27 -0
- package/lib-solid/components/table/elm-table-cell.jsx.map +1 -0
- package/lib-solid/components/table/elm-table-cell.module.css +27 -0
- package/lib-solid/components/table/elm-table-header.jsx +13 -0
- package/lib-solid/components/table/elm-table-header.jsx.map +1 -0
- package/lib-solid/components/table/elm-table-header.module.css +7 -0
- package/lib-solid/components/table/elm-table-row.jsx +10 -0
- package/lib-solid/components/table/elm-table-row.jsx.map +1 -0
- package/lib-solid/components/table/elm-table-row.module.css +15 -0
- package/lib-solid/components/table/elm-table.jsx +63 -0
- package/lib-solid/components/table/elm-table.jsx.map +1 -0
- package/lib-solid/components/table/elm-table.module.css +107 -0
- package/lib-solid/components/table/index.js +7 -0
- package/lib-solid/components/table/index.js.map +1 -0
- package/lib-solid/components/table/table-context.js +5 -0
- package/lib-solid/components/table/table-context.js.map +1 -0
- package/lib-solid/components/typography/elm-block-quote.jsx +22 -0
- package/lib-solid/components/typography/elm-block-quote.jsx.map +1 -0
- package/lib-solid/components/typography/elm-block-quote.module.css +40 -0
- package/lib-solid/components/typography/elm-callout.jsx +24 -0
- package/lib-solid/components/typography/elm-callout.jsx.map +1 -0
- package/lib-solid/components/typography/elm-callout.module.css +65 -0
- package/lib-solid/components/typography/elm-divider.jsx +8 -0
- package/lib-solid/components/typography/elm-divider.jsx.map +1 -0
- package/lib-solid/components/typography/elm-divider.module.css +5 -0
- package/lib-solid/components/typography/elm-fragment-identifier.jsx +16 -0
- package/lib-solid/components/typography/elm-fragment-identifier.jsx.map +1 -0
- package/lib-solid/components/typography/elm-fragment-identifier.module.css +28 -0
- package/lib-solid/components/typography/elm-heading.jsx +37 -0
- package/lib-solid/components/typography/elm-heading.jsx.map +1 -0
- package/lib-solid/components/typography/elm-heading.module.css +96 -0
- package/lib-solid/components/typography/elm-inline-text.jsx +75 -0
- package/lib-solid/components/typography/elm-inline-text.jsx.map +1 -0
- package/lib-solid/components/typography/elm-inline-text.module.css +118 -0
- package/lib-solid/components/typography/elm-list.jsx +13 -0
- package/lib-solid/components/typography/elm-list.jsx.map +1 -0
- package/lib-solid/components/typography/elm-list.module.css +92 -0
- package/lib-solid/components/typography/elm-paragraph.jsx +21 -0
- package/lib-solid/components/typography/elm-paragraph.jsx.map +1 -0
- package/lib-solid/components/typography/elm-paragraph.module.css +15 -0
- package/lib-solid/components/typography/markers/list-bullet-level-1.svg +3 -0
- package/lib-solid/components/typography/markers/list-bullet-level-2.svg +3 -0
- package/lib-solid/components/typography/markers/list-bullet-level-3.svg +3 -0
- package/lib-solid/exports.js +67 -0
- package/lib-solid/exports.js.map +1 -0
- package/lib-solid/hooks/create-auto-animate.js +61 -0
- package/lib-solid/hooks/create-auto-animate.js.map +1 -0
- package/lib-solid/index.js +3 -0
- package/lib-solid/index.js.map +1 -0
- package/lib-solid/primitives/call-event-handler.js +9 -0
- package/lib-solid/primitives/call-event-handler.js.map +1 -0
- package/lib-solid/primitives/create-async-state.js +71 -0
- package/lib-solid/primitives/create-async-state.js.map +1 -0
- package/lib-solid/primitives/create-auto-animate.js +67 -0
- package/lib-solid/primitives/create-auto-animate.js.map +1 -0
- package/lib-solid/primitives/create-clipboard.js +41 -0
- package/lib-solid/primitives/create-clipboard.js.map +1 -0
- package/lib-solid/primitives/create-controllable-signal.js +32 -0
- package/lib-solid/primitives/create-controllable-signal.js.map +1 -0
- package/lib-solid/primitives/create-debounced.js +41 -0
- package/lib-solid/primitives/create-debounced.js.map +1 -0
- package/lib-solid/primitives/create-delayed-signal.js +34 -0
- package/lib-solid/primitives/create-delayed-signal.js.map +1 -0
- package/lib-solid/primitives/create-elmethis-theme.js +83 -0
- package/lib-solid/primitives/create-elmethis-theme.js.map +1 -0
- package/lib-solid/primitives/create-modal.jsx +14 -0
- package/lib-solid/primitives/create-modal.jsx.map +1 -0
- package/lib-solid/primitives/create-storage.js +173 -0
- package/lib-solid/primitives/create-storage.js.map +1 -0
- package/lib-solid/primitives/create-throttled-queue.js +80 -0
- package/lib-solid/primitives/create-throttled-queue.js.map +1 -0
- package/lib-solid/primitives/create-throttled.js +58 -0
- package/lib-solid/primitives/create-throttled.js.map +1 -0
- package/lib-solid/styles/_component-vars.css +48 -0
- package/lib-solid/styles/merge-style.js +11 -0
- package/lib-solid/styles/merge-style.js.map +1 -0
- package/lib-solid/styles/text.module.css +11 -0
- package/lib-types/components/a2ui/catalog/basic-catalog.d.ts +5 -0
- package/lib-types/components/a2ui/catalog/basic-catalog.d.ts.map +1 -0
- package/lib-types/components/a2ui/catalog/catalog-utils.d.ts +5 -0
- package/lib-types/components/a2ui/catalog/catalog-utils.d.ts.map +1 -0
- package/lib-types/components/a2ui/catalog/catalog.d.ts +39 -0
- package/lib-types/components/a2ui/catalog/catalog.d.ts.map +1 -0
- package/lib-types/components/a2ui/catalog/notion-block-catalog.d.ts +5 -0
- package/lib-types/components/a2ui/catalog/notion-block-catalog.d.ts.map +1 -0
- package/lib-types/components/a2ui/catalog/render-indexed-child.d.ts +11 -0
- package/lib-types/components/a2ui/catalog/render-indexed-child.d.ts.map +1 -0
- package/lib-types/components/a2ui/component-host.d.ts +14 -0
- package/lib-types/components/a2ui/component-host.d.ts.map +1 -0
- package/lib-types/components/a2ui/elm-a2ui.d.ts +28 -0
- package/lib-types/components/a2ui/elm-a2ui.d.ts.map +1 -0
- package/lib-types/components/a2ui/stream-json-lines.d.ts +8 -0
- package/lib-types/components/a2ui/stream-json-lines.d.ts.map +1 -0
- package/lib-types/components/code/elm-code-block.d.ts +11 -0
- package/lib-types/components/code/elm-code-block.d.ts.map +1 -0
- package/lib-types/components/code/elm-html-viewer.d.ts +20 -0
- package/lib-types/components/code/elm-html-viewer.d.ts.map +1 -0
- package/lib-types/components/code/elm-html.d.ts +24 -0
- package/lib-types/components/code/elm-html.d.ts.map +1 -0
- package/lib-types/components/code/elm-katex.d.ts +9 -0
- package/lib-types/components/code/elm-katex.d.ts.map +1 -0
- package/lib-types/components/code/elm-shiki-highlighter.d.ts +9 -0
- package/lib-types/components/code/elm-shiki-highlighter.d.ts.map +1 -0
- package/lib-types/components/containments/elm-collapse.d.ts +8 -0
- package/lib-types/components/containments/elm-collapse.d.ts.map +1 -0
- package/lib-types/components/containments/elm-modal.d.ts +9 -0
- package/lib-types/components/containments/elm-modal.d.ts.map +1 -0
- package/lib-types/components/containments/elm-parallax.d.ts +6 -0
- package/lib-types/components/containments/elm-parallax.d.ts.map +1 -0
- package/lib-types/components/containments/elm-tabs.d.ts +24 -0
- package/lib-types/components/containments/elm-tabs.d.ts.map +1 -0
- package/lib-types/components/containments/elm-toggle.d.ts +17 -0
- package/lib-types/components/containments/elm-toggle.d.ts.map +1 -0
- package/lib-types/components/containments/elm-tooltip.d.ts +9 -0
- package/lib-types/components/containments/elm-tooltip.d.ts.map +1 -0
- package/lib-types/components/fallback/elm-block-fallback.d.ts +6 -0
- package/lib-types/components/fallback/elm-block-fallback.d.ts.map +1 -0
- package/lib-types/components/fallback/elm-rectangle-wave.d.ts +4 -0
- package/lib-types/components/fallback/elm-rectangle-wave.d.ts.map +1 -0
- package/lib-types/components/fallback/elm-unsupported-block.d.ts +6 -0
- package/lib-types/components/fallback/elm-unsupported-block.d.ts.map +1 -0
- package/lib-types/components/form/elm-button-dropdown.d.ts +51 -0
- package/lib-types/components/form/elm-button-dropdown.d.ts.map +1 -0
- package/lib-types/components/form/elm-button.d.ts +12 -0
- package/lib-types/components/form/elm-button.d.ts.map +1 -0
- package/lib-types/components/form/elm-checkbox.d.ts +17 -0
- package/lib-types/components/form/elm-checkbox.d.ts.map +1 -0
- package/lib-types/components/form/elm-select.d.ts +29 -0
- package/lib-types/components/form/elm-select.d.ts.map +1 -0
- package/lib-types/components/form/elm-slider.d.ts +32 -0
- package/lib-types/components/form/elm-slider.d.ts.map +1 -0
- package/lib-types/components/form/elm-switch.d.ts +15 -0
- package/lib-types/components/form/elm-switch.d.ts.map +1 -0
- package/lib-types/components/form/elm-text-area.d.ts +14 -0
- package/lib-types/components/form/elm-text-area.d.ts.map +1 -0
- package/lib-types/components/form/elm-text-field.d.ts +18 -0
- package/lib-types/components/form/elm-text-field.d.ts.map +1 -0
- package/lib-types/components/form/elm-validation.d.ts +8 -0
- package/lib-types/components/form/elm-validation.d.ts.map +1 -0
- package/lib-types/components/icon/elm-copy-icon.d.ts +7 -0
- package/lib-types/components/icon/elm-copy-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-dot-loading-icon.d.ts +7 -0
- package/lib-types/components/icon/elm-dot-loading-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-inline-icon.d.ts +12 -0
- package/lib-types/components/icon/elm-inline-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-language-icon.d.ts +13 -0
- package/lib-types/components/icon/elm-language-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-mdi-icon.d.ts +10 -0
- package/lib-types/components/icon/elm-mdi-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-square-loading-icon.d.ts +7 -0
- package/lib-types/components/icon/elm-square-loading-icon.d.ts.map +1 -0
- package/lib-types/components/icon/elm-toggle-theme.d.ts +7 -0
- package/lib-types/components/icon/elm-toggle-theme.d.ts.map +1 -0
- package/lib-types/components/icon/language-glyph.d.ts +11 -0
- package/lib-types/components/icon/language-glyph.d.ts.map +1 -0
- package/lib-types/components/media/elm-audio-player.d.ts +25 -0
- package/lib-types/components/media/elm-audio-player.d.ts.map +1 -0
- package/lib-types/components/media/elm-block-image.d.ts +15 -0
- package/lib-types/components/media/elm-block-image.d.ts.map +1 -0
- package/lib-types/components/media/elm-file.d.ts +11 -0
- package/lib-types/components/media/elm-file.d.ts.map +1 -0
- package/lib-types/components/navigation/elm-bookmark.d.ts +13 -0
- package/lib-types/components/navigation/elm-bookmark.d.ts.map +1 -0
- package/lib-types/components/navigation/elm-breadcrumb.d.ts +11 -0
- package/lib-types/components/navigation/elm-breadcrumb.d.ts.map +1 -0
- package/lib-types/components/navigation/elm-page-top.d.ts +7 -0
- package/lib-types/components/navigation/elm-page-top.d.ts.map +1 -0
- package/lib-types/components/notion/elm-notion-callout.d.ts +21 -0
- package/lib-types/components/notion/elm-notion-callout.d.ts.map +1 -0
- package/lib-types/components/others/color-sample-copy.d.ts +10 -0
- package/lib-types/components/others/color-sample-copy.d.ts.map +1 -0
- package/lib-types/components/others/elm-color-primitive-sample.d.ts +4 -0
- package/lib-types/components/others/elm-color-primitive-sample.d.ts.map +1 -0
- package/lib-types/components/others/elm-color-semantic-sample.d.ts +4 -0
- package/lib-types/components/others/elm-color-semantic-sample.d.ts.map +1 -0
- package/lib-types/components/others/elm-markdown.d.ts +8 -0
- package/lib-types/components/others/elm-markdown.d.ts.map +1 -0
- package/lib-types/components/others/use-wordle.d.ts +25 -0
- package/lib-types/components/others/use-wordle.d.ts.map +1 -0
- package/lib-types/components/others/wordle/validGuesses.d.ts +2 -0
- package/lib-types/components/others/wordle/validGuesses.d.ts.map +1 -0
- package/lib-types/components/others/wordle/wordlist.d.ts +2 -0
- package/lib-types/components/others/wordle/wordlist.d.ts.map +1 -0
- package/lib-types/components/table/elm-table-body.d.ts +4 -0
- package/lib-types/components/table/elm-table-body.d.ts.map +1 -0
- package/lib-types/components/table/elm-table-cell.d.ts +11 -0
- package/lib-types/components/table/elm-table-cell.d.ts.map +1 -0
- package/lib-types/components/table/elm-table-header.d.ts +4 -0
- package/lib-types/components/table/elm-table-header.d.ts.map +1 -0
- package/lib-types/components/table/elm-table-row.d.ts +4 -0
- package/lib-types/components/table/elm-table-row.d.ts.map +1 -0
- package/lib-types/components/table/elm-table.d.ts +7 -0
- package/lib-types/components/table/elm-table.d.ts.map +1 -0
- package/lib-types/components/table/index.d.ts +7 -0
- package/lib-types/components/table/index.d.ts.map +1 -0
- package/lib-types/components/table/table-context.d.ts +7 -0
- package/lib-types/components/table/table-context.d.ts.map +1 -0
- package/lib-types/components/typography/elm-block-quote.d.ts +5 -0
- package/lib-types/components/typography/elm-block-quote.d.ts.map +1 -0
- package/lib-types/components/typography/elm-callout.d.ts +8 -0
- package/lib-types/components/typography/elm-callout.d.ts.map +1 -0
- package/lib-types/components/typography/elm-divider.d.ts +4 -0
- package/lib-types/components/typography/elm-divider.d.ts.map +1 -0
- package/lib-types/components/typography/elm-fragment-identifier.d.ts +7 -0
- package/lib-types/components/typography/elm-fragment-identifier.d.ts.map +1 -0
- package/lib-types/components/typography/elm-heading.d.ts +8 -0
- package/lib-types/components/typography/elm-heading.d.ts.map +1 -0
- package/lib-types/components/typography/elm-inline-text.d.ts +23 -0
- package/lib-types/components/typography/elm-inline-text.d.ts.map +1 -0
- package/lib-types/components/typography/elm-list.d.ts +7 -0
- package/lib-types/components/typography/elm-list.d.ts.map +1 -0
- package/lib-types/components/typography/elm-paragraph.d.ts +7 -0
- package/lib-types/components/typography/elm-paragraph.d.ts.map +1 -0
- package/lib-types/exports.d.ts +67 -0
- package/lib-types/exports.d.ts.map +1 -0
- package/lib-types/hooks/create-auto-animate.d.ts +26 -0
- package/lib-types/hooks/create-auto-animate.d.ts.map +1 -0
- package/lib-types/index.d.ts +3 -0
- package/lib-types/index.d.ts.map +1 -0
- package/lib-types/primitives/call-event-handler.d.ts +6 -0
- package/lib-types/primitives/call-event-handler.d.ts.map +1 -0
- package/lib-types/primitives/create-async-state.d.ts +25 -0
- package/lib-types/primitives/create-async-state.d.ts.map +1 -0
- package/lib-types/primitives/create-auto-animate.d.ts +26 -0
- package/lib-types/primitives/create-auto-animate.d.ts.map +1 -0
- package/lib-types/primitives/create-clipboard.d.ts +16 -0
- package/lib-types/primitives/create-clipboard.d.ts.map +1 -0
- package/lib-types/primitives/create-controllable-signal.d.ts +17 -0
- package/lib-types/primitives/create-controllable-signal.d.ts.map +1 -0
- package/lib-types/primitives/create-debounced.d.ts +10 -0
- package/lib-types/primitives/create-debounced.d.ts.map +1 -0
- package/lib-types/primitives/create-delayed-signal.d.ts +10 -0
- package/lib-types/primitives/create-delayed-signal.d.ts.map +1 -0
- package/lib-types/primitives/create-elmethis-theme.d.ts +12 -0
- package/lib-types/primitives/create-elmethis-theme.d.ts.map +1 -0
- package/lib-types/primitives/create-modal.d.ts +15 -0
- package/lib-types/primitives/create-modal.d.ts.map +1 -0
- package/lib-types/primitives/create-storage.d.ts +18 -0
- package/lib-types/primitives/create-storage.d.ts.map +1 -0
- package/lib-types/primitives/create-throttled-queue.d.ts +17 -0
- package/lib-types/primitives/create-throttled-queue.d.ts.map +1 -0
- package/lib-types/primitives/create-throttled.d.ts +10 -0
- package/lib-types/primitives/create-throttled.d.ts.map +1 -0
- package/lib-types/styles/merge-style.d.ts +5 -0
- package/lib-types/styles/merge-style.d.ts.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
.elm-a2ui {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.surface {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: var(--elmethis-stack-gap);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:global(.a2ui-loading) {
|
|
12
|
+
color: gray;
|
|
13
|
+
font-size: 0.875em;
|
|
14
|
+
font-style: italic;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:global(.a2ui-unknown) {
|
|
18
|
+
color: tomato;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.row {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-flow: row wrap;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.column {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: var(--elmethis-stack-gap);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.list {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
overflow: auto;
|
|
38
|
+
gap: 4px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.list-horizontal {
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.list-item {
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.card {
|
|
50
|
+
border: 1px solid #e0e0e0;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
padding: 16px;
|
|
53
|
+
background: #fff;
|
|
54
|
+
box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.button {
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
gap: 4px;
|
|
62
|
+
padding: 8px 16px;
|
|
63
|
+
border: 1px solid #ccc;
|
|
64
|
+
border-radius: 4px;
|
|
65
|
+
background: transparent;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
font-size: 0.875rem;
|
|
68
|
+
font-weight: 500;
|
|
69
|
+
transition: background 0.15s;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.button:hover {
|
|
73
|
+
background: rgb(0 0 0 / 5%);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.button-primary {
|
|
77
|
+
background: var(--a2ui-primary, #1976d2);
|
|
78
|
+
border-color: transparent;
|
|
79
|
+
color: #fff;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button-primary:hover {
|
|
83
|
+
background: var(--a2ui-primary-hover, #1565c0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.button-disabled {
|
|
87
|
+
cursor: not-allowed;
|
|
88
|
+
opacity: 0.55;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.button-disabled:hover {
|
|
92
|
+
background: transparent;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.image {
|
|
96
|
+
max-width: 100%;
|
|
97
|
+
display: block;
|
|
98
|
+
object-fit: cover;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.icon {
|
|
102
|
+
display: inline-block;
|
|
103
|
+
width: 1.25em;
|
|
104
|
+
height: 1.25em;
|
|
105
|
+
vertical-align: middle;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.divider {
|
|
109
|
+
border: none;
|
|
110
|
+
border-top: 1px solid #e0e0e0;
|
|
111
|
+
margin: 8px 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.divider-vertical {
|
|
115
|
+
border-top: none;
|
|
116
|
+
border-left: 1px solid #e0e0e0;
|
|
117
|
+
margin: 0 8px;
|
|
118
|
+
align-self: stretch;
|
|
119
|
+
width: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.text-field,
|
|
123
|
+
.choice-picker,
|
|
124
|
+
.datetime-input,
|
|
125
|
+
.action-control,
|
|
126
|
+
.checkable-control {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
gap: 4px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.label,
|
|
133
|
+
.choice-picker-label {
|
|
134
|
+
font-size: 0.75rem;
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
color: #555;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.input {
|
|
140
|
+
padding: 8px 10px;
|
|
141
|
+
border: 1px solid #ccc;
|
|
142
|
+
border-radius: 4px;
|
|
143
|
+
font-size: 0.875rem;
|
|
144
|
+
outline: none;
|
|
145
|
+
transition: border-color 0.15s;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.input:focus {
|
|
149
|
+
border-color: var(--a2ui-primary, #1976d2);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.checkbox,
|
|
153
|
+
.choice-picker-option {
|
|
154
|
+
display: inline-flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 6px;
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
font-size: 0.875rem;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.checkbox-label,
|
|
162
|
+
.choice-picker-option {
|
|
163
|
+
user-select: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.slider {
|
|
167
|
+
width: 100%;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.modal-trigger {
|
|
172
|
+
display: inline-block;
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.video,
|
|
177
|
+
.audio {
|
|
178
|
+
max-width: 100%;
|
|
179
|
+
display: block;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.choice-picker-options {
|
|
183
|
+
display: flex;
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
gap: 4px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.validation-errors {
|
|
189
|
+
margin: 0;
|
|
190
|
+
padding-inline-start: 1.25rem;
|
|
191
|
+
color: #b42318;
|
|
192
|
+
font-size: 0.75rem;
|
|
193
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Incrementally parses a JSONL byte stream, skipping malformed lines. */
|
|
2
|
+
export async function streamJsonLines(body, { signal, onMessage, onError }) {
|
|
3
|
+
if (signal?.aborted)
|
|
4
|
+
return;
|
|
5
|
+
const reader = body.getReader();
|
|
6
|
+
const decoder = new TextDecoder();
|
|
7
|
+
let buffer = "";
|
|
8
|
+
const abort = () => void reader.cancel().catch(() => undefined);
|
|
9
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
10
|
+
const parse = (line) => {
|
|
11
|
+
const value = line.trim();
|
|
12
|
+
if (!value)
|
|
13
|
+
return;
|
|
14
|
+
try {
|
|
15
|
+
onMessage(JSON.parse(value));
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
onError?.(error, value);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
for (;;) {
|
|
23
|
+
const { done, value } = await reader.read();
|
|
24
|
+
if (done)
|
|
25
|
+
break;
|
|
26
|
+
buffer += decoder.decode(value, { stream: true });
|
|
27
|
+
const lines = buffer.split("\n");
|
|
28
|
+
buffer = lines.pop() ?? "";
|
|
29
|
+
for (const line of lines)
|
|
30
|
+
parse(line);
|
|
31
|
+
}
|
|
32
|
+
if (!signal?.aborted)
|
|
33
|
+
parse(buffer);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
signal?.removeEventListener("abort", abort);
|
|
37
|
+
try {
|
|
38
|
+
reader.releaseLock();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Cancellation can release the lock first.
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=stream-json-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-json-lines.js","sourceRoot":"","sources":["../../../src/components/a2ui/stream-json-lines.ts"],"names":[],"mappings":"AAMA,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAgC,EAChC,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAA0B;IAEtD,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO;IAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,IAAI,CAAC;YACH,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,OAAO;YAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,2CAA2C;QAC7C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mergeProps, splitProps } from "solid-js";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { ElmCopyIcon } from "../icon/elm-copy-icon";
|
|
4
|
+
import { ElmLanguageIcon } from "../icon/elm-language-icon";
|
|
5
|
+
import { ElmInlineText } from "../typography/elm-inline-text";
|
|
6
|
+
import { ElmShikiHighlighter } from "./elm-shiki-highlighter";
|
|
7
|
+
import styles from "./elm-code-block.module.css";
|
|
8
|
+
export const ElmCodeBlock = (props) => {
|
|
9
|
+
const merged = mergeProps({ language: "txt" }, props);
|
|
10
|
+
const [local, rest] = splitProps(merged, [
|
|
11
|
+
"class",
|
|
12
|
+
"children",
|
|
13
|
+
"code",
|
|
14
|
+
"language",
|
|
15
|
+
"caption",
|
|
16
|
+
]);
|
|
17
|
+
return (<figure {...rest} class={clsx(styles["elm-code-block"], local.class)}>
|
|
18
|
+
<span class={styles["language-icon"]}>
|
|
19
|
+
<ElmLanguageIcon language={local.language}/>
|
|
20
|
+
</span>
|
|
21
|
+
|
|
22
|
+
<span class={styles.caption}>
|
|
23
|
+
<ElmInlineText>
|
|
24
|
+
{local.caption || local.language}
|
|
25
|
+
{local.children}
|
|
26
|
+
</ElmInlineText>
|
|
27
|
+
</span>
|
|
28
|
+
|
|
29
|
+
<div class={styles["copy-icon"]}>
|
|
30
|
+
<ElmCopyIcon content={local.code}/>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<hr class={styles.divider}/>
|
|
34
|
+
|
|
35
|
+
<div class={styles.code}>
|
|
36
|
+
<ElmShikiHighlighter code={local.code} language={local.language}/>
|
|
37
|
+
</div>
|
|
38
|
+
</figure>);
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=elm-code-block.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elm-code-block.jsx","sourceRoot":"","sources":["../../../src/components/code/elm-code-block.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAY,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,MAAM,MAAM,6BAA6B,CAAC;AAajD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE;QACvC,OAAO;QACP,UAAU;QACV,MAAM;QACN,UAA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caption copy-icon" 2.75rem "divider divider divider" 1px "code code code" 1fr / 2rem 1fr 2.5rem;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
gap: 0;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
width: 100%;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0.25rem;
|
|
11
|
+
border-radius: 0.25rem;
|
|
12
|
+
background-color: var(--elmethis-color-surface-raised);
|
|
13
|
+
box-shadow: 0 0 0.125rem var(--elmethis-box-shadow-color);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.language-icon {
|
|
17
|
+
grid-area: language-icon;
|
|
18
|
+
padding-inline-start: 0.75rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.caption {
|
|
22
|
+
grid-area: caption;
|
|
23
|
+
padding: 1rem;
|
|
24
|
+
font-family: monospace;
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.copy-icon {
|
|
29
|
+
grid-area: copy-icon;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.divider {
|
|
33
|
+
grid-area: divider;
|
|
34
|
+
width: calc(100% - 1rem);
|
|
35
|
+
border: none;
|
|
36
|
+
border-bottom: solid 1px rgb(128 128 128 / 50%);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.code {
|
|
40
|
+
grid-area: code;
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
padding: 0 1rem;
|
|
43
|
+
overflow-x: auto;
|
|
44
|
+
scrollbar-width: thin;
|
|
45
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { onCleanup, splitProps } from "solid-js";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { mdiDownload, mdiOpenInNew } from "@mdi/js";
|
|
4
|
+
import { ElmMdiIcon } from "../icon/elm-mdi-icon";
|
|
5
|
+
import { ElmHtml } from "./elm-html";
|
|
6
|
+
import styles from "./elm-html-viewer.module.css";
|
|
7
|
+
export const ElmHtmlViewer = (props) => {
|
|
8
|
+
const [local, rest] = splitProps(props, [
|
|
9
|
+
"allowScripts",
|
|
10
|
+
"autoHeight",
|
|
11
|
+
"class",
|
|
12
|
+
"filename",
|
|
13
|
+
"height",
|
|
14
|
+
"html",
|
|
15
|
+
"sandbox",
|
|
16
|
+
"src",
|
|
17
|
+
]);
|
|
18
|
+
const pendingPopupUrls = new Set();
|
|
19
|
+
const revokePopupUrl = (url) => {
|
|
20
|
+
if (!pendingPopupUrls.delete(url))
|
|
21
|
+
return;
|
|
22
|
+
URL.revokeObjectURL(url);
|
|
23
|
+
};
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
for (const url of pendingPopupUrls)
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
pendingPopupUrls.clear();
|
|
28
|
+
});
|
|
29
|
+
const handleOpenInNewTab = () => {
|
|
30
|
+
if (local.src !== undefined) {
|
|
31
|
+
window.open(local.src, "_blank", "noreferrer");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let url;
|
|
35
|
+
try {
|
|
36
|
+
// JSON serialization avoids srcdoc attribute escaping. Escaping every
|
|
37
|
+
// closing tag prevents an HTML parser from treating caller-supplied
|
|
38
|
+
// `</script>` as the end of this wrapper's own script element.
|
|
39
|
+
const serializedHtml = JSON.stringify(local.html ?? "").replace(/<\//g, "<\\/");
|
|
40
|
+
const wrapper = `<!doctype html>
|
|
41
|
+
<html lang="en">
|
|
42
|
+
<head>
|
|
43
|
+
<meta charset="utf-8" />
|
|
44
|
+
<title>Embedded HTML content</title>
|
|
45
|
+
<style>html,body{margin:0;height:100%;}iframe{display:block;width:100%;height:100%;border:0;}</style>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<iframe sandbox title="Embedded HTML content"></iframe>
|
|
49
|
+
<script>document.querySelector("iframe").srcdoc = ${serializedHtml};</script>
|
|
50
|
+
</body>
|
|
51
|
+
</html>`;
|
|
52
|
+
url = URL.createObjectURL(new Blob([wrapper], { type: "text/html" }));
|
|
53
|
+
pendingPopupUrls.add(url);
|
|
54
|
+
const revoke = () => revokePopupUrl(url);
|
|
55
|
+
// Blob URLs require an opener-related browsing context, so `noopener`
|
|
56
|
+
// cannot be used here. The wrapper receives HTML only as inert JSON and
|
|
57
|
+
// its child iframe has an empty sandbox; `noreferrer` still suppresses
|
|
58
|
+
// referrer data.
|
|
59
|
+
const popup = window.open(url, "_blank", "noreferrer");
|
|
60
|
+
if (popup)
|
|
61
|
+
popup.addEventListener("load", revoke, { once: true });
|
|
62
|
+
else
|
|
63
|
+
revoke();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error("Failed to open HTML in a new tab", error);
|
|
67
|
+
if (url)
|
|
68
|
+
revokePopupUrl(url);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handleDownload = () => {
|
|
72
|
+
let url;
|
|
73
|
+
let link;
|
|
74
|
+
try {
|
|
75
|
+
link = document.createElement("a");
|
|
76
|
+
if (local.src !== undefined) {
|
|
77
|
+
link.href = local.src;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
url = URL.createObjectURL(new Blob([local.html ?? ""], { type: "text/html" }));
|
|
81
|
+
link.href = url;
|
|
82
|
+
}
|
|
83
|
+
link.download = local.filename || "download.html";
|
|
84
|
+
document.body.appendChild(link);
|
|
85
|
+
link.click();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error("Failed to download HTML", error);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
link?.remove();
|
|
92
|
+
if (url)
|
|
93
|
+
URL.revokeObjectURL(url);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return (<figure {...rest} class={clsx(styles["elm-html-viewer"], local.class)}>
|
|
97
|
+
<div class={styles.header}>
|
|
98
|
+
<button type="button" class={styles["icon-button"]} onClick={handleDownload} aria-label="Download">
|
|
99
|
+
<ElmMdiIcon d={mdiDownload} size="1.25rem"/>
|
|
100
|
+
</button>
|
|
101
|
+
|
|
102
|
+
<button type="button" class={styles["icon-button"]} onClick={handleOpenInNewTab} aria-label="Open in new tab">
|
|
103
|
+
<ElmMdiIcon d={mdiOpenInNew} size="1.25rem"/>
|
|
104
|
+
</button>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<hr class={styles.divider}/>
|
|
108
|
+
|
|
109
|
+
<div class={styles.content}>
|
|
110
|
+
<ElmHtml html={local.html} src={local.src} sandbox={local.sandbox} autoHeight={local.autoHeight} allowScripts={local.allowScripts} height={local.height}/>
|
|
111
|
+
</div>
|
|
112
|
+
</figure>);
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=elm-html-viewer.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elm-html-viewer.jsx","sourceRoot":"","sources":["../../../src/components/code/elm-html-viewer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAY,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAqB,MAAM,YAAY,CAAC;AACxD,OAAO,MAAM,MAAM,8BAA8B,CAAC;AAwBlD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE;IACzD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE;QACtC,cAAc;QACd,YAAY;QACZ,OAAO;QACP,UAAU;QACV,QAAQ;QACR,MAAM;QACN,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,MAAM,cAAc,GAAG,CA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YAAY,CAAC,CACjC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAEzB;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,MAAM,CAAC,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.elm-html-viewer {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template: "header" 2.75rem "divider" 1px "content" 1fr / 1fr;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 0;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
width: 100%;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0.25rem;
|
|
10
|
+
border-radius: 0.25rem;
|
|
11
|
+
background-color: var(--elmethis-color-surface-raised);
|
|
12
|
+
box-shadow: 0 0 0.125rem var(--elmethis-box-shadow-color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.header {
|
|
16
|
+
grid-area: header;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: flex-end;
|
|
19
|
+
gap: 0.25rem;
|
|
20
|
+
padding-inline-end: 0.25rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.icon-button {
|
|
24
|
+
display: grid;
|
|
25
|
+
place-items: center;
|
|
26
|
+
width: 2rem;
|
|
27
|
+
height: 2rem;
|
|
28
|
+
padding: 0;
|
|
29
|
+
border: none;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
color: var(--elmethis-color-neutral-strong);
|
|
32
|
+
background: transparent;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition:
|
|
35
|
+
color 160ms ease,
|
|
36
|
+
background-color 160ms ease;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.icon-button:hover {
|
|
40
|
+
color: var(--elmethis-color-primary);
|
|
41
|
+
background-color: var(--elmethis-color-primary-hover);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.icon-button:focus-visible {
|
|
45
|
+
outline: 2px solid var(--elmethis-color-primary);
|
|
46
|
+
outline-offset: 2px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.divider {
|
|
50
|
+
grid-area: divider;
|
|
51
|
+
width: calc(100% - 1rem);
|
|
52
|
+
margin-inline: auto;
|
|
53
|
+
border: none;
|
|
54
|
+
border-bottom: solid 1px rgb(128 128 128 / 50%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.content {
|
|
58
|
+
grid-area: content;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
padding: 0 0.25rem;
|
|
61
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { createEffect, createMemo, createSignal, mergeProps, on, onCleanup, Show, splitProps, } from "solid-js";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import styles from "./elm-html.module.css";
|
|
4
|
+
const AUTO_HEIGHT_MESSAGE_KIND = "elmethis:elm-html:auto-height";
|
|
5
|
+
const PROTECTED_ATTRIBUTES = new Set([
|
|
6
|
+
"referrerpolicy",
|
|
7
|
+
"sandbox",
|
|
8
|
+
"src",
|
|
9
|
+
"srcdoc",
|
|
10
|
+
]);
|
|
11
|
+
function sandboxHasAllowScripts(sandbox, allowScripts) {
|
|
12
|
+
if (allowScripts)
|
|
13
|
+
return true;
|
|
14
|
+
return (sandbox?.split(/\s+/).filter(Boolean) ?? []).some((token) => token.toLowerCase() === "allow-scripts");
|
|
15
|
+
}
|
|
16
|
+
function normalizeSandbox(sandbox, autoHeight, allowScripts) {
|
|
17
|
+
const tokens = sandbox
|
|
18
|
+
?.split(/\s+/)
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.map((token) => token.toLowerCase()) ?? [];
|
|
21
|
+
const hasToken = (name) => tokens.some((token) => token.toLowerCase() === name);
|
|
22
|
+
if (allowScripts && !hasToken("allow-scripts"))
|
|
23
|
+
tokens.push("allow-scripts");
|
|
24
|
+
if (sandboxHasAllowScripts(sandbox, allowScripts)) {
|
|
25
|
+
return tokens
|
|
26
|
+
.filter((token) => token.toLowerCase() !== "allow-same-origin")
|
|
27
|
+
.join(" ");
|
|
28
|
+
}
|
|
29
|
+
if (autoHeight && !hasToken("allow-same-origin")) {
|
|
30
|
+
tokens.push("allow-same-origin");
|
|
31
|
+
}
|
|
32
|
+
return tokens.join(" ");
|
|
33
|
+
}
|
|
34
|
+
// The reporter runs inside an opaque, script-enabled sandbox. Its namespaced
|
|
35
|
+
// message is accepted only when the browser-authenticated event.source is the
|
|
36
|
+
// iframe's own WindowProxy.
|
|
37
|
+
function withAutoHeightReporter(html) {
|
|
38
|
+
return `${html}
|
|
39
|
+
<script>(function () {
|
|
40
|
+
var send = function () {
|
|
41
|
+
try {
|
|
42
|
+
parent.postMessage(
|
|
43
|
+
{ kind: ${JSON.stringify(AUTO_HEIGHT_MESSAGE_KIND)}, height: document.documentElement.scrollHeight },
|
|
44
|
+
"*"
|
|
45
|
+
);
|
|
46
|
+
} catch (e) {}
|
|
47
|
+
};
|
|
48
|
+
new ResizeObserver(send).observe(document.documentElement);
|
|
49
|
+
send();
|
|
50
|
+
})();</script>`;
|
|
51
|
+
}
|
|
52
|
+
function withoutProtectedAttributes(props) {
|
|
53
|
+
const safe = {};
|
|
54
|
+
for (const name of Object.keys(props)) {
|
|
55
|
+
if (PROTECTED_ATTRIBUTES.has(name.toLowerCase()))
|
|
56
|
+
continue;
|
|
57
|
+
Object.defineProperty(safe, name, {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: () => Reflect.get(props, name),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return safe;
|
|
64
|
+
}
|
|
65
|
+
function mergeMeasuredHeight(style, height) {
|
|
66
|
+
if (height === undefined)
|
|
67
|
+
return style;
|
|
68
|
+
if (typeof style === "string") {
|
|
69
|
+
return [style.trim().replace(/;$/, ""), `height:${height}px`]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join(";");
|
|
72
|
+
}
|
|
73
|
+
return { ...(style ?? {}), height: `${height}px` };
|
|
74
|
+
}
|
|
75
|
+
const ElmHtmlFrame = (props) => {
|
|
76
|
+
let iframe;
|
|
77
|
+
const [contentHeight, setContentHeight] = createSignal();
|
|
78
|
+
const hasAllowScripts = createMemo(() => sandboxHasAllowScripts(props.sandbox, props.allowScripts));
|
|
79
|
+
const effectiveSandbox = createMemo(() => normalizeSandbox(props.sandbox, props.autoHeight, props.allowScripts));
|
|
80
|
+
createEffect(on(() => [props.html, props.src, props.sandbox, props.allowScripts], ([, src, sandbox, allowScripts]) => {
|
|
81
|
+
setContentHeight(undefined);
|
|
82
|
+
if (!props.autoHeight || !iframe)
|
|
83
|
+
return;
|
|
84
|
+
const scriptsAllowed = sandboxHasAllowScripts(sandbox, allowScripts);
|
|
85
|
+
if (src !== undefined && scriptsAllowed)
|
|
86
|
+
return;
|
|
87
|
+
if (scriptsAllowed) {
|
|
88
|
+
const onMessage = (event) => {
|
|
89
|
+
if (event.source !== iframe?.contentWindow)
|
|
90
|
+
return;
|
|
91
|
+
const data = event.data;
|
|
92
|
+
if (!data ||
|
|
93
|
+
data.kind !== AUTO_HEIGHT_MESSAGE_KIND ||
|
|
94
|
+
typeof data.height !== "number") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setContentHeight(data.height);
|
|
98
|
+
};
|
|
99
|
+
window.addEventListener("message", onMessage);
|
|
100
|
+
onCleanup(() => window.removeEventListener("message", onMessage));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let observer;
|
|
104
|
+
const contentRoot = () => {
|
|
105
|
+
try {
|
|
106
|
+
return iframe?.contentDocument?.documentElement;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const measure = () => {
|
|
113
|
+
const root = contentRoot();
|
|
114
|
+
if (root)
|
|
115
|
+
setContentHeight(root.scrollHeight);
|
|
116
|
+
};
|
|
117
|
+
const attachObserver = () => {
|
|
118
|
+
const root = contentRoot();
|
|
119
|
+
if (!root)
|
|
120
|
+
return;
|
|
121
|
+
observer?.disconnect();
|
|
122
|
+
observer = new ResizeObserver(measure);
|
|
123
|
+
observer.observe(root);
|
|
124
|
+
};
|
|
125
|
+
const onLoad = () => {
|
|
126
|
+
measure();
|
|
127
|
+
attachObserver();
|
|
128
|
+
};
|
|
129
|
+
iframe.addEventListener("load", onLoad);
|
|
130
|
+
onCleanup(() => {
|
|
131
|
+
iframe?.removeEventListener("load", onLoad);
|
|
132
|
+
observer?.disconnect();
|
|
133
|
+
});
|
|
134
|
+
}));
|
|
135
|
+
const usingSrc = () => props.src !== undefined;
|
|
136
|
+
const callerHasObjectHeight = () => typeof props.style !== "string" && props.style?.height !== undefined;
|
|
137
|
+
return (<iframe {...props.nativeProps} ref={(element) => {
|
|
138
|
+
iframe = element;
|
|
139
|
+
if (typeof props.forwardedRef === "function") {
|
|
140
|
+
props.forwardedRef(element);
|
|
141
|
+
}
|
|
142
|
+
}} title={props.title ?? "Embedded HTML content"} class={clsx(styles["elm-html"], props.class)} style={props.autoHeight
|
|
143
|
+
? mergeMeasuredHeight(props.style, contentHeight())
|
|
144
|
+
: props.style} height={props.autoHeight
|
|
145
|
+
? contentHeight() === undefined && !callerHasObjectHeight()
|
|
146
|
+
? props.height
|
|
147
|
+
: undefined
|
|
148
|
+
: props.height} src={usingSrc() ? props.src : undefined} srcdoc={usingSrc()
|
|
149
|
+
? undefined
|
|
150
|
+
: props.autoHeight && hasAllowScripts()
|
|
151
|
+
? withAutoHeightReporter(props.html ?? "")
|
|
152
|
+
: (props.html ?? "")} sandbox={effectiveSandbox()} referrerpolicy={usingSrc() ? "no-referrer" : undefined}/>);
|
|
153
|
+
};
|
|
154
|
+
export const ElmHtml = (props) => {
|
|
155
|
+
const merged = mergeProps({ autoHeight: true, allowScripts: false }, props);
|
|
156
|
+
const [local, rest] = splitProps(merged, [
|
|
157
|
+
"allowScripts",
|
|
158
|
+
"autoHeight",
|
|
159
|
+
"class",
|
|
160
|
+
"children",
|
|
161
|
+
"height",
|
|
162
|
+
"html",
|
|
163
|
+
"ref",
|
|
164
|
+
"sandbox",
|
|
165
|
+
"src",
|
|
166
|
+
"style",
|
|
167
|
+
"title",
|
|
168
|
+
]);
|
|
169
|
+
const nativeProps = withoutProtectedAttributes(rest);
|
|
170
|
+
const frame = (autoHeight) => (<ElmHtmlFrame html={local.html} src={local.src} autoHeight={autoHeight} allowScripts={local.allowScripts} sandbox={local.sandbox} title={local.title} class={local.class} style={local.style} height={local.height} forwardedRef={local.ref} nativeProps={nativeProps}/>);
|
|
171
|
+
// A JSX `key` is not a remount instruction in Solid. These mutually
|
|
172
|
+
// exclusive owned branches dispose and recreate the iframe browsing context
|
|
173
|
+
// whenever autoHeight changes, so sandbox flags apply to a fresh navigation.
|
|
174
|
+
return (<Show when={local.autoHeight} keyed fallback={frame(false)}>
|
|
175
|
+
{frame(true)}
|
|
176
|
+
</Show>);
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=elm-html.jsx.map
|