@wavemaker-ai/react-codegen 1.0.0-next.27766
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 +106 -0
- package/command.js.map +1 -0
- package/dist/transpiler/index.d.mts +77 -0
- package/dist/transpiler/index.mjs +48241 -0
- package/dist/transpiler/index.mjs.map +1 -0
- package/dist/transpiler/wm-styles.css +1617 -0
- package/index.js +122 -0
- package/index.js.map +1 -0
- package/package-lock.json +5233 -0
- package/package.json +104 -0
- package/src/app.generator.js +1291 -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 +51 -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 +257 -0
- package/src/transpile/bind.ex.transformer.js.map +1 -0
- package/src/transpile/class-expression.util.js +44 -0
- package/src/transpile/class-expression.util.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 +54 -0
- package/src/transpile/components/advanced/carousel.transformer.js.map +1 -0
- package/src/transpile/components/advanced/login.transformer.js +25 -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 +28 -0
- package/src/transpile/components/container/accordion-pane.transformer.js.map +1 -0
- package/src/transpile/components/container/accordion.transformer.js +48 -0
- package/src/transpile/components/container/accordion.transformer.js.map +1 -0
- package/src/transpile/components/container/container.transformer.js +25 -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 +20 -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 +32 -0
- package/src/transpile/components/container/tabpane.transformer.js.map +1 -0
- package/src/transpile/components/container/tabs.transformer.js +71 -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 +80 -0
- package/src/transpile/components/container/wizard.transformer.js.map +1 -0
- package/src/transpile/components/container/wizardaction.transformer.js +121 -0
- package/src/transpile/components/container/wizardaction.transformer.js.map +1 -0
- package/src/transpile/components/container/wizardstep.transformer.js +67 -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 +17 -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/field-widget-shared.js +9 -0
- package/src/transpile/components/data/form/field-widget-shared.js.map +1 -0
- package/src/transpile/components/data/form/form-action.transformer.js +150 -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 +166 -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 +22 -0
- package/src/transpile/components/data/list/list-template-transformer.js.map +1 -0
- package/src/transpile/components/data/list/list-transformer.js +294 -0
- package/src/transpile/components/data/list/list-transformer.js.map +1 -0
- package/src/transpile/components/data/live-filter-field.transformer.js +435 -0
- package/src/transpile/components/data/live-filter-field.transformer.js.map +1 -0
- package/src/transpile/components/data/live-form-shared.js +135 -0
- package/src/transpile/components/data/live-form-shared.js.map +1 -0
- package/src/transpile/components/data/livefilter.transformer.js +20 -0
- package/src/transpile/components/data/livefilter.transformer.js.map +1 -0
- package/src/transpile/components/data/liveform.transformer.js +40 -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 +124 -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 +37 -0
- package/src/transpile/components/data/table/table-row.transformer.js.map +1 -0
- package/src/transpile/components/data/table/table.transformer.js +77 -0
- package/src/transpile/components/data/table/table.transformer.js.map +1 -0
- package/src/transpile/components/data/table/utils.js +229 -0
- package/src/transpile/components/data/table/utils.js.map +1 -0
- package/src/transpile/components/dialogs/alert-dialog.transformer.js +8 -0
- package/src/transpile/components/dialogs/alert-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/confirm-dialog.transformer.js +8 -0
- package/src/transpile/components/dialogs/confirm-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/dialog-actions.transformer.js +56 -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-factory.js +18 -0
- package/src/transpile/components/dialogs/dialog-factory.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 +8 -0
- package/src/transpile/components/dialogs/iframe-dialog.transformer.js.map +1 -0
- package/src/transpile/components/dialogs/login-dialog.transformer.js +44 -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 +23 -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 +10 -0
- package/src/transpile/components/layout/footer.transformer.js.map +1 -0
- package/src/transpile/components/layout/header.transformer.js +10 -0
- package/src/transpile/components/layout/header.transformer.js.map +1 -0
- package/src/transpile/components/layout/layout-region-factory.js +46 -0
- package/src/transpile/components/layout/layout-region-factory.js.map +1 -0
- package/src/transpile/components/layout/leftnav.transformer.js +10 -0
- package/src/transpile/components/layout/leftnav.transformer.js.map +1 -0
- package/src/transpile/components/layout/rightnav.transformer.js +10 -0
- package/src/transpile/components/layout/rightnav.transformer.js.map +1 -0
- package/src/transpile/components/layout/topnav.transformer.js +10 -0
- package/src/transpile/components/layout/topnav.transformer.js.map +1 -0
- package/src/transpile/components/nav/nav-item.transformer.js +24 -0
- package/src/transpile/components/nav/nav-item.transformer.js.map +1 -0
- package/src/transpile/components/nav/nav.transformer.js +68 -0
- package/src/transpile/components/nav/nav.transformer.js.map +1 -0
- package/src/transpile/components/nav/navbar.transformer.js +120 -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 +23 -0
- package/src/transpile/components/navigation/popover.transformer.js.map +1 -0
- package/src/transpile/components/page/build-partial-markup.js +77 -0
- package/src/transpile/components/page/build-partial-markup.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 +16 -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/page/with-partial-container.js +26 -0
- package/src/transpile/components/page/with-partial-container.js.map +1 -0
- package/src/transpile/components/partial/partial-content.transformer.js +11 -0
- package/src/transpile/components/partial/partial-content.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 +91 -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 +367 -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/index.js +65 -0
- package/src/transpile/index.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 +278 -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/serialize-variables.js +322 -0
- package/src/transpile/serialize-variables.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/split-css-shorthand.js +60 -0
- package/src/transpile/style/split-css-shorthand.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/transform-markup.js +286 -0
- package/src/transpile/transform-markup.js.map +1 -0
- package/src/transpile/transpile-variables.js +35 -0
- package/src/transpile/transpile-variables.js.map +1 -0
- package/src/transpile/transpile.js +1349 -0
- package/src/transpile/transpile.js.map +1 -0
- package/src/transpile/transpiler.js +30 -0
- package/src/transpile/transpiler.js.map +1 -0
- package/src/transpile/variables-template-source.js +6 -0
- package/src/transpile/variables-template-source.js.map +1 -0
- package/src/transpile/variables-template.js +15 -0
- package/src/transpile/variables-template.js.map +1 -0
- package/src/transpile/widget-inline-style-constants.js +203 -0
- package/src/transpile/widget-inline-style-constants.js.map +1 -0
- package/src/transpile/widget-inline-style-processor.js +732 -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 +528 -0
- package/src/utils/grouping-util.js.map +1 -0
- package/src/utils.browser.js +903 -0
- package/src/utils.browser.js.map +1 -0
- package/src/utils.js +835 -0
- package/src/utils.js.map +1 -0
- package/src/variables/variable.transformer.js +736 -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 +80 -0
- package/templates/component/component.props.template +1 -0
- package/templates/component/formatter.hbs +8 -0
- package/templates/component/layout.hbs +33 -0
- package/templates/component/page.hbs +16 -0
- package/templates/component/partial.hbs +70 -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 +134 -0
- package/templates/project/app/client.layout.tsx +193 -0
- package/templates/project/app/components.css +292 -0
- package/templates/project/app/error.tsx +27 -0
- package/templates/project/app/globals.css +5 -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 +1031 -0
- package/templates/project/app/wm-globals.css +152 -0
- package/templates/project/app/wm-styles.css +4 -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 +41 -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 +255 -0
|
@@ -0,0 +1,1349 @@
|
|
|
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.HTMLElementClass = exports.isHTMLElement = exports.NodeType = exports.parse = exports.generateRandomString = void 0;
|
|
40
|
+
const lodash_1 = require("lodash");
|
|
41
|
+
const node_html_parser_1 = __importStar(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_browser_1 = require("../utils.browser");
|
|
47
|
+
const id_generator_1 = require("./id-generator");
|
|
48
|
+
const widget_inline_style_processor_1 = require("./widget-inline-style-processor");
|
|
49
|
+
const utils_1 = require("./components/data/table/utils");
|
|
50
|
+
const class_expression_util_1 = require("./class-expression.util");
|
|
51
|
+
const generateRandomString = (length = 10) => Math.random().toString(20).substr(2, length);
|
|
52
|
+
exports.generateRandomString = generateRandomString;
|
|
53
|
+
/**
|
|
54
|
+
* Variable categories that do NOT expose a loading state.
|
|
55
|
+
* ModelVariable (wm.Variable) holds static/client-side data.
|
|
56
|
+
* Action types fire one-shot effects and have no in-flight indicator.
|
|
57
|
+
*/
|
|
58
|
+
const CATEGORIES_WITHOUT_LOADING = new Set([
|
|
59
|
+
"wm.Variable",
|
|
60
|
+
"wm.NavigationAction",
|
|
61
|
+
"wm.TimerAction",
|
|
62
|
+
"wm.NotificationAction",
|
|
63
|
+
"wm.LoginAction",
|
|
64
|
+
"wm.LogoutAction",
|
|
65
|
+
]);
|
|
66
|
+
/**
|
|
67
|
+
* Scans an element's `bind:` attribute values (post-preTranspile) and returns
|
|
68
|
+
* the distinct variable names referenced via `fragment?.Variables?.varName`.
|
|
69
|
+
*/
|
|
70
|
+
function extractVariableNamesFromElement(e) {
|
|
71
|
+
const vars = new Set();
|
|
72
|
+
const pattern = /fragment\??\.Variables\??\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g;
|
|
73
|
+
Object.keys(e.attributes).forEach(attrName => {
|
|
74
|
+
const value = e.attributes[attrName];
|
|
75
|
+
if (!value)
|
|
76
|
+
return;
|
|
77
|
+
const matches = [...value.matchAll(pattern)];
|
|
78
|
+
matches.forEach(m => vars.add(m[1]));
|
|
79
|
+
});
|
|
80
|
+
return Array.from(vars);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Scans generated source (markup + split component bodies) for cross-context bindings on the
|
|
84
|
+
* active page — `fragment?.App?.activePage?.<...path>` — and returns the distinct dependency
|
|
85
|
+
* paths (normalized to dot-notation) the component reads, e.g.
|
|
86
|
+
* `Variables.PageDataInvoke1.dataSet.content` or `Widgets.button1.caption`.
|
|
87
|
+
*
|
|
88
|
+
* This is what powers cross-context reactivity: a partial/prefab can read another (the active)
|
|
89
|
+
* page's state (`Variables`, `Widgets`, anything), and the runtime needs to know, declaratively,
|
|
90
|
+
* which paths so it can value-gate re-renders to exactly those. Discovering them at codegen time
|
|
91
|
+
* avoids any runtime read-tracking proxy. The captured chain stops at the first non-identifier
|
|
92
|
+
* token (e.g. `(`, `[`), so method/bracket accessors are truncated harmlessly.
|
|
93
|
+
*
|
|
94
|
+
* Ancestor paths fully covered by a more specific descendant are dropped: e.g. a `datasource`
|
|
95
|
+
* binding to `Variables.PageDataInvoke1` and a `dataset` binding to
|
|
96
|
+
* `Variables.PageDataInvoke1.dataSet.content` collapse to just the latter. The ancestor resolves
|
|
97
|
+
* to a stable instance reference that never changes, so it adds no gating value.
|
|
98
|
+
*/
|
|
99
|
+
function extractActivePageDeps(source) {
|
|
100
|
+
const deps = new Set();
|
|
101
|
+
const pattern = /fragment(?:\?\.|\.)App(?:\?\.|\.)activePage((?:(?:\?\.|\.)[a-zA-Z0-9_$]+)+)/g;
|
|
102
|
+
for (const m of source.matchAll(pattern)) {
|
|
103
|
+
const path = m[1].replace(/\?\./g, ".").replace(/^\./, "");
|
|
104
|
+
if (path) {
|
|
105
|
+
deps.add(path);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const all = Array.from(deps);
|
|
109
|
+
return all.filter(path => !all.some(other => other !== path && other.startsWith(`${path}.`)));
|
|
110
|
+
}
|
|
111
|
+
const EVENT_NAME_MAP = {
|
|
112
|
+
"on-dblclick": "on-doubleClick",
|
|
113
|
+
"on-mouseenter": "on-mouseEnter",
|
|
114
|
+
"on-mouseleave": "on-mouseLeave",
|
|
115
|
+
"on-mouseover": "on-mouseOver",
|
|
116
|
+
"on-mouseout": "on-mouseOut",
|
|
117
|
+
"on-beforesubmit": "on-BeforeSubmit",
|
|
118
|
+
"on-dragstart": "on-dragStart",
|
|
119
|
+
"on-dragend": "on-dragEnd",
|
|
120
|
+
"on-dragover": "on-dragOver",
|
|
121
|
+
"on-dragenter": "on-dragEnter",
|
|
122
|
+
"on-dragleave": "on-dragLeave",
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Processes text content for JSX compatibility
|
|
126
|
+
* If content is only special characters (like > or <), wraps them in React expressions
|
|
127
|
+
* @param textContent The raw text content from the node
|
|
128
|
+
* @returns Processed text content safe for JSX, or empty string if no valid content
|
|
129
|
+
*/
|
|
130
|
+
const processTextContentForJSX = (textContent) => {
|
|
131
|
+
const trimmedContent = textContent.trim();
|
|
132
|
+
if (!trimmedContent) {
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
// If content is only special characters (like > or <), wrap in React expression
|
|
136
|
+
if (/^[<>&]+$/.test(trimmedContent)) {
|
|
137
|
+
// Convert each special character to React expression
|
|
138
|
+
return trimmedContent
|
|
139
|
+
.split("")
|
|
140
|
+
.map(char => `{'${char}'}`)
|
|
141
|
+
.join("");
|
|
142
|
+
}
|
|
143
|
+
return textContent;
|
|
144
|
+
};
|
|
145
|
+
exports.processTextContentForJSX = processTextContentForJSX;
|
|
146
|
+
// node-html-parser ESM wrapper bug: when bundlers use default interop, named exports (parse, NodeType, HTMLElement) are undefined
|
|
147
|
+
exports.parse = typeof node_html_parser_1.default === "function"
|
|
148
|
+
? node_html_parser_1.default
|
|
149
|
+
: node_html_parser_1.default.parse;
|
|
150
|
+
// Use standard DOM node type constants (1, 3) - NodeType named export breaks under Turbopack/Next bundling
|
|
151
|
+
exports.NodeType = {
|
|
152
|
+
ELEMENT_NODE: 1,
|
|
153
|
+
TEXT_NODE: 3,
|
|
154
|
+
};
|
|
155
|
+
/** Prefer over `instanceof HTMLElement` when the constructor may not match (e.g. bundlers). */
|
|
156
|
+
const isHTMLElement = (node) => node != null && node.nodeType === exports.NodeType.ELEMENT_NODE;
|
|
157
|
+
exports.isHTMLElement = isHTMLElement;
|
|
158
|
+
// HTMLElement constructor - fallback for when named export is undefined (Turbopack/Next bundling)
|
|
159
|
+
function getHTMLElementClass() {
|
|
160
|
+
var _a, _b, _c;
|
|
161
|
+
const fromModule = (_a = node_html_parser_1.default.HTMLElement) !== null && _a !== void 0 ? _a : node_html_parser_1.HTMLElement;
|
|
162
|
+
if (fromModule)
|
|
163
|
+
return fromModule;
|
|
164
|
+
// Fallback: get from parsed node (parse creates HTMLElement instances)
|
|
165
|
+
const parsed = (0, exports.parse)("<div></div>");
|
|
166
|
+
const firstEl = (_b = parsed.childNodes) === null || _b === void 0 ? void 0 : _b.find((c) => (c === null || c === void 0 ? void 0 : c.nodeType) === 1);
|
|
167
|
+
return ((_c = firstEl === null || firstEl === void 0 ? void 0 : firstEl.constructor) !== null && _c !== void 0 ? _c : (() => {
|
|
168
|
+
throw new Error("node-html-parser HTMLElement not available");
|
|
169
|
+
})());
|
|
170
|
+
}
|
|
171
|
+
exports.HTMLElementClass = getHTMLElementClass();
|
|
172
|
+
// Input widgets that should inherit required/floating-label behavior from wm-composite
|
|
173
|
+
const COMPOSITE_INPUT_TAGS = new Set([
|
|
174
|
+
"wm-text",
|
|
175
|
+
"wm-number",
|
|
176
|
+
"wm-currency",
|
|
177
|
+
"wm-date",
|
|
178
|
+
"wm-time",
|
|
179
|
+
"wm-datetime",
|
|
180
|
+
"wm-textarea",
|
|
181
|
+
"wm-select",
|
|
182
|
+
"wm-radioset",
|
|
183
|
+
"wm-checkbox",
|
|
184
|
+
"wm-checkboxset",
|
|
185
|
+
"wm-switch",
|
|
186
|
+
"wm-slider",
|
|
187
|
+
"wm-fileupload",
|
|
188
|
+
"wm-rating",
|
|
189
|
+
"wm-colorpicker",
|
|
190
|
+
"wm-search",
|
|
191
|
+
]);
|
|
192
|
+
/**
|
|
193
|
+
* Adds optional chaining to fragment expressions and fallback values
|
|
194
|
+
* Converts fragment.Variables.wsGetActiveTheme.dataSet.content[0].themeId
|
|
195
|
+
* to (fragment?.Variables?.wsGetActiveTheme?.dataSet?.content?.[0]?.themeId || "")
|
|
196
|
+
*
|
|
197
|
+
* Note: Does not add fallback for expressions containing function calls to preserve syntax
|
|
198
|
+
*/
|
|
199
|
+
const addFragmentOptionalChaining = (expression, addFallback = false) => {
|
|
200
|
+
const chainingObj = {
|
|
201
|
+
targetPattern: /fragment(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*|\[[^\]]+\])*/g,
|
|
202
|
+
addFallback: addFallback,
|
|
203
|
+
detectFunctionCalls: true,
|
|
204
|
+
...(addFallback && { fallbackValue: '""' }),
|
|
205
|
+
};
|
|
206
|
+
return (0, utils_browser_1.addOptionalChaining)(expression);
|
|
207
|
+
};
|
|
208
|
+
exports.addFragmentOptionalChaining = addFragmentOptionalChaining;
|
|
209
|
+
class TranspilationContext {
|
|
210
|
+
constructor(args) {
|
|
211
|
+
this.result = args.result;
|
|
212
|
+
this.transformer = args.transformer;
|
|
213
|
+
this.isPartOfPrefab = args.isPartOfPrefab;
|
|
214
|
+
this.listener = args.listener;
|
|
215
|
+
this.props = args.props;
|
|
216
|
+
this.data = (0, lodash_1.assign)({}, args.data);
|
|
217
|
+
}
|
|
218
|
+
get(key) {
|
|
219
|
+
return this.data && this.data[key];
|
|
220
|
+
}
|
|
221
|
+
set(key, value) {
|
|
222
|
+
this.data[key] = value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.TranspilationContext = TranspilationContext;
|
|
226
|
+
class Transpiler {
|
|
227
|
+
constructor() {
|
|
228
|
+
this.transformers = new Map();
|
|
229
|
+
this.componentNamesList = [];
|
|
230
|
+
this.transpile = (e, isPartOfPrefab, splitCode = true, oldContext) => {
|
|
231
|
+
var _a;
|
|
232
|
+
const isHtmlElement = utils_browser_1.htmlElements.includes(e.tagName.toLowerCase());
|
|
233
|
+
const ignoreElements = ["wm-filter-action", "wm-form-action"];
|
|
234
|
+
const transformer = this.transformers.get(e && e.tagName.toLowerCase());
|
|
235
|
+
let result = {
|
|
236
|
+
markup: "",
|
|
237
|
+
components: {},
|
|
238
|
+
attrs: {},
|
|
239
|
+
imports: [],
|
|
240
|
+
partials: [],
|
|
241
|
+
prefabs: [],
|
|
242
|
+
wmxcomponents: [],
|
|
243
|
+
};
|
|
244
|
+
// Skip name auto-generation for elements inside table column or explicitly ignored elements
|
|
245
|
+
if (!e.getAttribute("name") &&
|
|
246
|
+
!ignoreElements.includes(e.tagName.toLowerCase()) &&
|
|
247
|
+
!((_a = oldContext === null || oldContext === void 0 ? void 0 : oldContext.data) === null || _a === void 0 ? void 0 : _a.isInsideTableColumn)) {
|
|
248
|
+
e.setAttribute("name", `${e.tagName.toLowerCase().replace(/-/g, "_")}_${(0, exports.generateRandomString)()}`);
|
|
249
|
+
}
|
|
250
|
+
// for every new page, initially context is empty. Hence clearing the prev page componentNamesList array.
|
|
251
|
+
if (!oldContext) {
|
|
252
|
+
this.componentNamesList = [];
|
|
253
|
+
}
|
|
254
|
+
if (isHtmlElement) {
|
|
255
|
+
result.markup = preTranspileHtmlElement(e);
|
|
256
|
+
e.childNodes.forEach(c => {
|
|
257
|
+
if (c && c.nodeType == exports.NodeType.ELEMENT_NODE) {
|
|
258
|
+
const cResult = this.transpile(c, isPartOfPrefab, splitCode);
|
|
259
|
+
(0, lodash_1.assignIn)(result.components, cResult.components);
|
|
260
|
+
result.markup += cResult.markup;
|
|
261
|
+
result.imports.push(...cResult.imports);
|
|
262
|
+
result.prefabs.push(...cResult.prefabs);
|
|
263
|
+
result.partials.push(...cResult.partials);
|
|
264
|
+
result.components = { ...result.components, ...cResult.components };
|
|
265
|
+
if (cResult.pageEvents)
|
|
266
|
+
result.pageEvents = cResult.pageEvents;
|
|
267
|
+
}
|
|
268
|
+
else if (c && c.nodeType == exports.NodeType.TEXT_NODE) {
|
|
269
|
+
// Preserve text nodes
|
|
270
|
+
const processedContent = processTextContentForJSX(c.text);
|
|
271
|
+
if (processedContent) {
|
|
272
|
+
result.markup += processedContent;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
result.markup += postTranspileHtmlElement(e);
|
|
277
|
+
}
|
|
278
|
+
else if (transformer != null) {
|
|
279
|
+
const context = new TranspilationContext({
|
|
280
|
+
result: result,
|
|
281
|
+
isPartOfPrefab: isPartOfPrefab,
|
|
282
|
+
transformer: transformer,
|
|
283
|
+
listener: oldContext === null || oldContext === void 0 ? void 0 : oldContext.listener,
|
|
284
|
+
props: (oldContext === null || oldContext === void 0 ? void 0 : oldContext.props) || [],
|
|
285
|
+
data: oldContext === null || oldContext === void 0 ? void 0 : oldContext.data,
|
|
286
|
+
});
|
|
287
|
+
result.imports.push(...transformer.imports(e, context));
|
|
288
|
+
result.markup +=
|
|
289
|
+
transformer.pre(e, context).replace(new RegExp(bind_ex_transformer_1.FORMAT_CONTEXT, "g"), "") +
|
|
290
|
+
(e.childNodes.length > 0 ? "\n" : "");
|
|
291
|
+
e.childNodes.forEach(c => {
|
|
292
|
+
if (c && c.nodeType == exports.NodeType.ELEMENT_NODE) {
|
|
293
|
+
const cResult = this.transpile(c, isPartOfPrefab, splitCode, context);
|
|
294
|
+
(0, lodash_1.assignIn)(result.components, cResult.components);
|
|
295
|
+
result.markup += cResult.markup;
|
|
296
|
+
result.imports.push(...cResult.imports);
|
|
297
|
+
result.prefabs.push(...cResult.prefabs);
|
|
298
|
+
result.wmxcomponents.push(...cResult.wmxcomponents);
|
|
299
|
+
result.partials.push(...cResult.partials);
|
|
300
|
+
result.components = { ...result.components, ...cResult.components };
|
|
301
|
+
if (cResult.pageEvents)
|
|
302
|
+
result.pageEvents = cResult.pageEvents;
|
|
303
|
+
}
|
|
304
|
+
else if (c && c.nodeType == exports.NodeType.TEXT_NODE) {
|
|
305
|
+
// Handle text nodes for custom elements
|
|
306
|
+
const processedContent = processTextContentForJSX(c.text);
|
|
307
|
+
if (processedContent) {
|
|
308
|
+
result.markup += processedContent;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
transformer.partials && result.partials.push(...transformer.partials(e, context));
|
|
313
|
+
transformer.prefabs && result.prefabs.push(...transformer.prefabs(e, context));
|
|
314
|
+
transformer.wmxcomponents &&
|
|
315
|
+
result.wmxcomponents.push(...transformer.wmxcomponents(e, context));
|
|
316
|
+
result.markup += transformer.post(e, context).replace(new RegExp(bind_ex_transformer_1.FORMAT_CONTEXT, "g"), "");
|
|
317
|
+
// splitCode && transformer.createComponent && transformer.createComponent(e, context);
|
|
318
|
+
const accessRole = e.attrs["accessroles"];
|
|
319
|
+
if (accessRole) {
|
|
320
|
+
result.markup = `{fragment.appConfig.SecurityService.hasAccessToWidget('${accessRole}') ? (${result.markup}): null}`;
|
|
321
|
+
}
|
|
322
|
+
result.markup = (0, fomatter_1.prependSpace)(result.markup, 2) + "\n";
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Transforms $[...] syntax to fragment.property for use with Angular parser
|
|
329
|
+
* Examples:
|
|
330
|
+
* $[location] -> fragment.location
|
|
331
|
+
* $[data[$i].locationDesc] -> fragment.locationDesc (removes data[$i]. prefix)
|
|
332
|
+
*/
|
|
333
|
+
transformDollarBracketForFragmentContext(expression) {
|
|
334
|
+
// First, remove data[$i]. prefixes from within $[...] brackets
|
|
335
|
+
expression = expression.replace(/\$\[data\[\$i\]\./g, "$[");
|
|
336
|
+
// Transform $[property.path] to fragment.property.path
|
|
337
|
+
expression = expression.replace(/\$\[([^\]]+)\]/g, (match, property) => {
|
|
338
|
+
// Remove any remaining data[index]. patterns
|
|
339
|
+
property = property.replace(/data\[\d+\]\./g, "");
|
|
340
|
+
return `${property}`;
|
|
341
|
+
});
|
|
342
|
+
return expression;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Checks if a parent element has a dataset that matches the base path of the current dataset.
|
|
346
|
+
* This is used to determine if [$i] should be handled by parent's $item transformation.
|
|
347
|
+
* Example: child has "Variables.list.dataSet[$i].Features", parent has "Variables.list.dataSet"
|
|
348
|
+
*/
|
|
349
|
+
hasParentWithMatchingDataset(element, basePath) {
|
|
350
|
+
var _a;
|
|
351
|
+
let parent = element.parentNode;
|
|
352
|
+
while (parent) {
|
|
353
|
+
const parentDataset = (_a = parent.getAttribute) === null || _a === void 0 ? void 0 : _a.call(parent, "dataset");
|
|
354
|
+
if (parentDataset) {
|
|
355
|
+
// Remove bind: prefix if present
|
|
356
|
+
const parentDatasetValue = parentDataset.startsWith("bind:")
|
|
357
|
+
? parentDataset.substring(5)
|
|
358
|
+
: parentDataset;
|
|
359
|
+
// Check if parent dataset matches the base path (the array being iterated)
|
|
360
|
+
if (parentDatasetValue === basePath || parentDatasetValue === `fragment.${basePath}`) {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
parent = parent.parentNode;
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Transforms dataset expressions containing [$i] into a map function.
|
|
370
|
+
* Handles two cases:
|
|
371
|
+
* 1. Expression case: path[$i] inside a broader expression (e.g. function calls, pipes)
|
|
372
|
+
* Example: (calculateLoanMetric(Variables.CustomerLoansData.dataSet[$i], 'percentagePaid')) | suffix: '%'
|
|
373
|
+
* 2. Simple path case: path-like structure with optional nested [$i]
|
|
374
|
+
* Example: Variables.A[$i].children[$i].name
|
|
375
|
+
*/
|
|
376
|
+
transformDatasetWithIndex(value) {
|
|
377
|
+
// Check if there are any [$i] patterns
|
|
378
|
+
if (!value.includes("[$i]")) {
|
|
379
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
380
|
+
}
|
|
381
|
+
const segments = value.split("[$i]");
|
|
382
|
+
if (segments.length < 2) {
|
|
383
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
384
|
+
}
|
|
385
|
+
// Detect expression case: second segment contains expression syntax (parens, pipes, commas)
|
|
386
|
+
// e.g. ", 'percentagePaid')) | suffix: '%'" vs simple path ".children.name"
|
|
387
|
+
const secondSegment = segments[1].trim();
|
|
388
|
+
const isSimplePathSegment = /^\.?[a-zA-Z0-9_.]*$/.test(secondSegment);
|
|
389
|
+
if (!isSimplePathSegment) {
|
|
390
|
+
// Expression case: replace path[$i] with item, transform inner expr, wrap in map
|
|
391
|
+
const pathIndexMatch = value.match(/([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\[\$i\]/);
|
|
392
|
+
if (!pathIndexMatch) {
|
|
393
|
+
return "bind:" + (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
394
|
+
}
|
|
395
|
+
const basePath = pathIndexMatch[1];
|
|
396
|
+
const pathWithIndex = `${basePath}[$i]`;
|
|
397
|
+
const innerExpression = value.replace(pathWithIndex, "item");
|
|
398
|
+
value = this.transformDollarBracketForFragmentContext(innerExpression);
|
|
399
|
+
let transformedInner = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
400
|
+
// transformEx treats bare 'item' as fragment.item; fix for map callback param
|
|
401
|
+
transformedInner = transformedInner
|
|
402
|
+
.replace(/fragment\?\.item\b/g, "item")
|
|
403
|
+
.replace(/fragment\.item\b/g, "item");
|
|
404
|
+
const transformedBase = (0, utils_browser_1.addOptionalChaining)(`fragment.${basePath}`);
|
|
405
|
+
const mapExpression = `${transformedBase}?.map((item) => ${transformedInner})`;
|
|
406
|
+
return `mapfn:() => ${mapExpression}`;
|
|
407
|
+
}
|
|
408
|
+
// Simple path case: use nested map logic
|
|
409
|
+
const basePath = segments[0];
|
|
410
|
+
const transformedBase = (0, utils_browser_1.addOptionalChaining)(`fragment.${basePath}`);
|
|
411
|
+
const buildNestedMap = (segmentIndex, itemVar) => {
|
|
412
|
+
const segment = segments[segmentIndex];
|
|
413
|
+
let cleanSegment = segment.startsWith(".") ? segment.substring(1) : segment;
|
|
414
|
+
cleanSegment = cleanSegment.trim();
|
|
415
|
+
const isLastSegment = segmentIndex === segments.length - 1;
|
|
416
|
+
if (isLastSegment) {
|
|
417
|
+
if (cleanSegment) {
|
|
418
|
+
return (0, utils_browser_1.addOptionalChaining)(`${itemVar}.${cleanSegment}`);
|
|
419
|
+
}
|
|
420
|
+
return itemVar;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
const nextItemVar = segmentIndex === 1 ? "child" : `item${segmentIndex}`;
|
|
424
|
+
const nextExpression = buildNestedMap(segmentIndex + 1, nextItemVar);
|
|
425
|
+
if (cleanSegment) {
|
|
426
|
+
const propertyAccess = (0, utils_browser_1.addOptionalChaining)(`${itemVar}.${cleanSegment}`);
|
|
427
|
+
return `${propertyAccess}?.map(${nextItemVar} => ${nextExpression})`;
|
|
428
|
+
}
|
|
429
|
+
return `${itemVar}?.map(${nextItemVar} => ${nextExpression})`;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const mapExpression = `${transformedBase}?.map(item => ${buildNestedMap(1, "item")}) || []`;
|
|
433
|
+
return `mapfn:() => ${mapExpression}`;
|
|
434
|
+
}
|
|
435
|
+
preTranspile(e) {
|
|
436
|
+
// remove variant attribute from element
|
|
437
|
+
// because it's not required in JSX
|
|
438
|
+
e === null || e === void 0 ? void 0 : e.removeAttribute("variant");
|
|
439
|
+
// Rename lowercase skeleton attributes to their camelCase forms so that
|
|
440
|
+
// property-parser.ts resolves them correctly as numeric/boolean props.
|
|
441
|
+
Object.keys(e.attributes).forEach(name => {
|
|
442
|
+
const camelName = Transpiler.SKELETON_ATTR_RENAME[name];
|
|
443
|
+
if (camelName) {
|
|
444
|
+
const val = e.attributes[name];
|
|
445
|
+
e.removeAttribute(name);
|
|
446
|
+
e.setAttribute(camelName, val);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
Object.keys(e.attributes).forEach(name => {
|
|
450
|
+
let value = e.attributes[name];
|
|
451
|
+
if (value.startsWith("bind:")) {
|
|
452
|
+
value = value.substring(5).trim();
|
|
453
|
+
// Remove trailing semicolons (common in WaveMaker expressions but invalid in JSX)
|
|
454
|
+
value = value.replace(/;+$/, "");
|
|
455
|
+
// Check if this is a simple single $[...] expression that can be simplified
|
|
456
|
+
const simpleSinglePattern = /^\$\[([^\]]+)\]$/;
|
|
457
|
+
const match = value.match(simpleSinglePattern);
|
|
458
|
+
if (match) {
|
|
459
|
+
// Extract property path and remove data[$i]. prefix if present
|
|
460
|
+
let propertyPath = match[1];
|
|
461
|
+
propertyPath = propertyPath.replace(/^data\[\$i\]\./, "");
|
|
462
|
+
propertyPath = propertyPath.replace(/^data\[\d+\]\./, "");
|
|
463
|
+
e.setAttribute(name, propertyPath);
|
|
464
|
+
}
|
|
465
|
+
else if (name === "dataset" && value.includes("[$i]")) {
|
|
466
|
+
// Check if this [$i] should be handled by a parent's $item transformation
|
|
467
|
+
// Extract base path (everything before [$i])
|
|
468
|
+
const basePathMatch = value.match(/^(.+?)\[\$i\]/);
|
|
469
|
+
const basePath = basePathMatch ? basePathMatch[1] : null;
|
|
470
|
+
if (basePath && this.hasParentWithMatchingDataset(e, basePath)) {
|
|
471
|
+
// Parent has matching dataset - let transformRepeatChildData handle [$i] → $item
|
|
472
|
+
// Transform $[...] syntax before passing to Angular parser
|
|
473
|
+
value = this.transformDollarBracketForFragmentContext(value);
|
|
474
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
475
|
+
e.setAttribute(name, "bind:" + transformedValue);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
// No parent with matching dataset - generate map function
|
|
479
|
+
const datasetMapResult = this.transformDatasetWithIndex(value);
|
|
480
|
+
e.setAttribute(name, datasetMapResult);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
// Transform $[...] syntax before passing to Angular parser
|
|
485
|
+
value = this.transformDollarBracketForFragmentContext(value);
|
|
486
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "attr");
|
|
487
|
+
// Apply optional chaining with fallback only for backgroundimage
|
|
488
|
+
if (name === "backgroundimage") {
|
|
489
|
+
transformedValue = addFragmentOptionalChaining(transformedValue, true);
|
|
490
|
+
}
|
|
491
|
+
e.setAttribute(name, "bind:" + transformedValue);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
else if (name === "groupby" && value.includes("(")) {
|
|
495
|
+
e.setAttribute(name, (0, bind_ex_transformer_1.default)(value, "fragment", "event"));
|
|
496
|
+
}
|
|
497
|
+
else if (name.startsWith("on-")) {
|
|
498
|
+
//on-tap to onclick conversion
|
|
499
|
+
if (name === "on-tap") {
|
|
500
|
+
if (e.getAttribute("on-click")) {
|
|
501
|
+
e.removeAttribute("on-tap");
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const tapValue = value;
|
|
505
|
+
e.removeAttribute("on-tap");
|
|
506
|
+
name = "on-click";
|
|
507
|
+
value = tapValue;
|
|
508
|
+
}
|
|
509
|
+
const mappedName = EVENT_NAME_MAP[name];
|
|
510
|
+
if (mappedName) {
|
|
511
|
+
e.removeAttribute(name);
|
|
512
|
+
name = mappedName;
|
|
513
|
+
}
|
|
514
|
+
let transformedValue = (0, bind_ex_transformer_1.default)(value, "fragment", "event");
|
|
515
|
+
// Apply optional chaining for event handlers
|
|
516
|
+
transformedValue = addFragmentOptionalChaining(transformedValue, false);
|
|
517
|
+
e.setAttribute(name, transformedValue + ";");
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
e.childNodes.forEach(c => {
|
|
521
|
+
if ((0, exports.isHTMLElement)(c)) {
|
|
522
|
+
this.preTranspile(c);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
transformStyles(e, context) {
|
|
527
|
+
var _a, _b;
|
|
528
|
+
// WaveMaker source markup may carry a `styles` attr with raw CSS (e.g. "cursor:pointer;").
|
|
529
|
+
// Parse it into a JS style object and remove the raw attr so it doesn't leak into output.
|
|
530
|
+
let rawStylesObj = {};
|
|
531
|
+
const style_attr = e.getAttribute("style");
|
|
532
|
+
const rawStyles = e.getAttribute("styles") || style_attr;
|
|
533
|
+
if (rawStyles && !rawStyles.startsWith("bind:") && !rawStyles.startsWith("{")) {
|
|
534
|
+
rawStyles.split(";").forEach(rule => {
|
|
535
|
+
const colonIdx = rule.indexOf(":");
|
|
536
|
+
if (colonIdx > 0) {
|
|
537
|
+
const prop = rule.substring(0, colonIdx).trim();
|
|
538
|
+
const val = rule.substring(colonIdx + 1).trim();
|
|
539
|
+
if (prop && val) {
|
|
540
|
+
const camelProp = prop.replace(/-([a-z])/g, (_, l) => l.toUpperCase());
|
|
541
|
+
rawStylesObj[camelProp] = val;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
e.removeAttribute("styles");
|
|
546
|
+
if (style_attr) {
|
|
547
|
+
e.removeAttribute("style");
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const hasConditionalStyles = e.getAttribute("conditionalstyle");
|
|
551
|
+
if (hasConditionalStyles) {
|
|
552
|
+
// add optional chaining to the conditional styles
|
|
553
|
+
e.setAttribute("conditionalstyle", addFragmentOptionalChaining(hasConditionalStyles, true));
|
|
554
|
+
}
|
|
555
|
+
const styleObj = (0, style_transformer_1.default)(e, (propName) => {
|
|
556
|
+
const transformer = context.transformer;
|
|
557
|
+
if (transformer && transformer.isStyleProperty) {
|
|
558
|
+
return transformer.isStyleProperty(propName, e, context);
|
|
559
|
+
}
|
|
560
|
+
return true;
|
|
561
|
+
}) || {};
|
|
562
|
+
// Merge raw CSS properties from `styles` attr into the style object
|
|
563
|
+
if (Object.keys(rawStylesObj).length > 0) {
|
|
564
|
+
(0, lodash_1.merge)(styleObj, rawStylesObj);
|
|
565
|
+
}
|
|
566
|
+
let classes = e.getAttribute("class") || "";
|
|
567
|
+
let isStatic = true;
|
|
568
|
+
let styles = styleObj;
|
|
569
|
+
let style = {};
|
|
570
|
+
const styleAttr = e.getAttribute("style");
|
|
571
|
+
if (styleAttr) {
|
|
572
|
+
style =
|
|
573
|
+
(0, style_transformer_1.default)(e, (propName) => {
|
|
574
|
+
const transformer = context.transformer;
|
|
575
|
+
if (transformer && transformer.isStyleProperty) {
|
|
576
|
+
return transformer.isStyleProperty(propName, e, context);
|
|
577
|
+
}
|
|
578
|
+
return true;
|
|
579
|
+
}) || {};
|
|
580
|
+
styles = (0, lodash_1.merge)(style, styleObj);
|
|
581
|
+
}
|
|
582
|
+
if (styles) {
|
|
583
|
+
Object.keys(styleObj).forEach(i => {
|
|
584
|
+
const styleProp = styleObj[i];
|
|
585
|
+
if ((0, lodash_1.isString)(styleProp) && styleProp.startsWith("bind:")) {
|
|
586
|
+
isStatic = false;
|
|
587
|
+
const bindExpr = styleProp.substring(5);
|
|
588
|
+
styleObj[i] = `{___${(0, utils_browser_1.addOptionalChaining)(bindExpr)}___}`;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
if (styles.background) {
|
|
592
|
+
styles.root = styles.root || {};
|
|
593
|
+
styles.root._background = styles.background;
|
|
594
|
+
delete styles.background;
|
|
595
|
+
}
|
|
596
|
+
styles = JSON.stringify(styleObj).replace(/\\"/g, '"');
|
|
597
|
+
if (!isStatic) {
|
|
598
|
+
styles = styles.replace(/"\{___/g, "");
|
|
599
|
+
styles = styles.replace(/___\}"/g, "");
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
let conditionalClasses = e.getAttribute("conditionalclass") || e.getAttribute("ngclass");
|
|
603
|
+
if (classes.startsWith("bind:")) {
|
|
604
|
+
if ((_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context, "isInsideTableColumn")) {
|
|
605
|
+
let exp = classes.substring(5).replace("fragment.Page", "fragment");
|
|
606
|
+
exp = (0, utils_1.transformTableColumnClassExpression)(exp);
|
|
607
|
+
classes = `{${exp}}`;
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
classes = `{${classes.substring(5)}}`;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (conditionalClasses) {
|
|
614
|
+
conditionalClasses = conditionalClasses.startsWith("bind:")
|
|
615
|
+
? `${conditionalClasses.substring(5)}`
|
|
616
|
+
: conditionalClasses;
|
|
617
|
+
if (conditionalClasses.startsWith("{") && conditionalClasses.endsWith("}")) {
|
|
618
|
+
conditionalClasses = conditionalClasses.slice(1, -1);
|
|
619
|
+
let expressions = conditionalClasses.split(",").map(expression => {
|
|
620
|
+
const [className, condition] = expression.split(":");
|
|
621
|
+
// If no condition is provided (no colon), wrap the class in quotes
|
|
622
|
+
if (!condition) {
|
|
623
|
+
return `'${className.trim()}'`;
|
|
624
|
+
}
|
|
625
|
+
return `(${(0, utils_browser_1.addOptionalChaining)(condition.trim())} ? ${className.replace(/'$/, " '")} : '')`;
|
|
626
|
+
});
|
|
627
|
+
conditionalClasses = expressions.join("+");
|
|
628
|
+
}
|
|
629
|
+
else if (!conditionalClasses.includes(":") &&
|
|
630
|
+
!conditionalClasses.includes("&&") &&
|
|
631
|
+
!conditionalClasses.includes("||") &&
|
|
632
|
+
!conditionalClasses.includes("$formField")) {
|
|
633
|
+
conditionalClasses = `${conditionalClasses}`;
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
conditionalClasses = (0, utils_browser_1.addOptionalChaining)(conditionalClasses);
|
|
637
|
+
}
|
|
638
|
+
if (classes === null || classes === void 0 ? void 0 : classes.startsWith("{")) {
|
|
639
|
+
classes = classes.substring(0, classes.length - 1);
|
|
640
|
+
classes = `${classes} + ' ' + ${conditionalClasses}}`;
|
|
641
|
+
}
|
|
642
|
+
else if (classes) {
|
|
643
|
+
classes = `{'${classes} ' + ${conditionalClasses}}`;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
classes = `{${conditionalClasses}}`;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
else if (classes.includes("{{") && classes.includes("}}")) {
|
|
650
|
+
const mustacheClass = (0, class_expression_util_1.transformClassWithMustacheExpressions)(classes, {
|
|
651
|
+
isInsideTableColumn: !!((_b = context === null || context === void 0 ? void 0 : context.get) === null || _b === void 0 ? void 0 : _b.call(context, "isInsideTableColumn")),
|
|
652
|
+
});
|
|
653
|
+
classes = mustacheClass !== null && mustacheClass !== void 0 ? mustacheClass : `'${classes}'`;
|
|
654
|
+
}
|
|
655
|
+
else if (!!classes && !classes.startsWith("{")) {
|
|
656
|
+
classes = `'${classes}'`;
|
|
657
|
+
}
|
|
658
|
+
e.removeAttribute("conditionalclass");
|
|
659
|
+
e.removeAttribute("ngclass");
|
|
660
|
+
e.removeAttribute("class");
|
|
661
|
+
e.removeAttribute("style");
|
|
662
|
+
return {
|
|
663
|
+
styles: styles,
|
|
664
|
+
className: (0, utils_browser_1.addOptionalChaining)(classes),
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
// Parse arguments properly, handling commas inside object literals and arrays
|
|
668
|
+
parseArguments(argString) {
|
|
669
|
+
const args = [];
|
|
670
|
+
let currentArg = "";
|
|
671
|
+
let braceCount = 0;
|
|
672
|
+
let bracketCount = 0;
|
|
673
|
+
for (let i = 0; i < argString.length; i++) {
|
|
674
|
+
const char = argString[i];
|
|
675
|
+
// Track object literals (curly braces) and arrays (square brackets)
|
|
676
|
+
if (char === "{")
|
|
677
|
+
braceCount++;
|
|
678
|
+
else if (char === "}")
|
|
679
|
+
braceCount--;
|
|
680
|
+
else if (char === "[")
|
|
681
|
+
bracketCount++;
|
|
682
|
+
else if (char === "]")
|
|
683
|
+
bracketCount--;
|
|
684
|
+
// If we encounter a comma at the top level (not inside an object or array), it's an argument separator
|
|
685
|
+
if (char === "," && braceCount === 0 && bracketCount === 0) {
|
|
686
|
+
if (currentArg.trim()) {
|
|
687
|
+
args.push(currentArg.trim());
|
|
688
|
+
}
|
|
689
|
+
currentArg = "";
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
currentArg += char;
|
|
693
|
+
}
|
|
694
|
+
if (currentArg.trim()) {
|
|
695
|
+
args.push(currentArg.trim());
|
|
696
|
+
}
|
|
697
|
+
return args;
|
|
698
|
+
}
|
|
699
|
+
// Droping literal arguments like strings, numbers, booleans, null/undefined
|
|
700
|
+
isLiteral(s) {
|
|
701
|
+
const v = s.trim();
|
|
702
|
+
return (/^(['"]).*\1$/.test(v) ||
|
|
703
|
+
/^-?\d+(?:\.\d+)?$/.test(v) ||
|
|
704
|
+
/^(true|false|null|undefined)$/i.test(v));
|
|
705
|
+
}
|
|
706
|
+
// Arithmetic/binary expressions (e.g. "0-5", "0+3") are not valid parameter names.
|
|
707
|
+
// The Angular parser converts unary negatives like -5 into binary (0-5).
|
|
708
|
+
isArithmeticExpression(s) {
|
|
709
|
+
const v = s.trim();
|
|
710
|
+
return /^\d+\s*[-+*/%]\s*\d+/.test(v);
|
|
711
|
+
}
|
|
712
|
+
// Check if argument contains a dot (property access), which makes it an expression, not a valid parameter name
|
|
713
|
+
isPropertyAccess(s) {
|
|
714
|
+
return s.trim().includes(".");
|
|
715
|
+
}
|
|
716
|
+
// Object literals should not be extracted as function parameters
|
|
717
|
+
isObjectLiteral(s) {
|
|
718
|
+
const trimmed = s.trim();
|
|
719
|
+
if (trimmed.startsWith("{") && trimmed.includes(":")) {
|
|
720
|
+
let braceCount = 0;
|
|
721
|
+
let inString = false;
|
|
722
|
+
let stringChar = "";
|
|
723
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
724
|
+
const char = trimmed[i];
|
|
725
|
+
if ((char === '"' || char === "'") && (i === 0 || trimmed[i - 1] !== "\\")) {
|
|
726
|
+
if (!inString) {
|
|
727
|
+
inString = true;
|
|
728
|
+
stringChar = char;
|
|
729
|
+
}
|
|
730
|
+
else if (char === stringChar) {
|
|
731
|
+
inString = false;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
else if (!inString) {
|
|
735
|
+
if (char === "{")
|
|
736
|
+
braceCount++;
|
|
737
|
+
else if (char === "}")
|
|
738
|
+
braceCount--;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return braceCount === 0 && trimmed.endsWith("}");
|
|
742
|
+
}
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
// Array literals should not be extracted as function parameters
|
|
746
|
+
isArrayLiteral(s) {
|
|
747
|
+
const trimmed = s.trim();
|
|
748
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
749
|
+
let bracketCount = 0;
|
|
750
|
+
let inString = false;
|
|
751
|
+
let stringChar = "";
|
|
752
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
753
|
+
const char = trimmed[i];
|
|
754
|
+
if ((char === '"' || char === "'") && (i === 0 || trimmed[i - 1] !== "\\")) {
|
|
755
|
+
if (!inString) {
|
|
756
|
+
inString = true;
|
|
757
|
+
stringChar = char;
|
|
758
|
+
}
|
|
759
|
+
else if (char === stringChar) {
|
|
760
|
+
inString = false;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
else if (!inString) {
|
|
764
|
+
if (char === "[")
|
|
765
|
+
bracketCount++;
|
|
766
|
+
else if (char === "]")
|
|
767
|
+
bracketCount--;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return bracketCount === 0;
|
|
771
|
+
}
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
findArgs(str, context) {
|
|
775
|
+
var _a, _b;
|
|
776
|
+
let argStr = "";
|
|
777
|
+
let maxSplits = 0;
|
|
778
|
+
(_a = str.match(/\([^;]*\)/g)) === null || _a === void 0 ? void 0 : _a.forEach(s => {
|
|
779
|
+
const c = s.split(",").length;
|
|
780
|
+
if (maxSplits < c) {
|
|
781
|
+
maxSplits = c;
|
|
782
|
+
argStr = s;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
argStr = argStr.replace(/\(|\)/g, "");
|
|
786
|
+
if ((_b = context === null || context === void 0 ? void 0 : context.get) === null || _b === void 0 ? void 0 : _b.call(context, "isInsideList")) {
|
|
787
|
+
argStr = argStr
|
|
788
|
+
.split(",")
|
|
789
|
+
// List row context: omit loop-scoped proxies from synthesized handler params (`$item` from outer closure)
|
|
790
|
+
.filter(s => !(0, lodash_1.includes)(["$item", "currentItemWidgets"], s.trim()))
|
|
791
|
+
.join(",");
|
|
792
|
+
}
|
|
793
|
+
const parsedArgs = this.parseArguments(argStr);
|
|
794
|
+
const args = parsedArgs
|
|
795
|
+
.filter(Boolean)
|
|
796
|
+
.filter(s => !this.isLiteral(s))
|
|
797
|
+
.filter(s => !this.isArithmeticExpression(s))
|
|
798
|
+
.filter(s => !this.isPropertyAccess(s))
|
|
799
|
+
.filter(s => !this.isObjectLiteral(s))
|
|
800
|
+
.filter(s => !this.isArrayLiteral(s));
|
|
801
|
+
const usesBareEvent = /\$event\b/.test(str);
|
|
802
|
+
const hasEventParam = args.some(a => a.trim() === "$event");
|
|
803
|
+
if (usesBareEvent && !hasEventParam) {
|
|
804
|
+
return args.length > 0 ? `(${args.join(", ")}, $event)` : `($event)`;
|
|
805
|
+
}
|
|
806
|
+
return `(${args.join(", ")})`;
|
|
807
|
+
}
|
|
808
|
+
// Parse "($event, widget)" → ["$event", "widget"]; "()" → []
|
|
809
|
+
parseArrowParamNames(argsStr) {
|
|
810
|
+
const inner = argsStr.replace(/^\(|\)$/g, "").trim();
|
|
811
|
+
if (!inner)
|
|
812
|
+
return [];
|
|
813
|
+
return inner
|
|
814
|
+
.split(",")
|
|
815
|
+
.map(s => s.trim())
|
|
816
|
+
.filter(Boolean);
|
|
817
|
+
}
|
|
818
|
+
// Detect a `;` outside strings/parens/braces/brackets — signals multiple top-level statements
|
|
819
|
+
hasTopLevelSemicolon(body) {
|
|
820
|
+
let paren = 0;
|
|
821
|
+
let brace = 0;
|
|
822
|
+
let bracket = 0;
|
|
823
|
+
let inString = false;
|
|
824
|
+
let stringChar = "";
|
|
825
|
+
for (let i = 0; i < body.length; i++) {
|
|
826
|
+
const ch = body[i];
|
|
827
|
+
if ((ch === '"' || ch === "'") && (i === 0 || body[i - 1] !== "\\")) {
|
|
828
|
+
if (!inString) {
|
|
829
|
+
inString = true;
|
|
830
|
+
stringChar = ch;
|
|
831
|
+
}
|
|
832
|
+
else if (ch === stringChar) {
|
|
833
|
+
inString = false;
|
|
834
|
+
}
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
if (inString)
|
|
838
|
+
continue;
|
|
839
|
+
if (ch === "(")
|
|
840
|
+
paren++;
|
|
841
|
+
else if (ch === ")")
|
|
842
|
+
paren--;
|
|
843
|
+
else if (ch === "{")
|
|
844
|
+
brace++;
|
|
845
|
+
else if (ch === "}")
|
|
846
|
+
brace--;
|
|
847
|
+
else if (ch === "[")
|
|
848
|
+
bracket++;
|
|
849
|
+
else if (ch === "]")
|
|
850
|
+
bracket--;
|
|
851
|
+
else if (ch === ";" && paren === 0 && brace === 0 && bracket === 0)
|
|
852
|
+
return true;
|
|
853
|
+
}
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
isInstanceBoundFragmentCallee(calleeRef) {
|
|
857
|
+
return Transpiler.INSTANCE_BOUND_CALLEE.test(calleeRef);
|
|
858
|
+
}
|
|
859
|
+
// Match a body shaped like `fragment(...property chain...)?.(args)` — return callee ref + raw arg list
|
|
860
|
+
extractFragmentMethodCall(body) {
|
|
861
|
+
const trimmed = body.trim();
|
|
862
|
+
if (!trimmed.endsWith(")") || !trimmed.startsWith("fragment"))
|
|
863
|
+
return null;
|
|
864
|
+
let depth = 0;
|
|
865
|
+
let openIdx = -1;
|
|
866
|
+
for (let i = trimmed.length - 1; i >= 0; i--) {
|
|
867
|
+
const ch = trimmed[i];
|
|
868
|
+
if (ch === ")")
|
|
869
|
+
depth++;
|
|
870
|
+
else if (ch === "(") {
|
|
871
|
+
depth--;
|
|
872
|
+
if (depth === 0) {
|
|
873
|
+
openIdx = i;
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (openIdx < 2)
|
|
879
|
+
return null;
|
|
880
|
+
if (trimmed.substring(openIdx - 2, openIdx) !== "?.")
|
|
881
|
+
return null;
|
|
882
|
+
const calleeRef = trimmed.substring(0, openIdx - 2);
|
|
883
|
+
if (!Transpiler.FRAGMENT_CALLEE_REF.test(calleeRef))
|
|
884
|
+
return null;
|
|
885
|
+
const argsStr = trimmed.substring(openIdx + 1, trimmed.length - 1);
|
|
886
|
+
const callArgs = this.parseArguments(argsStr);
|
|
887
|
+
return { calleeRef, callArgs };
|
|
888
|
+
}
|
|
889
|
+
// Decide if an `on-*` handler body can be emitted as a direct function reference instead of an arrow wrapper.
|
|
890
|
+
// Eligible when body is a single `fragment?.x?.(...)` call whose args are all simple identifiers already
|
|
891
|
+
// present in the synthesized arrow parameter list — i.e. nothing references closure-only values like `$item`,
|
|
892
|
+
// `currentItemWidgetsRef.current`, literals, property-access expressions, or table column `rowData`.
|
|
893
|
+
//
|
|
894
|
+
// Additional exclusion: callee paths through `Actions` or `Variables` resolve to runtime instance
|
|
895
|
+
// methods (NavigationAction.invoke, BaseVariable.invoke, setData, navigate, …) that rely on `this`.
|
|
896
|
+
// Emitting them as detached refs strips the receiver and breaks runtime + WmAnchor's
|
|
897
|
+
// `getGoToPageNameFromClickHandler` source-string detection, so always wrap those in an arrow.
|
|
898
|
+
canUseDirectHandlerReference(body, arrowParams) {
|
|
899
|
+
const trimmed = body.replace(/;+\s*$/, "").trim();
|
|
900
|
+
if (!trimmed)
|
|
901
|
+
return null;
|
|
902
|
+
if (this.hasTopLevelSemicolon(trimmed))
|
|
903
|
+
return null;
|
|
904
|
+
const parsed = this.extractFragmentMethodCall(trimmed);
|
|
905
|
+
if (!parsed)
|
|
906
|
+
return null;
|
|
907
|
+
if (this.isInstanceBoundFragmentCallee(parsed.calleeRef))
|
|
908
|
+
return null;
|
|
909
|
+
const paramSet = new Set(arrowParams);
|
|
910
|
+
for (const raw of parsed.callArgs) {
|
|
911
|
+
const a = raw.trim();
|
|
912
|
+
if (!a)
|
|
913
|
+
continue;
|
|
914
|
+
if (this.isLiteral(a) ||
|
|
915
|
+
this.isArithmeticExpression(a) ||
|
|
916
|
+
this.isObjectLiteral(a) ||
|
|
917
|
+
this.isArrayLiteral(a) ||
|
|
918
|
+
this.isPropertyAccess(a)) {
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
if (!paramSet.has(a))
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
return parsed.calleeRef;
|
|
925
|
+
}
|
|
926
|
+
quoteAttr(v) {
|
|
927
|
+
return ("" + v) /* Forces the conversion to string. */
|
|
928
|
+
.replace(/&/g, "&") /* This MUST be the 1st replacement. */
|
|
929
|
+
.replace(/'/g, "'") /* The 4 other predefined entities, required. */
|
|
930
|
+
.replace(/"/g, """)
|
|
931
|
+
.replace(/</g, "<")
|
|
932
|
+
.replace(/>/g, ">");
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Converts ternary expressions that return string literals "true"/"false" to actual boolean values
|
|
936
|
+
* Example: (condition?"true":"false") -> (condition?true:false)
|
|
937
|
+
* Handles cases like: (condition?"true":"false"), (condition? "true" : "false"), etc.
|
|
938
|
+
*/
|
|
939
|
+
convertStringBooleanTernary(exp) {
|
|
940
|
+
return exp.replace(/\?\s*["'](true|false)["']\s*:\s*["'](true|false)["']/g, (_, g1, g2) => `?${g1}:${g2}`);
|
|
941
|
+
}
|
|
942
|
+
shouldTrimUrlAttribute(name) {
|
|
943
|
+
const attrName = name.toLowerCase();
|
|
944
|
+
return attrName.endsWith("url") || attrName.endsWith("src");
|
|
945
|
+
}
|
|
946
|
+
transformAttr(tagName, name, value, context, tx) {
|
|
947
|
+
var _a, _b, _c;
|
|
948
|
+
if (name === "styles" || name === "style" || name === "className") {
|
|
949
|
+
// continue
|
|
950
|
+
}
|
|
951
|
+
else if (name === "groupby" && value.includes("(")) {
|
|
952
|
+
value = `${this.findArgs(value, context)} => ${value}`;
|
|
953
|
+
value = `{${value}}`;
|
|
954
|
+
}
|
|
955
|
+
else if (name.startsWith("on-")) {
|
|
956
|
+
name = "on" + name.charAt(3).toUpperCase() + name.substr(4);
|
|
957
|
+
value = value.replace(/item,/g, "$item,");
|
|
958
|
+
value = value.replace(/item\./g, "$item.");
|
|
959
|
+
value = value.replace(/item\)/g, "$item)");
|
|
960
|
+
// List preprocessors strip `?.` via removeOptionChaining before dataset replace — restore
|
|
961
|
+
// fragment/Variables optional chaining for the emitted handler body.
|
|
962
|
+
if ((_a = context === null || context === void 0 ? void 0 : context.get) === null || _a === void 0 ? void 0 : _a.call(context, "isInsideList")) {
|
|
963
|
+
value = value.replace(/;+\s*$/, "").trim();
|
|
964
|
+
value = addFragmentOptionalChaining(value, false);
|
|
965
|
+
}
|
|
966
|
+
const args = this.findArgs(value, context);
|
|
967
|
+
if ((_b = context === null || context === void 0 ? void 0 : context.get) === null || _b === void 0 ? void 0 : _b.call(context, "isInsideTableColumn")) {
|
|
968
|
+
value = value.replace(/\brow\b/g, "rowData");
|
|
969
|
+
}
|
|
970
|
+
const arrowParams = this.parseArrowParamNames(args);
|
|
971
|
+
const bodyForCheck = value.replace(/;+\s*$/, "").trim();
|
|
972
|
+
const directRef = this.canUseDirectHandlerReference(bodyForCheck, arrowParams);
|
|
973
|
+
if (directRef) {
|
|
974
|
+
value = `{${directRef}}`;
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
value = `${args} => {${value}}`;
|
|
978
|
+
value = `{${value}}`;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
else if (name === "datasource" || name === "deletedatasource") {
|
|
982
|
+
if (value.startsWith("fragment")) {
|
|
983
|
+
value = `{${value}}`;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
else if (value.startsWith("mapfn:")) {
|
|
987
|
+
// Handle dataset with $i - wrapped as a function
|
|
988
|
+
const exp = value.substring(6); // Remove "mapfn:" prefix
|
|
989
|
+
value = `{${exp}}`;
|
|
990
|
+
}
|
|
991
|
+
else if (value.startsWith("bind:")) {
|
|
992
|
+
let exp = `${value.substring(5)}`;
|
|
993
|
+
exp = exp.replace("fragment.Page", "fragment");
|
|
994
|
+
const isProgressCircleDatavalue = tagName === "wm-progress-circle" && name === "datavalue";
|
|
995
|
+
exp = ((_c = context === null || context === void 0 ? void 0 : context.get) === null || _c === void 0 ? void 0 : _c.call(context, "isInsideTableColumn"))
|
|
996
|
+
? (0, utils_1.transformTableColumnClassExpression)(exp)
|
|
997
|
+
: (0, utils_browser_1.modifyExpression)(exp);
|
|
998
|
+
exp = (0, bind_ex_transformer_1.resolveFormatContext)(exp, context);
|
|
999
|
+
exp = this.convertStringBooleanTernary(exp);
|
|
1000
|
+
// If expression is empty after transformation, use empty string instead of empty braces
|
|
1001
|
+
if (!exp) {
|
|
1002
|
+
exp = '""';
|
|
1003
|
+
}
|
|
1004
|
+
if (isProgressCircleDatavalue) {
|
|
1005
|
+
value = `{(${exp} || 0)}`; // for progress circle datavalue, we need to set the value to 0 if it is null or undefined
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
value = name === "show" ? `{(${exp} || false)}` : `{${exp}}`;
|
|
1009
|
+
}
|
|
1010
|
+
if (name === "conditionalclass") {
|
|
1011
|
+
return "";
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
else if (name === "width" || name === "height") {
|
|
1015
|
+
let exp = `${value.substring(5)}`;
|
|
1016
|
+
value = `{${value}}`;
|
|
1017
|
+
}
|
|
1018
|
+
else {
|
|
1019
|
+
if (this.shouldTrimUrlAttribute(name)) {
|
|
1020
|
+
value = value.trim();
|
|
1021
|
+
}
|
|
1022
|
+
value = this.quoteAttr(value);
|
|
1023
|
+
value = (0, property_parser_1.parseProperty)(value, name, tagName);
|
|
1024
|
+
}
|
|
1025
|
+
if (tx) {
|
|
1026
|
+
const rvalue = tx(name, value);
|
|
1027
|
+
if (!(0, lodash_1.isNil)(rvalue)) {
|
|
1028
|
+
value = rvalue;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return (0, lodash_1.isNil)(value) || (0, lodash_1.isEmpty)(value) ? "" : `${name}=${value}`;
|
|
1032
|
+
}
|
|
1033
|
+
transformAttrs(e, context, tx) {
|
|
1034
|
+
var _a, _b, _c, _d;
|
|
1035
|
+
const autolayout = (_a = context.data) === null || _a === void 0 ? void 0 : _a.autolayoutCodegen;
|
|
1036
|
+
const autoLayoutResult = (_b = autolayout === null || autolayout === void 0 ? void 0 : autolayout.processElement(e)) !== null && _b !== void 0 ? _b : null;
|
|
1037
|
+
e.setAttribute("data-widget-id", (0, id_generator_1.generateWidgetId)());
|
|
1038
|
+
const { styles, className } = this.transformStyles(e, context);
|
|
1039
|
+
const tagName = e.tagName.toLowerCase();
|
|
1040
|
+
if (!(0, lodash_1.isEmpty)(styles) && styles != "{}") {
|
|
1041
|
+
e.setAttribute("styles", `{${styles}}`);
|
|
1042
|
+
}
|
|
1043
|
+
if (!(0, lodash_1.isEmpty)(className) && className) {
|
|
1044
|
+
e.setAttribute("className", className);
|
|
1045
|
+
}
|
|
1046
|
+
if (tagName === "wm-composite" &&
|
|
1047
|
+
(e.getAttribute("captionposition") === "floating" || e.getAttribute("required") === "true")) {
|
|
1048
|
+
const labelNode = e.childNodes.find((node) => { var _a; return node.tagName && ((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "wm-label"; });
|
|
1049
|
+
const isRequired = e.getAttribute("required") === "true";
|
|
1050
|
+
const floatingLabel = e.getAttribute("captionposition") === "floating";
|
|
1051
|
+
const labelCaption = (labelNode === null || labelNode === void 0 ? void 0 : labelNode.getAttribute("caption")) || "";
|
|
1052
|
+
const containerNode = e.childNodes.find((node) => { var _a; return node.tagName && ((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "wm-container"; });
|
|
1053
|
+
const searchNodes = (containerNode === null || containerNode === void 0 ? void 0 : containerNode.childNodes) || e.childNodes || [];
|
|
1054
|
+
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)) || ""); });
|
|
1055
|
+
if (foundInputs.length && floatingLabel) {
|
|
1056
|
+
foundInputs[0].setAttribute("floatinglabel", labelCaption);
|
|
1057
|
+
}
|
|
1058
|
+
if (isRequired) {
|
|
1059
|
+
labelNode && labelNode.setAttribute("required", "true");
|
|
1060
|
+
const name = (_c = foundInputs[0]) === null || _c === void 0 ? void 0 : _c.getAttribute("name");
|
|
1061
|
+
labelNode && name && labelNode.setAttribute("htmlFor", name);
|
|
1062
|
+
foundInputs.forEach(n => n.setAttribute("required", "true"));
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
let str = Object.keys(e.attributes)
|
|
1066
|
+
.map(name => {
|
|
1067
|
+
return this.transformAttr(tagName, name, e.attributes[name], context, tx);
|
|
1068
|
+
})
|
|
1069
|
+
.join(" ");
|
|
1070
|
+
// Append layoutClassName as a separate attribute, bypassing setAttribute to avoid HTML-entity encoding
|
|
1071
|
+
if (autoLayoutResult && autolayout) {
|
|
1072
|
+
const layoutClassNameValue = autolayout.buildLayoutClassNameAttr(autoLayoutResult);
|
|
1073
|
+
str += ` layoutClassName=${layoutClassNameValue}`;
|
|
1074
|
+
}
|
|
1075
|
+
// Inject a `loading` prop driven by the variable(s) the widget consumes so the
|
|
1076
|
+
// skeleton hides once data arrives. showSkeleton is not emitted by codegen —
|
|
1077
|
+
// runtime shows skeleton by default whenever loading is true.
|
|
1078
|
+
const loadableVars = (_d = context.data) === null || _d === void 0 ? void 0 : _d.loadableVariables;
|
|
1079
|
+
const referencedVars = extractVariableNamesFromElement(e);
|
|
1080
|
+
const loadingVars = loadableVars
|
|
1081
|
+
? referencedVars.filter(name => loadableVars.has(name))
|
|
1082
|
+
: referencedVars;
|
|
1083
|
+
if (loadingVars.length > 0) {
|
|
1084
|
+
const loadingParts = loadingVars.map(name => `fragment?.Variables?.${name}?.loading`);
|
|
1085
|
+
str += ` loading={${loadingParts.join(" || ")} || false}`;
|
|
1086
|
+
}
|
|
1087
|
+
return str;
|
|
1088
|
+
}
|
|
1089
|
+
createUniqueComponentName(components, name, counter = 0) {
|
|
1090
|
+
name = name + counter;
|
|
1091
|
+
if (components[name]) {
|
|
1092
|
+
return this.createUniqueComponentName(components, name, counter++);
|
|
1093
|
+
}
|
|
1094
|
+
return name;
|
|
1095
|
+
}
|
|
1096
|
+
createComponent(e, context) {
|
|
1097
|
+
const result = context.result;
|
|
1098
|
+
let widgetName = "PC_" + (0, lodash_1.capitalize)(e.attrs["name"]);
|
|
1099
|
+
widgetName = (0, lodash_1.replace)(widgetName, /[^a-zA-Z0-9]/g, "_");
|
|
1100
|
+
if (this.componentNamesList.indexOf(widgetName) !== -1) {
|
|
1101
|
+
widgetName = this.createUniqueComponentName(result.components, widgetName);
|
|
1102
|
+
}
|
|
1103
|
+
this.componentNamesList.push(widgetName);
|
|
1104
|
+
const props = ["fragment", ...context.props];
|
|
1105
|
+
result.components[widgetName] = `({${props.join(",")}}) => {
|
|
1106
|
+
return (${result.markup});
|
|
1107
|
+
}`;
|
|
1108
|
+
result.markup = `<${widgetName} ${props.map(p => `${p}={${p}}`).join(" ")}/>`;
|
|
1109
|
+
return result;
|
|
1110
|
+
}
|
|
1111
|
+
registerTransformer(tagName, transformer) {
|
|
1112
|
+
transpiler.transformers.set(tagName, transformer);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
// Skeleton-related attrs are authored in camelCase in WaveMaker markup but the HTML
|
|
1116
|
+
// parser lowercases all attribute names. Rename them back before attribute processing
|
|
1117
|
+
// so that property-parser.ts can match the camelCase keys it registers.
|
|
1118
|
+
Transpiler.SKELETON_ATTR_RENAME = {
|
|
1119
|
+
skeletonrows: "skeletonRows",
|
|
1120
|
+
skeletoncolumns: "skeletonColumns",
|
|
1121
|
+
showskeleton: "showSkeleton",
|
|
1122
|
+
};
|
|
1123
|
+
// Pure property / safe-property / keyed-read chain rooted at `fragment`.
|
|
1124
|
+
// Rejects callee refs that contain intermediate calls (e.g. `fragment.a?.b?.()?.c`),
|
|
1125
|
+
// operators, assignments, whitespace — anything that would change semantics when
|
|
1126
|
+
// evaluated at render time instead of click time.
|
|
1127
|
+
Transpiler.FRAGMENT_CALLEE_REF = /^fragment(?:\??\.[a-zA-Z_$][\w$]*|(?:\?\.)?\[[^\]]*\])*$/;
|
|
1128
|
+
// Callee paths rooted at runtime instance objects (Actions, Variables) whose methods
|
|
1129
|
+
// (invoke, navigate, setData, …) rely on `this` and must not be emitted as detached refs.
|
|
1130
|
+
// Anchored to `fragment` so `fragment?.myService?.Actions?.run` (custom object that happens
|
|
1131
|
+
// to have an Actions property) is NOT incorrectly forced into an arrow wrapper.
|
|
1132
|
+
Transpiler.INSTANCE_BOUND_CALLEE = /^fragment(?:\?\.|\.)(?:Actions|Variables)(?:\?\.|\.|\[|$)/;
|
|
1133
|
+
const transpiler = new Transpiler();
|
|
1134
|
+
exports.registerTransformer = transpiler.registerTransformer.bind(transpiler);
|
|
1135
|
+
const transpileMarkup = (markup, isPartOfPrefab, splitCode, variables, preview, insideTableColumn) => {
|
|
1136
|
+
const parsed = (0, exports.parse)(markup, {
|
|
1137
|
+
blockTextElements: {},
|
|
1138
|
+
});
|
|
1139
|
+
let finalResult = {
|
|
1140
|
+
markup: "",
|
|
1141
|
+
components: {},
|
|
1142
|
+
partials: [],
|
|
1143
|
+
wmxcomponents: [],
|
|
1144
|
+
prefabs: [],
|
|
1145
|
+
imports: [],
|
|
1146
|
+
};
|
|
1147
|
+
// Create a map of ModelVariables (wm.Variable category) with twoWayBinding: true
|
|
1148
|
+
// Only ModelVariables support twoWayBinding, other variable types don't
|
|
1149
|
+
const twoWayBindingVariables = new Set();
|
|
1150
|
+
// Variables that expose a .loading state — everything except ModelVariable and Actions
|
|
1151
|
+
const loadableVariables = new Set();
|
|
1152
|
+
if (variables) {
|
|
1153
|
+
Object.values(variables).forEach((v) => {
|
|
1154
|
+
// Only check twoWayBinding for ModelVariables (category === "wm.Variable")
|
|
1155
|
+
// These are the only variables that support two-way binding
|
|
1156
|
+
if (v.category === "wm.Variable" && v.twoWayBinding === true && v.name) {
|
|
1157
|
+
twoWayBindingVariables.add(v.name);
|
|
1158
|
+
}
|
|
1159
|
+
// Collect variables that have a loading state (excludes ModelVariable and all Actions)
|
|
1160
|
+
if (v.name && !CATEGORIES_WITHOUT_LOADING.has(v.category)) {
|
|
1161
|
+
loadableVariables.add(v.name);
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
const autolayoutCodegen = new widget_inline_style_processor_1.AutolayoutCodegen();
|
|
1166
|
+
// Create initial context with twoWayBinding variables info to pass down the tree
|
|
1167
|
+
const initialContext = new TranspilationContext({
|
|
1168
|
+
result: finalResult,
|
|
1169
|
+
isPartOfPrefab: isPartOfPrefab,
|
|
1170
|
+
transformer: {},
|
|
1171
|
+
props: [],
|
|
1172
|
+
data: {
|
|
1173
|
+
twoWayBindingVariables: twoWayBindingVariables,
|
|
1174
|
+
loadableVariables: loadableVariables,
|
|
1175
|
+
autolayoutCodegen,
|
|
1176
|
+
preview: preview === true,
|
|
1177
|
+
...(insideTableColumn ? { isInsideTableColumn: true } : {}),
|
|
1178
|
+
},
|
|
1179
|
+
});
|
|
1180
|
+
// Process all child nodes (including text nodes that come before the main element)
|
|
1181
|
+
parsed.childNodes.forEach((node) => {
|
|
1182
|
+
if (node.nodeType === exports.NodeType.TEXT_NODE) {
|
|
1183
|
+
const textContent = node.text;
|
|
1184
|
+
if (textContent.trim()) {
|
|
1185
|
+
finalResult.markup += `{"${textContent.trim()}"} \n`;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
else if (node.nodeType === exports.NodeType.ELEMENT_NODE) {
|
|
1189
|
+
transpiler.preTranspile(node);
|
|
1190
|
+
const result = transpiler.transpile(node, isPartOfPrefab, splitCode, initialContext);
|
|
1191
|
+
finalResult.markup += result.markup;
|
|
1192
|
+
finalResult.components = { ...finalResult.components, ...result.components };
|
|
1193
|
+
finalResult.partials.push(...result.partials);
|
|
1194
|
+
finalResult.prefabs.push(...result.prefabs);
|
|
1195
|
+
finalResult.wmxcomponents.push(...result.wmxcomponents);
|
|
1196
|
+
finalResult.imports.push(...result.imports);
|
|
1197
|
+
if (result.pageEvents)
|
|
1198
|
+
finalResult.pageEvents = result.pageEvents;
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
finalResult.autolayoutCss = autolayoutCodegen.getDynamicCssRules();
|
|
1202
|
+
// Statically discover cross-context active-page dependency paths from the generated source
|
|
1203
|
+
// (top-level markup + any split component bodies) so the runtime can value-gate declaratively.
|
|
1204
|
+
const generatedSource = [finalResult.markup, ...Object.values(finalResult.components)].join("\n");
|
|
1205
|
+
finalResult.activePageDeps = extractActivePageDeps(generatedSource);
|
|
1206
|
+
return finalResult;
|
|
1207
|
+
};
|
|
1208
|
+
exports.transpileMarkup = transpileMarkup;
|
|
1209
|
+
exports.transformAttrs = transpiler.transformAttrs.bind(transpiler);
|
|
1210
|
+
exports.preTranspile = transpiler.preTranspile.bind(transpiler);
|
|
1211
|
+
exports.createComponent = transpiler.createComponent.bind(transpiler);
|
|
1212
|
+
const transpileElement = (element, isPartOfPrefab, splitCode = true, oldContext) => {
|
|
1213
|
+
return transpiler.transpile(element, isPartOfPrefab, splitCode, oldContext);
|
|
1214
|
+
};
|
|
1215
|
+
exports.transpileElement = transpileElement;
|
|
1216
|
+
/**
|
|
1217
|
+
* Decodes HTML entities in a string
|
|
1218
|
+
* Handles common entities like ", &, <, >, '
|
|
1219
|
+
*/
|
|
1220
|
+
const decodeHTMLEntities = (text) => {
|
|
1221
|
+
const entities = {
|
|
1222
|
+
""": '"',
|
|
1223
|
+
"&": "&",
|
|
1224
|
+
"<": "<",
|
|
1225
|
+
">": ">",
|
|
1226
|
+
"'": "'",
|
|
1227
|
+
};
|
|
1228
|
+
return text.replace(/&[a-z]+;/g, entity => entities[entity] || entity);
|
|
1229
|
+
};
|
|
1230
|
+
exports.decodeHTMLEntities = decodeHTMLEntities;
|
|
1231
|
+
/**
|
|
1232
|
+
* Transforms $[...] syntax to proper property access
|
|
1233
|
+
* Examples:
|
|
1234
|
+
* $[location] -> $item.location
|
|
1235
|
+
* $[data[$i].locationDesc] -> $item.locationDesc (removes data[$i]. prefix)
|
|
1236
|
+
* $[fragment.assetType] -> $item.assetType (removes fragment. prefix)
|
|
1237
|
+
*/
|
|
1238
|
+
const transformDollarBracketSyntax = (expression) => {
|
|
1239
|
+
// First, remove data[$i]. prefixes from within $[...] brackets
|
|
1240
|
+
expression = expression.replace(/\$\[data\[\$i\]\./g, "$[");
|
|
1241
|
+
// Transform $[property.path] to $item.property.path
|
|
1242
|
+
expression = expression.replace(/\$\[([^\]]+)\]/g, (match, property) => {
|
|
1243
|
+
// Remove data[index]. and fragment. prefixes
|
|
1244
|
+
property = property.replace(/data\[\d+\]\./g, "").replace(/^fragment\./, "");
|
|
1245
|
+
return `$item.${property}`;
|
|
1246
|
+
});
|
|
1247
|
+
return expression;
|
|
1248
|
+
};
|
|
1249
|
+
exports.transformDollarBracketSyntax = transformDollarBracketSyntax;
|
|
1250
|
+
const createExpression = (element, attrName) => {
|
|
1251
|
+
let displayexpression = element.attrs[attrName];
|
|
1252
|
+
if (displayexpression === null || displayexpression === void 0 ? void 0 : displayexpression.startsWith("bind:")) {
|
|
1253
|
+
displayexpression = displayexpression.substring(5).trim();
|
|
1254
|
+
// Remove trailing semicolons (common in WaveMaker expressions but invalid in JSX)
|
|
1255
|
+
displayexpression = displayexpression.replace(/;+$/, "");
|
|
1256
|
+
// Decode HTML entities like " to "
|
|
1257
|
+
displayexpression = (0, exports.decodeHTMLEntities)(displayexpression);
|
|
1258
|
+
// Transform $[...] syntax to proper property access
|
|
1259
|
+
displayexpression = (0, exports.transformDollarBracketSyntax)(displayexpression);
|
|
1260
|
+
// Replace fragment references with $item
|
|
1261
|
+
displayexpression = displayexpression.replace(/fragment\.\$item/g, "$item");
|
|
1262
|
+
displayexpression = displayexpression.replace(/fragment\.\$index/g, "$index");
|
|
1263
|
+
displayexpression = displayexpression.replace(/fragment\.\$length/g, "$length");
|
|
1264
|
+
displayexpression = displayexpression.replace(/fragment\.\$/g, "$item");
|
|
1265
|
+
displayexpression = displayexpression.replace(/\$item\['fragment.(.*?)'\]/g, "$item['$1']");
|
|
1266
|
+
displayexpression = displayexpression.replace(/\$item\[fragment.(.*?)\]/g, "$item['$1']");
|
|
1267
|
+
displayexpression = displayexpression.replace(/\$item\['(.*?)'\]/g, "_get($item, '$1')");
|
|
1268
|
+
displayexpression = displayexpression.replace(/fragment.index/g, "$index");
|
|
1269
|
+
if (/formatters/.test(displayexpression)) {
|
|
1270
|
+
displayexpression = displayexpression.split(bind_ex_transformer_1.FORMAT_CONTEXT).join("$item");
|
|
1271
|
+
}
|
|
1272
|
+
// Transform fragment.name -> $item.name for item properties, but preserve
|
|
1273
|
+
// page-level variables (appLocale, Variables) as fragment references.
|
|
1274
|
+
displayexpression = displayexpression.replace(/fragment\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g, (match, name) => (bind_ex_transformer_1.FRAGMENT_SCOPED_NAMES.includes(name) ? match : `$item.${name}`));
|
|
1275
|
+
// Add optional chaining while preserving dots inside string literals (e.g. custom.rowCurrencyList)
|
|
1276
|
+
displayexpression = (0, utils_browser_1.addOptionalChaining)(displayexpression);
|
|
1277
|
+
const exp = (0, lodash_1.includes)(displayexpression, "(") ? `${displayexpression}` : displayexpression;
|
|
1278
|
+
if (displayexpression.indexOf("$index") >= 0) {
|
|
1279
|
+
return `{($item, $index, $length) => (${exp})}`;
|
|
1280
|
+
}
|
|
1281
|
+
return `{($item) => (${exp})}`;
|
|
1282
|
+
}
|
|
1283
|
+
if ((0, utils_browser_1.isJSExpression)(displayexpression)) {
|
|
1284
|
+
const transformedExp = (0, bind_ex_transformer_1.default)(displayexpression, "$item");
|
|
1285
|
+
return `{($item) => (${transformedExp})}`;
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
exports.createExpression = createExpression;
|
|
1289
|
+
const preTranspileHtmlElement = (e) => {
|
|
1290
|
+
// Process style properties using style transformer
|
|
1291
|
+
const styleObj = (0, style_transformer_1.default)(e, (propName) => {
|
|
1292
|
+
return true; // Process all style properties
|
|
1293
|
+
}) || {};
|
|
1294
|
+
// Get all attributes except name (which is added by transpiler) and convert class to className
|
|
1295
|
+
const attrs = Object.keys(e.attributes)
|
|
1296
|
+
.filter(attr => attr !== "name")
|
|
1297
|
+
.map(attr => {
|
|
1298
|
+
const value = e.getAttribute(attr);
|
|
1299
|
+
if (!value)
|
|
1300
|
+
return `${attr}=""`;
|
|
1301
|
+
// Convert HTML 'class' attribute to JSX 'className'
|
|
1302
|
+
if (attr === "class") {
|
|
1303
|
+
return `className="${value}"`;
|
|
1304
|
+
}
|
|
1305
|
+
// Convert HTML 'style' attribute to JSX style object
|
|
1306
|
+
else if (attr === "style") {
|
|
1307
|
+
const styleObject = convertStyleStringToObject(value);
|
|
1308
|
+
return `style={${styleObject}}`;
|
|
1309
|
+
}
|
|
1310
|
+
return `${attr}="${value}"`;
|
|
1311
|
+
})
|
|
1312
|
+
.join(" ");
|
|
1313
|
+
// Add processed styles if any were found
|
|
1314
|
+
let styleAttr = "";
|
|
1315
|
+
if (styleObj && Object.keys(styleObj).length > 0) {
|
|
1316
|
+
styleAttr = ` style={${JSON.stringify(styleObj)}}`;
|
|
1317
|
+
}
|
|
1318
|
+
const attrsStr = attrs ? ` ${attrs}` : "";
|
|
1319
|
+
return `<${e.tagName.toLowerCase()}${attrsStr}${styleAttr}>`;
|
|
1320
|
+
};
|
|
1321
|
+
/**
|
|
1322
|
+
* Converts CSS style string to React style object format
|
|
1323
|
+
* Example: "color:#ffffff; font-size:14px" -> {color:"#ffffff",fontSize:"14px"}
|
|
1324
|
+
*/
|
|
1325
|
+
const convertStyleStringToObject = (styleString) => {
|
|
1326
|
+
if (!styleString || styleString.trim() === "") {
|
|
1327
|
+
return "{}";
|
|
1328
|
+
}
|
|
1329
|
+
const styleObject = {};
|
|
1330
|
+
// Split by semicolon and process each style property
|
|
1331
|
+
styleString.split(";").forEach(rule => {
|
|
1332
|
+
const colonIndex = rule.indexOf(":");
|
|
1333
|
+
if (colonIndex > 0) {
|
|
1334
|
+
const property = rule.substring(0, colonIndex).trim();
|
|
1335
|
+
const value = rule.substring(colonIndex + 1).trim();
|
|
1336
|
+
if (property && value) {
|
|
1337
|
+
// Convert kebab-case to camelCase (e.g., font-size -> fontSize)
|
|
1338
|
+
const camelCaseProperty = property.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
1339
|
+
styleObject[camelCaseProperty] = value;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
// Convert to JSON string and return
|
|
1344
|
+
return JSON.stringify(styleObject);
|
|
1345
|
+
};
|
|
1346
|
+
const postTranspileHtmlElement = (e) => {
|
|
1347
|
+
return `</${e.tagName.toLowerCase()}>`;
|
|
1348
|
+
};
|
|
1349
|
+
//# sourceMappingURL=transpile.js.map
|