@maizzle/framework 6.0.0-rc.8 → 6.0.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/README.md +3 -3
- package/bin/maizzle.mjs +1 -1
- package/dist/build.d.ts +38 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +234 -0
- package/dist/build.js.map +1 -0
- package/dist/components/Body.vue +32 -3
- package/dist/components/Button.vue +91 -62
- package/dist/components/CodeBlock.vue +6 -4
- package/dist/components/CodeInline.vue +77 -6
- package/dist/components/Column.vue +67 -31
- package/dist/components/Container.vue +73 -12
- package/dist/components/Font.vue +96 -0
- package/dist/components/Head.vue +1 -1
- package/dist/components/Heading.vue +1 -1
- package/dist/components/Hr.vue +33 -0
- package/dist/components/Html.vue +36 -3
- package/dist/components/Img.vue +332 -0
- package/dist/components/Layout.vue +71 -21
- package/dist/components/Link.vue +1 -1
- package/dist/components/Markdown.vue +56 -23
- package/dist/components/MarkdownLayout.vue +39 -0
- package/dist/components/NotPlaintext.vue +14 -0
- package/dist/components/Outlook.vue +38 -11
- package/dist/components/OutlookBg.vue +241 -0
- package/dist/components/Plaintext.vue +14 -0
- package/dist/components/Preheader.vue +35 -10
- package/dist/components/QrCode.vue +157 -0
- package/dist/components/Raw.vue +28 -0
- package/dist/components/Row.vue +115 -22
- package/dist/components/Section.vue +65 -26
- package/dist/components/Spacer.vue +35 -29
- package/dist/components/Tailwind.vue +45 -0
- package/dist/components/Text.vue +3 -3
- package/dist/components/Vml.vue +207 -94
- package/dist/components/utils.d.ts +53 -0
- package/dist/components/utils.d.ts.map +1 -0
- package/dist/components/utils.js +80 -0
- package/dist/components/utils.js.map +1 -0
- package/dist/components/utils.ts +102 -0
- package/dist/composables/defineConfig.d.ts +13 -0
- package/dist/composables/defineConfig.d.ts.map +1 -0
- package/dist/composables/{defineConfig.mjs → defineConfig.js} +7 -9
- package/dist/composables/defineConfig.js.map +1 -0
- package/dist/composables/renderContext.d.ts +37 -0
- package/dist/composables/renderContext.d.ts.map +1 -0
- package/dist/composables/renderContext.js +6 -0
- package/dist/composables/renderContext.js.map +1 -0
- package/dist/composables/useBaseUrl.d.ts +19 -0
- package/dist/composables/useBaseUrl.d.ts.map +1 -0
- package/dist/composables/useBaseUrl.js +26 -0
- package/dist/composables/useBaseUrl.js.map +1 -0
- package/dist/composables/useConfig.d.ts +16 -0
- package/dist/composables/useConfig.d.ts.map +1 -0
- package/dist/composables/useConfig.js +19 -0
- package/dist/composables/useConfig.js.map +1 -0
- package/dist/composables/useCurrentTemplate.d.ts +31 -0
- package/dist/composables/useCurrentTemplate.d.ts.map +1 -0
- package/dist/composables/useCurrentTemplate.js +42 -0
- package/dist/composables/useCurrentTemplate.js.map +1 -0
- package/dist/composables/{useDoctype.d.mts → useDoctype.d.ts} +1 -1
- package/dist/composables/useDoctype.d.ts.map +1 -0
- package/dist/composables/{useDoctype.mjs → useDoctype.js} +3 -4
- package/dist/composables/useDoctype.js.map +1 -0
- package/dist/composables/{useEvent.d.mts → useEvent.d.ts} +3 -3
- package/dist/composables/useEvent.d.ts.map +1 -0
- package/dist/composables/{useEvent.mjs → useEvent.js} +4 -5
- package/dist/composables/useEvent.js.map +1 -0
- package/dist/composables/useFont.d.ts +50 -0
- package/dist/composables/useFont.d.ts.map +1 -0
- package/dist/composables/useFont.js +92 -0
- package/dist/composables/useFont.js.map +1 -0
- package/dist/composables/useOutlookFallback.d.ts +21 -0
- package/dist/composables/useOutlookFallback.d.ts.map +1 -0
- package/dist/composables/useOutlookFallback.js +29 -0
- package/dist/composables/useOutlookFallback.js.map +1 -0
- package/dist/composables/useOutputPath.d.ts +17 -0
- package/dist/composables/useOutputPath.d.ts.map +1 -0
- package/dist/composables/useOutputPath.js +23 -0
- package/dist/composables/useOutputPath.js.map +1 -0
- package/dist/composables/{usePlaintext.d.mts → usePlaintext.d.ts} +3 -1
- package/dist/composables/usePlaintext.d.ts.map +1 -0
- package/dist/composables/{usePlaintext.mjs → usePlaintext.js} +4 -4
- package/dist/composables/usePlaintext.js.map +1 -0
- package/dist/composables/usePreheader.d.ts +25 -0
- package/dist/composables/usePreheader.d.ts.map +1 -0
- package/dist/composables/usePreheader.js +28 -0
- package/dist/composables/usePreheader.js.map +1 -0
- package/dist/composables/useTransformers.d.ts +34 -0
- package/dist/composables/useTransformers.d.ts.map +1 -0
- package/dist/composables/useTransformers.js +48 -0
- package/dist/composables/useTransformers.js.map +1 -0
- package/dist/composables/useUrlQuery.d.ts +19 -0
- package/dist/composables/useUrlQuery.d.ts.map +1 -0
- package/dist/composables/useUrlQuery.js +26 -0
- package/dist/composables/useUrlQuery.js.map +1 -0
- package/dist/config/{defaults.d.mts → defaults.d.ts} +2 -2
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/{defaults.mjs → defaults.js} +10 -6
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +24 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/{index.mjs → index.js} +45 -14
- package/dist/config/index.js.map +1 -0
- package/dist/events/{index.d.mts → index.d.ts} +35 -12
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/{index.mjs → index.js} +31 -13
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +40 -0
- package/dist/{plaintext.d.mts → plaintext.d.ts} +1 -1
- package/dist/plaintext.d.ts.map +1 -0
- package/dist/{plaintext.mjs → plaintext.js} +4 -5
- package/dist/plaintext.js.map +1 -0
- package/dist/{plugin.d.mts → plugin.d.ts} +2 -2
- package/dist/plugin.d.ts.map +1 -0
- package/dist/{plugin.mjs → plugin.js} +16 -13
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/postcss/{mergeMediaQueries.d.mts → mergeMediaQueries.d.ts} +2 -2
- package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -0
- package/dist/plugins/postcss/{mergeMediaQueries.mjs → mergeMediaQueries.js} +2 -3
- package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -0
- package/dist/plugins/postcss/{pruneVars.d.mts → pruneVars.d.ts} +1 -1
- package/dist/plugins/postcss/pruneVars.d.ts.map +1 -0
- package/dist/plugins/postcss/{pruneVars.mjs → pruneVars.js} +2 -2
- package/dist/plugins/postcss/pruneVars.js.map +1 -0
- package/dist/plugins/postcss/quoteFontFamilies.d.ts +13 -0
- package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -0
- package/dist/plugins/postcss/quoteFontFamilies.js +84 -0
- package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -0
- package/dist/plugins/postcss/{removeDeclarations.d.mts → removeDeclarations.d.ts} +1 -1
- package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -0
- package/dist/plugins/postcss/{removeDeclarations.mjs → removeDeclarations.js} +2 -2
- package/dist/plugins/postcss/removeDeclarations.js.map +1 -0
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts +16 -0
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -0
- package/dist/plugins/postcss/resolveMaizzleImports.js +39 -0
- package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -0
- package/dist/plugins/postcss/resolveProps.d.ts +8 -0
- package/dist/plugins/postcss/resolveProps.d.ts.map +1 -0
- package/dist/plugins/postcss/resolveProps.js +155 -0
- package/dist/plugins/postcss/resolveProps.js.map +1 -0
- package/dist/plugins/postcss/{tailwindCleanup.d.mts → tailwindCleanup.d.ts} +2 -2
- package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -0
- package/dist/plugins/postcss/{tailwindCleanup.mjs → tailwindCleanup.js} +29 -5
- package/dist/plugins/postcss/tailwindCleanup.js.map +1 -0
- package/dist/prepare.d.ts +17 -0
- package/dist/prepare.d.ts.map +1 -0
- package/dist/prepare.js +44 -0
- package/dist/prepare.js.map +1 -0
- package/dist/render/active.d.ts +8 -0
- package/dist/render/active.d.ts.map +1 -0
- package/dist/render/active.js +12 -0
- package/dist/render/active.js.map +1 -0
- package/dist/render/buildTemplate.d.ts +49 -0
- package/dist/render/buildTemplate.d.ts.map +1 -0
- package/dist/render/buildTemplate.js +141 -0
- package/dist/render/buildTemplate.js.map +1 -0
- package/dist/render/{createRenderer.d.mts → createRenderer.d.ts} +17 -6
- package/dist/render/createRenderer.d.ts.map +1 -0
- package/dist/render/createRenderer.js +468 -0
- package/dist/render/createRenderer.js.map +1 -0
- package/dist/render/index.d.ts +18 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +59 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/injectFonts.d.ts +15 -0
- package/dist/render/injectFonts.d.ts.map +1 -0
- package/dist/render/injectFonts.js +45 -0
- package/dist/render/injectFonts.js.map +1 -0
- package/dist/render/parallel/buildWorker.d.ts +31 -0
- package/dist/render/parallel/buildWorker.d.ts.map +1 -0
- package/dist/render/parallel/buildWorker.js +66 -0
- package/dist/render/parallel/buildWorker.js.map +1 -0
- package/dist/render/parallel/worker.mjs +28 -0
- package/dist/render/plugins/codeBlockExtract.d.ts +14 -0
- package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -0
- package/dist/render/plugins/codeBlockExtract.js +38 -0
- package/dist/render/plugins/codeBlockExtract.js.map +1 -0
- package/dist/render/plugins/markdownExtract.d.ts +12 -0
- package/dist/render/plugins/markdownExtract.d.ts.map +1 -0
- package/dist/render/plugins/markdownExtract.js +49 -0
- package/dist/render/plugins/markdownExtract.js.map +1 -0
- package/dist/render/plugins/rawExtract.d.ts +14 -0
- package/dist/render/plugins/rawExtract.d.ts.map +1 -0
- package/dist/render/plugins/rawExtract.js +34 -0
- package/dist/render/plugins/rawExtract.js.map +1 -0
- package/dist/render/plugins/rowSourceLocation.d.ts +18 -0
- package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -0
- package/dist/render/plugins/rowSourceLocation.js +45 -0
- package/dist/render/plugins/rowSourceLocation.js.map +1 -0
- package/dist/{serve.d.mts → serve.d.ts} +5 -3
- package/dist/serve.d.ts.map +1 -0
- package/dist/{serve.mjs → serve.js} +207 -106
- package/dist/serve.js.map +1 -0
- package/dist/server/compatibility.d.ts +59 -0
- package/dist/server/compatibility.d.ts.map +1 -0
- package/dist/server/compatibility.js +959 -0
- package/dist/server/compatibility.js.map +1 -0
- package/dist/server/{email.d.mts → email.d.ts} +2 -2
- package/dist/server/email.d.ts.map +1 -0
- package/dist/server/{email.mjs → email.js} +2 -3
- package/dist/server/email.js.map +1 -0
- package/dist/server/linter.d.ts +20 -0
- package/dist/server/linter.d.ts.map +1 -0
- package/dist/server/linter.js +345 -0
- package/dist/server/linter.js.map +1 -0
- package/dist/server/sfc-utils.d.ts +21 -0
- package/dist/server/sfc-utils.d.ts.map +1 -0
- package/dist/server/sfc-utils.js +198 -0
- package/dist/server/sfc-utils.js.map +1 -0
- package/dist/server/ui/.vite/deps/@lucide_vue.js +44967 -0
- package/dist/server/ui/.vite/deps/@lucide_vue.js.map +1 -0
- package/dist/server/ui/.vite/deps/@vueuse_core.js +8155 -0
- package/dist/server/ui/.vite/deps/@vueuse_core.js.map +1 -0
- package/dist/server/ui/.vite/deps/@vueuse_shared.js +1859 -0
- package/dist/server/ui/.vite/deps/@vueuse_shared.js.map +1 -0
- package/dist/server/ui/.vite/deps/_metadata.json +78 -0
- package/dist/server/ui/.vite/deps/chunk-EAsCxrDo.js +14 -0
- package/dist/server/ui/.vite/deps/class-variance-authority.js +57 -0
- package/dist/server/ui/.vite/deps/class-variance-authority.js.map +1 -0
- package/dist/server/ui/.vite/deps/clsx.js +18 -0
- package/dist/server/ui/.vite/deps/clsx.js.map +1 -0
- package/dist/server/ui/.vite/deps/culori.js +4312 -0
- package/dist/server/ui/.vite/deps/culori.js.map +1 -0
- package/dist/server/ui/.vite/deps/package.json +3 -0
- package/dist/server/ui/.vite/deps/reka-ui.js +44464 -0
- package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -0
- package/dist/server/ui/.vite/deps/tailwind-merge.js +3458 -0
- package/dist/server/ui/.vite/deps/tailwind-merge.js.map +1 -0
- package/dist/server/ui/.vite/deps/vue-router.js +6383 -0
- package/dist/server/ui/.vite/deps/vue-router.js.map +1 -0
- package/dist/server/ui/.vite/deps/vue.js +2 -0
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js +8785 -0
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js.map +1 -0
- package/dist/server/ui/App.vue +106 -66
- package/dist/server/ui/components/SidebarClose.vue +12 -0
- package/dist/server/ui/components/ui/checkbox/Checkbox.vue +1 -1
- package/dist/server/ui/components/ui/command/Command.vue +5 -1
- package/dist/server/ui/components/ui/command/CommandInput.vue +2 -2
- package/dist/server/ui/components/ui/dialog/DialogContent.vue +1 -1
- package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
- package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/dist/server/ui/components/ui/input/Input.vue +1 -1
- package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
- package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +2 -2
- package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +1 -1
- package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +1 -1
- package/dist/server/ui/lib/emulated-dark-mode.ts +146 -0
- package/dist/server/ui/main.css +25 -0
- package/dist/server/ui/pages/Home.vue +1 -1
- package/dist/server/ui/pages/Preview.vue +377 -186
- package/dist/server/ui/vite-env.d.ts +1 -0
- package/dist/tests/render/_helpers.d.ts +6 -0
- package/dist/tests/render/_helpers.d.ts.map +1 -0
- package/dist/tests/render/_helpers.js +16 -0
- package/dist/tests/render/_helpers.js.map +1 -0
- package/dist/transformers/addAttributes.d.ts +42 -0
- package/dist/transformers/addAttributes.d.ts.map +1 -0
- package/dist/transformers/{addAttributes.mjs → addAttributes.js} +40 -24
- package/dist/transformers/addAttributes.js.map +1 -0
- package/dist/transformers/attributeToStyle.d.ts +38 -0
- package/dist/transformers/attributeToStyle.d.ts.map +1 -0
- package/dist/transformers/attributeToStyle.js +94 -0
- package/dist/transformers/attributeToStyle.js.map +1 -0
- package/dist/transformers/base.d.ts +71 -0
- package/dist/transformers/base.d.ts.map +1 -0
- package/dist/transformers/{base.mjs → base.js} +65 -40
- package/dist/transformers/base.js.map +1 -0
- package/dist/transformers/columnWidth.d.ts +31 -0
- package/dist/transformers/columnWidth.d.ts.map +1 -0
- package/dist/transformers/columnWidth.js +527 -0
- package/dist/transformers/columnWidth.js.map +1 -0
- package/dist/transformers/entities.d.ts +37 -0
- package/dist/transformers/entities.d.ts.map +1 -0
- package/dist/transformers/entities.js +74 -0
- package/dist/transformers/entities.js.map +1 -0
- package/dist/transformers/filters/{defaults.d.mts → defaults.d.ts} +1 -1
- package/dist/transformers/filters/defaults.d.ts.map +1 -0
- package/dist/transformers/filters/{defaults.mjs → defaults.js} +2 -2
- package/dist/transformers/filters/defaults.js.map +1 -0
- package/dist/transformers/filters/index.d.ts +43 -0
- package/dist/transformers/filters/index.d.ts.map +1 -0
- package/dist/transformers/filters/index.js +89 -0
- package/dist/transformers/filters/index.js.map +1 -0
- package/dist/transformers/format.d.ts +22 -0
- package/dist/transformers/format.d.ts.map +1 -0
- package/dist/transformers/format.js +30 -0
- package/dist/transformers/format.js.map +1 -0
- package/dist/transformers/imgWidth.d.ts +20 -0
- package/dist/transformers/imgWidth.d.ts.map +1 -0
- package/dist/transformers/imgWidth.js +76 -0
- package/dist/transformers/imgWidth.js.map +1 -0
- package/dist/transformers/{index.d.mts → index.d.ts} +14 -12
- package/dist/transformers/index.d.ts.map +1 -0
- package/dist/transformers/index.js +163 -0
- package/dist/transformers/index.js.map +1 -0
- package/dist/transformers/inlineCss.d.ts +85 -0
- package/dist/transformers/inlineCss.d.ts.map +1 -0
- package/dist/transformers/inlineCss.js +112 -0
- package/dist/transformers/inlineCss.js.map +1 -0
- package/dist/transformers/inlineLink.d.ts +35 -0
- package/dist/transformers/inlineLink.d.ts.map +1 -0
- package/dist/transformers/{inlineLink.mjs → inlineLink.js} +35 -11
- package/dist/transformers/inlineLink.js.map +1 -0
- package/dist/transformers/minify.d.ts +21 -0
- package/dist/transformers/minify.d.ts.map +1 -0
- package/dist/transformers/minify.js +25 -0
- package/dist/transformers/minify.js.map +1 -0
- package/dist/transformers/minifyCodeInline.d.ts +29 -0
- package/dist/transformers/minifyCodeInline.d.ts.map +1 -0
- package/dist/transformers/minifyCodeInline.js +36 -0
- package/dist/transformers/minifyCodeInline.js.map +1 -0
- package/dist/transformers/msoPlaceholders.d.ts +33 -0
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -0
- package/dist/transformers/msoPlaceholders.js +114 -0
- package/dist/transformers/msoPlaceholders.js.map +1 -0
- package/dist/transformers/purgeCss.d.ts +43 -0
- package/dist/transformers/purgeCss.d.ts.map +1 -0
- package/dist/transformers/purgeCss.js +207 -0
- package/dist/transformers/purgeCss.js.map +1 -0
- package/dist/transformers/removeAttributes.d.ts +54 -0
- package/dist/transformers/removeAttributes.d.ts.map +1 -0
- package/dist/transformers/removeAttributes.js +72 -0
- package/dist/transformers/removeAttributes.js.map +1 -0
- package/dist/transformers/{replaceStrings.d.mts → replaceStrings.d.ts} +2 -2
- package/dist/transformers/replaceStrings.d.ts.map +1 -0
- package/dist/transformers/{replaceStrings.mjs → replaceStrings.js} +2 -2
- package/dist/transformers/replaceStrings.js.map +1 -0
- package/dist/transformers/safeSelectors.d.ts +37 -0
- package/dist/transformers/safeSelectors.d.ts.map +1 -0
- package/dist/transformers/{safeClassNames.mjs → safeSelectors.js} +40 -10
- package/dist/transformers/safeSelectors.js.map +1 -0
- package/dist/transformers/shorthandCss.d.ts +47 -0
- package/dist/transformers/shorthandCss.d.ts.map +1 -0
- package/dist/transformers/shorthandCss.js +92 -0
- package/dist/transformers/shorthandCss.js.map +1 -0
- package/dist/transformers/sixHex.d.ts +25 -0
- package/dist/transformers/sixHex.d.ts.map +1 -0
- package/dist/transformers/sixHex.js +42 -0
- package/dist/transformers/sixHex.js.map +1 -0
- package/dist/transformers/tailwindComponent.d.ts +16 -0
- package/dist/transformers/tailwindComponent.d.ts.map +1 -0
- package/dist/transformers/tailwindComponent.js +101 -0
- package/dist/transformers/tailwindComponent.js.map +1 -0
- package/dist/transformers/{tailwindcss.d.mts → tailwindcss.d.ts} +2 -2
- package/dist/transformers/tailwindcss.d.ts.map +1 -0
- package/dist/transformers/{tailwindcss.mjs → tailwindcss.js} +33 -74
- package/dist/transformers/tailwindcss.js.map +1 -0
- package/dist/transformers/urlQuery.d.ts +36 -0
- package/dist/transformers/urlQuery.d.ts.map +1 -0
- package/dist/transformers/urlQuery.js +77 -0
- package/dist/transformers/urlQuery.js.map +1 -0
- package/dist/types/{config.d.mts → config.d.ts} +270 -40
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/ast/index.d.ts +4 -0
- package/dist/utils/ast/index.js +4 -0
- package/dist/utils/ast/{parser.d.mts → parser.d.ts} +1 -1
- package/dist/utils/ast/parser.d.ts.map +1 -0
- package/dist/utils/ast/{parser.mjs → parser.js} +2 -3
- package/dist/utils/ast/parser.js.map +1 -0
- package/dist/utils/ast/{serializer.d.mts → serializer.d.ts} +1 -1
- package/dist/utils/ast/serializer.d.ts.map +1 -0
- package/dist/utils/ast/serializer.js +46 -0
- package/dist/utils/ast/serializer.js.map +1 -0
- package/dist/utils/ast/{walker.d.mts → walker.d.ts} +1 -1
- package/dist/utils/ast/walker.d.ts.map +1 -0
- package/dist/utils/ast/{walker.mjs → walker.js} +2 -2
- package/dist/utils/ast/walker.js.map +1 -0
- package/dist/utils/cloneConfig.d.ts +13 -0
- package/dist/utils/cloneConfig.d.ts.map +1 -0
- package/dist/utils/cloneConfig.js +21 -0
- package/dist/utils/cloneConfig.js.map +1 -0
- package/dist/utils/compileTailwindCss.d.ts +16 -0
- package/dist/utils/compileTailwindCss.d.ts.map +1 -0
- package/dist/utils/compileTailwindCss.js +55 -0
- package/dist/utils/compileTailwindCss.js.map +1 -0
- package/dist/utils/componentSources.d.ts +50 -0
- package/dist/utils/componentSources.d.ts.map +1 -0
- package/dist/utils/componentSources.js +50 -0
- package/dist/utils/componentSources.js.map +1 -0
- package/dist/utils/cssBox.d.ts +42 -0
- package/dist/utils/cssBox.d.ts.map +1 -0
- package/dist/utils/cssBox.js +151 -0
- package/dist/utils/cssBox.js.map +1 -0
- package/dist/utils/decodeStyleEntities.d.ts +15 -0
- package/dist/utils/decodeStyleEntities.d.ts.map +1 -0
- package/dist/utils/decodeStyleEntities.js +18 -0
- package/dist/utils/decodeStyleEntities.js.map +1 -0
- package/dist/utils/{detect.d.mts → detect.d.ts} +1 -1
- package/dist/utils/detect.d.ts.map +1 -0
- package/dist/utils/{detect.mjs → detect.js} +2 -3
- package/dist/utils/detect.js.map +1 -0
- package/dist/utils/output-markers.d.ts +29 -0
- package/dist/utils/output-markers.d.ts.map +1 -0
- package/dist/utils/output-markers.js +68 -0
- package/dist/utils/output-markers.js.map +1 -0
- package/dist/utils/{url.d.mts → url.d.ts} +1 -1
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/{url.mjs → url.js} +2 -3
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/watchPaths.d.ts +11 -0
- package/dist/utils/watchPaths.d.ts.map +1 -0
- package/dist/utils/watchPaths.js +19 -0
- package/dist/utils/watchPaths.js.map +1 -0
- package/node_modules/@clack/core/CHANGELOG.md +44 -0
- package/node_modules/@clack/core/dist/index.d.mts +125 -5
- package/node_modules/@clack/core/dist/index.mjs +972 -11
- package/node_modules/@clack/core/package.json +6 -2
- package/node_modules/@clack/prompts/CHANGELOG.md +70 -0
- package/node_modules/@clack/prompts/README.md +129 -3
- package/node_modules/@clack/prompts/dist/index.d.mts +567 -33
- package/node_modules/@clack/prompts/dist/index.mjs +1378 -133
- package/node_modules/@clack/prompts/package.json +7 -4
- package/node_modules/fast-string-truncated-width/dist/index.js +36 -96
- package/node_modules/fast-string-truncated-width/dist/types.d.ts +0 -3
- package/node_modules/fast-string-truncated-width/dist/utils.d.ts +3 -3
- package/node_modules/fast-string-truncated-width/dist/utils.js +14 -9
- package/node_modules/fast-string-truncated-width/package.json +1 -1
- package/node_modules/fast-string-truncated-width/readme.md +2 -3
- package/node_modules/fast-string-width/package.json +2 -2
- package/node_modules/fast-string-width/readme.md +0 -3
- package/node_modules/fast-wrap-ansi/lib/main.js +4 -2
- package/node_modules/fast-wrap-ansi/package.json +11 -11
- package/node_modules/maizzle/README.md +24 -0
- package/node_modules/maizzle/dist/commands/make/component.mjs +1 -1
- package/node_modules/maizzle/dist/commands/make/config.mjs +8 -7
- package/node_modules/maizzle/dist/commands/make/layout.mjs +3 -3
- package/node_modules/maizzle/dist/commands/make/scaffold.mjs +1 -1
- package/node_modules/maizzle/dist/commands/make/stubs/Layout.vue +146 -0
- package/node_modules/maizzle/dist/commands/make/stubs/component.vue +2 -4
- package/node_modules/maizzle/dist/commands/make/stubs/config.ts +1 -5
- package/node_modules/maizzle/dist/commands/make/template.mjs +1 -1
- package/node_modules/maizzle/dist/commands/new.mjs +46 -135
- package/node_modules/maizzle/dist/index.d.mts +1 -0
- package/node_modules/maizzle/dist/index.mjs +30 -7
- package/node_modules/maizzle/package.json +5 -4
- package/node_modules/nypm/dist/cli.mjs +28 -5
- package/node_modules/nypm/dist/index.d.mts +0 -8
- package/node_modules/nypm/dist/index.mjs +27 -4
- package/node_modules/nypm/package.json +12 -12
- package/node_modules/tinyexec/README.md +9 -1
- package/node_modules/tinyexec/dist/main.d.mts +22 -7
- package/node_modules/tinyexec/dist/main.mjs +189 -491
- package/node_modules/tinyexec/package.json +14 -16
- package/package.json +38 -30
- package/dist/build.d.mts +0 -19
- package/dist/build.d.mts.map +0 -1
- package/dist/build.mjs +0 -140
- package/dist/build.mjs.map +0 -1
- package/dist/components/Divider.vue +0 -133
- package/dist/components/Image.vue +0 -70
- package/dist/components/Overlap.vue +0 -80
- package/dist/components/utils.d.mts +0 -5
- package/dist/components/utils.d.mts.map +0 -1
- package/dist/components/utils.mjs +0 -9
- package/dist/components/utils.mjs.map +0 -1
- package/dist/composables/defineConfig.d.mts +0 -14
- package/dist/composables/defineConfig.d.mts.map +0 -1
- package/dist/composables/defineConfig.mjs.map +0 -1
- package/dist/composables/renderContext.d.mts +0 -24
- package/dist/composables/renderContext.d.mts.map +0 -1
- package/dist/composables/renderContext.mjs +0 -6
- package/dist/composables/renderContext.mjs.map +0 -1
- package/dist/composables/useConfig.d.mts +0 -9
- package/dist/composables/useConfig.d.mts.map +0 -1
- package/dist/composables/useConfig.mjs +0 -13
- package/dist/composables/useConfig.mjs.map +0 -1
- package/dist/composables/useDoctype.d.mts.map +0 -1
- package/dist/composables/useDoctype.mjs.map +0 -1
- package/dist/composables/useEvent.d.mts.map +0 -1
- package/dist/composables/useEvent.mjs.map +0 -1
- package/dist/composables/usePlaintext.d.mts.map +0 -1
- package/dist/composables/usePlaintext.mjs.map +0 -1
- package/dist/composables/usePreviewText.d.mts +0 -24
- package/dist/composables/usePreviewText.d.mts.map +0 -1
- package/dist/composables/usePreviewText.mjs +0 -29
- package/dist/composables/usePreviewText.mjs.map +0 -1
- package/dist/config/defaults.d.mts.map +0 -1
- package/dist/config/defaults.mjs.map +0 -1
- package/dist/config/index.d.mts +0 -15
- package/dist/config/index.d.mts.map +0 -1
- package/dist/config/index.mjs.map +0 -1
- package/dist/events/index.d.mts.map +0 -1
- package/dist/events/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -30
- package/dist/index.mjs +0 -30
- package/dist/plaintext.d.mts.map +0 -1
- package/dist/plaintext.mjs.map +0 -1
- package/dist/plugin.d.mts.map +0 -1
- package/dist/plugin.mjs.map +0 -1
- package/dist/plugins/postcss/mergeMediaQueries.d.mts.map +0 -1
- package/dist/plugins/postcss/mergeMediaQueries.mjs.map +0 -1
- package/dist/plugins/postcss/pruneVars.d.mts.map +0 -1
- package/dist/plugins/postcss/pruneVars.mjs.map +0 -1
- package/dist/plugins/postcss/removeDeclarations.d.mts.map +0 -1
- package/dist/plugins/postcss/removeDeclarations.mjs.map +0 -1
- package/dist/plugins/postcss/tailwindCleanup.d.mts.map +0 -1
- package/dist/plugins/postcss/tailwindCleanup.mjs.map +0 -1
- package/dist/render/createRenderer.d.mts.map +0 -1
- package/dist/render/createRenderer.mjs +0 -279
- package/dist/render/createRenderer.mjs.map +0 -1
- package/dist/render/index.d.mts +0 -26
- package/dist/render/index.d.mts.map +0 -1
- package/dist/render/index.mjs +0 -45
- package/dist/render/index.mjs.map +0 -1
- package/dist/serve.d.mts.map +0 -1
- package/dist/serve.mjs.map +0 -1
- package/dist/server/compatibility.d.mts +0 -5
- package/dist/server/compatibility.d.mts.map +0 -1
- package/dist/server/compatibility.mjs +0 -97
- package/dist/server/compatibility.mjs.map +0 -1
- package/dist/server/email.d.mts.map +0 -1
- package/dist/server/email.mjs.map +0 -1
- package/dist/server/linter.d.mts +0 -5
- package/dist/server/linter.d.mts.map +0 -1
- package/dist/server/linter.mjs +0 -189
- package/dist/server/linter.mjs.map +0 -1
- package/dist/transformers/addAttributes.d.mts +0 -32
- package/dist/transformers/addAttributes.d.mts.map +0 -1
- package/dist/transformers/addAttributes.mjs.map +0 -1
- package/dist/transformers/attributeToStyle.d.mts +0 -25
- package/dist/transformers/attributeToStyle.d.mts.map +0 -1
- package/dist/transformers/attributeToStyle.mjs +0 -80
- package/dist/transformers/attributeToStyle.mjs.map +0 -1
- package/dist/transformers/base.d.mts +0 -8
- package/dist/transformers/base.d.mts.map +0 -1
- package/dist/transformers/base.mjs.map +0 -1
- package/dist/transformers/entities.d.mts +0 -8
- package/dist/transformers/entities.d.mts.map +0 -1
- package/dist/transformers/entities.mjs +0 -41
- package/dist/transformers/entities.mjs.map +0 -1
- package/dist/transformers/filters/defaults.d.mts.map +0 -1
- package/dist/transformers/filters/defaults.mjs.map +0 -1
- package/dist/transformers/filters/index.d.mts +0 -22
- package/dist/transformers/filters/index.d.mts.map +0 -1
- package/dist/transformers/filters/index.mjs +0 -67
- package/dist/transformers/filters/index.mjs.map +0 -1
- package/dist/transformers/format.d.mts +0 -15
- package/dist/transformers/format.d.mts.map +0 -1
- package/dist/transformers/format.mjs +0 -26
- package/dist/transformers/format.mjs.map +0 -1
- package/dist/transformers/index.d.mts.map +0 -1
- package/dist/transformers/index.mjs +0 -78
- package/dist/transformers/index.mjs.map +0 -1
- package/dist/transformers/inlineCSS.d.mts +0 -17
- package/dist/transformers/inlineCSS.d.mts.map +0 -1
- package/dist/transformers/inlineCSS.mjs +0 -70
- package/dist/transformers/inlineCSS.mjs.map +0 -1
- package/dist/transformers/inlineLink.d.mts +0 -14
- package/dist/transformers/inlineLink.d.mts.map +0 -1
- package/dist/transformers/inlineLink.mjs.map +0 -1
- package/dist/transformers/minify.d.mts +0 -17
- package/dist/transformers/minify.d.mts.map +0 -1
- package/dist/transformers/minify.mjs +0 -24
- package/dist/transformers/minify.mjs.map +0 -1
- package/dist/transformers/purgeCSS.d.mts +0 -23
- package/dist/transformers/purgeCSS.d.mts.map +0 -1
- package/dist/transformers/purgeCSS.mjs +0 -132
- package/dist/transformers/purgeCSS.mjs.map +0 -1
- package/dist/transformers/removeAttributes.d.mts +0 -31
- package/dist/transformers/removeAttributes.d.mts.map +0 -1
- package/dist/transformers/removeAttributes.mjs +0 -63
- package/dist/transformers/removeAttributes.mjs.map +0 -1
- package/dist/transformers/replaceStrings.d.mts.map +0 -1
- package/dist/transformers/replaceStrings.mjs.map +0 -1
- package/dist/transformers/safeClassNames.d.mts +0 -22
- package/dist/transformers/safeClassNames.d.mts.map +0 -1
- package/dist/transformers/safeClassNames.mjs.map +0 -1
- package/dist/transformers/shorthandCSS.d.mts +0 -24
- package/dist/transformers/shorthandCSS.d.mts.map +0 -1
- package/dist/transformers/shorthandCSS.mjs +0 -48
- package/dist/transformers/shorthandCSS.mjs.map +0 -1
- package/dist/transformers/tailwindcss.d.mts.map +0 -1
- package/dist/transformers/tailwindcss.mjs.map +0 -1
- package/dist/transformers/urlQuery.d.mts +0 -24
- package/dist/transformers/urlQuery.d.mts.map +0 -1
- package/dist/transformers/urlQuery.mjs +0 -65
- package/dist/transformers/urlQuery.mjs.map +0 -1
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs +0 -1
- package/dist/types/index.d.mts +0 -2
- package/dist/types/index.mjs +0 -1
- package/dist/utils/ast/index.d.mts +0 -4
- package/dist/utils/ast/index.mjs +0 -5
- package/dist/utils/ast/parser.d.mts.map +0 -1
- package/dist/utils/ast/parser.mjs.map +0 -1
- package/dist/utils/ast/serializer.d.mts.map +0 -1
- package/dist/utils/ast/serializer.mjs +0 -37
- package/dist/utils/ast/serializer.mjs.map +0 -1
- package/dist/utils/ast/walker.d.mts.map +0 -1
- package/dist/utils/ast/walker.mjs.map +0 -1
- package/dist/utils/detect.d.mts.map +0 -1
- package/dist/utils/detect.mjs.map +0 -1
- package/dist/utils/url.d.mts.map +0 -1
- package/dist/utils/url.mjs.map +0 -1
- package/node_modules/@clack/core/dist/index.mjs.map +0 -1
- package/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
- package/node_modules/fast-wrap-ansi/lib/main.js.map +0 -1
- package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
- package/node_modules/tinyexec/dist/LICENSES.txt +0 -83
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChildNode } from "domhandler";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/columnWidth.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolve `__MAIZZLE_COLW_{id}__` and `__MAIZZLE_OH_{id}__` placeholders.
|
|
6
|
+
*
|
|
7
|
+
* COLW (column width) — emitted by `<Column>` and `<Overlap>`. Walks up to
|
|
8
|
+
* the nearest ancestor marked `data-maizzle-cw` (Container, Section,
|
|
9
|
+
* Row, or another Column already resolved) and divides the source
|
|
10
|
+
* width by `data-maizzle-cw-count`. With `data-maizzle-cw-self`,
|
|
11
|
+
* reads from the element's own inlined max/width/min-width
|
|
12
|
+
* instead — used by `<Overlap>` with its own width class.
|
|
13
|
+
*
|
|
14
|
+
* OH (overlap height) — emitted by `<Overlap>`. Reads max-height, height,
|
|
15
|
+
* or min-height from the element's own inlined style.
|
|
16
|
+
*
|
|
17
|
+
* Resolution rules:
|
|
18
|
+
* - Style placeholders for `min-width`: replaced when resolvable, otherwise
|
|
19
|
+
* the entire `min-width` declaration is stripped.
|
|
20
|
+
* - Other style placeholders (Overlap td `width`, etc.): replaced when
|
|
21
|
+
* resolvable, otherwise replaced with the count-based fallback or `100%`.
|
|
22
|
+
* - Comment placeholders: same fallback chain.
|
|
23
|
+
*
|
|
24
|
+
* Resolved column widths are written back to `data-maizzle-cw` so nested
|
|
25
|
+
* rows cascade. All `data-maizzle-cw*` and `data-maizzle-oh-*` are
|
|
26
|
+
* stripped at the end of the second walk pass.
|
|
27
|
+
*/
|
|
28
|
+
declare function columnWidth(dom: ChildNode[]): ChildNode[];
|
|
29
|
+
//#endregion
|
|
30
|
+
export { columnWidth };
|
|
31
|
+
//# sourceMappingURL=columnWidth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columnWidth.d.ts","names":[],"sources":["../../src/transformers/columnWidth.ts"],"mappings":";;;;;AAqKA;;;;;;;;AAAwD;;;;;;;;;;;;;;iBAAxC,WAAA,CAAY,GAAA,EAAK,SAAA,KAAc,SAAS"}
|
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { walk } from "../utils/ast/walker.js";
|
|
2
|
+
import "../utils/ast/index.js";
|
|
3
|
+
import { horizontalBorderPx, horizontalPaddingPx, lengthToPx } from "../utils/cssBox.js";
|
|
4
|
+
import postcss from "postcss";
|
|
5
|
+
import safeParser from "postcss-safe-parser";
|
|
6
|
+
//#region src/transformers/columnWidth.ts
|
|
7
|
+
const RE_PERCENT = /^[\d.]+%$/;
|
|
8
|
+
/**
|
|
9
|
+
* Stringify decls into a `; `-joined inline-style attribute. PostCSS raws
|
|
10
|
+
* preserve the original source spacing, which mixes poorly with
|
|
11
|
+
* the fresh decls we inject — plain join keeps output uniform.
|
|
12
|
+
*/
|
|
13
|
+
function serializeStyle(root) {
|
|
14
|
+
const parts = [];
|
|
15
|
+
root.walkDecls((d) => {
|
|
16
|
+
parts.push(`${d.prop}: ${d.value}${d.important ? " !important" : ""}`);
|
|
17
|
+
});
|
|
18
|
+
return parts.join("; ");
|
|
19
|
+
}
|
|
20
|
+
function firstDeclValue(root, prop) {
|
|
21
|
+
let found;
|
|
22
|
+
root.walkDecls(prop, (d) => {
|
|
23
|
+
found = d.value;
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Find the user-set `min-width:` value on a column. Juice keeps both ours
|
|
30
|
+
* and the one inlined from a class like `min-w-1/3` — we skip any
|
|
31
|
+
* min-width whose value still contains our placeholder token,
|
|
32
|
+
* returning the first remaining user value, or null.
|
|
33
|
+
*/
|
|
34
|
+
function findUserMinWidth(root) {
|
|
35
|
+
let userVal = null;
|
|
36
|
+
root.walkDecls("min-width", (d) => {
|
|
37
|
+
if (!d.value.includes("__MAIZZLE_COLW_")) {
|
|
38
|
+
userVal = d.value;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return userVal;
|
|
43
|
+
}
|
|
44
|
+
function resolveLength(value) {
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
if (RE_PERCENT.test(trimmed)) return trimmed;
|
|
47
|
+
const m = trimmed.match(/^([\d.]+)(px|rem|em|pt)?$/i);
|
|
48
|
+
if (!m) return null;
|
|
49
|
+
const n = parseFloat(m[1]);
|
|
50
|
+
const unit = (m[2] || "px").toLowerCase();
|
|
51
|
+
return `${Math.round(n * (unit === "rem" || unit === "em" ? 16 : unit === "pt" ? 1.333 : 1))}px`;
|
|
52
|
+
}
|
|
53
|
+
function divideLength(value, divisor) {
|
|
54
|
+
const m = value.match(/^([\d.]+)(px|%)$/);
|
|
55
|
+
if (!m || divisor < 1) return null;
|
|
56
|
+
const n = parseFloat(m[1]);
|
|
57
|
+
return `${parseFloat((n / divisor).toFixed(2))}${m[2]}`;
|
|
58
|
+
}
|
|
59
|
+
function subtractInsetPx(width, insetPx) {
|
|
60
|
+
if (insetPx <= 0) return width;
|
|
61
|
+
const m = width.match(/^([\d.]+)(px|%)$/);
|
|
62
|
+
if (!m) return width;
|
|
63
|
+
if (m[2] === "%") return width;
|
|
64
|
+
const n = parseFloat(m[1]) - insetPx;
|
|
65
|
+
return `${Math.max(0, Math.round(n))}px`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Return the smaller of two px lengths. Clamps our count-based min-width
|
|
69
|
+
* down to the user's `max-width:` so the cap is never silently
|
|
70
|
+
* violated when our computed min would exceed the user's max.
|
|
71
|
+
*/
|
|
72
|
+
function minPxLength(a, b) {
|
|
73
|
+
const am = a.match(/^([\d.]+)px$/);
|
|
74
|
+
const bm = b.match(/^([\d.]+)px$/);
|
|
75
|
+
if (!am || !bm) return a;
|
|
76
|
+
return parseFloat(am[1]) < parseFloat(bm[1]) ? a : b;
|
|
77
|
+
}
|
|
78
|
+
function depth(node) {
|
|
79
|
+
let d = 0;
|
|
80
|
+
let cur = node.parent;
|
|
81
|
+
while (cur) {
|
|
82
|
+
d++;
|
|
83
|
+
cur = cur.parent ?? null;
|
|
84
|
+
}
|
|
85
|
+
return d;
|
|
86
|
+
}
|
|
87
|
+
function readWidthFromRoot(root) {
|
|
88
|
+
const raw = firstDeclValue(root, "max-width") ?? firstDeclValue(root, "width") ?? firstDeclValue(root, "min-width");
|
|
89
|
+
return raw ? resolveLength(raw) : null;
|
|
90
|
+
}
|
|
91
|
+
function readHeightFromRoot(root) {
|
|
92
|
+
const raw = firstDeclValue(root, "max-height") ?? firstDeclValue(root, "height") ?? firstDeclValue(root, "min-height");
|
|
93
|
+
return raw ? resolveLength(raw) : null;
|
|
94
|
+
}
|
|
95
|
+
function readWidthSource(el, root) {
|
|
96
|
+
const explicit = el.attribs?.["data-maizzle-cw"];
|
|
97
|
+
if (explicit) {
|
|
98
|
+
const r = resolveLength(explicit);
|
|
99
|
+
if (r) return r;
|
|
100
|
+
}
|
|
101
|
+
return root ? readWidthFromRoot(root) : null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Convert a user-supplied length to absolute px against the column's source
|
|
105
|
+
* width (post-inset). Percentages multiply against the source while
|
|
106
|
+
* absolute units pass through `resolveLength`. Returns null when
|
|
107
|
+
* the value or source can't be expressed in px.
|
|
108
|
+
*/
|
|
109
|
+
function userValueToPx(rawValue, sourcePx) {
|
|
110
|
+
const trimmed = rawValue.trim();
|
|
111
|
+
if (trimmed.match(/^([\d.]+)(px|rem|em|pt)$/i)) return resolveLength(trimmed);
|
|
112
|
+
const pctMatch = trimmed.match(/^([\d.]+)%$/);
|
|
113
|
+
if (!pctMatch || !sourcePx) return null;
|
|
114
|
+
const sourceMatch = sourcePx.match(/^([\d.]+)px$/);
|
|
115
|
+
if (!sourceMatch) return null;
|
|
116
|
+
const pct = parseFloat(pctMatch[1]);
|
|
117
|
+
const src = parseFloat(sourceMatch[1]);
|
|
118
|
+
return `${Math.round(pct / 100 * src)}px`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Resolve `__MAIZZLE_COLW_{id}__` and `__MAIZZLE_OH_{id}__` placeholders.
|
|
122
|
+
*
|
|
123
|
+
* COLW (column width) — emitted by `<Column>` and `<Overlap>`. Walks up to
|
|
124
|
+
* the nearest ancestor marked `data-maizzle-cw` (Container, Section,
|
|
125
|
+
* Row, or another Column already resolved) and divides the source
|
|
126
|
+
* width by `data-maizzle-cw-count`. With `data-maizzle-cw-self`,
|
|
127
|
+
* reads from the element's own inlined max/width/min-width
|
|
128
|
+
* instead — used by `<Overlap>` with its own width class.
|
|
129
|
+
*
|
|
130
|
+
* OH (overlap height) — emitted by `<Overlap>`. Reads max-height, height,
|
|
131
|
+
* or min-height from the element's own inlined style.
|
|
132
|
+
*
|
|
133
|
+
* Resolution rules:
|
|
134
|
+
* - Style placeholders for `min-width`: replaced when resolvable, otherwise
|
|
135
|
+
* the entire `min-width` declaration is stripped.
|
|
136
|
+
* - Other style placeholders (Overlap td `width`, etc.): replaced when
|
|
137
|
+
* resolvable, otherwise replaced with the count-based fallback or `100%`.
|
|
138
|
+
* - Comment placeholders: same fallback chain.
|
|
139
|
+
*
|
|
140
|
+
* Resolved column widths are written back to `data-maizzle-cw` so nested
|
|
141
|
+
* rows cascade. All `data-maizzle-cw*` and `data-maizzle-oh-*` are
|
|
142
|
+
* stripped at the end of the second walk pass.
|
|
143
|
+
*/
|
|
144
|
+
function columnWidth(dom) {
|
|
145
|
+
/**
|
|
146
|
+
* Cache parsed style ASTs for this columnWidth invocation. The walk-up
|
|
147
|
+
* loop visits the same Section/Container once per column of a Row,
|
|
148
|
+
* so without caching each column re-parses every ancestor's style.
|
|
149
|
+
* Cache is function-local — no cross-build leak via the WeakMap.
|
|
150
|
+
*/
|
|
151
|
+
const styleCache = /* @__PURE__ */ new WeakMap();
|
|
152
|
+
const parseElStyle = (el) => {
|
|
153
|
+
const cached = styleCache.get(el);
|
|
154
|
+
if (cached) return cached;
|
|
155
|
+
const style = el.attribs?.style ?? "";
|
|
156
|
+
const root = style ? safeParser(style) : postcss.root();
|
|
157
|
+
styleCache.set(el, root);
|
|
158
|
+
return root;
|
|
159
|
+
};
|
|
160
|
+
const columns = [];
|
|
161
|
+
const heightTargets = [];
|
|
162
|
+
walk(dom, (node) => {
|
|
163
|
+
const el = node;
|
|
164
|
+
if (!el.attribs) return;
|
|
165
|
+
const id = el.attribs["data-maizzle-cw-id"];
|
|
166
|
+
if (id) {
|
|
167
|
+
const count = parseInt(el.attribs["data-maizzle-cw-count"] || "1", 10);
|
|
168
|
+
const self = "data-maizzle-cw-self" in el.attribs;
|
|
169
|
+
columns.push({
|
|
170
|
+
el,
|
|
171
|
+
id,
|
|
172
|
+
count,
|
|
173
|
+
d: depth(node),
|
|
174
|
+
self
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const ohId = el.attribs["data-maizzle-oh-id"];
|
|
178
|
+
if (ohId) heightTargets.push({
|
|
179
|
+
el,
|
|
180
|
+
id: ohId
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
columns.sort((a, b) => a.d - b.d);
|
|
184
|
+
const widthResolutions = /* @__PURE__ */ new Map();
|
|
185
|
+
const widthFallbacks = /* @__PURE__ */ new Map();
|
|
186
|
+
/**
|
|
187
|
+
* Column ids whose absolute user `width:` was promoted to `min-width:`
|
|
188
|
+
* — the original `width:` declaration must be stripped from the
|
|
189
|
+
* column's style (otherwise it'd compete with the min-width).
|
|
190
|
+
*/
|
|
191
|
+
const stripWidth = /* @__PURE__ */ new Set();
|
|
192
|
+
/**
|
|
193
|
+
* Column ids where the user wrote a percentage `width:` (e.g. `w-1/2`) —
|
|
194
|
+
* explicit opt-out of px-based stacking. Keep the user's `width: X%`
|
|
195
|
+
* and drop our `min-width:` placeholder so the column stays at
|
|
196
|
+
* that percentage of its parent forever and never stacks.
|
|
197
|
+
*/
|
|
198
|
+
const dropMinWidth = /* @__PURE__ */ new Set();
|
|
199
|
+
/**
|
|
200
|
+
* Column ids where the user wrote their own `min-width:` (via `min-w-1/3`).
|
|
201
|
+
* Juice inlines theirs after ours, so two `min-width:` decls land in
|
|
202
|
+
* the style — we strip the user's after using its value as the
|
|
203
|
+
* column's resolution, leaving our placeholder as last word.
|
|
204
|
+
*/
|
|
205
|
+
const stripUserMinWidth = /* @__PURE__ */ new Set();
|
|
206
|
+
/**
|
|
207
|
+
* Column ids where the user already supplied a `max-width:` of their own.
|
|
208
|
+
* Our default `max-width: 100%` would just be shadowed by it via
|
|
209
|
+
* last-wins and bloat the style — so we skip emitting it.
|
|
210
|
+
*/
|
|
211
|
+
const userHasMaxWidth = /* @__PURE__ */ new Set();
|
|
212
|
+
/**
|
|
213
|
+
* Horizontal padding+border (px) of each column whose width was auto-
|
|
214
|
+
* derived from count-based math. The column's own border/padding eats
|
|
215
|
+
* its content box under content-box sizing, so the emitted `width:`
|
|
216
|
+
* must be the slice MINUS this inset; otherwise two bordered cols
|
|
217
|
+
* sum past the container and wrap. Only populated for auto paths
|
|
218
|
+
* — user-explicit `width:`/`min-width:`/`max-width:`-wins paths
|
|
219
|
+
* leave the value alone so the user's number stays the user's.
|
|
220
|
+
*/
|
|
221
|
+
const autoColumnInsets = /* @__PURE__ */ new Map();
|
|
222
|
+
/**
|
|
223
|
+
* Extra inline-style decls that get stamped onto each column's MSO `<td>`
|
|
224
|
+
* via its COLTDX placeholder. Carries `background-color` (so Word
|
|
225
|
+
* paints the cell behind any padding area or whitespace, not just
|
|
226
|
+
* the div) and hoisted `padding*` decls (when no border is present
|
|
227
|
+
* — without one Word silently drops div padding, with one a td
|
|
228
|
+
* copy would double-pad). The div keeps both for modern clients
|
|
229
|
+
* since the MSO td is conditional-comment-only.
|
|
230
|
+
*/
|
|
231
|
+
const tdExtras = /* @__PURE__ */ new Map();
|
|
232
|
+
/**
|
|
233
|
+
* MSO td width override for hoisted columns. With padding on the td and
|
|
234
|
+
* CSS content-box sizing for table cells, td_outer = width + 2*pad,
|
|
235
|
+
* so we set td width to the slot MINUS 2*horizontal-padding to keep
|
|
236
|
+
* the cell at its outer slot. Skipped when the slot is a %.
|
|
237
|
+
*/
|
|
238
|
+
const hoistedTdWidths = /* @__PURE__ */ new Map();
|
|
239
|
+
for (const { id, count } of columns) widthFallbacks.set(id, `${Math.round(100 / Math.max(count, 1))}%`);
|
|
240
|
+
const groupInfos = /* @__PURE__ */ new Map();
|
|
241
|
+
for (const c of columns) {
|
|
242
|
+
if (c.self) continue;
|
|
243
|
+
const ownRoot = parseElStyle(c.el);
|
|
244
|
+
const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot);
|
|
245
|
+
let cls = {
|
|
246
|
+
kind: "auto",
|
|
247
|
+
pxOuter: 0,
|
|
248
|
+
pctOuter: 0
|
|
249
|
+
};
|
|
250
|
+
const userVal = findUserMinWidth(ownRoot) ?? firstDeclValue(ownRoot, "width");
|
|
251
|
+
if (userVal) {
|
|
252
|
+
const resolved = resolveLength(userVal);
|
|
253
|
+
if (resolved?.endsWith("px")) {
|
|
254
|
+
const px = lengthToPx(resolved);
|
|
255
|
+
if (px != null) cls = {
|
|
256
|
+
kind: "explicit",
|
|
257
|
+
pxOuter: px + ownInset,
|
|
258
|
+
pctOuter: 0
|
|
259
|
+
};
|
|
260
|
+
} else if (resolved?.endsWith("%")) cls = {
|
|
261
|
+
kind: "explicit",
|
|
262
|
+
pxOuter: ownInset,
|
|
263
|
+
pctOuter: parseFloat(resolved)
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const parent = c.el.parent;
|
|
267
|
+
if (!parent) continue;
|
|
268
|
+
let info = groupInfos.get(parent);
|
|
269
|
+
if (!info) {
|
|
270
|
+
info = {
|
|
271
|
+
explicitPxOuterSum: 0,
|
|
272
|
+
explicitPctOuterSum: 0,
|
|
273
|
+
autoCount: 0
|
|
274
|
+
};
|
|
275
|
+
groupInfos.set(parent, info);
|
|
276
|
+
}
|
|
277
|
+
info.explicitPxOuterSum += cls.pxOuter;
|
|
278
|
+
info.explicitPctOuterSum += cls.pctOuter;
|
|
279
|
+
if (cls.kind === "auto") info.autoCount++;
|
|
280
|
+
}
|
|
281
|
+
for (const { el, id, count, self } of columns) {
|
|
282
|
+
const ownRoot = parseElStyle(el);
|
|
283
|
+
let sourceWidth = null;
|
|
284
|
+
let accumulatedInsetPx = 0;
|
|
285
|
+
if (self) {
|
|
286
|
+
sourceWidth = readWidthFromRoot(ownRoot);
|
|
287
|
+
accumulatedInsetPx = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot);
|
|
288
|
+
} else {
|
|
289
|
+
/**
|
|
290
|
+
* Walk up through every ancestor with attribs, accumulating horizontal
|
|
291
|
+
* padding+border along the way (including the source). Stop at the
|
|
292
|
+
* first `data-maizzle-cw` ancestor whose width is resolvable.
|
|
293
|
+
* Markers without a resolvable width (Row emitted empty after
|
|
294
|
+
* Tailwind dropped a bogus class) shouldn't shadow a real
|
|
295
|
+
* width on a higher ancestor like `<Container>`.
|
|
296
|
+
*
|
|
297
|
+
* With CSS content-box this is technically generous toward the
|
|
298
|
+
* source's own padding/border, but matches user expectations
|
|
299
|
+
* when they put `px-9` or `border-2` on a wrapper.
|
|
300
|
+
*/
|
|
301
|
+
let cur = el.parent;
|
|
302
|
+
while (cur) {
|
|
303
|
+
const parentEl = cur;
|
|
304
|
+
if (parentEl.attribs) {
|
|
305
|
+
let pRoot = null;
|
|
306
|
+
if (parentEl.attribs.style) {
|
|
307
|
+
pRoot = parseElStyle(parentEl);
|
|
308
|
+
accumulatedInsetPx += horizontalPaddingPx(pRoot) + horizontalBorderPx(pRoot);
|
|
309
|
+
}
|
|
310
|
+
if ("data-maizzle-cw" in parentEl.attribs) {
|
|
311
|
+
const w = readWidthSource(parentEl, pRoot);
|
|
312
|
+
if (w) {
|
|
313
|
+
sourceWidth = w;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
cur = cur.parent ?? null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const adjusted = sourceWidth ? subtractInsetPx(sourceWidth, accumulatedInsetPx) : null;
|
|
322
|
+
let countBased = adjusted ? divideLength(adjusted, count) : null;
|
|
323
|
+
/**
|
|
324
|
+
* Sibling-aware redistribution kicks in only when the auto col has at
|
|
325
|
+
* least one explicit-width sibling and the source is in px (can't
|
|
326
|
+
* mix px subtraction with a % source). When that's true, the auto
|
|
327
|
+
* col's share becomes `(source − sum_explicit_px − pct% of source)
|
|
328
|
+
* / autoCount`, replacing the naive `source/totalCount`.
|
|
329
|
+
*/
|
|
330
|
+
if (!self && adjusted?.endsWith("px") && countBased && el.parent) {
|
|
331
|
+
const group = groupInfos.get(el.parent);
|
|
332
|
+
if (group && group.autoCount > 0 && (group.explicitPxOuterSum > 0 || group.explicitPctOuterSum > 0)) {
|
|
333
|
+
const adjPx = lengthToPx(adjusted);
|
|
334
|
+
if (adjPx != null) {
|
|
335
|
+
const remaining = adjPx - group.explicitPxOuterSum - adjPx * group.explicitPctOuterSum / 100;
|
|
336
|
+
countBased = `${Math.max(0, Math.floor(remaining * 100 / group.autoCount) / 100)}px`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Four user-override paths, decided by which CSS property the user
|
|
342
|
+
* actually wrote:
|
|
343
|
+
*
|
|
344
|
+
* - `min-width: X` → user's value wins. Convert to px against
|
|
345
|
+
* the source (if %), use as the column's
|
|
346
|
+
* resolution, and strip the user's min-width
|
|
347
|
+
* declaration so our placeholder substitution
|
|
348
|
+
* remains the last `min-width:` in style.
|
|
349
|
+
* - `width: X%` → opt-out of px stacking. Keep `width:` in
|
|
350
|
+
* style, drop our `min-width:` placeholder.
|
|
351
|
+
* Cols stay at X% of parent forever, never stack.
|
|
352
|
+
* - `width: Xpx` (or rem/em/pt) → fixed pixel column. Promote to
|
|
353
|
+
* `min-width:`, strip the original `width:` so
|
|
354
|
+
* it doesn't compete.
|
|
355
|
+
* - `max-width: X` → CSS cap. Keep the `max-width:` declaration;
|
|
356
|
+
* clamp our count-based min-width *down* to
|
|
357
|
+
* the user's max-width when our min would
|
|
358
|
+
* otherwise violate it.
|
|
359
|
+
*/
|
|
360
|
+
const userMinRaw = findUserMinWidth(ownRoot);
|
|
361
|
+
const widthRaw = firstDeclValue(ownRoot, "width");
|
|
362
|
+
const maxRaw = firstDeclValue(ownRoot, "max-width");
|
|
363
|
+
if (userMinRaw) {
|
|
364
|
+
const minPx = userValueToPx(userMinRaw, adjusted) ?? resolveLength(userMinRaw);
|
|
365
|
+
if (minPx) {
|
|
366
|
+
widthResolutions.set(id, minPx);
|
|
367
|
+
el.attribs["data-maizzle-cw"] = minPx;
|
|
368
|
+
stripUserMinWidth.add(id);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (widthRaw) {
|
|
373
|
+
const widthVal = resolveLength(widthRaw);
|
|
374
|
+
if (widthVal?.endsWith("%")) {
|
|
375
|
+
widthResolutions.set(id, widthVal);
|
|
376
|
+
el.attribs["data-maizzle-cw"] = widthVal;
|
|
377
|
+
dropMinWidth.add(id);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (widthVal) {
|
|
381
|
+
widthResolutions.set(id, widthVal);
|
|
382
|
+
el.attribs["data-maizzle-cw"] = widthVal;
|
|
383
|
+
stripWidth.add(id);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (maxRaw && countBased) {
|
|
388
|
+
const maxPx = userValueToPx(maxRaw, adjusted);
|
|
389
|
+
if (maxPx) {
|
|
390
|
+
const cappedMin = countBased.endsWith("px") ? minPxLength(countBased, maxPx) : maxPx;
|
|
391
|
+
widthResolutions.set(id, cappedMin);
|
|
392
|
+
el.attribs["data-maizzle-cw"] = cappedMin;
|
|
393
|
+
userHasMaxWidth.add(id);
|
|
394
|
+
if (cappedMin === countBased) {
|
|
395
|
+
const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot);
|
|
396
|
+
if (ownInset > 0) autoColumnInsets.set(id, ownInset);
|
|
397
|
+
}
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (countBased) {
|
|
402
|
+
widthResolutions.set(id, countBased);
|
|
403
|
+
el.attribs["data-maizzle-cw"] = countBased;
|
|
404
|
+
const ownPaddingPx = horizontalPaddingPx(ownRoot);
|
|
405
|
+
const ownBorderPx = horizontalBorderPx(ownRoot);
|
|
406
|
+
const ownInset = ownPaddingPx + ownBorderPx;
|
|
407
|
+
if (ownInset > 0) autoColumnInsets.set(id, ownInset);
|
|
408
|
+
/**
|
|
409
|
+
* Build the MSO td's "extras" string — decls that need to live on
|
|
410
|
+
* the td in addition to width + vertical-align. Two contributors:
|
|
411
|
+
*
|
|
412
|
+
* - `background-color` (always, when present) — Word renders the
|
|
413
|
+
* div bg inside the cell, but anything outside the div (the
|
|
414
|
+
* td's padding area when hoisted, or any whitespace gap)
|
|
415
|
+
* would show the parent's bg instead of the column's. Painting
|
|
416
|
+
* the td matches the user's intent.
|
|
417
|
+
*
|
|
418
|
+
* - `padding*` (hoisted only when no horizontal border) — Word
|
|
419
|
+
* drops div padding without a stabilizing border, so the td
|
|
420
|
+
* has to carry it. With a border, Word renders div padding
|
|
421
|
+
* and a td copy would double-pad. Skip when the slot is `%`:
|
|
422
|
+
* td width math can't subtract px padding from a percentage.
|
|
423
|
+
*/
|
|
424
|
+
const extras = [];
|
|
425
|
+
let bgColor;
|
|
426
|
+
ownRoot.walkDecls("background-color", (d) => {
|
|
427
|
+
bgColor = d.value;
|
|
428
|
+
});
|
|
429
|
+
if (bgColor) extras.push(`background-color: ${bgColor}`);
|
|
430
|
+
if (ownPaddingPx > 0 && ownBorderPx === 0 && countBased.endsWith("px")) {
|
|
431
|
+
ownRoot.walkDecls((d) => {
|
|
432
|
+
if (/^padding(-|$)/.test(d.prop)) extras.push(`${d.prop}: ${d.value}`);
|
|
433
|
+
});
|
|
434
|
+
hoistedTdWidths.set(id, subtractInsetPx(countBased, ownPaddingPx));
|
|
435
|
+
}
|
|
436
|
+
if (extras.length) tdExtras.set(id, extras.join("; "));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
const heightResolutions = /* @__PURE__ */ new Map();
|
|
440
|
+
for (const { el, id } of heightTargets) {
|
|
441
|
+
if (!el.attribs?.style) continue;
|
|
442
|
+
const h = readHeightFromRoot(parseElStyle(el));
|
|
443
|
+
if (h) heightResolutions.set(id, h);
|
|
444
|
+
}
|
|
445
|
+
walk(dom, (node) => {
|
|
446
|
+
if (node.type === "comment") {
|
|
447
|
+
const data = node.data;
|
|
448
|
+
if (!data) return;
|
|
449
|
+
const hasCW = data.includes("__MAIZZLE_COLW_");
|
|
450
|
+
const hasOH = data.includes("__MAIZZLE_OH_");
|
|
451
|
+
const hasTDX = data.includes("__MAIZZLE_COLTDX_");
|
|
452
|
+
if (!hasCW && !hasOH && !hasTDX) return;
|
|
453
|
+
node.data = data.replace(/__MAIZZLE_COLW_([^_]+)__/g, (_m, mid) => hoistedTdWidths.get(mid) ?? widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? "100%").replace(/;\s*__MAIZZLE_COLTDX_([^_]+)__/g, (_m, mid) => {
|
|
454
|
+
const pad = tdExtras.get(mid);
|
|
455
|
+
return pad ? `; ${pad}` : "";
|
|
456
|
+
}).replace(/__MAIZZLE_OH_([^_]+)__/g, (_m, hid) => heightResolutions.get(hid) ?? "100%");
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const el = node;
|
|
460
|
+
if (!el.attribs) return;
|
|
461
|
+
const style = el.attribs.style;
|
|
462
|
+
if (style && (style.includes("__MAIZZLE_COLW_") || style.includes("__MAIZZLE_OH_"))) {
|
|
463
|
+
const root = parseElStyle(el);
|
|
464
|
+
const cwId = el.attribs["data-maizzle-cw-id"];
|
|
465
|
+
/**
|
|
466
|
+
* Strip user dups BEFORE substitution — last-wins CSS would
|
|
467
|
+
* otherwise shadow our resolved values in the output.
|
|
468
|
+
*/
|
|
469
|
+
if (cwId && stripUserMinWidth.has(cwId)) root.walkDecls("min-width", (d) => {
|
|
470
|
+
if (!d.value.includes("__MAIZZLE_COLW_")) d.remove();
|
|
471
|
+
});
|
|
472
|
+
if (cwId && stripWidth.has(cwId)) root.walkDecls("width", (d) => {
|
|
473
|
+
d.remove();
|
|
474
|
+
});
|
|
475
|
+
/**
|
|
476
|
+
* Substitute the column's `min-width:` placeholder with `width: <res>;
|
|
477
|
+
* max-width: 100%`. Width gives the same stacking trigger as
|
|
478
|
+
* min-width — inline-block wraps when children sum > parent
|
|
479
|
+
* — and the `max-width: 100%` clamp keeps the column from
|
|
480
|
+
* overflowing the viewport once it drops to its own row on
|
|
481
|
+
* mobile. Skip the clamp when the user supplied their own.
|
|
482
|
+
*
|
|
483
|
+
* Other placeholders (Overlap td `width`, comment markers,
|
|
484
|
+
* OH height) get a plain value substitution.
|
|
485
|
+
*/
|
|
486
|
+
root.walkDecls((d) => {
|
|
487
|
+
if (d.prop === "min-width") {
|
|
488
|
+
const m = d.value.match(/^__MAIZZLE_COLW_([^_]+)__$/);
|
|
489
|
+
if (m) {
|
|
490
|
+
const mid = m[1];
|
|
491
|
+
if (dropMinWidth.has(mid) || !widthResolutions.has(mid)) {
|
|
492
|
+
d.remove();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
let resolved = widthResolutions.get(mid);
|
|
496
|
+
const inset = autoColumnInsets.get(mid);
|
|
497
|
+
if (inset) resolved = subtractInsetPx(resolved, inset);
|
|
498
|
+
const repl = [postcss.decl({
|
|
499
|
+
prop: "width",
|
|
500
|
+
value: resolved
|
|
501
|
+
})];
|
|
502
|
+
if (!userHasMaxWidth.has(mid)) repl.push(postcss.decl({
|
|
503
|
+
prop: "max-width",
|
|
504
|
+
value: "100%"
|
|
505
|
+
}));
|
|
506
|
+
d.replaceWith(...repl);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (d.value.includes("__MAIZZLE_COLW_") || d.value.includes("__MAIZZLE_OH_")) d.value = d.value.replace(/__MAIZZLE_COLW_([^_]+)__/g, (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? "100%").replace(/__MAIZZLE_OH_([^_]+)__/g, (_m, hid) => heightResolutions.get(hid) ?? "100%");
|
|
511
|
+
});
|
|
512
|
+
const out = serializeStyle(root);
|
|
513
|
+
if (out) el.attribs.style = out;
|
|
514
|
+
else delete el.attribs.style;
|
|
515
|
+
}
|
|
516
|
+
delete el.attribs["data-maizzle-cw"];
|
|
517
|
+
delete el.attribs["data-maizzle-cw-id"];
|
|
518
|
+
delete el.attribs["data-maizzle-cw-count"];
|
|
519
|
+
delete el.attribs["data-maizzle-cw-self"];
|
|
520
|
+
delete el.attribs["data-maizzle-oh-id"];
|
|
521
|
+
});
|
|
522
|
+
return dom;
|
|
523
|
+
}
|
|
524
|
+
//#endregion
|
|
525
|
+
export { columnWidth };
|
|
526
|
+
|
|
527
|
+
//# sourceMappingURL=columnWidth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columnWidth.js","names":[],"sources":["../../src/transformers/columnWidth.ts"],"sourcesContent":["import postcss, { type Root, type Declaration } from 'postcss'\nimport safeParser from 'postcss-safe-parser'\nimport { walk } from '../utils/ast/index.ts'\nimport { horizontalBorderPx, horizontalPaddingPx, lengthToPx } from '../utils/cssBox.ts'\nimport type { ChildNode, Element, ParentNode } from 'domhandler'\n\nconst RE_PERCENT = /^[\\d.]+%$/\n\n/**\n * Stringify decls into a `; `-joined inline-style attribute. PostCSS raws\n * preserve the original source spacing, which mixes poorly with\n * the fresh decls we inject — plain join keeps output uniform.\n */\nfunction serializeStyle(root: Root): string {\n const parts: string[] = []\n root.walkDecls((d) => {\n parts.push(`${d.prop}: ${d.value}${d.important ? ' !important' : ''}`)\n })\n return parts.join('; ')\n}\n\nfunction firstDeclValue(root: Root, prop: string): string | undefined {\n let found: string | undefined\n root.walkDecls(prop, (d) => {\n found = d.value\n return false\n })\n return found\n}\n\n/**\n * Find the user-set `min-width:` value on a column. Juice keeps both ours\n * and the one inlined from a class like `min-w-1/3` — we skip any\n * min-width whose value still contains our placeholder token,\n * returning the first remaining user value, or null.\n */\nfunction findUserMinWidth(root: Root): string | null {\n let userVal: string | null = null\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) {\n userVal = d.value\n return false\n }\n })\n return userVal\n}\n\nfunction resolveLength(value: string): string | null {\n const trimmed = value.trim()\n if (RE_PERCENT.test(trimmed)) return trimmed\n const m = trimmed.match(/^([\\d.]+)(px|rem|em|pt)?$/i)\n if (!m) return null\n const n = parseFloat(m[1])\n const unit = (m[2] || 'px').toLowerCase()\n const factor = unit === 'rem' || unit === 'em' ? 16 : unit === 'pt' ? 1.333 : 1\n return `${Math.round(n * factor)}px`\n}\n\nfunction divideLength(value: string, divisor: number): string | null {\n const m = value.match(/^([\\d.]+)(px|%)$/)\n if (!m || divisor < 1) return null\n const n = parseFloat(m[1])\n return `${parseFloat((n / divisor).toFixed(2))}${m[2]}`\n}\n\nfunction subtractInsetPx(width: string, insetPx: number): string {\n if (insetPx <= 0) return width\n const m = width.match(/^([\\d.]+)(px|%)$/)\n if (!m) return width\n // Don't subtract px from percentage widths — units don't match.\n if (m[2] === '%') return width\n const n = parseFloat(m[1]) - insetPx\n return `${Math.max(0, Math.round(n))}px`\n}\n\n/**\n * Return the smaller of two px lengths. Clamps our count-based min-width\n * down to the user's `max-width:` so the cap is never silently\n * violated when our computed min would exceed the user's max.\n */\nfunction minPxLength(a: string, b: string): string {\n const am = a.match(/^([\\d.]+)px$/)\n const bm = b.match(/^([\\d.]+)px$/)\n if (!am || !bm) return a\n return parseFloat(am[1]) < parseFloat(bm[1]) ? a : b\n}\n\nfunction depth(node: ChildNode): number {\n let d = 0\n let cur: ParentNode | null = node.parent\n while (cur) {\n d++\n cur = (cur as any).parent ?? null\n }\n return d\n}\n\nfunction readWidthFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-width')\n ?? firstDeclValue(root, 'width')\n ?? firstDeclValue(root, 'min-width')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readHeightFromRoot(root: Root): string | null {\n const raw = firstDeclValue(root, 'max-height')\n ?? firstDeclValue(root, 'height')\n ?? firstDeclValue(root, 'min-height')\n return raw ? resolveLength(raw) : null\n}\n\nfunction readWidthSource(el: Element, root: Root | null): string | null {\n const explicit = el.attribs?.['data-maizzle-cw']\n if (explicit) {\n const r = resolveLength(explicit)\n if (r) return r\n }\n return root ? readWidthFromRoot(root) : null\n}\n\n/**\n * Convert a user-supplied length to absolute px against the column's source\n * width (post-inset). Percentages multiply against the source while\n * absolute units pass through `resolveLength`. Returns null when\n * the value or source can't be expressed in px.\n */\nfunction userValueToPx(rawValue: string, sourcePx: string | null): string | null {\n const trimmed = rawValue.trim()\n\n const absMatch = trimmed.match(/^([\\d.]+)(px|rem|em|pt)$/i)\n if (absMatch) return resolveLength(trimmed)\n\n const pctMatch = trimmed.match(/^([\\d.]+)%$/)\n if (!pctMatch || !sourcePx) return null\n const sourceMatch = sourcePx.match(/^([\\d.]+)px$/)\n if (!sourceMatch) return null\n const pct = parseFloat(pctMatch[1])\n const src = parseFloat(sourceMatch[1])\n return `${Math.round((pct / 100) * src)}px`\n}\n\n/**\n * Resolve `__MAIZZLE_COLW_{id}__` and `__MAIZZLE_OH_{id}__` placeholders.\n *\n * COLW (column width) — emitted by `<Column>` and `<Overlap>`. Walks up to\n * the nearest ancestor marked `data-maizzle-cw` (Container, Section,\n * Row, or another Column already resolved) and divides the source\n * width by `data-maizzle-cw-count`. With `data-maizzle-cw-self`,\n * reads from the element's own inlined max/width/min-width\n * instead — used by `<Overlap>` with its own width class.\n *\n * OH (overlap height) — emitted by `<Overlap>`. Reads max-height, height,\n * or min-height from the element's own inlined style.\n *\n * Resolution rules:\n * - Style placeholders for `min-width`: replaced when resolvable, otherwise\n * the entire `min-width` declaration is stripped.\n * - Other style placeholders (Overlap td `width`, etc.): replaced when\n * resolvable, otherwise replaced with the count-based fallback or `100%`.\n * - Comment placeholders: same fallback chain.\n *\n * Resolved column widths are written back to `data-maizzle-cw` so nested\n * rows cascade. All `data-maizzle-cw*` and `data-maizzle-oh-*` are\n * stripped at the end of the second walk pass.\n */\nexport function columnWidth(dom: ChildNode[]): ChildNode[] {\n /**\n * Cache parsed style ASTs for this columnWidth invocation. The walk-up\n * loop visits the same Section/Container once per column of a Row,\n * so without caching each column re-parses every ancestor's style.\n * Cache is function-local — no cross-build leak via the WeakMap.\n */\n const styleCache = new WeakMap<Element, Root>()\n const parseElStyle = (el: Element): Root => {\n const cached = styleCache.get(el)\n if (cached) return cached\n const style = el.attribs?.style ?? ''\n const root = style ? safeParser(style) : postcss.root()\n styleCache.set(el, root)\n return root\n }\n\n const columns: { el: Element; id: string; count: number; d: number; self: boolean }[] = []\n const heightTargets: { el: Element; id: string }[] = []\n\n walk(dom, (node) => {\n const el = node as Element\n if (!el.attribs) return\n\n const id = el.attribs['data-maizzle-cw-id']\n if (id) {\n const count = parseInt(el.attribs['data-maizzle-cw-count'] || '1', 10)\n const self = 'data-maizzle-cw-self' in el.attribs\n columns.push({ el, id, count, d: depth(node), self })\n }\n\n const ohId = el.attribs['data-maizzle-oh-id']\n if (ohId) heightTargets.push({ el, id: ohId })\n })\n\n columns.sort((a, b) => a.d - b.d)\n\n const widthResolutions = new Map<string, string>()\n const widthFallbacks = new Map<string, string>()\n /**\n * Column ids whose absolute user `width:` was promoted to `min-width:`\n * — the original `width:` declaration must be stripped from the\n * column's style (otherwise it'd compete with the min-width).\n */\n const stripWidth = new Set<string>()\n /**\n * Column ids where the user wrote a percentage `width:` (e.g. `w-1/2`) —\n * explicit opt-out of px-based stacking. Keep the user's `width: X%`\n * and drop our `min-width:` placeholder so the column stays at\n * that percentage of its parent forever and never stacks.\n */\n const dropMinWidth = new Set<string>()\n /**\n * Column ids where the user wrote their own `min-width:` (via `min-w-1/3`).\n * Juice inlines theirs after ours, so two `min-width:` decls land in\n * the style — we strip the user's after using its value as the\n * column's resolution, leaving our placeholder as last word.\n */\n const stripUserMinWidth = new Set<string>()\n /**\n * Column ids where the user already supplied a `max-width:` of their own.\n * Our default `max-width: 100%` would just be shadowed by it via\n * last-wins and bloat the style — so we skip emitting it.\n */\n const userHasMaxWidth = new Set<string>()\n /**\n * Horizontal padding+border (px) of each column whose width was auto-\n * derived from count-based math. The column's own border/padding eats\n * its content box under content-box sizing, so the emitted `width:`\n * must be the slice MINUS this inset; otherwise two bordered cols\n * sum past the container and wrap. Only populated for auto paths\n * — user-explicit `width:`/`min-width:`/`max-width:`-wins paths\n * leave the value alone so the user's number stays the user's.\n */\n const autoColumnInsets = new Map<string, number>()\n /**\n * Extra inline-style decls that get stamped onto each column's MSO `<td>`\n * via its COLTDX placeholder. Carries `background-color` (so Word\n * paints the cell behind any padding area or whitespace, not just\n * the div) and hoisted `padding*` decls (when no border is present\n * — without one Word silently drops div padding, with one a td\n * copy would double-pad). The div keeps both for modern clients\n * since the MSO td is conditional-comment-only.\n */\n const tdExtras = new Map<string, string>()\n /**\n * MSO td width override for hoisted columns. With padding on the td and\n * CSS content-box sizing for table cells, td_outer = width + 2*pad,\n * so we set td width to the slot MINUS 2*horizontal-padding to keep\n * the cell at its outer slot. Skipped when the slot is a %.\n */\n const hoistedTdWidths = new Map<string, string>()\n\n for (const { id, count } of columns) {\n widthFallbacks.set(id, `${Math.round(100 / Math.max(count, 1))}%`)\n }\n\n /**\n * Sibling-aware redistribution.\n *\n * Without this, every auto column slices its source `/ totalCount`,\n * ignoring siblings that already declared a fixed `w-5` (20px) or\n * `w-1/3` (%). Three auto cols next to a `w-5` would each take\n * `source/3` and overflow the row by 20px.\n *\n * Pre-pass: classify each col against its inlined style.\n * - explicit-px: `width:` or `min-width:` resolving to px. The col\n * occupies (px value + own horizontal padding +\n * own horizontal border) of the source.\n * - explicit-pct: `width:` or `min-width:` resolving to %. The col\n * occupies (pct * source / 100 + own inset).\n * - auto: everything else. Shares the remainder with other\n * auto siblings.\n *\n * Group cols by their immediate `el.parent` (the Row div). For each\n * group, sum the explicit contributions and count the autos. The\n * countBased path below uses these to redistribute leftover space\n * instead of dividing the raw source by total count.\n *\n * `data-maizzle-cw-self` cols (Overlap) are excluded — they own their\n * source independently and don't share a parent's slot with cols.\n */\n interface ColClassification {\n kind: 'auto' | 'explicit'\n pxOuter: number\n pctOuter: number\n }\n interface GroupInfo {\n explicitPxOuterSum: number\n explicitPctOuterSum: number\n autoCount: number\n }\n const groupInfos = new Map<ParentNode, GroupInfo>()\n\n for (const c of columns) {\n if (c.self) continue\n const ownRoot = parseElStyle(c.el)\n const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n\n let cls: ColClassification = { kind: 'auto', pxOuter: 0, pctOuter: 0 }\n const userVal = findUserMinWidth(ownRoot) ?? firstDeclValue(ownRoot, 'width')\n if (userVal) {\n const resolved = resolveLength(userVal)\n if (resolved?.endsWith('px')) {\n const px = lengthToPx(resolved)\n if (px != null) cls = { kind: 'explicit', pxOuter: px + ownInset, pctOuter: 0 }\n }\n else if (resolved?.endsWith('%')) {\n cls = { kind: 'explicit', pxOuter: ownInset, pctOuter: parseFloat(resolved) }\n }\n }\n\n const parent = c.el.parent as ParentNode | null\n if (!parent) continue\n let info = groupInfos.get(parent)\n if (!info) {\n info = { explicitPxOuterSum: 0, explicitPctOuterSum: 0, autoCount: 0 }\n groupInfos.set(parent, info)\n }\n info.explicitPxOuterSum += cls.pxOuter\n info.explicitPctOuterSum += cls.pctOuter\n if (cls.kind === 'auto') info.autoCount++\n }\n\n for (const { el, id, count, self } of columns) {\n const ownRoot = parseElStyle(el)\n\n let sourceWidth: string | null = null\n let accumulatedInsetPx = 0\n\n if (self) {\n sourceWidth = readWidthFromRoot(ownRoot)\n accumulatedInsetPx = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n }\n else {\n /**\n * Walk up through every ancestor with attribs, accumulating horizontal\n * padding+border along the way (including the source). Stop at the\n * first `data-maizzle-cw` ancestor whose width is resolvable.\n * Markers without a resolvable width (Row emitted empty after\n * Tailwind dropped a bogus class) shouldn't shadow a real\n * width on a higher ancestor like `<Container>`.\n *\n * With CSS content-box this is technically generous toward the\n * source's own padding/border, but matches user expectations\n * when they put `px-9` or `border-2` on a wrapper.\n */\n let cur: ParentNode | null = el.parent\n while (cur) {\n const parentEl = cur as Element\n if (parentEl.attribs) {\n let pRoot: Root | null = null\n if (parentEl.attribs.style) {\n pRoot = parseElStyle(parentEl)\n accumulatedInsetPx += horizontalPaddingPx(pRoot) + horizontalBorderPx(pRoot)\n }\n if ('data-maizzle-cw' in parentEl.attribs) {\n const w = readWidthSource(parentEl, pRoot)\n if (w) {\n sourceWidth = w\n break\n }\n }\n }\n cur = (cur as any).parent ?? null\n }\n }\n\n const adjusted = sourceWidth ? subtractInsetPx(sourceWidth, accumulatedInsetPx) : null\n let countBased = adjusted ? divideLength(adjusted, count) : null\n\n /**\n * Sibling-aware redistribution kicks in only when the auto col has at\n * least one explicit-width sibling and the source is in px (can't\n * mix px subtraction with a % source). When that's true, the auto\n * col's share becomes `(source − sum_explicit_px − pct% of source)\n * / autoCount`, replacing the naive `source/totalCount`.\n */\n if (!self && adjusted?.endsWith('px') && countBased && el.parent) {\n const group = groupInfos.get(el.parent as ParentNode)\n if (group && group.autoCount > 0\n && (group.explicitPxOuterSum > 0 || group.explicitPctOuterSum > 0)) {\n const adjPx = lengthToPx(adjusted)\n if (adjPx != null) {\n const remaining = adjPx - group.explicitPxOuterSum - (adjPx * group.explicitPctOuterSum / 100)\n /**\n * Floor-to-2-decimals on the per-auto share. Two reasons:\n *\n * 1. Matches `divideLength`'s precision so the auto path and\n * group-aware path emit consistent units.\n * 2. Rounding up (e.g. 536/3 = 178.6̄ → round to 179) pushes\n * the sum past the slot — 3×179 + 2×20 = 577 > 576 →\n * inline-block wraps and the row stacks. Flooring at 2\n * decimals keeps the sum ≤ slot with at most ~0.0(autoCount)\n * px unused, which is sub-pixel and invisible.\n */\n const share = Math.max(0, Math.floor((remaining * 100) / group.autoCount) / 100)\n countBased = `${share}px`\n }\n }\n }\n\n /**\n * Four user-override paths, decided by which CSS property the user\n * actually wrote:\n *\n * - `min-width: X` → user's value wins. Convert to px against\n * the source (if %), use as the column's\n * resolution, and strip the user's min-width\n * declaration so our placeholder substitution\n * remains the last `min-width:` in style.\n * - `width: X%` → opt-out of px stacking. Keep `width:` in\n * style, drop our `min-width:` placeholder.\n * Cols stay at X% of parent forever, never stack.\n * - `width: Xpx` (or rem/em/pt) → fixed pixel column. Promote to\n * `min-width:`, strip the original `width:` so\n * it doesn't compete.\n * - `max-width: X` → CSS cap. Keep the `max-width:` declaration;\n * clamp our count-based min-width *down* to\n * the user's max-width when our min would\n * otherwise violate it.\n */\n const userMinRaw = findUserMinWidth(ownRoot)\n const widthRaw = firstDeclValue(ownRoot, 'width')\n const maxRaw = firstDeclValue(ownRoot, 'max-width')\n\n if (userMinRaw) {\n const minPx = userValueToPx(userMinRaw, adjusted) ?? resolveLength(userMinRaw)\n if (minPx) {\n widthResolutions.set(id, minPx)\n el.attribs['data-maizzle-cw'] = minPx\n stripUserMinWidth.add(id)\n continue\n }\n }\n\n if (widthRaw) {\n const widthVal = resolveLength(widthRaw)\n if (widthVal?.endsWith('%')) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n dropMinWidth.add(id)\n continue\n }\n if (widthVal) {\n widthResolutions.set(id, widthVal)\n el.attribs['data-maizzle-cw'] = widthVal\n stripWidth.add(id)\n continue\n }\n }\n\n if (maxRaw && countBased) {\n const maxPx = userValueToPx(maxRaw, adjusted)\n if (maxPx) {\n const cappedMin = countBased.endsWith('px')\n ? minPxLength(countBased, maxPx)\n : maxPx\n widthResolutions.set(id, cappedMin)\n el.attribs['data-maizzle-cw'] = cappedMin\n userHasMaxWidth.add(id)\n if (cappedMin === countBased) {\n const ownInset = horizontalPaddingPx(ownRoot) + horizontalBorderPx(ownRoot)\n if (ownInset > 0) autoColumnInsets.set(id, ownInset)\n }\n continue\n }\n }\n\n if (countBased) {\n widthResolutions.set(id, countBased)\n el.attribs['data-maizzle-cw'] = countBased\n const ownPaddingPx = horizontalPaddingPx(ownRoot)\n const ownBorderPx = horizontalBorderPx(ownRoot)\n const ownInset = ownPaddingPx + ownBorderPx\n if (ownInset > 0) autoColumnInsets.set(id, ownInset)\n\n /**\n * Build the MSO td's \"extras\" string — decls that need to live on\n * the td in addition to width + vertical-align. Two contributors:\n *\n * - `background-color` (always, when present) — Word renders the\n * div bg inside the cell, but anything outside the div (the\n * td's padding area when hoisted, or any whitespace gap)\n * would show the parent's bg instead of the column's. Painting\n * the td matches the user's intent.\n *\n * - `padding*` (hoisted only when no horizontal border) — Word\n * drops div padding without a stabilizing border, so the td\n * has to carry it. With a border, Word renders div padding\n * and a td copy would double-pad. Skip when the slot is `%`:\n * td width math can't subtract px padding from a percentage.\n */\n const extras: string[] = []\n let bgColor: string | undefined\n ownRoot.walkDecls('background-color', (d) => { bgColor = d.value })\n if (bgColor) extras.push(`background-color: ${bgColor}`)\n\n if (ownPaddingPx > 0 && ownBorderPx === 0 && countBased.endsWith('px')) {\n ownRoot.walkDecls((d) => {\n if (/^padding(-|$)/.test(d.prop)) extras.push(`${d.prop}: ${d.value}`)\n })\n hoistedTdWidths.set(id, subtractInsetPx(countBased, ownPaddingPx))\n }\n\n if (extras.length) tdExtras.set(id, extras.join('; '))\n }\n }\n\n const heightResolutions = new Map<string, string>()\n for (const { el, id } of heightTargets) {\n if (!el.attribs?.style) continue\n const h = readHeightFromRoot(parseElStyle(el))\n if (h) heightResolutions.set(id, h)\n }\n\n walk(dom, (node) => {\n if (node.type === 'comment') {\n const data = (node as any).data as string\n if (!data) return\n const hasCW = data.includes('__MAIZZLE_COLW_')\n const hasOH = data.includes('__MAIZZLE_OH_')\n const hasTDX = data.includes('__MAIZZLE_COLTDX_')\n if (!hasCW && !hasOH && !hasTDX) return\n ;(node as any).data = data\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => hoistedTdWidths.get(mid) ?? widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/;\\s*__MAIZZLE_COLTDX_([^_]+)__/g,\n (_m, mid) => {\n const pad = tdExtras.get(mid)\n return pad ? `; ${pad}` : ''\n })\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n return\n }\n\n const el = node as Element\n if (!el.attribs) return\n\n const style = el.attribs.style\n if (style && (style.includes('__MAIZZLE_COLW_') || style.includes('__MAIZZLE_OH_'))) {\n const root = parseElStyle(el)\n const cwId = el.attribs['data-maizzle-cw-id']\n\n /**\n * Strip user dups BEFORE substitution — last-wins CSS would\n * otherwise shadow our resolved values in the output.\n */\n if (cwId && stripUserMinWidth.has(cwId)) {\n root.walkDecls('min-width', (d) => {\n if (!d.value.includes('__MAIZZLE_COLW_')) d.remove()\n })\n }\n if (cwId && stripWidth.has(cwId)) {\n root.walkDecls('width', (d) => { d.remove() })\n }\n\n /**\n * Substitute the column's `min-width:` placeholder with `width: <res>;\n * max-width: 100%`. Width gives the same stacking trigger as\n * min-width — inline-block wraps when children sum > parent\n * — and the `max-width: 100%` clamp keeps the column from\n * overflowing the viewport once it drops to its own row on\n * mobile. Skip the clamp when the user supplied their own.\n *\n * Other placeholders (Overlap td `width`, comment markers,\n * OH height) get a plain value substitution.\n */\n root.walkDecls((d) => {\n if (d.prop === 'min-width') {\n const m = d.value.match(/^__MAIZZLE_COLW_([^_]+)__$/)\n if (m) {\n const mid = m[1]\n if (dropMinWidth.has(mid) || !widthResolutions.has(mid)) {\n d.remove()\n return\n }\n let resolved = widthResolutions.get(mid)!\n const inset = autoColumnInsets.get(mid)\n if (inset) resolved = subtractInsetPx(resolved, inset)\n const repl: Declaration[] = [postcss.decl({ prop: 'width', value: resolved })]\n if (!userHasMaxWidth.has(mid)) {\n repl.push(postcss.decl({ prop: 'max-width', value: '100%' }))\n }\n d.replaceWith(...repl)\n return\n }\n }\n if (d.value.includes('__MAIZZLE_COLW_') || d.value.includes('__MAIZZLE_OH_')) {\n d.value = d.value\n .replace(/__MAIZZLE_COLW_([^_]+)__/g,\n (_m, mid) => widthResolutions.get(mid) ?? widthFallbacks.get(mid) ?? '100%')\n .replace(/__MAIZZLE_OH_([^_]+)__/g,\n (_m, hid) => heightResolutions.get(hid) ?? '100%')\n }\n })\n\n const out = serializeStyle(root)\n if (out) el.attribs.style = out\n else delete el.attribs.style\n }\n\n delete el.attribs['data-maizzle-cw']\n delete el.attribs['data-maizzle-cw-id']\n delete el.attribs['data-maizzle-cw-count']\n delete el.attribs['data-maizzle-cw-self']\n delete el.attribs['data-maizzle-oh-id']\n })\n\n return dom\n}\n"],"mappings":";;;;;;AAMA,MAAM,aAAa;;;;;;AAOnB,SAAS,eAAe,MAAoB;CAC1C,MAAM,QAAkB,CAAC;CACzB,KAAK,WAAW,MAAM;EACpB,MAAM,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ,EAAE,YAAY,gBAAgB,IAAI;CACvE,CAAC;CACD,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,SAAS,eAAe,MAAY,MAAkC;CACpE,IAAI;CACJ,KAAK,UAAU,OAAO,MAAM;EAC1B,QAAQ,EAAE;EACV,OAAO;CACT,CAAC;CACD,OAAO;AACT;;;;;;;AAQA,SAAS,iBAAiB,MAA2B;CACnD,IAAI,UAAyB;CAC7B,KAAK,UAAU,cAAc,MAAM;EACjC,IAAI,CAAC,EAAE,MAAM,SAAS,iBAAiB,GAAG;GACxC,UAAU,EAAE;GACZ,OAAO;EACT;CACF,CAAC;CACD,OAAO;AACT;AAEA,SAAS,cAAc,OAA8B;CACnD,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,WAAW,KAAK,OAAO,GAAG,OAAO;CACrC,MAAM,IAAI,QAAQ,MAAM,4BAA4B;CACpD,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,WAAW,EAAE,EAAE;CACzB,MAAM,QAAQ,EAAE,MAAM,KAAA,CAAM,YAAY;CAExC,OAAO,GAAG,KAAK,MAAM,KADN,SAAS,SAAS,SAAS,OAAO,KAAK,SAAS,OAAO,QAAQ,EAC/C,EAAE;AACnC;AAEA,SAAS,aAAa,OAAe,SAAgC;CACnE,MAAM,IAAI,MAAM,MAAM,kBAAkB;CACxC,IAAI,CAAC,KAAK,UAAU,GAAG,OAAO;CAC9B,MAAM,IAAI,WAAW,EA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G,IAAI;MACrB;KACF;IACF;IACA,IAAI,EAAE,MAAM,SAAS,iBAAiB,KAAK,EAAE,MAAM,SAAS,eAAe,GACzE,EAAE,QAAQ,EAAE,MACT,QAAQ,8BACN,IAAI,QAAQ,iBAAiB,IAAI,GAAG,KAAK,eAAe,IAAI,GAAG,KAAK,MAAM,CAAC,CAC7E,QAAQ,4BACN,IAAI,QAAQ,kBAAkB,IAAI,GAAG,KAAK,MAAM;GAEzD,CAAC;GAED,MAAM,MAAM,eAAe,IAAI;GAC/B,IAAI,KAAK,GAAG,QAAQ,QAAQ;QACvB,OAAO,GAAG,QAAQ;EACzB;EAEA,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;EAClB,OAAO,GAAG,QAAQ;CACpB,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EntitiesConfig } from "../types/config.js";
|
|
2
|
+
import { ChildNode } from "domhandler";
|
|
3
|
+
|
|
4
|
+
//#region src/transformers/entities.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Replace literal Unicode characters in text nodes with their HTML entity
|
|
7
|
+
* equivalents (zero-width joiners, non-breaking spaces, smart quotes,
|
|
8
|
+
* dashes, etc.) for better email-client rendering.
|
|
9
|
+
*
|
|
10
|
+
* @param html HTML string to transform.
|
|
11
|
+
* @param custom Extra entries merged on top of the built-in entity map, or
|
|
12
|
+
* `false` to disable the transform. Defaults to `true`
|
|
13
|
+
* (built-ins only).
|
|
14
|
+
* @returns The transformed HTML string.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { entities } from '@maizzle/framework'
|
|
18
|
+
*
|
|
19
|
+
* // Defaults only
|
|
20
|
+
* entities('hello world') // → 'hello world'
|
|
21
|
+
*
|
|
22
|
+
* // Add a custom mapping
|
|
23
|
+
* entities('© Maizzle', { '©': '©' })
|
|
24
|
+
*
|
|
25
|
+
* // Disable the transform
|
|
26
|
+
* entities('hello world', false)
|
|
27
|
+
*/
|
|
28
|
+
declare function entities(html: string, custom?: EntitiesConfig): string;
|
|
29
|
+
/**
|
|
30
|
+
* DOM-form of {@link entities} used by the internal transformer pipeline.
|
|
31
|
+
* Takes a parsed DOM, returns a parsed DOM — avoids redundant
|
|
32
|
+
* serialize/parse round-trips when chained with other transformers.
|
|
33
|
+
*/
|
|
34
|
+
declare function entitiesDom(dom: ChildNode[], custom?: EntitiesConfig): ChildNode[];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { entities, entitiesDom };
|
|
37
|
+
//# sourceMappingURL=entities.d.ts.map
|