@plasmicapp/react-web 0.2.136 → 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.
Files changed (36) hide show
  1. package/dist/all.d.ts +49 -46
  2. package/dist/auth/PlasmicPageGuard.d.ts +7 -0
  3. package/dist/index-common.d.ts +2 -3
  4. package/dist/react-web.cjs.development.js +708 -1087
  5. package/dist/react-web.cjs.development.js.map +1 -1
  6. package/dist/react-web.cjs.production.min.js +1 -1
  7. package/dist/react-web.cjs.production.min.js.map +1 -1
  8. package/dist/react-web.esm.js +710 -1086
  9. package/dist/react-web.esm.js.map +1 -1
  10. package/dist/render/translation.d.ts +2 -1
  11. package/dist/states/graph.d.ts +23 -2
  12. package/dist/states/helpers.d.ts +7 -6
  13. package/dist/states/index.d.ts +4 -24
  14. package/dist/states/types.d.ts +24 -0
  15. package/dist/states/valtio.d.ts +2 -3
  16. package/dist/stories/UseDollarState.stories.d.ts +1 -0
  17. package/package.json +5 -6
  18. package/skinny/dist/auth/PlasmicPageGuard.d.ts +7 -0
  19. package/skinny/dist/index-common.d.ts +2 -3
  20. package/skinny/dist/index.js +393 -319
  21. package/skinny/dist/index.js.map +1 -1
  22. package/skinny/dist/plume/checkbox/index.js +1 -1
  23. package/skinny/dist/plume/menu/index.js +1 -1
  24. package/skinny/dist/plume/menu-button/index.js +1 -1
  25. package/skinny/dist/plume/select/index.js +1 -1
  26. package/skinny/dist/plume/switch/index.js +1 -1
  27. package/skinny/dist/render/translation.d.ts +2 -1
  28. package/skinny/dist/{ssr-b16a1854.js → ssr-f6caec06.js} +7 -6
  29. package/skinny/dist/ssr-f6caec06.js.map +1 -0
  30. package/skinny/dist/states/graph.d.ts +23 -2
  31. package/skinny/dist/states/helpers.d.ts +7 -6
  32. package/skinny/dist/states/index.d.ts +4 -24
  33. package/skinny/dist/states/types.d.ts +24 -0
  34. package/skinny/dist/states/valtio.d.ts +2 -3
  35. package/skinny/dist/stories/UseDollarState.stories.d.ts +1 -0
  36. package/skinny/dist/ssr-b16a1854.js.map +0 -1
@@ -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
+ 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 type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes?: number[]) => T;
2
- export 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 type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes?: number[]) => T;
2
+ export 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>): {};
@@ -59,6 +59,7 @@ export declare const StateCellIsArray: Story<{
59
59
  export declare const StateCellIsMatrix: Story<{
60
60
  board: number[][];
61
61
  }>;
62
+ export declare const IsOnChangePropImmediatelyFired: Story<{}>;
62
63
  export declare const ImmutableStateCells: Story<{
63
64
  people: Person[];
64
65
  }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssr-b16a1854.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import { PlasmicDataSourceContextProvider } from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\nexport {\n PlasmicDataSourceContextProvider,\n useCurrentUser,\n} from \"@plasmicapp/data-sources-context\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children, userAuthToken, user } = props as any;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n user,\n }),\n [userAuthToken, user]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,IAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,IAAM,OAAO,GAAG,UAAC,IAAqB;QACpC,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QACD,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,OAAO,IAAI,KAAK,SAAS;YACzB,OAAO,IAAI,KAAK,QAAQ,EACxB;YACA,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;SACxB;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,EAAE,CAAC;SACX;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;iBACpB,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,OAAO,CAAC,KAAK,CAAC,GAAA,CAAC;iBAC9B,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,CAAC,CAAC,KAAK,GAAA,CAAC;iBAC1B,IAAI,CAAC,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