@plasmicapp/react-web 0.2.137 → 0.2.138

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,15 +1,36 @@
1
- import { $StateSpec, Internal$StateSpec } from ".";
1
+ import { $StateSpec, InitFunc, Internal$StateSpec, ObjectPath } from "./types";
2
+ export interface StateCell<T> {
3
+ initialValue?: T | Symbol;
4
+ path: ObjectPath;
5
+ registeredInitFunc?: InitFunc<T>;
6
+ listeners: (() => void)[];
7
+ }
2
8
  export declare class StateSpecNode<T> {
3
9
  private specs;
4
10
  private edges;
11
+ private state;
5
12
  constructor(specs: Internal$StateSpec<T>[]);
6
13
  hasEdge(key: string | symbol): boolean;
7
14
  addEdge(key: string | symbol, node: StateSpecNode<any>): void;
15
+ children(): IterableIterator<StateSpecNode<any>>;
8
16
  makeTransition(key: string | symbol | number): StateSpecNode<any> | undefined;
9
17
  isLeaf(): boolean;
10
18
  hasArrayTransition(): boolean;
11
19
  getSpec(): Internal$StateSpec<T>;
12
20
  getAllSpecs(): Internal$StateSpec<T>[];
21
+ getState(path: ObjectPath): StateCell<T>;
22
+ clearStates(): void;
23
+ states(): StateCell<T>[];
24
+ hasState(path: ObjectPath): boolean;
25
+ createStateCell(path: ObjectPath): void;
26
+ setInitialValue(path: ObjectPath, value: any): void;
27
+ getInitialValue(path: ObjectPath): Symbol | T | undefined;
28
+ addListener(path: ObjectPath, f: () => void): void;
13
29
  }
14
30
  export declare const transformPathStringToObj: (str: string) => (string | symbol)[];
15
- export declare function buildGraph(specs: $StateSpec<any>[]): StateSpecNode<any>;
31
+ export declare function buildTree(specs: $StateSpec<any>[]): StateSpecNode<any>;
32
+ export declare function getLeaves(root: StateSpecNode<any>): StateSpecNode<any>[];
33
+ export declare function findStateCell(root: StateSpecNode<any>, pathStr: string, repetitionIndex?: number[]): {
34
+ node: StateSpecNode<any>;
35
+ realPath: ObjectPath;
36
+ };
@@ -1,6 +1,5 @@
1
- import get from "dlv";
2
1
  import { useLayoutEffect } from "react";
3
- import { $State } from ".";
2
+ import { $State } from "./types";
4
3
  export declare function generateStateOnChangeProp($state: $State, stateName: string, dataReps: number[]): (val: any, path: (string | number)[]) => void;
5
4
  /**
6
5
  * This function generate the state value prop for repeated states
@@ -9,12 +8,14 @@ export declare function generateStateOnChangeProp($state: $State, stateName: str
9
8
  * We need to pass `parent[index1][index2].counter to the child component
10
9
  */
11
10
  export declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
11
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
12
+ export declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
13
+ export declare function isNum(value: string | number | symbol): value is number;
14
+ declare type StringGen = string | (() => string);
15
+ export declare function assert<T>(cond: T, msg?: StringGen): asserts cond;
12
16
  /**
13
17
  * Forked from https://github.com/lukeed/dset
14
18
  * Changes: fixed setting a deep value to a proxy object
15
19
  */
16
20
  export declare function set(obj: any, keys: any, val: any): void;
17
- export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
18
- export declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
19
- export declare function isNum(value: string | number | symbol): value is number;
20
- export { get };
21
+ export {};
@@ -1,24 +1,4 @@
1
- export declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes?: number[]) => T;
2
- export declare type ObjectPath = (string | number)[];
3
- export interface $StateSpec<T> {
4
- path: string;
5
- initFunc?: InitFunc<T>;
6
- initVal?: T;
7
- type: "private" | "readonly" | "writable";
8
- valueProp?: string;
9
- onChangeProp?: string;
10
- isImmutable?: boolean;
11
- }
12
- export interface $State {
13
- [key: string]: any;
14
- registerInitFunc?: (path: string, f: InitFunc<any>) => any;
15
- }
16
- export declare const ARRAY_SYMBOL: unique symbol;
17
- export interface Internal$StateSpec<T> extends $StateSpec<T> {
18
- isRepeated: boolean;
19
- pathObj: (string | symbol)[];
20
- }
21
- export interface Internal$StateInstance {
22
- path: ObjectPath;
23
- specKey: string;
24
- }
1
+ export { default as get } from "dlv";
2
+ export { generateStateOnChangeProp, generateStateValueProp, set, } from "./helpers";
3
+ export { $State } from "./types";
4
+ export { useDollarState } from "./valtio";
@@ -0,0 +1,24 @@
1
+ export declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes?: number[]) => T;
2
+ export declare type ObjectPath = (string | number)[];
3
+ export interface $StateSpec<T> {
4
+ path: string;
5
+ initFunc?: InitFunc<T>;
6
+ initVal?: T;
7
+ type: "private" | "readonly" | "writable";
8
+ valueProp?: string;
9
+ onChangeProp?: string;
10
+ isImmutable?: boolean;
11
+ }
12
+ export interface $State {
13
+ [key: string]: any;
14
+ registerInitFunc?: (path: string, f: InitFunc<any>, repetitonIndex?: number[]) => any;
15
+ }
16
+ export declare const ARRAY_SYMBOL: unique symbol;
17
+ export interface Internal$StateSpec<T> extends $StateSpec<T> {
18
+ isRepeated: boolean;
19
+ pathObj: (string | symbol)[];
20
+ }
21
+ export interface Internal$StateInstance {
22
+ path: ObjectPath;
23
+ specKey: string;
24
+ }
@@ -1,4 +1,3 @@
1
- import { $StateSpec } from ".";
2
- export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
1
+ import { $State, $StateSpec } from "./types";
2
+ export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): $State;
3
3
  export default useDollarState;
4
- export declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): {};
@@ -58,6 +58,7 @@ export declare const StateCellIsArray: import("@storybook/csf").AnnotatedStoryFn
58
58
  export declare const StateCellIsMatrix: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {
59
59
  board: number[][];
60
60
  }>;
61
+ export declare const IsOnChangePropImmediatelyFired: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {}>;
61
62
  export declare const ImmutableStateCells: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {
62
63
  people: Person[];
63
64
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.137",
3
+ "version": "0.2.138",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -65,7 +65,6 @@
65
65
  "classnames": "^2.2.6",
66
66
  "clone": "^2.1.2",
67
67
  "dlv": "^1.1.3",
68
- "dset": "^3.1.2",
69
68
  "fast-deep-equal": "^3.1.3",
70
69
  "valtio": "^1.6.3"
71
70
  },
@@ -110,5 +109,5 @@
110
109
  "react": ">=16.8.0",
111
110
  "react-dom": ">=16.8.0"
112
111
  },
113
- "gitHead": "e282c9cca3a168a822b34a1a5e6de3a6a072c00f"
112
+ "gitHead": "29e95851972acf14bf3ff15462022d322f4c6b57"
114
113
  }
@@ -14,7 +14,5 @@ export { PlasmicDataSourceContextProvider, PlasmicRootProvider, useCurrentUser,
14
14
  export { Stack } from "./render/Stack";
15
15
  export { genTranslatableString, Trans } from "./render/translation";
16
16
  export { useTrigger } from "./render/triggers";
17
- export { $State } from "./states";
18
- export * from "./states/helpers";
19
- export { default as useDollarState, useCanvasDollarState, } from "./states/valtio";
17
+ export * from "./states";
20
18
  export declare const classNames: typeof _classNames;