@sdata-plugin-adapter/react 0.0.0-alpha.2 → 0.0.0-alpha.4
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/dist/export-CuNiopMp.js +2 -0
- package/dist/export-CuNiopMp.js.map +1 -0
- package/dist/index-BV9RX_Ka.js +92 -0
- package/dist/index-BV9RX_Ka.js.map +1 -0
- package/dist/index-CC9uxwpR.js +4586 -0
- package/dist/index-CC9uxwpR.js.map +1 -0
- package/dist/index-CUpP0oMu.js +56 -0
- package/dist/index-CUpP0oMu.js.map +1 -0
- package/dist/index-CqtMUNRo.js +13 -0
- package/dist/index-CqtMUNRo.js.map +1 -0
- package/dist/index-D8cPmNOG.js +59 -0
- package/dist/index-D8cPmNOG.js.map +1 -0
- package/dist/index-DQLM9I3g.js +71 -0
- package/dist/index-DQLM9I3g.js.map +1 -0
- package/dist/index-bwVa5yZu.js +24 -0
- package/dist/index-bwVa5yZu.js.map +1 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +18 -754
- package/dist/index.js.map +1 -1
- package/dist/start-KvBmIDZs.js +695 -0
- package/dist/start-KvBmIDZs.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-CuNiopMp.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { generateUUID as R, setDomAttributes as $ } from "@sdata-plugin-adapter/utils";
|
|
2
|
+
import j from "configJson";
|
|
3
|
+
import { S as B } from "./index-bwVa5yZu.js";
|
|
4
|
+
import "./export-CuNiopMp.js";
|
|
5
|
+
import { c as L } from "./start-KvBmIDZs.js";
|
|
6
|
+
const U = !0, { "online-development-mode": _, "requirement-number": G } = j ?? {}, E = (n) => {
|
|
7
|
+
var I, w;
|
|
8
|
+
const { useEffect: g, useRef: h } = window.React, S = !!(_ != null && _.open), { type: v, formConfig: a, parent: p, component: m, configuration: P, changeConfiguration: y } = n, t = { ...n };
|
|
9
|
+
if (t.formId = a == null ? void 0 : a.id, t.formName = a == null ? void 0 : a.form_name, t.isInChildTable = (p == null ? void 0 : p.componentGroup) === "表格组件", t.componentName = (I = m == null ? void 0 : m.columnStyle) == null ? void 0 : I.title, t.componentId = m == null ? void 0 : m.id, (U || S) && (t.customConfig = P ? JSON.parse(n.configuration) : {}, y && (t.changeCustomConfig = y), v === "query" && (t.customConfig = JSON.parse(((w = n.component) == null ? void 0 : w.customPluginConfig) || "{}"))), v === "query") {
|
|
10
|
+
const { queryProps: r, queryData: i } = n;
|
|
11
|
+
t.onSearch = r.onSearch, t.queryData = r.data, t.componentName = i == null ? void 0 : i.title, t.onSearchChange = (s, c = 0) => {
|
|
12
|
+
r.onChange([
|
|
13
|
+
{
|
|
14
|
+
colId: r.queryConfig.componentId,
|
|
15
|
+
colName: r.data.componentBusinessConfigList[0].businessName,
|
|
16
|
+
value: s,
|
|
17
|
+
type: c
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return t.triggerEvent = (r, i = {}) => {
|
|
23
|
+
var f;
|
|
24
|
+
const { formConfig: s, componentId: c, index: C } = t;
|
|
25
|
+
(f = window == null ? void 0 : window.eventCenter) == null || f.triggerEventNew({
|
|
26
|
+
objectId: s == null ? void 0 : s.id,
|
|
27
|
+
componentId: c,
|
|
28
|
+
type: "report",
|
|
29
|
+
event: r,
|
|
30
|
+
payload: { ...i, childIndex: C }
|
|
31
|
+
});
|
|
32
|
+
}, t.useRegisterComponent = (r) => {
|
|
33
|
+
const { actions: i = {}, eventActionDefinitions: s } = r, {
|
|
34
|
+
instance: c,
|
|
35
|
+
componentId: C,
|
|
36
|
+
customConfig: f,
|
|
37
|
+
component: d,
|
|
38
|
+
isDesign: T = !1,
|
|
39
|
+
child_id: q,
|
|
40
|
+
index: u,
|
|
41
|
+
componentName: x
|
|
42
|
+
} = t, N = Object.keys(i).reduce((e, o) => (o.includes("do_EventCenter_") ? e[o] = i[o] : e[`do_EventCenter_${o}`] = i[o], e), {}), A = (e) => B.includes(e), D = () => {
|
|
43
|
+
var o;
|
|
44
|
+
const e = (c == null ? void 0 : c.parent) || d.parent;
|
|
45
|
+
if (e) {
|
|
46
|
+
const l = {
|
|
47
|
+
id: e == null ? void 0 : e.id,
|
|
48
|
+
name: (o = e == null ? void 0 : e.columnStyle) == null ? void 0 : o.title,
|
|
49
|
+
showType: e == null ? void 0 : e.showType
|
|
50
|
+
};
|
|
51
|
+
return A(l.showType) ? l : void 0;
|
|
52
|
+
}
|
|
53
|
+
}, b = () => x || f.id || G || R(), O = () => {
|
|
54
|
+
var e;
|
|
55
|
+
return (e = d == null ? void 0 : d.parent) == null ? void 0 : e.id;
|
|
56
|
+
};
|
|
57
|
+
let J = d != null && d.parentId && D() && n.type === "set" ? (
|
|
58
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
59
|
+
h({
|
|
60
|
+
Event_Center_getName: b,
|
|
61
|
+
...N,
|
|
62
|
+
Event_Center_getParentId: O
|
|
63
|
+
})
|
|
64
|
+
) : (
|
|
65
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
66
|
+
h({ Event_Center_getName: b, ...N })
|
|
67
|
+
);
|
|
68
|
+
g(() => {
|
|
69
|
+
var o;
|
|
70
|
+
let e = C;
|
|
71
|
+
return T || (typeof u == "string" && u || Number(u) > -1) && (e = `${e}_childtable_${u}`), (o = window.componentCenter) == null || o.register(
|
|
72
|
+
e,
|
|
73
|
+
"comp",
|
|
74
|
+
J.current,
|
|
75
|
+
s
|
|
76
|
+
), () => {
|
|
77
|
+
var l;
|
|
78
|
+
(l = window.componentCenter) == null || l.removeInstance(e);
|
|
79
|
+
};
|
|
80
|
+
}, [n, i, s, q, u]);
|
|
81
|
+
}, t;
|
|
82
|
+
}, H = async (n, g) => {
|
|
83
|
+
$(n, g, E);
|
|
84
|
+
}, Q = async (n) => {
|
|
85
|
+
L({ ...n, setAttributes: H, adapter: M });
|
|
86
|
+
}, M = (n) => E(n);
|
|
87
|
+
export {
|
|
88
|
+
M as adapter,
|
|
89
|
+
H as setAttributes,
|
|
90
|
+
Q as start
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=index-BV9RX_Ka.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BV9RX_Ka.js","sources":["../src/plugins/report/adapter.ts","../src/plugins/report/index.ts"],"sourcesContent":["import { generateUUID } from '@sdata-plugin-adapter/utils';\r\nimport configJson from 'configJson';\r\nimport type {\r\n UseRegisterComponentParams,\r\n BaseReportProps,\r\n ReportAdapterProps,\r\n ActionsFunction,\r\n EventActionDefinitions,\r\n} from '@sdata-plugin-adapter/types';\r\nimport { SHOW_TYPE_TABLES } from '@/enmu';\r\nimport type { ShowType } from '@/enmu';\r\n\r\nconst isEnvProd = import.meta.env.PROD;\r\n\r\nconst { 'online-development-mode': onlineDevMode, 'requirement-number': requirMNumber } =\r\n configJson ?? {};\r\n\r\nconst adapterProps = (props: BaseReportProps): ReportAdapterProps => {\r\n const { useEffect, useRef } = window.React;\r\n const onlineDevelopmentMode: boolean = !!onlineDevMode?.open;\r\n const { type, formConfig, parent, component, configuration, changeConfiguration } = props;\r\n // 透传给二开的props\r\n const adapterProps = { ...props } as ReportAdapterProps;\r\n\r\n // alias\r\n adapterProps.formId = formConfig?.id;\r\n adapterProps.formName = formConfig?.form_name;\r\n adapterProps.isInChildTable = parent?.componentGroup === '表格组件';\r\n\r\n adapterProps.componentName = component?.columnStyle?.title;\r\n adapterProps.componentId = component?.id;\r\n\r\n /**\r\n * 扩展 props API: 仅限在宿主环境为smdata平台\r\n */\r\n if (isEnvProd || onlineDevelopmentMode) {\r\n adapterProps.customConfig = configuration ? JSON.parse(props.configuration) : {};\r\n // 重命名 changeConfiguration\r\n if (changeConfiguration) {\r\n adapterProps.changeCustomConfig = changeConfiguration;\r\n }\r\n\r\n if (type === 'query') {\r\n adapterProps.customConfig = JSON.parse(props.component?.customPluginConfig || '{}');\r\n }\r\n }\r\n\r\n // type === ‘query’\r\n if (type === 'query') {\r\n const { queryProps, queryData } = props;\r\n adapterProps.onSearch = queryProps.onSearch;\r\n adapterProps.queryData = queryProps.data;\r\n adapterProps.componentName = queryData?.title;\r\n adapterProps.onSearchChange = (value: unknown, type = 0) => {\r\n queryProps.onChange([\r\n {\r\n colId: queryProps.queryConfig.componentId,\r\n colName: queryProps.data.componentBusinessConfigList[0].businessName,\r\n value: value,\r\n type: type,\r\n },\r\n ]);\r\n };\r\n }\r\n /**\r\n * 逻辑控制通信API\r\n * 1、triggerEvent: 用来触发组件事件\r\n * @param {String} eventName 事件名\r\n * @param {Object} payload 事件传参\r\n * @example\r\n * triggerEvent(\"click\",{value:\"123\"})\r\n *\r\n * 2、useRegisterComponent: 用来注册组件的动作和事件\r\n */\r\n adapterProps.triggerEvent = (eventName: string, payload: Record<string, any> = {}) => {\r\n const { formConfig, componentId, index } = adapterProps;\r\n window?.eventCenter?.triggerEventNew({\r\n objectId: formConfig?.id,\r\n componentId: componentId,\r\n type: 'report',\r\n event: eventName,\r\n payload: { ...payload, childIndex: index },\r\n });\r\n };\r\n adapterProps.useRegisterComponent = (params: UseRegisterComponentParams) => {\r\n const { actions = {}, eventActionDefinitions } = params;\r\n const {\r\n instance,\r\n componentId,\r\n customConfig,\r\n component,\r\n isDesign = false,\r\n child_id,\r\n index,\r\n componentName,\r\n } = adapterProps;\r\n\r\n const _actions = Object.keys(actions).reduce((acc, key) => {\r\n if (key.includes('do_EventCenter_')) {\r\n acc[key] = actions[key];\r\n } else {\r\n acc[`do_EventCenter_${key}`] = actions[key];\r\n }\r\n return acc;\r\n }, {} as ActionsFunction);\r\n\r\n const isChildTableComponent = (showType: ShowType): boolean => {\r\n return SHOW_TYPE_TABLES.includes(showType);\r\n };\r\n\r\n const _getParent = () => {\r\n const parent = instance?.parent || component.parent;\r\n if (parent) {\r\n const result = {\r\n id: parent?.id,\r\n name: parent?.columnStyle?.title,\r\n showType: parent?.showType,\r\n };\r\n return isChildTableComponent(result.showType) ? result : undefined;\r\n }\r\n return undefined;\r\n };\r\n\r\n const Event_Center_getName = () => {\r\n return componentName || customConfig.id || requirMNumber || generateUUID();\r\n };\r\n const Event_Center_getParentId = () => component?.parent?.id;\r\n let ref =\r\n component?.parentId && _getParent() && props.type === 'set'\r\n ? // eslint-disable-next-line react-hooks/rules-of-hooks\r\n useRef({\r\n Event_Center_getName,\r\n ..._actions,\r\n Event_Center_getParentId,\r\n })\r\n : // eslint-disable-next-line react-hooks/rules-of-hooks\r\n useRef({ Event_Center_getName, ..._actions });\r\n useEffect(() => {\r\n let initId = componentId;\r\n if (!isDesign) {\r\n if ((typeof index === 'string' && index) || Number(index) > -1) {\r\n initId = `${initId}_childtable_${index}`;\r\n }\r\n }\r\n window.componentCenter?.register(\r\n initId,\r\n 'comp',\r\n ref.current,\r\n eventActionDefinitions as EventActionDefinitions,\r\n );\r\n return () => {\r\n window.componentCenter?.removeInstance(initId);\r\n };\r\n }, [props, actions, eventActionDefinitions, child_id, index]);\r\n };\r\n\r\n return adapterProps as ReportAdapterProps;\r\n};\r\n\r\nexport { adapterProps };\r\n","import { setDomAttributes } from '@sdata-plugin-adapter/utils';\r\nimport { adapterProps } from './adapter';\r\nimport { createPlugin } from '@/common/export';\r\nimport type {\r\n BaseReportProps,\r\n ReportAdapterProps,\r\n SetAttributes,\r\n StartOptions,\r\n} from '@sdata-plugin-adapter/types';\r\n\r\nexport const setAttributes: SetAttributes<BaseReportProps> = async (dom, props) => {\r\n setDomAttributes(dom, props, adapterProps);\r\n};\r\n\r\nexport const start = async (options: StartOptions<ReportAdapterProps>) => {\r\n createPlugin<BaseReportProps, ReportAdapterProps>({ ...options, setAttributes, adapter });\r\n};\r\n\r\nexport const adapter = (props: BaseReportProps) => {\r\n return adapterProps(props);\r\n};\r\n"],"names":["isEnvProd","onlineDevMode","requirMNumber","configJson","adapterProps","props","useEffect","useRef","onlineDevelopmentMode","type","formConfig","parent","component","configuration","changeConfiguration","_a","_b","queryProps","queryData","value","eventName","payload","componentId","index","params","actions","eventActionDefinitions","instance","customConfig","isDesign","child_id","componentName","_actions","acc","key","isChildTableComponent","showType","SHOW_TYPE_TABLES","_getParent","result","Event_Center_getName","generateUUID","Event_Center_getParentId","ref","initId","setAttributes","dom","setDomAttributes","start","options","createPlugin","adapter"],"mappings":";;;;;AAYA,MAAMA,IAAY,IAEZ,EAAE,2BAA2BC,GAAe,sBAAsBC,EAAA,IACtEC,KAAc,CAAA,GAEVC,IAAe,CAACC,MAA+C;;AACnE,QAAM,EAAE,WAAAC,GAAW,QAAAC,EAAA,IAAW,OAAO,OAC/BC,IAAiC,CAAC,EAACP,KAAA,QAAAA,EAAe,OAClD,EAAE,MAAAQ,GAAM,YAAAC,GAAY,QAAAC,GAAQ,WAAAC,GAAW,eAAAC,GAAe,qBAAAC,MAAwBT,GAE9ED,IAAe,EAAE,GAAGC,EAAA;AA0B1B,MAvBAD,EAAa,SAASM,KAAA,gBAAAA,EAAY,IAClCN,EAAa,WAAWM,KAAA,gBAAAA,EAAY,WACpCN,EAAa,kBAAiBO,KAAA,gBAAAA,EAAQ,oBAAmB,QAEzDP,EAAa,iBAAgBW,IAAAH,KAAA,gBAAAA,EAAW,gBAAX,gBAAAG,EAAwB,OACrDX,EAAa,cAAcQ,KAAA,gBAAAA,EAAW,KAKlCZ,KAAaQ,OACfJ,EAAa,eAAeS,IAAgB,KAAK,MAAMR,EAAM,aAAa,IAAI,CAAA,GAE1ES,MACFV,EAAa,qBAAqBU,IAGhCL,MAAS,YACXL,EAAa,eAAe,KAAK,QAAMY,IAAAX,EAAM,cAAN,gBAAAW,EAAiB,uBAAsB,IAAI,KAKlFP,MAAS,SAAS;AACpB,UAAM,EAAE,YAAAQ,GAAY,WAAAC,EAAA,IAAcb;AAClCD,IAAAA,EAAa,WAAWa,EAAW,UACnCb,EAAa,YAAYa,EAAW,MACpCb,EAAa,gBAAgBc,KAAA,gBAAA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