@plasmicapp/react-web 0.2.176 → 0.2.178

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,7 +1,17 @@
1
+ import type { ComponentHelpers } from "@plasmicapp/host";
1
2
  import { useLayoutEffect } from "react";
2
3
  import { StateSpecNode } from "./graph";
3
- import { $State, ObjectPath, StateCell } from "./types";
4
+ import { $State, InitFunc, ObjectPath, StateCell } from "./types";
5
+ export declare function initializeCodeComponentStates($state: $State, states: {
6
+ name: string;
7
+ plasmicStateName: string;
8
+ }[], repetitionIndex: number[], componentHelpers: ComponentHelpers<any>, child$Props: Record<string, any>): void;
9
+ export declare function initializePlasmicStates($state: $State, states: {
10
+ name: string;
11
+ initFunc: InitFunc<any>;
12
+ }[], repetitionIndex: number[]): void;
4
13
  export declare function generateStateOnChangeProp($state: $State, path: ObjectPath): (val: any) => void;
14
+ export declare function generateStateOnChangePropForCodeComponents($state: $State, stateName: string, plasmicStatePath: ObjectPath, componentHelpers: ComponentHelpers<any>): (val: any) => void;
5
15
  export declare function generateStateValueProp($state: $State, path: ObjectPath): any;
6
16
  export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
7
17
  export declare function isPlasmicStateProxy(obj: any): boolean;
@@ -1,4 +1,4 @@
1
1
  export { default as get } from "dlv";
2
- export { generateStateOnChangeProp, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
2
+ export { generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, initializeCodeComponentStates, initializePlasmicStates, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
3
3
  export { $State, $StateSpec } from "./types";
4
4
  export { useDollarState } from "./valtio";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.176",
3
+ "version": "0.2.178",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -86,9 +86,9 @@
86
86
  },
87
87
  "prettier": {},
88
88
  "dependencies": {
89
- "@plasmicapp/data-sources": "0.1.50",
89
+ "@plasmicapp/data-sources": "0.1.51",
90
90
  "@plasmicapp/data-sources-context": "0.1.7",
91
- "@plasmicapp/host": "1.0.117",
91
+ "@plasmicapp/host": "1.0.118",
92
92
  "@plasmicapp/query": "0.1.61",
93
93
  "@react-aria/checkbox": "^3.5.0",
94
94
  "@react-aria/focus": "^3.7.0",
@@ -155,5 +155,5 @@
155
155
  "react": ">=16.8.0",
156
156
  "react-dom": ">=16.8.0"
157
157
  },
158
- "gitHead": "a1c72e430eeac84ef53622f2f7a4642e54657443"
158
+ "gitHead": "f5d0cd2ad8930d509f48d608bda4829c5158dc00"
159
159
  }
@@ -1322,9 +1322,67 @@ function useDollarState(specs) {
1322
1322
  return $state;
1323
1323
  }
1324
1324
 
1325
+ function initializeCodeComponentStates($state, states, repetitionIndex, componentHelpers, child$Props) {
1326
+ var e_1, _a;
1327
+ var _b, _c;
1328
+ var stateHelpers = (_b = componentHelpers === null || componentHelpers === void 0 ? void 0 : componentHelpers.states) !== null && _b !== void 0 ? _b : {};
1329
+ var _loop_1 = function (name_1, plasmicStateName) {
1330
+ if (name_1 in stateHelpers && "initFunc" in stateHelpers[name_1]) {
1331
+ (_c = $state.registerInitFunc) === null || _c === void 0 ? void 0 : _c.call($state, plasmicStateName, function (_a) {
1332
+ var _b, _c;
1333
+ var $props = _a.$props;
1334
+ return (_c = (_b = stateHelpers[name_1]).initFunc) === null || _c === void 0 ? void 0 : _c.call(_b, $props);
1335
+ }, repetitionIndex !== null && repetitionIndex !== void 0 ? repetitionIndex : [], { $props: child$Props });
1336
+ }
1337
+ };
1338
+ try {
1339
+ for (var states_1 = __values(states), states_1_1 = states_1.next(); !states_1_1.done; states_1_1 = states_1.next()) {
1340
+ var _d = states_1_1.value, name_1 = _d.name, plasmicStateName = _d.plasmicStateName;
1341
+ _loop_1(name_1, plasmicStateName);
1342
+ }
1343
+ }
1344
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1345
+ finally {
1346
+ try {
1347
+ if (states_1_1 && !states_1_1.done && (_a = states_1["return"])) _a.call(states_1);
1348
+ }
1349
+ finally { if (e_1) throw e_1.error; }
1350
+ }
1351
+ }
1352
+ function initializePlasmicStates($state, states, repetitionIndex) {
1353
+ var e_2, _a;
1354
+ var _b;
1355
+ try {
1356
+ for (var states_2 = __values(states), states_2_1 = states_2.next(); !states_2_1.done; states_2_1 = states_2.next()) {
1357
+ var _c = states_2_1.value, name_2 = _c.name, initFunc = _c.initFunc;
1358
+ (_b = $state.registerInitFunc) === null || _b === void 0 ? void 0 : _b.call($state, name_2, initFunc, repetitionIndex !== null && repetitionIndex !== void 0 ? repetitionIndex : []);
1359
+ }
1360
+ }
1361
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1362
+ finally {
1363
+ try {
1364
+ if (states_2_1 && !states_2_1.done && (_a = states_2["return"])) _a.call(states_2);
1365
+ }
1366
+ finally { if (e_2) throw e_2.error; }
1367
+ }
1368
+ }
1325
1369
  function generateStateOnChangeProp($state, path) {
1326
1370
  return function (val) { return set($state, path, val); };
1327
1371
  }
1372
+ function generateStateOnChangePropForCodeComponents($state, stateName, plasmicStatePath, componentHelpers) {
1373
+ var _a, _b;
1374
+ var onChangeArgsToValue = (_b = (_a = componentHelpers === null || componentHelpers === void 0 ? void 0 : componentHelpers.states) === null || _a === void 0 ? void 0 : _a[stateName]) === null || _b === void 0 ? void 0 : _b.onChangeArgsToValue;
1375
+ if (!onChangeArgsToValue || typeof onChangeArgsToValue !== "function") {
1376
+ return generateStateOnChangeProp($state, plasmicStatePath);
1377
+ }
1378
+ return function () {
1379
+ var args = [];
1380
+ for (var _i = 0; _i < arguments.length; _i++) {
1381
+ args[_i] = arguments[_i];
1382
+ }
1383
+ return generateStateOnChangeProp($state, plasmicStatePath)(onChangeArgsToValue.apply(null, args));
1384
+ };
1385
+ }
1328
1386
  function generateStateValueProp($state, path) {
1329
1387
  return get($state, path);
1330
1388
  }
@@ -1478,5 +1536,5 @@ function assignValue(object, key, value) {
1478
1536
  // Utilities used by generated code
1479
1537
  var classNames = classNames$1;
1480
1538
 
1481
- export { PlasmicIcon, PlasmicLink, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, wrapWithClassName };
1539
+ export { PlasmicIcon, PlasmicLink, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, initializeCodeComponentStates, initializePlasmicStates, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, wrapWithClassName };
1482
1540
  //# sourceMappingURL=index.js.map