plain-design 1.0.0-beta.110 → 1.0.0-beta.112

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.110",
3
+ "version": "1.0.0-beta.112",
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.203",
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,
@@ -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;
@@ -1,4 +1,5 @@
1
- import {getCurrentDesignInstance} from '@peryl/react-compose';
1
+ import {getCurrentDesignInstance, onBeforeUnmount} from '@peryl/react-compose';
2
+ import {delay} from "@peryl/utils/delay";
2
3
 
3
4
  type Shift<T> = T extends [infer L, ...infer R] ? R : T
4
5
 
@@ -9,6 +10,7 @@ export function useFunctionWrapper<T extends (ctx: any, ...args: any[]) => any>(
9
10
  return (...args) => {
10
11
  const ctx = getCurrentDesignInstance() as any;
11
12
  if (!ctx._use) ctx._use = {};
13
+ onBeforeUnmount(() => delay().then(() => {delete ctx._use;}));
12
14
 
13
15
  if (!!ctx._use[key]) {
14
16
  throw new Error(`use ${key} can only be executed once!`);
@@ -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;