@plasmicapp/react-web 0.2.135 → 0.2.137
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 +27 -19
- package/dist/auth/PlasmicPageGuard.d.ts +7 -0
- package/dist/index-common.d.ts +1 -0
- package/dist/react-web.cjs.development.js +383 -793
- 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 +384 -795
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/translation.d.ts +2 -1
- package/package.json +6 -6
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +7 -0
- package/skinny/dist/index-common.d.ts +1 -0
- package/skinny/dist/index.js +28 -5
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/checkbox/index.js +1 -1
- package/skinny/dist/plume/menu/index.js +1 -1
- package/skinny/dist/plume/menu-button/index.js +1 -1
- package/skinny/dist/plume/select/index.js +1 -1
- package/skinny/dist/plume/switch/index.js +1 -1
- package/skinny/dist/render/translation.d.ts +2 -1
- package/skinny/dist/{ssr-b16a1854.js → ssr-f6caec06.js} +7 -6
- package/skinny/dist/ssr-f6caec06.js.map +1 -0
- package/skinny/dist/ssr-b16a1854.js.map +0 -1
package/dist/react-web.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import classNames$1 from 'classnames';
|
|
2
|
-
import _get from 'dlv';
|
|
3
|
-
export { default as get } from 'dlv';
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import React__default, { forwardRef, createElement, Fragment, isValidElement, useContext, createContext, useState, useRef, useMemo, useLayoutEffect, useEffect, useImperativeHandle, useCallback, cloneElement } from 'react';
|
|
4
|
+
import _get from 'dlv';
|
|
5
|
+
export { default as get } from 'dlv';
|
|
6
6
|
import ReactDOM__default, { createPortal } from 'react-dom';
|
|
7
7
|
import { PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-context';
|
|
8
8
|
export { PlasmicDataSourceContextProvider, useCurrentUser } from '@plasmicapp/data-sources-context';
|
|
@@ -27,39 +27,57 @@ import { useSelectState } from '@react-stately/select';
|
|
|
27
27
|
import { useSwitch as useSwitch$1 } from '@react-aria/switch';
|
|
28
28
|
import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
|
|
29
29
|
|
|
30
|
+
function PlasmicPageGuard(props) {
|
|
31
|
+
var children = props.children,
|
|
32
|
+
dataSourceCtxValue = props.dataSourceCtxValue,
|
|
33
|
+
validRoles = props.validRoles;
|
|
34
|
+
if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function canUserViewPage() {
|
|
38
|
+
if (!dataSourceCtxValue) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (!dataSourceCtxValue.user) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (!("roleId" in dataSourceCtxValue.user)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return validRoles.includes(dataSourceCtxValue.user.roleId);
|
|
48
|
+
}
|
|
49
|
+
if (!canUserViewPage()) {
|
|
50
|
+
return React__default.createElement("div", null, "You don't have access to this page");
|
|
51
|
+
}
|
|
52
|
+
return children;
|
|
53
|
+
}
|
|
54
|
+
|
|
30
55
|
function _extends() {
|
|
31
|
-
_extends = Object.assign
|
|
56
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
32
57
|
for (var i = 1; i < arguments.length; i++) {
|
|
33
58
|
var source = arguments[i];
|
|
34
|
-
|
|
35
59
|
for (var key in source) {
|
|
36
60
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
37
61
|
target[key] = source[key];
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
|
-
|
|
42
65
|
return target;
|
|
43
66
|
};
|
|
44
|
-
|
|
45
67
|
return _extends.apply(this, arguments);
|
|
46
68
|
}
|
|
47
|
-
|
|
48
69
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
49
70
|
if (source == null) return {};
|
|
50
71
|
var target = {};
|
|
51
72
|
var sourceKeys = Object.keys(source);
|
|
52
73
|
var key, i;
|
|
53
|
-
|
|
54
74
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
55
75
|
key = sourceKeys[i];
|
|
56
76
|
if (excluded.indexOf(key) >= 0) continue;
|
|
57
77
|
target[key] = source[key];
|
|
58
78
|
}
|
|
59
|
-
|
|
60
79
|
return target;
|
|
61
80
|
}
|
|
62
|
-
|
|
63
81
|
function _unsupportedIterableToArray(o, minLen) {
|
|
64
82
|
if (!o) return;
|
|
65
83
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -68,19 +86,14 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
68
86
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
69
87
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
70
88
|
}
|
|
71
|
-
|
|
72
89
|
function _arrayLikeToArray(arr, len) {
|
|
73
90
|
if (len == null || len > arr.length) len = arr.length;
|
|
74
|
-
|
|
75
91
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
76
|
-
|
|
77
92
|
return arr2;
|
|
78
93
|
}
|
|
79
|
-
|
|
80
94
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
81
95
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
82
96
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
83
|
-
|
|
84
97
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
85
98
|
if (it) o = it;
|
|
86
99
|
var i = 0;
|
|
@@ -94,7 +107,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
94
107
|
};
|
|
95
108
|
};
|
|
96
109
|
}
|
|
97
|
-
|
|
98
110
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
99
111
|
}
|
|
100
112
|
|
|
@@ -105,57 +117,44 @@ function pick(obj) {
|
|
|
105
117
|
if (Object.keys(obj).length === 0) {
|
|
106
118
|
return obj;
|
|
107
119
|
}
|
|
108
|
-
|
|
109
120
|
var res = {};
|
|
110
|
-
|
|
111
121
|
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
112
122
|
keys[_key - 1] = arguments[_key];
|
|
113
123
|
}
|
|
114
|
-
|
|
115
124
|
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
|
|
116
125
|
var key = _keys[_i];
|
|
117
|
-
|
|
118
126
|
if (key in obj) {
|
|
119
127
|
res[key] = obj[key];
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
|
-
|
|
123
130
|
return res;
|
|
124
131
|
}
|
|
125
132
|
function pickBy(obj, func) {
|
|
126
133
|
var res = {};
|
|
127
|
-
|
|
128
134
|
for (var _i2 = 0, _Object$entries = Object.entries(obj); _i2 < _Object$entries.length; _i2++) {
|
|
129
135
|
var _Object$entries$_i = _Object$entries[_i2],
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
key = _Object$entries$_i[0],
|
|
137
|
+
val = _Object$entries$_i[1];
|
|
133
138
|
if (func(key, val)) {
|
|
134
139
|
res[key] = obj[key];
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
|
|
138
142
|
return res;
|
|
139
143
|
}
|
|
140
144
|
function omit(obj) {
|
|
141
145
|
if (Object.keys(obj).length === 0) {
|
|
142
146
|
return obj;
|
|
143
147
|
}
|
|
144
|
-
|
|
145
148
|
var res = {};
|
|
146
|
-
|
|
147
149
|
for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
148
150
|
keys[_key2 - 1] = arguments[_key2];
|
|
149
151
|
}
|
|
150
|
-
|
|
151
152
|
for (var _i3 = 0, _Object$keys = Object.keys(obj); _i3 < _Object$keys.length; _i3++) {
|
|
152
153
|
var key = _Object$keys[_i3];
|
|
153
|
-
|
|
154
154
|
if (!keys.includes(key)) {
|
|
155
155
|
res[key] = obj[key];
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
|
|
159
158
|
return res;
|
|
160
159
|
}
|
|
161
160
|
function isSubset(a1, a2) {
|
|
@@ -167,19 +166,15 @@ function chainSingleArgFuncs() {
|
|
|
167
166
|
for (var _len3 = arguments.length, funcs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
168
167
|
funcs[_key3] = arguments[_key3];
|
|
169
168
|
}
|
|
170
|
-
|
|
171
169
|
if (funcs.length === 0) {
|
|
172
170
|
return undefined;
|
|
173
171
|
}
|
|
174
|
-
|
|
175
172
|
return function (arg) {
|
|
176
173
|
var res = arg;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var func = _step.value;
|
|
174
|
+
for (var _i4 = 0, _funcs = funcs; _i4 < _funcs.length; _i4++) {
|
|
175
|
+
var func = _funcs[_i4];
|
|
180
176
|
res = func(res);
|
|
181
177
|
}
|
|
182
|
-
|
|
183
178
|
return res;
|
|
184
179
|
};
|
|
185
180
|
}
|
|
@@ -188,27 +183,22 @@ function isString(x) {
|
|
|
188
183
|
}
|
|
189
184
|
function groupBy(collection, keyFunc) {
|
|
190
185
|
var result = {};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var obj = _step2.value;
|
|
186
|
+
for (var _iterator = _createForOfIteratorHelperLoose(collection), _step; !(_step = _iterator()).done;) {
|
|
187
|
+
var obj = _step.value;
|
|
194
188
|
var key = keyFunc(obj);
|
|
195
|
-
|
|
196
189
|
if (key in result) {
|
|
197
190
|
result[key].push(obj);
|
|
198
191
|
} else {
|
|
199
192
|
result[key] = [obj];
|
|
200
193
|
}
|
|
201
194
|
}
|
|
202
|
-
|
|
203
195
|
return result;
|
|
204
196
|
}
|
|
205
197
|
function mapValues(obj, mapper) {
|
|
206
198
|
var result = {};
|
|
207
|
-
|
|
208
199
|
for (var key in obj) {
|
|
209
200
|
result[key] = mapper(obj[key]);
|
|
210
201
|
}
|
|
211
|
-
|
|
212
202
|
return result;
|
|
213
203
|
}
|
|
214
204
|
|
|
@@ -246,7 +236,6 @@ function ensureNotArray(children) {
|
|
|
246
236
|
* Flattens ReactNode into an array of ReactChild, but does NOT replace
|
|
247
237
|
* missing keys with array index, as React.Children.toArray() does.
|
|
248
238
|
*/
|
|
249
|
-
|
|
250
239
|
function toChildArray(children) {
|
|
251
240
|
if (isReactChild(children)) {
|
|
252
241
|
return [children];
|
|
@@ -269,32 +258,25 @@ function mergeProps(props) {
|
|
|
269
258
|
for (var _len = arguments.length, restProps = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
270
259
|
restProps[_key - 1] = arguments[_key];
|
|
271
260
|
}
|
|
272
|
-
|
|
273
261
|
if (restProps.every(function (rest) {
|
|
274
262
|
return Object.keys(rest).length === 0;
|
|
275
263
|
})) {
|
|
276
264
|
return props;
|
|
277
265
|
}
|
|
278
|
-
|
|
279
266
|
var result = _extends({}, props);
|
|
280
|
-
|
|
281
267
|
for (var _i = 0, _restProps = restProps; _i < _restProps.length; _i++) {
|
|
282
268
|
var rest = _restProps[_i];
|
|
283
|
-
|
|
284
269
|
for (var _i2 = 0, _Object$keys = Object.keys(rest); _i2 < _Object$keys.length; _i2++) {
|
|
285
270
|
var key = _Object$keys[_i2];
|
|
286
271
|
result[key] = mergePropVals(key, result[key], rest[key]);
|
|
287
272
|
}
|
|
288
273
|
}
|
|
289
|
-
|
|
290
274
|
return result;
|
|
291
275
|
}
|
|
292
|
-
|
|
293
276
|
function updateRef(ref, value) {
|
|
294
277
|
if (!ref) {
|
|
295
278
|
return;
|
|
296
279
|
}
|
|
297
|
-
|
|
298
280
|
if (typeof ref === "function") {
|
|
299
281
|
ref(value);
|
|
300
282
|
} else {
|
|
@@ -303,15 +285,13 @@ function updateRef(ref, value) {
|
|
|
303
285
|
}
|
|
304
286
|
}
|
|
305
287
|
}
|
|
306
|
-
|
|
307
288
|
function mergeRefs() {
|
|
308
289
|
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
309
290
|
refs[_key2] = arguments[_key2];
|
|
310
291
|
}
|
|
311
|
-
|
|
312
292
|
return function (value) {
|
|
313
|
-
for (var
|
|
314
|
-
var ref =
|
|
293
|
+
for (var _i3 = 0, _refs = refs; _i3 < _refs.length; _i3++) {
|
|
294
|
+
var ref = _refs[_i3];
|
|
315
295
|
updateRef(ref, value);
|
|
316
296
|
}
|
|
317
297
|
};
|
|
@@ -342,15 +322,12 @@ function mergePropVals(name, val1, val2) {
|
|
|
342
322
|
// Special case for event handlers -- always call both handlers
|
|
343
323
|
return function () {
|
|
344
324
|
var res;
|
|
345
|
-
|
|
346
325
|
if (typeof val1 === "function") {
|
|
347
326
|
res = val1.apply(void 0, arguments);
|
|
348
327
|
}
|
|
349
|
-
|
|
350
328
|
if (typeof val2 === "function") {
|
|
351
329
|
res = val2.apply(void 0, arguments);
|
|
352
330
|
}
|
|
353
|
-
|
|
354
331
|
return res;
|
|
355
332
|
};
|
|
356
333
|
} else {
|
|
@@ -363,45 +340,36 @@ function getElementTypeName(element) {
|
|
|
363
340
|
return element.type;
|
|
364
341
|
} else {
|
|
365
342
|
var _ref, _ref2, _comp$displayName, _comp$render;
|
|
366
|
-
|
|
367
343
|
var comp = element.type;
|
|
368
344
|
return (_ref = (_ref2 = (_comp$displayName = comp.displayName) != null ? _comp$displayName : comp.name) != null ? _ref2 : (_comp$render = comp.render) == null ? void 0 : _comp$render.name) != null ? _ref : "Component";
|
|
369
345
|
}
|
|
370
346
|
}
|
|
371
347
|
|
|
372
348
|
var _excluded = ["children"],
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
349
|
+
_excluded2 = ["as", "hasGap"],
|
|
350
|
+
_excluded3 = ["hasGap"];
|
|
376
351
|
function renderStack(as, props, hasGap, ref) {
|
|
377
352
|
var children = props.children,
|
|
378
|
-
|
|
379
|
-
|
|
353
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
380
354
|
var wrappedChildren = wrapFlexContainerChildren(children, hasGap != null ? hasGap : false);
|
|
381
355
|
return createElementWithChildren(as, _extends({
|
|
382
356
|
ref: ref
|
|
383
357
|
}, rest), wrappedChildren);
|
|
384
358
|
}
|
|
385
|
-
|
|
386
359
|
function FlexStack_(props, outerRef) {
|
|
387
360
|
var as = props.as,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
361
|
+
hasGap = props.hasGap,
|
|
362
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
391
363
|
return renderStack(as != null ? as : "div", rest, hasGap, outerRef);
|
|
392
364
|
}
|
|
393
|
-
|
|
394
365
|
var FlexStack = /*#__PURE__*/forwardRef(FlexStack_);
|
|
395
|
-
|
|
396
366
|
var makeStackImpl = function makeStackImpl(as) {
|
|
397
367
|
return forwardRef(function (props, ref) {
|
|
398
368
|
var hasGap = props.hasGap,
|
|
399
|
-
|
|
400
|
-
|
|
369
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded3);
|
|
401
370
|
return renderStack(as, rest, hasGap, ref);
|
|
402
371
|
});
|
|
403
372
|
};
|
|
404
|
-
|
|
405
373
|
var Stack = /*#__PURE__*/Object.assign(FlexStack, {
|
|
406
374
|
div: /*#__PURE__*/makeStackImpl("div"),
|
|
407
375
|
a: /*#__PURE__*/makeStackImpl("a"),
|
|
@@ -424,9 +392,7 @@ function hasVariant(variants, groupName, variant) {
|
|
|
424
392
|
if (variants == null) {
|
|
425
393
|
return false;
|
|
426
394
|
}
|
|
427
|
-
|
|
428
395
|
var groupVariants = variants[groupName];
|
|
429
|
-
|
|
430
396
|
if (groupVariants == null) {
|
|
431
397
|
return false;
|
|
432
398
|
} else if (groupVariants === true) {
|
|
@@ -447,7 +413,6 @@ function wrapFlexContainerChildren(children, hasGap) {
|
|
|
447
413
|
// will blow away the children tree and all state if we switch from having
|
|
448
414
|
// a wrapper and not.
|
|
449
415
|
var className = hasGap ? "__wab_flex-container" : "__wab_passthrough";
|
|
450
|
-
|
|
451
416
|
if (!children) {
|
|
452
417
|
return null;
|
|
453
418
|
} else if (Array.isArray(children)) {
|
|
@@ -460,21 +425,16 @@ function wrapFlexContainerChildren(children, hasGap) {
|
|
|
460
425
|
}, children);
|
|
461
426
|
}
|
|
462
427
|
}
|
|
463
|
-
|
|
464
428
|
function createPlasmicElement(override, defaultRoot, defaultProps, wrapChildrenInFlex) {
|
|
465
429
|
if (!override || Object.keys(override).length === 0) {
|
|
466
430
|
return createElementWithChildren(defaultRoot, defaultProps, defaultProps.children);
|
|
467
431
|
}
|
|
468
|
-
|
|
469
432
|
var override2 = deriveOverride(override);
|
|
470
433
|
var props = mergeOverrideProps(defaultProps, override2.props);
|
|
471
|
-
|
|
472
434
|
if (override2.type === "render") {
|
|
473
435
|
return override2.render(props, defaultRoot);
|
|
474
436
|
}
|
|
475
|
-
|
|
476
437
|
var root = defaultRoot;
|
|
477
|
-
|
|
478
438
|
if (override2.type === "as" && override2.as) {
|
|
479
439
|
if (defaultRoot === Stack) {
|
|
480
440
|
// If there was an "as" override specified, but the default type is
|
|
@@ -486,30 +446,23 @@ function createPlasmicElement(override, defaultRoot, defaultProps, wrapChildrenI
|
|
|
486
446
|
root = override2.as;
|
|
487
447
|
}
|
|
488
448
|
}
|
|
489
|
-
|
|
490
449
|
var children = props.children;
|
|
491
|
-
|
|
492
450
|
if (override2.wrapChildren) {
|
|
493
451
|
children = override2.wrapChildren(ensureNotArray(children));
|
|
494
452
|
}
|
|
495
|
-
|
|
496
453
|
if (wrapChildrenInFlex) {
|
|
497
454
|
// For legacy, we still support data-plasmic-wrap-flex-children
|
|
498
455
|
children = wrapFlexContainerChildren(children, true);
|
|
499
456
|
}
|
|
500
|
-
|
|
501
457
|
var result = createElementWithChildren(root, props, children);
|
|
502
|
-
|
|
503
458
|
if (override2.wrap) {
|
|
504
459
|
result = override2.wrap(result);
|
|
505
460
|
}
|
|
506
|
-
|
|
507
461
|
return result;
|
|
508
|
-
}
|
|
462
|
+
}
|
|
463
|
+
// We use data-plasmic-XXX attributes for custom properties since Typescript doesn't
|
|
509
464
|
// support type check on jsx pragma. See https://github.com/microsoft/TypeScript/issues/21699
|
|
510
465
|
// for more info.
|
|
511
|
-
|
|
512
|
-
|
|
513
466
|
var seenElements = /*#__PURE__*/new Map();
|
|
514
467
|
function createPlasmicElementProxy(defaultElement, props) {
|
|
515
468
|
// We use seenElements to keep track of elements that has been rendered by
|
|
@@ -526,78 +479,61 @@ function createPlasmicElementProxy(defaultElement, props) {
|
|
|
526
479
|
if (props == null) {
|
|
527
480
|
props = {};
|
|
528
481
|
}
|
|
529
|
-
|
|
530
482
|
var name = props["data-plasmic-name"];
|
|
531
483
|
var isRoot = props["data-plasmic-root"];
|
|
532
484
|
var forNodeName = props["data-plasmic-for-node"];
|
|
533
485
|
delete props["data-plasmic-name"];
|
|
534
486
|
delete props["data-plasmic-root"];
|
|
535
487
|
delete props["data-plasmic-for-node"];
|
|
536
|
-
|
|
537
488
|
for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
538
489
|
children[_key - 2] = arguments[_key];
|
|
539
490
|
}
|
|
540
|
-
|
|
541
491
|
var element = createPlasmicElementFromJsx.apply(void 0, [defaultElement, props].concat(children));
|
|
542
|
-
|
|
543
492
|
if (name) {
|
|
544
493
|
seenElements.set(name, element);
|
|
545
494
|
}
|
|
546
|
-
|
|
547
495
|
if (isRoot) {
|
|
548
496
|
var _seenElements$get;
|
|
549
|
-
|
|
550
497
|
// If this is the root, and we requested a specific node by specifying data-plasmic-for-node,
|
|
551
498
|
// then return that node instead
|
|
552
|
-
var forNode = forNodeName ? (_seenElements$get = seenElements.get(forNodeName)) != null ? _seenElements$get : null : element;
|
|
553
|
-
|
|
499
|
+
var forNode = forNodeName ? (_seenElements$get = seenElements.get(forNodeName)) != null ? _seenElements$get : null : element;
|
|
500
|
+
// Clear out the seenElements map, as we're done rendering this Plasmic* component.
|
|
554
501
|
seenElements.clear();
|
|
555
502
|
return forNode;
|
|
556
503
|
}
|
|
557
|
-
|
|
558
504
|
return element;
|
|
559
505
|
}
|
|
560
|
-
|
|
561
506
|
function createPlasmicElementFromJsx(defaultElement, props) {
|
|
562
507
|
var _props$dataPlasmicT;
|
|
563
|
-
|
|
564
508
|
var override = props["data-plasmic-override"];
|
|
565
509
|
var wrapFlexChild = props["data-plasmic-wrap-flex-child"];
|
|
566
510
|
var triggerProps = (_props$dataPlasmicT = props["data-plasmic-trigger-props"]) != null ? _props$dataPlasmicT : [];
|
|
567
511
|
delete props["data-plasmic-override"];
|
|
568
512
|
delete props["data-plasmic-wrap-flex-child"];
|
|
569
513
|
delete props["data-plasmic-trigger-props"];
|
|
570
|
-
|
|
571
514
|
for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
572
515
|
children[_key2 - 2] = arguments[_key2];
|
|
573
516
|
}
|
|
574
|
-
|
|
575
517
|
return createPlasmicElement(override, defaultElement, mergeProps.apply(void 0, [props, children.length === 0 ? {} : {
|
|
576
518
|
children: children.length === 1 ? children[0] : children
|
|
577
519
|
}].concat(triggerProps)), wrapFlexChild);
|
|
578
520
|
}
|
|
579
|
-
|
|
580
521
|
function makeFragment() {
|
|
581
522
|
for (var _len3 = arguments.length, children = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
582
523
|
children[_key3] = arguments[_key3];
|
|
583
524
|
}
|
|
584
|
-
|
|
585
525
|
return createElement.apply(React, [Fragment, {}].concat(children));
|
|
586
526
|
}
|
|
587
527
|
var UNSET = /*#__PURE__*/Symbol("UNSET");
|
|
588
|
-
|
|
589
528
|
function mergeOverrideProps(defaults, overrides) {
|
|
590
529
|
if (!overrides) {
|
|
591
530
|
return defaults;
|
|
592
531
|
}
|
|
593
|
-
|
|
594
532
|
var result = _extends({}, defaults);
|
|
595
|
-
|
|
596
533
|
for (var _i = 0, _Object$keys = Object.keys(overrides); _i < _Object$keys.length; _i++) {
|
|
597
534
|
var key = _Object$keys[_i];
|
|
598
535
|
var defaultVal = defaults[key];
|
|
599
536
|
var overrideVal = overrides[key];
|
|
600
|
-
|
|
601
537
|
if (overrideVal === UNSET) {
|
|
602
538
|
delete result[key];
|
|
603
539
|
} else {
|
|
@@ -608,14 +544,11 @@ function mergeOverrideProps(defaults, overrides) {
|
|
|
608
544
|
if (overrideVal == null && key !== "className" && key !== "style" && !(key.startsWith("on") && typeof defaultVal === "function")) {
|
|
609
545
|
overrideVal = NONE;
|
|
610
546
|
}
|
|
611
|
-
|
|
612
547
|
result[key] = mergePropVals(key, defaultVal, overrideVal);
|
|
613
548
|
}
|
|
614
549
|
}
|
|
615
|
-
|
|
616
550
|
return result;
|
|
617
551
|
}
|
|
618
|
-
|
|
619
552
|
function wrapWithClassName(element, className) {
|
|
620
553
|
var key = isValidElement(element) ? element.key || undefined : undefined;
|
|
621
554
|
return createElement("div", {
|
|
@@ -626,7 +559,6 @@ function wrapWithClassName(element, className) {
|
|
|
626
559
|
}
|
|
627
560
|
}, element);
|
|
628
561
|
}
|
|
629
|
-
|
|
630
562
|
function deriveOverride(x) {
|
|
631
563
|
if (!x) {
|
|
632
564
|
// undefined Binding is an empty Binding
|
|
@@ -666,9 +598,8 @@ function deriveOverride(x) {
|
|
|
666
598
|
props: {},
|
|
667
599
|
type: "default"
|
|
668
600
|
});
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
601
|
+
}
|
|
602
|
+
// Else, assume this is just a props object.
|
|
672
603
|
return {
|
|
673
604
|
type: "default",
|
|
674
605
|
props: x
|
|
@@ -679,68 +610,53 @@ function deriveOverride(x) {
|
|
|
679
610
|
render: x
|
|
680
611
|
};
|
|
681
612
|
}
|
|
682
|
-
|
|
683
613
|
throw new Error("Unexpected override: " + x);
|
|
684
614
|
}
|
|
685
|
-
|
|
686
615
|
function mergeVariants(v1, v2) {
|
|
687
616
|
if (!v1 || !v2) {
|
|
688
617
|
return v1 || v2 || {};
|
|
689
618
|
}
|
|
690
|
-
|
|
691
619
|
return _extends({}, v1, v2);
|
|
692
620
|
}
|
|
693
|
-
|
|
694
621
|
function mergeVariantsWithStates(variants, $state, linkedStates) {
|
|
695
622
|
return _extends({}, variants, Object.fromEntries(linkedStates.map(function (_ref) {
|
|
696
623
|
var variantGroup = _ref.variantGroup,
|
|
697
|
-
|
|
624
|
+
statePath = _ref.statePath;
|
|
698
625
|
return [variantGroup, _get($state, statePath)];
|
|
699
626
|
})));
|
|
700
627
|
}
|
|
701
|
-
|
|
702
628
|
function mergeArgs(a1, a2) {
|
|
703
629
|
if (!a1 || !a2) {
|
|
704
630
|
return a1 || a2 || {};
|
|
705
631
|
}
|
|
706
|
-
|
|
707
632
|
return _extends({}, a1, a2);
|
|
708
633
|
}
|
|
709
|
-
|
|
710
634
|
function mergeFlexOverrides(o1, o2) {
|
|
711
635
|
if (!o2) {
|
|
712
636
|
return o1;
|
|
713
637
|
}
|
|
714
|
-
|
|
715
638
|
var keys = Array.from(new Set([].concat(Object.keys(o1), Object.keys(o2))));
|
|
716
639
|
var merged = {};
|
|
717
|
-
|
|
718
640
|
for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
|
|
719
641
|
var key = _keys[_i2];
|
|
720
642
|
merged[key] = mergeFlexOverride(o1[key], o2[key]);
|
|
721
643
|
}
|
|
722
|
-
|
|
723
644
|
return merged;
|
|
724
645
|
}
|
|
725
|
-
|
|
726
646
|
function mergeFlexOverride(fo1, fo2) {
|
|
727
647
|
var _o1$props, _ref2;
|
|
728
|
-
|
|
729
648
|
if (!fo1) {
|
|
730
649
|
return fo2;
|
|
731
650
|
}
|
|
732
|
-
|
|
733
651
|
if (!fo2) {
|
|
734
652
|
return fo1;
|
|
735
653
|
}
|
|
736
|
-
|
|
737
654
|
var o1 = deriveOverride(fo1);
|
|
738
655
|
var o2 = deriveOverride(fo2);
|
|
739
656
|
var wrap = chainSingleArgFuncs.apply(void 0, [o1.wrap, o2.wrap].filter(notNil));
|
|
740
|
-
var wrapChildren = chainSingleArgFuncs.apply(void 0, [o1.wrapChildren, o2.wrapChildren].filter(notNil));
|
|
741
|
-
|
|
657
|
+
var wrapChildren = chainSingleArgFuncs.apply(void 0, [o1.wrapChildren, o2.wrapChildren].filter(notNil));
|
|
658
|
+
// "render" type always takes precedence, but we still merge the props
|
|
742
659
|
var props = mergeOverrideProps((_o1$props = o1.props) != null ? _o1$props : {}, o2.props);
|
|
743
|
-
|
|
744
660
|
if (o2.type === "render") {
|
|
745
661
|
return {
|
|
746
662
|
render: o2.render,
|
|
@@ -749,7 +665,6 @@ function mergeFlexOverride(fo1, fo2) {
|
|
|
749
665
|
wrapChildren: wrapChildren
|
|
750
666
|
};
|
|
751
667
|
}
|
|
752
|
-
|
|
753
668
|
if (o1.type === "render") {
|
|
754
669
|
return {
|
|
755
670
|
render: o1.render,
|
|
@@ -757,9 +672,8 @@ function mergeFlexOverride(fo1, fo2) {
|
|
|
757
672
|
wrap: wrap,
|
|
758
673
|
wrapChildren: wrapChildren
|
|
759
674
|
};
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
675
|
+
}
|
|
676
|
+
// "as" will take precedence
|
|
763
677
|
var as = (_ref2 = o2.type === "as" ? o2.as : undefined) != null ? _ref2 : o1.type === "as" ? o1.as : undefined;
|
|
764
678
|
return _extends({
|
|
765
679
|
props: props,
|
|
@@ -769,26 +683,22 @@ function mergeFlexOverride(fo1, fo2) {
|
|
|
769
683
|
as: as
|
|
770
684
|
} : {});
|
|
771
685
|
}
|
|
772
|
-
|
|
773
686
|
function deriveRenderOpts(props, config) {
|
|
774
687
|
var name = config.name,
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
688
|
+
descendantNames = config.descendantNames,
|
|
689
|
+
internalVariantPropNames = config.internalVariantPropNames,
|
|
690
|
+
internalArgPropNames = config.internalArgPropNames;
|
|
778
691
|
var reservedPropNames = ["variants", "args", "overrides"];
|
|
779
692
|
var variants = mergeVariants(omit.apply(void 0, [pick.apply(void 0, [props].concat(internalVariantPropNames))].concat(reservedPropNames)), props.variants);
|
|
780
693
|
var args = mergeArgs(omit.apply(void 0, [pick.apply(void 0, [props].concat(internalArgPropNames))].concat(reservedPropNames)), props.args);
|
|
781
694
|
var overrides = mergeFlexOverrides(omit.apply(void 0, [pick.apply(void 0, [props].concat(descendantNames))].concat(internalArgPropNames, internalVariantPropNames, reservedPropNames)), props.overrides);
|
|
782
695
|
var leftoverProps = omit.apply(void 0, [props, "variants", "args", "overrides"].concat(descendantNames, internalVariantPropNames, internalArgPropNames));
|
|
783
|
-
|
|
784
696
|
if (Object.keys(leftoverProps).length > 0) {
|
|
785
697
|
var _mergeFlexOverrides;
|
|
786
|
-
|
|
787
698
|
overrides = mergeFlexOverrides(overrides, (_mergeFlexOverrides = {}, _mergeFlexOverrides[name] = {
|
|
788
699
|
props: leftoverProps
|
|
789
700
|
}, _mergeFlexOverrides));
|
|
790
701
|
}
|
|
791
|
-
|
|
792
702
|
return {
|
|
793
703
|
variants: variants,
|
|
794
704
|
args: args,
|
|
@@ -799,7 +709,6 @@ function deriveRenderOpts(props, config) {
|
|
|
799
709
|
var isDefaultValue = function isDefaultValue(val) {
|
|
800
710
|
return val === "PLEASE_RENDER_INSIDE_PROVIDER";
|
|
801
711
|
};
|
|
802
|
-
|
|
803
712
|
var seenDefaultVariants = {};
|
|
804
713
|
function ensureGlobalVariants(globalVariantValues) {
|
|
805
714
|
Object.entries(globalVariantValues).filter(function (_ref) {
|
|
@@ -808,7 +717,6 @@ function ensureGlobalVariants(globalVariantValues) {
|
|
|
808
717
|
}).forEach(function (_ref2) {
|
|
809
718
|
var key = _ref2[0];
|
|
810
719
|
globalVariantValues[key] = undefined;
|
|
811
|
-
|
|
812
720
|
if (!seenDefaultVariants[key] && process.env.NODE_ENV === "development") {
|
|
813
721
|
seenDefaultVariants[key] = true;
|
|
814
722
|
var providerName = "" + key[0].toUpperCase() + key.substring(1) + "Context.Provider";
|
|
@@ -821,15 +729,13 @@ function ensureGlobalVariants(globalVariantValues) {
|
|
|
821
729
|
var PlasmicHeadContext = /*#__PURE__*/createContext(undefined);
|
|
822
730
|
function PlasmicHead(props) {
|
|
823
731
|
var Head = useContext(PlasmicHeadContext);
|
|
824
|
-
|
|
825
732
|
if (!Head) {
|
|
826
|
-
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
827
|
-
|
|
733
|
+
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
734
|
+
// TODO: Link to doc about Head.
|
|
828
735
|
return null;
|
|
829
|
-
}
|
|
736
|
+
}
|
|
737
|
+
// Helmet does not support React.Fragments, so we need to use `[<meta />,
|
|
830
738
|
// <meta />]` instead of `<><meta /><meta /></>`.
|
|
831
|
-
|
|
832
|
-
|
|
833
739
|
return createElement(Head, null, props.image ? [createElement("meta", {
|
|
834
740
|
key: "twitter:card",
|
|
835
741
|
name: "twitter:card",
|
|
@@ -905,50 +811,46 @@ var plasmicHeadMeta = {
|
|
|
905
811
|
var _excluded$1 = ["PlasmicIconType"];
|
|
906
812
|
function PlasmicIcon(props) {
|
|
907
813
|
var PlasmicIconType = props.PlasmicIconType,
|
|
908
|
-
|
|
909
|
-
|
|
814
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
910
815
|
return createElement(PlasmicIconType, Object.assign({}, rest));
|
|
911
816
|
}
|
|
912
817
|
|
|
913
818
|
var _excluded$2 = ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "imgRef", "style", "loading"];
|
|
819
|
+
// Default image sizes to snap to
|
|
914
820
|
// TODO: make this configurable?
|
|
915
|
-
|
|
916
821
|
var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
917
822
|
var DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
918
823
|
var ALL_SIZES = /*#__PURE__*/[].concat(IMG_SIZES, DEVICE_SIZES);
|
|
919
824
|
var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(props, outerRef) {
|
|
920
825
|
var src = props.src,
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
826
|
+
className = props.className,
|
|
827
|
+
displayWidth = props.displayWidth,
|
|
828
|
+
displayHeight = props.displayHeight,
|
|
829
|
+
displayMinWidth = props.displayMinWidth,
|
|
830
|
+
displayMinHeight = props.displayMinHeight,
|
|
831
|
+
displayMaxWidth = props.displayMaxWidth,
|
|
832
|
+
displayMaxHeight = props.displayMaxHeight,
|
|
833
|
+
quality = props.quality,
|
|
834
|
+
loader = props.loader,
|
|
835
|
+
imgRef = props.imgRef,
|
|
836
|
+
style = props.style,
|
|
837
|
+
loading = props.loading,
|
|
838
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
935
839
|
var imgProps = Object.assign({}, rest, {
|
|
936
840
|
// Default loading to "lazy" if not specified (which is different from the
|
|
937
841
|
// html img, which defaults to eager!)
|
|
938
842
|
loading: loading != null ? loading : "lazy"
|
|
939
843
|
});
|
|
940
|
-
|
|
941
844
|
var _ref = typeof src === "string" || !src ? {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
845
|
+
fullWidth: undefined,
|
|
846
|
+
fullHeight: undefined,
|
|
847
|
+
aspectRatio: undefined
|
|
848
|
+
} : src,
|
|
849
|
+
fullWidth = _ref.fullWidth,
|
|
850
|
+
fullHeight = _ref.fullHeight,
|
|
851
|
+
aspectRatio = _ref.aspectRatio;
|
|
852
|
+
var srcStr = src ? typeof src === "string" ? src : typeof src.src === "string" ? src.src : src.src.src : "";
|
|
853
|
+
// Assume external image if either dimension is null and use usual <img>
|
|
952
854
|
if (fullHeight == null || fullWidth == null) {
|
|
953
855
|
return React__default.createElement("img", Object.assign({
|
|
954
856
|
src: srcStr,
|
|
@@ -959,13 +861,10 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
959
861
|
ref: mergeRefs(imgRef, outerRef)
|
|
960
862
|
}));
|
|
961
863
|
}
|
|
962
|
-
|
|
963
864
|
if (isSvg(srcStr) && (displayHeight == null || displayHeight === "auto") && (displayWidth == null || displayWidth === "auto")) {
|
|
964
865
|
displayWidth = "100%";
|
|
965
866
|
}
|
|
966
|
-
|
|
967
867
|
var computedDisplayWidth = displayWidth;
|
|
968
|
-
|
|
969
868
|
if (fullWidth && fullHeight && (!displayWidth || displayWidth === "auto") && !!getPixelLength(displayHeight)) {
|
|
970
869
|
// If there's a pixel length specified for displayHeight but not displayWidth,
|
|
971
870
|
// then we can derive the pixel length for displayWidth. Having an explicit
|
|
@@ -978,10 +877,8 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
978
877
|
computedDisplayWidth = getPixelLength(displayHeight) * fullWidth / fullHeight;
|
|
979
878
|
}
|
|
980
879
|
}
|
|
981
|
-
|
|
982
880
|
var spacerWidth = fullWidth;
|
|
983
881
|
var spacerHeight = fullHeight;
|
|
984
|
-
|
|
985
882
|
if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {
|
|
986
883
|
// For SVGs, fullWidth and fullHeight can be rounded values, which would
|
|
987
884
|
// cause some discrepancy between the actual aspect ratio and the aspect
|
|
@@ -990,25 +887,21 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
990
887
|
spacerWidth = DEFAULT_SVG_WIDTH;
|
|
991
888
|
spacerHeight = Math.round(spacerWidth / aspectRatio);
|
|
992
889
|
}
|
|
993
|
-
|
|
994
890
|
var _getWidths = getWidths(computedDisplayWidth, fullWidth, {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
891
|
+
minWidth: displayMinWidth
|
|
892
|
+
}),
|
|
893
|
+
sizes = _getWidths.sizes,
|
|
894
|
+
widthDescs = _getWidths.widthDescs;
|
|
1000
895
|
var imageLoader = getImageLoader(loader);
|
|
1001
896
|
var spacerSvg = "<svg width=\"" + spacerWidth + "\" height=\"" + spacerHeight + "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>";
|
|
1002
897
|
var spacerSvgBase64 = typeof window === "undefined" ? Buffer.from(spacerSvg).toString("base64") : window.btoa(spacerSvg);
|
|
1003
|
-
|
|
1004
898
|
var wrapperStyle = _extends({}, style || {});
|
|
1005
|
-
|
|
1006
899
|
var spacerStyle = _extends({}, pick(style || {}, "objectFit", "objectPosition"));
|
|
1007
|
-
|
|
1008
900
|
if (displayWidth != null && displayWidth !== "auto") {
|
|
1009
901
|
// If width is set, set it on the wrapper along with min/max width
|
|
1010
902
|
// and just use `width: 100%` on the spacer
|
|
1011
|
-
spacerStyle.width = "100%";
|
|
903
|
+
spacerStyle.width = "100%";
|
|
904
|
+
// Rely on the styles set by `classname` on the wrapper:
|
|
1012
905
|
// wrapperStyle.width = displayWidth;
|
|
1013
906
|
// wrapperStyle.minWidth = displayMinWidth;
|
|
1014
907
|
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
@@ -1022,32 +915,35 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
1022
915
|
// than it should.
|
|
1023
916
|
spacerStyle.width = displayWidth;
|
|
1024
917
|
wrapperStyle.width = "auto";
|
|
1025
|
-
|
|
1026
918
|
if (displayMinWidth) {
|
|
1027
|
-
spacerStyle.minWidth = "100%";
|
|
919
|
+
spacerStyle.minWidth = "100%";
|
|
920
|
+
// Rely on min-width set by `classname` on the wrapper:
|
|
1028
921
|
// wrapperStyle.minWidth = displayMinWidth;
|
|
1029
922
|
}
|
|
1030
923
|
|
|
1031
924
|
if (displayMaxWidth != null && displayMaxWidth !== "none") {
|
|
1032
|
-
spacerStyle.maxWidth = "100%";
|
|
925
|
+
spacerStyle.maxWidth = "100%";
|
|
926
|
+
// Rely on max-width set by `classname` on the wrapper:
|
|
1033
927
|
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
1034
928
|
}
|
|
1035
929
|
}
|
|
1036
930
|
|
|
1037
931
|
if (displayHeight != null && displayHeight !== "auto") {
|
|
1038
|
-
spacerStyle.height = "100%";
|
|
932
|
+
spacerStyle.height = "100%";
|
|
933
|
+
// wrapperStyle.height = displayHeight;
|
|
1039
934
|
// wrapperStyle.minHeight = displayMinHeight;
|
|
1040
935
|
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
1041
936
|
} else {
|
|
1042
937
|
spacerStyle.height = displayHeight;
|
|
1043
938
|
wrapperStyle.height = "auto";
|
|
1044
|
-
|
|
1045
939
|
if (displayMinHeight) {
|
|
1046
|
-
spacerStyle.minHeight = "100%";
|
|
940
|
+
spacerStyle.minHeight = "100%";
|
|
941
|
+
// wrapperStyle.minHeight = displayMinHeight;
|
|
1047
942
|
}
|
|
1048
943
|
|
|
1049
944
|
if (displayMaxHeight != null && displayMaxHeight !== "none") {
|
|
1050
|
-
spacerStyle.maxHeight = "100%";
|
|
945
|
+
spacerStyle.maxHeight = "100%";
|
|
946
|
+
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
1051
947
|
}
|
|
1052
948
|
}
|
|
1053
949
|
|
|
@@ -1073,20 +969,19 @@ var PlasmicImg = /*#__PURE__*/React__default.forwardRef(function PlasmicImg(prop
|
|
|
1073
969
|
className: "__wab_img"
|
|
1074
970
|
}));
|
|
1075
971
|
});
|
|
1076
|
-
|
|
1077
972
|
function makePicture(opts) {
|
|
1078
973
|
// If imageLoader is undefined, then this renders to just a normal
|
|
1079
974
|
// <img />. Else it will render to a <picture> with a <source> for
|
|
1080
975
|
// webp, and srcSet/sizes set according to width requirements.
|
|
1081
976
|
var imageLoader = opts.imageLoader,
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
977
|
+
widthDescs = opts.widthDescs,
|
|
978
|
+
src = opts.src,
|
|
979
|
+
quality = opts.quality,
|
|
980
|
+
style = opts.style,
|
|
981
|
+
className = opts.className,
|
|
982
|
+
sizes = opts.sizes,
|
|
983
|
+
imgProps = opts.imgProps,
|
|
984
|
+
ref = opts.ref;
|
|
1090
985
|
return React__default.createElement("picture", {
|
|
1091
986
|
className: "__wab_picture"
|
|
1092
987
|
}, imageLoader && imageLoader.supportsUrl(src) && React__default.createElement("source", {
|
|
@@ -1122,21 +1017,16 @@ function makePicture(opts) {
|
|
|
1122
1017
|
})
|
|
1123
1018
|
})));
|
|
1124
1019
|
}
|
|
1125
|
-
|
|
1126
1020
|
var DEFAULT_SVG_WIDTH = 10000;
|
|
1127
|
-
|
|
1128
1021
|
function isSvg(src) {
|
|
1129
1022
|
return src.endsWith(".svg") || src.startsWith("data:image/svg");
|
|
1130
1023
|
}
|
|
1131
|
-
|
|
1132
1024
|
function getClosestPresetSize(width, fullWidth) {
|
|
1133
1025
|
var _ALL_SIZES$findIndex;
|
|
1134
|
-
|
|
1135
1026
|
var nextBiggerIndex = (_ALL_SIZES$findIndex = ALL_SIZES.findIndex(function (w) {
|
|
1136
1027
|
return w >= width;
|
|
1137
1028
|
})) != null ? _ALL_SIZES$findIndex : ALL_SIZES.length - 1;
|
|
1138
1029
|
var nextBigger = ALL_SIZES[nextBiggerIndex];
|
|
1139
|
-
|
|
1140
1030
|
if (nextBigger >= fullWidth) {
|
|
1141
1031
|
// If the requested width is larger than the fullWidth,
|
|
1142
1032
|
// we just use the original width instead. It's impossible
|
|
@@ -1149,19 +1039,15 @@ function getClosestPresetSize(width, fullWidth) {
|
|
|
1149
1039
|
// less than 48)
|
|
1150
1040
|
return undefined;
|
|
1151
1041
|
}
|
|
1152
|
-
|
|
1153
1042
|
return nextBigger;
|
|
1154
1043
|
}
|
|
1155
1044
|
/**
|
|
1156
1045
|
* Computes the appropriate srcSet and sizes to use
|
|
1157
1046
|
*/
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
1047
|
function getWidths(width, fullWidth, extra) {
|
|
1161
1048
|
var minWidth = extra == null ? void 0 : extra.minWidth;
|
|
1162
1049
|
var pixelWidth = getPixelLength(width);
|
|
1163
1050
|
var pixelMinWidth = getPixelLength(minWidth);
|
|
1164
|
-
|
|
1165
1051
|
if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
|
|
1166
1052
|
// If there's an exact width, then we just need to display it at 1x and 2x density
|
|
1167
1053
|
return {
|
|
@@ -1174,14 +1060,12 @@ function getWidths(width, fullWidth, extra) {
|
|
|
1174
1060
|
}],
|
|
1175
1061
|
sizes: undefined
|
|
1176
1062
|
};
|
|
1177
|
-
}
|
|
1063
|
+
}
|
|
1064
|
+
// Otherwise we don't know what sizes we'll end up, so we just cap it at
|
|
1178
1065
|
// device width. TODO: do better!
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
1066
|
var usefulSizes = DEVICE_SIZES.filter(function (size) {
|
|
1182
1067
|
return !fullWidth || size < fullWidth;
|
|
1183
1068
|
});
|
|
1184
|
-
|
|
1185
1069
|
if (!!fullWidth && usefulSizes.length === 0) {
|
|
1186
1070
|
// image fullWidth is smaller than all device sizes. So all we can do
|
|
1187
1071
|
// is offer 1x
|
|
@@ -1193,7 +1077,6 @@ function getWidths(width, fullWidth, extra) {
|
|
|
1193
1077
|
sizes: undefined
|
|
1194
1078
|
};
|
|
1195
1079
|
}
|
|
1196
|
-
|
|
1197
1080
|
return {
|
|
1198
1081
|
widthDescs: usefulSizes.map(function (size) {
|
|
1199
1082
|
return {
|
|
@@ -1214,33 +1097,25 @@ function getWidths(width, fullWidth, extra) {
|
|
|
1214
1097
|
sizes: "100vw"
|
|
1215
1098
|
};
|
|
1216
1099
|
}
|
|
1217
|
-
|
|
1218
1100
|
function getPixelLength(length) {
|
|
1219
1101
|
if (length == null || length == "") {
|
|
1220
1102
|
return undefined;
|
|
1221
1103
|
}
|
|
1222
|
-
|
|
1223
1104
|
if (typeof length === "number") {
|
|
1224
1105
|
return length;
|
|
1225
1106
|
}
|
|
1226
|
-
|
|
1227
1107
|
var parsed = parseNumeric(length);
|
|
1228
|
-
|
|
1229
1108
|
if (parsed && (!parsed.units || parsed.units === "px")) {
|
|
1230
1109
|
return parsed.num;
|
|
1231
1110
|
}
|
|
1232
|
-
|
|
1233
1111
|
return undefined;
|
|
1234
1112
|
}
|
|
1235
|
-
|
|
1236
1113
|
function parseNumeric(val) {
|
|
1237
1114
|
// Parse strings like "30", "30px", "30%", "30px /* blah blah */"
|
|
1238
1115
|
var res = val.match(/^\s*(-?(?:\d+\.\d*|\d*\.\d+|\d+))\s*([a-z]*|%)\s*(?:\/\*.*)?$/i);
|
|
1239
|
-
|
|
1240
1116
|
if (res == null) {
|
|
1241
1117
|
return undefined;
|
|
1242
1118
|
}
|
|
1243
|
-
|
|
1244
1119
|
var num = res[1];
|
|
1245
1120
|
var units = res[2];
|
|
1246
1121
|
return {
|
|
@@ -1248,7 +1123,6 @@ function parseNumeric(val) {
|
|
|
1248
1123
|
units: units
|
|
1249
1124
|
};
|
|
1250
1125
|
}
|
|
1251
|
-
|
|
1252
1126
|
function getImageLoader(loader) {
|
|
1253
1127
|
if (loader == null) {
|
|
1254
1128
|
return undefined;
|
|
@@ -1258,14 +1132,12 @@ function getImageLoader(loader) {
|
|
|
1258
1132
|
return loader;
|
|
1259
1133
|
}
|
|
1260
1134
|
}
|
|
1261
|
-
|
|
1262
1135
|
var PLASMIC_IMAGE_LOADER = {
|
|
1263
1136
|
supportsUrl: function supportsUrl(src) {
|
|
1264
1137
|
return src.startsWith("https://img.plasmic.app") && !isSvg(src);
|
|
1265
1138
|
},
|
|
1266
1139
|
transformUrl: function transformUrl(opts) {
|
|
1267
1140
|
var _opts$quality;
|
|
1268
|
-
|
|
1269
1141
|
var params = [opts.width ? "w=" + opts.width : undefined, "q=" + ((_opts$quality = opts.quality) != null ? _opts$quality : 75), opts.format ? "f=" + opts.format : undefined].filter(function (x) {
|
|
1270
1142
|
return !!x;
|
|
1271
1143
|
});
|
|
@@ -1284,46 +1156,37 @@ var PlasmicLink = /*#__PURE__*/React__default.forwardRef(function PlasmicLink(pr
|
|
|
1284
1156
|
ref: ref
|
|
1285
1157
|
})));
|
|
1286
1158
|
}
|
|
1287
|
-
|
|
1288
1159
|
if (props.platform === "gatsby" && isInternalHref(props.href)) {
|
|
1289
1160
|
return React__default.createElement(props.component, _extends({}, omit(props, "component", "platform", "href"), {
|
|
1290
1161
|
to: props.href,
|
|
1291
1162
|
ref: ref
|
|
1292
1163
|
}));
|
|
1293
1164
|
}
|
|
1294
|
-
|
|
1295
1165
|
return React__default.createElement("a", Object.assign({}, omit(props, "component", "platform"), {
|
|
1296
1166
|
ref: ref
|
|
1297
1167
|
}));
|
|
1298
1168
|
});
|
|
1299
|
-
|
|
1300
1169
|
function isInternalHref(href) {
|
|
1301
1170
|
return /^\/(?!\/)/.test(href);
|
|
1302
1171
|
}
|
|
1303
1172
|
|
|
1304
1173
|
var PlasmicTranslatorContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
1305
|
-
|
|
1306
1174
|
function isIterable(val) {
|
|
1307
1175
|
return val != null && typeof val[Symbol.iterator] === "function";
|
|
1308
1176
|
}
|
|
1309
|
-
|
|
1310
1177
|
function genTranslatableString(elt) {
|
|
1311
1178
|
var components = {};
|
|
1312
1179
|
var componentsCount = 0;
|
|
1313
|
-
|
|
1314
1180
|
var getText = function getText(node) {
|
|
1315
1181
|
if (!node) {
|
|
1316
1182
|
return "";
|
|
1317
1183
|
}
|
|
1318
|
-
|
|
1319
1184
|
if (typeof node === "number" || typeof node === "boolean" || typeof node === "string") {
|
|
1320
1185
|
return node.toString();
|
|
1321
1186
|
}
|
|
1322
|
-
|
|
1323
1187
|
if (typeof node !== "object") {
|
|
1324
1188
|
return "";
|
|
1325
1189
|
}
|
|
1326
|
-
|
|
1327
1190
|
if (Array.isArray(node) || isIterable(node)) {
|
|
1328
1191
|
return Array.from(node).map(function (child) {
|
|
1329
1192
|
return getText(child);
|
|
@@ -1331,18 +1194,15 @@ function genTranslatableString(elt) {
|
|
|
1331
1194
|
return !!child;
|
|
1332
1195
|
}).join("");
|
|
1333
1196
|
}
|
|
1334
|
-
|
|
1335
1197
|
var nodeChildren = hasKey(node, "props") && hasKey(node.props, "children") && node.props.children || hasKey(node, "children") && node.children || [];
|
|
1336
1198
|
var contents = "" + React__default.Children.toArray(nodeChildren).map(function (child) {
|
|
1337
1199
|
return getText(child);
|
|
1338
1200
|
}).filter(function (child) {
|
|
1339
1201
|
return !!child;
|
|
1340
1202
|
}).join("");
|
|
1341
|
-
|
|
1342
1203
|
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
1343
1204
|
return contents;
|
|
1344
1205
|
}
|
|
1345
|
-
|
|
1346
1206
|
var componentId = componentsCount + 1;
|
|
1347
1207
|
componentsCount++;
|
|
1348
1208
|
components[componentId] = React__default.isValidElement(node) ? React__default.cloneElement(node, {
|
|
@@ -1351,7 +1211,6 @@ function genTranslatableString(elt) {
|
|
|
1351
1211
|
}) : node;
|
|
1352
1212
|
return "<" + componentId + ">" + contents + "</" + componentId + ">";
|
|
1353
1213
|
};
|
|
1354
|
-
|
|
1355
1214
|
var str = getText(elt);
|
|
1356
1215
|
return {
|
|
1357
1216
|
str: str,
|
|
@@ -1360,33 +1219,28 @@ function genTranslatableString(elt) {
|
|
|
1360
1219
|
};
|
|
1361
1220
|
}
|
|
1362
1221
|
function Trans(_ref) {
|
|
1363
|
-
var
|
|
1364
|
-
|
|
1222
|
+
var transKey = _ref.transKey,
|
|
1223
|
+
children = _ref.children;
|
|
1365
1224
|
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
1366
|
-
|
|
1367
1225
|
if (!_t) {
|
|
1368
1226
|
warnNoTranslationFunctionAtMostOnce();
|
|
1369
1227
|
return children;
|
|
1370
1228
|
}
|
|
1371
|
-
|
|
1372
1229
|
var _genTranslatableStrin = genTranslatableString(children),
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
return _t(str, componentsCount > 0 ? {
|
|
1230
|
+
str = _genTranslatableStrin.str,
|
|
1231
|
+
components = _genTranslatableStrin.components,
|
|
1232
|
+
componentsCount = _genTranslatableStrin.componentsCount;
|
|
1233
|
+
return _t(transKey != null ? transKey : str, componentsCount > 0 ? {
|
|
1378
1234
|
components: components
|
|
1379
1235
|
} : undefined);
|
|
1380
1236
|
}
|
|
1381
1237
|
var hasWarned = false;
|
|
1382
|
-
|
|
1383
1238
|
function warnNoTranslationFunctionAtMostOnce() {
|
|
1384
1239
|
if (!hasWarned) {
|
|
1385
1240
|
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
1386
1241
|
hasWarned = true;
|
|
1387
1242
|
}
|
|
1388
1243
|
}
|
|
1389
|
-
|
|
1390
1244
|
function hasKey(v, key) {
|
|
1391
1245
|
return typeof v === "object" && v !== null && key in v;
|
|
1392
1246
|
}
|
|
@@ -1397,68 +1251,56 @@ function PlasmicSlot(props) {
|
|
|
1397
1251
|
}
|
|
1398
1252
|
function renderPlasmicSlot(opts) {
|
|
1399
1253
|
var as = opts.as,
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1254
|
+
defaultContents = opts.defaultContents,
|
|
1255
|
+
value = opts.value,
|
|
1256
|
+
rest = _objectWithoutPropertiesLoose(opts, _excluded$3);
|
|
1404
1257
|
var content = value === undefined ? defaultContents : value;
|
|
1405
|
-
|
|
1406
1258
|
if (!content || Array.isArray(content) && content.length === 0) {
|
|
1407
1259
|
return null;
|
|
1408
|
-
}
|
|
1260
|
+
}
|
|
1261
|
+
// If the content is a raw string, then we need to wrap the raw string
|
|
1409
1262
|
// into an element, in case the slot is inside a flex-gap
|
|
1410
1263
|
// container (you cannot apply margin to just a text node).
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
1264
|
var maybeString = maybeAsString(content);
|
|
1414
|
-
|
|
1415
1265
|
if (maybeString) {
|
|
1416
1266
|
content = createElement("span", {
|
|
1417
1267
|
className: "__wab_slot-string-wrapper"
|
|
1418
1268
|
}, maybeString);
|
|
1419
1269
|
}
|
|
1420
|
-
|
|
1421
1270
|
var nonEmptyProps = Object.keys(rest).filter(function (p) {
|
|
1422
1271
|
return !!rest[p];
|
|
1423
1272
|
});
|
|
1424
|
-
|
|
1425
1273
|
if (nonEmptyProps.length === 0) {
|
|
1426
1274
|
// No attrs to apply to the slot (which means the slot is unstyled), then
|
|
1427
1275
|
// just render the content directly; no need for style wrapper.
|
|
1428
1276
|
return createElement(Fragment, null, content);
|
|
1429
1277
|
}
|
|
1430
|
-
|
|
1431
1278
|
return createElement(as || "span", mergeProps({
|
|
1432
1279
|
className: "__wab_slot"
|
|
1433
1280
|
}, rest), content);
|
|
1434
1281
|
}
|
|
1435
|
-
|
|
1436
1282
|
function maybeAsString(node) {
|
|
1437
1283
|
// Unwrap fragments
|
|
1438
|
-
if (isValidElement(node) && (
|
|
1284
|
+
if (isValidElement(node) && (
|
|
1285
|
+
// Fragment and Trans don't render DOM elements
|
|
1439
1286
|
node.type === Fragment || node.type === Trans)) {
|
|
1440
1287
|
return maybeAsString(node.props.children);
|
|
1441
1288
|
}
|
|
1442
|
-
|
|
1443
1289
|
if (typeof node === "string") {
|
|
1444
1290
|
return node;
|
|
1445
1291
|
}
|
|
1446
|
-
|
|
1447
1292
|
if (Array.isArray(node) && node.length === 1 && typeof node[0] === "string") {
|
|
1448
1293
|
return node[0];
|
|
1449
1294
|
}
|
|
1450
|
-
|
|
1451
1295
|
return undefined;
|
|
1452
1296
|
}
|
|
1453
1297
|
|
|
1454
1298
|
var listeners = [];
|
|
1455
1299
|
var queries = {};
|
|
1456
|
-
|
|
1457
1300
|
function matchScreenVariants() {
|
|
1458
1301
|
if (!isBrowser) {
|
|
1459
1302
|
return [];
|
|
1460
1303
|
}
|
|
1461
|
-
|
|
1462
1304
|
return Object.entries(queries).filter(function (_ref) {
|
|
1463
1305
|
var query = _ref[1];
|
|
1464
1306
|
return window.matchMedia(query).matches;
|
|
@@ -1466,14 +1308,11 @@ function matchScreenVariants() {
|
|
|
1466
1308
|
var name = _ref2[0];
|
|
1467
1309
|
return name;
|
|
1468
1310
|
});
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1311
|
+
}
|
|
1312
|
+
// undefined if screen variants have never been calculated
|
|
1472
1313
|
var curScreenVariants = undefined;
|
|
1473
|
-
|
|
1474
1314
|
function recalculateScreenVariants() {
|
|
1475
1315
|
var screenVariant = matchScreenVariants();
|
|
1476
|
-
|
|
1477
1316
|
if (!curScreenVariants || screenVariant.join("") !== curScreenVariants.join("")) {
|
|
1478
1317
|
curScreenVariants = screenVariant;
|
|
1479
1318
|
ReactDOM__default.unstable_batchedUpdates(function () {
|
|
@@ -1483,7 +1322,6 @@ function recalculateScreenVariants() {
|
|
|
1483
1322
|
});
|
|
1484
1323
|
}
|
|
1485
1324
|
}
|
|
1486
|
-
|
|
1487
1325
|
function ensureInitCurScreenVariants() {
|
|
1488
1326
|
// Initializes curScreenVariants if it hadn't been before. Note that this must
|
|
1489
1327
|
// be called from within an effect.
|
|
@@ -1491,11 +1329,9 @@ function ensureInitCurScreenVariants() {
|
|
|
1491
1329
|
curScreenVariants = matchScreenVariants();
|
|
1492
1330
|
}
|
|
1493
1331
|
}
|
|
1494
|
-
|
|
1495
1332
|
if (isBrowser) {
|
|
1496
1333
|
window.addEventListener("resize", recalculateScreenVariants);
|
|
1497
1334
|
}
|
|
1498
|
-
|
|
1499
1335
|
function createUseScreenVariants(isMulti, screenQueries) {
|
|
1500
1336
|
Object.assign(queries, screenQueries);
|
|
1501
1337
|
curScreenVariants = undefined;
|
|
@@ -1505,38 +1341,35 @@ function createUseScreenVariants(isMulti, screenQueries) {
|
|
|
1505
1341
|
// only happens on the client), we then actually ask for the real screen variant
|
|
1506
1342
|
// and, if different from [] or undefined, forces a re-render.
|
|
1507
1343
|
var _React$useState = useState(),
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1344
|
+
updateState = _React$useState[1];
|
|
1345
|
+
var lastScreenVariantsRef = useRef(curScreenVariants || []);
|
|
1346
|
+
// We do useLayoutEffect instead of useEffect to immediately
|
|
1511
1347
|
// register our forceUpdate. This ensures that if there was
|
|
1512
1348
|
// a window resize event between render and effects, that the
|
|
1513
1349
|
// listener will be registered in time
|
|
1514
|
-
|
|
1515
1350
|
useIsomorphicLayoutEffect(function () {
|
|
1516
1351
|
var updateIfChanged = function updateIfChanged() {
|
|
1517
1352
|
if (curScreenVariants && lastScreenVariantsRef.current.join("") !== curScreenVariants.join("")) {
|
|
1518
|
-
lastScreenVariantsRef.current = curScreenVariants;
|
|
1519
|
-
|
|
1353
|
+
lastScreenVariantsRef.current = curScreenVariants;
|
|
1354
|
+
// Force update
|
|
1520
1355
|
updateState({});
|
|
1521
1356
|
}
|
|
1522
|
-
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1357
|
+
};
|
|
1358
|
+
// Listeners are invoked whenever the window is resized
|
|
1359
|
+
listeners.push(updateIfChanged);
|
|
1360
|
+
// Initialize the curScreenVariants for the first time. We don't need
|
|
1526
1361
|
// to invoke the listeners here because all components will already
|
|
1527
1362
|
// have this effect running and will re-render if the real screen
|
|
1528
1363
|
// variant is non-empty.
|
|
1529
|
-
|
|
1530
|
-
|
|
1364
|
+
ensureInitCurScreenVariants();
|
|
1365
|
+
// Now, if the curScreenVariants differs from what we returned last,
|
|
1531
1366
|
// then force a re-render.
|
|
1532
|
-
|
|
1533
1367
|
updateIfChanged();
|
|
1534
1368
|
return function () {
|
|
1535
1369
|
// Remove our listener on unmount
|
|
1536
1370
|
listeners.splice(listeners.indexOf(updateIfChanged), 1);
|
|
1537
1371
|
};
|
|
1538
1372
|
}, []);
|
|
1539
|
-
|
|
1540
1373
|
if (isMulti) {
|
|
1541
1374
|
return curScreenVariants || [];
|
|
1542
1375
|
} else if (curScreenVariants) {
|
|
@@ -1550,9 +1383,10 @@ function createUseScreenVariants(isMulti, screenQueries) {
|
|
|
1550
1383
|
var PlasmicRootContext = /*#__PURE__*/createContext(undefined);
|
|
1551
1384
|
function PlasmicRootProvider(props) {
|
|
1552
1385
|
var platform = props.platform,
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1386
|
+
children = props.children,
|
|
1387
|
+
userAuthToken = props.userAuthToken,
|
|
1388
|
+
isUserLoading = props.isUserLoading,
|
|
1389
|
+
user = props.user;
|
|
1556
1390
|
var context = useMemo(function () {
|
|
1557
1391
|
return {
|
|
1558
1392
|
platform: platform
|
|
@@ -1561,9 +1395,10 @@ function PlasmicRootProvider(props) {
|
|
|
1561
1395
|
var dataSourceContextValue = useMemo(function () {
|
|
1562
1396
|
return {
|
|
1563
1397
|
userAuthToken: userAuthToken,
|
|
1564
|
-
user: user
|
|
1398
|
+
user: user,
|
|
1399
|
+
isUserLoading: isUserLoading
|
|
1565
1400
|
};
|
|
1566
|
-
}, [userAuthToken, user]);
|
|
1401
|
+
}, [userAuthToken, isUserLoading, user]);
|
|
1567
1402
|
return createElement(PlasmicRootContext.Provider, {
|
|
1568
1403
|
value: context
|
|
1569
1404
|
}, createElement(SSRProvider, null, createElement(PlasmicDataSourceContextProvider, {
|
|
@@ -1582,67 +1417,55 @@ var hasWarnedSSR = false;
|
|
|
1582
1417
|
/**
|
|
1583
1418
|
* Warns the user if PlasmicRootProvider is not used
|
|
1584
1419
|
*/
|
|
1585
|
-
|
|
1586
1420
|
function useEnsureSSRProvider() {
|
|
1587
1421
|
var hasRoot = useHasPlasmicRoot();
|
|
1588
|
-
|
|
1589
1422
|
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
1590
1423
|
return;
|
|
1591
1424
|
}
|
|
1592
|
-
|
|
1593
1425
|
hasWarnedSSR = true;
|
|
1594
1426
|
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
1595
1427
|
}
|
|
1596
1428
|
|
|
1597
1429
|
function useFocused(opts) {
|
|
1598
1430
|
var _useAriaFocusRing = useFocusRing({
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1431
|
+
within: false,
|
|
1432
|
+
isTextInput: opts.isTextInput
|
|
1433
|
+
}),
|
|
1434
|
+
isFocused = _useAriaFocusRing.isFocused,
|
|
1435
|
+
focusProps = _useAriaFocusRing.focusProps;
|
|
1605
1436
|
return [isFocused, focusProps];
|
|
1606
1437
|
}
|
|
1607
|
-
|
|
1608
1438
|
function useFocusVisible(opts) {
|
|
1609
1439
|
var _useAriaFocusRing2 = useFocusRing({
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1440
|
+
within: false,
|
|
1441
|
+
isTextInput: opts.isTextInput
|
|
1442
|
+
}),
|
|
1443
|
+
isFocusVisible = _useAriaFocusRing2.isFocusVisible,
|
|
1444
|
+
focusProps = _useAriaFocusRing2.focusProps;
|
|
1616
1445
|
return [isFocusVisible, focusProps];
|
|
1617
1446
|
}
|
|
1618
|
-
|
|
1619
1447
|
function useFocusedWithin(opts) {
|
|
1620
1448
|
var _useAriaFocusRing3 = useFocusRing({
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1449
|
+
within: true,
|
|
1450
|
+
isTextInput: opts.isTextInput
|
|
1451
|
+
}),
|
|
1452
|
+
isFocused = _useAriaFocusRing3.isFocused,
|
|
1453
|
+
focusProps = _useAriaFocusRing3.focusProps;
|
|
1627
1454
|
return [isFocused, focusProps];
|
|
1628
1455
|
}
|
|
1629
|
-
|
|
1630
1456
|
function useFocusVisibleWithin(opts) {
|
|
1631
1457
|
var _useAriaFocusRing4 = useFocusRing({
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1458
|
+
within: true,
|
|
1459
|
+
isTextInput: opts.isTextInput
|
|
1460
|
+
}),
|
|
1461
|
+
isFocusVisible = _useAriaFocusRing4.isFocusVisible,
|
|
1462
|
+
focusProps = _useAriaFocusRing4.focusProps;
|
|
1638
1463
|
return [isFocusVisible, focusProps];
|
|
1639
1464
|
}
|
|
1640
|
-
|
|
1641
1465
|
function useHover() {
|
|
1642
1466
|
var _React$useState = useState(false),
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1467
|
+
isHover = _React$useState[0],
|
|
1468
|
+
setHover = _React$useState[1];
|
|
1646
1469
|
return [isHover, {
|
|
1647
1470
|
onMouseEnter: function onMouseEnter() {
|
|
1648
1471
|
return setHover(true);
|
|
@@ -1652,12 +1475,10 @@ function useHover() {
|
|
|
1652
1475
|
}
|
|
1653
1476
|
}];
|
|
1654
1477
|
}
|
|
1655
|
-
|
|
1656
1478
|
function usePressed() {
|
|
1657
1479
|
var _React$useState2 = useState(false),
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1480
|
+
isPressed = _React$useState2[0],
|
|
1481
|
+
setPressed = _React$useState2[1];
|
|
1661
1482
|
return [isPressed, {
|
|
1662
1483
|
onMouseDown: function onMouseDown() {
|
|
1663
1484
|
return setPressed(true);
|
|
@@ -1667,7 +1488,6 @@ function usePressed() {
|
|
|
1667
1488
|
}
|
|
1668
1489
|
}];
|
|
1669
1490
|
}
|
|
1670
|
-
|
|
1671
1491
|
var TRIGGER_TO_HOOK = {
|
|
1672
1492
|
useHover: useHover,
|
|
1673
1493
|
useFocused: useFocused,
|
|
@@ -1680,7 +1500,6 @@ var TRIGGER_TO_HOOK = {
|
|
|
1680
1500
|
* Installs argment trigger. All the useTrigger calls must use hardcoded `trigger` arg,
|
|
1681
1501
|
* as it's not valid to install variable React hooks!
|
|
1682
1502
|
*/
|
|
1683
|
-
|
|
1684
1503
|
function useTrigger(trigger, opts) {
|
|
1685
1504
|
return TRIGGER_TO_HOOK[trigger](opts);
|
|
1686
1505
|
}
|
|
@@ -1696,7 +1515,6 @@ function generateStateOnChangeProp($state, stateName, dataReps) {
|
|
|
1696
1515
|
* - parent[][].counter[].count
|
|
1697
1516
|
* We need to pass `parent[index1][index2].counter to the child component
|
|
1698
1517
|
*/
|
|
1699
|
-
|
|
1700
1518
|
function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
1701
1519
|
) {
|
|
1702
1520
|
return _get($state, path);
|
|
@@ -1705,19 +1523,16 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
|
1705
1523
|
* Forked from https://github.com/lukeed/dset
|
|
1706
1524
|
* Changes: fixed setting a deep value to a proxy object
|
|
1707
1525
|
*/
|
|
1708
|
-
|
|
1709
1526
|
function set(obj, keys, val) {
|
|
1710
1527
|
keys = keys.split ? keys.split(".") : keys;
|
|
1711
1528
|
var i = 0,
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1529
|
+
l = keys.length,
|
|
1530
|
+
t = obj,
|
|
1531
|
+
x,
|
|
1532
|
+
k;
|
|
1717
1533
|
while (i < l) {
|
|
1718
1534
|
k = keys[i++];
|
|
1719
1535
|
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
1720
|
-
|
|
1721
1536
|
if (i === l) {
|
|
1722
1537
|
t[k] = val;
|
|
1723
1538
|
t = t[k];
|
|
@@ -1739,13 +1554,11 @@ function shallowEqual(a1, a2) {
|
|
|
1739
1554
|
if (a1.length !== a2.length) {
|
|
1740
1555
|
return false;
|
|
1741
1556
|
}
|
|
1742
|
-
|
|
1743
1557
|
for (var i = 0; i < a1.length; i++) {
|
|
1744
1558
|
if (a1[i] !== a2[i]) {
|
|
1745
1559
|
return false;
|
|
1746
1560
|
}
|
|
1747
1561
|
}
|
|
1748
|
-
|
|
1749
1562
|
return true;
|
|
1750
1563
|
}
|
|
1751
1564
|
function isNum(value) {
|
|
@@ -1759,45 +1572,35 @@ var StateSpecNode = /*#__PURE__*/function () {
|
|
|
1759
1572
|
this.specs = specs;
|
|
1760
1573
|
this.edges = new Map();
|
|
1761
1574
|
}
|
|
1762
|
-
|
|
1763
1575
|
var _proto = StateSpecNode.prototype;
|
|
1764
|
-
|
|
1765
1576
|
_proto.hasEdge = function hasEdge(key) {
|
|
1766
1577
|
return this.edges.has(key);
|
|
1767
1578
|
};
|
|
1768
|
-
|
|
1769
1579
|
_proto.addEdge = function addEdge(key, node) {
|
|
1770
1580
|
this.edges.set(key, node);
|
|
1771
1581
|
};
|
|
1772
|
-
|
|
1773
1582
|
_proto.makeTransition = function makeTransition(key) {
|
|
1774
1583
|
key = isNum(key) ? ARRAY_SYMBOL : key;
|
|
1775
1584
|
return this.edges.get(key);
|
|
1776
1585
|
};
|
|
1777
|
-
|
|
1778
1586
|
_proto.isLeaf = function isLeaf() {
|
|
1779
1587
|
return this.edges.size === 0;
|
|
1780
1588
|
};
|
|
1781
|
-
|
|
1782
1589
|
_proto.hasArrayTransition = function hasArrayTransition() {
|
|
1783
1590
|
return this.edges.has(ARRAY_SYMBOL);
|
|
1784
1591
|
};
|
|
1785
|
-
|
|
1786
1592
|
_proto.getSpec = function getSpec() {
|
|
1787
1593
|
return this.specs[0];
|
|
1788
1594
|
};
|
|
1789
|
-
|
|
1790
1595
|
_proto.getAllSpecs = function getAllSpecs() {
|
|
1791
1596
|
return this.specs;
|
|
1792
1597
|
};
|
|
1793
|
-
|
|
1794
1598
|
return StateSpecNode;
|
|
1795
1599
|
}();
|
|
1796
1600
|
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
1797
1601
|
var splitStatePathPart = function splitStatePathPart(state) {
|
|
1798
1602
|
return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), [ARRAY_SYMBOL]) : [state];
|
|
1799
1603
|
};
|
|
1800
|
-
|
|
1801
1604
|
return str.split(".").flatMap(splitStatePathPart);
|
|
1802
1605
|
};
|
|
1803
1606
|
function buildGraph(specs) {
|
|
@@ -1809,7 +1612,6 @@ function buildGraph(specs) {
|
|
|
1809
1612
|
})
|
|
1810
1613
|
});
|
|
1811
1614
|
});
|
|
1812
|
-
|
|
1813
1615
|
var rec = function rec(currentPath) {
|
|
1814
1616
|
var node = new StateSpecNode(internalSpec.filter(function (spec) {
|
|
1815
1617
|
return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
|
|
@@ -1817,7 +1619,6 @@ function buildGraph(specs) {
|
|
|
1817
1619
|
node.getAllSpecs().forEach(function (spec) {
|
|
1818
1620
|
if (spec.pathObj.length > currentPath.length) {
|
|
1819
1621
|
var nextKey = spec.pathObj[currentPath.length];
|
|
1820
|
-
|
|
1821
1622
|
if (!node.hasEdge(nextKey)) {
|
|
1822
1623
|
node.addEdge(nextKey, rec([].concat(currentPath, [nextKey])));
|
|
1823
1624
|
}
|
|
@@ -1825,63 +1626,52 @@ function buildGraph(specs) {
|
|
|
1825
1626
|
});
|
|
1826
1627
|
return node;
|
|
1827
1628
|
};
|
|
1828
|
-
|
|
1829
1629
|
return rec([]);
|
|
1830
1630
|
}
|
|
1831
1631
|
|
|
1832
1632
|
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1833
1633
|
return o != null && typeof o === "object" ? ref(o) : o;
|
|
1834
1634
|
};
|
|
1835
|
-
|
|
1836
1635
|
function shallowEqual$1(a1, a2) {
|
|
1837
1636
|
if (a1.length !== a2.length) {
|
|
1838
1637
|
return false;
|
|
1839
1638
|
}
|
|
1840
|
-
|
|
1841
1639
|
for (var i = 0; i < a1.length; i++) {
|
|
1842
1640
|
if (a1[i] !== a2[i]) {
|
|
1843
1641
|
return false;
|
|
1844
1642
|
}
|
|
1845
1643
|
}
|
|
1846
|
-
|
|
1847
1644
|
return true;
|
|
1848
1645
|
}
|
|
1849
|
-
|
|
1850
1646
|
function isNum$1(value) {
|
|
1851
1647
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1852
1648
|
}
|
|
1853
|
-
|
|
1854
1649
|
function saveNewState($$state, path, spec) {
|
|
1855
1650
|
var key = JSON.stringify(path);
|
|
1856
1651
|
$$state.existingStates.set(key, {
|
|
1857
1652
|
path: path,
|
|
1858
1653
|
specKey: spec.path
|
|
1859
1654
|
});
|
|
1860
|
-
|
|
1861
1655
|
if (!$$state.statesInstanceBySpec.has(spec.path)) {
|
|
1862
1656
|
$$state.statesInstanceBySpec.set(spec.path, []);
|
|
1863
1657
|
}
|
|
1864
|
-
|
|
1865
1658
|
$$state.statesInstanceBySpec.get(spec.path).push({
|
|
1866
1659
|
path: path,
|
|
1867
1660
|
specKey: spec.path
|
|
1868
1661
|
});
|
|
1869
1662
|
}
|
|
1870
|
-
|
|
1871
1663
|
function create$StateProxy($$state, handlers) {
|
|
1872
1664
|
var rec = function rec(currPath, currNode) {
|
|
1873
1665
|
var getNextPath = function getNextPath(property) {
|
|
1874
1666
|
return [].concat(currPath, [isNum$1(property) ? +property : property]);
|
|
1875
1667
|
};
|
|
1876
|
-
|
|
1877
1668
|
return new Proxy(currNode.hasArrayTransition() ? [] : {}, {
|
|
1878
1669
|
deleteProperty: function deleteProperty(target, property) {
|
|
1879
1670
|
var prefixPath = getNextPath(property);
|
|
1880
1671
|
var specKeysToUpdate = new Set();
|
|
1881
1672
|
$$state.existingStates.forEach(function (_ref) {
|
|
1882
1673
|
var path = _ref.path,
|
|
1883
|
-
|
|
1884
|
-
|
|
1674
|
+
specKey = _ref.specKey;
|
|
1885
1675
|
if (path.length >= prefixPath.length && shallowEqual$1(path.slice(0, prefixPath.length), prefixPath)) {
|
|
1886
1676
|
deleteState($$state, path);
|
|
1887
1677
|
specKeysToUpdate.add(specKey);
|
|
@@ -1889,10 +1679,8 @@ function create$StateProxy($$state, handlers) {
|
|
|
1889
1679
|
});
|
|
1890
1680
|
specKeysToUpdate.forEach(function (specKey) {
|
|
1891
1681
|
var spec = $$state.specsByKey[specKey];
|
|
1892
|
-
|
|
1893
1682
|
if (spec.onChangeProp) {
|
|
1894
1683
|
var _$$state$props$spec$o, _$$state$props;
|
|
1895
|
-
|
|
1896
1684
|
(_$$state$props$spec$o = (_$$state$props = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props, _get($$state.stateValues, currPath), currPath);
|
|
1897
1685
|
}
|
|
1898
1686
|
});
|
|
@@ -1901,101 +1689,81 @@ function create$StateProxy($$state, handlers) {
|
|
|
1901
1689
|
get: function get(target, property, receiver) {
|
|
1902
1690
|
var nextPath = getNextPath(property);
|
|
1903
1691
|
var nextNode = currNode.makeTransition(property);
|
|
1904
|
-
|
|
1905
1692
|
if (nextNode) {
|
|
1906
1693
|
if (nextNode.isLeaf()) {
|
|
1907
1694
|
var _handlers$get, _handlers;
|
|
1908
|
-
|
|
1909
1695
|
target[property] = (_handlers$get = (_handlers = handlers(nextPath, nextNode.getSpec())).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
|
|
1910
1696
|
} else if (!(property in target)) {
|
|
1911
1697
|
target[property] = rec(nextPath, nextNode);
|
|
1912
1698
|
}
|
|
1913
1699
|
}
|
|
1914
|
-
|
|
1915
1700
|
return Reflect.get(target, property, receiver);
|
|
1916
1701
|
},
|
|
1917
1702
|
set: function set$1(target, property, value, receiver) {
|
|
1918
1703
|
var nextPath = getNextPath(property);
|
|
1919
1704
|
var nextNode = currNode.makeTransition(property);
|
|
1920
|
-
|
|
1921
1705
|
if (nextNode && typeof property !== "symbol") {
|
|
1922
1706
|
if (nextNode.isLeaf()) {
|
|
1923
1707
|
var _handlers$set, _handlers2;
|
|
1924
|
-
|
|
1925
1708
|
// reached the end of the spec
|
|
1926
1709
|
target[property] = (_handlers$set = (_handlers2 = handlers(nextPath, nextNode.getSpec())).set) == null ? void 0 : _handlers$set.call(_handlers2, target, property, value, receiver);
|
|
1927
1710
|
return Reflect.set(target, property, value, receiver);
|
|
1928
1711
|
} else if (typeof value === "object") {
|
|
1929
1712
|
target[property] = rec(nextPath, nextNode);
|
|
1930
|
-
|
|
1931
1713
|
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
1932
1714
|
var key = _Object$keys[_i];
|
|
1933
1715
|
target[property][key] = value[key];
|
|
1934
1716
|
}
|
|
1935
|
-
|
|
1936
1717
|
return true;
|
|
1937
1718
|
}
|
|
1938
1719
|
}
|
|
1939
|
-
|
|
1940
1720
|
if (property === "registerInitFunc" && currPath.length === 0) {
|
|
1941
1721
|
return Reflect.set(target, property, value, receiver);
|
|
1942
1722
|
}
|
|
1943
|
-
|
|
1944
1723
|
if (currNode.hasArrayTransition()) {
|
|
1945
1724
|
var _currNode$makeTransit, _currNode$makeTransit2;
|
|
1946
|
-
|
|
1947
1725
|
set($$state.stateValues, nextPath, value);
|
|
1948
|
-
|
|
1949
1726
|
(_currNode$makeTransit = currNode.makeTransition(ARRAY_SYMBOL)) == null ? void 0 : (_currNode$makeTransit2 = _currNode$makeTransit.getAllSpecs()) == null ? void 0 : _currNode$makeTransit2.forEach(function (spec) {
|
|
1950
1727
|
if (spec.onChangeProp) {
|
|
1951
1728
|
var _$$state$props$spec$o2, _$$state$props2;
|
|
1952
|
-
|
|
1953
1729
|
(_$$state$props$spec$o2 = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o2.call(_$$state$props2, value, nextPath);
|
|
1954
1730
|
}
|
|
1955
1731
|
});
|
|
1956
1732
|
return Reflect.set(target, property, value, receiver);
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1733
|
+
}
|
|
1734
|
+
// invalid setting a value that doesn't make part of the spec
|
|
1960
1735
|
return false;
|
|
1961
1736
|
}
|
|
1962
1737
|
});
|
|
1963
1738
|
};
|
|
1964
|
-
|
|
1965
1739
|
return rec([], $$state.rootStateSpec);
|
|
1966
1740
|
}
|
|
1967
|
-
|
|
1968
1741
|
var deleteState = function deleteState($$state, path) {
|
|
1969
1742
|
var _$$state$unsubscripti;
|
|
1970
|
-
|
|
1971
1743
|
var key = JSON.stringify(path);
|
|
1972
1744
|
(_$$state$unsubscripti = $$state.unsubscriptionsByState[key]) == null ? void 0 : _$$state$unsubscripti.forEach(function (f) {
|
|
1973
1745
|
return f();
|
|
1974
1746
|
});
|
|
1975
1747
|
delete $$state.unsubscriptionsByState[key];
|
|
1976
|
-
$$state.existingStates["delete"](key);
|
|
1748
|
+
$$state.existingStates["delete"](key);
|
|
1749
|
+
// delete get($$state.stateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
1977
1750
|
// delete get($$state.initStateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
1978
1751
|
};
|
|
1979
1752
|
|
|
1980
1753
|
var getIndexes = function getIndexes(path, spec) {
|
|
1981
1754
|
var indexes = [];
|
|
1982
|
-
|
|
1983
1755
|
if (path.length !== spec.pathObj.length) {
|
|
1984
1756
|
throw new Error("Unexpected error: state path and spec path have different lengths");
|
|
1985
1757
|
}
|
|
1986
|
-
|
|
1987
1758
|
for (var i = 0; i < spec.pathObj.length; i++) {
|
|
1988
1759
|
if (spec.pathObj[i] === "[]") {
|
|
1989
1760
|
indexes.push(path[i]);
|
|
1990
1761
|
}
|
|
1991
1762
|
}
|
|
1992
|
-
|
|
1993
1763
|
return indexes;
|
|
1994
1764
|
};
|
|
1995
|
-
|
|
1996
1765
|
function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
1997
1766
|
var _$$state$unsubscripti2;
|
|
1998
|
-
|
|
1999
1767
|
var initialStateKey = JSON.stringify(initialStatePath);
|
|
2000
1768
|
var stateAccess = new Set();
|
|
2001
1769
|
var $state = create$StateProxy($$state, function (path, spec) {
|
|
@@ -2006,18 +1774,15 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
2006
1774
|
path: path,
|
|
2007
1775
|
spec: spec
|
|
2008
1776
|
});
|
|
2009
|
-
|
|
2010
1777
|
if (spec.valueProp) {
|
|
2011
1778
|
return !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
2012
1779
|
}
|
|
2013
|
-
|
|
2014
1780
|
if ($$state.existingStates.has(key)) {
|
|
2015
1781
|
// is already initialized
|
|
2016
1782
|
return _get($$state.stateValues, path);
|
|
2017
1783
|
} else if (spec.initFunc) {
|
|
2018
1784
|
initializeStateValue($$state, path, spec);
|
|
2019
1785
|
}
|
|
2020
|
-
|
|
2021
1786
|
return _get($$state.stateValues, path);
|
|
2022
1787
|
},
|
|
2023
1788
|
set: function set() {
|
|
@@ -2031,7 +1796,7 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
2031
1796
|
$$state.unsubscriptionsByState[initialStateKey] = [];
|
|
2032
1797
|
stateAccess.forEach(function (_ref2) {
|
|
2033
1798
|
var path = _ref2.path,
|
|
2034
|
-
|
|
1799
|
+
spec = _ref2.spec;
|
|
2035
1800
|
var unsubscribe = subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
2036
1801
|
return saveValue($$state, initialStatePath, initialSpec, initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec)));
|
|
2037
1802
|
});
|
|
@@ -2041,7 +1806,6 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
2041
1806
|
saveStateInitialValue($$state, initialStatePath, initialSpec, initialValue);
|
|
2042
1807
|
return initialValue;
|
|
2043
1808
|
}
|
|
2044
|
-
|
|
2045
1809
|
function saveValue($$state, path, spec, value) {
|
|
2046
1810
|
if (spec.isImmutable) {
|
|
2047
1811
|
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
@@ -2049,21 +1813,16 @@ function saveValue($$state, path, spec, value) {
|
|
|
2049
1813
|
set($$state.stateValues, path, value);
|
|
2050
1814
|
}
|
|
2051
1815
|
}
|
|
2052
|
-
|
|
2053
1816
|
function saveStateInitialValue($$state, path, spec, initialValue) {
|
|
2054
1817
|
if (spec.isImmutable) {
|
|
2055
1818
|
var untrackedValue = mkUntrackedValue(initialValue);
|
|
2056
|
-
|
|
2057
1819
|
set($$state.stateValues, path, untrackedValue);
|
|
2058
|
-
|
|
2059
1820
|
set($$state.initStateValues, path, clone(untrackedValue));
|
|
2060
1821
|
} else {
|
|
2061
1822
|
set($$state.stateValues, path, clone(initialValue));
|
|
2062
|
-
|
|
2063
1823
|
set($$state.initStateValues, path, clone(initialValue));
|
|
2064
1824
|
}
|
|
2065
1825
|
}
|
|
2066
|
-
|
|
2067
1826
|
function useDollarState(specs, props, $ctx) {
|
|
2068
1827
|
var $$state = React__default.useRef(proxy({
|
|
2069
1828
|
stateValues: {},
|
|
@@ -2088,15 +1847,12 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2088
1847
|
$$state.ctx = mkUntrackedValue($ctx != null ? $ctx : {});
|
|
2089
1848
|
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
2090
1849
|
var key = JSON.stringify(path);
|
|
2091
|
-
|
|
2092
1850
|
if (!$$state.existingStates.has(key)) {
|
|
2093
1851
|
var _spec$initVal;
|
|
2094
|
-
|
|
2095
1852
|
saveNewState($$state, path, spec);
|
|
2096
1853
|
var initialValue = !spec.initFunc ? (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined : initializeStateValue($$state, path, spec);
|
|
2097
1854
|
saveStateInitialValue($$state, path, spec, initialValue);
|
|
2098
1855
|
}
|
|
2099
|
-
|
|
2100
1856
|
return {
|
|
2101
1857
|
get: function get() {
|
|
2102
1858
|
if (spec.valueProp) {
|
|
@@ -2108,23 +1864,19 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2108
1864
|
},
|
|
2109
1865
|
set: function set(_t, _p, value) {
|
|
2110
1866
|
saveValue($$state, path, spec, value);
|
|
2111
|
-
|
|
2112
1867
|
if (spec.onChangeProp) {
|
|
2113
1868
|
var _$$state$props$spec$o3, _$$state$props3;
|
|
2114
|
-
|
|
2115
1869
|
(_$$state$props$spec$o3 = (_$$state$props3 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o3.call(_$$state$props3, value, path);
|
|
2116
1870
|
}
|
|
2117
|
-
|
|
2118
1871
|
return true;
|
|
2119
1872
|
}
|
|
2120
1873
|
};
|
|
2121
1874
|
}), {
|
|
2122
1875
|
registerInitFunc: function registerInitFunc(pathStr, f) {
|
|
2123
1876
|
var _$$state$statesInstan;
|
|
2124
|
-
|
|
2125
1877
|
if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
|
|
2126
1878
|
var path = _ref3.path,
|
|
2127
|
-
|
|
1879
|
+
specKey = _ref3.specKey;
|
|
2128
1880
|
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2129
1881
|
})) {
|
|
2130
1882
|
$$state.registrationsQueue.push({
|
|
@@ -2133,18 +1885,16 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2133
1885
|
});
|
|
2134
1886
|
}
|
|
2135
1887
|
}
|
|
2136
|
-
})).current;
|
|
1888
|
+
})).current;
|
|
1889
|
+
// For each spec with an initFunc, evaluate it and see if
|
|
2137
1890
|
// the init value has changed. If so, reset its state.
|
|
2138
|
-
|
|
2139
1891
|
var resetSpecs = [];
|
|
2140
1892
|
$$state.existingStates.forEach(function (_ref4) {
|
|
2141
1893
|
var path = _ref4.path,
|
|
2142
|
-
|
|
1894
|
+
specKey = _ref4.specKey;
|
|
2143
1895
|
var spec = $$state.specsByKey[specKey];
|
|
2144
|
-
|
|
2145
1896
|
if (spec.initFunc) {
|
|
2146
1897
|
var newInit = spec.initFunc(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, spec));
|
|
2147
|
-
|
|
2148
1898
|
if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
|
|
2149
1899
|
resetSpecs.push({
|
|
2150
1900
|
path: path,
|
|
@@ -2156,12 +1906,10 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2156
1906
|
useIsomorphicLayoutEffect$1(function () {
|
|
2157
1907
|
resetSpecs.forEach(function (_ref5) {
|
|
2158
1908
|
var path = _ref5.path,
|
|
2159
|
-
|
|
1909
|
+
spec = _ref5.spec;
|
|
2160
1910
|
var newInit = initializeStateValue($$state, path, spec);
|
|
2161
|
-
|
|
2162
1911
|
if (spec.onChangeProp) {
|
|
2163
1912
|
var _$$state$props$spec$o4, _$$state$props4;
|
|
2164
|
-
|
|
2165
1913
|
(_$$state$props$spec$o4 = (_$$state$props4 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o4.call(_$$state$props4, newInit, path);
|
|
2166
1914
|
}
|
|
2167
1915
|
});
|
|
@@ -2169,12 +1917,12 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2169
1917
|
useIsomorphicLayoutEffect$1(function () {
|
|
2170
1918
|
$$state.registrationsQueue.forEach(function (_ref6) {
|
|
2171
1919
|
var f = _ref6.f,
|
|
2172
|
-
|
|
1920
|
+
pathStr = _ref6.pathStr;
|
|
2173
1921
|
$$state.specsByKey[pathStr].initFunc = f;
|
|
2174
1922
|
});
|
|
2175
1923
|
$$state.registrationsQueue = [];
|
|
2176
|
-
}, [$$state.registrationsQueue]);
|
|
2177
|
-
|
|
1924
|
+
}, [$$state.registrationsQueue]);
|
|
1925
|
+
// Re-render if any value changed in one of these objects
|
|
2178
1926
|
useSnapshot($$state.stateValues, {
|
|
2179
1927
|
sync: true
|
|
2180
1928
|
});
|
|
@@ -2183,7 +1931,7 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2183
1931
|
});
|
|
2184
1932
|
return $state;
|
|
2185
1933
|
}
|
|
2186
|
-
|
|
1934
|
+
// Simple version of $state useDollarState for read-only
|
|
2187
1935
|
function useCanvasDollarState(specs, props, $ctx) {
|
|
2188
1936
|
var $$state = proxy({
|
|
2189
1937
|
stateValues: {},
|
|
@@ -2207,15 +1955,12 @@ function useCanvasDollarState(specs, props, $ctx) {
|
|
|
2207
1955
|
$$state.props = mkUntrackedValue(props);
|
|
2208
1956
|
$$state.ctx = mkUntrackedValue($ctx);
|
|
2209
1957
|
var $state = {};
|
|
2210
|
-
|
|
2211
1958
|
for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
|
|
2212
1959
|
var spec = _step.value;
|
|
2213
1960
|
var path = transformPathStringToObj(spec.path);
|
|
2214
1961
|
var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initVal ? spec.initVal : spec.initFunc ? initializeStateValue($$state, path, $$state.specsByKey[spec.path]) : undefined;
|
|
2215
|
-
|
|
2216
1962
|
set($state, path, init);
|
|
2217
1963
|
}
|
|
2218
|
-
|
|
2219
1964
|
return $state;
|
|
2220
1965
|
}
|
|
2221
1966
|
|
|
@@ -2230,7 +1975,6 @@ function mergeVariantToggles() {
|
|
|
2230
1975
|
for (var _len = arguments.length, toggles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2231
1976
|
toggles[_key] = arguments[_key];
|
|
2232
1977
|
}
|
|
2233
|
-
|
|
2234
1978
|
var definedToggles = toggles.filter(function (x) {
|
|
2235
1979
|
return !!x.def;
|
|
2236
1980
|
});
|
|
@@ -2241,7 +1985,7 @@ function mergeVariantToggles() {
|
|
|
2241
1985
|
return mapValues(grouped, function (subToggles) {
|
|
2242
1986
|
return Object.fromEntries(subToggles.map(function (_ref2) {
|
|
2243
1987
|
var def = _ref2.def,
|
|
2244
|
-
|
|
1988
|
+
active = _ref2.active;
|
|
2245
1989
|
return [def.variant, !!active];
|
|
2246
1990
|
}));
|
|
2247
1991
|
});
|
|
@@ -2255,7 +1999,6 @@ function getPlumeType(child) {
|
|
|
2255
1999
|
if (!isValidElement(child)) {
|
|
2256
2000
|
return undefined;
|
|
2257
2001
|
}
|
|
2258
|
-
|
|
2259
2002
|
var childType = child.type;
|
|
2260
2003
|
return childType.__plumeType || (childType.getPlumeType == null ? void 0 : childType.getPlumeType(child.props));
|
|
2261
2004
|
}
|
|
@@ -2263,20 +2006,17 @@ function getPlumeType(child) {
|
|
|
2263
2006
|
var _excluded$4 = ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children"];
|
|
2264
2007
|
function useButton(plasmicClass, props, config, ref) {
|
|
2265
2008
|
var _ref, _ref2, _extends2, _overrides;
|
|
2266
|
-
|
|
2267
2009
|
if (ref === void 0) {
|
|
2268
2010
|
ref = null;
|
|
2269
2011
|
}
|
|
2270
|
-
|
|
2271
2012
|
var link = props.link,
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2013
|
+
isDisabled = props.isDisabled,
|
|
2014
|
+
startIcon = props.startIcon,
|
|
2015
|
+
endIcon = props.endIcon,
|
|
2016
|
+
showStartIcon = props.showStartIcon,
|
|
2017
|
+
showEndIcon = props.showEndIcon,
|
|
2018
|
+
children = props.children,
|
|
2019
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
2280
2020
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2281
2021
|
def: config.showStartIconVariant,
|
|
2282
2022
|
active: showStartIcon
|
|
@@ -2287,9 +2027,7 @@ function useButton(plasmicClass, props, config, ref) {
|
|
|
2287
2027
|
def: config.isDisabledVariant,
|
|
2288
2028
|
active: isDisabled
|
|
2289
2029
|
}));
|
|
2290
|
-
|
|
2291
2030
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.startIconSlot && (_ref = {}, _ref[config.startIconSlot] = startIcon, _ref), config.endIconSlot && (_ref2 = {}, _ref2[config.endIconSlot] = endIcon, _ref2), (_extends2 = {}, _extends2[config.contentSlot] = children, _extends2));
|
|
2292
|
-
|
|
2293
2031
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2294
2032
|
as: !!link ? "a" : "button",
|
|
2295
2033
|
props: _extends({}, omit.apply(void 0, [rest].concat(plasmicClass.internalArgProps, plasmicClass.internalVariantProps)), {
|
|
@@ -2332,31 +2070,25 @@ function asAriaCheckboxProps(props) {
|
|
|
2332
2070
|
isSelected: props.isChecked,
|
|
2333
2071
|
defaultSelected: props.defaultChecked
|
|
2334
2072
|
});
|
|
2335
|
-
|
|
2336
2073
|
delete ariaProps["isChecked"];
|
|
2337
2074
|
delete ariaProps["defaultChecked"];
|
|
2338
2075
|
return ariaProps;
|
|
2339
2076
|
}
|
|
2340
|
-
|
|
2341
2077
|
function useCheckbox(plasmicClass, props, config, ref) {
|
|
2342
2078
|
var _overrides, _ref;
|
|
2343
|
-
|
|
2344
2079
|
if (ref === void 0) {
|
|
2345
2080
|
ref = null;
|
|
2346
2081
|
}
|
|
2347
|
-
|
|
2348
2082
|
var children = props.children,
|
|
2349
|
-
|
|
2350
|
-
|
|
2083
|
+
isDisabled = props.isDisabled,
|
|
2084
|
+
isIndeterminate = props.isIndeterminate;
|
|
2351
2085
|
useEnsureSSRProvider();
|
|
2352
2086
|
var inputRef = useRef(null);
|
|
2353
2087
|
var rootRef = useRef(null);
|
|
2354
2088
|
var ariaProps = asAriaCheckboxProps(props);
|
|
2355
2089
|
var state = useToggleState(ariaProps);
|
|
2356
|
-
|
|
2357
2090
|
var _useAriaCheckbox = useCheckbox$1(ariaProps, state, inputRef),
|
|
2358
|
-
|
|
2359
|
-
|
|
2091
|
+
inputProps = _useAriaCheckbox.inputProps;
|
|
2360
2092
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2361
2093
|
def: config.isDisabledVariant,
|
|
2362
2094
|
active: isDisabled
|
|
@@ -2370,7 +2102,6 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
2370
2102
|
def: config.noLabelVariant,
|
|
2371
2103
|
active: !children
|
|
2372
2104
|
}));
|
|
2373
|
-
|
|
2374
2105
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2375
2106
|
as: "label",
|
|
2376
2107
|
props: mergeProps(getStyleProps(props), {
|
|
@@ -2382,9 +2113,7 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
2382
2113
|
}))), children);
|
|
2383
2114
|
}
|
|
2384
2115
|
}, _overrides);
|
|
2385
|
-
|
|
2386
2116
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.labelSlot ? (_ref = {}, _ref[config.labelSlot] = children, _ref) : {});
|
|
2387
|
-
|
|
2388
2117
|
var plumeState = useMemo(function () {
|
|
2389
2118
|
return {
|
|
2390
2119
|
setChecked: function setChecked(checked) {
|
|
@@ -2399,12 +2128,10 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
2399
2128
|
},
|
|
2400
2129
|
focus: function focus() {
|
|
2401
2130
|
var _inputRef$current;
|
|
2402
|
-
|
|
2403
2131
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
2404
2132
|
},
|
|
2405
2133
|
blur: function blur() {
|
|
2406
2134
|
var _inputRef$current2;
|
|
2407
|
-
|
|
2408
2135
|
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
2409
2136
|
},
|
|
2410
2137
|
setChecked: function setChecked(checked) {
|
|
@@ -2430,7 +2157,6 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
2430
2157
|
* Will also assign keys to items by their index in the collection,
|
|
2431
2158
|
* and collect the keys of disabled items.
|
|
2432
2159
|
*/
|
|
2433
|
-
|
|
2434
2160
|
function deriveItemsFromChildren(children, opts) {
|
|
2435
2161
|
if (!children) {
|
|
2436
2162
|
return {
|
|
@@ -2438,15 +2164,13 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
2438
2164
|
disabledKeys: []
|
|
2439
2165
|
};
|
|
2440
2166
|
}
|
|
2441
|
-
|
|
2442
2167
|
var itemPlumeType = opts.itemPlumeType,
|
|
2443
|
-
|
|
2444
|
-
|
|
2168
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
2169
|
+
invalidChildError = opts.invalidChildError;
|
|
2170
|
+
// For Plume items without an explicit key, we assign a key as the index
|
|
2445
2171
|
// of the collection.
|
|
2446
|
-
|
|
2447
2172
|
var itemCount = 0;
|
|
2448
2173
|
var sectionCount = 0;
|
|
2449
|
-
|
|
2450
2174
|
var ensureValue = function ensureValue(element) {
|
|
2451
2175
|
if (!propInChild(element, "value")) {
|
|
2452
2176
|
if (opts.requireItemValue && PLUME_STRICT_MODE) {
|
|
@@ -2463,32 +2187,24 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
2463
2187
|
return element;
|
|
2464
2188
|
}
|
|
2465
2189
|
};
|
|
2466
|
-
|
|
2467
2190
|
var disabledKeys = [];
|
|
2468
|
-
|
|
2469
2191
|
var flattenedChildren = function flattenedChildren(children) {
|
|
2470
2192
|
return toChildArray(children).flatMap(function (child) {
|
|
2471
2193
|
if (React__default.isValidElement(child)) {
|
|
2472
2194
|
if (child.type === React__default.Fragment) {
|
|
2473
2195
|
return flattenedChildren(child.props.children);
|
|
2474
2196
|
}
|
|
2475
|
-
|
|
2476
2197
|
var type = getPlumeType(child);
|
|
2477
|
-
|
|
2478
2198
|
if (type === itemPlumeType) {
|
|
2479
2199
|
child = ensureValue(child);
|
|
2480
2200
|
var childKey = getItemLikeKey(child);
|
|
2481
|
-
|
|
2482
2201
|
if (getChildProp(child, "isDisabled") && !!childKey) {
|
|
2483
2202
|
disabledKeys.push(childKey);
|
|
2484
2203
|
}
|
|
2485
|
-
|
|
2486
2204
|
return [child];
|
|
2487
2205
|
}
|
|
2488
|
-
|
|
2489
2206
|
if (type === sectionPlumeType) {
|
|
2490
2207
|
var _child$key;
|
|
2491
|
-
|
|
2492
2208
|
return [cloneChild(child, {
|
|
2493
2209
|
// key of section doesn't actually matter, just needs
|
|
2494
2210
|
// to be unique
|
|
@@ -2497,7 +2213,6 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
2497
2213
|
})];
|
|
2498
2214
|
}
|
|
2499
2215
|
}
|
|
2500
|
-
|
|
2501
2216
|
if (PLUME_STRICT_MODE) {
|
|
2502
2217
|
throw new Error(invalidChildError != null ? invalidChildError : "Unexpected child");
|
|
2503
2218
|
} else {
|
|
@@ -2505,7 +2220,6 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
2505
2220
|
}
|
|
2506
2221
|
});
|
|
2507
2222
|
};
|
|
2508
|
-
|
|
2509
2223
|
return {
|
|
2510
2224
|
items: flattenedChildren(children),
|
|
2511
2225
|
disabledKeys: disabledKeys
|
|
@@ -2513,9 +2227,9 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
2513
2227
|
}
|
|
2514
2228
|
function useDerivedItemsFromChildren(children, opts) {
|
|
2515
2229
|
var itemPlumeType = opts.itemPlumeType,
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2230
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
2231
|
+
invalidChildError = opts.invalidChildError,
|
|
2232
|
+
requireItemValue = opts.requireItemValue;
|
|
2519
2233
|
return React__default.useMemo(function () {
|
|
2520
2234
|
return deriveItemsFromChildren(children, {
|
|
2521
2235
|
itemPlumeType: itemPlumeType,
|
|
@@ -2529,7 +2243,6 @@ function useDerivedItemsFromChildren(children, opts) {
|
|
|
2529
2243
|
* Given a Collection node, create the React element that we should use
|
|
2530
2244
|
* to render it.
|
|
2531
2245
|
*/
|
|
2532
|
-
|
|
2533
2246
|
function renderCollectionNode(node) {
|
|
2534
2247
|
// node.rendered should already have our item-like or section-like Plume
|
|
2535
2248
|
// component elements, so we just need to clone them with a secret
|
|
@@ -2543,19 +2256,17 @@ function renderCollectionNode(node) {
|
|
|
2543
2256
|
* Renders a item-like or section-like Plume component element into an
|
|
2544
2257
|
* Item or a Section element.
|
|
2545
2258
|
*/
|
|
2546
|
-
|
|
2547
2259
|
function renderAsCollectionChild(child, opts) {
|
|
2548
2260
|
var plumeType = getPlumeType(child);
|
|
2549
|
-
|
|
2550
2261
|
if (plumeType === opts.itemPlumeType) {
|
|
2551
2262
|
var _getChildProp;
|
|
2552
|
-
|
|
2553
|
-
|
|
2263
|
+
var option = child;
|
|
2264
|
+
// We look at the children passed to the item-like element, and derive key
|
|
2554
2265
|
// or textValue from it if it is a string
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2266
|
+
var content = getChildProp(option, "children");
|
|
2267
|
+
// The children render prop needs to return an <Item/>
|
|
2268
|
+
return React__default.createElement(Item
|
|
2269
|
+
// We use ItemLike.value if the user explicitly specified a value,
|
|
2559
2270
|
// and we fallback to key. If the user specified neither, then
|
|
2560
2271
|
// the Collections API will generate a unique key for this item.
|
|
2561
2272
|
, {
|
|
@@ -2570,7 +2281,8 @@ function renderAsCollectionChild(child, opts) {
|
|
|
2570
2281
|
}, option);
|
|
2571
2282
|
} else {
|
|
2572
2283
|
var group = child;
|
|
2573
|
-
return React__default.createElement(Section
|
|
2284
|
+
return React__default.createElement(Section
|
|
2285
|
+
// Note that we are using the whole section-like element as the title
|
|
2574
2286
|
// here, and not group.props.title; we want the entire section-like
|
|
2575
2287
|
// Plume element to end up as Node.rendered.
|
|
2576
2288
|
, {
|
|
@@ -2588,23 +2300,19 @@ function renderAsCollectionChild(child, opts) {
|
|
|
2588
2300
|
});
|
|
2589
2301
|
}
|
|
2590
2302
|
}
|
|
2591
|
-
|
|
2592
2303
|
function getItemLikeKey(element) {
|
|
2593
2304
|
var _getChildProp2;
|
|
2594
|
-
|
|
2595
2305
|
return (_getChildProp2 = getChildProp(element, "value")) != null ? _getChildProp2 : element.key;
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2306
|
+
}
|
|
2307
|
+
// PlasmicLoader-aware function to get prop from child.
|
|
2599
2308
|
function getChildProp(child, prop) {
|
|
2600
2309
|
return "componentProps" in child.props ? child.props.componentProps[prop] : child.props[prop];
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2310
|
+
}
|
|
2311
|
+
// PlasmicLoader-aware function to check `if (prop in element.props)`.
|
|
2603
2312
|
function propInChild(child, prop) {
|
|
2604
2313
|
return "componentProps" in child.props ? prop in child.props.componentProps : prop in child.props;
|
|
2605
|
-
}
|
|
2606
|
-
|
|
2607
|
-
|
|
2314
|
+
}
|
|
2315
|
+
// PlasmicLoader-aware function to clone React element.
|
|
2608
2316
|
function cloneChild(child, props) {
|
|
2609
2317
|
if (child.type.getPlumeType) {
|
|
2610
2318
|
// If React element has getPlumeType(), assume that it is PlasmicLoader,
|
|
@@ -2615,7 +2323,6 @@ function cloneChild(child, props) {
|
|
|
2615
2323
|
key: props.key
|
|
2616
2324
|
} : {}));
|
|
2617
2325
|
}
|
|
2618
|
-
|
|
2619
2326
|
return React__default.cloneElement(child, props);
|
|
2620
2327
|
}
|
|
2621
2328
|
|
|
@@ -2631,18 +2338,15 @@ var COLLECTION_OPTS = {
|
|
|
2631
2338
|
/**
|
|
2632
2339
|
* Converts props from BaseMenuProps to react-aria's useMenu() props.
|
|
2633
2340
|
*/
|
|
2634
|
-
|
|
2635
2341
|
function asAriaMenuProps(props) {
|
|
2636
2342
|
var children = props.children,
|
|
2637
|
-
|
|
2638
|
-
|
|
2343
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
2639
2344
|
var _useDerivedItemsFromC = useDerivedItemsFromChildren(children, _extends({}, COLLECTION_OPTS, {
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2345
|
+
invalidChildError: "Can only use Menu.Item and Menu.Group as children to Menu",
|
|
2346
|
+
requireItemValue: false
|
|
2347
|
+
})),
|
|
2348
|
+
items = _useDerivedItemsFromC.items,
|
|
2349
|
+
disabledKeys = _useDerivedItemsFromC.disabledKeys;
|
|
2646
2350
|
var collectionChildRenderer = useCallback(function (child) {
|
|
2647
2351
|
return renderAsCollectionChild(child, COLLECTION_OPTS);
|
|
2648
2352
|
}, []);
|
|
@@ -2654,38 +2358,29 @@ function asAriaMenuProps(props) {
|
|
|
2654
2358
|
})
|
|
2655
2359
|
};
|
|
2656
2360
|
}
|
|
2657
|
-
|
|
2658
2361
|
function useMenu(plasmicClass, props, config, ref) {
|
|
2659
2362
|
var _overrides, _extends2;
|
|
2660
|
-
|
|
2661
2363
|
if (ref === void 0) {
|
|
2662
2364
|
ref = null;
|
|
2663
2365
|
}
|
|
2664
|
-
|
|
2665
2366
|
useEnsureSSRProvider();
|
|
2666
|
-
|
|
2667
2367
|
var _asAriaMenuProps = asAriaMenuProps(props),
|
|
2668
|
-
|
|
2669
|
-
|
|
2368
|
+
ariaProps = _asAriaMenuProps.ariaProps;
|
|
2670
2369
|
var triggerContext = useContext(TriggeredOverlayContext);
|
|
2671
2370
|
var rootRef = useRef(null);
|
|
2672
2371
|
var state = useTreeState(ariaProps);
|
|
2673
2372
|
var menuListRef = useRef(null);
|
|
2674
|
-
|
|
2675
2373
|
var _useAriaMenu = useMenu$1(_extends({}, ariaProps, {
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2374
|
+
autoFocus: triggerContext == null ? void 0 : triggerContext.autoFocus
|
|
2375
|
+
}), state, menuListRef),
|
|
2376
|
+
menuProps = _useAriaMenu.menuProps;
|
|
2680
2377
|
var contextValue = useMemo(function () {
|
|
2681
2378
|
return {
|
|
2682
2379
|
state: state,
|
|
2683
2380
|
menuProps: props
|
|
2684
2381
|
};
|
|
2685
2382
|
}, [state, props]);
|
|
2686
|
-
|
|
2687
2383
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)));
|
|
2688
|
-
|
|
2689
2384
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2690
2385
|
props: mergeProps(getStyleProps(props), {
|
|
2691
2386
|
ref: rootRef
|
|
@@ -2697,13 +2392,11 @@ function useMenu(plasmicClass, props, config, ref) {
|
|
|
2697
2392
|
style: _extends({}, noOutline())
|
|
2698
2393
|
})
|
|
2699
2394
|
}, _overrides);
|
|
2700
|
-
|
|
2701
2395
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.itemsSlot] = createElement(MenuContext.Provider, {
|
|
2702
2396
|
value: contextValue
|
|
2703
2397
|
}, Array.from(state.collection).map(function (node) {
|
|
2704
2398
|
return renderCollectionNode(node);
|
|
2705
2399
|
})), _extends2));
|
|
2706
|
-
|
|
2707
2400
|
var plumeState = useMemo(function () {
|
|
2708
2401
|
return {
|
|
2709
2402
|
getFocusedValue: function getFocusedValue() {
|
|
@@ -2739,30 +2432,24 @@ function useMenu(plasmicClass, props, config, ref) {
|
|
|
2739
2432
|
|
|
2740
2433
|
function useMenuGroup(plasmicClass, props, config) {
|
|
2741
2434
|
var _extends2, _overrides;
|
|
2742
|
-
|
|
2743
2435
|
var context = useContext(MenuContext);
|
|
2744
2436
|
var node = props._node;
|
|
2745
|
-
|
|
2746
2437
|
if (!context || !node) {
|
|
2747
2438
|
if (PLUME_STRICT_MODE) {
|
|
2748
2439
|
throw new Error("You can only use a Menu.Group within a Menu component.");
|
|
2749
2440
|
}
|
|
2750
|
-
|
|
2751
2441
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
2752
2442
|
}
|
|
2753
|
-
|
|
2754
2443
|
var _useMenuSection = useMenuSection({
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2444
|
+
heading: props.title,
|
|
2445
|
+
"aria-label": props["aria-label"]
|
|
2446
|
+
}),
|
|
2447
|
+
headingProps = _useMenuSection.headingProps,
|
|
2448
|
+
groupProps = _useMenuSection.groupProps;
|
|
2761
2449
|
var _useSeparator = useSeparator({
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2450
|
+
elementType: "li"
|
|
2451
|
+
}),
|
|
2452
|
+
separatorProps = _useSeparator.separatorProps;
|
|
2766
2453
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2767
2454
|
def: config.noTitleVariant,
|
|
2768
2455
|
active: !props.title
|
|
@@ -2770,11 +2457,9 @@ function useMenuGroup(plasmicClass, props, config) {
|
|
|
2770
2457
|
def: config.isFirstVariant,
|
|
2771
2458
|
active: context.state.collection.getFirstKey() === node.key
|
|
2772
2459
|
}));
|
|
2773
|
-
|
|
2774
2460
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.titleSlot] = props.title, _extends2[config.itemsSlot] = Array.from(node.childNodes).map(function (childNode) {
|
|
2775
2461
|
return renderCollectionNode(childNode);
|
|
2776
2462
|
}), _extends2));
|
|
2777
|
-
|
|
2778
2463
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2779
2464
|
props: getStyleProps(props)
|
|
2780
2465
|
}, _overrides[config.separator] = {
|
|
@@ -2803,45 +2488,39 @@ function useMenuGroup(plasmicClass, props, config) {
|
|
|
2803
2488
|
|
|
2804
2489
|
function useMenuItem(plasmicClass, props, config) {
|
|
2805
2490
|
var _extends2, _overrides;
|
|
2806
|
-
|
|
2807
2491
|
var menuContext = useContext(MenuContext);
|
|
2808
2492
|
var triggerContext = useContext(TriggeredOverlayContext);
|
|
2809
|
-
|
|
2810
2493
|
if (!menuContext) {
|
|
2811
2494
|
if (PLUME_STRICT_MODE) {
|
|
2812
2495
|
throw new Error("You can only use a Menu.Item within a Menu component.");
|
|
2813
2496
|
}
|
|
2814
|
-
|
|
2815
2497
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
2816
2498
|
}
|
|
2817
|
-
|
|
2818
2499
|
var children = props.children,
|
|
2819
|
-
|
|
2500
|
+
onAction = props.onAction;
|
|
2820
2501
|
var state = menuContext.state,
|
|
2821
|
-
|
|
2822
|
-
|
|
2502
|
+
menuProps = menuContext.menuProps;
|
|
2503
|
+
// We pass in the Node secretly as an undocumented prop from <Select />
|
|
2823
2504
|
var node = props._node;
|
|
2824
2505
|
var isDisabled = state.disabledKeys.has(node.key);
|
|
2825
2506
|
var isHighlighted = state.selectionManager.isFocused && state.selectionManager.focusedKey === node.key;
|
|
2826
2507
|
var ref = useRef(null);
|
|
2827
|
-
|
|
2828
2508
|
var _useAriaMenuItem = useMenuItem$1(mergeProps({
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2509
|
+
// We need to merge both the onAction on MenuItem and the onAction
|
|
2510
|
+
// on Menu
|
|
2511
|
+
onAction: onAction
|
|
2512
|
+
}, {
|
|
2513
|
+
onAction: menuProps.onAction,
|
|
2514
|
+
onClose: triggerContext == null ? void 0 : triggerContext.state.close
|
|
2515
|
+
}, {
|
|
2516
|
+
isDisabled: isDisabled,
|
|
2517
|
+
"aria-label": node && node["aria-label"],
|
|
2518
|
+
key: node.key,
|
|
2519
|
+
isVirtualized: false,
|
|
2520
|
+
closeOnSelect: true
|
|
2521
|
+
}), state, ref),
|
|
2522
|
+
menuItemProps = _useAriaMenuItem.menuItemProps,
|
|
2523
|
+
labelProps = _useAriaMenuItem.labelProps;
|
|
2845
2524
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2846
2525
|
def: config.isDisabledVariant,
|
|
2847
2526
|
active: isDisabled
|
|
@@ -2849,9 +2528,7 @@ function useMenuItem(plasmicClass, props, config) {
|
|
|
2849
2528
|
def: config.isHighlightedVariant,
|
|
2850
2529
|
active: isHighlighted
|
|
2851
2530
|
}));
|
|
2852
|
-
|
|
2853
2531
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
2854
|
-
|
|
2855
2532
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2856
2533
|
as: "li",
|
|
2857
2534
|
props: mergeProps(menuItemProps, {
|
|
@@ -2874,48 +2551,38 @@ function useMenuItem(plasmicClass, props, config) {
|
|
|
2874
2551
|
* A menu trigger hook that combines react-aria's useMenuTrigger, useAriaMenuTrigger,
|
|
2875
2552
|
* useOverlayPosition, useOverlay, and usePress
|
|
2876
2553
|
*/
|
|
2877
|
-
|
|
2878
2554
|
function useMenuTrigger(opts, state) {
|
|
2879
2555
|
var triggerRef = opts.triggerRef,
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2556
|
+
isDisabled = opts.isDisabled,
|
|
2557
|
+
placement = opts.placement,
|
|
2558
|
+
menuMatchTriggerWidth = opts.menuMatchTriggerWidth,
|
|
2559
|
+
menuWidth = opts.menuWidth,
|
|
2560
|
+
menu = opts.menu;
|
|
2886
2561
|
var _useAriaMenuTrigger = useMenuTrigger$1({
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2562
|
+
type: "menu",
|
|
2563
|
+
isDisabled: isDisabled
|
|
2564
|
+
}, state, triggerRef),
|
|
2565
|
+
triggerPressProps = _useAriaMenuTrigger.menuTriggerProps,
|
|
2566
|
+
menuProps = _useAriaMenuTrigger.menuProps;
|
|
2893
2567
|
var _usePress = usePress(_extends({}, triggerPressProps, {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2568
|
+
isDisabled: isDisabled
|
|
2569
|
+
})),
|
|
2570
|
+
triggerProps = _usePress.pressProps;
|
|
2898
2571
|
var makeMenu = function makeMenu() {
|
|
2899
2572
|
var realMenu = typeof menu === "function" ? menu() : menu;
|
|
2900
|
-
|
|
2901
2573
|
if (!realMenu) {
|
|
2902
2574
|
return null;
|
|
2903
2575
|
}
|
|
2904
|
-
|
|
2905
2576
|
if (getPlumeType(realMenu) !== "menu") {
|
|
2906
2577
|
if (PLUME_STRICT_MODE) {
|
|
2907
2578
|
throw new Error("Must use an instance of the Menu component.");
|
|
2908
2579
|
}
|
|
2909
|
-
|
|
2910
2580
|
return null;
|
|
2911
2581
|
}
|
|
2912
|
-
|
|
2913
2582
|
return cloneElement(realMenu, mergeProps(realMenu.props, menuProps));
|
|
2914
2583
|
};
|
|
2915
|
-
|
|
2916
2584
|
var triggerContext = useMemo(function () {
|
|
2917
2585
|
var _state$focusStrategy;
|
|
2918
|
-
|
|
2919
2586
|
return {
|
|
2920
2587
|
triggerRef: triggerRef,
|
|
2921
2588
|
state: state,
|
|
@@ -2935,11 +2602,11 @@ function useMenuTrigger(opts, state) {
|
|
|
2935
2602
|
|
|
2936
2603
|
function DropdownMenu(props) {
|
|
2937
2604
|
var isOpen = props.isOpen,
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2605
|
+
defaultOpen = props.defaultOpen,
|
|
2606
|
+
onOpenChange = props.onOpenChange,
|
|
2607
|
+
children = props.children,
|
|
2608
|
+
placement = props.placement,
|
|
2609
|
+
menu = props.menu;
|
|
2943
2610
|
var triggerRef = useRef(null);
|
|
2944
2611
|
var state = useMenuTriggerState({
|
|
2945
2612
|
isOpen: isOpen,
|
|
@@ -2947,16 +2614,14 @@ function DropdownMenu(props) {
|
|
|
2947
2614
|
onOpenChange: onOpenChange,
|
|
2948
2615
|
shouldFlip: true
|
|
2949
2616
|
});
|
|
2950
|
-
|
|
2951
2617
|
var _useMenuTrigger = useMenuTrigger({
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2618
|
+
triggerRef: triggerRef,
|
|
2619
|
+
placement: placement,
|
|
2620
|
+
menu: menu
|
|
2621
|
+
}, state),
|
|
2622
|
+
triggerProps = _useMenuTrigger.triggerProps,
|
|
2623
|
+
makeMenu = _useMenuTrigger.makeMenu,
|
|
2624
|
+
triggerContext = _useMenuTrigger.triggerContext;
|
|
2960
2625
|
return createElement(TriggeredOverlayContext.Provider, {
|
|
2961
2626
|
value: triggerContext
|
|
2962
2627
|
}, cloneElement(children, mergeProps(children.props, triggerProps, {
|
|
@@ -2966,20 +2631,18 @@ function DropdownMenu(props) {
|
|
|
2966
2631
|
|
|
2967
2632
|
function useMenuButton(plasmicClass, props, config, outerRef) {
|
|
2968
2633
|
var _extends2, _overrides;
|
|
2969
|
-
|
|
2970
2634
|
if (outerRef === void 0) {
|
|
2971
2635
|
outerRef = null;
|
|
2972
2636
|
}
|
|
2973
|
-
|
|
2974
2637
|
var placement = props.placement,
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2638
|
+
isOpen = props.isOpen,
|
|
2639
|
+
defaultOpen = props.defaultOpen,
|
|
2640
|
+
onOpenChange = props.onOpenChange,
|
|
2641
|
+
isDisabled = props.isDisabled,
|
|
2642
|
+
menu = props.menu,
|
|
2643
|
+
autoFocus = props.autoFocus,
|
|
2644
|
+
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
2645
|
+
menuWidth = props.menuWidth;
|
|
2983
2646
|
useEnsureSSRProvider();
|
|
2984
2647
|
var rootRef = useRef(null);
|
|
2985
2648
|
var triggerRef = useRef(null);
|
|
@@ -2989,22 +2652,19 @@ function useMenuButton(plasmicClass, props, config, outerRef) {
|
|
|
2989
2652
|
onOpenChange: onOpenChange,
|
|
2990
2653
|
shouldFlip: true
|
|
2991
2654
|
});
|
|
2992
|
-
|
|
2993
2655
|
var _useMenuTrigger = useMenuTrigger({
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
2656
|
+
isDisabled: isDisabled,
|
|
2657
|
+
triggerRef: triggerRef,
|
|
2658
|
+
placement: placement,
|
|
2659
|
+
menuMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2660
|
+
menuWidth: menuWidth,
|
|
2661
|
+
menu: menu
|
|
2662
|
+
}, state),
|
|
2663
|
+
triggerProps = _useMenuTrigger.triggerProps,
|
|
2664
|
+
makeMenu = _useMenuTrigger.makeMenu,
|
|
2665
|
+
triggerContext = _useMenuTrigger.triggerContext;
|
|
3005
2666
|
var _useFocusable = useFocusable(props, triggerRef),
|
|
3006
|
-
|
|
3007
|
-
|
|
2667
|
+
triggerFocusProps = _useFocusable.focusableProps;
|
|
3008
2668
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3009
2669
|
def: config.isOpenVariant,
|
|
3010
2670
|
active: state.isOpen
|
|
@@ -3012,9 +2672,7 @@ function useMenuButton(plasmicClass, props, config, outerRef) {
|
|
|
3012
2672
|
def: config.isDisabledVariant,
|
|
3013
2673
|
active: isDisabled
|
|
3014
2674
|
}));
|
|
3015
|
-
|
|
3016
2675
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.menuSlot] = state.isOpen ? makeMenu() : undefined, _extends2));
|
|
3017
|
-
|
|
3018
2676
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3019
2677
|
wrapChildren: function wrapChildren(children) {
|
|
3020
2678
|
return createElement(TriggeredOverlayContext.Provider, {
|
|
@@ -3117,21 +2775,18 @@ var COLLECTION_OPTS$1 = {
|
|
|
3117
2775
|
* with the secret derived `_node` prop. That means Option and OptionGroup
|
|
3118
2776
|
* render functions can assume that _node is passed in.
|
|
3119
2777
|
*/
|
|
3120
|
-
|
|
3121
2778
|
function useAriaSelectProps(props) {
|
|
3122
2779
|
var value = props.value,
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
2780
|
+
defaultValue = props.defaultValue,
|
|
2781
|
+
children = props.children,
|
|
2782
|
+
onChange = props.onChange,
|
|
2783
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
3128
2784
|
var _useDerivedItemsFromC = useDerivedItemsFromChildren(children, _extends({}, COLLECTION_OPTS$1, {
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
2785
|
+
invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select",
|
|
2786
|
+
requireItemValue: true
|
|
2787
|
+
})),
|
|
2788
|
+
items = _useDerivedItemsFromC.items,
|
|
2789
|
+
disabledKeys = _useDerivedItemsFromC.disabledKeys;
|
|
3135
2790
|
var collectionChildRenderer = useCallback(function (child) {
|
|
3136
2791
|
return renderAsCollectionChild(child, COLLECTION_OPTS$1);
|
|
3137
2792
|
}, []);
|
|
@@ -3156,42 +2811,33 @@ function useAriaSelectProps(props) {
|
|
|
3156
2811
|
})
|
|
3157
2812
|
};
|
|
3158
2813
|
}
|
|
3159
|
-
|
|
3160
2814
|
function useSelect(plasmicClass, props, config, ref) {
|
|
3161
2815
|
var _overrides, _extends2;
|
|
3162
|
-
|
|
3163
2816
|
if (ref === void 0) {
|
|
3164
2817
|
ref = null;
|
|
3165
2818
|
}
|
|
3166
|
-
|
|
3167
2819
|
useEnsureSSRProvider();
|
|
3168
|
-
|
|
3169
2820
|
var _useAriaSelectProps = useAriaSelectProps(props),
|
|
3170
|
-
|
|
3171
|
-
|
|
2821
|
+
ariaProps = _useAriaSelectProps.ariaProps;
|
|
3172
2822
|
var placement = props.placement;
|
|
3173
2823
|
var state = useSelectState(ariaProps);
|
|
3174
2824
|
var triggerRef = useRef(null);
|
|
3175
2825
|
var rootRef = useRef(null);
|
|
3176
2826
|
var isDisabled = props.isDisabled,
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
2827
|
+
name = props.name,
|
|
2828
|
+
menuWidth = props.menuWidth,
|
|
2829
|
+
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
2830
|
+
autoFocus = props.autoFocus,
|
|
2831
|
+
placeholder = props.placeholder,
|
|
2832
|
+
selectedContent = props.selectedContent;
|
|
3184
2833
|
var _useAriaSelect = useSelect$1(ariaProps, state, triggerRef),
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
2834
|
+
triggerPressProps = _useAriaSelect.triggerProps,
|
|
2835
|
+
menuProps = _useAriaSelect.menuProps;
|
|
3188
2836
|
var _usePress = usePress(_extends({}, triggerPressProps, {
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
2837
|
+
isDisabled: isDisabled
|
|
2838
|
+
})),
|
|
2839
|
+
triggerProps = _usePress.pressProps;
|
|
3193
2840
|
var triggerContent = state.selectedItem ? selectedContent != null ? selectedContent : getChildProp(state.selectedItem.value, "children") : null;
|
|
3194
|
-
|
|
3195
2841
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3196
2842
|
def: config.isOpenVariant,
|
|
3197
2843
|
active: state.isOpen
|
|
@@ -3202,7 +2848,6 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3202
2848
|
def: config.isDisabledVariant,
|
|
3203
2849
|
active: isDisabled
|
|
3204
2850
|
}));
|
|
3205
|
-
|
|
3206
2851
|
var triggerContext = useMemo(function () {
|
|
3207
2852
|
return {
|
|
3208
2853
|
triggerRef: triggerRef,
|
|
@@ -3247,13 +2892,11 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3247
2892
|
}, content);
|
|
3248
2893
|
}
|
|
3249
2894
|
}, _overrides);
|
|
3250
|
-
|
|
3251
2895
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.triggerContentSlot] = triggerContent, _extends2[config.placeholderSlot] = placeholder, _extends2[config.optionsSlot] = createElement(SelectContext.Provider, {
|
|
3252
2896
|
value: state
|
|
3253
2897
|
}, Array.from(state.collection).map(function (node) {
|
|
3254
2898
|
return renderCollectionNode(node);
|
|
3255
2899
|
})), _extends2));
|
|
3256
|
-
|
|
3257
2900
|
var plumeState = useMemo(function () {
|
|
3258
2901
|
return {
|
|
3259
2902
|
open: function open() {
|
|
@@ -3283,12 +2926,10 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3283
2926
|
},
|
|
3284
2927
|
focus: function focus() {
|
|
3285
2928
|
var _triggerRef$current;
|
|
3286
|
-
|
|
3287
2929
|
return (_triggerRef$current = triggerRef.current) == null ? void 0 : _triggerRef$current.focus();
|
|
3288
2930
|
},
|
|
3289
2931
|
blur: function blur() {
|
|
3290
2932
|
var _triggerRef$current2;
|
|
3291
|
-
|
|
3292
2933
|
return (_triggerRef$current2 = triggerRef.current) == null ? void 0 : _triggerRef$current2.blur();
|
|
3293
2934
|
},
|
|
3294
2935
|
open: function open() {
|
|
@@ -3317,20 +2958,17 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3317
2958
|
state: plumeState
|
|
3318
2959
|
};
|
|
3319
2960
|
}
|
|
3320
|
-
|
|
3321
2961
|
function ListBoxWrapper(props) {
|
|
3322
2962
|
var state = props.state,
|
|
3323
|
-
|
|
3324
|
-
|
|
2963
|
+
menuProps = props.menuProps,
|
|
2964
|
+
children = props.children;
|
|
3325
2965
|
var ref = useRef(null);
|
|
3326
|
-
|
|
3327
2966
|
var _useListBox = useListBox(_extends({}, menuProps, {
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
2967
|
+
isVirtualized: false,
|
|
2968
|
+
autoFocus: state.focusStrategy || true,
|
|
2969
|
+
disallowEmptySelection: true
|
|
2970
|
+
}), state, ref),
|
|
2971
|
+
listBoxProps = _useListBox.listBoxProps;
|
|
3334
2972
|
return cloneElement(children, mergeProps(children.props, listBoxProps, {
|
|
3335
2973
|
style: noOutline(),
|
|
3336
2974
|
ref: ref
|
|
@@ -3339,13 +2977,10 @@ function ListBoxWrapper(props) {
|
|
|
3339
2977
|
|
|
3340
2978
|
function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
3341
2979
|
var _extends2, _overrides;
|
|
3342
|
-
|
|
3343
2980
|
if (outerRef === void 0) {
|
|
3344
2981
|
outerRef = null;
|
|
3345
2982
|
}
|
|
3346
|
-
|
|
3347
2983
|
var state = useContext(SelectContext);
|
|
3348
|
-
|
|
3349
2984
|
if (!state) {
|
|
3350
2985
|
// If no context, then we are being incorrectly used. Complain or just don't
|
|
3351
2986
|
// bother installing any hooks. It's okay to violate rules of hooks here
|
|
@@ -3353,31 +2988,27 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
3353
2988
|
if (PLUME_STRICT_MODE) {
|
|
3354
2989
|
throw new Error("You can only use a Select.Option within a Select component.");
|
|
3355
2990
|
}
|
|
3356
|
-
|
|
3357
2991
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3358
2992
|
}
|
|
3359
|
-
|
|
3360
2993
|
var children = props.children;
|
|
3361
2994
|
var rootRef = useRef(null);
|
|
3362
|
-
var onRef = mergeRefs(rootRef, outerRef);
|
|
3363
|
-
|
|
2995
|
+
var onRef = mergeRefs(rootRef, outerRef);
|
|
2996
|
+
// We pass in the Node secretly as an undocumented prop from <Select />
|
|
3364
2997
|
var node = props._node;
|
|
3365
2998
|
var isSelected = state.selectionManager.isSelected(node.key);
|
|
3366
2999
|
var isDisabled = state.disabledKeys.has(node.key);
|
|
3367
3000
|
var isHighlighted = state.selectionManager.isFocused && state.selectionManager.focusedKey === node.key;
|
|
3368
|
-
|
|
3369
3001
|
var _useAriaOption = useOption({
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3002
|
+
isSelected: isSelected,
|
|
3003
|
+
isDisabled: isDisabled,
|
|
3004
|
+
"aria-label": node && node["aria-label"],
|
|
3005
|
+
key: node.key,
|
|
3006
|
+
shouldSelectOnPressUp: true,
|
|
3007
|
+
shouldFocusOnHover: true,
|
|
3008
|
+
isVirtualized: false
|
|
3009
|
+
}, state, rootRef),
|
|
3010
|
+
optionProps = _useAriaOption.optionProps,
|
|
3011
|
+
labelProps = _useAriaOption.labelProps;
|
|
3381
3012
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3382
3013
|
def: config.isSelectedVariant,
|
|
3383
3014
|
active: isSelected
|
|
@@ -3388,9 +3019,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
3388
3019
|
def: config.isHighlightedVariant,
|
|
3389
3020
|
active: isHighlighted
|
|
3390
3021
|
}));
|
|
3391
|
-
|
|
3392
3022
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
3393
|
-
|
|
3394
3023
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3395
3024
|
props: mergeProps(optionProps, getStyleProps(props), {
|
|
3396
3025
|
ref: onRef,
|
|
@@ -3410,32 +3039,26 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
3410
3039
|
|
|
3411
3040
|
function useSelectOptionGroup(plasmicClass, props, config) {
|
|
3412
3041
|
var _extends2, _overrides;
|
|
3413
|
-
|
|
3414
|
-
|
|
3042
|
+
var state = useContext(SelectContext);
|
|
3043
|
+
// `node` should exist if the OptionGroup was instantiated properly
|
|
3415
3044
|
// within a Select
|
|
3416
|
-
|
|
3417
3045
|
var node = props._node;
|
|
3418
|
-
|
|
3419
3046
|
if (!state || !node) {
|
|
3420
3047
|
if (PLUME_STRICT_MODE) {
|
|
3421
3048
|
throw new Error("You can only use a Select.OptionGroup within a Select component.");
|
|
3422
3049
|
}
|
|
3423
|
-
|
|
3424
3050
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3425
3051
|
}
|
|
3426
|
-
|
|
3427
3052
|
var _useListBoxSection = useListBoxSection({
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3053
|
+
heading: props.title,
|
|
3054
|
+
"aria-label": props["aria-label"]
|
|
3055
|
+
}),
|
|
3056
|
+
headingProps = _useListBoxSection.headingProps,
|
|
3057
|
+
groupProps = _useListBoxSection.groupProps;
|
|
3434
3058
|
var _useSeparator = useSeparator({
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3059
|
+
elementType: "li"
|
|
3060
|
+
}),
|
|
3061
|
+
separatorProps = _useSeparator.separatorProps;
|
|
3439
3062
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3440
3063
|
def: config.noTitleVariant,
|
|
3441
3064
|
active: !props.title
|
|
@@ -3443,11 +3066,9 @@ function useSelectOptionGroup(plasmicClass, props, config) {
|
|
|
3443
3066
|
def: config.isFirstVariant,
|
|
3444
3067
|
active: state.collection.getFirstKey() === node.key
|
|
3445
3068
|
}));
|
|
3446
|
-
|
|
3447
3069
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.titleSlot] = props.title, _extends2[config.optionsSlot] = Array.from(node.childNodes).map(function (childNode) {
|
|
3448
3070
|
return renderCollectionNode(childNode);
|
|
3449
3071
|
}), _extends2));
|
|
3450
|
-
|
|
3451
3072
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3452
3073
|
props: getStyleProps(props)
|
|
3453
3074
|
}, _overrides[config.separator] = {
|
|
@@ -3477,30 +3098,24 @@ function asAriaSwitchProps(props) {
|
|
|
3477
3098
|
isSelected: props.isChecked,
|
|
3478
3099
|
defaultSelected: props.defaultChecked
|
|
3479
3100
|
});
|
|
3480
|
-
|
|
3481
3101
|
delete ariaProps["isChecked"];
|
|
3482
3102
|
delete ariaProps["defaultChecked"];
|
|
3483
3103
|
return ariaProps;
|
|
3484
3104
|
}
|
|
3485
|
-
|
|
3486
3105
|
function useSwitch(plasmicClass, props, config, ref) {
|
|
3487
3106
|
var _overrides, _ref;
|
|
3488
|
-
|
|
3489
3107
|
if (ref === void 0) {
|
|
3490
3108
|
ref = null;
|
|
3491
3109
|
}
|
|
3492
|
-
|
|
3493
3110
|
var children = props.children,
|
|
3494
|
-
|
|
3111
|
+
isDisabled = props.isDisabled;
|
|
3495
3112
|
useEnsureSSRProvider();
|
|
3496
3113
|
var inputRef = useRef(null);
|
|
3497
3114
|
var rootRef = useRef(null);
|
|
3498
3115
|
var ariaProps = asAriaSwitchProps(props);
|
|
3499
3116
|
var state = useToggleState(ariaProps);
|
|
3500
|
-
|
|
3501
3117
|
var _useAriaSwitch = useSwitch$1(ariaProps, state, inputRef),
|
|
3502
|
-
|
|
3503
|
-
|
|
3118
|
+
inputProps = _useAriaSwitch.inputProps;
|
|
3504
3119
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3505
3120
|
def: config.isDisabledVariant,
|
|
3506
3121
|
active: isDisabled
|
|
@@ -3511,7 +3126,6 @@ function useSwitch(plasmicClass, props, config, ref) {
|
|
|
3511
3126
|
def: config.noLabelVariant,
|
|
3512
3127
|
active: !children
|
|
3513
3128
|
}));
|
|
3514
|
-
|
|
3515
3129
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3516
3130
|
as: "label",
|
|
3517
3131
|
props: mergeProps(getStyleProps(props), {
|
|
@@ -3523,9 +3137,7 @@ function useSwitch(plasmicClass, props, config, ref) {
|
|
|
3523
3137
|
}))), children);
|
|
3524
3138
|
}
|
|
3525
3139
|
}, _overrides);
|
|
3526
|
-
|
|
3527
3140
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.labelSlot ? (_ref = {}, _ref[config.labelSlot] = children, _ref) : {});
|
|
3528
|
-
|
|
3529
3141
|
var plumeState = useMemo(function () {
|
|
3530
3142
|
return {
|
|
3531
3143
|
setChecked: function setChecked(checked) {
|
|
@@ -3540,12 +3152,10 @@ function useSwitch(plasmicClass, props, config, ref) {
|
|
|
3540
3152
|
},
|
|
3541
3153
|
focus: function focus() {
|
|
3542
3154
|
var _inputRef$current;
|
|
3543
|
-
|
|
3544
3155
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
3545
3156
|
},
|
|
3546
3157
|
blur: function blur() {
|
|
3547
3158
|
var _inputRef$current2;
|
|
3548
|
-
|
|
3549
3159
|
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
3550
3160
|
},
|
|
3551
3161
|
setChecked: function setChecked(checked) {
|
|
@@ -3566,34 +3176,29 @@ function useSwitch(plasmicClass, props, config, ref) {
|
|
|
3566
3176
|
var _excluded$7 = ["isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "className", "style", "inputClassName", "inputStyle"];
|
|
3567
3177
|
function useTextInput(plasmicClass, props, config, ref) {
|
|
3568
3178
|
var _ref, _ref2, _overrides;
|
|
3569
|
-
|
|
3570
3179
|
if (ref === void 0) {
|
|
3571
3180
|
ref = null;
|
|
3572
3181
|
}
|
|
3573
|
-
|
|
3574
3182
|
var isDisabled = props.isDisabled,
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3183
|
+
startIcon = props.startIcon,
|
|
3184
|
+
endIcon = props.endIcon,
|
|
3185
|
+
showStartIcon = props.showStartIcon,
|
|
3186
|
+
showEndIcon = props.showEndIcon,
|
|
3187
|
+
className = props.className,
|
|
3188
|
+
style = props.style,
|
|
3189
|
+
inputClassName = props.inputClassName,
|
|
3190
|
+
inputStyle = props.inputStyle,
|
|
3191
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
3585
3192
|
var rootRef = useRef(null);
|
|
3586
3193
|
var inputRef = useRef(null);
|
|
3587
3194
|
useImperativeHandle(ref, function () {
|
|
3588
3195
|
return {
|
|
3589
3196
|
focus: function focus() {
|
|
3590
3197
|
var _inputRef$current;
|
|
3591
|
-
|
|
3592
3198
|
(_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
3593
3199
|
},
|
|
3594
3200
|
blur: function blur() {
|
|
3595
3201
|
var _inputRef$current2;
|
|
3596
|
-
|
|
3597
3202
|
(_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
3598
3203
|
},
|
|
3599
3204
|
getRoot: function getRoot() {
|
|
@@ -3604,7 +3209,6 @@ function useTextInput(plasmicClass, props, config, ref) {
|
|
|
3604
3209
|
}
|
|
3605
3210
|
};
|
|
3606
3211
|
}, [rootRef, inputRef]);
|
|
3607
|
-
|
|
3608
3212
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3609
3213
|
def: config.showStartIconVariant,
|
|
3610
3214
|
active: showStartIcon
|
|
@@ -3615,9 +3219,7 @@ function useTextInput(plasmicClass, props, config, ref) {
|
|
|
3615
3219
|
def: config.isDisabledVariant,
|
|
3616
3220
|
active: isDisabled
|
|
3617
3221
|
}));
|
|
3618
|
-
|
|
3619
3222
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.startIconSlot && (_ref = {}, _ref[config.startIconSlot] = startIcon, _ref), config.endIconSlot && (_ref2 = {}, _ref2[config.endIconSlot] = endIcon, _ref2));
|
|
3620
|
-
|
|
3621
3223
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3622
3224
|
props: {
|
|
3623
3225
|
ref: rootRef,
|
|
@@ -3645,19 +3247,15 @@ function useTextInput(plasmicClass, props, config, ref) {
|
|
|
3645
3247
|
|
|
3646
3248
|
function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissable) {
|
|
3647
3249
|
var _extends2, _overrides;
|
|
3648
|
-
|
|
3649
3250
|
if (outerRef === void 0) {
|
|
3650
3251
|
outerRef = null;
|
|
3651
3252
|
}
|
|
3652
|
-
|
|
3653
3253
|
if (isDismissable === void 0) {
|
|
3654
3254
|
isDismissable = true;
|
|
3655
3255
|
}
|
|
3656
|
-
|
|
3657
3256
|
var overlayRef = useRef(null);
|
|
3658
3257
|
var onOverlayRef = mergeRefs(overlayRef, outerRef);
|
|
3659
3258
|
var context = useContext(TriggeredOverlayContext);
|
|
3660
|
-
|
|
3661
3259
|
if (!context) {
|
|
3662
3260
|
// If no context, then we are not being correctly used. Either complain, or
|
|
3663
3261
|
// exit early. It's okay to exit early and break the rules of React hooks
|
|
@@ -3665,50 +3263,44 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3665
3263
|
if (PLUME_STRICT_MODE) {
|
|
3666
3264
|
throw new Error("You can only use a triggered overlay with a TriggeredOverlayContext");
|
|
3667
3265
|
}
|
|
3668
|
-
|
|
3669
3266
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3670
3267
|
}
|
|
3671
|
-
|
|
3672
3268
|
var children = props.children;
|
|
3673
3269
|
var triggerRef = context.triggerRef,
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3270
|
+
placement = context.placement,
|
|
3271
|
+
overlayMatchTriggerWidth = context.overlayMatchTriggerWidth,
|
|
3272
|
+
overlayMinTriggerWidth = context.overlayMinTriggerWidth,
|
|
3273
|
+
overlayWidth = context.overlayWidth,
|
|
3274
|
+
state = context.state;
|
|
3275
|
+
// Measure the width of the trigger to inform the width of the menu (below).
|
|
3680
3276
|
var _React$useState = useState(false),
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3277
|
+
isRendered = _React$useState[0],
|
|
3278
|
+
setRendered = _React$useState[1];
|
|
3684
3279
|
var triggerWidth = triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth) ? triggerRef.current.offsetWidth : undefined;
|
|
3685
3280
|
useIsomorphicLayoutEffect(function () {
|
|
3686
3281
|
if (!isRendered && triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)) {
|
|
3687
3282
|
setRendered(true);
|
|
3688
3283
|
}
|
|
3689
3284
|
}, [triggerRef, isRendered, overlayMatchTriggerWidth, overlayMinTriggerWidth]);
|
|
3690
|
-
|
|
3691
3285
|
var _useOverlay = useOverlay({
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3286
|
+
isOpen: state.isOpen,
|
|
3287
|
+
onClose: state.close,
|
|
3288
|
+
isDismissable: isDismissable,
|
|
3289
|
+
shouldCloseOnBlur: true
|
|
3290
|
+
}, overlayRef),
|
|
3291
|
+
overlayAriaProps = _useOverlay.overlayProps;
|
|
3699
3292
|
var _useOverlayPosition = useOverlayPosition({
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3293
|
+
targetRef: triggerRef,
|
|
3294
|
+
overlayRef: overlayRef,
|
|
3295
|
+
placement: placement != null ? placement : "bottom left",
|
|
3296
|
+
shouldFlip: true,
|
|
3297
|
+
isOpen: state.isOpen,
|
|
3298
|
+
onClose: state.close,
|
|
3299
|
+
containerPadding: 0
|
|
3300
|
+
}),
|
|
3301
|
+
overlayPositionProps = _useOverlayPosition.overlayProps,
|
|
3302
|
+
updatePosition = _useOverlayPosition.updatePosition,
|
|
3303
|
+
placementAxis = _useOverlayPosition.placement;
|
|
3712
3304
|
useIsomorphicLayoutEffect(function () {
|
|
3713
3305
|
if (state.isOpen) {
|
|
3714
3306
|
requestAnimationFrame(function () {
|
|
@@ -3727,7 +3319,6 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3727
3319
|
minWidth: overlayMinTriggerWidth ? triggerWidth : "auto"
|
|
3728
3320
|
}
|
|
3729
3321
|
}, overlayAriaProps, overlayPositionProps);
|
|
3730
|
-
|
|
3731
3322
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3732
3323
|
def: config.isPlacedTopVariant,
|
|
3733
3324
|
active: placementAxis === "top"
|
|
@@ -3741,13 +3332,11 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3741
3332
|
def: config.isPlacedRightVariant,
|
|
3742
3333
|
active: placementAxis === "right"
|
|
3743
3334
|
}));
|
|
3744
|
-
|
|
3745
3335
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.contentSlot] = createElement(FocusScope, {
|
|
3746
3336
|
restoreFocus: true
|
|
3747
3337
|
}, createElement(DismissButton, {
|
|
3748
3338
|
onDismiss: state.close
|
|
3749
3339
|
}), children), _extends2));
|
|
3750
|
-
|
|
3751
3340
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3752
3341
|
props: mergeProps(overlayProps, getStyleProps(props), {
|
|
3753
3342
|
ref: onOverlayRef
|
|
@@ -3771,5 +3360,5 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3771
3360
|
};
|
|
3772
3361
|
}
|
|
3773
3362
|
|
|
3774
|
-
export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, isNum, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, shallowEqual, useButton, useCanvasDollarState, useCheckbox, useDollarState, useIsSSR, useIsomorphicLayoutEffect$1 as useIsomorphicLayoutEffect, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
3363
|
+
export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicPageGuard, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, isNum, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, shallowEqual, useButton, useCanvasDollarState, useCheckbox, useDollarState, useIsSSR, useIsomorphicLayoutEffect$1 as useIsomorphicLayoutEffect, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
3775
3364
|
//# sourceMappingURL=react-web.esm.js.map
|