@simpleform/render 4.1.17 → 4.1.19

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/lib/store.d.ts CHANGED
@@ -1,16 +1,12 @@
1
- /// <reference types="react" />
2
1
  import { CustomUnionType, FormRenderProps, WidgetList } from "./typings";
3
2
  export type FormRenderListener<V> = (newValue?: V, oldValue?: V) => void;
4
3
  export declare class SimpleFormRender {
5
- config?: {
6
- variables?: FormRenderProps['variables'];
7
- components?: FormRenderProps['components'];
8
- };
4
+ config?: FormRenderProps;
9
5
  private widgetList;
10
6
  private lastWidgetList;
11
7
  private widgetListListeners;
12
8
  constructor(config?: SimpleFormRender['config']);
13
- defineConfig(data?: SimpleFormRender['config']): void;
9
+ defineConfig(payload?: SimpleFormRender['config'] | ((config?: FormRenderProps) => Partial<FormRenderProps>)): void;
14
10
  getFormComponent(target?: CustomUnionType): any;
15
11
  createFormElement(target?: CustomUnionType, commonProps?: unknown): import("react").ReactNode;
16
12
  getWidgetList(): WidgetList;
@@ -19,9 +15,9 @@ export declare class SimpleFormRender {
19
15
  }): void;
20
16
  setItemByPath: (data?: unknown, path?: string) => void;
21
17
  setItemByIndex: <V>(data?: unknown, index?: number, parent?: string) => void;
22
- insertItemByIndex: <V>(data?: V | V[] | undefined, index?: number, parent?: string) => void;
18
+ insertItemByIndex: <V>(data?: V | Array<V>, index?: number, parent?: string) => void;
23
19
  delItemByPath: (path?: string) => void;
24
- getItemByPath: <V>(path?: string) => V | undefined;
20
+ getItemByPath: (path?: string) => undefined;
25
21
  getItemByIndex: <V>(index: number, parent?: string) => V | undefined;
26
22
  moveItemByPath: (from: {
27
23
  parent?: string;
package/lib/typings.d.ts CHANGED
@@ -21,7 +21,7 @@ export type GenerateWidgetItem<P = {}> = P & FormItemProps & {
21
21
  export type WidgetItem<P = {}> = {
22
22
  [key in keyof GenerateWidgetItem<P>]: (string | GenerateWidgetItem<P>[key]);
23
23
  };
24
- export type WidgetOptions<P = {}> = GenerateWidgetItem<P> & Pick<FormChildrenProps, 'form' | 'formrender' | 'renderList' | 'renderItem'> & {
24
+ export type WidgetOptions<P = {}> = GenerateWidgetItem<P> & Pick<FormChildrenProps, 'formrender'> & Pick<FormProps, 'form'> & {
25
25
  index?: number;
26
26
  path?: string;
27
27
  };
@@ -29,12 +29,16 @@ export type WidgetContextProps<P = {}> = {
29
29
  _options?: WidgetOptions<P>;
30
30
  };
31
31
  export type CustomRenderType = <C, P = {}>(children?: C, context?: WidgetContextProps<P>) => C;
32
- export type FormChildrenProps<P = {}> = Pick<FormProps, 'form'> & Pick<GenerateWidgetItem<P>, 'inside'> & {
32
+ export type FormChildrenProps<P = {}> = {
33
+ /**@deprecated no longer recommended, please use 'options.inside' instead */
34
+ inside?: GenerateWidgetItem<P>['inside'];
35
+ /**@deprecated no longer recommended */
36
+ form?: FormProps['form'];
33
37
  formrender?: SimpleFormRender;
34
38
  options?: GenerateWidgetItem<P> | ((item?: GenerateWidgetItem<P>) => GenerateWidgetItem<P>);
35
- uneval?: boolean;
39
+ parser?: <V>(value?: unknown, variables?: object) => V;
36
40
  components?: RegisteredComponents;
37
- /**@deprecated plugins由variables代替 */
41
+ /**@deprecated no longer recommended, please use 'variables' instead */
38
42
  plugins?: Record<string, unknown>;
39
43
  variables?: Record<string, unknown>;
40
44
  widgetList?: WidgetList<P>;
@@ -42,4 +46,4 @@ export type FormChildrenProps<P = {}> = Pick<FormProps, 'form'> & Pick<GenerateW
42
46
  renderItem?: CustomRenderType;
43
47
  onRenderChange?: (newData?: WidgetList<P>, oldData?: WidgetList<P>) => void;
44
48
  };
45
- export type FormRenderProps<P = {}> = FormProps & FormChildrenProps<P>;
49
+ export type FormRenderProps<P = {}> = FormProps & Omit<FormChildrenProps<P>, 'form'>;
@@ -1,17 +1,17 @@
1
1
  import React from 'react';
2
2
  import { CustomRenderType, CustomUnionType, FormRenderProps, RegisteredComponents, WidgetContextProps, WidgetItem, WidgetList } from "../typings";
3
- export declare const mergeFormOptions: <V>(oldConfig: V, newConfig?: Partial<V> | undefined, mergeFunNames?: string[]) => V;
3
+ export declare const mergeFormOptions: <V>(oldConfig: V, newConfig?: Partial<V>, mergeFunNames?: string[]) => V;
4
+ export declare const matchExpression: (value?: unknown) => string | undefined;
5
+ export declare const toExpression: (val?: unknown) => string | undefined;
6
+ export declare const parseExpression: <V>(value: V, variables?: object) => any;
4
7
  export declare const traverseMapObject: (val: any, callback: any) => any;
5
- export declare const traverseWidgetList: <R>(list?: WidgetList, callback?: ((item: WidgetItem, _options: {
8
+ export declare const traverseWidgetList: <R>(list?: WidgetList, callback?: (item: WidgetItem, _options: {
6
9
  path: string;
7
10
  index?: number;
8
- }, children?: R[] | undefined) => R) | undefined, parent?: string) => any;
9
- export declare const matchExpression: (value?: unknown) => string | undefined;
10
- export declare const evalAttr: <V>(val: V, variables?: object, uneval?: boolean) => any;
11
+ }, children?: R[]) => R, parent?: string) => any;
12
+ export declare const evalAttr: <V>(val: V, variables?: object, parser?: FormRenderProps["parser"]) => any;
11
13
  export declare const getInitialValues: <V>(widgetList?: WidgetList) => V | undefined;
12
14
  export declare const getFormComponent: (target?: any, widgets?: RegisteredComponents) => any;
13
15
  export declare const createFormElement: (target?: CustomUnionType, props?: unknown, widgets?: RegisteredComponents) => React.ReactNode;
14
- export declare const transformStr: (str?: string) => string | undefined;
15
- export declare const compileExpression: <V>(value: V, variables?: object, uneval?: boolean) => any;
16
16
  export declare const withSide: (target?: React.ReactNode, customRender?: CustomRenderType, side?: React.ReactNode, context?: WidgetContextProps) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
17
- export declare const renderWidgetItem: (formrender?: FormRenderProps['formrender'], target?: CustomUnionType, options?: WidgetContextProps['_options']) => any;
17
+ export declare const renderWidgetItem: (formrender?: FormRenderProps["formrender"], target?: CustomUnionType, options?: WidgetContextProps["_options"]) => any;
@@ -7,12 +7,12 @@ export declare function isNumber<T>(data: T): boolean;
7
7
  export declare function isString<T>(data: T): boolean;
8
8
  export declare function isFunction<T>(data: T): boolean;
9
9
  export declare function isArray<T>(data: T): boolean;
10
- export declare function isDate<T>(data: T): boolean;
10
+ export declare function isDate<T>(data: T): data is T & Date;
11
11
  export declare function isRegExp<T>(data: T): boolean;
12
12
  export declare function isUndefined<T>(data: T): boolean;
13
13
  export declare function isNull<T>(data: T): boolean;
14
14
  export declare function isObject<T>(data: T): boolean;
15
- export declare function isElement<T>(data: T): boolean;
15
+ export declare function isElement<T>(data: T): data is T & Element;
16
16
  export declare function isDom<T>(data: T & {
17
17
  nodeType?: number;
18
18
  nodeName?: string;
@@ -30,5 +30,5 @@ export declare function isStream<T>(data: T & {
30
30
  pipe?: Function;
31
31
  }): boolean;
32
32
  export declare function isBase<T>(data: T): boolean;
33
- export declare const isNumberStr: <T>(str?: T | undefined) => true | undefined;
34
- export declare const isBase64: <T>(str?: T | undefined) => boolean | undefined;
33
+ export declare const isNumberStr: <T>(str?: T) => true | undefined;
34
+ export declare const isBase64: <T>(str?: T) => boolean | undefined;
@@ -1,24 +1,19 @@
1
+ import { FormPathType } from "@simpleform/form";
1
2
  import { WidgetList } from "../typings";
2
3
  export declare const getPathEnd: (path?: string) => string | number | undefined;
3
4
  export declare const getParent: (path?: string) => string;
4
5
  export declare const getPathLen: (path?: string) => number;
5
- export declare const setItemByPath: (widgetList?: WidgetList, data?: unknown, path?: string) => WidgetList | undefined;
6
- export type GetItemByPath = {
7
- (widgetList?: WidgetList): WidgetList | undefined;
8
- <V>(widgetList?: WidgetList, path?: string): V | undefined;
9
- };
10
- export declare const getItemByPath: GetItemByPath;
6
+ export declare const setItemByPath: <V>(widgetList?: V, data?: unknown, path?: string) => V | undefined;
7
+ export declare const getItemByPath: <V, Path extends FormPathType = string>(widgetList?: V, path?: Path) => import("@simpleform/form/lib/typings").PathValue<V, Path> | undefined;
11
8
  export declare const getKeyValueByIndex: <V>(widgetList?: WidgetList, index?: number, parent?: string) => [string, V] | undefined;
12
- export declare const toEntries: <T>(data: T) => {
9
+ export declare const toEntries: <V>(data: any) => {
13
10
  isList: boolean;
14
- entries: (T extends (infer I)[] | Record<string, infer I> ? [string, I] : unknown)[];
11
+ entries: Array<[string, V]>;
15
12
  };
16
- export type ParseEntries = {
17
- <T>(entries: Array<[string, T]>): Record<string, T>;
18
- <T>(entries: Array<[string, T]>, isList: boolean): Array<T> | Record<string, T>;
13
+ export declare const parseEntries: <T>(entries: Array<[string, T]>, isList?: boolean) => T[] | {
14
+ [k: string]: T;
19
15
  };
20
- export declare const parseEntries: ParseEntries;
21
- export declare const insertItemByIndex: <V>(widgetList?: WidgetList, data?: V | V[] | undefined, index?: number, parent?: string) => WidgetList | undefined;
16
+ export declare const insertItemByIndex: <V>(widgetList?: WidgetList, data?: V | Array<V>, index?: number, parent?: string) => WidgetList | undefined;
22
17
  export declare const moveSameLevel: (widgetList: WidgetList | undefined, from: {
23
18
  parent?: string;
24
19
  index: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleform/render",
3
- "version": "4.1.17",
3
+ "version": "4.1.19",
4
4
  "description": "dynamic rendering core of simple form",
5
5
  "author": "mezhanglei <496623925@qq.com>",
6
6
  "homepage": "https://github.com/mezhanglei/simpleform#readme",
@@ -45,9 +45,10 @@
45
45
  "react-router-dom": "^6.19.0"
46
46
  },
47
47
  "dependencies": {
48
- "@simpleform/form": "^2.1.9",
48
+ "@simpleform/form": "^2.1.11",
49
49
  "classnames": "^2.3.2",
50
- "copy-anything": "^3.0.5"
50
+ "copy-anything": "^3.0.5",
51
+ "serialize-javascript": "^6.0.2"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "antd": ">=4.0.0",