lwc-convert 1.0.0 → 1.0.1
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/LICENSE +21 -21
- package/README.md +719 -719
- package/dist/cli/commands/aura.d.ts.map +1 -1
- package/dist/cli/commands/aura.js +10 -0
- package/dist/cli/commands/aura.js.map +1 -1
- package/dist/cli/commands/vf.d.ts.map +1 -1
- package/dist/cli/commands/vf.js +10 -0
- package/dist/cli/commands/vf.js.map +1 -1
- package/dist/cli/interactive.d.ts +1 -0
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +10 -0
- package/dist/cli/interactive.js.map +1 -1
- package/dist/cli/options.d.ts +2 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +14 -13
- package/dist/cli/options.js.map +1 -1
- package/dist/generators/full-conversion.js +6 -6
- package/dist/generators/scaffolding.js +90 -90
- package/dist/generators/test-comparison.js +149 -149
- package/dist/generators/test-generator.js +231 -231
- package/dist/index.js +49 -35
- package/dist/index.js.map +1 -1
- package/dist/transformers/aura-to-lwc/events.js +130 -130
- package/dist/transformers/vf-to-lwc/components.js +79 -79
- package/dist/transformers/vf-to-lwc/data-binding.js +165 -165
- package/dist/utils/file-io.js +15 -15
- package/dist/utils/preview-generator.d.ts +20 -0
- package/dist/utils/preview-generator.d.ts.map +1 -0
- package/dist/utils/preview-generator.js +833 -0
- package/dist/utils/preview-generator.js.map +1 -0
- package/dist/utils/session-store.js +32 -32
- package/package.json +85 -81
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,2CAA2F;AAC3F,8CAAkD;AAClD,0CAA8C;AAC9C,2CAAwC;AACxC,yDAAqD;AAErD,MAAM,OAAO,GAAG,IAAI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CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -40,22 +40,22 @@ function transformAuraEvent(event, handler) {
|
|
|
40
40
|
warnings.push(`"${event.type}" is an application event - consider using pub/sub pattern or Lightning Message Service`);
|
|
41
41
|
}
|
|
42
42
|
// Generate dispatch code
|
|
43
|
-
const dispatchCode = `
|
|
44
|
-
// Fire the ${event.name} event
|
|
45
|
-
this.dispatchEvent(new CustomEvent('${lwcEventName}', {
|
|
46
|
-
detail: {
|
|
47
|
-
// TODO: Add event data properties here
|
|
48
|
-
},
|
|
49
|
-
bubbles: ${isApplicationEvent},
|
|
50
|
-
composed: ${isApplicationEvent}
|
|
43
|
+
const dispatchCode = `
|
|
44
|
+
// Fire the ${event.name} event
|
|
45
|
+
this.dispatchEvent(new CustomEvent('${lwcEventName}', {
|
|
46
|
+
detail: {
|
|
47
|
+
// TODO: Add event data properties here
|
|
48
|
+
},
|
|
49
|
+
bubbles: ${isApplicationEvent},
|
|
50
|
+
composed: ${isApplicationEvent}
|
|
51
51
|
}));`;
|
|
52
52
|
// Generate handler code
|
|
53
53
|
const handlerMethod = handler?.action?.replace('{!c.', '').replace('}', '') || `handle${event.name}`;
|
|
54
|
-
const handlerCode = `
|
|
55
|
-
// Handler for ${event.name} event
|
|
56
|
-
${handlerMethod}(event) {
|
|
57
|
-
const detail = event.detail;
|
|
58
|
-
// TODO: Handle event data
|
|
54
|
+
const handlerCode = `
|
|
55
|
+
// Handler for ${event.name} event
|
|
56
|
+
${handlerMethod}(event) {
|
|
57
|
+
const detail = event.detail;
|
|
58
|
+
// TODO: Handle event data
|
|
59
59
|
}`;
|
|
60
60
|
// Generate parent binding (in parent component's template)
|
|
61
61
|
const parentBinding = `on${lwcEventName}={${handlerMethod}}`;
|
|
@@ -78,141 +78,141 @@ function transformAuraEvent(event, handler) {
|
|
|
78
78
|
* Generate pub/sub utility for application events
|
|
79
79
|
*/
|
|
80
80
|
function generatePubSubUtility() {
|
|
81
|
-
return `/**
|
|
82
|
-
* Pub/Sub utility for component communication
|
|
83
|
-
* Use this when converting Aura application events that need cross-component communication
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
const events = {};
|
|
87
|
-
|
|
88
|
-
const registerListener = (eventName, callback, thisArg) => {
|
|
89
|
-
if (!events[eventName]) {
|
|
90
|
-
events[eventName] = [];
|
|
91
|
-
}
|
|
92
|
-
const duplicate = events[eventName].find((listener) => {
|
|
93
|
-
return listener.callback === callback && listener.thisArg === thisArg;
|
|
94
|
-
});
|
|
95
|
-
if (!duplicate) {
|
|
96
|
-
events[eventName].push({ callback, thisArg });
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const unregisterListener = (eventName, callback, thisArg) => {
|
|
101
|
-
if (events[eventName]) {
|
|
102
|
-
events[eventName] = events[eventName].filter(
|
|
103
|
-
(listener) =>
|
|
104
|
-
listener.callback !== callback || listener.thisArg !== thisArg
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const unregisterAllListeners = (thisArg) => {
|
|
110
|
-
Object.keys(events).forEach((eventName) => {
|
|
111
|
-
events[eventName] = events[eventName].filter(
|
|
112
|
-
(listener) => listener.thisArg !== thisArg
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const fireEvent = (eventName, detail) => {
|
|
118
|
-
if (events[eventName]) {
|
|
119
|
-
events[eventName].forEach((listener) => {
|
|
120
|
-
try {
|
|
121
|
-
listener.callback.call(listener.thisArg, detail);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.error('Error in event listener:', error);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export { registerListener, unregisterListener, unregisterAllListeners, fireEvent };
|
|
81
|
+
return `/**
|
|
82
|
+
* Pub/Sub utility for component communication
|
|
83
|
+
* Use this when converting Aura application events that need cross-component communication
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
const events = {};
|
|
87
|
+
|
|
88
|
+
const registerListener = (eventName, callback, thisArg) => {
|
|
89
|
+
if (!events[eventName]) {
|
|
90
|
+
events[eventName] = [];
|
|
91
|
+
}
|
|
92
|
+
const duplicate = events[eventName].find((listener) => {
|
|
93
|
+
return listener.callback === callback && listener.thisArg === thisArg;
|
|
94
|
+
});
|
|
95
|
+
if (!duplicate) {
|
|
96
|
+
events[eventName].push({ callback, thisArg });
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const unregisterListener = (eventName, callback, thisArg) => {
|
|
101
|
+
if (events[eventName]) {
|
|
102
|
+
events[eventName] = events[eventName].filter(
|
|
103
|
+
(listener) =>
|
|
104
|
+
listener.callback !== callback || listener.thisArg !== thisArg
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const unregisterAllListeners = (thisArg) => {
|
|
110
|
+
Object.keys(events).forEach((eventName) => {
|
|
111
|
+
events[eventName] = events[eventName].filter(
|
|
112
|
+
(listener) => listener.thisArg !== thisArg
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const fireEvent = (eventName, detail) => {
|
|
118
|
+
if (events[eventName]) {
|
|
119
|
+
events[eventName].forEach((listener) => {
|
|
120
|
+
try {
|
|
121
|
+
listener.callback.call(listener.thisArg, detail);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error('Error in event listener:', error);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export { registerListener, unregisterListener, unregisterAllListeners, fireEvent };
|
|
130
130
|
`;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Generate Lightning Message Service channel definition
|
|
134
134
|
*/
|
|
135
135
|
function generateMessageChannel(eventName, description) {
|
|
136
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
137
|
-
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
138
|
-
<description>${description || `Message channel for ${eventName} communication`}</description>
|
|
139
|
-
<isExposed>true</isExposed>
|
|
140
|
-
<lightningMessageFields>
|
|
141
|
-
<description>The payload of the message</description>
|
|
142
|
-
<fieldName>payload</fieldName>
|
|
143
|
-
</lightningMessageFields>
|
|
144
|
-
<masterLabel>${eventName}</masterLabel>
|
|
145
|
-
</LightningMessageChannel>
|
|
136
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
137
|
+
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
138
|
+
<description>${description || `Message channel for ${eventName} communication`}</description>
|
|
139
|
+
<isExposed>true</isExposed>
|
|
140
|
+
<lightningMessageFields>
|
|
141
|
+
<description>The payload of the message</description>
|
|
142
|
+
<fieldName>payload</fieldName>
|
|
143
|
+
</lightningMessageFields>
|
|
144
|
+
<masterLabel>${eventName}</masterLabel>
|
|
145
|
+
</LightningMessageChannel>
|
|
146
146
|
`;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Generate LMS usage code for publishing
|
|
150
150
|
*/
|
|
151
151
|
function generateLmsPublishCode(channelName) {
|
|
152
|
-
return `
|
|
153
|
-
// Import the message channel
|
|
154
|
-
import { publish, MessageContext } from 'lightning/messageService';
|
|
155
|
-
import ${channelName.toUpperCase()}_CHANNEL from '@salesforce/messageChannel/${channelName}__c';
|
|
156
|
-
|
|
157
|
-
// Wire the message context
|
|
158
|
-
@wire(MessageContext)
|
|
159
|
-
messageContext;
|
|
160
|
-
|
|
161
|
-
// Publish a message
|
|
162
|
-
publishMessage(data) {
|
|
163
|
-
const message = {
|
|
164
|
-
payload: data
|
|
165
|
-
};
|
|
166
|
-
publish(this.messageContext, ${channelName.toUpperCase()}_CHANNEL, message);
|
|
152
|
+
return `
|
|
153
|
+
// Import the message channel
|
|
154
|
+
import { publish, MessageContext } from 'lightning/messageService';
|
|
155
|
+
import ${channelName.toUpperCase()}_CHANNEL from '@salesforce/messageChannel/${channelName}__c';
|
|
156
|
+
|
|
157
|
+
// Wire the message context
|
|
158
|
+
@wire(MessageContext)
|
|
159
|
+
messageContext;
|
|
160
|
+
|
|
161
|
+
// Publish a message
|
|
162
|
+
publishMessage(data) {
|
|
163
|
+
const message = {
|
|
164
|
+
payload: data
|
|
165
|
+
};
|
|
166
|
+
publish(this.messageContext, ${channelName.toUpperCase()}_CHANNEL, message);
|
|
167
167
|
}`;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Generate LMS usage code for subscribing
|
|
171
171
|
*/
|
|
172
172
|
function generateLmsSubscribeCode(channelName) {
|
|
173
|
-
return `
|
|
174
|
-
// Import the message channel
|
|
175
|
-
import {
|
|
176
|
-
subscribe,
|
|
177
|
-
unsubscribe,
|
|
178
|
-
APPLICATION_SCOPE,
|
|
179
|
-
MessageContext
|
|
180
|
-
} from 'lightning/messageService';
|
|
181
|
-
import ${channelName.toUpperCase()}_CHANNEL from '@salesforce/messageChannel/${channelName}__c';
|
|
182
|
-
|
|
183
|
-
// Wire the message context
|
|
184
|
-
@wire(MessageContext)
|
|
185
|
-
messageContext;
|
|
186
|
-
|
|
187
|
-
subscription = null;
|
|
188
|
-
|
|
189
|
-
// Subscribe in connectedCallback
|
|
190
|
-
connectedCallback() {
|
|
191
|
-
this.subscribeToChannel();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
subscribeToChannel() {
|
|
195
|
-
if (!this.subscription) {
|
|
196
|
-
this.subscription = subscribe(
|
|
197
|
-
this.messageContext,
|
|
198
|
-
${channelName.toUpperCase()}_CHANNEL,
|
|
199
|
-
(message) => this.handleMessage(message),
|
|
200
|
-
{ scope: APPLICATION_SCOPE }
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
handleMessage(message) {
|
|
206
|
-
const payload = message.payload;
|
|
207
|
-
// TODO: Handle the received message
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Unsubscribe in disconnectedCallback
|
|
211
|
-
disconnectedCallback() {
|
|
212
|
-
if (this.subscription) {
|
|
213
|
-
unsubscribe(this.subscription);
|
|
214
|
-
this.subscription = null;
|
|
215
|
-
}
|
|
173
|
+
return `
|
|
174
|
+
// Import the message channel
|
|
175
|
+
import {
|
|
176
|
+
subscribe,
|
|
177
|
+
unsubscribe,
|
|
178
|
+
APPLICATION_SCOPE,
|
|
179
|
+
MessageContext
|
|
180
|
+
} from 'lightning/messageService';
|
|
181
|
+
import ${channelName.toUpperCase()}_CHANNEL from '@salesforce/messageChannel/${channelName}__c';
|
|
182
|
+
|
|
183
|
+
// Wire the message context
|
|
184
|
+
@wire(MessageContext)
|
|
185
|
+
messageContext;
|
|
186
|
+
|
|
187
|
+
subscription = null;
|
|
188
|
+
|
|
189
|
+
// Subscribe in connectedCallback
|
|
190
|
+
connectedCallback() {
|
|
191
|
+
this.subscribeToChannel();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
subscribeToChannel() {
|
|
195
|
+
if (!this.subscription) {
|
|
196
|
+
this.subscription = subscribe(
|
|
197
|
+
this.messageContext,
|
|
198
|
+
${channelName.toUpperCase()}_CHANNEL,
|
|
199
|
+
(message) => this.handleMessage(message),
|
|
200
|
+
{ scope: APPLICATION_SCOPE }
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
handleMessage(message) {
|
|
206
|
+
const payload = message.payload;
|
|
207
|
+
// TODO: Handle the received message
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Unsubscribe in disconnectedCallback
|
|
211
|
+
disconnectedCallback() {
|
|
212
|
+
if (this.subscription) {
|
|
213
|
+
unsubscribe(this.subscription);
|
|
214
|
+
this.subscription = null;
|
|
215
|
+
}
|
|
216
216
|
}`;
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
@@ -17,15 +17,15 @@ const formComponentMappings = {
|
|
|
17
17
|
lwc: 'lightning-input',
|
|
18
18
|
codeGen: (attrs) => ({
|
|
19
19
|
vfField: { name: 'apex:inputText', attributes: attrs, children: [], location: {} },
|
|
20
|
-
lwcCode: `<lightning-input
|
|
21
|
-
type="text"
|
|
22
|
-
label="${attrs.label || 'Input'}"
|
|
23
|
-
value={${getPropertyName(attrs.value)}}
|
|
24
|
-
onchange={${getHandlerName(attrs.value)}}
|
|
20
|
+
lwcCode: `<lightning-input
|
|
21
|
+
type="text"
|
|
22
|
+
label="${attrs.label || 'Input'}"
|
|
23
|
+
value={${getPropertyName(attrs.value)}}
|
|
24
|
+
onchange={${getHandlerName(attrs.value)}}
|
|
25
25
|
></lightning-input>`,
|
|
26
26
|
jsProperty: `${getPropertyName(attrs.value)} = '';`,
|
|
27
|
-
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
28
|
-
this.${getPropertyName(attrs.value)} = event.target.value;
|
|
27
|
+
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
28
|
+
this.${getPropertyName(attrs.value)} = event.target.value;
|
|
29
29
|
}`,
|
|
30
30
|
warnings: [],
|
|
31
31
|
}),
|
|
@@ -34,14 +34,14 @@ const formComponentMappings = {
|
|
|
34
34
|
lwc: 'lightning-textarea',
|
|
35
35
|
codeGen: (attrs) => ({
|
|
36
36
|
vfField: { name: 'apex:inputTextarea', attributes: attrs, children: [], location: {} },
|
|
37
|
-
lwcCode: `<lightning-textarea
|
|
38
|
-
label="${attrs.label || 'Text Area'}"
|
|
39
|
-
value={${getPropertyName(attrs.value)}}
|
|
40
|
-
onchange={${getHandlerName(attrs.value)}}
|
|
37
|
+
lwcCode: `<lightning-textarea
|
|
38
|
+
label="${attrs.label || 'Text Area'}"
|
|
39
|
+
value={${getPropertyName(attrs.value)}}
|
|
40
|
+
onchange={${getHandlerName(attrs.value)}}
|
|
41
41
|
></lightning-textarea>`,
|
|
42
42
|
jsProperty: `${getPropertyName(attrs.value)} = '';`,
|
|
43
|
-
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
44
|
-
this.${getPropertyName(attrs.value)} = event.target.value;
|
|
43
|
+
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
44
|
+
this.${getPropertyName(attrs.value)} = event.target.value;
|
|
45
45
|
}`,
|
|
46
46
|
warnings: [],
|
|
47
47
|
}),
|
|
@@ -51,15 +51,15 @@ const formComponentMappings = {
|
|
|
51
51
|
type: 'checkbox',
|
|
52
52
|
codeGen: (attrs) => ({
|
|
53
53
|
vfField: { name: 'apex:inputCheckbox', attributes: attrs, children: [], location: {} },
|
|
54
|
-
lwcCode: `<lightning-input
|
|
55
|
-
type="checkbox"
|
|
56
|
-
label="${attrs.label || 'Checkbox'}"
|
|
57
|
-
checked={${getPropertyName(attrs.value || attrs.selected)}}
|
|
58
|
-
onchange={${getHandlerName(attrs.value || attrs.selected)}}
|
|
54
|
+
lwcCode: `<lightning-input
|
|
55
|
+
type="checkbox"
|
|
56
|
+
label="${attrs.label || 'Checkbox'}"
|
|
57
|
+
checked={${getPropertyName(attrs.value || attrs.selected)}}
|
|
58
|
+
onchange={${getHandlerName(attrs.value || attrs.selected)}}
|
|
59
59
|
></lightning-input>`,
|
|
60
60
|
jsProperty: `${getPropertyName(attrs.value || attrs.selected)} = false;`,
|
|
61
|
-
handlerCode: `${getHandlerName(attrs.value || attrs.selected)}(event) {
|
|
62
|
-
this.${getPropertyName(attrs.value || attrs.selected)} = event.target.checked;
|
|
61
|
+
handlerCode: `${getHandlerName(attrs.value || attrs.selected)}(event) {
|
|
62
|
+
this.${getPropertyName(attrs.value || attrs.selected)} = event.target.checked;
|
|
63
63
|
}`,
|
|
64
64
|
warnings: [],
|
|
65
65
|
}),
|
|
@@ -71,24 +71,24 @@ const formComponentMappings = {
|
|
|
71
71
|
return {
|
|
72
72
|
vfField: { name: 'apex:selectList', attributes: attrs, children: [], location: {} },
|
|
73
73
|
lwcCode: isMultiple
|
|
74
|
-
? `<lightning-dual-listbox
|
|
75
|
-
label="${attrs.label || 'Select'}"
|
|
76
|
-
source-label="Available"
|
|
77
|
-
selected-label="Selected"
|
|
78
|
-
options={${getPropertyName(attrs.value)}Options}
|
|
79
|
-
value={${getPropertyName(attrs.value)}}
|
|
80
|
-
onchange={${getHandlerName(attrs.value)}}
|
|
74
|
+
? `<lightning-dual-listbox
|
|
75
|
+
label="${attrs.label || 'Select'}"
|
|
76
|
+
source-label="Available"
|
|
77
|
+
selected-label="Selected"
|
|
78
|
+
options={${getPropertyName(attrs.value)}Options}
|
|
79
|
+
value={${getPropertyName(attrs.value)}}
|
|
80
|
+
onchange={${getHandlerName(attrs.value)}}
|
|
81
81
|
></lightning-dual-listbox>`
|
|
82
|
-
: `<lightning-combobox
|
|
83
|
-
label="${attrs.label || 'Select'}"
|
|
84
|
-
options={${getPropertyName(attrs.value)}Options}
|
|
85
|
-
value={${getPropertyName(attrs.value)}}
|
|
86
|
-
onchange={${getHandlerName(attrs.value)}}
|
|
82
|
+
: `<lightning-combobox
|
|
83
|
+
label="${attrs.label || 'Select'}"
|
|
84
|
+
options={${getPropertyName(attrs.value)}Options}
|
|
85
|
+
value={${getPropertyName(attrs.value)}}
|
|
86
|
+
onchange={${getHandlerName(attrs.value)}}
|
|
87
87
|
></lightning-combobox>`,
|
|
88
|
-
jsProperty: `${getPropertyName(attrs.value)} = '';
|
|
88
|
+
jsProperty: `${getPropertyName(attrs.value)} = '';
|
|
89
89
|
${getPropertyName(attrs.value)}Options = []; // TODO: Populate with { label, value } objects`,
|
|
90
|
-
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
91
|
-
this.${getPropertyName(attrs.value)} = event.detail.value;
|
|
90
|
+
handlerCode: `${getHandlerName(attrs.value)}(event) {
|
|
91
|
+
this.${getPropertyName(attrs.value)} = event.detail.value;
|
|
92
92
|
}`,
|
|
93
93
|
warnings: isMultiple
|
|
94
94
|
? ['Multi-select converted to lightning-dual-listbox']
|
|
@@ -100,15 +100,15 @@ ${getPropertyName(attrs.value)}Options = []; // TODO: Populate with { label, val
|
|
|
100
100
|
lwc: 'lightning-button',
|
|
101
101
|
codeGen: (attrs) => ({
|
|
102
102
|
vfField: { name: 'apex:commandButton', attributes: attrs, children: [], location: {} },
|
|
103
|
-
lwcCode: `<lightning-button
|
|
104
|
-
label="${attrs.value || 'Submit'}"
|
|
105
|
-
variant="${attrs.styleclass?.includes('btn-primary') ? 'brand' : 'neutral'}"
|
|
106
|
-
onclick={${getHandlerName(attrs.action)}}
|
|
103
|
+
lwcCode: `<lightning-button
|
|
104
|
+
label="${attrs.value || 'Submit'}"
|
|
105
|
+
variant="${attrs.styleclass?.includes('btn-primary') ? 'brand' : 'neutral'}"
|
|
106
|
+
onclick={${getHandlerName(attrs.action)}}
|
|
107
107
|
></lightning-button>`,
|
|
108
108
|
jsProperty: '',
|
|
109
|
-
handlerCode: `async ${getHandlerName(attrs.action)}() {
|
|
110
|
-
// TODO: Implement button action
|
|
111
|
-
// Original Apex action: ${attrs.action}
|
|
109
|
+
handlerCode: `async ${getHandlerName(attrs.action)}() {
|
|
110
|
+
// TODO: Implement button action
|
|
111
|
+
// Original Apex action: ${attrs.action}
|
|
112
112
|
}`,
|
|
113
113
|
warnings: ['Button action needs conversion to imperative Apex call'],
|
|
114
114
|
}),
|
|
@@ -238,11 +238,11 @@ function suggestLwcComponents(vfComponents) {
|
|
|
238
238
|
confidenceScore: score,
|
|
239
239
|
confidenceFactors: [reason],
|
|
240
240
|
notes: 'Use lightning-record-form with mode="view" or "edit"',
|
|
241
|
-
codeExample: `<lightning-record-form
|
|
242
|
-
record-id={recordId}
|
|
243
|
-
object-api-name="Account"
|
|
244
|
-
layout-type="Full"
|
|
245
|
-
mode="view">
|
|
241
|
+
codeExample: `<lightning-record-form
|
|
242
|
+
record-id={recordId}
|
|
243
|
+
object-api-name="Account"
|
|
244
|
+
layout-type="Full"
|
|
245
|
+
mode="view">
|
|
246
246
|
</lightning-record-form>`,
|
|
247
247
|
});
|
|
248
248
|
}
|
|
@@ -255,9 +255,9 @@ function suggestLwcComponents(vfComponents) {
|
|
|
255
255
|
confidenceScore: score,
|
|
256
256
|
confidenceFactors: [reason],
|
|
257
257
|
notes: 'Direct LWC equivalent available',
|
|
258
|
-
codeExample: `<lightning-related-list-view
|
|
259
|
-
related-list-id="Contacts"
|
|
260
|
-
record-id={recordId}>
|
|
258
|
+
codeExample: `<lightning-related-list-view
|
|
259
|
+
related-list-id="Contacts"
|
|
260
|
+
record-id={recordId}>
|
|
261
261
|
</lightning-related-list-view>`,
|
|
262
262
|
});
|
|
263
263
|
}
|
|
@@ -325,8 +325,8 @@ function generateDataTableColumns(tableComponent) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
const columnsCode = `columns = [
|
|
329
|
-
${columns.map((col) => ` { label: '${col.label}', fieldName: '${col.fieldName}'${col.type ? `, type: '${col.type}'` : ''} }`).join(',\n')}
|
|
328
|
+
const columnsCode = `columns = [
|
|
329
|
+
${columns.map((col) => ` { label: '${col.label}', fieldName: '${col.fieldName}'${col.type ? `, type: '${col.type}'` : ''} }`).join(',\n')}
|
|
330
330
|
];`;
|
|
331
331
|
return { columns: columnsCode, warnings };
|
|
332
332
|
}
|
|
@@ -342,33 +342,33 @@ function generateFormHandler(formComponent, _apexAction) {
|
|
|
342
342
|
return ` ${propName}: this.${propName}`;
|
|
343
343
|
})
|
|
344
344
|
.join(',\n');
|
|
345
|
-
return `async handleSubmit(event) {
|
|
346
|
-
event.preventDefault();
|
|
347
|
-
|
|
348
|
-
try {
|
|
349
|
-
const formData = {
|
|
350
|
-
${fieldAssignments}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// TODO: Call Apex method
|
|
354
|
-
// const result = await saveRecord({ data: formData });
|
|
355
|
-
|
|
356
|
-
this.dispatchEvent(
|
|
357
|
-
new ShowToastEvent({
|
|
358
|
-
title: 'Success',
|
|
359
|
-
message: 'Record saved successfully',
|
|
360
|
-
variant: 'success'
|
|
361
|
-
})
|
|
362
|
-
);
|
|
363
|
-
} catch (error) {
|
|
364
|
-
this.dispatchEvent(
|
|
365
|
-
new ShowToastEvent({
|
|
366
|
-
title: 'Error',
|
|
367
|
-
message: error.body?.message || 'An error occurred',
|
|
368
|
-
variant: 'error'
|
|
369
|
-
})
|
|
370
|
-
);
|
|
371
|
-
}
|
|
345
|
+
return `async handleSubmit(event) {
|
|
346
|
+
event.preventDefault();
|
|
347
|
+
|
|
348
|
+
try {
|
|
349
|
+
const formData = {
|
|
350
|
+
${fieldAssignments}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// TODO: Call Apex method
|
|
354
|
+
// const result = await saveRecord({ data: formData });
|
|
355
|
+
|
|
356
|
+
this.dispatchEvent(
|
|
357
|
+
new ShowToastEvent({
|
|
358
|
+
title: 'Success',
|
|
359
|
+
message: 'Record saved successfully',
|
|
360
|
+
variant: 'success'
|
|
361
|
+
})
|
|
362
|
+
);
|
|
363
|
+
} catch (error) {
|
|
364
|
+
this.dispatchEvent(
|
|
365
|
+
new ShowToastEvent({
|
|
366
|
+
title: 'Error',
|
|
367
|
+
message: error.body?.message || 'An error occurred',
|
|
368
|
+
variant: 'error'
|
|
369
|
+
})
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
372
|
}`;
|
|
373
373
|
}
|
|
374
374
|
//# sourceMappingURL=components.js.map
|