@plasmicapp/react-web 0.2.103 → 0.2.106

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 (66) hide show
  1. package/dist/all.d.ts +495 -106
  2. package/dist/index-common.d.ts +2 -1
  3. package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  4. package/dist/plume/select/index.d.ts +1 -0
  5. package/dist/plume/triggered-overlay/index.d.ts +1 -0
  6. package/dist/react-web.cjs.development.js +302 -127
  7. package/dist/react-web.cjs.development.js.map +1 -1
  8. package/dist/react-web.cjs.production.min.js +1 -1
  9. package/dist/react-web.cjs.production.min.js.map +1 -1
  10. package/dist/react-web.esm.js +300 -129
  11. package/dist/react-web.esm.js.map +1 -1
  12. package/dist/render/PlasmicHead.d.ts +35 -0
  13. package/dist/render/ssr.d.ts +2 -1
  14. package/dist/render/triggers.d.ts +4 -4
  15. package/dist/states/index.d.ts +3 -1
  16. package/dist/stories/UseDollarState.stories.d.ts +7 -0
  17. package/package.json +20 -19
  18. package/skinny/dist/collection-utils-3487dd27.js +238 -0
  19. package/skinny/dist/collection-utils-3487dd27.js.map +1 -0
  20. package/skinny/dist/collection-utils-57c273dc.js +238 -0
  21. package/skinny/dist/collection-utils-57c273dc.js.map +1 -0
  22. package/skinny/dist/common-182a0b0c.js +201 -0
  23. package/skinny/dist/common-182a0b0c.js.map +1 -0
  24. package/skinny/dist/index-common.d.ts +2 -1
  25. package/skinny/dist/index.js +65 -45
  26. package/skinny/dist/index.js.map +1 -1
  27. package/skinny/dist/plume/button/index.js +5 -5
  28. package/skinny/dist/plume/button/index.js.map +1 -1
  29. package/skinny/dist/plume/checkbox/index.js +7 -7
  30. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  31. package/skinny/dist/plume/menu/index.js +12 -12
  32. package/skinny/dist/plume/menu/index.js.map +1 -1
  33. package/skinny/dist/plume/menu-button/index.js +7 -7
  34. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  35. package/skinny/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  36. package/skinny/dist/plume/select/index.d.ts +1 -0
  37. package/skinny/dist/plume/select/index.js +13 -13
  38. package/skinny/dist/plume/select/index.js.map +1 -1
  39. package/skinny/dist/plume/switch/index.js +7 -7
  40. package/skinny/dist/plume/switch/index.js.map +1 -1
  41. package/skinny/dist/plume/text-input/index.js +5 -5
  42. package/skinny/dist/plume/text-input/index.js.map +1 -1
  43. package/skinny/dist/plume/triggered-overlay/index.d.ts +1 -0
  44. package/skinny/dist/plume/triggered-overlay/index.js +8 -7
  45. package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
  46. package/skinny/dist/plume-utils-623b91cc.js +35 -0
  47. package/skinny/dist/plume-utils-623b91cc.js.map +1 -0
  48. package/skinny/dist/props-utils-b2ad4997.js +8 -0
  49. package/skinny/dist/props-utils-b2ad4997.js.map +1 -0
  50. package/skinny/dist/react-utils-35cb2a4e.js +201 -0
  51. package/skinny/dist/react-utils-35cb2a4e.js.map +1 -0
  52. package/skinny/dist/render/PlasmicHead.d.ts +35 -0
  53. package/skinny/dist/render/PlasmicImg/index.js +3 -3
  54. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  55. package/skinny/dist/render/ssr.d.ts +2 -1
  56. package/skinny/dist/render/triggers.d.ts +4 -4
  57. package/skinny/dist/ssr-14264281.js +158 -0
  58. package/skinny/dist/ssr-14264281.js.map +1 -0
  59. package/skinny/dist/ssr-579df58f.js +158 -0
  60. package/skinny/dist/ssr-579df58f.js.map +1 -0
  61. package/skinny/dist/ssr-9ebd98ed.js +158 -0
  62. package/skinny/dist/ssr-9ebd98ed.js.map +1 -0
  63. package/skinny/dist/ssr-d2fd94f2.js +31 -0
  64. package/skinny/dist/ssr-d2fd94f2.js.map +1 -0
  65. package/skinny/dist/states/index.d.ts +3 -1
  66. package/skinny/dist/stories/UseDollarState.stories.d.ts +7 -0
@@ -15,7 +15,7 @@ export declare function useMenuTrigger(opts: {
15
15
  menuWidth?: number;
16
16
  menu: React.ReactElement<BaseMenuProps> | (() => React.ReactElement<BaseMenuProps>);
17
17
  }, state: MenuTriggerState): {
18
- triggerProps: React.HTMLAttributes<HTMLElement>;
18
+ triggerProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
19
19
  makeMenu: () => React.ReactElement<BaseMenuProps, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
20
20
  triggerContext: TriggeredOverlayContextValue;
21
21
  };
@@ -1,3 +1,4 @@
1
1
  export { BaseSelectProps, SelectRef, SelectRefValue, useSelect, } from "./select";
2
2
  export { BaseSelectOptionProps, SelectOptionRef, useSelectOption, } from "./select-option";
3
3
  export { BaseSelectOptionGroupProps, useSelectOptionGroup, } from "./select-option-group";
4
+ export { SelectContext } from "./context";
@@ -1 +1,2 @@
1
1
  export { BaseTriggeredOverlayProps, TriggeredOverlayConfig, TriggeredOverlayRef, useTriggeredOverlay, } from "./triggered-overlay";
2
+ export { TriggeredOverlayContext } from "./context";
@@ -811,6 +811,83 @@ function ensureGlobalVariants(globalVariantValues) {
811
811
  return globalVariantValues;
812
812
  }
813
813
 
814
+ var PlasmicHeadContext = /*#__PURE__*/React.createContext(undefined);
815
+ function PlasmicHead(props) {
816
+ var Head = React.useContext(PlasmicHeadContext);
817
+
818
+ if (!Head) {
819
+ console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider."); // TODO: Link to doc about Head.
820
+
821
+ return null;
822
+ }
823
+
824
+ return React.createElement(Head, null, props.image ? React.createElement(React.Fragment, null, React.createElement("meta", {
825
+ name: "twitter:card",
826
+ content: "summary_large_image"
827
+ }), React.createElement("meta", {
828
+ key: "og:image",
829
+ property: "og:image",
830
+ content: props.image
831
+ }), React.createElement("meta", {
832
+ key: "twitter:image",
833
+ name: "twitter:image",
834
+ content: props.image
835
+ })) : React.createElement("meta", {
836
+ name: "twitter:card",
837
+ content: "summary"
838
+ }), props.title && React.createElement(React.Fragment, null, React.createElement("title", {
839
+ key: "title"
840
+ }, props.title), React.createElement("meta", {
841
+ key: "og:title",
842
+ property: "og:title",
843
+ content: props.title
844
+ }), React.createElement("meta", {
845
+ key: "twitter:title",
846
+ property: "twitter:title",
847
+ content: props.title
848
+ })), props.description && React.createElement(React.Fragment, null, React.createElement("meta", {
849
+ key: "description",
850
+ name: "description",
851
+ content: props.description
852
+ }), React.createElement("meta", {
853
+ key: "og:description",
854
+ property: "og:description",
855
+ content: props.description
856
+ }), React.createElement("meta", {
857
+ key: "twitter:description",
858
+ name: "twitter:description",
859
+ content: props.description
860
+ })), props.canonical && React.createElement("link", {
861
+ ref: "canonical",
862
+ href: props.canonical
863
+ }));
864
+ }
865
+ var plasmicHeadMeta = {
866
+ name: "hostless-plasmic-head",
867
+ displayName: "Head",
868
+ description: "Used to add page metadata to HEAD tag",
869
+ importName: "PlasmicHead",
870
+ importPath: "@plasmicapp/react-web",
871
+ props: {
872
+ title: {
873
+ type: "string",
874
+ displayName: "Title"
875
+ },
876
+ description: {
877
+ type: "string",
878
+ displayName: "Description"
879
+ },
880
+ image: {
881
+ type: "imageUrl",
882
+ displayName: "Image"
883
+ },
884
+ canonical: {
885
+ type: "string",
886
+ displayName: "Canonical URL"
887
+ }
888
+ }
889
+ };
890
+
814
891
  function PlasmicIcon(props) {
815
892
  var PlasmicIconType = props.PlasmicIconType,
816
893
  rest = _objectWithoutPropertiesLoose(props, ["PlasmicIconType"]);
@@ -1464,7 +1541,9 @@ function PlasmicRootProvider(props) {
1464
1541
  value: context
1465
1542
  }, React.createElement(ssr.SSRProvider, null, React.createElement(PlasmicTranslatorContext.Provider, {
1466
1543
  value: props.translator
1467
- }, children)));
1544
+ }, React.createElement(PlasmicHeadContext.Provider, {
1545
+ value: props.Head
1546
+ }, children))));
1468
1547
  }
1469
1548
  var useIsSSR = ssr.useIsSSR;
1470
1549
  function useHasPlasmicRoot() {
@@ -3174,8 +3253,8 @@ function mkProxy(specs, maybeHandlers) {
3174
3253
  };
3175
3254
  };
3176
3255
 
3177
- var rec = function rec(currPath) {
3178
- var nextParts = Object.fromEntries(specs.filter(function (spec) {
3256
+ var getNextParts = function getNextParts(currPath) {
3257
+ return Object.fromEntries(Object.values(specs).filter(function (spec) {
3179
3258
  return shallowEqual(currPath.map(function (p) {
3180
3259
  return isNum(p) ? "[]" : p;
3181
3260
  }), spec.path.slice(0, currPath.length));
@@ -3185,16 +3264,74 @@ function mkProxy(specs, maybeHandlers) {
3185
3264
  if (spec.path.length === currPath.length + 1) {
3186
3265
  return [nextPart, {
3187
3266
  isLast: true,
3188
- spec: spec
3267
+ specKey: spec.pathStr
3189
3268
  }];
3190
3269
  } else {
3191
3270
  return [nextPart, {
3192
3271
  isLast: false,
3193
- spec: spec
3272
+ specKey: spec.pathStr
3194
3273
  }];
3195
3274
  }
3196
3275
  }));
3276
+ };
3277
+ /**
3278
+ * We use this function when we're setting a value in the middle of the state path.
3279
+ * We can't just set the value, because we need to keep the proxy properties, so
3280
+ * we use the specs to walk through the object and just set the value in the end of the path
3281
+ **/
3282
+
3283
+
3284
+ var cloneValue = function cloneValue(target, currPath, value) {
3285
+ if (typeof value !== "object") {
3286
+ return;
3287
+ }
3288
+
3289
+ var nextParts = getNextParts(currPath);
3290
+
3291
+ for (var _i = 0, _Object$entries = Object.entries(nextParts); _i < _Object$entries.length; _i++) {
3292
+ var _Object$entries$_i = _Object$entries[_i],
3293
+ nextPart = _Object$entries$_i[0],
3294
+ _Object$entries$_i$ = _Object$entries$_i[1],
3295
+ isLast = _Object$entries$_i$.isLast,
3296
+ specKey = _Object$entries$_i$.specKey;
3297
+
3298
+ if (nextPart === "[]" && Array.isArray(value)) {
3299
+ for (var i = 0; i < value.length; i++) {
3300
+ cloneValue(target[i], [].concat(currPath, [i]), value[i]);
3301
+ }
3302
+ } else if (nextPart in value) {
3303
+ if (isLast) {
3304
+ var _handlers$set, _handlers;
3305
+
3306
+ handlers == null ? void 0 : (_handlers$set = (_handlers = handlers({
3307
+ specKey: specKey,
3308
+ path: [].concat(currPath, [nextPart])
3309
+ })).set) == null ? void 0 : _handlers$set.call(_handlers, target, nextPart, value[nextPart], undefined);
3310
+ } else {
3311
+ cloneValue(target[nextPart], [].concat(currPath, [nextPart]), value[nextPart]);
3312
+ }
3313
+ }
3314
+ }
3315
+ };
3316
+
3317
+ var rec = function rec(currPath) {
3318
+ var nextParts = getNextParts(currPath);
3197
3319
  return new Proxy("[]" in nextParts ? [] : {}, {
3320
+ deleteProperty: function deleteProperty(target, property) {
3321
+ if ("[]" in nextParts && isNum(property)) {
3322
+ var _handlers$deletePrope, _handlers2;
3323
+
3324
+ delete target[property];
3325
+ handlers == null ? void 0 : (_handlers$deletePrope = (_handlers2 = handlers({
3326
+ path: [].concat(currPath, [+property]),
3327
+ specKey: nextParts["[]"].specKey
3328
+ })).deleteProperty) == null ? void 0 : _handlers$deletePrope.call(_handlers2, target, property);
3329
+ } else {
3330
+ throw new Error("You can't delete a non-repeated property in the middle of the path");
3331
+ }
3332
+
3333
+ return true;
3334
+ },
3198
3335
  get: function get(target, property, receiver) {
3199
3336
  if ("[]" in nextParts && isNum(property)) {
3200
3337
  if (!(property in target)) {
@@ -3202,12 +3339,12 @@ function mkProxy(specs, maybeHandlers) {
3202
3339
  }
3203
3340
  } else if (property in nextParts) {
3204
3341
  if (nextParts[property].isLast) {
3205
- var _handlers$get, _handlers;
3342
+ var _handlers$get, _handlers3;
3206
3343
 
3207
- return handlers == null ? void 0 : (_handlers$get = (_handlers = handlers({
3344
+ return target[property] = handlers == null ? void 0 : (_handlers$get = (_handlers3 = handlers({
3208
3345
  path: [].concat(currPath, [property]),
3209
- spec: nextParts[property].spec
3210
- })).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
3346
+ specKey: nextParts[property].specKey
3347
+ })).get) == null ? void 0 : _handlers$get.call(_handlers3, target, property, receiver);
3211
3348
  } else if (!(property in target)) {
3212
3349
  target[property] = rec([].concat(currPath, [property]));
3213
3350
  }
@@ -3216,21 +3353,29 @@ function mkProxy(specs, maybeHandlers) {
3216
3353
  return target[property];
3217
3354
  },
3218
3355
  set: function set(target, property, value, receiver) {
3219
- if (!(property in target) && property in nextParts) {
3356
+ if ("[]" in nextParts && isNum(property)) {
3357
+ if (!(property in target)) {
3358
+ target[property] = rec([].concat(currPath, [+property]));
3359
+ }
3360
+ } else if (property in nextParts) {
3220
3361
  if (nextParts[property].isLast) {
3221
- var _handlers$set, _handlers$set2, _handlers2;
3362
+ var _handlers$set2, _handlers$set3, _handlers4;
3222
3363
 
3223
- return (_handlers$set = (_handlers$set2 = (_handlers2 = handlers({
3364
+ target[property] = value;
3365
+ return (_handlers$set2 = (_handlers$set3 = (_handlers4 = handlers({
3224
3366
  path: [].concat(currPath, [property]),
3225
- spec: nextParts[property].spec
3226
- })).set) == null ? void 0 : _handlers$set2.call(_handlers2, target, property, value, receiver)) != null ? _handlers$set : false;
3227
- } else {
3228
- throw new Error("You can't set a value in the middle of the path");
3367
+ specKey: nextParts[property].specKey
3368
+ })).set) == null ? void 0 : _handlers$set3.call(_handlers4, target, property, value, receiver)) != null ? _handlers$set2 : false;
3229
3369
  }
3230
- } else {
3370
+ }
3371
+
3372
+ if (property === "registerInitFunc") {
3231
3373
  target[property] = value;
3232
- return true;
3374
+ } else if (typeof value === "object") {
3375
+ cloneValue(target[property], [].concat(currPath, [isNum(property) ? +property : property]), value);
3233
3376
  }
3377
+
3378
+ return true;
3234
3379
  }
3235
3380
  });
3236
3381
  };
@@ -3266,133 +3411,141 @@ var transformPathStringToObj = function transformPathStringToObj(str) {
3266
3411
  };
3267
3412
 
3268
3413
  function useVanillaDollarState(_specs, props) {
3269
- var specs = _specs.map(function (_ref2) {
3270
- var pathStr = _ref2.path,
3271
- spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
3272
-
3273
- return _extends({}, spec, {
3274
- pathStr: pathStr,
3275
- path: transformPathStringToObj(pathStr),
3276
- isRepeated: pathStr.split(".").some(function (part) {
3277
- return part.endsWith("[]");
3278
- })
3279
- });
3280
- });
3281
-
3282
- var _React$useState = React__default.useState(function () {
3283
- var stateValues = mkProxy(specs);
3284
- var initStates = {};
3285
-
3286
- for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
3287
- var spec = _step.value;
3288
-
3289
- if (spec.valueProp || spec.isRepeated) {
3290
- continue;
3291
- } else if (spec.initFunc) {
3292
- dset.dset(stateValues, spec.path, UNINITIALIZED);
3293
- } else {
3294
- var _spec$initVal;
3295
-
3296
- dset.dset(stateValues, spec.path, (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined);
3297
- }
3298
-
3299
- saveState({
3300
- path: spec.path,
3301
- spec: spec
3302
- }, initStates);
3303
- }
3304
-
3305
- var deps = fillUninitializedStateValues(specs, props, stateValues, initStates);
3414
+ var forceRender = React__default.useState(0)[1];
3415
+ var $$state = React__default.useMemo(function () {
3416
+ var specs = Object.fromEntries(_specs.map(function (_ref2) {
3417
+ var pathStr = _ref2.path,
3418
+ spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
3419
+
3420
+ return [pathStr, _extends({}, spec, {
3421
+ pathStr: pathStr,
3422
+ path: transformPathStringToObj(pathStr),
3423
+ isRepeated: pathStr.split(".").some(function (part) {
3424
+ return part.endsWith("[]");
3425
+ })
3426
+ })];
3427
+ }));
3306
3428
  return {
3307
- stateValues: stateValues,
3308
- initStateDeps: deps,
3309
- initStateValues: cloneProxy(specs, initStates, stateValues),
3310
- states: initStates
3429
+ stateValues: mkProxy(specs),
3430
+ initStateDeps: {},
3431
+ initStateValues: mkProxy(specs),
3432
+ states: {},
3433
+ specs: specs
3311
3434
  };
3312
- }),
3313
- $$state = _React$useState[0],
3314
- set$$State = _React$useState[1];
3315
-
3316
- var $state = mkProxy(specs, function (state) {
3435
+ }, []);
3436
+ var $state = Object.assign(mkProxy($$state.specs, function (state) {
3317
3437
  return {
3438
+ deleteProperty: function deleteProperty(_target, _property) {
3439
+ var prefixPath = state.path;
3440
+
3441
+ for (var _i2 = 0, _Object$entries2 = Object.entries($$state.states); _i2 < _Object$entries2.length; _i2++) {
3442
+ var _Object$entries2$_i = _Object$entries2[_i2],
3443
+ key = _Object$entries2$_i[0],
3444
+ existingState = _Object$entries2$_i[1];
3445
+
3446
+ if (existingState.path.length >= prefixPath.length && shallowEqual(existingState.path.slice(0, prefixPath.length), prefixPath)) {
3447
+ delete $$state.states[key];
3448
+ }
3449
+ }
3450
+
3451
+ forceRender(function (r) {
3452
+ return r + 1;
3453
+ });
3454
+ return true;
3455
+ },
3318
3456
  get: function get(_target, _property) {
3319
- if (state.spec.valueProp) {
3320
- if (!state.spec.isRepeated) {
3321
- return props[state.spec.valueProp];
3457
+ var spec = $$state.specs[state.specKey];
3458
+
3459
+ if (spec.valueProp) {
3460
+ if (!spec.isRepeated) {
3461
+ return props[spec.valueProp];
3322
3462
  } else {
3323
- return _get(props[state.spec.valueProp], state.path.slice(1));
3463
+ return _get(props[spec.valueProp], state.path.slice(1));
3324
3464
  }
3325
3465
  }
3326
3466
 
3327
3467
  if (!hasState(state, $$state.states)) {
3328
- var _state$spec$initVal;
3468
+ var _spec$initVal;
3329
3469
 
3330
3470
  saveState(state, $$state.states);
3331
3471
 
3332
- dset.dset($$state.stateValues, state.path, state.spec.initFunc ? UNINITIALIZED : (_state$spec$initVal = state.spec.initVal) != null ? _state$spec$initVal : undefined);
3472
+ dset.dset($$state.stateValues, state.path, spec.initFunc ? UNINITIALIZED : (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined);
3333
3473
 
3334
- var deps = state.spec.initFunc ? fillUninitializedStateValues(specs, props, $$state.stateValues, $$state.states) : {};
3474
+ var deps = spec.initFunc ? fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states) : {};
3335
3475
 
3336
3476
  dset.dset($$state.initStateValues, state.path, _get($$state.stateValues, state.path));
3337
3477
 
3338
- set$$State(function (prev) {
3339
- return {
3340
- initStateValues: cloneProxy(specs, prev.states, prev.stateValues),
3341
- stateValues: cloneProxy(specs, prev.states, prev.initStateValues),
3342
- initStateDeps: _extends({}, prev.initStateDeps, deps),
3343
- states: _extends({}, prev.states)
3344
- };
3478
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, deps);
3479
+ forceRender(function (r) {
3480
+ return r + 1;
3345
3481
  });
3482
+ return spec.initFunc ? spec.initFunc(props, $state) : spec.initVal;
3346
3483
  }
3347
3484
 
3348
3485
  return _get($$state.stateValues, state.path);
3349
3486
  },
3350
3487
  set: function set(_target, _property, newValue) {
3351
- saveState(state, $$state.states);
3352
-
3353
3488
  if (newValue !== _get($$state.stateValues, state.path)) {
3489
+ saveState(state, $$state.states);
3490
+
3354
3491
  dset.dset($$state.stateValues, state.path, newValue);
3355
3492
 
3356
- for (var _i = 0, _Object$entries = Object.entries($$state.initStateDeps); _i < _Object$entries.length; _i++) {
3357
- var _Object$entries$_i = _Object$entries[_i],
3358
- key = _Object$entries$_i[0],
3359
- deps = _Object$entries$_i[1];
3493
+ for (var _i3 = 0, _Object$entries3 = Object.entries($$state.initStateDeps); _i3 < _Object$entries3.length; _i3++) {
3494
+ var _Object$entries3$_i = _Object$entries3[_i3],
3495
+ key = _Object$entries3$_i[0],
3496
+ deps = _Object$entries3$_i[1];
3360
3497
 
3361
3498
  if (deps.includes(JSON.stringify(state.path))) {
3362
3499
  dset.dset($$state.stateValues, JSON.parse(key), UNINITIALIZED);
3363
3500
  }
3364
3501
  }
3365
3502
 
3366
- var newDeps = fillUninitializedStateValues(specs, props, $$state.stateValues, $$state.states);
3367
- set$$State(function (prev) {
3368
- return {
3369
- initStateValues: _extends({}, prev.initStateValues),
3370
- stateValues: cloneProxy(specs, prev.states, prev.stateValues),
3371
- initStateDeps: _extends({}, prev.initStateDeps, newDeps),
3372
- states: _extends({}, prev.states)
3373
- };
3503
+ var newDeps = fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states);
3504
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3505
+ forceRender(function (r) {
3506
+ return r + 1;
3374
3507
  });
3508
+ }
3375
3509
 
3376
- if (state.spec.onChangeProp) {
3377
- var _props$state$spec$onC;
3510
+ var spec = $$state.specs[state.specKey];
3378
3511
 
3379
- (_props$state$spec$onC = props[state.spec.onChangeProp]) == null ? void 0 : _props$state$spec$onC.call(props, newValue, state.path);
3380
- }
3512
+ if (spec.onChangeProp) {
3513
+ var _props$spec$onChangeP;
3514
+
3515
+ (_props$spec$onChangeP = props[spec.onChangeProp]) == null ? void 0 : _props$spec$onChangeP.call(props, newValue, state.path);
3381
3516
  }
3382
3517
 
3383
3518
  return true;
3384
3519
  }
3385
3520
  };
3521
+ }), {
3522
+ registerInitFunc: function registerInitFunc(pathStr, f) {
3523
+ if (Object.values($$state.states).filter(function (_ref3) {
3524
+ var specKey = _ref3.specKey;
3525
+ return specKey === pathStr;
3526
+ }).some(function (_ref4) {
3527
+ var path = _ref4.path;
3528
+ return _get($$state.stateValues, path) !== f(props, $state);
3529
+ })) {
3530
+ $$state.specs[pathStr] = _extends({}, $$state.specs[pathStr], {
3531
+ initFunc: f
3532
+ });
3533
+ forceRender(function (r) {
3534
+ return r + 1;
3535
+ });
3536
+ }
3537
+ }
3386
3538
  }); // For each spec with an initFunc, evaluate it and see if
3387
3539
  // the init value has changed. If so, reset its state.
3388
3540
 
3389
3541
  var newStateValues = undefined;
3390
3542
  var resetSpecs = [];
3391
3543
 
3392
- for (var _i2 = 0, _Object$values = Object.values($$state.states); _i2 < _Object$values.length; _i2++) {
3393
- var _Object$values$_i = _Object$values[_i2],
3544
+ for (var _i4 = 0, _Object$values = Object.values($$state.states); _i4 < _Object$values.length; _i4++) {
3545
+ var _Object$values$_i = _Object$values[_i4],
3394
3546
  path = _Object$values$_i.path,
3395
- spec = _Object$values$_i.spec;
3547
+ specKey = _Object$values$_i.specKey;
3548
+ var spec = $$state.specs[specKey];
3396
3549
 
3397
3550
  if (spec.initFunc) {
3398
3551
  var newInit = spec.initFunc(props, $state);
@@ -3401,11 +3554,11 @@ function useVanillaDollarState(_specs, props) {
3401
3554
  console.log("init changed for " + JSON.stringify(path) + " from " + _get($$state.initStateValues, path) + " to " + newInit + "; resetting state");
3402
3555
  resetSpecs.push({
3403
3556
  path: path,
3404
- spec: spec
3557
+ specKey: specKey
3405
3558
  });
3406
3559
 
3407
3560
  if (!newStateValues) {
3408
- newStateValues = cloneProxy(specs, $$state.states, $$state.stateValues);
3561
+ newStateValues = cloneProxy($$state.specs, $$state.states, $$state.stateValues);
3409
3562
  }
3410
3563
 
3411
3564
  dset.dset(newStateValues, path, UNINITIALIZED);
@@ -3415,26 +3568,25 @@ function useVanillaDollarState(_specs, props) {
3415
3568
 
3416
3569
  React__default.useLayoutEffect(function () {
3417
3570
  if (newStateValues !== undefined) {
3418
- var newDeps = fillUninitializedStateValues(specs, props, newStateValues, $$state.states);
3419
- set$$State(function (prev) {
3420
- var initStateValues = cloneProxy(specs, prev.states, prev.initStateValues);
3421
- resetSpecs.forEach(function (_ref3) {
3422
- var path = _ref3.path;
3571
+ var newDeps = fillUninitializedStateValues($$state.specs, props, newStateValues, $$state.states);
3572
+ var initStateValues = cloneProxy($$state.specs, $$state.states, $$state.initStateValues);
3573
+ resetSpecs.forEach(function (_ref5) {
3574
+ var path = _ref5.path;
3423
3575
 
3424
- dset.dset(initStateValues, path, _get(newStateValues, path));
3425
- });
3426
- return {
3427
- stateValues: cloneProxy(specs, prev.states, newStateValues),
3428
- initStateDeps: _extends({}, prev.initStateDeps, newDeps),
3429
- initStateValues: initStateValues,
3430
- states: _extends({}, prev.states)
3431
- };
3576
+ dset.dset(initStateValues, path, _get(newStateValues, path));
3577
+ });
3578
+ $$state.stateValues = cloneProxy($$state.specs, $$state.states, newStateValues);
3579
+ $$state.initStateValues = initStateValues;
3580
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3581
+ forceRender(function (r) {
3582
+ return r + 1;
3432
3583
  });
3433
3584
 
3434
- for (var _iterator2 = _createForOfIteratorHelperLoose(resetSpecs), _step2; !(_step2 = _iterator2()).done;) {
3435
- var _step2$value = _step2.value,
3436
- _path = _step2$value.path,
3437
- _spec = _step2$value.spec;
3585
+ for (var _iterator = _createForOfIteratorHelperLoose(resetSpecs), _step; !(_step = _iterator()).done;) {
3586
+ var _step$value = _step.value,
3587
+ _path = _step$value.path,
3588
+ _specKey = _step$value.specKey;
3589
+ var _spec = $$state.specs[_specKey];
3438
3590
 
3439
3591
  if (_spec.onChangeProp) {
3440
3592
  var _props$_spec$onChange;
@@ -3444,21 +3596,38 @@ function useVanillaDollarState(_specs, props) {
3444
3596
  }
3445
3597
  }
3446
3598
  }
3447
- }, [newStateValues, props, resetSpecs, specs]);
3599
+ }, [newStateValues, props, resetSpecs, $$state.specs]);
3600
+ /* *
3601
+ * Initialize all known states. (we need to do it for repeated states
3602
+ * because they're created only after the first get/set operation)
3603
+ * If we don't initialize them, we won't be able to consume the repeated states properly.
3604
+ * For example, let's say the consumer is just mapping the repeated states. The first operation
3605
+ * is to get the length of the array which will always be 0 because the existing states
3606
+ * weren't allocated yet -- they're only stored in internal state)
3607
+ * */
3608
+
3609
+ for (var _i5 = 0, _Object$values2 = Object.values($$state.states); _i5 < _Object$values2.length; _i5++) {
3610
+ var _path2 = _Object$values2[_i5].path;
3611
+
3612
+ _get($state, _path2);
3613
+ }
3614
+
3448
3615
  return $state;
3449
3616
  }
3450
3617
 
3451
3618
  function fillUninitializedStateValues(specs, props, stateValues, states) {
3452
3619
  var stateAccessStack = [new Set()];
3453
3620
  var initFuncDeps = {};
3454
- var $state = mkProxy(specs, function (state) {
3621
+ var $state = Object.assign(mkProxy(specs, function (state) {
3455
3622
  return {
3456
3623
  get: function get(_target, _property) {
3457
- if (state.spec.valueProp) {
3458
- if (!state.spec.isRepeated) {
3459
- return props[state.spec.valueProp];
3624
+ var spec = specs[state.specKey];
3625
+
3626
+ if (spec.valueProp) {
3627
+ if (!spec.isRepeated) {
3628
+ return props[spec.valueProp];
3460
3629
  } else {
3461
- return _get(props[state.spec.valueProp], state.path.slice(1));
3630
+ return _get(props[spec.valueProp], state.path.slice(1));
3462
3631
  }
3463
3632
  }
3464
3633
 
@@ -3481,18 +3650,20 @@ function fillUninitializedStateValues(specs, props, stateValues, states) {
3481
3650
  throw new Error("Cannot update state values during initialization");
3482
3651
  }
3483
3652
  };
3653
+ }), {
3654
+ registerInitFunc: function registerInitFunc() {}
3484
3655
  });
3485
3656
 
3486
3657
  function tracked(state) {
3487
3658
  stateAccessStack.push(new Set());
3488
- var res = state.spec.initFunc(props, $state);
3659
+ var res = specs[state.specKey].initFunc(props, $state);
3489
3660
  var deps = stateAccessStack.pop();
3490
3661
  initFuncDeps[JSON.stringify(state.path)] = [].concat(deps.values());
3491
3662
  return res;
3492
3663
  }
3493
3664
 
3494
- for (var _i3 = 0, _Object$values2 = Object.values(states); _i3 < _Object$values2.length; _i3++) {
3495
- var path = _Object$values2[_i3].path;
3665
+ for (var _i6 = 0, _Object$values3 = Object.values(states); _i6 < _Object$values3.length; _i6++) {
3666
+ var path = _Object$values3[_i6].path;
3496
3667
 
3497
3668
  if (_get(stateValues, path) === UNINITIALIZED) {
3498
3669
  _get($state, path);
@@ -3503,13 +3674,16 @@ function fillUninitializedStateValues(specs, props, stateValues, states) {
3503
3674
  }
3504
3675
 
3505
3676
  exports.DropdownMenu = DropdownMenu;
3677
+ exports.PlasmicHead = PlasmicHead;
3506
3678
  exports.PlasmicIcon = PlasmicIcon;
3507
3679
  exports.PlasmicImg = PlasmicImg;
3508
3680
  exports.PlasmicLink = PlasmicLink;
3509
3681
  exports.PlasmicRootProvider = PlasmicRootProvider;
3510
3682
  exports.PlasmicSlot = PlasmicSlot;
3683
+ exports.SelectContext = SelectContext;
3511
3684
  exports.Stack = Stack;
3512
3685
  exports.Trans = Trans;
3686
+ exports.TriggeredOverlayContext = TriggeredOverlayContext;
3513
3687
  exports.classNames = classNames;
3514
3688
  exports.createPlasmicElementProxy = createPlasmicElementProxy;
3515
3689
  exports.createUseScreenVariants = createUseScreenVariants;
@@ -3523,6 +3697,7 @@ exports.hasVariant = hasVariant;
3523
3697
  exports.makeFragment = makeFragment;
3524
3698
  exports.omit = omit;
3525
3699
  exports.pick = pick;
3700
+ exports.plasmicHeadMeta = plasmicHeadMeta;
3526
3701
  exports.renderPlasmicSlot = renderPlasmicSlot;
3527
3702
  exports.setPlumeStrictMode = setPlumeStrictMode;
3528
3703
  exports.useButton = useButton;