@plasmicapp/react-web 0.2.123 → 0.2.125

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,4 +1,5 @@
1
1
  import get from "dlv";
2
+ import { useLayoutEffect } from "react";
2
3
  import { $State } from ".";
3
4
  export declare function generateStateOnChangeProp($state: $State, stateName: string, dataReps: number[]): (val: any, path: (string | number)[]) => void;
4
5
  /**
@@ -13,4 +14,5 @@ export declare function generateStateValueProp($state: $State, path: (string | n
13
14
  * Changes: fixed setting a deep value to a proxy object
14
15
  */
15
16
  export declare function set(obj: any, keys: any, val: any): void;
17
+ export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
16
18
  export { get };
@@ -1,4 +1,4 @@
1
- declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, indexes: number[]) => T;
1
+ declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes: number[]) => T;
2
2
  export interface $State {
3
3
  [key: string]: any;
4
4
  registerInitFunc?: (path: string, f: InitFunc<any>) => any;
@@ -12,6 +12,6 @@ export interface $StateSpec<T> {
12
12
  onChangeProp?: string;
13
13
  isArray?: boolean;
14
14
  }
15
- export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
15
+ export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
16
16
  export default useDollarState;
17
- export declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
17
+ export declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
@@ -31,7 +31,13 @@ export declare const RepeatedStates: import("@storybook/csf").AnnotatedStoryFn<i
31
31
  }>;
32
32
  export declare const NestedRepeatedCounter: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {}>;
33
33
  export declare const MatrixRepeatedCounter: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {}>;
34
- export declare const InitFuncFromContextData: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {
34
+ export declare const InitFuncFromInternalContextData: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {
35
+ products: {
36
+ price: number;
37
+ name: string;
38
+ }[];
39
+ }>;
40
+ export declare const InitFuncFromRootContextData: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, {
35
41
  products: {
36
42
  price: number;
37
43
  name: string;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dataSources = require('@plasmicapp/data-sources');
6
+
7
+
8
+
9
+ Object.keys(dataSources).forEach(function (k) {
10
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return dataSources[k];
14
+ }
15
+ });
16
+ });
17
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
- "module": "index.js"
3
+ "exports": {
4
+ "import": "./index.js",
5
+ "require": "./index.cjs.js"
6
+ }
4
7
  }
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var host = require('@plasmicapp/host');
6
+
7
+
8
+
9
+ Object.keys(host).forEach(function (k) {
10
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return host[k];
14
+ }
15
+ });
16
+ });
17
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
- "module": "index.js"
3
+ "exports": {
4
+ "import": "./index.js",
5
+ "require": "./index.cjs.js"
6
+ }
4
7
  }
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var query = require('@plasmicapp/query');
6
+
7
+
8
+
9
+ Object.keys(query).forEach(function (k) {
10
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return query[k];
14
+ }
15
+ });
16
+ });
17
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
- "module": "index.js"
3
+ "exports": {
4
+ "import": "./index.js",
5
+ "require": "./index.cjs.js"
6
+ }
4
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.123",
3
+ "version": "0.2.125",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,9 +40,9 @@
40
40
  },
41
41
  "prettier": {},
42
42
  "dependencies": {
43
- "@plasmicapp/data-sources": "0.1.13",
43
+ "@plasmicapp/data-sources": "0.1.14",
44
44
  "@plasmicapp/data-sources-context": "0.1.2",
45
- "@plasmicapp/host": "1.0.84",
45
+ "@plasmicapp/host": "1.0.85",
46
46
  "@plasmicapp/query": "0.1.55",
47
47
  "@react-aria/checkbox": "^3.5.0",
48
48
  "@react-aria/focus": "^3.7.0",
@@ -108,5 +108,5 @@
108
108
  "react": ">=16.8.0",
109
109
  "react-dom": ">=16.8.0"
110
110
  },
111
- "gitHead": "fe8ebae44fdf80156a58149a7d7781525a939252"
111
+ "gitHead": "b53e96d1eae801c0774e7e51c5217c3416d5ba47"
112
112
  }
@@ -2,8 +2,8 @@ import classNames$1 from 'classnames';
2
2
  import get from 'dlv';
3
3
  export { default as get } from 'dlv';
4
4
  import * as React from 'react';
5
- import React__default from 'react';
6
- import { c as createElementWithChildren, m as mergeProps, e as ensureNotArray, N as NONE, a as mergePropVals, i as isReactNode, b as isBrowser, u as useIsomorphicLayoutEffect } from './react-utils-7bc53870.js';
5
+ import React__default, { useLayoutEffect, useEffect } from 'react';
6
+ import { c as createElementWithChildren, m as mergeProps, e as ensureNotArray, N as NONE, a as mergePropVals, i as isReactNode, b as isBrowser, u as useIsomorphicLayoutEffect$1 } from './react-utils-7bc53870.js';
7
7
  import { _ as __rest, a as __assign, b as __spreadArray, c as __read, o as omit, p as pick, d as __values, i as isSubset, e as chainSingleArgFuncs, n as notNil } from './common-9ebe374e.js';
8
8
  export { o as omit, p as pick } from './common-9ebe374e.js';
9
9
  export { PlasmicHead, plasmicHeadMeta } from './render/PlasmicHead/index.js';
@@ -537,7 +537,7 @@ function createUseScreenVariants(isMulti, screenQueries) {
537
537
  // register our forceUpdate. This ensures that if there was
538
538
  // a window resize event between render and effects, that the
539
539
  // listener will be registered in time
540
- useIsomorphicLayoutEffect(function () {
540
+ useIsomorphicLayoutEffect$1(function () {
541
541
  var updateIfChanged = function () {
542
542
  if (curScreenVariants &&
543
543
  lastScreenVariantsRef.current.join("") !== curScreenVariants.join("")) {
@@ -679,9 +679,12 @@ function set(obj, keys, val) {
679
679
  }
680
680
  }
681
681
  }
682
- }
682
+ }
683
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
683
684
 
684
- var mkUntrackedValue = function (o) { return (typeof o === "object" ? ref(o) : o); };
685
+ var mkUntrackedValue = function (o) {
686
+ return o != null && typeof o === "object" ? ref(o) : o;
687
+ };
685
688
  var transformPathStringToObj = function (str) {
686
689
  var splitStatePathPart = function (state) {
687
690
  return state.endsWith("[]")
@@ -878,11 +881,11 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
878
881
  stateAccess.forEach(function (_a) {
879
882
  var path = _a.path, spec = _a.spec;
880
883
  var unsubscribe = subscribeKey(get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
881
- return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
884
+ return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec))));
882
885
  });
883
886
  $$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
884
887
  });
885
- var initialValue = initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec));
888
+ var initialValue = initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(initialStatePath, initialSpec));
886
889
  saveStateInitialValue($$state, initialStatePath, initialSpec, initialValue);
887
890
  return initialValue;
888
891
  }
@@ -904,7 +907,7 @@ function saveStateInitialValue($$state, path, spec, initialValue) {
904
907
  set($$state.initStateValues, path, untrackedValue);
905
908
  }
906
909
  }
907
- function useDollarState(specs, props) {
910
+ function useDollarState(specs, props, $ctx) {
908
911
  var $$state = React__default.useRef(proxy({
909
912
  stateValues: {},
910
913
  initStateValues: {},
@@ -917,10 +920,12 @@ function useDollarState(specs, props) {
917
920
  statesInstanceBySpec: new Map(),
918
921
  existingStates: new Map(),
919
922
  unsubscriptionsByState: {},
920
- props: undefined,
923
+ props: {},
924
+ ctx: {},
921
925
  registrationsQueue: []
922
926
  })).current;
923
927
  $$state.props = mkUntrackedValue(props);
928
+ $$state.ctx = mkUntrackedValue($ctx !== null && $ctx !== void 0 ? $ctx : {});
924
929
  var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
925
930
  var _a;
926
931
  var key = JSON.stringify(path);
@@ -958,7 +963,7 @@ function useDollarState(specs, props) {
958
963
  if ((_a = $$state.statesInstanceBySpec
959
964
  .get(pathStr)) === null || _a === void 0 ? void 0 : _a.some(function (_a) {
960
965
  var path = _a.path, specKey = _a.specKey;
961
- return !deepEqual(get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
966
+ return !deepEqual(get($$state.initStateValues, path), f(props, $state, $ctx !== null && $ctx !== void 0 ? $ctx : {}, getIndexes(path, $$state.specsByKey[specKey])));
962
967
  })) {
963
968
  $$state.registrationsQueue.push({ pathStr: pathStr, f: f });
964
969
  }
@@ -971,13 +976,13 @@ function useDollarState(specs, props) {
971
976
  var path = _a.path, specKey = _a.specKey;
972
977
  var spec = $$state.specsByKey[specKey];
973
978
  if (spec.initFunc) {
974
- var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
979
+ var newInit = spec.initFunc(props, $state, $ctx !== null && $ctx !== void 0 ? $ctx : {}, getIndexes(path, spec));
975
980
  if (!deepEqual(newInit, get($$state.initStateValues, path))) {
976
981
  resetSpecs.push({ path: path, spec: spec });
977
982
  }
978
983
  }
979
984
  });
980
- React__default.useLayoutEffect(function () {
985
+ useIsomorphicLayoutEffect(function () {
981
986
  resetSpecs.forEach(function (_a) {
982
987
  var _b, _c;
983
988
  var path = _a.path, spec = _a.spec;
@@ -987,7 +992,7 @@ function useDollarState(specs, props) {
987
992
  }
988
993
  });
989
994
  }, [props, resetSpecs]);
990
- React__default.useLayoutEffect(function () {
995
+ useIsomorphicLayoutEffect(function () {
991
996
  $$state.registrationsQueue.forEach(function (_a) {
992
997
  var f = _a.f, pathStr = _a.pathStr;
993
998
  $$state.specsByKey[pathStr].initFunc = f;
@@ -1000,7 +1005,7 @@ function useDollarState(specs, props) {
1000
1005
  return $state;
1001
1006
  }
1002
1007
  // Simple version of $state useDollarState for read-only
1003
- function useCanvasDollarState(specs, props) {
1008
+ function useCanvasDollarState(specs, props, $ctx) {
1004
1009
  var e_2, _a;
1005
1010
  var $$state = proxy({
1006
1011
  stateValues: {},
@@ -1012,10 +1017,12 @@ function useCanvasDollarState(specs, props) {
1012
1017
  statesInstanceBySpec: new Map(),
1013
1018
  existingStates: new Map(),
1014
1019
  unsubscriptionsByState: {},
1015
- props: undefined,
1020
+ props: {},
1021
+ ctx: {},
1016
1022
  registrationsQueue: []
1017
1023
  });
1018
1024
  $$state.props = mkUntrackedValue(props);
1025
+ $$state.ctx = mkUntrackedValue($ctx);
1019
1026
  var $state = create$StateProxy($$state, function (path, spec) {
1020
1027
  return {
1021
1028
  get: function () {
@@ -1058,5 +1065,5 @@ function useCanvasDollarState(specs, props) {
1058
1065
  // Utilities used by generated code
1059
1066
  var classNames = classNames$1;
1060
1067
 
1061
- export { PlasmicIcon, PlasmicLink, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateValueProp, hasVariant, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, set, useCanvasDollarState, useDollarState, useTrigger, wrapWithClassName };
1068
+ export { PlasmicIcon, PlasmicLink, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateValueProp, hasVariant, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, set, useCanvasDollarState, useDollarState, useIsomorphicLayoutEffect, useTrigger, wrapWithClassName };
1062
1069
  //# sourceMappingURL=index.js.map