@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,1057 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createExpression = exports.transformDollarBracketSyntax = exports.decodeHTMLEntities = exports.transpileElement = exports.processTextContentForJSX = exports.addFragmentOptionalChaining = exports.createComponent = exports.preTranspile = exports.transformAttrs = exports.transpileMarkup = exports.registerTransformer = exports.TranspilationContext = exports.generateRandomString = void 0;
|
|
40
|
+
const lodash_1 = require("lodash");
|
|
41
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
42
|
+
const fomatter_1 = require("../fomatter");
|
|
43
|
+
const bind_ex_transformer_1 = __importStar(require("./bind.ex.transformer"));
|
|
44
|
+
const style_transformer_1 = __importDefault(require("./style.transformer"));
|
|
45
|
+
const property_parser_1 = require("./property/property-parser");
|
|
46
|
+
const utils_1 = require("../utils");
|
|
47
|
+
const id_generator_1 = require("./id-generator");
|
|
48
|
+
const widget_inline_style_processor_1 = require("./widget-inline-style-processor");
|
|
49
|
+
const generateRandomString = (length = 10) => Math.random().toString(20).substr(2, length);
|
|
50
|
+
exports.generateRandomString = generateRandomString;
|
|
51
|
+
const EVENT_NAME_MAP = {
|
|
52
|
+
"on-dblclick": "on-doubleClick",
|
|
53
|
+
"on-mouseenter": "on-mouseEnter",
|
|
54
|
+
"on-mouseleave": "on-mouseLeave",
|
|
55
|
+
"on-mouseover": "on-mouseOver",
|
|
56
|
+
"on-mouseout": "on-mouseOut",
|
|
57
|
+
"on-beforesubmit": "on-BeforeSubmit",
|
|
58
|
+
"on-dragstart": "on-dragStart",
|
|
59
|
+
"on-dragend": "on-dragEnd",
|
|
60
|
+
"on-dragover": "on-dragOver",
|
|
61
|
+
"on-dragenter": "on-dragEnter",
|
|
62
|
+
"on-dragleave": "on-dragLeave",
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Processes text content for JSX compatibility
|
|
66
|
+
* If content is only special characters (like > or <), wraps them in React expressions
|
|
67
|
+
* @param textContent The raw text content from the node
|
|
68
|
+
* @returns Processed text content safe for JSX, or empty string if no valid content
|
|
69
|
+
*/
|
|
70
|
+
const processTextContentForJSX = (textContent) => {
|
|
71
|
+
const trimmedContent = textContent.trim();
|
|
72
|
+
if (!trimmedContent) {
|
|
73
|
+
return "";
|
|
74
|
+
}
|
|
75
|
+
// If content is only special characters (like > or <), wrap in React expression
|
|
76
|
+
if (/^[<>&]+$/.test(trimmedContent)) {
|
|
77
|
+
// Convert each special character to React expression
|
|
78
|
+
return trimmedContent
|
|
79
|
+
.split("")
|
|
80
|
+
.map(char => `{'${char}'}`)
|
|
81
|
+
.join("");
|
|
82
|
+
}
|
|
83
|
+
return textContent;
|
|
84
|
+
};
|
|
85
|
+
exports.processTextContentForJSX = processTextContentForJSX;
|
|
86
|
+
// Input widgets that should inherit required/floating-label behavior from wm-composite
|
|
87
|
+
const COMPOSITE_INPUT_TAGS = new Set([
|
|
88
|
+
"wm-text",
|
|
89
|
+
"wm-number",
|
|
90
|
+
"wm-currency",
|
|
91
|
+
"wm-date",
|
|
92
|
+
"wm-time",
|
|
93
|
+
"wm-datetime",
|
|
94
|
+
"wm-textarea",
|
|
95
|
+
"wm-select",
|
|
96
|
+
"wm-radioset",
|
|
97
|
+
"wm-checkbox",
|
|
98
|
+
"wm-checkboxset",
|
|
99
|
+
"wm-switch",
|
|
100
|
+
"wm-slider",
|
|
101
|
+
"wm-fileupload",
|
|
102
|
+
"wm-rating",
|
|
103
|
+
"wm-colorpicker",
|
|
104
|
+
"wm-search",
|
|
105
|
+
]);
|
|
106
|
+
/**
|
|
107
|
+
* Adds optional chaining to fragment expressions and fallback values
|
|
108
|
+
* Converts fragment.Variables.wsGetActiveTheme.dataSet.content[0].themeId
|
|
109
|
+
* to (fragment?.Variables?.wsGetActiveTheme?.dataSet?.content?.[0]?.themeId || "")
|
|
110
|
+
*
|
|
111
|
+
* Note: Does not add fallback for expressions containing function calls to preserve syntax
|
|
112
|
+
*/
|
|
113
|
+
const addFragmentOptionalChaining = (expression, addFallback = false) => {
|
|
114
|
+
const chainingObj = {
|
|
115
|
+
targetPattern: /fragment(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*|\[[^\]]+\])*/g,
|
|
116
|
+
addFallback: addFallback,
|
|
117
|
+
detectFunctionCalls: true,
|
|
118
|
+
...(addFallback && { fallbackValue: '""' }),
|
|
119
|
+
};
|
|
120
|
+
return (0, utils_1.addOptionalChaining)(expression);
|
|
121
|
+
};
|
|
122
|
+
exports.addFragmentOptionalChaining = addFragmentOptionalChaining;
|
|
123
|
+
class TranspilationContext {
|
|
124
|
+
constructor(args) {
|
|
125
|
+
this.result = args.result;
|
|
126
|
+
this.transformer = args.transformer;
|
|
127
|
+
this.isPartOfPrefab = args.isPartOfPrefab;
|
|
128
|
+
this.listener = args.listener;
|
|
129
|
+
this.props = args.props;
|
|
130
|
+
this.data = (0, lodash_1.assign)({}, args.data);
|
|
131
|
+
}
|
|
132
|
+
get(key) {
|
|
133
|
+
return this.data && this.data[key];
|
|
134
|
+
}
|
|
135
|
+
set(key, value) {
|
|
136
|
+
this.data[key] = value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.TranspilationContext = TranspilationContext;
|
|
140
|
+
class Transpiler {
|
|
141
|
+
constructor() {
|
|
142
|
+
this.transformers = new Map();
|
|
143
|
+
this.componentNamesList = [];
|
|
144
|
+
this.transpile = (e, isPartOfPrefab, splitCode = true, oldContext) => {
|
|
145
|
+
var _a;
|
|
146
|
+
const isHtmlElement = utils_1.htmlElements.includes(e.tagName.toLowerCase());
|
|
147
|
+
const ignoreElements = ["wm-filter-action", "wm-form-action"];
|
|
148
|
+
const transformer = this.transformers.get(e && e.tagName.toLowerCase());
|
|
149
|
+
let result = {
|
|
150
|
+
markup: "",
|
|
151
|
+
components: {},
|
|
152
|
+
attrs: {},
|
|
153
|
+
imports: [],
|
|
154
|
+
partials: [],
|
|
155
|
+
prefabs: [],
|
|
156
|
+
wmxcomponents: [],
|
|
157
|
+
};
|
|
158
|
+
// Skip name auto-generation for elements inside table column or explicitly ignored elements
|
|
159
|
+
if (!e.getAttribute("name") &&
|
|
160
|
+
!ignoreElements.includes(e.tagName.toLowerCase()) &&
|
|
161
|
+
!((_a = oldContext === null || oldContext === void 0 ? void 0 : oldContext.data) === null || _a === void 0 ? void 0 : _a.isInsideTableColumn)) {
|
|
162
|
+
e.setAttribute("name", `${e.tagName.toLowerCase().replace(/-/g, "_")}_${(0, exports.generateRandomString)()}`);
|
|
163
|
+
}
|
|
164
|
+
// for every new page, initially context is empty. Hence clearing the prev page componentNamesList array.
|
|
165
|
+
if (!oldContext) {
|
|
166
|
+
this.componentNamesList = [];
|
|
167
|
+
}
|
|
168
|
+
if (isHtmlElement) {
|
|
169
|
+
result.markup = preTranspileHtmlElement(e);
|
|
170
|
+
e.childNodes.forEach(c => {
|
|
171
|
+
if (c && c.nodeType == node_html_parser_1.NodeType.ELEMENT_NODE) {
|
|
172
|
+
const cResult = this.transpile(c, isPartOfPrefab, splitCode);
|
|
173
|
+
(0, lodash_1.assignIn)(result.components, cResult.components);
|
|
174
|
+
result.markup += cResult.markup;
|
|
175
|
+
result.imports.push(...cResult.imports);
|
|
176
|
+
result.prefabs.push(...cResult.prefabs);
|
|
177
|
+
result.partials.push(...cResult.partials);
|
|
178
|
+
result.components = { ...result.components, ...cResult.components };
|
|
179
|
+
if (cResult.pageEvents)
|
|
180
|
+
result.pageEvents = cResult.pageEvents;
|
|
181
|
+
}
|
|
182
|
+
else if (c && c.nodeType == node_html_parser_1.NodeType.TEXT_NODE) {
|
|
183
|
+
// Preserve text nodes
|
|
184
|
+
const processedContent = processTextContentForJSX(c.text);
|
|
185
|
+
if (processedContent) {
|
|
186
|
+
result.markup += processedContent;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
result.markup += postTranspileHtmlElement(e);
|
|
191
|
+
}
|
|
192
|
+
else if (transformer != null) {
|
|
193
|
+
const context = new TranspilationContext({
|
|
194
|
+
result: result,
|
|
195
|
+
isPartOfPrefab: isPartOfPrefab,
|
|
196
|
+
transformer: transformer,
|
|
197
|
+
listener: oldContext === null || oldContext === void 0 ? void 0 : oldContext.listener,
|
|
198
|
+
props: (oldContext === null || oldContext === void 0 ? void 0 : oldContext.props) || [],
|
|
199
|
+
data: oldContext === null || oldContext === void 0 ? void 0 : oldContext.data,
|
|
200
|
+
});
|
|
201
|
+
result.imports.push(...transformer.imports(e, context));
|
|
202
|
+
result.markup +=
|
|
203
|
+
transformer.pre(e, context).replace(new RegExp(bind_ex_transformer_1.FORMAT_CONTEXT, "g"), "") +
|
|
204
|
+
(e.childNodes.length > 0 ? "\n" : "");
|
|
205
|
+
e.childNodes.forEach(c => {
|
|
206
|
+
if (c && c.nodeType == node_html_parser_1.NodeType.ELEMENT_NODE) {
|
|
207
|
+
const cResult = this.transpile(c, isPartOfPrefab, splitCode, context);
|
|
208
|
+
(0, lodash_1.assignIn)(result.components, cResult.components);
|
|
209
|
+
result.markup += cResult.markup;
|
|
210
|
+
result.imports.push(...cResult.imports);
|
|
211
|
+
result.prefabs.push(...cResult.prefabs);
|
|
212
|
+
result.wmxcomponents.push(...cResult.wmxcomponents);
|
|
213
|
+
result.partials.push(...cResult.partials);
|
|
214
|
+
result.components = { ...result.components, ...cResult.components };
|
|
215
|
+
if (cResult.pageEvents)
|
|
216
|
+
result.pageEvents = cResult.pageEvents;
|
|
217
|
+
}
|
|
218
|
+
else if (c && c.nodeType == node_html_parser_1.NodeType.TEXT_NODE) {
|
|
219
|
+
// Handle text nodes for custom elements
|
|
220
|
+
const processedContent = processTextContentForJSX(c.text);
|
|
221
|
+
if (processedContent) {
|
|
222
|
+
result.markup += processedContent;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
transformer.partials && result.partials.push(...transformer.partials(e, context));
|
|
227
|
+
transformer.prefabs && result.prefabs.push(...transformer.prefabs(e, context));
|
|
228
|
+
transformer.wmxcomponents &&
|
|
229
|
+
result.wmxcomponents.push(...transformer.wmxcomponents(e, context));
|
|
230
|
+
result.markup += transformer.post(e, context).replace(new RegExp(bind_ex_transformer_1.FORMAT_CONTEXT, "g"), "");
|
|
231
|
+
// splitCode && transformer.createComponent && transformer.createComponent(e, context);
|
|
232
|
+
const accessRole = e.attrs["accessroles"];
|
|
233
|
+
if (accessRole) {
|
|
234
|
+
result.markup = `{fragment.appConfig.SecurityService.hasAccessToWidget('${accessRole}') ? (${result.markup}): null}`;
|
|
235
|
+
}
|
|
236
|
+
result.markup = (0, fomatter_1.prependSpace)(result.markup, 2) + "\n";
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Transforms $[...] syntax to fragment.property for use with Angular parser
|
|
243
|
+
* Examples:
|
|
244
|
+
* $[location] -> fragment.location
|
|
245
|
+
* $[data[$i].locationDesc] -> fragment.locationDesc (removes data[$i]. prefix)
|
|
246
|
+
*/
|
|
247
|
+
transformDollarBracketForFragmentContext(expression) {
|
|
248
|
+
// First, remove data[$i]. prefixes from within $[...] brackets
|
|
249
|
+
expression = expression.replace(/\$\[data\[\$i\]\./g, "$[");
|
|
250
|
+
// Transform $[property.path] to fragment.property.path
|
|
251
|
+
expression = expression.replace(/\$\[([^\]]+)\]/g, (match, property) => {
|
|
252
|
+
// Remove any remaining data[index]. patterns
|
|
253
|
+
property = property.replace(/data\[\d+\]\./g, "");
|
|
254
|
+
return `${property}`;
|
|
255
|
+
});
|
|
256
|
+
return expression;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Checks if a parent element has a dataset that matches the base path of the current dataset.
|
|
260
|
+
* This is used to determine if [$i] should be handled by parent's $item transformation.
|
|
261
|
+
* Example: child has "Variables.list.dataSet[$i].Features", parent has "Variables.list.dataSet"
|
|
262
|
+
*/
|
|
263
|
+
hasParentWithMatchingDataset(element, basePath) {
|
|
264
|
+
var _a;
|
|
265
|
+
let parent = element.parentNode;
|
|
266
|
+
while (parent) {
|
|
267
|
+
const parentDataset = (_a = parent.getAttribute) === null || _a === void 0 ? void 0 : _a.call(parent, "dataset");
|
|
268
|
+
if (parentDataset) {
|
|
269
|
+
// Remove bind: prefix if present
|
|
270
|
+
const parentDatasetValue = parentDataset.startsWith("bind:")
|
|
271
|
+
? parentDataset.substring(5)
|
|
272
|
+
: parentDataset;
|
|
273
|
+
// Check if parent dataset matches the base path (the array being iterated)
|
|
274
|
+
if (parentDatasetValue === basePath || parentDatasetValue === `fragment.${basePath}`) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
parent = parent.parentNode;
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Transforms dataset expressions containing [$i] into a map function.
|
|
284
|
+
* Handles two cases:
|
|
285
|
+
* 1. Expression case: path[$i] inside a broader expression (e.g. function calls, pipes)
|
|
286
|
+
* Example: (calculateLoanMetric(Variables.CustomerLoansData.dataSet[$i], 'percentagePaid')) | suffix: '%'
|
|
287
|
+
* 2. Simple path case: path-like structure with optional nested [$i]
|
|
288
|
+
* Example: Variables.A[$i].children[$i].name
|
|
289
|
+
*/
|
|
290
|
+
transformDatasetWithIndex(value) {
|
|
291
|
+
// Check if there are any [$i] patterns
|
|
292
|
+
if (!value.includes("[$i]")) {
|
|
293
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
294
|
+
}
|
|
295
|
+
const segments = value.split("[$i]");
|
|
296
|
+
if (segments.length < 2) {
|
|
297
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
298
|
+
}
|
|
299
|
+
// Detect expression case: second segment contains expression syntax (parens, pipes, commas)
|
|
300
|
+
// e.g. ", 'percentagePaid')) | suffix: '%'" vs simple path ".children.name"
|
|
301
|
+
const secondSegment = segments[1].trim();
|
|
302
|
+
const isSimplePathSegment = /^\.?[a-zA-Z0-9_.]*$/.test(secondSegment);
|
|
303
|
+
if (!isSimplePathSegment) {
|
|
304
|
+
// Expression case: replace path[$i] with item, transform inner expr, wrap in map
|
|
305
|
+
const pathIndexMatch = value.match(/([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\[\$i\]/);
|
|
306
|
+
if (!pathIndexMatch) {
|
|
307
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
308
|
+
}
|
|
309
|
+
const basePath = pathIndexMatch[1];
|
|
310
|
+
const pathWithIndex = `${basePath}[$i]`;
|
|
311
|
+
const innerExpression = value.replace(pathWithIndex, "item");
|
|
312
|
+
value = this.transformDollarBracketForFragmentContext(innerExpression);
|
|
313
|
+
let transformedInner = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
314
|
+
// transformEx treats bare 'item' as fragment.item; fix for map callback param
|
|
315
|
+
transformedInner = transformedInner
|
|
316
|
+
.replace(/fragment\?\.item\b/g, "item")
|
|
317
|
+
.replace(/fragment\.item\b/g, "item");
|
|
318
|
+
const transformedBase = (0, utils_1.addOptionalChaining)(`fragment.${basePath}`);
|
|
319
|
+
const mapExpression = `${transformedBase}?.map((item) => ${transformedInner})`;
|
|
320
|
+
return `mapfn:() => ${mapExpression}`;
|
|
321
|
+
}
|
|
322
|
+
// Simple path case: use nested map logic
|
|
323
|
+
const basePath = segments[0];
|
|
324
|
+
const transformedBase = (0, utils_1.addOptionalChaining)(`fragment.${basePath}`);
|
|
325
|
+
const buildNestedMap = (segmentIndex, itemVar) => {
|
|
326
|
+
const segment = segments[segmentIndex];
|
|
327
|
+
let cleanSegment = segment.startsWith(".") ? segment.substring(1) : segment;
|
|
328
|
+
cleanSegment = cleanSegment.trim();
|
|
329
|
+
const isLastSegment = segmentIndex === segments.length - 1;
|
|
330
|
+
if (isLastSegment) {
|
|
331
|
+
if (cleanSegment) {
|
|
332
|
+
return (0, utils_1.addOptionalChaining)(`${itemVar}.${cleanSegment}`);
|
|
333
|
+
}
|
|
334
|
+
return itemVar;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const nextItemVar = segmentIndex === 1 ? "child" : `item${segmentIndex}`;
|
|
338
|
+
const nextExpression = buildNestedMap(segmentIndex + 1, nextItemVar);
|
|
339
|
+
if (cleanSegment) {
|
|
340
|
+
const propertyAccess = (0, utils_1.addOptionalChaining)(`${itemVar}.${cleanSegment}`);
|
|
341
|
+
return `${propertyAccess}?.map(${nextItemVar} => ${nextExpression})`;
|
|
342
|
+
}
|
|
343
|
+
return `${itemVar}?.map(${nextItemVar} => ${nextExpression})`;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const mapExpression = `${transformedBase}?.map(item => ${buildNestedMap(1, "item")}) || []`;
|
|
347
|
+
return `mapfn:() => ${mapExpression}`;
|
|
348
|
+
}
|
|
349
|
+
preTranspile(e) {
|
|
350
|
+
Object.keys(e.attributes).forEach(name => {
|
|
351
|
+
let value = e.attributes[name];
|
|
352
|
+
if (value.startsWith("bind:")) {
|
|
353
|
+
value = value.substring(5).trim();
|
|
354
|
+
// Remove trailing semicolons (common in WaveMaker expressions but invalid in JSX)
|
|
355
|
+
value = value.replace(/;+$/, "");
|
|
356
|
+
// Check if this is a simple single $[...] expression that can be simplified
|
|
357
|
+
const simpleSinglePattern = /^\$\[([^\]]+)\]$/;
|
|
358
|
+
const match = value.match(simpleSinglePattern);
|
|
359
|
+
if (match) {
|
|
360
|
+
// Extract property path and remove data[$i]. prefix if present
|
|
361
|
+
let propertyPath = match[1];
|
|
362
|
+
propertyPath = propertyPath.replace(/^data\[\$i\]\./, "");
|
|
363
|
+
propertyPath = propertyPath.replace(/^data\[\d+\]\./, "");
|
|
364
|
+
e.setAttribute(name, propertyPath);
|
|
365
|
+
}
|
|
366
|
+
else if (name === "dataset" && value.includes("[$i]")) {
|
|
367
|
+
// Check if this [$i] should be handled by a parent's $item transformation
|
|
368
|
+
// Extract base path (everything before [$i])
|
|
369
|
+
const basePathMatch = value.match(/^(.+?)\[\$i\]/);
|
|
370
|
+
const basePath = basePathMatch ? basePathMatch[1] : null;
|
|
371
|
+
if (basePath && this.hasParentWithMatchingDataset(e, basePath)) {
|
|
372
|
+
// Parent has matching dataset - let transformRepeatChildData handle [$i] → $item
|
|
373
|
+
// Transform $[...] syntax before passing to Angular parser
|
|
374
|
+
value = this.transformDollarBracketForFragmentContext(value);
|
|
375
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
376
|
+
e.setAttribute(name, "bind:" + transformedValue);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
// No parent with matching dataset - generate map function
|
|
380
|
+
const datasetMapResult = this.transformDatasetWithIndex(value);
|
|
381
|
+
e.setAttribute(name, datasetMapResult);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
// Transform $[...] syntax before passing to Angular parser
|
|
386
|
+
value = this.transformDollarBracketForFragmentContext(value);
|
|
387
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
388
|
+
// Apply optional chaining with fallback only for backgroundimage
|
|
389
|
+
if (name === "backgroundimage") {
|
|
390
|
+
transformedValue = addFragmentOptionalChaining(transformedValue, true);
|
|
391
|
+
}
|
|
392
|
+
e.setAttribute(name, "bind:" + transformedValue);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else if (name === "groupby" && value.includes("(")) {
|
|
396
|
+
e.setAttribute(name, (0, bind_ex_transformer_1.default)(value, "fragment", "event"));
|
|
397
|
+
}
|
|
398
|
+
else if (name.startsWith("on-")) {
|
|
399
|
+
//on-tap to onclick conversion
|
|
400
|
+
if (name === "on-tap") {
|
|
401
|
+
if (e.getAttribute("on-click")) {
|
|
402
|
+
e.removeAttribute("on-tap");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const tapValue = value;
|
|
406
|
+
e.removeAttribute("on-tap");
|
|
407
|
+
name = "on-click";
|
|
408
|
+
value = tapValue;
|
|
409
|
+
}
|
|
410
|
+
const mappedName = EVENT_NAME_MAP[name];
|
|
411
|
+
if (mappedName) {
|
|
412
|
+
e.removeAttribute(name);
|
|
413
|
+
name = mappedName;
|
|
414
|
+
}
|
|
415
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "event");
|
|
416
|
+
// Apply optional chaining for event handlers
|
|
417
|
+
transformedValue = addFragmentOptionalChaining(transformedValue, false);
|
|
418
|
+
e.setAttribute(name, transformedValue + ";");
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
e.childNodes.forEach(c => {
|
|
422
|
+
if (c instanceof node_html_parser_1.HTMLElement) {
|
|
423
|
+
this.preTranspile(c);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
transformStyles(e, context) {
|
|
428
|
+
// WaveMaker source markup may carry a `styles` attr with raw CSS (e.g. "cursor:pointer;").
|
|
429
|
+
// Parse it into a JS style object and remove the raw attr so it doesn't leak into output.
|
|
430
|
+
let rawStylesObj = {};
|
|
431
|
+
const rawStyles = e.getAttribute("styles");
|
|
432
|
+
if (rawStyles && !rawStyles.startsWith("bind:") && !rawStyles.startsWith("{")) {
|
|
433
|
+
rawStyles.split(";").forEach(rule => {
|
|
434
|
+
const colonIdx = rule.indexOf(":");
|
|
435
|
+
if (colonIdx > 0) {
|
|
436
|
+
const prop = rule.substring(0, colonIdx).trim();
|
|
437
|
+
const val = rule.substring(colonIdx + 1).trim();
|
|
438
|
+
if (prop && val) {
|
|
439
|
+
const camelProp = prop.replace(/-([a-z])/g, (_, l) => l.toUpperCase());
|
|
440
|
+
rawStylesObj[camelProp] = val;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
e.removeAttribute("styles");
|
|
445
|
+
}
|
|
446
|
+
const hasConditionalStyles = e.getAttribute("conditionalstyle");
|
|
447
|
+
if (hasConditionalStyles) {
|
|
448
|
+
// add optional chaining to the conditional styles
|
|
449
|
+
e.setAttribute("conditionalstyle", addFragmentOptionalChaining(hasConditionalStyles, true));
|
|
450
|
+
}
|
|
451
|
+
const styleObj = (0, style_transformer_1.default)(e, (propName) => {
|
|
452
|
+
const transformer = context.transformer;
|
|
453
|
+
if (transformer && transformer.isStyleProperty) {
|
|
454
|
+
return transformer.isStyleProperty(propName, e, context);
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
}) || {};
|
|
458
|
+
// Merge raw CSS properties from `styles` attr into the style object
|
|
459
|
+
if (Object.keys(rawStylesObj).length > 0) {
|
|
460
|
+
(0, lodash_1.merge)(styleObj, rawStylesObj);
|
|
461
|
+
}
|
|
462
|
+
let classes = e.getAttribute("class") || "";
|
|
463
|
+
let isStatic = true;
|
|
464
|
+
let styles = styleObj;
|
|
465
|
+
let style = {};
|
|
466
|
+
const styleAttr = e.getAttribute("style");
|
|
467
|
+
if (styleAttr) {
|
|
468
|
+
style =
|
|
469
|
+
(0, style_transformer_1.default)(e, (propName) => {
|
|
470
|
+
const transformer = context.transformer;
|
|
471
|
+
if (transformer && transformer.isStyleProperty) {
|
|
472
|
+
return transformer.isStyleProperty(propName, e, context);
|
|
473
|
+
}
|
|
474
|
+
return true;
|
|
475
|
+
}) || {};
|
|
476
|
+
styles = (0, lodash_1.merge)(style, styleObj);
|
|
477
|
+
}
|
|
478
|
+
if (styles) {
|
|
479
|
+
Object.keys(styleObj).forEach(i => {
|
|
480
|
+
const styleProp = styleObj[i];
|
|
481
|
+
if ((0, lodash_1.isString)(styleProp) && styleProp.startsWith("bind:")) {
|
|
482
|
+
isStatic = false;
|
|
483
|
+
const bindExpr = styleProp.substring(5);
|
|
484
|
+
styleObj[i] = `{___${(0, utils_1.addOptionalChaining)(bindExpr)}___}`;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
if (styles.background) {
|
|
488
|
+
styles.root = styles.root || {};
|
|
489
|
+
styles.root._background = styles.background;
|
|
490
|
+
delete styles.background;
|
|
491
|
+
}
|
|
492
|
+
styles = JSON.stringify(styleObj).replace(/\\"/g, '"');
|
|
493
|
+
if (!isStatic) {
|
|
494
|
+
styles = styles.replace(/"\{___/g, "");
|
|
495
|
+
styles = styles.replace(/___\}"/g, "");
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
let conditionalClasses = e.getAttribute("conditionalclass") || e.getAttribute("ngclass");
|
|
499
|
+
if (classes.startsWith("bind:")) {
|
|
500
|
+
classes = `{${classes.substring(5)}}`;
|
|
501
|
+
}
|
|
502
|
+
if (conditionalClasses) {
|
|
503
|
+
conditionalClasses = conditionalClasses.startsWith("bind:")
|
|
504
|
+
? `${conditionalClasses.substring(5)}`
|
|
505
|
+
: conditionalClasses;
|
|
506
|
+
if (conditionalClasses.startsWith("{") && conditionalClasses.endsWith("}")) {
|
|
507
|
+
conditionalClasses = conditionalClasses.slice(1, -1);
|
|
508
|
+
let expressions = conditionalClasses.split(",").map(expression => {
|
|
509
|
+
const [className, condition] = expression.split(":");
|
|
510
|
+
// If no condition is provided (no colon), wrap the class in quotes
|
|
511
|
+
if (!condition) {
|
|
512
|
+
return `'${className.trim()}'`;
|
|
513
|
+
}
|
|
514
|
+
return `(${(0, utils_1.addOptionalChaining)(condition.trim())} ? ${className.replace(/'$/, " '")} : '')`;
|
|
515
|
+
});
|
|
516
|
+
conditionalClasses = expressions.join("+");
|
|
517
|
+
}
|
|
518
|
+
else if (!conditionalClasses.includes(":") &&
|
|
519
|
+
!conditionalClasses.includes("&&") &&
|
|
520
|
+
!conditionalClasses.includes("||") &&
|
|
521
|
+
!conditionalClasses.includes("$formField")) {
|
|
522
|
+
conditionalClasses = `${conditionalClasses}`;
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
conditionalClasses = (0, utils_1.addOptionalChaining)(conditionalClasses);
|
|
526
|
+
}
|
|
527
|
+
if (classes === null || classes === void 0 ? void 0 : classes.startsWith("{")) {
|
|
528
|
+
classes = classes.substring(0, classes.length - 1);
|
|
529
|
+
classes = `${classes} + ' ' + ${conditionalClasses}}`;
|
|
530
|
+
}
|
|
531
|
+
else if (classes) {
|
|
532
|
+
classes = `{'${classes} ' + ${conditionalClasses}}`;
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
classes = `{${conditionalClasses}}`;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else if (!!classes && !classes.startsWith("{")) {
|
|
539
|
+
classes = `'${classes}'`;
|
|
540
|
+
}
|
|
541
|
+
e.removeAttribute("conditionalclass");
|
|
542
|
+
e.removeAttribute("ngclass");
|
|
543
|
+
e.removeAttribute("class");
|
|
544
|
+
e.removeAttribute("style");
|
|
545
|
+
return {
|
|
546
|
+
styles: styles,
|
|
547
|
+
className: (0, utils_1.addOptionalChaining)(classes),
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
findArgs(str, context) {
|
|
551
|
+
var _a;
|
|
552
|
+
let argStr = "";
|
|
553
|
+
let maxSplits = 0;
|
|
554
|
+
(_a = str.match(/\([^;]*\)/g)) === null || _a === void 0 ? void 0 : _a.forEach(s => {
|
|
555
|
+
const c = s.split(",").length;
|
|
556
|
+
if (maxSplits < c) {
|
|
557
|
+
maxSplits = c;
|
|
558
|
+
argStr = s;
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
argStr = argStr.replace(/\(|\)/g, "");
|
|
562
|
+
if (argStr.indexOf("currentItemWidgets") > 0 && (context === null || context === void 0 ? void 0 : context.get("isInsideList"))) {
|
|
563
|
+
argStr = argStr
|
|
564
|
+
.split(",")
|
|
565
|
+
// implement the logic for currentItemWidgets in proxy mechanism for looped items
|
|
566
|
+
.filter(s => !(0, lodash_1.includes)(["$item", "currentItemWidgets"], s.trim()))
|
|
567
|
+
.join(",");
|
|
568
|
+
}
|
|
569
|
+
// Parse arguments properly, handling commas inside object literals and arrays
|
|
570
|
+
const parseArguments = (argString) => {
|
|
571
|
+
const args = [];
|
|
572
|
+
let currentArg = "";
|
|
573
|
+
let braceCount = 0;
|
|
574
|
+
let bracketCount = 0;
|
|
575
|
+
for (let i = 0; i < argString.length; i++) {
|
|
576
|
+
const char = argString[i];
|
|
577
|
+
// Track object literals (curly braces) and arrays (square brackets)
|
|
578
|
+
if (char === "{")
|
|
579
|
+
braceCount++;
|
|
580
|
+
else if (char === "}")
|
|
581
|
+
braceCount--;
|
|
582
|
+
else if (char === "[")
|
|
583
|
+
bracketCount++;
|
|
584
|
+
else if (char === "]")
|
|
585
|
+
bracketCount--;
|
|
586
|
+
// If we encounter a comma at the top level (not inside an object or array), it's an argument separator
|
|
587
|
+
if (char === "," && braceCount === 0 && bracketCount === 0) {
|
|
588
|
+
if (currentArg.trim()) {
|
|
589
|
+
args.push(currentArg.trim());
|
|
590
|
+
}
|
|
591
|
+
currentArg = "";
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
currentArg += char;
|
|
595
|
+
}
|
|
596
|
+
// Add the last argument
|
|
597
|
+
if (currentArg.trim()) {
|
|
598
|
+
args.push(currentArg.trim());
|
|
599
|
+
}
|
|
600
|
+
return args;
|
|
601
|
+
};
|
|
602
|
+
// Droping literal arguments like strings, numbers, booleans, null/undefined
|
|
603
|
+
const isLiteral = (s) => {
|
|
604
|
+
const v = s.trim();
|
|
605
|
+
return (/^(['"]).*\1$/.test(v) ||
|
|
606
|
+
/^-?\d+(?:\.\d+)?$/.test(v) ||
|
|
607
|
+
/^(true|false|null|undefined)$/i.test(v));
|
|
608
|
+
};
|
|
609
|
+
// Arithmetic/binary expressions (e.g. "0-5", "0+3") are not valid parameter names.
|
|
610
|
+
// The Angular parser converts unary negatives like -5 into binary (0-5).
|
|
611
|
+
const isArithmeticExpression = (s) => {
|
|
612
|
+
const v = s.trim();
|
|
613
|
+
return /^\d+\s*[-+*/%]\s*\d+/.test(v);
|
|
614
|
+
};
|
|
615
|
+
// Check if argument contains a dot (property access), which makes it an expression, not a valid parameter name
|
|
616
|
+
const isPropertyAccess = (s) => {
|
|
617
|
+
return s.trim().includes(".");
|
|
618
|
+
};
|
|
619
|
+
// Object literals should not be extracted as function parameters
|
|
620
|
+
const isObjectLiteral = (s) => {
|
|
621
|
+
const trimmed = s.trim();
|
|
622
|
+
// Check if it starts with { and contains at least one : (key-value pair)
|
|
623
|
+
if (trimmed.startsWith("{") && trimmed.includes(":")) {
|
|
624
|
+
// Verify it's a balanced object literal
|
|
625
|
+
let braceCount = 0;
|
|
626
|
+
let inString = false;
|
|
627
|
+
let stringChar = "";
|
|
628
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
629
|
+
const char = trimmed[i];
|
|
630
|
+
if ((char === '"' || char === "'") && (i === 0 || trimmed[i - 1] !== "\\")) {
|
|
631
|
+
if (!inString) {
|
|
632
|
+
inString = true;
|
|
633
|
+
stringChar = char;
|
|
634
|
+
}
|
|
635
|
+
else if (char === stringChar) {
|
|
636
|
+
inString = false;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else if (!inString) {
|
|
640
|
+
if (char === "{")
|
|
641
|
+
braceCount++;
|
|
642
|
+
else if (char === "}")
|
|
643
|
+
braceCount--;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
// If braces are balanced and it ends with }, it's an object literal
|
|
647
|
+
return braceCount === 0 && trimmed.endsWith("}");
|
|
648
|
+
}
|
|
649
|
+
return false;
|
|
650
|
+
};
|
|
651
|
+
// Array literals should not be extracted as function parameters
|
|
652
|
+
const isArrayLiteral = (s) => {
|
|
653
|
+
const trimmed = s.trim();
|
|
654
|
+
// Check if it starts with [ and ends with ]
|
|
655
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
656
|
+
// Verify it's a balanced array literal
|
|
657
|
+
let bracketCount = 0;
|
|
658
|
+
let inString = false;
|
|
659
|
+
let stringChar = "";
|
|
660
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
661
|
+
const char = trimmed[i];
|
|
662
|
+
if ((char === '"' || char === "'") && (i === 0 || trimmed[i - 1] !== "\\")) {
|
|
663
|
+
if (!inString) {
|
|
664
|
+
inString = true;
|
|
665
|
+
stringChar = char;
|
|
666
|
+
}
|
|
667
|
+
else if (char === stringChar) {
|
|
668
|
+
inString = false;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
else if (!inString) {
|
|
672
|
+
if (char === "[")
|
|
673
|
+
bracketCount++;
|
|
674
|
+
else if (char === "]")
|
|
675
|
+
bracketCount--;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
// If brackets are balanced, it's an array literal
|
|
679
|
+
return bracketCount === 0;
|
|
680
|
+
}
|
|
681
|
+
return false;
|
|
682
|
+
};
|
|
683
|
+
const parsedArgs = parseArguments(argStr);
|
|
684
|
+
const args = parsedArgs
|
|
685
|
+
.filter(Boolean)
|
|
686
|
+
.filter(s => !isLiteral(s))
|
|
687
|
+
.filter(s => !isArithmeticExpression(s))
|
|
688
|
+
.filter(s => !isPropertyAccess(s))
|
|
689
|
+
.filter(s => !isObjectLiteral(s))
|
|
690
|
+
.filter(s => !isArrayLiteral(s));
|
|
691
|
+
return `(${args.join(", ")})`;
|
|
692
|
+
}
|
|
693
|
+
quoteAttr(v) {
|
|
694
|
+
return ("" + v) /* Forces the conversion to string. */
|
|
695
|
+
.replace(/&/g, "&") /* This MUST be the 1st replacement. */
|
|
696
|
+
.replace(/'/g, "'") /* The 4 other predefined entities, required. */
|
|
697
|
+
.replace(/"/g, """)
|
|
698
|
+
.replace(/</g, "<")
|
|
699
|
+
.replace(/>/g, ">");
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Converts ternary expressions that return string literals "true"/"false" to actual boolean values
|
|
703
|
+
* Example: (condition?"true":"false") -> (condition?true:false)
|
|
704
|
+
* Handles cases like: (condition?"true":"false"), (condition? "true" : "false"), etc.
|
|
705
|
+
*/
|
|
706
|
+
convertStringBooleanTernary(exp) {
|
|
707
|
+
return exp.replace(/\?\s*["'](true|false)["']\s*:\s*["'](true|false)["']/g, (_, g1, g2) => `?${g1}:${g2}`);
|
|
708
|
+
}
|
|
709
|
+
shouldTrimUrlAttribute(name) {
|
|
710
|
+
const attrName = name.toLowerCase();
|
|
711
|
+
return attrName.endsWith("url") || attrName.endsWith("src");
|
|
712
|
+
}
|
|
713
|
+
transformAttr(tagName, name, value, context, tx) {
|
|
714
|
+
if (name === "styles" || name === "style" || name === "className") {
|
|
715
|
+
// continue
|
|
716
|
+
}
|
|
717
|
+
else if (name === "groupby" && value.includes("(")) {
|
|
718
|
+
value = `${this.findArgs(value, context)} => ${value}`;
|
|
719
|
+
value = `{${value}}`;
|
|
720
|
+
}
|
|
721
|
+
else if (name.startsWith("on-")) {
|
|
722
|
+
name = "on" + name.charAt(3).toUpperCase() + name.substr(4);
|
|
723
|
+
value = value.replace(/item,/g, "$item,");
|
|
724
|
+
value = value.replace(/item\./g, "$item.");
|
|
725
|
+
value = value.replace(/item\)/g, "$item)");
|
|
726
|
+
const args = this.findArgs(value, context);
|
|
727
|
+
if (context === null || context === void 0 ? void 0 : context.get("isInsideTableColumn")) {
|
|
728
|
+
value = value.replace(/\brow\b/g, "rowData");
|
|
729
|
+
}
|
|
730
|
+
value = `${args} => {${value}}`;
|
|
731
|
+
value = `{${value}}`;
|
|
732
|
+
}
|
|
733
|
+
else if (name === "datasource" || name === "deletedatasource") {
|
|
734
|
+
if (value.startsWith("fragment")) {
|
|
735
|
+
value = `{${value}}`;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
else if (value.startsWith("mapfn:")) {
|
|
739
|
+
// Handle dataset with $i - wrapped as a function
|
|
740
|
+
const exp = value.substring(6); // Remove "mapfn:" prefix
|
|
741
|
+
value = `{${exp}}`;
|
|
742
|
+
}
|
|
743
|
+
else if (value.startsWith("bind:")) {
|
|
744
|
+
let exp = `${value.substring(5)}`;
|
|
745
|
+
exp = exp.replace("fragment.Page", "fragment");
|
|
746
|
+
const isProgressCircleDatavalue = tagName === "wm-progress-circle" && name === "datavalue";
|
|
747
|
+
exp = (0, utils_1.modifyExpression)(exp);
|
|
748
|
+
exp = this.convertStringBooleanTernary(exp);
|
|
749
|
+
// If expression is empty after transformation, use empty string instead of empty braces
|
|
750
|
+
if (!exp) {
|
|
751
|
+
exp = '""';
|
|
752
|
+
}
|
|
753
|
+
if (isProgressCircleDatavalue) {
|
|
754
|
+
value = `{(${exp} || 0)}`; // for progress circle datavalue, we need to set the value to 0 if it is null or undefined
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
value = name === "show" ? `{(${exp} || false)}` : `{${exp}}`;
|
|
758
|
+
}
|
|
759
|
+
if (name === "conditionalclass") {
|
|
760
|
+
return "";
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else if (name === "width" || name === "height") {
|
|
764
|
+
let exp = `${value.substring(5)}`;
|
|
765
|
+
value = `{${value}}`;
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
if (this.shouldTrimUrlAttribute(name)) {
|
|
769
|
+
value = value.trim();
|
|
770
|
+
}
|
|
771
|
+
value = this.quoteAttr(value);
|
|
772
|
+
value = (0, property_parser_1.parseProperty)(value, name, tagName);
|
|
773
|
+
}
|
|
774
|
+
if (tx) {
|
|
775
|
+
const rvalue = tx(name, value);
|
|
776
|
+
if (!(0, lodash_1.isNil)(rvalue)) {
|
|
777
|
+
value = rvalue;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return (0, lodash_1.isNil)(value) || (0, lodash_1.isEmpty)(value) ? "" : `${name}=${value}`;
|
|
781
|
+
}
|
|
782
|
+
transformAttrs(e, context, tx) {
|
|
783
|
+
var _a, _b, _c;
|
|
784
|
+
const autolayout = (_a = context.data) === null || _a === void 0 ? void 0 : _a.autolayoutCodegen;
|
|
785
|
+
const autoLayoutResult = (_b = autolayout === null || autolayout === void 0 ? void 0 : autolayout.processElement(e)) !== null && _b !== void 0 ? _b : null;
|
|
786
|
+
e.setAttribute("data-widget-id", (0, id_generator_1.generateWidgetId)());
|
|
787
|
+
const { styles, className } = this.transformStyles(e, context);
|
|
788
|
+
const tagName = e.tagName.toLowerCase();
|
|
789
|
+
if (!(0, lodash_1.isEmpty)(styles) && styles != "{}") {
|
|
790
|
+
e.setAttribute("styles", `{${styles}}`);
|
|
791
|
+
}
|
|
792
|
+
if (!(0, lodash_1.isEmpty)(className) && className) {
|
|
793
|
+
e.setAttribute("className", className);
|
|
794
|
+
}
|
|
795
|
+
if (tagName === "wm-composite" &&
|
|
796
|
+
(e.getAttribute("captionposition") === "floating" || e.getAttribute("required") === "true")) {
|
|
797
|
+
const labelNode = e.childNodes.find((node) => { var _a; return node.tagName && ((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "wm-label"; });
|
|
798
|
+
const isRequired = e.getAttribute("required") === "true";
|
|
799
|
+
const floatingLabel = e.getAttribute("captionposition") === "floating";
|
|
800
|
+
const labelCaption = (labelNode === null || labelNode === void 0 ? void 0 : labelNode.getAttribute("caption")) || "";
|
|
801
|
+
const containerNode = e.childNodes.find((node) => { var _a; return node.tagName && ((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "wm-container"; });
|
|
802
|
+
const searchNodes = (containerNode === null || containerNode === void 0 ? void 0 : containerNode.childNodes) || e.childNodes || [];
|
|
803
|
+
const foundInputs = searchNodes.filter((node) => { var _a, _b; return COMPOSITE_INPUT_TAGS.has(((_b = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) || ""); });
|
|
804
|
+
if (foundInputs.length && floatingLabel) {
|
|
805
|
+
foundInputs[0].setAttribute("floatinglabel", labelCaption);
|
|
806
|
+
labelNode && labelNode.remove();
|
|
807
|
+
}
|
|
808
|
+
if (isRequired) {
|
|
809
|
+
labelNode && labelNode.setAttribute("required", "true");
|
|
810
|
+
const name = (_c = foundInputs[0]) === null || _c === void 0 ? void 0 : _c.getAttribute("name");
|
|
811
|
+
labelNode && name && labelNode.setAttribute("htmlFor", name);
|
|
812
|
+
foundInputs.forEach(n => n.setAttribute("required", "true"));
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
let str = Object.keys(e.attributes)
|
|
816
|
+
.map(name => {
|
|
817
|
+
return this.transformAttr(tagName, name, e.attributes[name], context, tx);
|
|
818
|
+
})
|
|
819
|
+
.join(" ");
|
|
820
|
+
// Append layoutClassName as a separate attribute, bypassing setAttribute to avoid HTML-entity encoding
|
|
821
|
+
if (autoLayoutResult && autolayout) {
|
|
822
|
+
const layoutClassNameValue = autolayout.buildLayoutClassNameAttr(autoLayoutResult);
|
|
823
|
+
str += ` layoutClassName=${layoutClassNameValue}`;
|
|
824
|
+
}
|
|
825
|
+
return str;
|
|
826
|
+
}
|
|
827
|
+
createUniqueComponentName(components, name, counter = 0) {
|
|
828
|
+
name = name + counter;
|
|
829
|
+
if (components[name]) {
|
|
830
|
+
return this.createUniqueComponentName(components, name, counter++);
|
|
831
|
+
}
|
|
832
|
+
return name;
|
|
833
|
+
}
|
|
834
|
+
createComponent(e, context) {
|
|
835
|
+
const result = context.result;
|
|
836
|
+
let widgetName = "PC_" + (0, lodash_1.capitalize)(e.attrs["name"]);
|
|
837
|
+
widgetName = (0, lodash_1.replace)(widgetName, /[^a-zA-Z0-9]/g, "_");
|
|
838
|
+
if (this.componentNamesList.indexOf(widgetName) !== -1) {
|
|
839
|
+
widgetName = this.createUniqueComponentName(result.components, widgetName);
|
|
840
|
+
}
|
|
841
|
+
this.componentNamesList.push(widgetName);
|
|
842
|
+
const props = ["fragment", ...context.props];
|
|
843
|
+
result.components[widgetName] = `({${props.join(",")}}) => {
|
|
844
|
+
return (${result.markup});
|
|
845
|
+
}`;
|
|
846
|
+
result.markup = `<${widgetName} ${props.map(p => `${p}={${p}}`).join(" ")}/>`;
|
|
847
|
+
return result;
|
|
848
|
+
}
|
|
849
|
+
registerTransformer(tagName, transformer) {
|
|
850
|
+
transpiler.transformers.set(tagName, transformer);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
const transpiler = new Transpiler();
|
|
854
|
+
exports.registerTransformer = transpiler.registerTransformer.bind(transpiler);
|
|
855
|
+
const transpileMarkup = (markup, isPartOfPrefab, splitCode, variables) => {
|
|
856
|
+
const parsed = (0, node_html_parser_1.parse)(markup, {
|
|
857
|
+
blockTextElements: {},
|
|
858
|
+
});
|
|
859
|
+
let finalResult = {
|
|
860
|
+
markup: "",
|
|
861
|
+
components: {},
|
|
862
|
+
partials: [],
|
|
863
|
+
wmxcomponents: [],
|
|
864
|
+
prefabs: [],
|
|
865
|
+
imports: [],
|
|
866
|
+
};
|
|
867
|
+
// Create a map of ModelVariables (wm.Variable category) with twoWayBinding: true
|
|
868
|
+
// Only ModelVariables support twoWayBinding, other variable types don't
|
|
869
|
+
const twoWayBindingVariables = new Set();
|
|
870
|
+
if (variables) {
|
|
871
|
+
Object.values(variables).forEach((v) => {
|
|
872
|
+
// Only check twoWayBinding for ModelVariables (category === "wm.Variable")
|
|
873
|
+
// These are the only variables that support two-way binding
|
|
874
|
+
if (v.category === "wm.Variable" && v.twoWayBinding === true && v.name) {
|
|
875
|
+
twoWayBindingVariables.add(v.name);
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
const autolayoutCodegen = new widget_inline_style_processor_1.AutolayoutCodegen();
|
|
880
|
+
// Create initial context with twoWayBinding variables info to pass down the tree
|
|
881
|
+
const initialContext = new TranspilationContext({
|
|
882
|
+
result: finalResult,
|
|
883
|
+
isPartOfPrefab: isPartOfPrefab,
|
|
884
|
+
transformer: {},
|
|
885
|
+
props: [],
|
|
886
|
+
data: {
|
|
887
|
+
twoWayBindingVariables: twoWayBindingVariables,
|
|
888
|
+
autolayoutCodegen,
|
|
889
|
+
},
|
|
890
|
+
});
|
|
891
|
+
// Process all child nodes (including text nodes that come before the main element)
|
|
892
|
+
parsed.childNodes.forEach((node) => {
|
|
893
|
+
if (node.nodeType === node_html_parser_1.NodeType.TEXT_NODE) {
|
|
894
|
+
const textContent = node.text;
|
|
895
|
+
if (textContent.trim()) {
|
|
896
|
+
finalResult.markup += `{"${textContent.trim()}"} \n`;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
else if (node.nodeType === node_html_parser_1.NodeType.ELEMENT_NODE) {
|
|
900
|
+
transpiler.preTranspile(node);
|
|
901
|
+
const result = transpiler.transpile(node, isPartOfPrefab, splitCode, initialContext);
|
|
902
|
+
finalResult.markup += result.markup;
|
|
903
|
+
finalResult.components = { ...finalResult.components, ...result.components };
|
|
904
|
+
finalResult.partials.push(...result.partials);
|
|
905
|
+
finalResult.prefabs.push(...result.prefabs);
|
|
906
|
+
finalResult.wmxcomponents.push(...result.wmxcomponents);
|
|
907
|
+
finalResult.imports.push(...result.imports);
|
|
908
|
+
if (result.pageEvents)
|
|
909
|
+
finalResult.pageEvents = result.pageEvents;
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
finalResult.autolayoutCss = autolayoutCodegen.getDynamicCssRules();
|
|
913
|
+
return finalResult;
|
|
914
|
+
};
|
|
915
|
+
exports.transpileMarkup = transpileMarkup;
|
|
916
|
+
exports.transformAttrs = transpiler.transformAttrs.bind(transpiler);
|
|
917
|
+
exports.preTranspile = transpiler.preTranspile.bind(transpiler);
|
|
918
|
+
exports.createComponent = transpiler.createComponent.bind(transpiler);
|
|
919
|
+
const transpileElement = (element, isPartOfPrefab, splitCode = true, oldContext) => {
|
|
920
|
+
return transpiler.transpile(element, isPartOfPrefab, splitCode, oldContext);
|
|
921
|
+
};
|
|
922
|
+
exports.transpileElement = transpileElement;
|
|
923
|
+
/**
|
|
924
|
+
* Decodes HTML entities in a string
|
|
925
|
+
* Handles common entities like ", &, <, >, '
|
|
926
|
+
*/
|
|
927
|
+
const decodeHTMLEntities = (text) => {
|
|
928
|
+
const entities = {
|
|
929
|
+
""": '"',
|
|
930
|
+
"&": "&",
|
|
931
|
+
"<": "<",
|
|
932
|
+
">": ">",
|
|
933
|
+
"'": "'",
|
|
934
|
+
};
|
|
935
|
+
return text.replace(/&[a-z]+;/g, entity => entities[entity] || entity);
|
|
936
|
+
};
|
|
937
|
+
exports.decodeHTMLEntities = decodeHTMLEntities;
|
|
938
|
+
/**
|
|
939
|
+
* Transforms $[...] syntax to proper property access
|
|
940
|
+
* Examples:
|
|
941
|
+
* $[location] -> $item.location
|
|
942
|
+
* $[data[$i].locationDesc] -> $item.locationDesc (removes data[$i]. prefix)
|
|
943
|
+
* $[fragment.assetType] -> $item.assetType (removes fragment. prefix)
|
|
944
|
+
*/
|
|
945
|
+
const transformDollarBracketSyntax = (expression) => {
|
|
946
|
+
// First, remove data[$i]. prefixes from within $[...] brackets
|
|
947
|
+
expression = expression.replace(/\$\[data\[\$i\]\./g, "$[");
|
|
948
|
+
// Transform $[property.path] to $item.property.path
|
|
949
|
+
expression = expression.replace(/\$\[([^\]]+)\]/g, (match, property) => {
|
|
950
|
+
// Remove data[index]. and fragment. prefixes
|
|
951
|
+
property = property.replace(/data\[\d+\]\./g, "").replace(/^fragment\./, "");
|
|
952
|
+
return `$item.${property}`;
|
|
953
|
+
});
|
|
954
|
+
return expression;
|
|
955
|
+
};
|
|
956
|
+
exports.transformDollarBracketSyntax = transformDollarBracketSyntax;
|
|
957
|
+
const createExpression = (element, attrName) => {
|
|
958
|
+
let displayexpression = element.attrs[attrName];
|
|
959
|
+
if (displayexpression === null || displayexpression === void 0 ? void 0 : displayexpression.startsWith("bind:")) {
|
|
960
|
+
displayexpression = displayexpression.substring(5).trim();
|
|
961
|
+
// Remove trailing semicolons (common in WaveMaker expressions but invalid in JSX)
|
|
962
|
+
displayexpression = displayexpression.replace(/;+$/, "");
|
|
963
|
+
// Decode HTML entities like " to "
|
|
964
|
+
displayexpression = (0, exports.decodeHTMLEntities)(displayexpression);
|
|
965
|
+
// Transform $[...] syntax to proper property access
|
|
966
|
+
displayexpression = (0, exports.transformDollarBracketSyntax)(displayexpression);
|
|
967
|
+
// Replace fragment references with $item
|
|
968
|
+
displayexpression = displayexpression.replace(/fragment\.\$item/g, "$item");
|
|
969
|
+
displayexpression = displayexpression.replace(/fragment\.\$index/g, "$index");
|
|
970
|
+
displayexpression = displayexpression.replace(/fragment\.\$length/g, "$length");
|
|
971
|
+
displayexpression = displayexpression.replace(/fragment\.\$/g, "$item");
|
|
972
|
+
displayexpression = displayexpression.replace(/\$item\['fragment.(.*?)'\]/g, "$item['$1']");
|
|
973
|
+
displayexpression = displayexpression.replace(/\$item\[fragment.(.*?)\]/g, "$item['$1']");
|
|
974
|
+
displayexpression = displayexpression.replace(/\$item\['(.*?)'\]/g, "_get($item, '$1')");
|
|
975
|
+
displayexpression = displayexpression.replace(/fragment.index/g, "$index");
|
|
976
|
+
if (displayexpression.indexOf("fragment.formatters.") >= 0) {
|
|
977
|
+
displayexpression = displayexpression.replace(new RegExp(bind_ex_transformer_1.FORMAT_CONTEXT, "g"), "$item");
|
|
978
|
+
}
|
|
979
|
+
// Transform fragment.name -> $item.name for arrow functions with $item
|
|
980
|
+
displayexpression = displayexpression.replace(/fragment\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g, "$item.$1");
|
|
981
|
+
// Add optional chaining for all property access (e.g., $item.App.appLocale -> $item?.App?.appLocale)
|
|
982
|
+
// Use negative lookbehind to avoid double optional chaining (??)
|
|
983
|
+
displayexpression = displayexpression.replace(/(?<!\?)\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g, "?.$1");
|
|
984
|
+
displayexpression = displayexpression.replace(/([a-zA-Z0-9_$\]])\[/g, "$1?.[");
|
|
985
|
+
const exp = (0, lodash_1.includes)(displayexpression, "(") ? `${displayexpression}` : displayexpression;
|
|
986
|
+
if (displayexpression.indexOf("$index") >= 0) {
|
|
987
|
+
return `{($item, $index, $length) => (${exp})}`;
|
|
988
|
+
}
|
|
989
|
+
return `{($item) => (${exp})}`;
|
|
990
|
+
}
|
|
991
|
+
if ((0, utils_1.isJSExpression)(displayexpression)) {
|
|
992
|
+
const transformedExp = (0, bind_ex_transformer_1.default)(displayexpression, "$item");
|
|
993
|
+
return `{($item) => (${transformedExp})}`;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
exports.createExpression = createExpression;
|
|
997
|
+
const preTranspileHtmlElement = (e) => {
|
|
998
|
+
// Process style properties using style transformer
|
|
999
|
+
const styleObj = (0, style_transformer_1.default)(e, (propName) => {
|
|
1000
|
+
return true; // Process all style properties
|
|
1001
|
+
}) || {};
|
|
1002
|
+
// Get all attributes except name (which is added by transpiler) and convert class to className
|
|
1003
|
+
const attrs = Object.keys(e.attributes)
|
|
1004
|
+
.filter(attr => attr !== "name")
|
|
1005
|
+
.map(attr => {
|
|
1006
|
+
const value = e.getAttribute(attr);
|
|
1007
|
+
if (!value)
|
|
1008
|
+
return `${attr}=""`;
|
|
1009
|
+
// Convert HTML 'class' attribute to JSX 'className'
|
|
1010
|
+
if (attr === "class") {
|
|
1011
|
+
return `className="${value}"`;
|
|
1012
|
+
}
|
|
1013
|
+
// Convert HTML 'style' attribute to JSX style object
|
|
1014
|
+
else if (attr === "style") {
|
|
1015
|
+
const styleObject = convertStyleStringToObject(value);
|
|
1016
|
+
return `style={${styleObject}}`;
|
|
1017
|
+
}
|
|
1018
|
+
return `${attr}="${value}"`;
|
|
1019
|
+
})
|
|
1020
|
+
.join(" ");
|
|
1021
|
+
// Add processed styles if any were found
|
|
1022
|
+
let styleAttr = "";
|
|
1023
|
+
if (styleObj && Object.keys(styleObj).length > 0) {
|
|
1024
|
+
styleAttr = ` style={${JSON.stringify(styleObj)}}`;
|
|
1025
|
+
}
|
|
1026
|
+
const attrsStr = attrs ? ` ${attrs}` : "";
|
|
1027
|
+
return `<${e.tagName.toLowerCase()}${attrsStr}${styleAttr}>`;
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Converts CSS style string to React style object format
|
|
1031
|
+
* Example: "color:#ffffff; font-size:14px" -> {color:"#ffffff",fontSize:"14px"}
|
|
1032
|
+
*/
|
|
1033
|
+
const convertStyleStringToObject = (styleString) => {
|
|
1034
|
+
if (!styleString || styleString.trim() === "") {
|
|
1035
|
+
return "{}";
|
|
1036
|
+
}
|
|
1037
|
+
const styleObject = {};
|
|
1038
|
+
// Split by semicolon and process each style property
|
|
1039
|
+
styleString.split(";").forEach(rule => {
|
|
1040
|
+
const colonIndex = rule.indexOf(":");
|
|
1041
|
+
if (colonIndex > 0) {
|
|
1042
|
+
const property = rule.substring(0, colonIndex).trim();
|
|
1043
|
+
const value = rule.substring(colonIndex + 1).trim();
|
|
1044
|
+
if (property && value) {
|
|
1045
|
+
// Convert kebab-case to camelCase (e.g., font-size -> fontSize)
|
|
1046
|
+
const camelCaseProperty = property.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
1047
|
+
styleObject[camelCaseProperty] = value;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
// Convert to JSON string and return
|
|
1052
|
+
return JSON.stringify(styleObject);
|
|
1053
|
+
};
|
|
1054
|
+
const postTranspileHtmlElement = (e) => {
|
|
1055
|
+
return `</${e.tagName.toLowerCase()}>`;
|
|
1056
|
+
};
|
|
1057
|
+
//# sourceMappingURL=transpile.js.map
|