@wavemaker-ai/react-codegen 1.0.0-rc.647469
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/build-react-web.js +149 -0
- package/build-react-web.js.map +1 -0
- package/command.js +101 -0
- package/command.js.map +1 -0
- package/index.js +122 -0
- package/index.js.map +1 -0
- package/package-lock.json +4353 -0
- package/package.json +86 -0
- package/src/app.generator.js +1272 -0
- package/src/app.generator.js.map +1 -0
- package/src/download-packages.js +193 -0
- package/src/download-packages.js.map +1 -0
- package/src/fomatter.js +20 -0
- package/src/fomatter.js.map +1 -0
- package/src/gen-app-override-css.js +379 -0
- package/src/gen-app-override-css.js.map +1 -0
- package/src/genappoverridecssold-file.js +311 -0
- package/src/genappoverridecssold-file.js.map +1 -0
- package/src/handlebar-helpers.js +399 -0
- package/src/handlebar-helpers.js.map +1 -0
- package/src/increment-builder.js +85 -0
- package/src/increment-builder.js.map +1 -0
- package/src/profiles/profile.js +24 -0
- package/src/profiles/profile.js.map +1 -0
- package/src/profiles/web-preview.profile.js +15 -0
- package/src/profiles/web-preview.profile.js.map +1 -0
- package/src/project.service.js +314 -0
- package/src/project.service.js.map +1 -0
- package/src/transpile/bind.ex.transformer.js +226 -0
- package/src/transpile/bind.ex.transformer.js.map +1 -0
- package/src/transpile/components/advanced/carousel-template.transformer.js +16 -0
- package/src/transpile/components/advanced/carousel-template.transformer.js.map +1 -0
- package/src/transpile/components/advanced/carousel.transformer.js +55 -0
- package/src/transpile/components/advanced/carousel.transformer.js.map +1 -0
- package/src/transpile/components/advanced/login.transformer.js +26 -0
- package/src/transpile/components/advanced/login.transformer.js.map +1 -0
- package/src/transpile/components/advanced/marquee.transformer.js +16 -0
- package/src/transpile/components/advanced/marquee.transformer.js.map +1 -0
- package/src/transpile/components/basic/anchor.transformer.js +13 -0
- package/src/transpile/components/basic/anchor.transformer.js.map +1 -0
- package/src/transpile/components/basic/audio.transformer.js +16 -0
- package/src/transpile/components/basic/audio.transformer.js.map +1 -0
- package/src/transpile/components/basic/html.transformer.js +15 -0
- package/src/transpile/components/basic/html.transformer.js.map +1 -0
- package/src/transpile/components/basic/icon.transformer.js +16 -0
- package/src/transpile/components/basic/icon.transformer.js.map +1 -0
- package/src/transpile/components/basic/iframe.transformer.js +16 -0
- package/src/transpile/components/basic/iframe.transformer.js.map +1 -0
- package/src/transpile/components/basic/label.transformer.js +16 -0
- package/src/transpile/components/basic/label.transformer.js.map +1 -0
- package/src/transpile/components/basic/message.transformer.js +16 -0
- package/src/transpile/components/basic/message.transformer.js.map +1 -0
- package/src/transpile/components/basic/picture.transformer.js +22 -0
- package/src/transpile/components/basic/picture.transformer.js.map +1 -0
- package/src/transpile/components/basic/progress-bar.transformer.js +18 -0
- package/src/transpile/components/basic/progress-bar.transformer.js.map +1 -0
- package/src/transpile/components/basic/progress-circle.transformer.js +16 -0
- package/src/transpile/components/basic/progress-circle.transformer.js.map +1 -0
- package/src/transpile/components/basic/richtexteditor.transformer.js +21 -0
- package/src/transpile/components/basic/richtexteditor.transformer.js.map +1 -0
- package/src/transpile/components/basic/search.transformer.js +68 -0
- package/src/transpile/components/basic/search.transformer.js.map +1 -0
- package/src/transpile/components/basic/spinner.transformer.js +16 -0
- package/src/transpile/components/basic/spinner.transformer.js.map +1 -0
- package/src/transpile/components/basic/tree.transformer.js +16 -0
- package/src/transpile/components/basic/tree.transformer.js.map +1 -0
- package/src/transpile/components/basic/video.transformer.js +16 -0
- package/src/transpile/components/basic/video.transformer.js.map +1 -0
- package/src/transpile/components/chart/chart.transformer.js +13 -0
- package/src/transpile/components/chart/chart.transformer.js.map +1 -0
- package/src/transpile/components/container/accordion-pane.transformer.js +34 -0
- package/src/transpile/components/container/accordion-pane.transformer.js.map +1 -0
- package/src/transpile/components/container/accordion.transformer.js +49 -0
- package/src/transpile/components/container/accordion.transformer.js.map +1 -0
- package/src/transpile/components/container/container.transformer.js +27 -0
- package/src/transpile/components/container/container.transformer.js.map +1 -0
- package/src/transpile/components/container/layout-grid/grid-column.transformer.js +16 -0
- package/src/transpile/components/container/layout-grid/grid-column.transformer.js.map +1 -0
- package/src/transpile/components/container/layout-grid/grid-row.transformer.js +16 -0
- package/src/transpile/components/container/layout-grid/grid-row.transformer.js.map +1 -0
- package/src/transpile/components/container/layout-grid/grid.transformer.js +16 -0
- package/src/transpile/components/container/layout-grid/grid.transformer.js.map +1 -0
- package/src/transpile/components/container/linear-layout/linear-layout-item.js +16 -0
- package/src/transpile/components/container/linear-layout/linear-layout-item.js.map +1 -0
- package/src/transpile/components/container/linear-layout/linear-layout.js +16 -0
- package/src/transpile/components/container/linear-layout/linear-layout.js.map +1 -0
- package/src/transpile/components/container/panel-content.transformer.js +16 -0
- package/src/transpile/components/container/panel-content.transformer.js.map +1 -0
- package/src/transpile/components/container/panel-footer.transformer.js +11 -0
- package/src/transpile/components/container/panel-footer.transformer.js.map +1 -0
- package/src/transpile/components/container/panel.transformer.js +26 -0
- package/src/transpile/components/container/panel.transformer.js.map +1 -0
- package/src/transpile/components/container/repeat-template.transformer.js +16 -0
- package/src/transpile/components/container/repeat-template.transformer.js.map +1 -0
- package/src/transpile/components/container/tabheader.transformer.js +13 -0
- package/src/transpile/components/container/tabheader.transformer.js.map +1 -0
- package/src/transpile/components/container/tabpane.transformer.js +38 -0
- package/src/transpile/components/container/tabpane.transformer.js.map +1 -0
- package/src/transpile/components/container/tabs.transformer.js +105 -0
- package/src/transpile/components/container/tabs.transformer.js.map +1 -0
- package/src/transpile/components/container/tile.transformer.js +16 -0
- package/src/transpile/components/container/tile.transformer.js.map +1 -0
- package/src/transpile/components/container/wizard.transformer.js +81 -0
- package/src/transpile/components/container/wizard.transformer.js.map +1 -0
- package/src/transpile/components/container/wizardaction.transformer.js +120 -0
- package/src/transpile/components/container/wizardaction.transformer.js.map +1 -0
- package/src/transpile/components/container/wizardstep.transformer.js +74 -0
- package/src/transpile/components/container/wizardstep.transformer.js.map +1 -0
- package/src/transpile/components/data/card/card-actions.transformer.js +13 -0
- package/src/transpile/components/data/card/card-actions.transformer.js.map +1 -0
- package/src/transpile/components/data/card/card-content.transformer.js +23 -0
- package/src/transpile/components/data/card/card-content.transformer.js.map +1 -0
- package/src/transpile/components/data/card/card-footer.transformer.js +13 -0
- package/src/transpile/components/data/card/card-footer.transformer.js.map +1 -0
- package/src/transpile/components/data/card/card.transformer.js +13 -0
- package/src/transpile/components/data/card/card.transformer.js.map +1 -0
- package/src/transpile/components/data/form/dynamic-fields.transformer.js +24 -0
- package/src/transpile/components/data/form/dynamic-fields.transformer.js.map +1 -0
- package/src/transpile/components/data/form/form-action.transformer.js +145 -0
- package/src/transpile/components/data/form/form-action.transformer.js.map +1 -0
- package/src/transpile/components/data/form/form-body.transformer.js +16 -0
- package/src/transpile/components/data/form/form-body.transformer.js.map +1 -0
- package/src/transpile/components/data/form/form-field.transformer.js +443 -0
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -0
- package/src/transpile/components/data/form/form-footer.transformer.js +16 -0
- package/src/transpile/components/data/form/form-footer.transformer.js.map +1 -0
- package/src/transpile/components/data/form/form.transformer.js +167 -0
- package/src/transpile/components/data/form/form.transformer.js.map +1 -0
- package/src/transpile/components/data/form/util.js +70 -0
- package/src/transpile/components/data/form/util.js.map +1 -0
- package/src/transpile/components/data/list/list-content.transformer.js +35 -0
- package/src/transpile/components/data/list/list-content.transformer.js.map +1 -0
- package/src/transpile/components/data/list/list-template-transformer.js +13 -0
- package/src/transpile/components/data/list/list-template-transformer.js.map +1 -0
- package/src/transpile/components/data/list/list-transformer.js +308 -0
- package/src/transpile/components/data/list/list-transformer.js.map +1 -0
- package/src/transpile/components/data/live-filter-field.transformer.js +437 -0
- package/src/transpile/components/data/live-filter-field.transformer.js.map +1 -0
- package/src/transpile/components/data/livefilter.transformer.js +141 -0
- package/src/transpile/components/data/livefilter.transformer.js.map +1 -0
- package/src/transpile/components/data/liveform.transformer.js +160 -0
- package/src/transpile/components/data/liveform.transformer.js.map +1 -0
- package/src/transpile/components/data/table/live-table.transformer.js +15 -0
- package/src/transpile/components/data/table/live-table.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table-action.transformer.js +29 -0
- package/src/transpile/components/data/table/table-action.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table-column.transformer.js +121 -0
- package/src/transpile/components/data/table/table-column.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table-group.transformer.js +16 -0
- package/src/transpile/components/data/table/table-group.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table-row-action.transformer.js +34 -0
- package/src/transpile/components/data/table/table-row-action.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table-row.transformer.js +33 -0
- package/src/transpile/components/data/table/table-row.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table.transformer.js +64 -0
- package/src/transpile/components/data/table/table.transformer.js.map +1 -0
- package/src/transpile/components/data/table/utils.js +89 -0
- package/src/transpile/components/data/table/utils.js.map +1 -0
- package/src/transpile/components/dialogs/alert-dialog.transformer.js +16 -0
- package/src/transpile/components/dialogs/alert-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/confirm-dialog.transformer.js +16 -0
- package/src/transpile/components/dialogs/confirm-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/dialog-actions.transformer.js +57 -0
- package/src/transpile/components/dialogs/dialog-actions.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/dialog-body.transformer.js +13 -0
- package/src/transpile/components/dialogs/dialog-body.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/dialog.transformer.js +26 -0
- package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/iframe-dialog.transformer.js +16 -0
- package/src/transpile/components/dialogs/iframe-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/login-dialog.transformer.js +45 -0
- package/src/transpile/components/dialogs/login-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/page-dialog.transformer.js +16 -0
- package/src/transpile/components/dialogs/page-dialog.transformer.js.map +1 -0
- package/src/transpile/components/element/html-transformer.js +9 -0
- package/src/transpile/components/element/html-transformer.js.map +1 -0
- package/src/transpile/components/form/button-group.transformer.js +16 -0
- package/src/transpile/components/form/button-group.transformer.js.map +1 -0
- package/src/transpile/components/form/button.transformer.js +27 -0
- package/src/transpile/components/form/button.transformer.js.map +1 -0
- package/src/transpile/components/form/rating.transformer.js +19 -0
- package/src/transpile/components/form/rating.transformer.js.map +1 -0
- package/src/transpile/components/input/calendar.transformer.js +13 -0
- package/src/transpile/components/input/calendar.transformer.js.map +1 -0
- package/src/transpile/components/input/checkbox-set.transformer.js +29 -0
- package/src/transpile/components/input/checkbox-set.transformer.js.map +1 -0
- package/src/transpile/components/input/checkbox.transformer.js +47 -0
- package/src/transpile/components/input/checkbox.transformer.js.map +1 -0
- package/src/transpile/components/input/chips.transformer.js +22 -0
- package/src/transpile/components/input/chips.transformer.js.map +1 -0
- package/src/transpile/components/input/color-picker.transformer.js +19 -0
- package/src/transpile/components/input/color-picker.transformer.js.map +1 -0
- package/src/transpile/components/input/composite.transformer.js +16 -0
- package/src/transpile/components/input/composite.transformer.js.map +1 -0
- package/src/transpile/components/input/currency.transformer.js +21 -0
- package/src/transpile/components/input/currency.transformer.js.map +1 -0
- package/src/transpile/components/input/epoch/date.transformer.js +16 -0
- package/src/transpile/components/input/epoch/date.transformer.js.map +1 -0
- package/src/transpile/components/input/epoch/datetime.transformer.js +16 -0
- package/src/transpile/components/input/epoch/datetime.transformer.js.map +1 -0
- package/src/transpile/components/input/epoch/time.transformer.js +16 -0
- package/src/transpile/components/input/epoch/time.transformer.js.map +1 -0
- package/src/transpile/components/input/file-upload.transformer.js +32 -0
- package/src/transpile/components/input/file-upload.transformer.js.map +1 -0
- package/src/transpile/components/input/number.transformer.js +20 -0
- package/src/transpile/components/input/number.transformer.js.map +1 -0
- package/src/transpile/components/input/radio-set.transformer.js +25 -0
- package/src/transpile/components/input/radio-set.transformer.js.map +1 -0
- package/src/transpile/components/input/rating.transformer.js +20 -0
- package/src/transpile/components/input/rating.transformer.js.map +1 -0
- package/src/transpile/components/input/select.transformer.js +57 -0
- package/src/transpile/components/input/select.transformer.js.map +1 -0
- package/src/transpile/components/input/slider.transformer.js +28 -0
- package/src/transpile/components/input/slider.transformer.js.map +1 -0
- package/src/transpile/components/input/switch.transformer.js +21 -0
- package/src/transpile/components/input/switch.transformer.js.map +1 -0
- package/src/transpile/components/input/text.transformer.js +21 -0
- package/src/transpile/components/input/text.transformer.js.map +1 -0
- package/src/transpile/components/input/textarea.transformer.js +19 -0
- package/src/transpile/components/input/textarea.transformer.js.map +1 -0
- package/src/transpile/components/input/upload.transformer.js +19 -0
- package/src/transpile/components/input/upload.transformer.js.map +1 -0
- package/src/transpile/components/layout/footer.transformer.js +31 -0
- package/src/transpile/components/layout/footer.transformer.js.map +1 -0
- package/src/transpile/components/layout/header.transformer.js +31 -0
- package/src/transpile/components/layout/header.transformer.js.map +1 -0
- package/src/transpile/components/layout/leftnav.transformer.js +31 -0
- package/src/transpile/components/layout/leftnav.transformer.js.map +1 -0
- package/src/transpile/components/layout/rightnav.transformer.js +31 -0
- package/src/transpile/components/layout/rightnav.transformer.js.map +1 -0
- package/src/transpile/components/layout/topnav.transformer.js +35 -0
- package/src/transpile/components/layout/topnav.transformer.js.map +1 -0
- package/src/transpile/components/nav/nav-item.transformer.js +25 -0
- package/src/transpile/components/nav/nav-item.transformer.js.map +1 -0
- package/src/transpile/components/nav/nav.transformer.js +69 -0
- package/src/transpile/components/nav/nav.transformer.js.map +1 -0
- package/src/transpile/components/nav/navbar.transformer.js +121 -0
- package/src/transpile/components/nav/navbar.transformer.js.map +1 -0
- package/src/transpile/components/navigation/breadcrumb.transformer.js +16 -0
- package/src/transpile/components/navigation/breadcrumb.transformer.js.map +1 -0
- package/src/transpile/components/navigation/menu.transformer.js +36 -0
- package/src/transpile/components/navigation/menu.transformer.js.map +1 -0
- package/src/transpile/components/navigation/popover.transformer.js +29 -0
- package/src/transpile/components/navigation/popover.transformer.js.map +1 -0
- package/src/transpile/components/page/content.transformer.js +17 -0
- package/src/transpile/components/page/content.transformer.js.map +1 -0
- package/src/transpile/components/page/page-content.transformer.js +17 -0
- package/src/transpile/components/page/page-content.transformer.js.map +1 -0
- package/src/transpile/components/page/page.transformer.js +50 -0
- package/src/transpile/components/page/page.transformer.js.map +1 -0
- package/src/transpile/components/page/partial-container.transformer.js +95 -0
- package/src/transpile/components/page/partial-container.transformer.js.map +1 -0
- package/src/transpile/components/page/partial.transformer.js +19 -0
- package/src/transpile/components/page/partial.transformer.js.map +1 -0
- package/src/transpile/components/prefab/prefab-container.transformer.js +32 -0
- package/src/transpile/components/prefab/prefab-container.transformer.js.map +1 -0
- package/src/transpile/components/prefab/prefab.transformer.js +85 -0
- package/src/transpile/components/prefab/prefab.transformer.js.map +1 -0
- package/src/transpile/components/transform-register.js +247 -0
- package/src/transpile/components/transform-register.js.map +1 -0
- package/src/transpile/components/utils.js +371 -0
- package/src/transpile/components/utils.js.map +1 -0
- package/src/transpile/components/wmx-component/wmx-component.transformer.js +35 -0
- package/src/transpile/components/wmx-component/wmx-component.transformer.js.map +1 -0
- package/src/transpile/id-generator.js +87 -0
- package/src/transpile/id-generator.js.map +1 -0
- package/src/transpile/property/base-parser.js +13 -0
- package/src/transpile/property/base-parser.js.map +1 -0
- package/src/transpile/property/property-parser.js +276 -0
- package/src/transpile/property/property-parser.js.map +1 -0
- package/src/transpile/property/show-in-device.parser.js +17 -0
- package/src/transpile/property/show-in-device.parser.js.map +1 -0
- package/src/transpile/style/background-image.parser.js +20 -0
- package/src/transpile/style/background-image.parser.js.map +1 -0
- package/src/transpile/style/border-width.parser.js +20 -0
- package/src/transpile/style/border-width.parser.js.map +1 -0
- package/src/transpile/style/dimension-style.parser.js +70 -0
- package/src/transpile/style/dimension-style.parser.js.map +1 -0
- package/src/transpile/style/horizontal-align.parser.js +24 -0
- package/src/transpile/style/horizontal-align.parser.js.map +1 -0
- package/src/transpile/style/margin.parser.js +20 -0
- package/src/transpile/style/margin.parser.js.map +1 -0
- package/src/transpile/style/multi-dimension-style.parser.js +29 -0
- package/src/transpile/style/multi-dimension-style.parser.js.map +1 -0
- package/src/transpile/style/numeric-style.parser.js +18 -0
- package/src/transpile/style/numeric-style.parser.js.map +1 -0
- package/src/transpile/style/padding.parser.js +20 -0
- package/src/transpile/style/padding.parser.js.map +1 -0
- package/src/transpile/style/style.parser.js +15 -0
- package/src/transpile/style/style.parser.js.map +1 -0
- package/src/transpile/style.transformer.js +124 -0
- package/src/transpile/style.transformer.js.map +1 -0
- package/src/transpile/transpile.js +1057 -0
- package/src/transpile/transpile.js.map +1 -0
- package/src/transpile/widget-inline-style-constants.js +200 -0
- package/src/transpile/widget-inline-style-constants.js.map +1 -0
- package/src/transpile/widget-inline-style-processor.js +714 -0
- package/src/transpile/widget-inline-style-processor.js.map +1 -0
- package/src/types/index.js +6 -0
- package/src/types/index.js.map +1 -0
- package/src/utils/grouping-util.js +500 -0
- package/src/utils/grouping-util.js.map +1 -0
- package/src/utils.js +934 -0
- package/src/utils.js.map +1 -0
- package/src/variables/variable.transformer.js +675 -0
- package/src/variables/variable.transformer.js.map +1 -0
- package/src/wmx.generator.js +216 -0
- package/src/wmx.generator.js.map +1 -0
- package/templates/.DS_Store +0 -0
- package/templates/app.style.template +3 -0
- package/templates/app.variables.template +1 -0
- package/templates/component/app.libs.hbs +38 -0
- package/templates/component/app.script.hbs +8 -0
- package/templates/component/app.template.hbs +47 -0
- package/templates/component/component.hbs +92 -0
- package/templates/component/component.props.template +1 -0
- package/templates/component/formatter.hbs +8 -0
- package/templates/component/layout.hbs +32 -0
- package/templates/component/page.hbs +16 -0
- package/templates/component/partial.hbs +78 -0
- package/templates/component/script.template +6 -0
- package/templates/component/style-def.template +18 -0
- package/templates/component/style.template +1 -0
- package/templates/entity-provider.template +21 -0
- package/templates/foundation/layout.tsx +30 -0
- package/templates/pages-config.template +12 -0
- package/templates/partial-config.template +58 -0
- package/templates/project/.DS_Store +0 -0
- package/templates/project/.env +1 -0
- package/templates/project/.gitignore +2 -0
- package/templates/project/.prettierrc +8 -0
- package/templates/project/README.md +60 -0
- package/templates/project/app/autoLayout.css +133 -0
- package/templates/project/app/client.layout.tsx +193 -0
- package/templates/project/app/components.css +186 -0
- package/templates/project/app/error.tsx +27 -0
- package/templates/project/app/globals.css +157 -0
- package/templates/project/app/layout.tsx +40 -0
- package/templates/project/app/loading.tsx +6 -0
- package/templates/project/app/page.tsx +3 -0
- package/templates/project/app/widgetInlineStylesOverride.css +676 -0
- package/templates/project/hooks/usePageEvents.tsx +45 -0
- package/templates/project/libs/appConfig.ts +14 -0
- package/templates/project/next-env.d.ts +5 -0
- package/templates/project/next.config.ts +17 -0
- package/templates/project/package-lock.json +5397 -0
- package/templates/project/package.json +38 -0
- package/templates/project/public/error-fallback.svg +89 -0
- package/templates/project/public/file.svg +1 -0
- package/templates/project/public/globe.svg +1 -0
- package/templates/project/public/next.svg +1 -0
- package/templates/project/public/vercel.svg +1 -0
- package/templates/project/public/window.svg +1 -0
- package/templates/project/scripts/app-custom-server.js +44 -0
- package/templates/project/scripts/getlibs.js +53 -0
- package/templates/project/tsconfig.json +36 -0
- package/templates/project/types/runtime-config.d.ts +9 -0
- package/templates/resource.resolver.template +20 -0
- package/templates/service.defs.template +3 -0
- package/templates/variables.template +252 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Converts static autoLayout and style attributes into Tailwind-like CSS utility classes.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AutolayoutCodegen = void 0;
|
|
5
|
+
const widget_inline_style_constants_1 = require("./widget-inline-style-constants");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const isBind = (v) => !!(v && (v.startsWith("bind:") || v.startsWith("{")));
|
|
8
|
+
const hasValidDir = (v) => v === "row" || v === "column";
|
|
9
|
+
const isAuto = (v) => v === "auto";
|
|
10
|
+
const normalizeGap = (v) => v != null && v !== "" && !isAuto(v) ? v : null;
|
|
11
|
+
const px = (v) => v == null || v === "auto" ? undefined : `${v}px`;
|
|
12
|
+
function getBaseAlignment(key) {
|
|
13
|
+
return widget_inline_style_constants_1.ALIGNMENT_MATRIX[key] || { justifyContent: "flex-start", alignItems: "flex-start" };
|
|
14
|
+
}
|
|
15
|
+
// Swaps justifyContent/alignItems for column direction
|
|
16
|
+
function getDirectionalAlignment(base, isRow) {
|
|
17
|
+
return {
|
|
18
|
+
justifyContent: isRow ? base.justifyContent : base.alignItems,
|
|
19
|
+
alignItems: isRow ? base.alignItems : base.justifyContent,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Replaces special characters to produce valid CSS class names
|
|
23
|
+
function sanitizeValue(value) {
|
|
24
|
+
return value
|
|
25
|
+
.replace(/\s+/g, "-")
|
|
26
|
+
.replace(/%/g, "pct")
|
|
27
|
+
.replace(/\./g, "_")
|
|
28
|
+
.replace(/#/g, "h")
|
|
29
|
+
.replace(/\//g, "-")
|
|
30
|
+
.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
31
|
+
}
|
|
32
|
+
function cssToClassName(property, value) {
|
|
33
|
+
const prefix = widget_inline_style_constants_1.CSS_PROP_PREFIX[property] || property.replace(/-/g, "");
|
|
34
|
+
return `${prefix}-${sanitizeValue(value)}`;
|
|
35
|
+
}
|
|
36
|
+
// Strips matching outer parentheses from an expression
|
|
37
|
+
function stripBalancedOuterParens(expr) {
|
|
38
|
+
let e = expr;
|
|
39
|
+
while (e.startsWith("(") && e.endsWith(")")) {
|
|
40
|
+
let depth = 0;
|
|
41
|
+
let balanced = true;
|
|
42
|
+
for (let i = 0; i < e.length - 1; i++) {
|
|
43
|
+
if (e[i] === "(")
|
|
44
|
+
depth++;
|
|
45
|
+
else if (e[i] === ")")
|
|
46
|
+
depth--;
|
|
47
|
+
if (depth === 0) {
|
|
48
|
+
balanced = false;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (balanced)
|
|
53
|
+
e = e.substring(1, e.length - 1).trim();
|
|
54
|
+
else
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
// Extracts a string literal or numeric literal from an expression
|
|
60
|
+
function extractStringLiteral(expr) {
|
|
61
|
+
const e = stripBalancedOuterParens(expr.trim());
|
|
62
|
+
if ((e.startsWith('"') && e.endsWith('"')) || (e.startsWith("'") && e.endsWith("'"))) {
|
|
63
|
+
return e.substring(1, e.length - 1);
|
|
64
|
+
}
|
|
65
|
+
const n = Number(e);
|
|
66
|
+
if (!Number.isNaN(n) && e.length > 0)
|
|
67
|
+
return String(n);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// Parses a bind: ternary expression into condition, trueValue, falseValue
|
|
71
|
+
function parseTernaryExpression(rawAttrValue) {
|
|
72
|
+
let expr = rawAttrValue.trim();
|
|
73
|
+
if (expr.startsWith("bind:"))
|
|
74
|
+
expr = expr.substring(5).trim();
|
|
75
|
+
if (expr.startsWith("{") && expr.endsWith("}"))
|
|
76
|
+
expr = expr.substring(1, expr.length - 1).trim();
|
|
77
|
+
expr = stripBalancedOuterParens(expr);
|
|
78
|
+
let questionIdx = -1;
|
|
79
|
+
let colonIdx = -1;
|
|
80
|
+
let depth = 0;
|
|
81
|
+
let inSingle = false;
|
|
82
|
+
let inDouble = false;
|
|
83
|
+
let inTemplate = false;
|
|
84
|
+
for (let i = 0; i < expr.length; i++) {
|
|
85
|
+
const ch = expr[i];
|
|
86
|
+
if (i > 0 && expr[i - 1] === "\\")
|
|
87
|
+
continue;
|
|
88
|
+
if (!inDouble && !inTemplate && ch === "'") {
|
|
89
|
+
inSingle = !inSingle;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!inSingle && !inTemplate && ch === '"') {
|
|
93
|
+
inDouble = !inDouble;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (!inSingle && !inDouble && ch === "`") {
|
|
97
|
+
inTemplate = !inTemplate;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (inSingle || inDouble || inTemplate)
|
|
101
|
+
continue;
|
|
102
|
+
if (ch === "(" || ch === "[") {
|
|
103
|
+
depth++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (ch === ")" || ch === "]") {
|
|
107
|
+
depth--;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (depth !== 0)
|
|
111
|
+
continue;
|
|
112
|
+
if (ch === "?" && questionIdx < 0) {
|
|
113
|
+
const next = i + 1 < expr.length ? expr[i + 1] : "";
|
|
114
|
+
if (next !== "." && next !== "?")
|
|
115
|
+
questionIdx = i;
|
|
116
|
+
}
|
|
117
|
+
if (ch === ":" && questionIdx >= 0 && colonIdx < 0) {
|
|
118
|
+
colonIdx = i;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (questionIdx < 0 || colonIdx < 0)
|
|
122
|
+
return null;
|
|
123
|
+
const condition = expr.substring(0, questionIdx).trim();
|
|
124
|
+
const trueExpr = expr.substring(questionIdx + 1, colonIdx).trim();
|
|
125
|
+
const falseExpr = expr.substring(colonIdx + 1).trim();
|
|
126
|
+
const trueValue = extractStringLiteral(trueExpr);
|
|
127
|
+
const falseValue = extractStringLiteral(falseExpr);
|
|
128
|
+
if (trueValue === null || falseValue === null)
|
|
129
|
+
return null;
|
|
130
|
+
return { condition, trueValue, falseValue };
|
|
131
|
+
}
|
|
132
|
+
// Maps a single layout attr value to its CSS property/value pairs
|
|
133
|
+
function computeCssForSingleAttr(attrName, value) {
|
|
134
|
+
if (!value && value !== "0")
|
|
135
|
+
return [];
|
|
136
|
+
switch (attrName) {
|
|
137
|
+
case "position":
|
|
138
|
+
return value ? [{ property: "position", value }] : [];
|
|
139
|
+
case "positionvalue": {
|
|
140
|
+
if (!value)
|
|
141
|
+
return [];
|
|
142
|
+
const sides = expandInsetToSides(value);
|
|
143
|
+
const result = [];
|
|
144
|
+
if (sides.top && sides.top !== "auto")
|
|
145
|
+
result.push({ property: "top", value: sides.top });
|
|
146
|
+
if (sides.right && sides.right !== "auto")
|
|
147
|
+
result.push({ property: "right", value: sides.right });
|
|
148
|
+
if (sides.bottom && sides.bottom !== "auto")
|
|
149
|
+
result.push({ property: "bottom", value: sides.bottom });
|
|
150
|
+
if (sides.left && sides.left !== "auto")
|
|
151
|
+
result.push({ property: "left", value: sides.left });
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
case "zindex":
|
|
155
|
+
return value !== "" ? [{ property: "z-index", value: String(value) }] : [];
|
|
156
|
+
case "overflow": {
|
|
157
|
+
const ov = value.toLowerCase();
|
|
158
|
+
if (ov === "vertical")
|
|
159
|
+
return [
|
|
160
|
+
{ property: "overflow-x", value: "hidden" },
|
|
161
|
+
{ property: "overflow-y", value: "scroll" },
|
|
162
|
+
];
|
|
163
|
+
if (ov === "horizontal")
|
|
164
|
+
return [
|
|
165
|
+
{ property: "overflow-x", value: "scroll" },
|
|
166
|
+
{ property: "overflow-y", value: "hidden" },
|
|
167
|
+
];
|
|
168
|
+
if (ov === "both directions" || ov === "both")
|
|
169
|
+
return [{ property: "overflow", value: "scroll" }];
|
|
170
|
+
if (ov === "none")
|
|
171
|
+
return [{ property: "overflow", value: "hidden" }];
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Parses an inset shorthand value into individual top/right/bottom/left (CSS shorthand rules)
|
|
179
|
+
function expandInsetToSides(value) {
|
|
180
|
+
const parts = value.split(/\s+/).filter(Boolean);
|
|
181
|
+
if (parts.length === 1)
|
|
182
|
+
return { top: parts[0], right: parts[0], bottom: parts[0], left: parts[0] };
|
|
183
|
+
if (parts.length === 2)
|
|
184
|
+
return { top: parts[0], right: parts[1], bottom: parts[0], left: parts[1] };
|
|
185
|
+
if (parts.length === 3)
|
|
186
|
+
return { top: parts[0], right: parts[1], bottom: parts[2], left: parts[1] };
|
|
187
|
+
return { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };
|
|
188
|
+
}
|
|
189
|
+
// Computes final CSS properties from static layout props (flex, overflow, position)
|
|
190
|
+
function computeLayoutCssProperties(props) {
|
|
191
|
+
var _a;
|
|
192
|
+
const css = {};
|
|
193
|
+
if (hasValidDir(props.direction)) {
|
|
194
|
+
const direction = props.direction;
|
|
195
|
+
const hasAlignment = !!props.alignment;
|
|
196
|
+
const alignment = props.alignment || "top-left";
|
|
197
|
+
const wrap = direction === "column" ? false : ((_a = props.wrap) !== null && _a !== void 0 ? _a : false);
|
|
198
|
+
const base = getBaseAlignment(alignment);
|
|
199
|
+
const isRow = direction === "row";
|
|
200
|
+
const { justifyContent, alignItems } = getDirectionalAlignment(base, isRow);
|
|
201
|
+
const normGap = normalizeGap(props.gap);
|
|
202
|
+
const normCgap = normalizeGap(props.columngap);
|
|
203
|
+
css["display"] = "flex";
|
|
204
|
+
css["flex-direction"] = direction;
|
|
205
|
+
css["flex-wrap"] = wrap ? "wrap" : "nowrap";
|
|
206
|
+
if (!wrap) {
|
|
207
|
+
if (isAuto(props.gap)) {
|
|
208
|
+
if (hasAlignment) {
|
|
209
|
+
css["justify-content"] = base.justifyContent;
|
|
210
|
+
css["align-items"] = base.alignItems;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
if (hasAlignment) {
|
|
215
|
+
css["justify-content"] = justifyContent;
|
|
216
|
+
css["align-items"] = alignItems;
|
|
217
|
+
}
|
|
218
|
+
if (normGap != null)
|
|
219
|
+
css["gap"] = px(normGap);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
const gapIsAuto = isAuto(props.gap);
|
|
224
|
+
const columnGapIsAuto = isAuto(props.columngap);
|
|
225
|
+
if (hasAlignment) {
|
|
226
|
+
css["justify-content"] = justifyContent;
|
|
227
|
+
css["align-items"] = alignItems;
|
|
228
|
+
}
|
|
229
|
+
if (columnGapIsAuto && gapIsAuto) {
|
|
230
|
+
if (hasAlignment)
|
|
231
|
+
css["align-content"] = justifyContent;
|
|
232
|
+
}
|
|
233
|
+
else if (columnGapIsAuto && !gapIsAuto) {
|
|
234
|
+
if (hasAlignment)
|
|
235
|
+
css["align-content"] = alignItems;
|
|
236
|
+
}
|
|
237
|
+
else if (gapIsAuto && !columnGapIsAuto) {
|
|
238
|
+
if (hasAlignment)
|
|
239
|
+
css["align-content"] = "space-between";
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
if (hasAlignment)
|
|
243
|
+
css["align-content"] = alignItems;
|
|
244
|
+
}
|
|
245
|
+
if (normGap != null)
|
|
246
|
+
css["row-gap"] = px(normGap);
|
|
247
|
+
if (normCgap != null)
|
|
248
|
+
css["column-gap"] = px(normCgap);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Overflow is only applied when clipcontent is true (matches handleClipBehaviour)
|
|
252
|
+
if (props.clipcontent) {
|
|
253
|
+
const overflow = (props.overflow || "").toLowerCase();
|
|
254
|
+
if (overflow === "vertical") {
|
|
255
|
+
css["overflow-x"] = "hidden";
|
|
256
|
+
css["overflow-y"] = "scroll";
|
|
257
|
+
}
|
|
258
|
+
else if (overflow === "horizontal") {
|
|
259
|
+
css["overflow-x"] = "scroll";
|
|
260
|
+
css["overflow-y"] = "hidden";
|
|
261
|
+
}
|
|
262
|
+
else if (overflow === "both directions" || overflow === "both") {
|
|
263
|
+
css["overflow"] = "scroll";
|
|
264
|
+
}
|
|
265
|
+
else if (overflow === "no scrolling" || overflow === "none") {
|
|
266
|
+
css["overflow"] = "hidden";
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (props.position) {
|
|
270
|
+
css["position"] = props.position;
|
|
271
|
+
}
|
|
272
|
+
const rawInset = props.positionvalue || (props.position === "sticky" ? "0px auto auto 0px" : null);
|
|
273
|
+
if (rawInset) {
|
|
274
|
+
const sides = expandInsetToSides(rawInset);
|
|
275
|
+
if (sides.top && sides.top !== "auto")
|
|
276
|
+
css["top"] = sides.top;
|
|
277
|
+
if (sides.right && sides.right !== "auto")
|
|
278
|
+
css["right"] = sides.right;
|
|
279
|
+
if (sides.bottom && sides.bottom !== "auto")
|
|
280
|
+
css["bottom"] = sides.bottom;
|
|
281
|
+
if (sides.left && sides.left !== "auto")
|
|
282
|
+
css["left"] = sides.left;
|
|
283
|
+
}
|
|
284
|
+
if (props.zindex != null && props.zindex !== "") {
|
|
285
|
+
css["z-index"] = String(props.zindex);
|
|
286
|
+
}
|
|
287
|
+
return css;
|
|
288
|
+
}
|
|
289
|
+
// Parses a raw attribute value into the typed StaticLayoutProps field
|
|
290
|
+
function parseAttrValue(name, raw, props) {
|
|
291
|
+
if (name === "wrap") {
|
|
292
|
+
props.wrap = raw === "true" || raw === "wrap";
|
|
293
|
+
}
|
|
294
|
+
else if (name === "gap" || name === "columngap") {
|
|
295
|
+
const n = Number(raw);
|
|
296
|
+
props[name] = Number.isNaN(n) ? raw : n;
|
|
297
|
+
}
|
|
298
|
+
else if (name === "clipcontent") {
|
|
299
|
+
props.clipcontent = raw === "true";
|
|
300
|
+
}
|
|
301
|
+
else if (name === "zindex") {
|
|
302
|
+
const n = Number(raw);
|
|
303
|
+
props.zindex = Number.isNaN(n) ? raw : n;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
props[name] = raw;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Reads static (non-bind) layout attributes from element, skipping dynamic groups
|
|
310
|
+
function getStaticLayoutPropsFromElement(element, dynamicGroups) {
|
|
311
|
+
const attrs = element.attributes || {};
|
|
312
|
+
const props = {};
|
|
313
|
+
let hasAny = false;
|
|
314
|
+
for (const name of widget_inline_style_constants_1.LAYOUT_ATTR_NAMES) {
|
|
315
|
+
if (dynamicGroups) {
|
|
316
|
+
if (dynamicGroups.flex && widget_inline_style_constants_1.FLEX_ATTR_GROUP.has(name))
|
|
317
|
+
continue;
|
|
318
|
+
if (dynamicGroups.overflow && widget_inline_style_constants_1.OVERFLOW_ATTR_GROUP.has(name))
|
|
319
|
+
continue;
|
|
320
|
+
if (dynamicGroups.position && widget_inline_style_constants_1.POSITION_ATTR_GROUP.has(name))
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const raw = attrs[name];
|
|
324
|
+
if (raw == null)
|
|
325
|
+
continue;
|
|
326
|
+
if (isBind(raw))
|
|
327
|
+
continue;
|
|
328
|
+
hasAny = true;
|
|
329
|
+
parseAttrValue(name, raw, props);
|
|
330
|
+
}
|
|
331
|
+
return hasAny ? props : null;
|
|
332
|
+
}
|
|
333
|
+
// Removes processed static layout attributes from the element
|
|
334
|
+
function removeStaticLayoutAttrsFromElement(element, staticProps, dynamicGroups) {
|
|
335
|
+
if (!(dynamicGroups === null || dynamicGroups === void 0 ? void 0 : dynamicGroups.flex)) {
|
|
336
|
+
if (staticProps.direction != null)
|
|
337
|
+
element.removeAttribute("direction");
|
|
338
|
+
if (staticProps.alignment != null)
|
|
339
|
+
element.removeAttribute("alignment");
|
|
340
|
+
if (staticProps.gap != null)
|
|
341
|
+
element.removeAttribute("gap");
|
|
342
|
+
if (staticProps.columngap != null)
|
|
343
|
+
element.removeAttribute("columngap");
|
|
344
|
+
if (staticProps.wrap != null)
|
|
345
|
+
element.removeAttribute("wrap");
|
|
346
|
+
}
|
|
347
|
+
if (!(dynamicGroups === null || dynamicGroups === void 0 ? void 0 : dynamicGroups.overflow)) {
|
|
348
|
+
if (staticProps.clipcontent != null)
|
|
349
|
+
element.removeAttribute("clipcontent");
|
|
350
|
+
if (staticProps.overflow != null)
|
|
351
|
+
element.removeAttribute("overflow");
|
|
352
|
+
}
|
|
353
|
+
if (!(dynamicGroups === null || dynamicGroups === void 0 ? void 0 : dynamicGroups.position)) {
|
|
354
|
+
if (staticProps.position != null)
|
|
355
|
+
element.removeAttribute("position");
|
|
356
|
+
if (staticProps.positionvalue != null)
|
|
357
|
+
element.removeAttribute("positionvalue");
|
|
358
|
+
if (staticProps.zindex != null)
|
|
359
|
+
element.removeAttribute("zindex");
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Converts a dimension value to its CSS equivalent (auto, hug→fit-content, fill→100%, number→px)
|
|
363
|
+
function parseDimensionValue(value, element) {
|
|
364
|
+
if (value === "auto")
|
|
365
|
+
return "auto";
|
|
366
|
+
if (value === "hug")
|
|
367
|
+
return "fit-content";
|
|
368
|
+
if (value === "fill")
|
|
369
|
+
return "100%";
|
|
370
|
+
if (/(%|vw|vh|em|rem|px|pt|pc|in|cm|mm)$/.test(value))
|
|
371
|
+
return value;
|
|
372
|
+
const n = Number(value);
|
|
373
|
+
if (!Number.isNaN(n))
|
|
374
|
+
return `${n}px`;
|
|
375
|
+
return value;
|
|
376
|
+
}
|
|
377
|
+
// Expands a shorthand value (e.g. "10px 20px") into [top, right, bottom, left]
|
|
378
|
+
function expandShorthand(value) {
|
|
379
|
+
const parts = value.split(/\s+/).map(v => (v !== "unset" ? parseDimensionValue(v) : "unset"));
|
|
380
|
+
if (parts.length === 1)
|
|
381
|
+
return [parts[0], parts[0], parts[0], parts[0]];
|
|
382
|
+
if (parts.length === 2)
|
|
383
|
+
return [parts[0], parts[1], parts[0], parts[1]];
|
|
384
|
+
if (parts.length === 3)
|
|
385
|
+
return [parts[0], parts[1], parts[2], parts[1]];
|
|
386
|
+
return [parts[0], parts[1], parts[2], parts[3]];
|
|
387
|
+
}
|
|
388
|
+
// Identifies which layout attribute groups contain dynamic (bind:) values
|
|
389
|
+
function detectDynamicGroups(element) {
|
|
390
|
+
const attrs = element.attributes || {};
|
|
391
|
+
const flags = { flex: false, overflow: false, position: false };
|
|
392
|
+
for (const name of widget_inline_style_constants_1.LAYOUT_ATTR_NAMES) {
|
|
393
|
+
const raw = attrs[name];
|
|
394
|
+
if (raw == null || !isBind(raw))
|
|
395
|
+
continue;
|
|
396
|
+
if (widget_inline_style_constants_1.FLEX_ATTR_GROUP.has(name))
|
|
397
|
+
flags.flex = true;
|
|
398
|
+
else if (widget_inline_style_constants_1.OVERFLOW_ATTR_GROUP.has(name))
|
|
399
|
+
flags.overflow = true;
|
|
400
|
+
else if (widget_inline_style_constants_1.POSITION_ATTR_GROUP.has(name))
|
|
401
|
+
flags.position = true;
|
|
402
|
+
}
|
|
403
|
+
return flags;
|
|
404
|
+
}
|
|
405
|
+
// Encapsulates all autolayout codegen logic: registry, element processing, CSS collection
|
|
406
|
+
class AutolayoutCodegen {
|
|
407
|
+
constructor() {
|
|
408
|
+
this.registry = new Map();
|
|
409
|
+
for (const cls of widget_inline_style_constants_1.PREDEFINED_CLASS_NAMES) {
|
|
410
|
+
this.registry.set(cls, "");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// Registers a CSS class in the registry and returns the class name
|
|
414
|
+
registerClass(property, value) {
|
|
415
|
+
const className = cssToClassName(property, value);
|
|
416
|
+
if (!this.registry.has(className)) {
|
|
417
|
+
this.registry.set(className, `.${className} {\n ${property}: ${value} !important;\n}`);
|
|
418
|
+
}
|
|
419
|
+
return className;
|
|
420
|
+
}
|
|
421
|
+
// Returns the effective parent flex direction for fill/size calculations.
|
|
422
|
+
// For wm-list, the runtime target (<ul>) sits inside an intermediate Box wrapper
|
|
423
|
+
getEffectiveParentDirection(element) {
|
|
424
|
+
var _a, _b, _c;
|
|
425
|
+
const tagName = (_b = (_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
426
|
+
if (tagName === "wm-list")
|
|
427
|
+
return null;
|
|
428
|
+
const parent = element.parentNode;
|
|
429
|
+
const dir = ((_c = parent === null || parent === void 0 ? void 0 : parent.getAttribute) === null || _c === void 0 ? void 0 : _c.call(parent, "direction")) || null;
|
|
430
|
+
return dir && hasValidDir(dir) ? dir : null;
|
|
431
|
+
}
|
|
432
|
+
// Collect flex props for a single dimension, axis-aware to avoid cross-axis conflicts.
|
|
433
|
+
collectSizeFlexProps(element, key, val, flexProps) {
|
|
434
|
+
const parentDirection = this.getEffectiveParentDirection(element);
|
|
435
|
+
const minKey = key === "width" ? "min-width" : "min-height";
|
|
436
|
+
if (val === "fill") {
|
|
437
|
+
if (!parentDirection)
|
|
438
|
+
return;
|
|
439
|
+
const isRow = parentDirection === "row";
|
|
440
|
+
const isMainAxis = (key === "width" && isRow) || (key === "height" && !isRow);
|
|
441
|
+
if (isMainAxis) {
|
|
442
|
+
flexProps["flex-grow"] = "1";
|
|
443
|
+
flexProps[minKey] = "0";
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
flexProps["align-self"] = "stretch";
|
|
447
|
+
}
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
// hug and fixed sizes both prevent shrinking.
|
|
451
|
+
if (parentDirection) {
|
|
452
|
+
const isRow = parentDirection === "row";
|
|
453
|
+
const isMainAxis = (key === "width" && isRow) || (key === "height" && !isRow);
|
|
454
|
+
if (isMainAxis) {
|
|
455
|
+
flexProps["flex-shrink"] = "0";
|
|
456
|
+
if (val !== "hug")
|
|
457
|
+
flexProps["flex-grow"] = "0";
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
flexProps["align-self"] = "auto";
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
flexProps["flex-shrink"] = "0";
|
|
465
|
+
if (val !== "hug")
|
|
466
|
+
flexProps["flex-grow"] = "0";
|
|
467
|
+
flexProps["align-self"] = "auto";
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
// Register the size class (w-100pct, h-fit-content, etc.)
|
|
471
|
+
registerSizeClass(element, key, val) {
|
|
472
|
+
const classes = [];
|
|
473
|
+
if (val === "hug") {
|
|
474
|
+
classes.push(this.registerClass(key, "fit-content"));
|
|
475
|
+
}
|
|
476
|
+
else if (val === "fill") {
|
|
477
|
+
const parentDirection = this.getEffectiveParentDirection(element);
|
|
478
|
+
if (!parentDirection) {
|
|
479
|
+
classes.push(this.registerClass(key, "100%"));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
classes.push(this.registerClass(key, parseDimensionValue(val)));
|
|
484
|
+
}
|
|
485
|
+
return classes;
|
|
486
|
+
}
|
|
487
|
+
normalizeBackgroundImageValue(value) {
|
|
488
|
+
const trimmed = value.trim();
|
|
489
|
+
// CSS gradient functions — already a valid background-image value.
|
|
490
|
+
if (trimmed.startsWith("linear-gradient(") ||
|
|
491
|
+
trimmed.startsWith("radial-gradient(") ||
|
|
492
|
+
trimmed.startsWith("conic-gradient(") ||
|
|
493
|
+
trimmed.startsWith("repeating-")) {
|
|
494
|
+
return trimmed;
|
|
495
|
+
}
|
|
496
|
+
// Strip an existing url() wrapper to get the bare inner path.
|
|
497
|
+
let innerPath = trimmed;
|
|
498
|
+
if (trimmed.startsWith("url(")) {
|
|
499
|
+
const m = trimmed.match(/^url\(\s*(['"]?)(.+?)\1\s*\)$/s);
|
|
500
|
+
if (m)
|
|
501
|
+
innerPath = m[2].trim();
|
|
502
|
+
}
|
|
503
|
+
// Make relative paths absolute using the WaveMaker public-folder convention.
|
|
504
|
+
if (!innerPath.startsWith("/") &&
|
|
505
|
+
!innerPath.startsWith("http://") &&
|
|
506
|
+
!innerPath.startsWith("https://") &&
|
|
507
|
+
!innerPath.startsWith("data:")) {
|
|
508
|
+
innerPath = `/${innerPath}`;
|
|
509
|
+
}
|
|
510
|
+
return `url(${innerPath})`;
|
|
511
|
+
}
|
|
512
|
+
// Converts static style attributes to CSS utility classes and removes them from element
|
|
513
|
+
processStaticStyleProps(element) {
|
|
514
|
+
const classNames = [];
|
|
515
|
+
const bgImageRaw = element.getAttribute("backgroundimage");
|
|
516
|
+
if (bgImageRaw && !isBind(bgImageRaw)) {
|
|
517
|
+
classNames.push(this.registerClass("background-image", this.normalizeBackgroundImageValue(bgImageRaw)));
|
|
518
|
+
element.removeAttribute("backgroundimage");
|
|
519
|
+
}
|
|
520
|
+
const fontUnit = element.getAttribute("fontunit");
|
|
521
|
+
if (fontUnit && !isBind(fontUnit)) {
|
|
522
|
+
element.removeAttribute("fontunit");
|
|
523
|
+
}
|
|
524
|
+
// Process width & height together, simulating sequential override:
|
|
525
|
+
const flexProps = {};
|
|
526
|
+
for (const dimKey of ["width", "height"]) {
|
|
527
|
+
const raw = element.getAttribute(dimKey);
|
|
528
|
+
if (!raw || isBind(raw))
|
|
529
|
+
continue;
|
|
530
|
+
this.collectSizeFlexProps(element, dimKey, raw, flexProps);
|
|
531
|
+
classNames.push(...this.registerSizeClass(element, dimKey, raw));
|
|
532
|
+
element.removeAttribute(dimKey);
|
|
533
|
+
}
|
|
534
|
+
for (const [prop, value] of Object.entries(flexProps)) {
|
|
535
|
+
classNames.push(this.registerClass(prop, value));
|
|
536
|
+
}
|
|
537
|
+
for (const [attrName, info] of Object.entries(widget_inline_style_constants_1.STYLE_ATTR_MAP)) {
|
|
538
|
+
const raw = element.getAttribute(attrName);
|
|
539
|
+
if (!raw || isBind(raw))
|
|
540
|
+
continue;
|
|
541
|
+
if (attrName === "width" || attrName === "height")
|
|
542
|
+
continue;
|
|
543
|
+
if (info.type === "shorthand-4" && info.shorthandSides) {
|
|
544
|
+
const [top, right, bottom, left] = expandShorthand(raw);
|
|
545
|
+
const sides = info.shorthandSides;
|
|
546
|
+
if (top !== "unset")
|
|
547
|
+
classNames.push(this.registerClass(sides.top, top));
|
|
548
|
+
if (right !== "unset")
|
|
549
|
+
classNames.push(this.registerClass(sides.right, right));
|
|
550
|
+
if (bottom !== "unset")
|
|
551
|
+
classNames.push(this.registerClass(sides.bottom, bottom));
|
|
552
|
+
if (left !== "unset")
|
|
553
|
+
classNames.push(this.registerClass(sides.left, left));
|
|
554
|
+
element.removeAttribute(attrName);
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
let cssValue;
|
|
558
|
+
if (info.type === "dimension") {
|
|
559
|
+
if (attrName === "fontsize" && fontUnit && !isBind(fontUnit)) {
|
|
560
|
+
const n = Number(raw);
|
|
561
|
+
cssValue = !Number.isNaN(n) ? `${n}${fontUnit}` : parseDimensionValue(raw);
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
cssValue = parseDimensionValue(raw);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
else if (info.type === "number") {
|
|
568
|
+
const match = raw.match(/^[0-9.\-]+/);
|
|
569
|
+
cssValue = match ? match[0] : raw;
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
cssValue = raw;
|
|
573
|
+
}
|
|
574
|
+
classNames.push(this.registerClass(info.cssProperty, cssValue));
|
|
575
|
+
element.removeAttribute(attrName);
|
|
576
|
+
}
|
|
577
|
+
return classNames;
|
|
578
|
+
}
|
|
579
|
+
// Converts dynamic ternary layout attrs to conditional class expressions
|
|
580
|
+
processDynamicTernaryProps(element, removeAttrs = true) {
|
|
581
|
+
const attrs = element.attributes || {};
|
|
582
|
+
const parsed = [];
|
|
583
|
+
for (const name of widget_inline_style_constants_1.LAYOUT_ATTR_NAMES) {
|
|
584
|
+
const raw = attrs[name];
|
|
585
|
+
if (raw == null || !isBind(raw))
|
|
586
|
+
continue;
|
|
587
|
+
if (widget_inline_style_constants_1.FLEX_ATTR_GROUP.has(name))
|
|
588
|
+
continue;
|
|
589
|
+
const ternary = parseTernaryExpression(raw);
|
|
590
|
+
if (!ternary)
|
|
591
|
+
continue;
|
|
592
|
+
const trueCssEntries = computeCssForSingleAttr(name, ternary.trueValue);
|
|
593
|
+
const falseCssEntries = computeCssForSingleAttr(name, ternary.falseValue);
|
|
594
|
+
if (trueCssEntries.length === 0 && falseCssEntries.length === 0)
|
|
595
|
+
continue;
|
|
596
|
+
const trueClasses = trueCssEntries.map(e => this.registerClass(e.property, e.value));
|
|
597
|
+
const falseClasses = falseCssEntries.map(e => this.registerClass(e.property, e.value));
|
|
598
|
+
parsed.push({ attrName: name, condition: ternary.condition, trueClasses, falseClasses });
|
|
599
|
+
if (removeAttrs || name === "styles")
|
|
600
|
+
element.removeAttribute(name);
|
|
601
|
+
}
|
|
602
|
+
if (parsed.length === 0)
|
|
603
|
+
return [];
|
|
604
|
+
// Merge attrs sharing the same condition into a single ternary expression
|
|
605
|
+
const conditionMap = new Map();
|
|
606
|
+
for (const entry of parsed) {
|
|
607
|
+
const existing = conditionMap.get(entry.condition);
|
|
608
|
+
if (existing) {
|
|
609
|
+
existing.trueClasses.push(...entry.trueClasses);
|
|
610
|
+
existing.falseClasses.push(...entry.falseClasses);
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
conditionMap.set(entry.condition, {
|
|
614
|
+
trueClasses: [...entry.trueClasses],
|
|
615
|
+
falseClasses: [...entry.falseClasses],
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return Array.from(conditionMap.entries()).map(([condition, classes]) => ({
|
|
620
|
+
condition,
|
|
621
|
+
trueClasses: classes.trueClasses.join(" "),
|
|
622
|
+
falseClasses: classes.falseClasses.join(" "),
|
|
623
|
+
}));
|
|
624
|
+
}
|
|
625
|
+
// Processes a container/list element — returns static classes + conditional expressions
|
|
626
|
+
// Does NOT modify the element's class attribute; caller is responsible for emitting layoutClassName.
|
|
627
|
+
processElement(element) {
|
|
628
|
+
var _a, _b;
|
|
629
|
+
const tagName = (_b = (_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
630
|
+
if (!tagName || !widget_inline_style_constants_1.AUTOLAYOUT_WIDGET_TAGS.has(tagName))
|
|
631
|
+
return null;
|
|
632
|
+
const dynamicGroups = detectDynamicGroups(element);
|
|
633
|
+
const allClasses = [];
|
|
634
|
+
const staticProps = getStaticLayoutPropsFromElement(element, dynamicGroups);
|
|
635
|
+
if (staticProps) {
|
|
636
|
+
const cssProperties = computeLayoutCssProperties(staticProps);
|
|
637
|
+
for (const [prop, value] of Object.entries(cssProperties)) {
|
|
638
|
+
allClasses.push(this.registerClass(prop, value));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
allClasses.push(...this.processStaticStyleProps(element));
|
|
642
|
+
const conditionalExpressions = this.processDynamicTernaryProps(element, false);
|
|
643
|
+
for (const attr of widget_inline_style_constants_1.STYLE_OVERLAPPING_LAYOUT_ATTRS) {
|
|
644
|
+
element.removeAttribute(attr);
|
|
645
|
+
}
|
|
646
|
+
const uniqueClasses = [...new Set(allClasses)];
|
|
647
|
+
if (uniqueClasses.length === 0 && conditionalExpressions.length === 0)
|
|
648
|
+
return null;
|
|
649
|
+
return {
|
|
650
|
+
staticClasses: uniqueClasses.join(" "),
|
|
651
|
+
conditionalExpressions,
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
// Processes a list-template element — returns static classes + conditional expressions
|
|
655
|
+
processListTemplate(templateElement) {
|
|
656
|
+
const dynamicGroups = detectDynamicGroups(templateElement);
|
|
657
|
+
const staticClassNames = [];
|
|
658
|
+
const staticProps = getStaticLayoutPropsFromElement(templateElement, dynamicGroups);
|
|
659
|
+
if (staticProps) {
|
|
660
|
+
const cssProperties = computeLayoutCssProperties(staticProps);
|
|
661
|
+
for (const [prop, value] of Object.entries(cssProperties)) {
|
|
662
|
+
staticClassNames.push(this.registerClass(prop, value));
|
|
663
|
+
}
|
|
664
|
+
removeStaticLayoutAttrsFromElement(templateElement, staticProps, dynamicGroups);
|
|
665
|
+
}
|
|
666
|
+
staticClassNames.push(...this.processStaticStyleProps(templateElement));
|
|
667
|
+
const conditionalExpressions = this.processDynamicTernaryProps(templateElement);
|
|
668
|
+
const uniqueClasses = [...new Set(staticClassNames)];
|
|
669
|
+
if (uniqueClasses.length === 0 && conditionalExpressions.length === 0)
|
|
670
|
+
return null;
|
|
671
|
+
return {
|
|
672
|
+
staticClasses: uniqueClasses.join(" "),
|
|
673
|
+
conditionalExpressions,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
// Builds a standalone layoutClassName attribute value string
|
|
677
|
+
buildLayoutClassNameAttr(result) {
|
|
678
|
+
const { staticClasses, conditionalExpressions } = result;
|
|
679
|
+
if (conditionalExpressions.length === 0) {
|
|
680
|
+
return `'${staticClasses}'`;
|
|
681
|
+
}
|
|
682
|
+
const parts = [];
|
|
683
|
+
if (staticClasses) {
|
|
684
|
+
parts.push(JSON.stringify(staticClasses));
|
|
685
|
+
}
|
|
686
|
+
for (const ce of conditionalExpressions) {
|
|
687
|
+
const cond = (0, utils_1.modifyExpression)(ce.condition);
|
|
688
|
+
parts.push(`(${cond} ? ${JSON.stringify(ce.trueClasses)} : ${JSON.stringify(ce.falseClasses)})`);
|
|
689
|
+
}
|
|
690
|
+
return `{[${parts.join(", ")}].filter(Boolean).join(" ")}`;
|
|
691
|
+
}
|
|
692
|
+
// Builds layoutClassName expression for list template itemAttrs
|
|
693
|
+
buildItemAttrsClassName(result) {
|
|
694
|
+
const { staticClasses, conditionalExpressions } = result;
|
|
695
|
+
if (conditionalExpressions.length === 0) {
|
|
696
|
+
return JSON.stringify(staticClasses);
|
|
697
|
+
}
|
|
698
|
+
const parts = [];
|
|
699
|
+
if (staticClasses) {
|
|
700
|
+
parts.push(JSON.stringify(staticClasses));
|
|
701
|
+
}
|
|
702
|
+
for (const ce of conditionalExpressions) {
|
|
703
|
+
const cond = (0, utils_1.modifyExpression)(ce.condition);
|
|
704
|
+
parts.push(`(${cond} ? ${JSON.stringify(ce.trueClasses)} : ${JSON.stringify(ce.falseClasses)})`);
|
|
705
|
+
}
|
|
706
|
+
return `[${parts.join(", ")}].filter(Boolean).join(" ")`;
|
|
707
|
+
}
|
|
708
|
+
// Returns only dynamically generated CSS rules (predefined entries are filtered out)
|
|
709
|
+
getDynamicCssRules() {
|
|
710
|
+
return Array.from(this.registry.values()).filter(Boolean);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
exports.AutolayoutCodegen = AutolayoutCodegen;
|
|
714
|
+
//# sourceMappingURL=widget-inline-style-processor.js.map
|