@wavemaker/angular-codegen 12.0.0-next.45061 → 12.0.0-next.45064
Sign up to get free protection for your applications and to get access to all the features.
- angular-codegen/angular-app/package-lock.json +12 -12
- angular-codegen/angular-app/package.json +4 -4
- angular-codegen/dependencies/custom-widgets-m3/src/checkbox_set/checkbox_set.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/checkbox_set/checkbox_set.js +38 -0
- angular-codegen/dependencies/custom-widgets-m3/src/checkbox_set/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/checkbox_set/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/discrete_slider/discrete_slider.d.ts +10 -0
- angular-codegen/dependencies/custom-widgets-m3/src/discrete_slider/discrete_slider.js +171 -0
- angular-codegen/dependencies/custom-widgets-m3/src/discrete_slider/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/discrete_slider/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/divider/divider.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/divider/divider.js +28 -0
- angular-codegen/dependencies/custom-widgets-m3/src/divider/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/divider/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/icon_button/icon_button.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/icon_button/icon_button.js +24 -0
- angular-codegen/dependencies/custom-widgets-m3/src/icon_button/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/icon_button/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/input_chip.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/input_chip.js +34 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/input_chip.variables.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/input_chip.variables.js +1 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/input_chip/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/payee_list/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/payee_list/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/payee_list/payee_list.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/payee_list/payee_list.js +19 -0
- angular-codegen/dependencies/custom-widgets-m3/src/progressbar/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/progressbar/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/progressbar/progressbar.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/progressbar/progressbar.js +52 -0
- angular-codegen/dependencies/custom-widgets-m3/src/radio_set/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/radio_set/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/radio_set/radio_set.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/radio_set/radio_set.js +35 -0
- angular-codegen/dependencies/custom-widgets-m3/src/slider/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/slider/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/slider/slider.d.ts +11 -0
- angular-codegen/dependencies/custom-widgets-m3/src/slider/slider.js +121 -0
- angular-codegen/dependencies/custom-widgets-m3/src/switch_button/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/switch_button/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/switch_button/switch_button.d.ts +0 -0
- angular-codegen/dependencies/custom-widgets-m3/src/switch_button/switch_button.js +33 -0
- angular-codegen/dependencies/custom-widgets-m3/src/textfield/page.min.d.ts +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/textfield/page.min.js +7 -0
- angular-codegen/dependencies/custom-widgets-m3/src/textfield/textfield.d.ts +4 -0
- angular-codegen/dependencies/custom-widgets-m3/src/textfield/textfield.js +65 -0
- angular-codegen/dependencies/custom-widgets-m3/src/widget-registry.d.ts +6 -0
- angular-codegen/dependencies/custom-widgets-m3/src/widget-registry.js +68 -0
- angular-codegen/package.json +1 -1
- angular-codegen/src/gen-components.js +1 -1
@@ -0,0 +1,65 @@
|
|
1
|
+
/*
|
2
|
+
* Use App.getDependency for Dependency Injection
|
3
|
+
* eg: var DialogService = App.getDependency('DialogService');
|
4
|
+
*/
|
5
|
+
/* perform any action on widgets/variables within this block */
|
6
|
+
Widget.onReady = function () {
|
7
|
+
/*
|
8
|
+
* variables can be accessed through 'Widget.Variables' property here
|
9
|
+
* e.g. to get dataSet in a staticVariable named 'loggedInUser' use following script
|
10
|
+
* Widget.Variables.loggedInUser.getData()
|
11
|
+
*
|
12
|
+
* widgets can be accessed through 'widgetMap' property here
|
13
|
+
* e.g. to get value of text widget named 'username' use following script
|
14
|
+
* 'widgetMap.username.datavalue'
|
15
|
+
*/
|
16
|
+
var widgetMap = Widget.Widgets;
|
17
|
+
var _a = Widget.props, leading_icon = _a.leading_icon, trailing_icon = _a.trailing_icon, input_type = _a.input_type, required = _a.required;
|
18
|
+
handleLeadingIcon(widgetMap, leading_icon);
|
19
|
+
handleTrailingIcon(widgetMap, trailing_icon);
|
20
|
+
handleinputType(widgetMap, input_type);
|
21
|
+
handleRequired(widgetMap, required);
|
22
|
+
};
|
23
|
+
Widget.onPropertyChange = function (propname, newvalue, oldvalue) {
|
24
|
+
var widgetMap = Widget.Widgets;
|
25
|
+
var _a = Widget.props, leading_icon = _a.leading_icon, trailing_icon = _a.trailing_icon, input_type = _a.input_type, required = _a.required;
|
26
|
+
switch (propname) {
|
27
|
+
case 'prop-leading_icon':
|
28
|
+
handleLeadingIcon(widgetMap, leading_icon);
|
29
|
+
break;
|
30
|
+
case 'prop-trailing_icon':
|
31
|
+
handleTrailingIcon(widgetMap, trailing_icon);
|
32
|
+
break;
|
33
|
+
case 'prop-required':
|
34
|
+
handleRequired(widgetMap, required);
|
35
|
+
break;
|
36
|
+
case 'prop-input_type':
|
37
|
+
handleinputType(widgetMap, input_type);
|
38
|
+
break;
|
39
|
+
}
|
40
|
+
};
|
41
|
+
function handleLeadingIcon(widgetMap, leading_icon) {
|
42
|
+
widgetMap.textField.nativeElement.classList.remove('with-leading-icon');
|
43
|
+
widgetMap.labelCaption.nativeElement.classList.remove('with-leading-icon');
|
44
|
+
if (leading_icon == true) {
|
45
|
+
widgetMap.labelCaption.class += ' with-leading-icon';
|
46
|
+
widgetMap.textField.class += ' with-leading-icon';
|
47
|
+
}
|
48
|
+
}
|
49
|
+
function handleTrailingIcon(widgetMap, trailing_icon) {
|
50
|
+
widgetMap.textField.nativeElement.classList.remove('with-trailing-icon');
|
51
|
+
widgetMap.labelCaption.nativeElement.classList.remove('with-trailing-icon');
|
52
|
+
if (trailing_icon == true) {
|
53
|
+
widgetMap.labelCaption.class += ' with-trailing-icon';
|
54
|
+
widgetMap.textField.class += ' with-trailing-icon';
|
55
|
+
}
|
56
|
+
}
|
57
|
+
function handleRequired(widgetMap, required) {
|
58
|
+
widgetMap.composite.required = required;
|
59
|
+
}
|
60
|
+
function handleinputType(widgetMap, input_type) {
|
61
|
+
widgetMap.textField.type = input_type;
|
62
|
+
}
|
63
|
+
Widget.buttonTrailingIconClick = function ($event, widget) {
|
64
|
+
// Widget.invokeEvent('trailingIconButtonOnClick');
|
65
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
export var widgetRegistry = [
|
2
|
+
{
|
3
|
+
"name": "checkbox_set",
|
4
|
+
"displayName": "Chekboxset",
|
5
|
+
"iconClass": "checkboxset",
|
6
|
+
"desc": "Checkbox set control supporting Material 3 design system"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "divider",
|
10
|
+
"displayName": "Divider",
|
11
|
+
"iconClass": "design-dialog",
|
12
|
+
"desc": "Divider based on Material 3 design system"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "icon_button",
|
16
|
+
"displayName": "Icon button",
|
17
|
+
"iconClass": "button",
|
18
|
+
"desc": "Icon button based on Material 3 design system"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "input_chip",
|
22
|
+
"displayName": "Input Chip",
|
23
|
+
"iconClass": "chips",
|
24
|
+
"desc": "Input chips based on Material 3 design system"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "payee_list",
|
28
|
+
"displayName": "Payee List",
|
29
|
+
"iconClass": "checkboxset",
|
30
|
+
"desc": "Payee List"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"name": "radio_set",
|
34
|
+
"displayName": "Radioset",
|
35
|
+
"iconClass": "radioset",
|
36
|
+
"desc": "Radioset based on Material 3 design system"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "switch_button",
|
40
|
+
"displayName": "Switch",
|
41
|
+
"iconClass": "switch",
|
42
|
+
"desc": "Switch button based on Material 3 design system"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "textfield",
|
46
|
+
"displayName": "Textfield",
|
47
|
+
"iconClass": "text",
|
48
|
+
"desc": "Input text control based on Material 3 design system"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "slider",
|
52
|
+
"displayName": "Slider",
|
53
|
+
"iconClass": "slider",
|
54
|
+
"desc": "Slider control based on Material 3 design system"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"name": "discrete_slider",
|
58
|
+
"displayName": "Discrete slider",
|
59
|
+
"iconClass": "slider",
|
60
|
+
"desc": "Discrete Slider control based on Material 3 design system"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"name": "progressbar",
|
64
|
+
"displayName": "Progress bar",
|
65
|
+
"iconClass": "progress",
|
66
|
+
"desc": "Progress bar widget based on Material 3 design system"
|
67
|
+
}
|
68
|
+
];
|
angular-codegen/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
const{createDir:createDir,writeFile:writeFile,isPrefabProject:isPrefabProject,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,formatContents:formatContents,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getPrefabPagesDirPath:getPrefabPagesDirPath}=require("./wm-utils"),fs=require("fs"),cheerio=require("cheerio"),{getPageContents:getPageContents,getCustomWidgetPageContents:getCustomWidgetPageContents}=require("./pages-util"),{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{generateCustomWidgetConfigFile:generateCustomWidgetConfigFile}=require("./gen-customwidget-config")
|
1
|
+
const{createDir:createDir,writeFile:writeFile,isPrefabProject:isPrefabProject,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,formatContents:formatContents,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getPrefabPagesDirPath:getPrefabPagesDirPath}=require("./wm-utils"),fs=require("fs"),cheerio=require("cheerio"),{getPageContents:getPageContents,getCustomWidgetPageContents:getCustomWidgetPageContents}=require("./pages-util"),{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{generateCustomWidgetConfigFile:generateCustomWidgetConfigFile}=require("./gen-customwidget-config");let customWidgetConfigMap=new Map;const writeComponentHtmlFile=async(e,t,a)=>{const n=`${a}/${e}.component.html`;await writeFile(n,t.string)},writeComponentCssFile=async(e,t,a)=>{const n=`${a}/${e}.component.css`;await writeFile(n,t.string)},writeComponentVariablesFile=async(e,t,a,n)=>{let o=getHandlebarTemplate(e)({variables:a});await writeFile(`${n}/${t}.component.variables.ts`,formatContents(o))},writeComponentConfigFile=async(e,t,a,n)=>{let o=getHandlebarTemplate(e)({config:a});await writeFile(`${n}/${t}.component.config.ts`,formatContents(o))},writeComponentJsFile=async(e,t,a,n)=>{const o=getHandlebarTemplate(e)({jsContent:a});await writeFile(`${n}/${t}.component.script.js`,formatContents(o,"javascript"))},writeComponentExpressionsFile=async(e,t,a,n)=>{const o=getHandlebarTemplate(e)({expressions:a});await writeFile(`${n}/${t}.component.expressions.ts`,formatContents(o,"javascript"))},writeComponentTsFile=async(e,t,a,n,o,i,r=[])=>{let s=getHandlebarTemplate(e)({name:t,prefabName:a,componentName:getComponentName(t),enableSpa:o,layoutPages:safeString(JSON.stringify(i)),requiredWMComponents:r});await writeFile(`${n}/${t}.component.ts`,s)},writePagePartialModuleTsFile=async(e,t,a,n,o,i,r=!1,s,m,p,g)=>{let l=getHandlebarTemplate(e)({name:t,componentName:getComponentName(t),moduleName:getComponentModuleName(t),requiredPartials:n,requiredPrefabs:o,requiredWMComponents:i,hasCustomElement:r,insidePrefab:!!s,pagesConfig:m,securityConfig:p,requireCustomComponents:g});await writeFile(`${a}/${t}.module.ts`,l)},writePrefabModuleTsFile=async(e,t,a,n=!1,o)=>{let i=getHandlebarTemplate("prefab-module-ts")({name:e,componentName:getComponentName(e),moduleName:getComponentModuleName(e),requiredPartials:o,requiredWMComponents:a,hasCustomElement:n});await writeFile(`${t}/${e}.module.ts`,i)},generateComponent=async(e,t,a,n,o,i,r,s,m,p=!1)=>{await createDir(e,{recursive:!0});const{markup:g,styles:l,variables:c,script:u,expressions:d}=n,C=[writeComponentHtmlFile(t,safeString(g),e),writeComponentTsFile(o,t,a,e,s,m,n.requiredWMComponents)];return p||writeComponentExpressionsFile("component-expressions",t,safeString(d),e),r||C.concat([writeComponentCssFile(t,safeString(l),e),writeComponentVariablesFile("component-variables",t,safeString(c),e),writeComponentJsFile(i,t,safeString(u),e)]),Promise.all(C)},findRequiredPartials=e=>{const t={};return e("[partialContainer]").map((t,a)=>e(a).attr("content")).toArray().map(e=>({type:"PARTIAL",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},findRequiredPrefabs=e=>{const t={};return e("[wmPrefab]").map((t,a)=>e(a).attr("prefabname")).toArray().map(e=>({type:"PREFAB",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},findRequiredCustomWidgets=e=>{const t={};return e("[customWidgetContainer]").map((t,a)=>e(a).attr("widgetname")).toArray().map(e=>({type:"CUSTOMWIDGET",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},generateCustomWidgetsComponent=async(e,t,a,n)=>{let o,i,r,s;{if(s=`${t}/src/app/customwidgets/${e}`,o="customwidget-component-ts",i="customwidget-component-script",r="customwidget-module-ts",fs.existsSync(`${s}/${e}.component.ts`))return;const a="dependencies/custom-widgets-m3/src",m=await getCustomWidgetPageContents(a,e);n.set(e,m.config);try{const t=cheerio.load(m.markup);findRequiredPartials(t),findRequiredPrefabs(t);await generateComponent(s,e,void 0,m,"customwidget-component-ts","customwidget-component-script",!1,void 0,void 0,!0)}catch(e){throw console.log("failed in "+pageName),e}}};convertHTMLStructure=(e=>{return e.replace(/<div\s+wmWidgetContainer\s+customWidgetContainer\s+#wm_custom_widget\d+="wmWidgetContainer"\s+widgetname="([^"]+)"\s+name="([^"]+)"\s*(.*?)\s*\/?>\s*<\/div>/g,(e,t,a,n)=>{let o;return`<${o=`app-custom-${t.replace("_","-")}`} wmWidgetContainer #wm_custom_widget${a.match(/\d+/)[0]}="wmWidgetContainer" widgetname="${t}" name="${a}" ${n}></${o}>`})});const generatePagePartialComponent=async(e,t,a,n,o,i,r,s,m,p,g,l)=>{let c,u,d,C,f;if("PAGE"===n?(C=`${o}/src/app/pages/${a}`,c="page-component-ts",u="page-component-script",d="page-module-ts"):"LAYOUT"===n?(C=`${o}/src/app/layouts/${a}`,c="layout-component-ts",d="layout-module-ts",f=p.filter(e=>"PAGE"===e.type&&e.layout===a).map(e=>e.name)):(C=i?`${o}/partials/${a}`:`${o}/src/app/partials/${a}`,c="partial-component-ts",u="partial-component-script",d="partial-module-ts"),fs.existsSync(`${C}/${a}.component.ts`))return;let w=`${e}/${a}`;i&&(w=`${getPrefabPagesDirPath(r,i)}/${a}`);const P=await getPageContents(t,w,`${a}`,a,n,void 0,s);try{const e=cheerio.load(P.markup),l=findRequiredPartials(e),w=findRequiredPrefabs(e),$=findRequiredCustomWidgets(e);for(const e of l){const a=getPagesDirPath(r);await generatePagePartialComponent(a,t,e.name,e.type,o,i,r,s,m)}for(const e of $)await generateCustomWidgetsComponent(e.name,o,0,customWidgetConfigMap);$.length&&await generateCustomWidgetConfigFile(customWidgetConfigMap,o),P.markup=convertHTMLStructure(P.markup),await generateComponent(C,a,void 0,P,c,u,"LAYOUT"===n,m,f),await writePagePartialModuleTsFile(d,a,C,l,w,P.requiredWMComponents,P.hasCustomElement,i,p,g,$)}catch(e){throw console.log("failed in "+a),e}},generateComponents=async(e,t,a,n,o,i,r,s,m,p)=>{const g=getPagesDirPath(e);customWidgetConfigMap=new Map;for(const a of i.keys()){const n="__self__"===a?`${g}/Main`:`${getPrefabPagesDirPath(e,a)}/Main`,o=await getPageContents(t,n,"Main",a,"PREFAB",i.get(a),m),c=`${r}/src/app/prefabs/${a}`,u=cheerio.load(o.markup),d=findRequiredPartials(u);await generateComponent(c,a,a,o,"prefab-component-ts","prefab-component-script",!1,p);const C=s[a];for(var l=0;l<C.length;l++)await generatePagePartialComponent(g,t,C[l].name,C[l].type,c,a,e,m,p);await writePrefabModuleTsFile(a,c,o.requiredWMComponents,o.hasCustomElement,d)}if(!isPrefabProject(t)){if(p){const i=getLayoutsDirPath(e);for(let s of a)await generateLayoutComponent(i,t,s.name,s.type,r,s.prefabName,e,m,p,n,o)}for(let a of n)await generatePagePartialComponent(g,t,a.name,a.type,r,a.prefabName,e,m,p)}},generateLayoutComponent=async(e,t,a,n,o,i,r,s,m,p,g)=>{await generatePagePartialComponent(e,t,a,n,o,i,r,s,m,p,g)};module.exports={generateComponents:generateComponents,generatePagePartialComponent:generatePagePartialComponent};
|