@plasmicapp/react-web 0.2.234 → 0.2.236

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.
@@ -6,6 +6,7 @@ export declare function initializeCodeComponentStates($state: $State, states: {
6
6
  name: string;
7
7
  plasmicStateName: string;
8
8
  }[], repetitionIndex: number[], componentHelpers: ComponentHelpers<any>, child$Props: Record<string, any>): void;
9
+ export declare function generateOnMutateForSpec(stateName: string, componentHelpers: ComponentHelpers<any>): ((stateValue: any, $ref: any) => void) | undefined;
9
10
  export declare function initializePlasmicStates($state: $State, states: {
10
11
  name: string;
11
12
  initFunc: InitFunc<any>;
@@ -1,4 +1,4 @@
1
1
  export { default as get } from "dlv";
2
- export { generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
2
+ export { generateOnMutateForSpec, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
3
3
  export { $State, $StateSpec } from "./types";
4
4
  export { useDollarState } from "./valtio";
@@ -4,6 +4,7 @@ export type InitFuncEnv = {
4
4
  $state: Record<string, any>;
5
5
  $queries?: Record<string, any>;
6
6
  $ctx?: Record<string, any>;
7
+ $refs?: Record<string, any>;
7
8
  };
8
9
  export type DollarStateEnv = Omit<InitFuncEnv, "$state">;
9
10
  export type NoUndefinedField<T> = {
@@ -22,6 +23,8 @@ export interface $StateSpec<T> {
22
23
  isImmutable?: boolean;
23
24
  variableType: "text" | "number" | "boolean" | "array" | "object" | "variant";
24
25
  initFuncHash?: string;
26
+ refName?: string;
27
+ onMutate?: (stateValue: T, $ref: any) => void;
25
28
  }
26
29
  export interface $State {
27
30
  [key: string]: any;
@@ -39,7 +42,7 @@ export interface Internal$StateInstance {
39
42
  specKey: string;
40
43
  }
41
44
  export interface StateCell<T> {
42
- initialValue?: T | Symbol;
45
+ initialValue?: T | symbol;
43
46
  node: StateSpecNode<any>;
44
47
  path: ObjectPath;
45
48
  initFunc?: InitFunc<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.234",
3
+ "version": "0.2.236",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -86,9 +86,9 @@
86
86
  "prettier": {},
87
87
  "dependencies": {
88
88
  "@plasmicapp/auth-react": "^0.0.5",
89
- "@plasmicapp/data-sources": "0.1.94",
89
+ "@plasmicapp/data-sources": "0.1.96",
90
90
  "@plasmicapp/data-sources-context": "0.1.11",
91
- "@plasmicapp/host": "1.0.149",
91
+ "@plasmicapp/host": "1.0.151",
92
92
  "@plasmicapp/prepass": "1.0.1",
93
93
  "@plasmicapp/query": "0.1.67",
94
94
  "@react-aria/checkbox": "^3.5.0",
@@ -155,5 +155,5 @@
155
155
  "react": ">=16.8.0",
156
156
  "react-dom": ">=16.8.0"
157
157
  },
158
- "gitHead": "ff42d1b747943bedcc21cb39f8ffb92d38347292"
158
+ "gitHead": "35d4595c6d82b47128fdb0c536fab54d7bbc609f"
159
159
  }
@@ -986,9 +986,13 @@ function subscribeToValtio($$state, statePath, node) {
986
986
  var maybeValtioProxy = spec.valueProp
987
987
  ? $$state.env.$props[spec.valueProp]
988
988
  : get($$state.stateValues, statePath);
989
- if (getVersion(maybeValtioProxy) && spec.onChangeProp) {
989
+ if (getVersion(maybeValtioProxy) &&
990
+ (spec.onChangeProp || (spec.onMutate && node.isLeaf()))) {
990
991
  var unsub = subscribe(maybeValtioProxy, function () {
991
992
  var _a, _b;
993
+ if (spec.onMutate && node.isLeaf()) {
994
+ spec.onMutate(maybeValtioProxy, spec.refName ? $$state.env.$refs[spec.refName] : undefined);
995
+ }
992
996
  (_b = (_a = $$state.env.$props)[spec.onChangeProp]) === null || _b === void 0 ? void 0 : _b.call(_a, spec.valueProp
993
997
  ? $$state.env.$props[spec.valueProp]
994
998
  : get($$state.stateValues, statePath));
@@ -1157,11 +1161,12 @@ var mkUntrackedValue = function (o) {
1157
1161
  return o != null && typeof o === "object" ? ref(o) : o;
1158
1162
  };
1159
1163
  var envFieldsAreNonNill = function (env) {
1160
- var _a, _b;
1164
+ var _a, _b, _c;
1161
1165
  return ({
1162
1166
  $props: env.$props,
1163
1167
  $ctx: (_a = env.$ctx) !== null && _a !== void 0 ? _a : {},
1164
1168
  $queries: (_b = env.$queries) !== null && _b !== void 0 ? _b : {},
1169
+ $refs: (_c = env.$refs) !== null && _c !== void 0 ? _c : {},
1165
1170
  });
1166
1171
  };
1167
1172
  /**
@@ -1398,6 +1403,10 @@ function initializeCodeComponentStates($state, states, repetitionIndex, componen
1398
1403
  finally { if (e_1) throw e_1.error; }
1399
1404
  }
1400
1405
  }
1406
+ function generateOnMutateForSpec(stateName, componentHelpers) {
1407
+ var _a, _b;
1408
+ return (_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.onMutate;
1409
+ }
1401
1410
  function initializePlasmicStates($state, states, repetitionIndex) {
1402
1411
  var e_2, _a;
1403
1412
  var _b;
@@ -1592,5 +1601,5 @@ function assignValue(object, key, value) {
1592
1601
  // Utilities used by generated code
1593
1602
  var classNames = classNames$1;
1594
1603
 
1595
- export { PlasmicIcon, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, withPlasmicPageGuard, wrapWithClassName };
1604
+ export { PlasmicIcon, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateOnMutateForSpec, generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, hasVariant, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, resetToInitialValue, set, useDollarState, useTrigger, withPlasmicPageGuard, wrapWithClassName };
1596
1605
  //# sourceMappingURL=index.js.map