@plasmicapp/react-web 0.2.101 → 0.2.102
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.
- package/dist/all.d.ts +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/react-web.cjs.development.js +336 -0
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +336 -1
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/index.d.ts +15 -0
- package/package.json +5 -2
- package/skinny/dist/index.d.ts +1 -0
- package/skinny/dist/states/index.d.ts +15 -0
- package/skinny/dist/collection-utils-3487dd27.js +0 -238
- package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
- package/skinny/dist/collection-utils-47e89cbe.js +0 -238
- package/skinny/dist/collection-utils-47e89cbe.js.map +0 -1
- package/skinny/dist/collection-utils-4dae6efa.js +0 -292
- package/skinny/dist/collection-utils-4dae6efa.js.map +0 -1
- package/skinny/dist/collection-utils-57ec40f9.js +0 -292
- package/skinny/dist/collection-utils-57ec40f9.js.map +0 -1
- package/skinny/dist/collection-utils-96cde83c.js +0 -238
- package/skinny/dist/collection-utils-96cde83c.js.map +0 -1
- package/skinny/dist/collection-utils-b0b8f30e.js +0 -291
- package/skinny/dist/collection-utils-b0b8f30e.js.map +0 -1
- package/skinny/dist/plume-utils-5c413fd1.js +0 -35
- package/skinny/dist/plume-utils-5c413fd1.js.map +0 -1
- package/skinny/dist/props-utils-4633caf6.js +0 -8
- package/skinny/dist/props-utils-4633caf6.js.map +0 -1
- package/skinny/dist/props-utils-5c0ad25a.js +0 -59
- package/skinny/dist/props-utils-5c0ad25a.js.map +0 -1
- package/skinny/dist/props-utils-754f655a.js +0 -39
- package/skinny/dist/props-utils-754f655a.js.map +0 -1
- package/skinny/dist/props-utils-c632595f.js +0 -59
- package/skinny/dist/props-utils-c632595f.js.map +0 -1
- package/skinny/dist/props-utils-fd5f444e.js +0 -59
- package/skinny/dist/props-utils-fd5f444e.js.map +0 -1
- package/skinny/dist/react-utils-118d8539.js +0 -190
- package/skinny/dist/react-utils-118d8539.js.map +0 -1
- package/skinny/dist/react-utils-2a2fd6c9.js +0 -339
- package/skinny/dist/react-utils-2a2fd6c9.js.map +0 -1
- package/skinny/dist/react-utils-2d70bbbe.js +0 -172
- package/skinny/dist/react-utils-2d70bbbe.js.map +0 -1
- package/skinny/dist/react-utils-675565b4.js +0 -334
- package/skinny/dist/react-utils-675565b4.js.map +0 -1
- package/skinny/dist/render/PlasmicImg.d.ts +0 -62
- package/skinny/dist/ssr-64e38713.js +0 -108
- package/skinny/dist/ssr-64e38713.js.map +0 -1
- package/skinny/dist/ssr-902d1292.js +0 -105
- package/skinny/dist/ssr-902d1292.js.map +0 -1
- package/skinny/dist/ssr-a8081074.js +0 -108
- package/skinny/dist/ssr-a8081074.js.map +0 -1
- package/skinny/dist/ssr-d2fd94f2.js +0 -31
- package/skinny/dist/ssr-d2fd94f2.js.map +0 -1
- package/skinny/dist/tslib.es6-00014098.js +0 -148
- package/skinny/dist/tslib.es6-00014098.js.map +0 -1
- package/skinny/dist/tslib.es6-73236e8e.js +0 -141
- package/skinny/dist/tslib.es6-73236e8e.js.map +0 -1
package/dist/react-web.esm.js
CHANGED
|
@@ -18,6 +18,8 @@ import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
|
|
|
18
18
|
import { useSelectState } from '@react-stately/select';
|
|
19
19
|
import { useSwitch as useSwitch$1 } from '@react-aria/switch';
|
|
20
20
|
import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
|
|
21
|
+
import get from 'dlv';
|
|
22
|
+
import { dset } from 'dset';
|
|
21
23
|
|
|
22
24
|
function _extends() {
|
|
23
25
|
_extends = Object.assign || function (target) {
|
|
@@ -3115,5 +3117,338 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef) {
|
|
|
3115
3117
|
};
|
|
3116
3118
|
}
|
|
3117
3119
|
|
|
3118
|
-
|
|
3120
|
+
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
3121
|
+
function keyBy(list, keyFunc) {
|
|
3122
|
+
var keyedObject = {};
|
|
3123
|
+
|
|
3124
|
+
for (var _iterator = _createForOfIteratorHelperLoose(list), _step; !(_step = _iterator()).done;) {
|
|
3125
|
+
var val = _step.value;
|
|
3126
|
+
keyedObject[keyFunc(val)] = val;
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
return keyedObject;
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
function getObjectAtPath($state, path) {
|
|
3133
|
+
var parts = path.split(".");
|
|
3134
|
+
var parts2 = parts.slice(0, parts.length - 1);
|
|
3135
|
+
|
|
3136
|
+
if (parts2.length === 0) {
|
|
3137
|
+
return $state;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
var existing = get($state, parts2);
|
|
3141
|
+
|
|
3142
|
+
if (existing) {
|
|
3143
|
+
return existing;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
var newObj = {};
|
|
3147
|
+
dset($state, parts2, newObj);
|
|
3148
|
+
return newObj;
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
function isRendering() {
|
|
3152
|
+
return !!React__default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
function shallowEqual(a1, a2) {
|
|
3156
|
+
if (a1.length !== a2.length) {
|
|
3157
|
+
return false;
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
for (var i = 0; i < a1.length; i++) {
|
|
3161
|
+
if (a1[i] !== a2[i]) {
|
|
3162
|
+
return false;
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
return true;
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
function useVanillaDollarState(specs, props) {
|
|
3170
|
+
var _React$useState = React__default.useState(function () {
|
|
3171
|
+
return {
|
|
3172
|
+
stateValues: Object.fromEntries(specs.map(function (spec) {
|
|
3173
|
+
return [spec.path, // If the initial value depends on initFunc, then we initialize
|
|
3174
|
+
// it to this special UNINITIALIZED symbol. We can't just run
|
|
3175
|
+
// spec.initFunc() here, because the expression may read from
|
|
3176
|
+
// $state, which is not yet initialized. Instead, we will
|
|
3177
|
+
// lazily compute and initialize this at get() time.
|
|
3178
|
+
spec.initFunc ? UNINITIALIZED : spec.initVal];
|
|
3179
|
+
})),
|
|
3180
|
+
initStateValues: Object.fromEntries(specs.filter(function (spec) {
|
|
3181
|
+
return !spec.initFunc;
|
|
3182
|
+
}).map(function (spec) {
|
|
3183
|
+
return [spec.path, spec.initVal];
|
|
3184
|
+
})),
|
|
3185
|
+
initStateDeps: {},
|
|
3186
|
+
fireOnChange: {}
|
|
3187
|
+
};
|
|
3188
|
+
}),
|
|
3189
|
+
_$$state = _React$useState[0],
|
|
3190
|
+
set$$State = _React$useState[1]; // We have a weird scheme here to reduce the number of state updates.
|
|
3191
|
+
// Whenever user does a $state get() or set(), we may end up initializing
|
|
3192
|
+
// a bunch of values. We don't want to call set$$State() a bunch of times.
|
|
3193
|
+
// Instead, we will fork as we need to, and call set$$State() at the end of
|
|
3194
|
+
// the hook and at the end of get() / set() as appropriate.
|
|
3195
|
+
// $$state here is going to be copied-on-write; once copied, it will
|
|
3196
|
+
// be directly mutated. Since $state will always be directly proxying $$state,
|
|
3197
|
+
// that means you can "read what you wrote": after $state.count = $state.count + 1,
|
|
3198
|
+
// if you read $state.count again, it will reflect the latest value.
|
|
3199
|
+
//
|
|
3200
|
+
// There are three places where we might actually call set$$State():
|
|
3201
|
+
// 1. At the end of a "top-level" get(): we may have ended up initializing
|
|
3202
|
+
// some state values.
|
|
3203
|
+
// 2. At the end of a "top-level" set(): we mutated this value, but also
|
|
3204
|
+
// may have reset some other state values that depended on this one.
|
|
3205
|
+
// 3. At the end of the hook, where we compare the new initial value with
|
|
3206
|
+
// the previous initial value.
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
var $$state = _extends({}, _$$state);
|
|
3210
|
+
|
|
3211
|
+
var dirtyFields = {
|
|
3212
|
+
stateValues: false,
|
|
3213
|
+
initStateValues: false,
|
|
3214
|
+
initStateDeps: false,
|
|
3215
|
+
fireOnChange: false
|
|
3216
|
+
};
|
|
3217
|
+
|
|
3218
|
+
function makeDirty(field, copy) {
|
|
3219
|
+
if (!dirtyFields[field]) {
|
|
3220
|
+
dirtyFields[field] = true;
|
|
3221
|
+
$$state[field] = copy($$state[field]);
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
function updateStateValue(path, value) {
|
|
3226
|
+
makeDirty("stateValues", function (x) {
|
|
3227
|
+
return _extends({}, x);
|
|
3228
|
+
});
|
|
3229
|
+
console.log("UPDATE state value:", path, value);
|
|
3230
|
+
$$state.stateValues[path] = value; // If any other state depends on this one, then reset their
|
|
3231
|
+
// values to their initial as well
|
|
3232
|
+
|
|
3233
|
+
for (var _i = 0, _Object$entries = Object.entries($$state.initStateDeps); _i < _Object$entries.length; _i++) {
|
|
3234
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
3235
|
+
key = _Object$entries$_i[0],
|
|
3236
|
+
deps = _Object$entries$_i[1];
|
|
3237
|
+
|
|
3238
|
+
if (deps.includes(path)) {
|
|
3239
|
+
resetPath(key);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
var spec = specByPath[path];
|
|
3244
|
+
|
|
3245
|
+
if (spec.onChangeProp) {
|
|
3246
|
+
if (isRendering()) {
|
|
3247
|
+
// If we're currently rendering this component, then we
|
|
3248
|
+
// CANNOT fire the event handler, as it is illegal to set
|
|
3249
|
+
// the state of another component during rendering.
|
|
3250
|
+
// Instead, we save it into our internal state, and fire
|
|
3251
|
+
// it later in a layout effect.
|
|
3252
|
+
updateFireOnChange(spec.path, value);
|
|
3253
|
+
} else {
|
|
3254
|
+
var _props$spec$onChangeP;
|
|
3255
|
+
|
|
3256
|
+
// Most of the time, state changes outside of rendering
|
|
3257
|
+
// (in an event handler), and we just directly call the
|
|
3258
|
+
// onChange
|
|
3259
|
+
(_props$spec$onChangeP = props[spec.onChangeProp]) == null ? void 0 : _props$spec$onChangeP.call(props, value);
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
function updateInitStateValue(path, value) {
|
|
3265
|
+
makeDirty("initStateValues", function (x) {
|
|
3266
|
+
return _extends({}, x);
|
|
3267
|
+
});
|
|
3268
|
+
console.log("UPDATE initValue:", path, value);
|
|
3269
|
+
$$state.initStateValues[path] = value;
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
function updateInitStateDeps(path, deps) {
|
|
3273
|
+
makeDirty("initStateDeps", function (x) {
|
|
3274
|
+
return _extends({}, x);
|
|
3275
|
+
});
|
|
3276
|
+
console.log("UPDATE DEPS: " + path, deps);
|
|
3277
|
+
$$state.initStateDeps[path] = deps;
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
function updateInternalStateIfDirty() {
|
|
3281
|
+
if (Object.values(dirtyFields).some(function (x) {
|
|
3282
|
+
return x;
|
|
3283
|
+
})) {
|
|
3284
|
+
console.log("UPDATE $$STATE");
|
|
3285
|
+
set$$State($$state);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
function updateFireOnChange(path, value) {
|
|
3290
|
+
makeDirty("fireOnChange", function (x) {
|
|
3291
|
+
return _extends({}, x);
|
|
3292
|
+
});
|
|
3293
|
+
$$state.fireOnChange[path] = value;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
console.log("useDollarState", _extends({}, _$$state));
|
|
3297
|
+
var specByPath = React__default.useMemo(function () {
|
|
3298
|
+
return keyBy(specs, function (spec) {
|
|
3299
|
+
return spec.path;
|
|
3300
|
+
});
|
|
3301
|
+
}, [specs]);
|
|
3302
|
+
var stateAccessStack = [{}];
|
|
3303
|
+
var $props = props;
|
|
3304
|
+
/**
|
|
3305
|
+
* Runs spec.initFunc, keeping track of the state accesses
|
|
3306
|
+
* that occurred while running it
|
|
3307
|
+
*/
|
|
3308
|
+
|
|
3309
|
+
function trackedInit(spec) {
|
|
3310
|
+
var _$$state$initStateDep;
|
|
3311
|
+
|
|
3312
|
+
var stateAccess = {};
|
|
3313
|
+
stateAccessStack.push(stateAccess);
|
|
3314
|
+
var res = spec.initFunc($props, $state);
|
|
3315
|
+
var deps = Object.keys(stateAccess);
|
|
3316
|
+
|
|
3317
|
+
if (!shallowEqual(deps, (_$$state$initStateDep = $$state.initStateDeps[spec.path]) != null ? _$$state$initStateDep : [])) {
|
|
3318
|
+
updateInitStateDeps(spec.path, deps);
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
stateAccessStack.pop();
|
|
3322
|
+
return res;
|
|
3323
|
+
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Resets the value for this state
|
|
3326
|
+
*/
|
|
3327
|
+
|
|
3328
|
+
|
|
3329
|
+
function resetPath(path) {
|
|
3330
|
+
// Resets the value for this state
|
|
3331
|
+
var spec = specByPath[path];
|
|
3332
|
+
var initValue = trackedInit(spec);
|
|
3333
|
+
|
|
3334
|
+
if (initValue !== $$state.stateValues[spec.path]) {
|
|
3335
|
+
updateStateValue(spec.path, initValue);
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
if (initValue !== $$state.initStateValues[spec.path]) {
|
|
3339
|
+
updateInitStateValue(spec.path, initValue);
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
return initValue;
|
|
3343
|
+
} // Since a get() or a set() may result in other get() or set(),
|
|
3344
|
+
// we keep track of whether we're at the "top-level" so we know
|
|
3345
|
+
// whether to update state at the end.
|
|
3346
|
+
|
|
3347
|
+
|
|
3348
|
+
var accessLevel = 0;
|
|
3349
|
+
var $state = {};
|
|
3350
|
+
|
|
3351
|
+
var _loop = function _loop() {
|
|
3352
|
+
var spec = _step2.value;
|
|
3353
|
+
var parts = spec.path.split(".");
|
|
3354
|
+
var name = parts[parts.length - 1];
|
|
3355
|
+
var obj = getObjectAtPath($state, spec.path); // Define get() and set() for this state cell
|
|
3356
|
+
|
|
3357
|
+
Object.defineProperty(obj, name, {
|
|
3358
|
+
get: function get() {
|
|
3359
|
+
if (spec.valueProp) {
|
|
3360
|
+
return props[spec.valueProp];
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
accessLevel += 1;
|
|
3364
|
+
var value = $$state.stateValues[spec.path];
|
|
3365
|
+
|
|
3366
|
+
if (value === UNINITIALIZED) {
|
|
3367
|
+
// This value has a init expression; need to be evaluated.
|
|
3368
|
+
value = resetPath(spec.path);
|
|
3369
|
+
} // Record that this field had just been accessed; for
|
|
3370
|
+
// trackInit() to know what fields were used to compute
|
|
3371
|
+
// the init value
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
stateAccessStack[stateAccessStack.length - 1][spec.path] = true;
|
|
3375
|
+
accessLevel -= 1;
|
|
3376
|
+
|
|
3377
|
+
if (accessLevel === 0) {
|
|
3378
|
+
updateInternalStateIfDirty();
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
return value;
|
|
3382
|
+
},
|
|
3383
|
+
set: function set(newValue) {
|
|
3384
|
+
accessLevel += 1;
|
|
3385
|
+
|
|
3386
|
+
if (newValue !== $$state.stateValues[spec.path]) {
|
|
3387
|
+
updateStateValue(spec.path, newValue);
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
accessLevel -= 1;
|
|
3391
|
+
|
|
3392
|
+
if (accessLevel === 0) {
|
|
3393
|
+
updateInternalStateIfDirty();
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3397
|
+
};
|
|
3398
|
+
|
|
3399
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(specs), _step2; !(_step2 = _iterator2()).done;) {
|
|
3400
|
+
_loop();
|
|
3401
|
+
} // For each spec with an initFunc, evaluate it and see if
|
|
3402
|
+
// the init value has changed. If so, reset its state.
|
|
3403
|
+
|
|
3404
|
+
|
|
3405
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(specs), _step3; !(_step3 = _iterator3()).done;) {
|
|
3406
|
+
var spec = _step3.value;
|
|
3407
|
+
|
|
3408
|
+
if (spec.initFunc) {
|
|
3409
|
+
var newInit = spec.initFunc($props, $state);
|
|
3410
|
+
|
|
3411
|
+
if (newInit !== $$state.initStateValues[spec.path]) {
|
|
3412
|
+
console.log("init changed for " + spec.path + " from " + $$state.initStateValues[spec.path] + " to " + newInit + "; resetting state");
|
|
3413
|
+
updateInitStateValue(spec.path, newInit);
|
|
3414
|
+
updateStateValue(spec.path, newInit);
|
|
3415
|
+
|
|
3416
|
+
if (spec.onChangeProp) {
|
|
3417
|
+
updateFireOnChange(spec.path, newInit);
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
var fireOnChange = $$state.fireOnChange;
|
|
3424
|
+
React__default.useLayoutEffect(function () {
|
|
3425
|
+
if (Object.keys(fireOnChange).length > 0) {
|
|
3426
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(fireOnChange); _i2 < _Object$entries2.length; _i2++) {
|
|
3427
|
+
var _Object$entries2$_i = _Object$entries2[_i2],
|
|
3428
|
+
path = _Object$entries2$_i[0],
|
|
3429
|
+
value = _Object$entries2$_i[1];
|
|
3430
|
+
var spec = specByPath[path];
|
|
3431
|
+
|
|
3432
|
+
if (spec.onChangeProp) {
|
|
3433
|
+
var _props$spec$onChangeP2;
|
|
3434
|
+
|
|
3435
|
+
(_props$spec$onChangeP2 = props[spec.onChangeProp]) == null ? void 0 : _props$spec$onChangeP2.call(props, value);
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
set$$State(function (prev) {
|
|
3440
|
+
return _extends({}, prev, {
|
|
3441
|
+
fireOnChange: {}
|
|
3442
|
+
});
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
}, [fireOnChange, props, specByPath]); // update state if the above did some writes.
|
|
3446
|
+
|
|
3447
|
+
updateInternalStateIfDirty();
|
|
3448
|
+
return $state;
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
var useDollarState = useVanillaDollarState;
|
|
3452
|
+
|
|
3453
|
+
export { DropdownMenu, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, Stack, Trans, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, getDataProps, hasVariant, makeFragment, omit, pick, renderPlasmicSlot, setPlumeStrictMode, useButton, useCheckbox, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
3119
3454
|
//# sourceMappingURL=react-web.esm.js.map
|