plain-design 1.0.0-beta.111 → 1.0.0-beta.113

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plain-design",
3
- "version": "1.0.0-beta.111",
3
+ "version": "1.0.0-beta.113",
4
4
  "description": "",
5
5
  "main": "dist/plain-design.min.js",
6
6
  "module": "dist/plain-design.commonjs.min.js",
@@ -45,7 +45,7 @@
45
45
  "@babel/preset-env": "7.23.7",
46
46
  "@babel/preset-react": "7.23.3",
47
47
  "@babel/preset-typescript": "7.23.3",
48
- "@peryl/react-compose": "0.0.204",
48
+ "@peryl/react-compose": "0.0.205",
49
49
  "@types/classnames": "^2.2.11",
50
50
  "@types/react": "18.2.4",
51
51
  "@types/react-dom": "18.2.4",
@@ -12,6 +12,7 @@ import {tStyleComputed} from "../../uses/useStyle";
12
12
  import {getTableRowHeight} from "../Table/table/utils/table.utils";
13
13
  import {PlcIndex} from "../Table/standard/PlcIndex";
14
14
  import {createPopupEditor} from "../usePopupEditor";
15
+ import {tEditControl} from "../../uses/useEdit";
15
16
 
16
17
  export function createCascadePopper(
17
18
  {
@@ -31,7 +32,7 @@ export function createCascadePopper(
31
32
  getPublicPopperAttrs: () => any,
32
33
  onPopperClose: () => void,
33
34
  onPopperShow?: () => void,
34
- editControl: { editComputed: { value: { editable: boolean } } }
35
+ editControl: tEditControl
35
36
  refs: { input: typeof Input.use.class | null | undefined },
36
37
  scopeSlots: any,
37
38
  getTreeAttrs: () => any,
@@ -25,6 +25,7 @@ export const RenderPlcTreeNode = designComponent({
25
25
  const { refs, onRef } = useRefs({ el: iHTMLDivElement });
26
26
 
27
27
  const isLeaf = computed(() => props.treeNode.isLeaf());
28
+ const leafIcon = computed(() => props.treeNode.leafIcon());
28
29
  const checkStatus = cacheComputed(() => props.treeNode.checkStatus());
29
30
  const isExpanded = cacheComputed(() => props.treeNode.isExpanded());
30
31
 
@@ -63,7 +64,7 @@ export const RenderPlcTreeNode = designComponent({
63
64
 
64
65
  return () => {
65
66
  const { treeNode, tableNode } = props;
66
- const { leafIcon, folderExpandIcon, folderCollapseIcon } = props.treeCore.props;
67
+ const { folderExpandIcon, folderCollapseIcon } = props.treeCore.props;
67
68
  return (
68
69
  <div className={getComponentCls('plc-tree-node')} ref={onRef.el}>
69
70
  <div className="tree-node-operator">
@@ -74,7 +75,7 @@ export const RenderPlcTreeNode = designComponent({
74
75
  {treeNode.isLoading() ?
75
76
  <Loading type="gamma"/> :
76
77
  <Icon
77
- icon={isLeaf.value || treeNode.empty ? leafIcon : isExpanded.value ? folderExpandIcon : folderCollapseIcon}
78
+ icon={isLeaf.value || treeNode.empty ? leafIcon.value : isExpanded.value ? folderExpandIcon : folderCollapseIcon}
78
79
  />}
79
80
  </div>
80
81
  {props.treeCore.props.multiple && (
@@ -44,6 +44,7 @@ export const RenderTreeNode = designComponent({
44
44
  const checkStatus = cacheComputed(() => props.treeNode.checkStatus());
45
45
  const isExpanded = cacheComputed(() => props.treeNode.isExpanded());
46
46
  const isLeaf = cacheComputed(() => props.treeNode.isLeaf());
47
+ const leafIcon = computed(() => props.treeNode.leafIcon());
47
48
 
48
49
  const connectorClassesList = computed(() => {
49
50
 
@@ -124,7 +125,7 @@ export const RenderTreeNode = designComponent({
124
125
  props.treeNode.isLoading() ?
125
126
  <Loading type="gamma"/> :
126
127
  <Icon
127
- icon={props.treeNode.isLeaf() || props.treeNode.empty ? tree.props.leafIcon : isExpanded.value ? tree.props.folderExpandIcon : tree.props.folderCollapseIcon}
128
+ icon={props.treeNode.isLeaf() || props.treeNode.empty ? leafIcon.value : isExpanded.value ? tree.props.folderExpandIcon : tree.props.folderCollapseIcon}
128
129
  />
129
130
  }
130
131
  </div>
@@ -70,7 +70,7 @@ export interface iTreeProps {
70
70
  /*判断节点是否可以放置*/
71
71
  isAllowDroppable?: (startNode: iTreeNode, moveNode: iTreeNode, dropType: typeof eTreeDropType.TYPE) => boolean | void,
72
72
  /*叶子节点图标*/
73
- leafIcon: string,
73
+ leafIcon: string | ((treeNode: iTreeNode) => string),
74
74
  /*节点收起时显示图标*/
75
75
  folderCollapseIcon: string,
76
76
  /*节点展开时显示的图标*/
@@ -112,6 +112,8 @@ export function createTreeNode(
112
112
  /*默认情况下,没有设置isLeaf来判断节点是否为叶子节点的话,则判断是否存在有子节点数据来判断是否为叶子节点,如果子节点数据是一个空数组也视为非叶子节点*/
113
113
  return !props.isLeaf ? !childrenData() : props.isLeaf(data);
114
114
  };
115
+ /*叶子节点的图标*/
116
+ const leafIcon = () => {return typeof props.leafIcon === "string" ? props.leafIcon : props.leafIcon(data);};
115
117
  /*是否已经选中*/
116
118
  const checkStatus = (): typeof CheckboxStatus.TYPE => getCheckStatus()[key];
117
119
  /*是否可选中*/
@@ -194,6 +196,7 @@ export function createTreeNode(
194
196
  setChildrenData,
195
197
  children,
196
198
  isLeaf,
199
+ leafIcon,
197
200
  checkStatus,
198
201
  isCheckAble,
199
202
  isExpanded,
@@ -225,6 +228,7 @@ export interface iTreeNode {
225
228
  setChildrenData: (childrenData: any[] | null | undefined) => void, // 设置节点子数据
226
229
  children: () => iTreeNode[], // 子节点
227
230
  isLeaf: () => boolean, // 节点是否为叶子节点
231
+ leafIcon: () => string, // 叶子节点的图标
228
232
  checkStatus: () => typeof CheckboxStatus.TYPE, // 节点的选中状态,check选中,uncheck未选中,minus半选
229
233
  isCheckAble: () => boolean, // 节点是否可以选中
230
234
  isExpanded: () => boolean, // 节点是否已经展开
@@ -15,6 +15,7 @@ export const EditProps = {
15
15
  } as const;
16
16
 
17
17
  export interface EditProvideData {
18
+ editable: boolean | null,
18
19
  disabled: boolean | null,
19
20
  readonly: boolean | null,
20
21
  loading: boolean | null,
@@ -32,7 +33,10 @@ export const useEdit = useFunctionWrapper(
32
33
 
33
34
  const editState = reactive({ loading: null as null | boolean });
34
35
 
35
- const editComputed = computed(() => {
36
+ const editComputed = computed((): EditProvideData => {
37
+
38
+ if (ctx.isDestroyed) {return {} as EditProvideData;}
39
+
36
40
  const {
37
41
  disabled,
38
42
  readonly,
@@ -40,7 +44,7 @@ export const useEdit = useFunctionWrapper(
40
44
  placeholder
41
45
  } = ctx.props as any as EditProvideData;
42
46
 
43
- let data = { disabled, readonly, loading, placeholder };
47
+ let data: EditProvideData = { disabled, readonly, loading, placeholder, editable: false };
44
48
 
45
49
  if (data.disabled == null) data.disabled = !!parentEditComputed ? parentEditComputed.value.disabled : false;
46
50
  if (data.readonly == null) data.readonly = !!parentEditComputed ? parentEditComputed.value.readonly : false;
@@ -47,6 +47,8 @@ export const useStyle = useFunctionWrapper('style', (ctx, option: UseStyleOption
47
47
  const parent = inject(USE_STYLE_PROVIDER, null) as null | { value: UseStyleProvideData };
48
48
 
49
49
  const styleComputed = computed(() => {
50
+ if (ctx.isDestroyed) {return {} as UseStyleProvideData;}
51
+
50
52
  const defaultData = Object.assign({ shape: applicationConfiguration.value.default.shape, size: applicationConfiguration.value.default.size, inputMode: applicationConfiguration.value.default.inputMode }, option);
51
53
 
52
54
  const { shape, size, status, inputMode } = ctx.props;