@cloudbase/framework-plugin-low-code 0.6.0 → 0.6.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,eAAe,EAEf,aAAa,EAEb,kBAAkB,EAWlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAGL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGxF,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAE7D,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,iBAwBpB;AAED,wBAAsB,qBAAqB,CACzC,SAAS,oBAAa,EACtB,WAAW,EAAE,MAAM,iBAiBpB;AAED,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,aAAa,EAAE,EACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,6BAAsB,EAClC,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,aAAa,EAAE,GAAG,EAAE,iBAcrB;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,6BAAsB,EAClC,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,aAAa,EAAE,GAAG,EAAE,iBAyGrB;AAED,wBAAgB,+BAA+B,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AE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,EAAO,EACR,oBAAoB,GAAE,MAAM,EAAO,YAepC;AAED,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,cAAc,EAAE,EAClC,qBAAqB,GAAE,MAAM,EAAO,YAQrC;AAED,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,cAAc,EAChC,qBAAqB,EAAE,MAAM,EAAE,QAqBhC;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAK,EACb,aAAa,GAAE,SAAS,EAAO,iBAwChC;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,iBAuCpB;AAED,wBAAsB,iCAAiC,CACrD,eAAe,EAAE,aAAa,EAAE,EAChC,WAAW,EAAE,MAAM,iBA6EpB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,aAAa,EAAE,EAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,KAAA,EACR,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,SAAS,EAAE,EAC1B,SAAS,KAAA,iBAkFV"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,eAAe,EAEf,aAAa,EAEb,kBAAkB,EAWlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAGL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,WAAW,EAAE,MAAM,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AE,MAAM,iBAuCpB;AAED,wBAAsB,iCAAiC,CACrD,eAAe,EAAE,aAAa,EAAE,EAChC,WAAW,EAAE,MAAM,iBA6EpB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,aAAa,EAAE,EAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,KAAA,EACR,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,SAAS,EAAE,EAC1B,SAAS,KAAA,iBAkFV"}
@@ -254,19 +254,22 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
254
254
  const compWidgets = {};
255
255
  const compDataBinds = {};
256
256
  const componentSchemaJson = util_1.deepDealSchema(copyJson, (schema) => {
257
- var _a, _b, _c, _d, _e, _f, _g;
257
+ var _a, _b, _c, _d, _e, _f, _g, _h;
258
258
  const { 'x-props': xProps = {}, properties } = schema;
259
259
  const { dataBinds = [], commonStyle = {}, data = {}, classNameList = [], sourceKey, styleBind, classNameListBind, staticResourceAttribute = [], } = xProps;
260
260
  const componentInfo = componentsInfoMap[sourceKey];
261
- if ((_a = componentInfo) === null || _a === void 0 ? void 0 : _a.events) {
262
- schema['emitEvents'] = (_b = componentInfo) === null || _b === void 0 ? void 0 : _b.events.map((item) => item.name);
261
+ if ((_a = componentInfo) === null || _a === void 0 ? void 0 : _a.selectableBlock) {
262
+ schema['selectableBlock'] = componentInfo['selectableBlock'];
263
263
  }
264
- else if ((_c = componentInfo) === null || _c === void 0 ? void 0 : _c.emitEvents) {
264
+ if ((_b = componentInfo) === null || _b === void 0 ? void 0 : _b.events) {
265
+ schema['emitEvents'] = (_c = componentInfo) === null || _c === void 0 ? void 0 : _c.events.map((item) => item.name);
266
+ }
267
+ else if ((_d = componentInfo) === null || _d === void 0 ? void 0 : _d.emitEvents) {
265
268
  schema['emitEvents'] = componentInfo.emitEvents.map((item) => item.eventName);
266
269
  }
267
270
  if (!isSlot(schema) && schema.key) {
268
271
  compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style: weapps_core_1.toCssStyle(commonStyle), classList: classNameList, widgetType: sourceKey, _parentId: isSlot(schema.parent)
269
- ? (_e = (_d = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.key : (_f = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _f === void 0 ? void 0 : _f.key });
272
+ ? (_f = (_e = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _e === void 0 ? void 0 : _e.parent) === null || _f === void 0 ? void 0 : _f.key : (_g = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _g === void 0 ? void 0 : _g.key });
270
273
  if (dataBinds.length > 0) {
271
274
  compDataBinds[schema.key] = generateDataBinds(dataBinds, isComposite);
272
275
  }
@@ -288,9 +291,26 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
288
291
  delete schema.properties;
289
292
  }
290
293
  delete schema.type;
294
+ if (compWidgets[schema.key]) {
295
+ const propsKeys = Object.keys(compWidgets[schema.key]);
296
+ propsKeys.forEach((propsKey) => {
297
+ const propsVaule = compWidgets[schema.key][propsKey];
298
+ if (propsVaule && Array.isArray(propsVaule)) {
299
+ propsVaule.map((block) => {
300
+ var _a, _b;
301
+ const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) && ((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
302
+ if (blockInstance) {
303
+ block.selectableBlock['x-props'].listenerInstances =
304
+ generateListnerInstances(blockInstance, isComposite);
305
+ }
306
+ return block;
307
+ });
308
+ }
309
+ });
310
+ }
291
311
  if (xProps) {
292
312
  if (isComposite) {
293
- if (!((_g = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _g === void 0 ? void 0 : _g.parent)) {
313
+ if (!((_h = schema === null || schema === void 0 ? void 0 : schema.parent) === null || _h === void 0 ? void 0 : _h.parent)) {
294
314
  if (!xProps['classNameList'])
295
315
  xProps['classNameList'] = [];
296
316
  xProps['classNameList'].push(wrapperClass);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/generator/core/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGV,oBAAoB,EAEpB,iBAAiB,EACjB,aAAa,EACb,aAAa,EAGb,kBAAkB,EAIlB,UAAU,EACV,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AASxD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMnD,wBAAsB,eAAe,CAAC,KAAK,EAAE;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACrC,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE;QACT,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,GAAG,CAAC;KAChB,CAAC;IACF,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,YAAY,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB,iBA2FA;AA4BD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAA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aString(componentSchema, isComposite = false, componen
202
202
  const compWidgets = {};
203
203
  const compDataBinds = {};
204
204
  const componentSchemaJson = util_1.deepDealSchema(copyJson, (schema) => {
205
- var _a, _b, _c, _d, _e;
205
+ var _a, _b, _c, _d, _e, _f;
206
206
  const { 'x-props': xProps = {}, properties } = schema;
207
207
  const { dataBinds = [], commonStyle = {}, data = {}, classNameList = [], sourceKey, styleBind, classNameListBind, } = xProps;
208
208
  const componentInfo = componentsInfoMap[sourceKey];
209
- if ((_a = componentInfo) === null || _a === void 0 ? void 0 : _a.events) {
210
- schema['emitEvents'] = (_b = componentInfo) === null || _b === void 0 ? void 0 : _b.events.map((item) => item.name);
209
+ if ((_a = componentInfo) === null || _a === void 0 ? void 0 : _a.selectableBlock) {
210
+ schema['selectableBlock'] = componentInfo['selectableBlock'];
211
+ }
212
+ if ((_b = componentInfo) === null || _b === void 0 ? void 0 : _b.events) {
213
+ schema['emitEvents'] = (_c = componentInfo) === null || _c === void 0 ? void 0 : _c.events.map((item) => item.name);
211
214
  }
212
- else if ((_c = componentInfo) === null || _c === void 0 ? void 0 : _c.emitEvents) {
215
+ else if ((_d = componentInfo) === null || _d === void 0 ? void 0 : _d.emitEvents) {
213
216
  schema['emitEvents'] = componentInfo.emitEvents.map((item) => item.eventName);
214
217
  }
215
218
  if (!isSlot(schema) && schema.key) {
216
219
  const parentSchema = schema.parent;
217
220
  compWidgets[schema.key] = Object.assign(Object.assign({}, data), { style: weapps_core_1.toCssStyle(commonStyle), classList: classNameList, widgetType: sourceKey, _parentId: isSlot(parentSchema)
218
- ? (_d = parentSchema.parent) === null || _d === void 0 ? void 0 : _d.key : parentSchema.key });
221
+ ? (_e = parentSchema.parent) === null || _e === void 0 ? void 0 : _e.key : parentSchema.key });
219
222
  if (dataBinds.length > 0) {
220
223
  compDataBinds[schema.key] = generateDataBinds(dataBinds, isComposite);
221
224
  }
@@ -242,9 +245,26 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
242
245
  delete schema.properties;
243
246
  }
244
247
  delete schema.type;
248
+ if (compWidgets[schema.key]) {
249
+ const propsKeys = Object.keys(compWidgets[schema.key]);
250
+ propsKeys.forEach((propsKey) => {
251
+ const propsVaule = compWidgets[schema.key][propsKey];
252
+ if (propsVaule && Array.isArray(propsVaule)) {
253
+ propsVaule.map((block) => {
254
+ var _a, _b;
255
+ const blockInstance = (block === null || block === void 0 ? void 0 : block.selectableBlock) && ((_b = (_a = block === null || block === void 0 ? void 0 : block.selectableBlock) === null || _a === void 0 ? void 0 : _a['x-props']) === null || _b === void 0 ? void 0 : _b.listenerInstances);
256
+ if (blockInstance) {
257
+ block.selectableBlock['x-props'].listenerInstances =
258
+ generateListnerInstances(blockInstance, isComposite);
259
+ }
260
+ return block;
261
+ });
262
+ }
263
+ });
264
+ }
245
265
  if (xProps) {
246
266
  if (isComposite) {
247
- if (!((_e = schema.parent) === null || _e === void 0 ? void 0 : _e.parent)) {
267
+ if (!((_f = schema.parent) === null || _f === void 0 ? void 0 : _f.parent)) {
248
268
  if (!xProps['classNameList'])
249
269
  xProps['classNameList'] = [];
250
270
  xProps['classNameList'].push(wrapperClass);
@@ -23,10 +23,10 @@ exports.default = {
23
23
  "code": "import { setConfig, initTcb, CLOUD_SDK } from '@cloudbase/weda-cloud-sdk/dist/h5';\nimport config from './config';\nexport {\n createDataset,\n createStateDataSourceVar,\n generateParamsParser,\n EXTRA_API,\n CLOUD_SDK,\n DS_API,\n DS_SDK,\n} from '@cloudbase/weda-cloud-sdk/dist/h5';\n\nsetConfig(config);\ninitTcb();\n"
24
24
  },
25
25
  "/src/handlers/NodeRenderer.jsx": {
26
- "code": "import * as React from 'react';\nimport { useContext, useCallback, createContext } from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { emitEvent, translateStyleToRem, checkVisible } from '../utils';\nimport { get, set } from 'lodash';\nimport { getDom } from '../utils/widgets';\n\nexport const ForContext = createContext({});\n\nexport const CompRenderer = observer(function (props) {\n const {\n id: compId,\n xProps,\n virtualFields,\n slots = {},\n codeContext = {},\n scopeContext = {},\n genericComp = {},\n emitEvents = [],\n } = props;\n const isInComposite = !!codeContext.$WEAPPS_COMP;\n // 判断 widgets 是从 page 来的,还是组件来的\n const widgetsData = !isInComposite\n ? codeContext.$page.widgets[compId]\n : codeContext.$WEAPPS_COMP.widgets[compId];\n\n const isRootNode = widgetsData && !widgetsData.parent;\n\n if (!xProps) {\n return props.children;\n }\n\n const {\n commonStyle = {},\n sourceKey,\n listenerInstances,\n classNameList = [],\n staticResourceAttribute = [],\n } = xProps;\n const dataBinds =\n (codeContext._dataBinds && codeContext._dataBinds[compId]) || {};\n const FieldKey = genericComp.propName\n ? codeContext.node[genericComp.propName]\n : sourceKey;\n const Field = virtualFields[FieldKey];\n const parentForItems = useContext(ForContext);\n\n // 最终用于执行的事件函数\n const emit = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext) => {\n const listeners = listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n function getSafeComponentProps({\n style,\n classNameList,\n staticResourceAttribute,\n }) {\n const componentProps = {};\n if (classNameList.length) {\n componentProps.className = classNameList.join(' ');\n }\n\n if (style && Object.keys(style).length) {\n componentProps.style = style;\n }\n\n if (staticResourceAttribute && staticResourceAttribute.length > 0) {\n componentProps.staticResourceAttribute = staticResourceAttribute;\n }\n return componentProps;\n }\n\n // For循环渲染\n let forList;\n try {\n forList = dataBinds && dataBinds._waFor && dataBinds._waFor(parentForItems);\n } catch (e) {\n forList = [];\n console.error('_waFor data', e);\n }\n if (forList) {\n if (!Array.isArray(forList)) {\n console.warn(`${compId}循环绑定非数组值:`, forList);\n forList = [];\n }\n return forList.map((item, index) => {\n const forItemsIndexes = (parentForItems.forIndexes || []).concat(index);\n const forItems = {\n ...parentForItems,\n [compId]: item,\n forIndexes: forItemsIndexes,\n };\n const {\n fieldData: forItemData,\n finalStyle: forItemStyle,\n finalClassNameList: forItemClassNameList,\n } = getBindData(forItems, scopeContext);\n if (!checkVisible(forItemData)) {\n return null;\n }\n // 多个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(forItemData, slotProp, slots[slotProp]);\n });\n const emitWithForItems = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, forItems, domEvent, scopeContext);\n delete forItemData.style;\n\n // 获取当前元素的 ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forItemsIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n return (\n <ForContext.Provider key={index} value={forItems}>\n <Field\n data={forItemData}\n id={compId}\n {...getSafeComponentProps({\n style: forItemStyle,\n classNameList: forItemClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithForItems}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forItemsIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n </ForContext.Provider>\n );\n });\n }\n\n // 单节点渲染\n const { fieldData, finalClassNameList, finalStyle } = getBindData(\n parentForItems,\n scopeContext\n );\n const emitWithFiedle = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, parentForItems, domEvent, scopeContext);\n\n // false 或空字符串时\n if (!checkVisible(fieldData)) {\n return null;\n }\n\n // 单个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(fieldData, slotProp, slots[slotProp]);\n });\n\n // 防止渲染时 data 的 style 与实际的 style 冲突\n delete fieldData.style;\n\n // 修正 forIndexes\n const forIndexes = getForIndexes(parentForItems, widgetsData);\n\n // 获取 Element Ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n\n return (\n <Field\n data={fieldData}\n id={compId}\n {...getSafeComponentProps({\n style: finalStyle,\n classNameList: finalClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithFiedle}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n );\n\n // TODO: 需要不断移除 dataBinds(style/classList)\n function getBindData(forItems, scopeContext) {\n // bindData\n let wData = widgetsData;\n if (Array.isArray(wData)) {\n wData =\n forItems.forIndexes === void 0 || wData.length === 0\n ? {}\n : get(wData, getForIndexes(forItems, wData));\n }\n wData = wData || {};\n const fieldData = { ...wData };\n\n // 再次计算 scope value\n for (let key in fieldData) {\n if (Object.prototype.hasOwnProperty.call(fieldData, key)) {\n const value = fieldData[key];\n if (value && value.__type === 'scopedValue') {\n try {\n fieldData[key] = value.getValue(scopeContext);\n } catch (e) {\n console.warn(`Error computing data bind '${key}' error:`, e);\n fieldData[key] = '';\n }\n }\n }\n }\n\n // bindStyle\n let bindStyle = fieldData.style || {};\n // 复合组件第一层需要将最外层样式 style 挂到节点上\n let cssStyle = commonStyle;\n if (isInComposite && wData && !wData.parent) {\n cssStyle = {\n ...cssStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n bindStyle = {\n ...bindStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n }\n const finalStyle = getFinalStyle(cssStyle, bindStyle);\n\n // bindClassList\n const bindClassList = fieldData.classList || [];\n const finalClassNameList = getFinalClassNameList(\n classNameList,\n bindClassList\n );\n\n // 当前在复合组件中,且当前节点为根节点\n if (isInComposite && isRootNode) {\n if (wData.ownerWidget) {\n Object.keys(wData.ownerWidget).forEach((propName) => {\n if (\n propName === 'role' ||\n ['aria-', 'data-'].some((prefix) => propName.startsWith(prefix))\n ) {\n wData[propName] = wData.ownerWidget[propName];\n }\n });\n }\n }\n\n return { fieldData, finalStyle, finalClassNameList };\n }\n});\n\nexport function getFinalStyle(\n commonStyle = {},\n bindStyle = {},\n widgetStyle = {}\n) {\n const remBindStyle =\n typeof bindStyle === 'object' ? translateStyleToRem(bindStyle) : {};\n\n return {\n ...(translateStyleToRem(commonStyle) || {}),\n ...(translateStyleToRem(widgetStyle) || {}),\n ...remBindStyle,\n };\n}\n\nexport function getFinalClassNameList(\n classNameList = [],\n bindClassList = [],\n widgetClassList = []\n) {\n return [].concat(classNameList, bindClassList, widgetClassList);\n}\n\n// HACK: 从后向前保证循环的深度与 forIndexes 一致\n// 后续需要将 For 循环迁移到外层\nfunction getForIndexes(parentForItems, widgetsData) {\n return Array.isArray(widgetsData) && widgetsData.length > 0\n ? (parentForItems.forIndexes || []).slice(0 - getDeepArrLen(widgetsData))\n : undefined;\n}\n\nfunction getDeepArrLen(arr, len = 0) {\n if (Array.isArray(arr)) {\n return getDeepArrLen(arr[0], len + 1);\n } else {\n return len;\n }\n}\n\nfunction setGetDomApi(currentWidget, props) {\n if (!currentWidget) return React.createRef();\n const isComposite = !currentWidget.widgetType.startsWith('gsd-h5-react');\n const isInComposite = !!(props.codeContext || {}).$WEAPPS_COMP;\n\n // 如果当前是复合组件,不做 getDom 的挂载\n if (!isComposite) {\n if (!currentWidget.domRef) {\n currentWidget.domRef = React.createRef();\n }\n if (!currentWidget.getDom) {\n currentWidget.getDom = (options) =>\n getDom(currentWidget.domRef.current, options);\n }\n\n if (\n isInComposite && // 当前在复合组件内\n !currentWidget.parent && // 当前节点为复合组件的根节点\n props.codeContext.node && // 复合组件的 node 已经创建\n !props.codeContext.node.getDom // 复合组件的 node 未挂载 getDom 方法\n ) {\n props.codeContext.node.domRef = currentWidget.domRef;\n props.codeContext.node.getDom = currentWidget.getDom;\n }\n }\n\n return currentWidget.domRef;\n}\n"
26
+ "code": "import * as React from 'react';\nimport {\n useContext,\n useCallback,\n createContext,\n useState,\n useRef,\n} from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { emitEvent, translateStyleToRem, checkVisible } from '../utils';\nimport { get, set } from 'lodash';\nimport { getDom } from '../utils/widgets';\n\nexport const ForContext = createContext({});\n\nexport const CompRenderer = observer(function (props) {\n const {\n id: compId,\n xProps,\n virtualFields,\n slots = {},\n codeContext = {},\n scopeContext = {},\n genericComp = {},\n emitEvents = [],\n componentSchema = {},\n } = props;\n\n const [blockIndex, setBlockIndex] = useState();\n const [blockType, setBlockType] = useState();\n const indexRef = useRef();\n const typeRef = useRef();\n indexRef.current = blockIndex;\n typeRef.current = blockType;\n\n const isInComposite = !!codeContext.$WEAPPS_COMP;\n // 判断 widgets 是从 page 来的,还是组件来的\n const widgetsData = !isInComposite\n ? codeContext.$page.widgets[compId]\n : codeContext.$WEAPPS_COMP.widgets[compId];\n\n const isRootNode = widgetsData && !widgetsData.parent;\n\n if (!xProps) {\n return props.children;\n }\n\n const {\n commonStyle = {},\n sourceKey,\n listenerInstances,\n classNameList = [],\n staticResourceAttribute = [],\n } = xProps;\n const dataBinds =\n (codeContext._dataBinds && codeContext._dataBinds[compId]) || {};\n const FieldKey = genericComp.propName\n ? codeContext.node[genericComp.propName]\n : sourceKey;\n const Field = virtualFields[FieldKey];\n const parentForItems = useContext(ForContext);\n\n // 组件最终用于执行的事件函数\n const emit = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext) => {\n const listeners = listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n // 选区最终用于执行的事件函数\n const emitSB = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext, fieldData) => {\n const listeners =\n typeRef.current &&\n indexRef.current &&\n fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[\n 'x-props'\n ]?.listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n function getSafeComponentProps({\n style,\n classNameList,\n staticResourceAttribute,\n }) {\n const componentProps = {};\n if (classNameList.length) {\n componentProps.className = classNameList.join(' ');\n }\n\n if (style && Object.keys(style).length) {\n componentProps.style = style;\n }\n\n if (staticResourceAttribute && staticResourceAttribute.length > 0) {\n componentProps.staticResourceAttribute = staticResourceAttribute;\n }\n return componentProps;\n }\n\n // 选区的预览的click事件\n const onCustomEvent = ({ order: index, blockKey }) => {\n if (index) {\n setBlockIndex(index);\n setBlockType(blockKey);\n }\n };\n\n // For循环渲染\n let forList;\n try {\n forList = dataBinds && dataBinds._waFor && dataBinds._waFor(parentForItems);\n } catch (e) {\n forList = [];\n console.error('_waFor data', e);\n }\n if (forList) {\n if (!Array.isArray(forList)) {\n console.warn(`${compId}循环绑定非数组值:`, forList);\n forList = [];\n }\n return forList.map((item, index) => {\n const forItemsIndexes = (parentForItems.forIndexes || []).concat(index);\n const forItems = {\n ...parentForItems,\n [compId]: item,\n forIndexes: forItemsIndexes,\n };\n const {\n fieldData: forItemData,\n finalStyle: forItemStyle,\n finalClassNameList: forItemClassNameList,\n } = getBindData(forItems, scopeContext);\n if (!checkVisible(forItemData)) {\n return null;\n }\n // 多个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(forItemData, slotProp, slots[slotProp]);\n });\n const emitWithForItems = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, forItems, domEvent, scopeContext);\n\n const _selectableBlockEventsForItems = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) ||\n [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n forItems,\n domEvent,\n scopeContext,\n forItemData\n ),\n };\n\n delete forItemData.style;\n\n // 获取当前元素的 ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forItemsIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n return (\n <ForContext.Provider key={index} value={forItems}>\n <Field\n data={{\n ...forItemData,\n _selectableBlockEvents: _selectableBlockEventsForItems,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: forItemStyle,\n classNameList: forItemClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithForItems}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forItemsIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n </ForContext.Provider>\n );\n });\n }\n\n // 单节点渲染\n const { fieldData, finalClassNameList, finalStyle } = getBindData(\n parentForItems,\n scopeContext\n );\n const emitWithFiedle = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, parentForItems, domEvent, scopeContext);\n\n const _selectableBlockEventsWithFiedle = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) || [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n parentForItems,\n domEvent,\n scopeContext,\n fieldData\n ),\n };\n\n // false 或空字符串时\n if (!checkVisible(fieldData)) {\n return null;\n }\n\n // 单个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(fieldData, slotProp, slots[slotProp]);\n });\n\n // 防止渲染时 data 的 style 与实际的 style 冲突\n delete fieldData.style;\n\n // 修正 forIndexes\n const forIndexes = getForIndexes(parentForItems, widgetsData);\n\n // 获取 Element Ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n\n return (\n <Field\n data={{\n ...fieldData,\n _selectableBlockEvents: _selectableBlockEventsWithFiedle,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: finalStyle,\n classNameList: finalClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithFiedle}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n );\n\n // TODO: 需要不断移除 dataBinds(style/classList)\n function getBindData(forItems, scopeContext) {\n // bindData\n let wData = widgetsData;\n if (Array.isArray(wData)) {\n wData =\n forItems.forIndexes === void 0 || wData.length === 0\n ? {}\n : get(wData, getForIndexes(forItems, wData));\n }\n wData = wData || {};\n const fieldData = { ...wData };\n\n // 再次计算 scope value\n for (let key in fieldData) {\n if (Object.prototype.hasOwnProperty.call(fieldData, key)) {\n const value = fieldData[key];\n if (value && value.__type === 'scopedValue') {\n try {\n fieldData[key] = value.getValue(scopeContext);\n } catch (e) {\n console.warn(`Error computing data bind '${key}' error:`, e);\n fieldData[key] = '';\n }\n }\n }\n }\n\n // bindStyle\n let bindStyle = fieldData.style || {};\n // 复合组件第一层需要将最外层样式 style 挂到节点上\n let cssStyle = commonStyle;\n if (isInComposite && wData && !wData.parent) {\n cssStyle = {\n ...cssStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n bindStyle = {\n ...bindStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n }\n const finalStyle = getFinalStyle(cssStyle, bindStyle);\n\n // bindClassList\n const bindClassList = fieldData.classList || [];\n const finalClassNameList = getFinalClassNameList(\n classNameList,\n bindClassList\n );\n\n // 当前在复合组件中,且当前节点为根节点\n if (isInComposite && isRootNode) {\n if (wData.ownerWidget) {\n Object.keys(wData.ownerWidget).forEach((propName) => {\n if (\n propName === 'role' ||\n ['aria-', 'data-'].some((prefix) => propName.startsWith(prefix))\n ) {\n wData[propName] = wData.ownerWidget[propName];\n }\n });\n }\n }\n\n return { fieldData, finalStyle, finalClassNameList };\n }\n});\n\nexport function getFinalStyle(\n commonStyle = {},\n bindStyle = {},\n widgetStyle = {}\n) {\n const remBindStyle =\n typeof bindStyle === 'object' ? translateStyleToRem(bindStyle) : {};\n\n return {\n ...(translateStyleToRem(commonStyle) || {}),\n ...(translateStyleToRem(widgetStyle) || {}),\n ...remBindStyle,\n };\n}\n\nexport function getFinalClassNameList(\n classNameList = [],\n bindClassList = [],\n widgetClassList = []\n) {\n return [].concat(classNameList, bindClassList, widgetClassList);\n}\n\n// HACK: 从后向前保证循环的深度与 forIndexes 一致\n// 后续需要将 For 循环迁移到外层\nfunction getForIndexes(parentForItems, widgetsData) {\n return Array.isArray(widgetsData) && widgetsData.length > 0\n ? (parentForItems.forIndexes || []).slice(0 - getDeepArrLen(widgetsData))\n : undefined;\n}\n\nfunction getDeepArrLen(arr, len = 0) {\n if (Array.isArray(arr)) {\n return getDeepArrLen(arr[0], len + 1);\n } else {\n return len;\n }\n}\n\nfunction setGetDomApi(currentWidget, props) {\n if (!currentWidget) return React.createRef();\n const isComposite = !currentWidget.widgetType.startsWith('gsd-h5-react');\n const isInComposite = !!(props.codeContext || {}).$WEAPPS_COMP;\n\n // 如果当前是复合组件,不做 getDom 的挂载\n if (!isComposite) {\n if (!currentWidget.domRef) {\n currentWidget.domRef = React.createRef();\n }\n if (!currentWidget.getDom) {\n currentWidget.getDom = (options) =>\n getDom(currentWidget.domRef.current, options);\n }\n\n if (\n isInComposite && // 当前在复合组件内\n !currentWidget.parent && // 当前节点为复合组件的根节点\n props.codeContext.node && // 复合组件的 node 已经创建\n !props.codeContext.node.getDom // 复合组件的 node 未挂载 getDom 方法\n ) {\n props.codeContext.node.domRef = currentWidget.domRef;\n props.codeContext.node.getDom = currentWidget.getDom;\n }\n }\n\n return currentWidget.domRef;\n}\n"
27
27
  },
28
28
  "/src/handlers/RenderWrapper.jsx": {
29
- "code": "import * as React from 'react';\nimport { useRef } from 'react';\nimport { CompRenderer } from './NodeRenderer';\nimport lodashSet from 'lodash.set';\nimport cloneDeep from 'lodash.clonedeep';\nimport { isScopeSlot } from '../utils/common';\n\nfunction getComponentChildren(component) {\n const { properties } = component;\n if (!properties) {\n return [];\n }\n return Object.values(properties).sort(\n (a, b) => (a['x-index'] || 0) - (b['x-index'] || 0)\n );\n}\n\nexport function AppRender(props) {\n const {\n className,\n virtualFields,\n componentSchema,\n renderSlot,\n rootNode = true,\n codeContext,\n scopeContext = {},\n } = props;\n const {\n 'x-props': xProps,\n properties = {},\n genericComp = {},\n } = componentSchema;\n // 判断是否为 slot\n const isSlot = !xProps;\n if (isSlot && !(renderSlot || rootNode)) {\n return null;\n }\n\n const preClassName = useRef(); \n\n // wrapperClass\n const containerEl = Object.values(properties)[0];\n if (containerEl && containerEl['x-props'] && className) {\n let { classNameList = [] } = containerEl['x-props'];\n\n // 先替换掉先前计算出来的className部分\n if (preClassName.current) {\n if (preClassName.current !== className) {\n classNameList = classNameList.filter(\n (clsName) => clsName !== preClassName.current\n );\n preClassName.current = className;\n }\n } else {\n preClassName.current = className;\n }\n\n containerEl['x-props'].classNameList = [className, ...classNameList];\n }\n\n if (xProps && xProps.sourceKey) {\n const { sourceKey } = xProps;\n const Field = virtualFields[sourceKey];\n if (!Field) {\n return (\n <div style={{ color: 'red' }}>\n 组件<em>{sourceKey}</em>未找到\n </div>\n );\n }\n }\n const children = getComponentChildren(componentSchema);\n const slots = {};\n // eslint-disable-next-line guard-for-in\n for (const key in properties) {\n const child = properties[key];\n if (!child['x-props'] && child.properties) {\n slots[key] = isScopeSlot(componentSchema, key) ? (\n (props) => { \n let clonedScopeContext = cloneDeep(scopeContext);\n lodashSet(\n clonedScopeContext,\n `${componentSchema.key}.${child.key}`,\n props\n );\n return (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={clonedScopeContext}\n />\n );\n }\n ) : (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n );\n }\n }\n\n return (\n <CompRenderer\n id={componentSchema.key}\n xProps={xProps}\n emitEvents={componentSchema.emitEvents || []}\n virtualFields={virtualFields}\n slots={slots}\n codeContext={codeContext}\n scopeContext={scopeContext}\n genericComp={genericComp}\n >\n {children.map((comp) => (\n <AppRender\n key={comp.key}\n componentSchema={comp}\n rootNode={false}\n renderSlot={false}\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n ))}\n </CompRenderer>\n );\n}\n"
29
+ "code": "import * as React from 'react';\nimport { useRef } from 'react';\nimport { CompRenderer } from './NodeRenderer';\nimport lodashSet from 'lodash.set';\nimport cloneDeep from 'lodash.clonedeep';\nimport { isScopeSlot } from '../utils/common';\n\nfunction getComponentChildren(component) {\n const { properties } = component;\n if (!properties) {\n return [];\n }\n return Object.values(properties).sort(\n (a, b) => (a['x-index'] || 0) - (b['x-index'] || 0)\n );\n}\n\nexport function AppRender(props) {\n const {\n className,\n virtualFields,\n componentSchema,\n renderSlot,\n rootNode = true,\n codeContext,\n scopeContext = {},\n } = props;\n const {\n 'x-props': xProps,\n properties = {},\n genericComp = {},\n } = componentSchema;\n // 判断是否为 slot\n const isSlot = !xProps;\n if (isSlot && !(renderSlot || rootNode)) {\n return null;\n }\n\n const preClassName = useRef();\n\n // wrapperClass\n const containerEl = Object.values(properties)[0];\n if (containerEl && containerEl['x-props'] && className) {\n let { classNameList = [] } = containerEl['x-props'];\n\n // 先替换掉先前计算出来的className部分\n if (preClassName.current) {\n if (preClassName.current !== className) {\n classNameList = classNameList.filter(\n (clsName) => clsName !== preClassName.current\n );\n preClassName.current = className;\n }\n } else {\n preClassName.current = className;\n }\n\n containerEl['x-props'].classNameList = [className, ...classNameList];\n }\n\n if (xProps && xProps.sourceKey) {\n const { sourceKey } = xProps;\n const Field = virtualFields[sourceKey];\n if (!Field) {\n return (\n <div style={{ color: 'red' }}>\n 组件<em>{sourceKey}</em>未找到\n </div>\n );\n }\n }\n const children = getComponentChildren(componentSchema);\n const slots = {};\n // eslint-disable-next-line guard-for-in\n for (const key in properties) {\n const child = properties[key];\n if (!child['x-props'] && child.properties) {\n slots[key] = isScopeSlot(componentSchema, key) ? (\n (props) => {\n let clonedScopeContext = cloneDeep(scopeContext);\n lodashSet(\n clonedScopeContext,\n `${componentSchema.key}.${child.key}`,\n props\n );\n return (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={clonedScopeContext}\n />\n );\n }\n ) : (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n );\n }\n }\n\n return (\n <CompRenderer\n id={componentSchema.key}\n xProps={xProps}\n emitEvents={componentSchema.emitEvents || []}\n componentSchema={componentSchema}\n virtualFields={virtualFields}\n slots={slots}\n codeContext={codeContext}\n scopeContext={scopeContext}\n genericComp={genericComp}\n >\n {children.map((comp) => (\n <AppRender\n key={comp.key}\n componentSchema={comp}\n rootNode={false}\n renderSlot={false}\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n ))}\n </CompRenderer>\n );\n}\n"
30
30
  },
31
31
  "/src/index.jsx": {
32
32
  "code": "import * as React from 'react'\nimport * as ReactDOM from 'react-dom'\nimport { setConfig } from '@cloudbase/weda-cloud-sdk/dist/h5'\nimport App from './router'\n<% if(!isSandbox){ %>\nimport './utils/monitor-jssdk.min'\n<% } %>\nimport './lowcode/style.css'\n// 引入数据源管理器并进行初始化\nimport './datasources'\nimport './utils/initGlobalVar'\n// import i18nData from './i18n/index.js'\nimport { initAppLifeCycle } from './utils/lifecycle'\n<% subAppDataList.forEach(subApp => { %>\n import './packages/<%= subApp.rootPath %>/lowcode/style.css'\n<% }) %>\n\n<% if(!isSandbox){ %>\nimport attachFastClick from 'fastclick'\nattachFastClick && attachFastClick.attach && attachFastClick.attach(document.body)\n<% } %>\nimport { app } from './app/global-api'\nimport { createStateDataSourceVar, generateParamsParser, EXTRA_API } from './datasources'\n\n\n// 初始化应用生命周期\ninitAppLifeCycle(app,{\n beforeCustomLaunch: (query)=>{\n EXTRA_API.setParams('$global', query || {})\n createStateDataSourceVar('$global',generateParamsParser({app}))\n }\n})\n\n<% if(!isSandbox && isBuildApp){ %>\n// app 中注册配置页面以及app的全局配置miniprogram.config,h5里分app以及web页分别处理,使用process.env.isApp 区分判断\nimport { initWebConfig } from './utils/lifecycle'\nimport AppConfig from '../webpack/miniprogram.config'\ninitWebConfig(app, AppConfig);\n<% } %>\n// 设置数据源请求的 loading 及 toast 处理\nsetConfig({\n beforeDSRequest: (cfg) => {\n if (!cfg.options || !cfg.options.showLoading) return\n app.showLoading()\n },\n afterDSRequest: (cfg, error, result) => {\n if (!cfg.options) return\n if (cfg.options.showLoading) app.hideLoading()\n if (!cfg.options.showToast) return\n const isSuccess = !error && result && !result.code\n app.showToast({icon: isSuccess ? 'success' : 'error'})\n }\n})\n\n\n<% if(!isSandbox){ %>\nif (yyptReport && typeof yyptReport.pgvMain == 'function') {\n // report_url,appKey必填\n yyptReport.pgvMain({\n appKey: '<%= yyptAppKey %>', // 填入你申请的运营平台的应用key(必填)\n report_url: '<%= reportUrl %><%= yyptAppKey %>', // 上报url(把后端上报接口需要先挂网关,该url填写网关地址)\n autoReportPv: true, // 单页应用监听页面路径改变自动上报Pv,默认为false\n stopReport: <%= stopReport %>, // 停止上报\n // 其他参数说明\n // customUserPrams: null, // 用户自定义的额外属性--对于小马的用户属性,比如用户的部门编码(customUserPrams: { deptno: 1100 })需要在小马系统事先配置好\n //userKey: \"user_id\", // cookie里面用户的唯一标示\n //autoWatchClick: true, // 默认开启自动监听hottag\n //isWxEnv: false// 是否微信环境,微信环境会通过wx.getNetworkType获取网络环境\n // 通过传入函数,可以让业务方写代码传入要上报的属性,比如返回自定义属性,这里主要也是自定义属性,让sdk获取并且进行上报,减少重复编码\n //getCusParams: function () {\n // return {kv:{money:1}}; //kv:Key-Value,自定义事件Key-Value参数对\tmap\tJSON格式,在报表页面的事件参数分析页和页面参数分析页中可以看到上报的kv值\n //},\n })\n}\n<% } %>\n\n;(function() {\n function flex() {\n try {\n let htmlDom = document.documentElement\n let width = window.innerWidth || htmlDom.clientWidth\n let fontSize = width / (375 / 14)\n if (\n !navigator.userAgent.match(\n /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i\n ) &&\n fontSize > 14\n ) {\n htmlDom.style.fontSize = `14px`\n } else {\n htmlDom.style.fontSize = fontSize + `px`\n }\n } catch (e) {\n console.error(e)\n }\n }\n\n flex()\n window.addEventListener('resize', flex)\n})()\nReactDOM.render(<App/>, document.getElementById('root'))\n\n<% if(!isSandbox){ %>\n// 使用HMR\nif(process.env.compileTool === 'vite') {\n if (import.meta.hot) {\n import.meta.hot.accept()\n }\n} else {\n if (process.env.NODE_ENV !== 'production') {\n if (module.hot) {\n module.hot.accept()\n }\n }\n}\n<% } %>\n"
@@ -53,7 +53,7 @@ exports.default = {
53
53
  "code": "import { resolveDataBinds } from './common';\nimport lodashSet from 'lodash.set';\n\nconst DEFAULT_MAX_TIMEOUT = 10 * 1000;\n\nexport function getMetaInfoBySourceKey(sourceKey) {\n const [materialName, name] = sourceKey.split(':');\n return {\n materialName,\n name,\n };\n}\n\nexport function emitEvent(trigger, listeners = [], args, scopeContext = {}) {\n const targetListeners = listeners.filter((l) => l.trigger === trigger);\n targetListeners.forEach(async (listener) => {\n // 当前非捕获Event,再判断冒泡行为\n if (!args?.event?.detail?.isCapturePhase && listener.noPropagation) {\n args?.domEvent?.stopPropagation && args?.domEvent?.stopPropagation();\n }\n\n // 判断捕获的执行,只有执行的捕获与配置的捕获一致时。才会执行。\n if (\n (listener?.isCapturePhase || false) ===\n (args?.customEventData?.detail?.isCapturePhase || false)\n ) {\n try {\n const res = await invokeListener(listener, args, scopeContext);\n const eventName = `${listener.key}.success`;\n const event = {\n detail: {\n value: res,\n origin: args.event,\n isCapturePhase: !!args.event?.isCapturePhase,\n },\n name: eventName,\n };\n emitEvent(\n eventName,\n listeners,\n {\n ...args,\n event,\n customEventData: event,\n },\n scopeContext\n );\n } catch (e) {\n const eventName = `${listener.key}.fail`;\n const event = {\n detail: {\n value: e,\n origin: args.event,\n isCapturePhase: !!args.event?.isCapturePhase,\n },\n name: eventName,\n };\n emitEvent(\n eventName,\n listeners,\n {\n ...args,\n event,\n customEventData: event,\n },\n scopeContext\n );\n // 之前 invoke 内部catch 了错误,不会抛错\n // throw e\n console.error(`Action error: [${listener.trigger}]`, e);\n }\n }\n });\n}\n\nfunction invokeListener(\n { instanceFunction, data = {}, dataBinds = {} },\n args,\n scopeContext\n) {\n // ToDo resolve databinds\n const action = instanceFunction;\n const resolvedData = {\n ...data,\n };\n const resolvedDataBinds = resolveDataBinds(\n dataBinds,\n args.forItems,\n { event: args.event },\n scopeContext,\n true\n );\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in resolvedDataBinds) {\n if (\n resolvedDataBinds[key] &&\n resolvedDataBinds[key].__type === 'scopedValue'\n ) {\n try {\n lodashSet(\n resolvedData,\n key,\n resolvedDataBinds[key].getValue(scopeContext)\n );\n } catch (e) {\n lodashSet(resolvedData, key, '');\n }\n } else {\n lodashSet(resolvedData, key, resolvedDataBinds[key]);\n }\n }\n const params = {\n data: resolvedData,\n ...args,\n };\n\n return action(params);\n}\n"
54
54
  },
55
55
  "/src/utils/common.js": {
56
- "code": "/**\n * All data bindings are generated as functions: (forItems) => any\n * @param {*} dataBinds\n * @param {*} forItems\n */\nexport function resolveDataBinds(\n dataBinds,\n forItems,\n codeContext,\n scopeContext,\n throwError\n) {\n const resolvedProps = {};\n for (const prop in dataBinds) {\n let fn = dataBinds[prop];\n try {\n if (codeContext && codeContext.$WEAPPS_COMP) {\n fn = fn.bind(codeContext.$WEAPPS_COMP);\n }\n resolvedProps[prop] = fn(\n forItems,\n codeContext && codeContext.event,\n scopeContext\n );\n } catch (e) {\n console.error('Error resolving data binding', prop, dataBinds[prop], e);\n if (throwError) {\n throw e;\n }\n }\n }\n return resolvedProps;\n}\n\n/**\n * 对函数进行批量绑定\n * @param {*} funcObj\n * @param {*} context\n */\nexport function bindFuncObj(funcObj = {}, context) {\n return Object.keys(funcObj).reduce((obj, fnName) => {\n obj[fnName] = funcObj[fnName].bind(context);\n return obj;\n }, {});\n}\n\nexport function kebabCase(str) {\n return str.replace(KEBAB_REGEX, function (match) {\n return '-' + match.toLowerCase();\n });\n}\n\nexport function camelcase(str, firstUpperCase = false) {\n str = str.replace(/[_-]([a-z])/g, function (l) {\n return l[1].toUpperCase();\n });\n\n if (firstUpperCase) str = str.charAt(0).toUpperCase() + str.slice(1);\n\n return str;\n}\n\nexport const isEmptyObj = (obj) => {\n if (!isPlainObject(obj)) {\n return false;\n }\n for (const i in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, i)) {\n return false;\n }\n }\n return true;\n};\n\nexport function isPlainObject(src) {\n return Object.prototype.toString.call(src) === '[object Object]';\n}\n\n/**\n * 用于处理自定义组件props传参结构,对系统变量进行保留\n */\nexport function resolveComponentProps(props, isPlainProps) {\n const { staticResourceAttribute } = props;\n staticResourceAttribute &&\n staticResourceAttribute.map((property) => {\n if (props.data && props.data[property]) {\n props.data[property] = getStaticResourceAttribute(props.data[property]);\n }\n });\n if (!isPlainProps) {\n return {\n ...props,\n };\n }\n const { data = {}, events = [], ...restProps } = props;\n const customProps = { ...data };\n const builtinProps = [\n // react 保留字\n 'ref',\n 'key',\n 'dangerouslySetInnerHTML',\n 'className',\n 'htmlFor',\n 'style',\n 'contentEditable',\n // lowcode 保留字\n 'events',\n 'children',\n '_parentId',\n '_visible',\n 'classList',\n 'widgetType',\n 'getWidgetsByType',\n 'getDom',\n 'domRef',\n 'extends',\n // 小程序保留字\n 'id',\n 'class',\n 'hidden',\n 'slot',\n ];\n // delete builtin props\n builtinProps.map((prop) => delete customProps[prop]);\n return {\n ...data,\n ...restProps,\n events: new Proxy(\n events.reduce((events, item) => {\n const propName = item;\n events[propName] = (e) => restProps.emit(propName, e);\n return events;\n }, {}),\n {\n get(obj, prop) {\n return prop in obj ? obj[prop] : (e) => restProps.emit(prop, e);\n },\n }\n ),\n };\n}\n\nconst SCOPE_SLOT_COMPONENT_LIB = ['tea_basis', 'tea_shop', 'crm_basis'];\n\nconst SCOPE_SLOT_MAP = SCOPE_SLOT_COMPONENT_LIB.reduce((map, lib) => {\n map[`${lib}:TableMatching`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:TableExpanded`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:TabsTable`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:Table`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n return map;\n}, {});\n\nexport function isScopeSlot(comp, slot) {\n const { 'x-props': xProps } = comp;\n const sourceKey = xProps && xProps.sourceKey;\n const map = SCOPE_SLOT_MAP[sourceKey];\n return map && map[slot];\n}\n\nexport function getStaticResourceAttribute(staticUrl) {\n if (/^\\//.test(staticUrl)) {\n const { domain = '' } = window.app || {};\n const url = `https://${domain}${staticUrl}`;\n return url;\n }\n return staticUrl;\n}\n/**\n * 检查页面权限\n **/\nexport async function checkAuth(app, appId, pageId) {\n app.showNavigationBarLoading();\n const checkAuthResult = await app.cloud.callWedaApi({\n action: 'DescribeResourcesPermission',\n data: {\n ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,\n ResourceIdList: [`${appId}-${pageId}`],\n },\n });\n let isLogin = false;\n if (Array.isArray(checkAuthResult) && checkAuthResult.length > 0) {\n isLogin = checkAuthResult[0]?.IsAccess ?? false;\n }\n app.hideNavigationBarLoading();\n\n if (!isLogin) {\n app.showToast({\n title: '页面无访问权限',\n icon: 'error',\n });\n }\n return isLogin;\n}\n"
56
+ "code": "/**\n * All data bindings are generated as functions: (forItems) => any\n * @param {*} dataBinds\n * @param {*} forItems\n */\nexport function resolveDataBinds(\n dataBinds,\n forItems,\n codeContext,\n scopeContext,\n throwError\n) {\n const resolvedProps = {};\n for (const prop in dataBinds) {\n let fn = dataBinds[prop];\n try {\n if (codeContext && codeContext.$WEAPPS_COMP) {\n fn = fn.bind(codeContext.$WEAPPS_COMP);\n }\n resolvedProps[prop] = fn(\n forItems,\n codeContext && codeContext.event,\n scopeContext\n );\n } catch (e) {\n console.error('Error resolving data binding', prop, dataBinds[prop], e);\n if (throwError) {\n throw e;\n }\n }\n }\n return resolvedProps;\n}\n\n/**\n * 对函数进行批量绑定\n * @param {*} funcObj\n * @param {*} context\n */\nexport function bindFuncObj(funcObj = {}, context) {\n return Object.keys(funcObj).reduce((obj, fnName) => {\n obj[fnName] = funcObj[fnName].bind(context);\n return obj;\n }, {});\n}\n\nexport function kebabCase(str) {\n return str.replace(KEBAB_REGEX, function (match) {\n return '-' + match.toLowerCase();\n });\n}\n\nexport function camelcase(str, firstUpperCase = false) {\n str = str.replace(/[_-]([a-z])/g, function (l) {\n return l[1].toUpperCase();\n });\n\n if (firstUpperCase) str = str.charAt(0).toUpperCase() + str.slice(1);\n\n return str;\n}\n\nexport const isEmptyObj = (obj) => {\n if (!isPlainObject(obj)) {\n return false;\n }\n for (const i in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, i)) {\n return false;\n }\n }\n return true;\n};\n\nexport function isPlainObject(src) {\n return Object.prototype.toString.call(src) === '[object Object]';\n}\n\n/**\n * 用于处理自定义组件props传参结构,对系统变量进行保留\n */\nexport function resolveComponentProps(props, isPlainProps) {\n const { staticResourceAttribute } = props;\n staticResourceAttribute &&\n staticResourceAttribute.map((property) => {\n if (props.data && props.data[property]) {\n props.data[property] = getStaticResourceAttribute(props.data[property]);\n }\n });\n if (!isPlainProps) {\n return {\n ...props,\n };\n }\n const { data = {}, events = [], ...restProps } = props;\n const customProps = { ...data };\n const builtinProps = [\n // react 保留字\n 'ref',\n 'key',\n 'dangerouslySetInnerHTML',\n 'className',\n 'htmlFor',\n 'style',\n 'contentEditable',\n // lowcode 保留字\n 'events',\n 'children',\n '_parentId',\n '_visible',\n 'classList',\n 'widgetType',\n 'getWidgetsByType',\n 'getDom',\n 'domRef',\n 'extends',\n // 小程序保留字\n 'id',\n 'class',\n 'hidden',\n 'slot',\n ];\n // delete builtin props\n builtinProps.map((prop) => delete customProps[prop]);\n // 选区events处理\n const { _selectableBlockEvents, ...restData } = data;\n const { emit: _selectableBlockEmit } = _selectableBlockEvents;\n _selectableBlockEvents.events = new Proxy(\n _selectableBlockEvents.events.reduce((events, item) => {\n const propName = item;\n events[propName] = (e) => _selectableBlockEmit(propName, e);\n return events;\n }, {}),\n {\n get(obj, prop) {\n return prop in obj ? obj[prop] : (e) => _selectableBlockEmit(prop, e);\n },\n }\n );\n return {\n ...restData,\n ...restProps,\n _selectableBlockEvents,\n events: new Proxy(\n events.reduce((events, item) => {\n const propName = item;\n events[propName] = (e) => restProps.emit(propName, e);\n return events;\n }, {}),\n {\n get(obj, prop) {\n return prop in obj ? obj[prop] : (e) => restProps.emit(prop, e);\n },\n }\n ),\n };\n}\n\nconst SCOPE_SLOT_COMPONENT_LIB = ['tea_basis', 'tea_shop', 'crm_basis'];\n\nconst SCOPE_SLOT_MAP = SCOPE_SLOT_COMPONENT_LIB.reduce((map, lib) => {\n map[`${lib}:TableMatching`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:TableExpanded`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:TabsTable`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n map[`${lib}:Table`] = {\n headerSlot: true,\n recordSlot: true,\n };\n\n return map;\n}, {});\n\nexport function isScopeSlot(comp, slot) {\n const { 'x-props': xProps } = comp;\n const sourceKey = xProps && xProps.sourceKey;\n const map = SCOPE_SLOT_MAP[sourceKey];\n return map && map[slot];\n}\n\nexport function getStaticResourceAttribute(staticUrl) {\n if (/^\\//.test(staticUrl)) {\n const { domain = '' } = window.app || {};\n const url = `https://${domain}${staticUrl}`;\n return url;\n }\n return staticUrl;\n}\n/**\n * 检查页面权限\n **/\nexport async function checkAuth(app, appId, pageId) {\n app.showNavigationBarLoading();\n const checkAuthResult = await app.cloud.callWedaApi({\n action: 'DescribeResourcesPermission',\n data: {\n ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,\n ResourceIdList: [`${appId}-${pageId}`],\n },\n });\n let isLogin = false;\n if (Array.isArray(checkAuthResult) && checkAuthResult.length > 0) {\n isLogin = checkAuthResult[0]?.IsAccess ?? false;\n }\n app.hideNavigationBarLoading();\n\n if (!isLogin) {\n app.showToast({\n title: '页面无访问权限',\n icon: 'error',\n });\n }\n return isLogin;\n}\n"
57
57
  },
58
58
  "/src/utils/computed.js": {
59
59
  "code": "export function createComputed(funcs, bindContext = null) {\n const obj = {}\n for (const name in funcs) {\n Object.defineProperty(obj, name, {\n get: bindContext ? funcs[name].bind(bindContext) : funcs[name],\n })\n }\n return obj\n}\n"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.6.0",
3
+ "version": "0.6.5",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@cloudbase/cals": "0.3.3",
37
+ "@cloudbase/cals": "0.3.17",
38
38
  "@cloudbase/framework-core": "^1.6.13",
39
39
  "@cloudbase/framework-plugin-auth": "^1.6.13",
40
40
  "@cloudbase/framework-plugin-mp": "v1.3.6-beta.8",
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
- import { useContext, useCallback, createContext } from 'react';
2
+ import {
3
+ useContext,
4
+ useCallback,
5
+ createContext,
6
+ useState,
7
+ useRef,
8
+ } from 'react';
3
9
  import { observer } from 'mobx-react-lite';
4
10
  import { emitEvent, translateStyleToRem, checkVisible } from '../utils';
5
11
  import { get, set } from 'lodash';
@@ -17,7 +23,16 @@ export const CompRenderer = observer(function (props) {
17
23
  scopeContext = {},
18
24
  genericComp = {},
19
25
  emitEvents = [],
26
+ componentSchema = {},
20
27
  } = props;
28
+
29
+ const [blockIndex, setBlockIndex] = useState();
30
+ const [blockType, setBlockType] = useState();
31
+ const indexRef = useRef();
32
+ const typeRef = useRef();
33
+ indexRef.current = blockIndex;
34
+ typeRef.current = blockType;
35
+
21
36
  const isInComposite = !!codeContext.$WEAPPS_COMP;
22
37
  // 判断 widgets 是从 page 来的,还是组件来的
23
38
  const widgetsData = !isInComposite
@@ -45,7 +60,7 @@ export const CompRenderer = observer(function (props) {
45
60
  const Field = virtualFields[FieldKey];
46
61
  const parentForItems = useContext(ForContext);
47
62
 
48
- // 最终用于执行的事件函数
63
+ // 组件最终用于执行的事件函数
49
64
  const emit = useCallback(
50
65
  (trigger, eventData, forItems, domEvent, scopeContext) => {
51
66
  const listeners = listenerInstances;
@@ -75,6 +90,41 @@ export const CompRenderer = observer(function (props) {
75
90
  [props]
76
91
  );
77
92
 
93
+ // 选区最终用于执行的事件函数
94
+ const emitSB = useCallback(
95
+ (trigger, eventData, forItems, domEvent, scopeContext, fieldData) => {
96
+ const listeners =
97
+ typeRef.current &&
98
+ indexRef.current &&
99
+ fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
100
+ 'x-props'
101
+ ]?.listenerInstances;
102
+ const event = {
103
+ detail: eventData,
104
+ name: trigger,
105
+ target: widgetsData,
106
+ currentTarget: widgetsData,
107
+ domEvent,
108
+ };
109
+ forItems = {
110
+ ...forItems,
111
+ forIndexes: getForIndexes(forItems, widgetsData),
112
+ };
113
+ emitEvent(
114
+ trigger,
115
+ listeners,
116
+ {
117
+ event,
118
+ customEventData: event,
119
+ forItems,
120
+ domEvent,
121
+ },
122
+ scopeContext
123
+ );
124
+ },
125
+ [props]
126
+ );
127
+
78
128
  function getSafeComponentProps({
79
129
  style,
80
130
  classNameList,
@@ -95,6 +145,14 @@ export const CompRenderer = observer(function (props) {
95
145
  return componentProps;
96
146
  }
97
147
 
148
+ // 选区的预览的click事件
149
+ const onCustomEvent = ({ order: index, blockKey }) => {
150
+ if (index) {
151
+ setBlockIndex(index);
152
+ setBlockType(blockKey);
153
+ }
154
+ };
155
+
98
156
  // For循环渲染
99
157
  let forList;
100
158
  try {
@@ -129,6 +187,23 @@ export const CompRenderer = observer(function (props) {
129
187
  });
130
188
  const emitWithForItems = (trigger, eventData, domEvent) =>
131
189
  emit(trigger, eventData, forItems, domEvent, scopeContext);
190
+
191
+ const _selectableBlockEventsForItems = {
192
+ onCustomEvent,
193
+ events:
194
+ componentSchema?.selectableBlock?.events.map((item) => item.name) ||
195
+ [],
196
+ emit: (trigger, eventData, domEvent) =>
197
+ emitSB(
198
+ trigger,
199
+ eventData,
200
+ forItems,
201
+ domEvent,
202
+ scopeContext,
203
+ forItemData
204
+ ),
205
+ };
206
+
132
207
  delete forItemData.style;
133
208
 
134
209
  // 获取当前元素的 ref
@@ -139,7 +214,10 @@ export const CompRenderer = observer(function (props) {
139
214
  return (
140
215
  <ForContext.Provider key={index} value={forItems}>
141
216
  <Field
142
- data={forItemData}
217
+ data={{
218
+ ...forItemData,
219
+ _selectableBlockEvents: _selectableBlockEventsForItems,
220
+ }}
143
221
  id={compId}
144
222
  {...getSafeComponentProps({
145
223
  style: forItemStyle,
@@ -168,6 +246,21 @@ export const CompRenderer = observer(function (props) {
168
246
  const emitWithFiedle = (trigger, eventData, domEvent) =>
169
247
  emit(trigger, eventData, parentForItems, domEvent, scopeContext);
170
248
 
249
+ const _selectableBlockEventsWithFiedle = {
250
+ onCustomEvent,
251
+ events:
252
+ componentSchema?.selectableBlock?.events.map((item) => item.name) || [],
253
+ emit: (trigger, eventData, domEvent) =>
254
+ emitSB(
255
+ trigger,
256
+ eventData,
257
+ parentForItems,
258
+ domEvent,
259
+ scopeContext,
260
+ fieldData
261
+ ),
262
+ };
263
+
171
264
  // false 或空字符串时
172
265
  if (!checkVisible(fieldData)) {
173
266
  return null;
@@ -192,7 +285,10 @@ export const CompRenderer = observer(function (props) {
192
285
 
193
286
  return (
194
287
  <Field
195
- data={fieldData}
288
+ data={{
289
+ ...fieldData,
290
+ _selectableBlockEvents: _selectableBlockEventsWithFiedle,
291
+ }}
196
292
  id={compId}
197
293
  {...getSafeComponentProps({
198
294
  style: finalStyle,
@@ -36,7 +36,7 @@ export function AppRender(props) {
36
36
  return null;
37
37
  }
38
38
 
39
- const preClassName = useRef();
39
+ const preClassName = useRef();
40
40
 
41
41
  // wrapperClass
42
42
  const containerEl = Object.values(properties)[0];
@@ -76,7 +76,7 @@ export function AppRender(props) {
76
76
  const child = properties[key];
77
77
  if (!child['x-props'] && child.properties) {
78
78
  slots[key] = isScopeSlot(componentSchema, key) ? (
79
- (props) => {
79
+ (props) => {
80
80
  let clonedScopeContext = cloneDeep(scopeContext);
81
81
  lodashSet(
82
82
  clonedScopeContext,
@@ -112,6 +112,7 @@ export function AppRender(props) {
112
112
  id={componentSchema.key}
113
113
  xProps={xProps}
114
114
  emitEvents={componentSchema.emitEvents || []}
115
+ componentSchema={componentSchema}
115
116
  virtualFields={virtualFields}
116
117
  slots={slots}
117
118
  codeContext={codeContext}
@@ -122,9 +122,25 @@ export function resolveComponentProps(props, isPlainProps) {
122
122
  ];
123
123
  // delete builtin props
124
124
  builtinProps.map((prop) => delete customProps[prop]);
125
+ // 选区events处理
126
+ const { _selectableBlockEvents, ...restData } = data;
127
+ const { emit: _selectableBlockEmit } = _selectableBlockEvents;
128
+ _selectableBlockEvents.events = new Proxy(
129
+ _selectableBlockEvents.events.reduce((events, item) => {
130
+ const propName = item;
131
+ events[propName] = (e) => _selectableBlockEmit(propName, e);
132
+ return events;
133
+ }, {}),
134
+ {
135
+ get(obj, prop) {
136
+ return prop in obj ? obj[prop] : (e) => _selectableBlockEmit(prop, e);
137
+ },
138
+ }
139
+ );
125
140
  return {
126
- ...data,
141
+ ...restData,
127
142
  ...restProps,
143
+ _selectableBlockEvents,
128
144
  events: new Proxy(
129
145
  events.reduce((events, item) => {
130
146
  const propName = item;
@@ -1,13 +1,15 @@
1
1
  // Imports all material actions
2
- <% materials.map((material,index) => { if(material.entry){ %>
3
- import <%= _.camelCase(material.name)%>_<%= index%> from 'libraries/<%=material.name%>@<%= material.version %>/<%=material.entry%>';
2
+ <% materials.map((material,index) => { if(material.entries && material.entries.actions){ %>
3
+ import * as <%= _.camelCase(material.name)%>Actions_<%= index%> from 'libraries/<%=material.name%>@<%= material.version %>/<%=material.entries.actions%>';
4
+ <% } else if(material.entries && material.entries.entry) {%>
5
+ import <%= _.camelCase(material.name)%>_<%= index%> from 'libraries/<%=material.name%>@<%= material.version %>/<%=material.entries.entry%>';
4
6
  const <%= _.camelCase(material.name)%>Actions_<%= index%> = <%= _.camelCase(material.name)%>_<%= index%>.actions
5
7
  <% } else { (material.actions || []).map(act => {%>
6
8
  import <%= _.camelCase(material.name)%>_<%=act.name%> from 'libraries/<%=material.name%>@<%= material.version %>/actions/<%= act.name %>'
7
9
  <% }) }}) %>
8
10
  export default {
9
11
  <% materials.map((material, index) => {
10
- %> ['<%= material.name%>']:<% if(material.entry){ %> <%=_.camelCase(material.name)%>Actions_<%= index%>,
12
+ %> ['<%= material.name%>']:<% if(material.entries && (material.entries.entry || material.entries.actions)){ %> <%=_.camelCase(material.name)%>Actions_<%= index%>,
11
13
  <% }else{ %> {<% (material.actions || []).map(act => { %>
12
14
  ['<%= act.name%>']: <%= _.camelCase(material.name)%>_<%=act.name%>,<%})%>
13
15
  },
@@ -1,5 +1,11 @@
1
1
  import * as React from 'react';
2
- import { useContext, useCallback, createContext, useRef } from 'react';
2
+ import {
3
+ useContext,
4
+ useCallback,
5
+ createContext,
6
+ useRef,
7
+ useState,
8
+ } from 'react';
3
9
  import { observer } from 'mobx-react-lite';
4
10
  import { emitEvent } from '../actionHandler/utils';
5
11
  import { translateStyleToRem } from '@tcwd/weapps-core';
@@ -19,8 +25,16 @@ export const CompRenderer = observer(function (props) {
19
25
  codeContext,
20
26
  scopeContext,
21
27
  emitEvents = [],
28
+ componentSchema = {},
22
29
  } = props;
23
30
 
31
+ const [blockIndex, setBlockIndex] = useState();
32
+ const [blockType, setBlockType] = useState();
33
+ const indexRef = useRef();
34
+ const typeRef = useRef();
35
+ indexRef.current = blockIndex;
36
+ typeRef.current = blockType;
37
+
24
38
  const isInComposite = !!props.codeContext;
25
39
  // 判断 widgets 是从 page 来的,还是组件来的
26
40
  const widgetsData = !isInComposite
@@ -45,6 +59,7 @@ export const CompRenderer = observer(function (props) {
45
59
  const Field = virtualFields[sourceKey];
46
60
  const parentForItems = useContext(ForContext);
47
61
 
62
+ // 组件最终用于执行的事件函数
48
63
  const emit = useCallback(
49
64
  (trigger, event, forItems, scopeContext) => {
50
65
  const listeners = listenerInstances;
@@ -67,6 +82,34 @@ export const CompRenderer = observer(function (props) {
67
82
  [props]
68
83
  );
69
84
 
85
+ // 选区最终用于执行的事件函数
86
+ const emitSB = useCallback(
87
+ (trigger, event, forItems, scopeContext, fieldData) => {
88
+ const listeners =
89
+ indexRef.current &&
90
+ typeRef.current &&
91
+ fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
92
+ 'x-props'
93
+ ]?.listenerInstances;
94
+ event = { detail: event, name: trigger };
95
+ forItems = {
96
+ ...forItems,
97
+ forIndexes: getForIndexes(forItems, widgetsData),
98
+ };
99
+ emitEvent(
100
+ trigger,
101
+ listeners,
102
+ {
103
+ event,
104
+ customEventData: event,
105
+ forItems,
106
+ },
107
+ scopeContext
108
+ );
109
+ },
110
+ [props]
111
+ );
112
+
70
113
  function getSafeComponentProps({
71
114
  style,
72
115
  classNameList,
@@ -86,6 +129,14 @@ export const CompRenderer = observer(function (props) {
86
129
  return componentProps;
87
130
  }
88
131
 
132
+ // 选区的预览的click事件
133
+ const onCustomEvent = ({ order: index, blockKey }) => {
134
+ if (index) {
135
+ setBlockIndex(index);
136
+ setBlockType(blockKey);
137
+ }
138
+ };
139
+
89
140
  // For循环渲染
90
141
  let forList;
91
142
  try {
@@ -123,6 +174,16 @@ export const CompRenderer = observer(function (props) {
123
174
  });
124
175
  const emitWithForItems = (trigger, evt) =>
125
176
  emit(trigger, evt, forItems, scopeContext);
177
+
178
+ const _selectableBlockEventsForItems = {
179
+ onCustomEvent,
180
+ events:
181
+ componentSchema?.selectableBlock?.events.map((item) => item.name) ||
182
+ [],
183
+ emit: (trigger, evt) =>
184
+ emitSB(trigger, evt, forItems, scopeContext, forItemData),
185
+ };
186
+
126
187
  delete forItemData.style;
127
188
 
128
189
  // 获取当前元素的 ref
@@ -139,7 +200,10 @@ export const CompRenderer = observer(function (props) {
139
200
  return (
140
201
  <ForContext.Provider key={index} value={forItems}>
141
202
  <Field
142
- data={forItemData}
203
+ data={{
204
+ ...forItemData,
205
+ _selectableBlockEvents: _selectableBlockEventsForItems,
206
+ }}
143
207
  id={compId}
144
208
  {...componentProps}
145
209
  emit={emitWithForItems}
@@ -164,6 +228,14 @@ export const CompRenderer = observer(function (props) {
164
228
  const emitWithForItems = (trigger, evt) =>
165
229
  emit(trigger, evt, parentForItems, scopeContext);
166
230
 
231
+ const _selectableBlockEventsWithItem = {
232
+ onCustomEvent,
233
+ events:
234
+ componentSchema?.selectableBlock?.events.map((item) => item.name) || [],
235
+ emit: (trigger, evt) =>
236
+ emitSB(trigger, evt, parentForItems, scopeContext, fieldData),
237
+ };
238
+
167
239
  // false 或空字符串时
168
240
  if (!checkVisible(fieldData)) {
169
241
  return null;
@@ -193,7 +265,7 @@ export const CompRenderer = observer(function (props) {
193
265
  });
194
266
  return (
195
267
  <Field
196
- data={fieldData}
268
+ data={{ ...fieldData, _selectableBlockEvents: _selectableBlockEventsWithItem }}
197
269
  id={compId}
198
270
  {...componentProps}
199
271
  emit={emitWithForItems}
@@ -24,7 +24,7 @@ export function AppRender(props) {
24
24
  codeContext,
25
25
  scopeContext = {},
26
26
  } = props;
27
-
27
+
28
28
  const { 'x-props': xProps, properties = {} } = componentSchema;
29
29
 
30
30
  // 判断是否为 slot
@@ -110,6 +110,7 @@ export function AppRender(props) {
110
110
  id={componentSchema.key}
111
111
  xProps={xProps}
112
112
  emitEvents={componentSchema.emitEvents || []}
113
+ componentSchema={componentSchema}
113
114
  virtualFields={virtualFields}
114
115
  slots={slots}
115
116
  codeContext={codeContext}
@@ -105,9 +105,25 @@ export function resolveComponentProps(props, isPlainProps) {
105
105
  'slot',
106
106
  ];
107
107
  builtinProps.map((prop) => delete customProps[prop]);
108
+ // 选区events处理
109
+ const { _selectableBlockEvents, ...restData } = data;
110
+ const { emit: _selectableBlockEmit } = _selectableBlockEvents;
111
+ _selectableBlockEvents.events = new Proxy(
112
+ _selectableBlockEvents.events.reduce((events, item) => {
113
+ const propName = item;
114
+ events[propName] = (e) => _selectableBlockEmit(propName, e);
115
+ return events;
116
+ }, {}),
117
+ {
118
+ get(obj, prop) {
119
+ return prop in obj ? obj[prop] : (e) => _selectableBlockEmit(prop, e);
120
+ },
121
+ }
122
+ );
108
123
  return {
109
- ...data,
124
+ ...restData,
110
125
  ...restProps,
126
+ _selectableBlockEvents,
111
127
  events: events.reduce((events, item) => {
112
128
  const propName = item;
113
129
  events[propName] = (e) => restProps.emit(propName, e);