@plasmicapp/react-web 0.2.90 → 0.2.94
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 +21 -4
- package/dist/index-common.d.ts +1 -0
- package/dist/plume/collection-utils.d.ts +1 -1
- package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
- package/dist/plume/text-input/index.d.ts +1 -1
- package/dist/react-utils.d.ts +2 -2
- package/dist/react-web.cjs.development.js +105 -6
- 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 +104 -7
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/PlasmicLink.d.ts +2 -2
- package/dist/render/ssr.d.ts +2 -0
- package/dist/render/translation.d.ts +18 -0
- package/lib/plasmic.css +1 -1
- package/package.json +3 -3
- package/skinny/dist/{collection-utils-aadc3a43.js → collection-utils-47e89cbe.js} +4 -4
- package/skinny/dist/{collection-utils-976df07d.js.map → collection-utils-47e89cbe.js.map} +1 -1
- package/skinny/dist/collection-utils-4dae6efa.js +292 -0
- package/skinny/dist/{collection-utils-21ad9cae.js.map → collection-utils-4dae6efa.js.map} +1 -1
- package/skinny/dist/collection-utils-57ec40f9.js +292 -0
- package/skinny/dist/{collection-utils-aadc3a43.js.map → collection-utils-57ec40f9.js.map} +1 -1
- package/skinny/dist/collection-utils-b0b8f30e.js +287 -234
- package/skinny/dist/index-common.d.ts +1 -0
- package/skinny/dist/index.js +6 -6
- 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/plume/text-input/index.d.ts +1 -1
- package/skinny/dist/plume/text-input/index.js.map +1 -1
- package/skinny/dist/{props-utils-6cf101b2.js → plume-utils-5c413fd1.js} +3 -7
- package/skinny/dist/plume-utils-5c413fd1.js.map +1 -0
- package/skinny/dist/props-utils-4633caf6.js +8 -0
- package/skinny/dist/props-utils-4633caf6.js.map +1 -0
- package/skinny/dist/props-utils-5c0ad25a.js +59 -0
- package/skinny/dist/{props-utils-6cf101b2.js.map → props-utils-5c0ad25a.js.map} +1 -1
- package/skinny/dist/props-utils-c632595f.js +53 -33
- package/skinny/dist/props-utils-fd5f444e.js +59 -0
- package/skinny/dist/{props-utils-1f98cfd3.js.map → props-utils-fd5f444e.js.map} +1 -1
- package/skinny/dist/react-utils-118d8539.js +186 -168
- package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
- package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
- package/skinny/dist/{react-utils-14af9d28.js → react-utils-2d70bbbe.js} +2 -2
- package/skinny/dist/react-utils-2d70bbbe.js.map +1 -0
- package/skinny/dist/react-utils-675565b4.js +334 -0
- package/skinny/dist/react-utils-675565b4.js.map +1 -0
- package/skinny/dist/react-utils.d.ts +1 -1
- package/skinny/dist/render/PlasmicImg.d.ts +62 -55
- package/skinny/dist/render/PlasmicLink.d.ts +2 -2
- package/skinny/dist/render/ssr.d.ts +2 -0
- package/skinny/dist/render/translation.d.ts +18 -0
- package/skinny/dist/ssr-902d1292.js +105 -0
- package/skinny/dist/ssr-902d1292.js.map +1 -0
- package/skinny/dist/ssr-a8081074.js +108 -0
- package/skinny/dist/ssr-a8081074.js.map +1 -0
- package/skinny/dist/tslib.es6-00014098.js +143 -123
- package/skinny/dist/{tslib.es6-10d3f595.js → tslib.es6-73236e8e.js} +12 -3
- package/skinny/dist/tslib.es6-73236e8e.js.map +1 -0
- package/skinny/dist/collection-utils-21ad9cae.js +0 -238
- package/skinny/dist/collection-utils-87ffc0ed.js +0 -238
- package/skinny/dist/collection-utils-87ffc0ed.js.map +0 -1
- package/skinny/dist/collection-utils-976df07d.js +0 -238
- package/skinny/dist/collection-utils-b8a2fd59.js +0 -238
- package/skinny/dist/collection-utils-b8a2fd59.js.map +0 -1
- package/skinny/dist/props-utils-1f98cfd3.js +0 -40
- package/skinny/dist/props-utils-40224c71.js +0 -40
- package/skinny/dist/props-utils-40224c71.js.map +0 -1
- package/skinny/dist/props-utils-69f9ba8b.js +0 -40
- package/skinny/dist/props-utils-69f9ba8b.js.map +0 -1
- package/skinny/dist/props-utils-85691c9c.js +0 -40
- package/skinny/dist/props-utils-85691c9c.js.map +0 -1
- package/skinny/dist/react-utils-06bae09a.js +0 -254
- package/skinny/dist/react-utils-06bae09a.js.map +0 -1
- package/skinny/dist/react-utils-14af9d28.js.map +0 -1
- package/skinny/dist/react-utils-834a65c3.js +0 -254
- package/skinny/dist/react-utils-834a65c3.js.map +0 -1
- package/skinny/dist/react-utils-ae69f4e0.js +0 -254
- package/skinny/dist/react-utils-ae69f4e0.js.map +0 -1
- package/skinny/dist/react-utils-cca81efc.js +0 -245
- package/skinny/dist/react-utils-cca81efc.js.map +0 -1
- package/skinny/dist/stories/Button.d.ts +0 -29
- package/skinny/dist/stories/Header.d.ts +0 -10
- package/skinny/dist/stories/Page.d.ts +0 -10
- package/skinny/dist/tslib.es6-10d3f595.js.map +0 -1
|
@@ -1,238 +1,291 @@
|
|
|
1
|
-
import { a as __assign, d as isString } from
|
|
2
|
-
import React__default from
|
|
3
|
-
import { Item, Section } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { a as __assign, d as isString } from "./tslib.es6-00014098.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { Item, Section } from "react-stately";
|
|
4
|
+
import {
|
|
5
|
+
t as toChildArray,
|
|
6
|
+
g as getElementTypeName,
|
|
7
|
+
} from "./react-utils-118d8539.js";
|
|
8
|
+
import {
|
|
9
|
+
a as getPlumeType,
|
|
10
|
+
P as PLUME_STRICT_MODE,
|
|
11
|
+
} from "./props-utils-c632595f.js";
|
|
6
12
|
|
|
7
|
-
/**
|
|
8
|
-
* In general, we try not to expose react-aria's Collections API to Plume users.
|
|
9
|
-
* The Collections API is how react-aria users pass data about collections of
|
|
10
|
-
* things using the built-in Item and Section components, which are abstract,
|
|
11
|
-
* metadata-only components that don't render anything but only serve to specify
|
|
12
|
-
* data. For example, here's how you would use react-spectrum's Picker:
|
|
13
|
-
*
|
|
14
|
-
* <Picker>
|
|
15
|
-
* <Section title="Asia">
|
|
16
|
-
* <Item key="taiwan">Taiwan</Item>
|
|
17
|
-
* <Item key="japan">Japan</Item>
|
|
18
|
-
* <Item key="china">China</Item>
|
|
19
|
-
* </Section>
|
|
20
|
-
* <Section title="Europe">
|
|
21
|
-
* <Item key="germany">Germany</Item>
|
|
22
|
-
* <Item key="france">France</Item>
|
|
23
|
-
* </Section>
|
|
24
|
-
* </Picker>
|
|
25
|
-
*
|
|
26
|
-
* You would re-use this same Item/Section components to pass similar things to
|
|
27
|
-
* Menu, Tabs, etc.
|
|
28
|
-
*
|
|
29
|
-
* For Plasmic, this API is too abstract. The user has explicitly designed components
|
|
30
|
-
* like Select.Option and Select.OptionGroup, and it is weird that they don't actually
|
|
31
|
-
* use these components. It is more natural to do:
|
|
32
|
-
*
|
|
33
|
-
* <Select>
|
|
34
|
-
* <Select.OptionGroup title="Asia">
|
|
35
|
-
* <Select.Option key="taiwan">Taiwan</Select>
|
|
36
|
-
* </Select.OptionGroup>
|
|
37
|
-
* </Select>
|
|
38
|
-
*
|
|
39
|
-
* For Plume, we let users directly use the components they designed, both to collect
|
|
40
|
-
* information and to perform actual rendering. For example, for Plume,
|
|
41
|
-
* you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.
|
|
42
|
-
* This means that the Select.Option props will collect the same information Item
|
|
43
|
-
* does.
|
|
44
|
-
*
|
|
45
|
-
* A component like Select.Option then serves two purposes:
|
|
46
|
-
*
|
|
47
|
-
* 1. Allow users to specify the collection of data, like in the above example
|
|
48
|
-
* Here, we're mainly interested in the props in those ReactElements so
|
|
49
|
-
* we can pass the Item/Section data onto react-aria's APIs. We are not
|
|
50
|
-
* actually rendering these elements.
|
|
51
|
-
* 2. Once react-aria's Collections API has gone through them and built
|
|
52
|
-
* Collection "nodes", we then create cloned versions of these elements
|
|
53
|
-
* with the corresponding node passed in as a secret prop. These ReactElements
|
|
54
|
-
* are then actually used to _render_ the corresponding Option / OptionGroup.
|
|
55
|
-
*
|
|
56
|
-
* This file contains helper functions to help with implementing the above.
|
|
57
|
-
*
|
|
58
|
-
* Note also that most of the collections-based react-aria components expose
|
|
59
|
-
* a parallel API that accepts a list of "items" and a render prop, instead
|
|
60
|
-
* of list of Item/Section elements. This is for efficiency, but we are opting
|
|
61
|
-
* to only support the composite-component pattern for now for simplicity.
|
|
62
|
-
*/
|
|
63
|
-
/**
|
|
64
|
-
* Given children of a component like Select or Menu, derive the items
|
|
65
|
-
* that we will pass into the Collections API. These will be
|
|
66
|
-
* ReactElement<ItemLikeProps|SectionLikeProps>[].
|
|
67
|
-
*
|
|
68
|
-
* Will also assign keys to items by their index in the collection,
|
|
69
|
-
* and collect the keys of disabled items.
|
|
70
|
-
*/
|
|
71
|
-
function deriveItemsFromChildren(children, opts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
//
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
13
|
+
/**
|
|
14
|
+
* In general, we try not to expose react-aria's Collections API to Plume users.
|
|
15
|
+
* The Collections API is how react-aria users pass data about collections of
|
|
16
|
+
* things using the built-in Item and Section components, which are abstract,
|
|
17
|
+
* metadata-only components that don't render anything but only serve to specify
|
|
18
|
+
* data. For example, here's how you would use react-spectrum's Picker:
|
|
19
|
+
*
|
|
20
|
+
* <Picker>
|
|
21
|
+
* <Section title="Asia">
|
|
22
|
+
* <Item key="taiwan">Taiwan</Item>
|
|
23
|
+
* <Item key="japan">Japan</Item>
|
|
24
|
+
* <Item key="china">China</Item>
|
|
25
|
+
* </Section>
|
|
26
|
+
* <Section title="Europe">
|
|
27
|
+
* <Item key="germany">Germany</Item>
|
|
28
|
+
* <Item key="france">France</Item>
|
|
29
|
+
* </Section>
|
|
30
|
+
* </Picker>
|
|
31
|
+
*
|
|
32
|
+
* You would re-use this same Item/Section components to pass similar things to
|
|
33
|
+
* Menu, Tabs, etc.
|
|
34
|
+
*
|
|
35
|
+
* For Plasmic, this API is too abstract. The user has explicitly designed components
|
|
36
|
+
* like Select.Option and Select.OptionGroup, and it is weird that they don't actually
|
|
37
|
+
* use these components. It is more natural to do:
|
|
38
|
+
*
|
|
39
|
+
* <Select>
|
|
40
|
+
* <Select.OptionGroup title="Asia">
|
|
41
|
+
* <Select.Option key="taiwan">Taiwan</Select>
|
|
42
|
+
* </Select.OptionGroup>
|
|
43
|
+
* </Select>
|
|
44
|
+
*
|
|
45
|
+
* For Plume, we let users directly use the components they designed, both to collect
|
|
46
|
+
* information and to perform actual rendering. For example, for Plume,
|
|
47
|
+
* you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.
|
|
48
|
+
* This means that the Select.Option props will collect the same information Item
|
|
49
|
+
* does.
|
|
50
|
+
*
|
|
51
|
+
* A component like Select.Option then serves two purposes:
|
|
52
|
+
*
|
|
53
|
+
* 1. Allow users to specify the collection of data, like in the above example
|
|
54
|
+
* Here, we're mainly interested in the props in those ReactElements so
|
|
55
|
+
* we can pass the Item/Section data onto react-aria's APIs. We are not
|
|
56
|
+
* actually rendering these elements.
|
|
57
|
+
* 2. Once react-aria's Collections API has gone through them and built
|
|
58
|
+
* Collection "nodes", we then create cloned versions of these elements
|
|
59
|
+
* with the corresponding node passed in as a secret prop. These ReactElements
|
|
60
|
+
* are then actually used to _render_ the corresponding Option / OptionGroup.
|
|
61
|
+
*
|
|
62
|
+
* This file contains helper functions to help with implementing the above.
|
|
63
|
+
*
|
|
64
|
+
* Note also that most of the collections-based react-aria components expose
|
|
65
|
+
* a parallel API that accepts a list of "items" and a render prop, instead
|
|
66
|
+
* of list of Item/Section elements. This is for efficiency, but we are opting
|
|
67
|
+
* to only support the composite-component pattern for now for simplicity.
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Given children of a component like Select or Menu, derive the items
|
|
71
|
+
* that we will pass into the Collections API. These will be
|
|
72
|
+
* ReactElement<ItemLikeProps|SectionLikeProps>[].
|
|
73
|
+
*
|
|
74
|
+
* Will also assign keys to items by their index in the collection,
|
|
75
|
+
* and collect the keys of disabled items.
|
|
76
|
+
*/
|
|
77
|
+
function deriveItemsFromChildren(children, opts) {
|
|
78
|
+
if (!children) {
|
|
79
|
+
return {
|
|
80
|
+
items: [],
|
|
81
|
+
disabledKeys: [],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
85
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
86
|
+
invalidChildError = opts.invalidChildError;
|
|
87
|
+
// For Plume items without an explicit key, we assign a key as the index
|
|
88
|
+
// of the collection.
|
|
89
|
+
var itemCount = 0;
|
|
90
|
+
var sectionCount = 0;
|
|
91
|
+
var ensureValue = function (element) {
|
|
92
|
+
if (!propInChild(element, "value")) {
|
|
93
|
+
if (opts.requireItemValue && PLUME_STRICT_MODE) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
'Must specify a "value" prop for ' + getElementTypeName(element)
|
|
96
|
+
);
|
|
97
|
+
} else {
|
|
98
|
+
return cloneChild(element, { value: "" + itemCount++ });
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
// Still increment count even if key is present, so that the
|
|
102
|
+
// auto-assigned key really reflects the index
|
|
103
|
+
itemCount++;
|
|
104
|
+
return element;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var disabledKeys = [];
|
|
108
|
+
var flattenedChildren = function (children) {
|
|
109
|
+
return toChildArray(children).flatMap(function (child) {
|
|
110
|
+
var _a;
|
|
111
|
+
if (React__default.isValidElement(child)) {
|
|
112
|
+
if (child.type === React__default.Fragment) {
|
|
113
|
+
return flattenedChildren(child.props.children);
|
|
114
|
+
}
|
|
115
|
+
var type = getPlumeType(child);
|
|
116
|
+
if (type === itemPlumeType) {
|
|
117
|
+
child = ensureValue(child);
|
|
118
|
+
var childKey = getItemLikeKey(child);
|
|
119
|
+
if (getChildProp(child, "isDisabled") && !!childKey) {
|
|
120
|
+
disabledKeys.push(childKey);
|
|
121
|
+
}
|
|
122
|
+
return [child];
|
|
123
|
+
}
|
|
124
|
+
if (type === sectionPlumeType) {
|
|
125
|
+
return [
|
|
126
|
+
cloneChild(child, {
|
|
127
|
+
// key of section doesn't actually matter, just needs
|
|
128
|
+
// to be unique
|
|
129
|
+
key:
|
|
130
|
+
(_a = child.key) !== null && _a !== void 0
|
|
131
|
+
? _a
|
|
132
|
+
: "section-" + sectionCount++,
|
|
133
|
+
children: flattenedChildren(getChildProp(child, "children")),
|
|
134
|
+
}),
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
{
|
|
139
|
+
throw new Error(
|
|
140
|
+
invalidChildError !== null && invalidChildError !== void 0
|
|
141
|
+
? invalidChildError
|
|
142
|
+
: "Unexpected child"
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
return { items: flattenedChildren(children), disabledKeys: disabledKeys };
|
|
148
|
+
}
|
|
149
|
+
function useDerivedItemsFromChildren(children, opts) {
|
|
150
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
151
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
152
|
+
invalidChildError = opts.invalidChildError,
|
|
153
|
+
requireItemValue = opts.requireItemValue;
|
|
154
|
+
return React__default.useMemo(
|
|
155
|
+
function () {
|
|
156
|
+
return deriveItemsFromChildren(children, {
|
|
157
|
+
itemPlumeType: itemPlumeType,
|
|
158
|
+
sectionPlumeType: sectionPlumeType,
|
|
159
|
+
invalidChildError: invalidChildError,
|
|
160
|
+
requireItemValue: requireItemValue,
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
[
|
|
164
|
+
children,
|
|
165
|
+
itemPlumeType,
|
|
166
|
+
sectionPlumeType,
|
|
167
|
+
invalidChildError,
|
|
168
|
+
requireItemValue,
|
|
169
|
+
]
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Given a Collection node, create the React element that we should use
|
|
174
|
+
* to render it.
|
|
175
|
+
*/
|
|
176
|
+
function renderCollectionNode(node) {
|
|
177
|
+
// node.rendered should already have our item-like or section-like Plume
|
|
178
|
+
// component elements, so we just need to clone them with a secret
|
|
179
|
+
// _node prop that we use to render.
|
|
180
|
+
return cloneChild(node.rendered, {
|
|
181
|
+
_node: node,
|
|
182
|
+
key: node.key,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Renders a item-like or section-like Plume component element into an
|
|
187
|
+
* Item or a Section element.
|
|
188
|
+
*/
|
|
189
|
+
function renderAsCollectionChild(child, opts) {
|
|
190
|
+
var _a;
|
|
191
|
+
var plumeType = getPlumeType(child);
|
|
192
|
+
if (plumeType === opts.itemPlumeType) {
|
|
193
|
+
var option = child;
|
|
194
|
+
// We look at the children passed to the item-like element, and derive key
|
|
195
|
+
// or textValue from it if it is a string
|
|
196
|
+
var content = getChildProp(option, "children");
|
|
197
|
+
// The children render prop needs to return an <Item/>
|
|
198
|
+
return React__default.createElement(
|
|
199
|
+
Item,
|
|
200
|
+
// We use ItemLike.value if the user explicitly specified a value,
|
|
201
|
+
// and we fallback to key. If the user specified neither, then
|
|
202
|
+
// the Collections API will generate a unique key for this item.
|
|
203
|
+
{
|
|
204
|
+
// We use ItemLike.value if the user explicitly specified a value,
|
|
205
|
+
// and we fallback to key. If the user specified neither, then
|
|
206
|
+
// the Collections API will generate a unique key for this item.
|
|
207
|
+
key: getItemLikeKey(option),
|
|
208
|
+
// textValue is either explicitly specified by the user, or we
|
|
209
|
+
// try to derive it if `content` is a string.
|
|
210
|
+
textValue:
|
|
211
|
+
(_a = getChildProp(option, "textValue")) !== null && _a !== void 0
|
|
212
|
+
? _a
|
|
213
|
+
: isString(content)
|
|
214
|
+
? content
|
|
215
|
+
: propInChild(option, "value")
|
|
216
|
+
? getChildProp(option, "value")
|
|
217
|
+
: option.key,
|
|
218
|
+
"aria-label": getChildProp(option, "aria-label"),
|
|
219
|
+
},
|
|
220
|
+
option
|
|
221
|
+
);
|
|
222
|
+
} else {
|
|
223
|
+
var group = child;
|
|
224
|
+
return React__default.createElement(
|
|
225
|
+
Section,
|
|
226
|
+
// Note that we are using the whole section-like element as the title
|
|
227
|
+
// here, and not group.props.title; we want the entire section-like
|
|
228
|
+
// Plume element to end up as Node.rendered.
|
|
229
|
+
{
|
|
230
|
+
// Note that we are using the whole section-like element as the title
|
|
231
|
+
// here, and not group.props.title; we want the entire section-like
|
|
232
|
+
// Plume element to end up as Node.rendered.
|
|
233
|
+
title: group,
|
|
234
|
+
"aria-label": getChildProp(group, "aria-label"),
|
|
235
|
+
// We are flattening and deriving the descendant Options as items here.
|
|
236
|
+
// group.props.children should've already been cleaned up by
|
|
237
|
+
// deriveItemsFromChildren()
|
|
238
|
+
items: getChildProp(group, "children"),
|
|
239
|
+
},
|
|
240
|
+
function (c) {
|
|
241
|
+
return renderAsCollectionChild(c, opts);
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function getItemLikeKey(element) {
|
|
247
|
+
var _a;
|
|
248
|
+
return (_a = getChildProp(element, "value")) !== null && _a !== void 0
|
|
249
|
+
? _a
|
|
250
|
+
: element.key;
|
|
251
|
+
}
|
|
252
|
+
// PlasmicLoader-aware function to get prop from child.
|
|
253
|
+
function getChildProp(child, prop) {
|
|
254
|
+
return "componentProps" in child.props
|
|
255
|
+
? child.props.componentProps[prop]
|
|
256
|
+
: child.props[prop];
|
|
257
|
+
}
|
|
258
|
+
// PlasmicLoader-aware function to check `if (prop in element.props)`.
|
|
259
|
+
function propInChild(child, prop) {
|
|
260
|
+
return "componentProps" in child.props
|
|
261
|
+
? prop in child.props.componentProps
|
|
262
|
+
: prop in child.props;
|
|
263
|
+
}
|
|
264
|
+
// PlasmicLoader-aware function to clone React element.
|
|
265
|
+
function cloneChild(child, props) {
|
|
266
|
+
if (child.type.getPlumeType) {
|
|
267
|
+
// If React element has getPlumeType(), assume that it is PlasmicLoader,
|
|
268
|
+
// so add nodeProps to componentProps instead of element props.
|
|
269
|
+
return React__default.cloneElement(
|
|
270
|
+
child,
|
|
271
|
+
__assign(
|
|
272
|
+
{
|
|
273
|
+
componentProps: __assign(
|
|
274
|
+
__assign({}, child.props.componentProps),
|
|
275
|
+
props
|
|
276
|
+
),
|
|
277
|
+
},
|
|
278
|
+
props.key ? { key: props.key } : {}
|
|
279
|
+
)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
return React__default.cloneElement(child, props);
|
|
235
283
|
}
|
|
236
284
|
|
|
237
|
-
export {
|
|
285
|
+
export {
|
|
286
|
+
renderAsCollectionChild as a,
|
|
287
|
+
getChildProp as g,
|
|
288
|
+
renderCollectionNode as r,
|
|
289
|
+
useDerivedItemsFromChildren as u,
|
|
290
|
+
};
|
|
238
291
|
//# sourceMappingURL=collection-utils-b0b8f30e.js.map
|
|
@@ -11,3 +11,4 @@ export { createUseScreenVariants } from "./render/screen-variants";
|
|
|
11
11
|
export { PlasmicRootProvider, useIsSSR } from "./render/ssr";
|
|
12
12
|
export { Stack } from "./render/Stack";
|
|
13
13
|
export { useTrigger } from "./render/triggers";
|
|
14
|
+
export { Trans, genTranslatableString } from "./render/translation";
|
package/skinny/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { _ as __rest, a as __assign, b as __spreadArray, o as omit, p as pick, i
|
|
|
6
6
|
export { o as omit, p as pick } from './tslib.es6-d26ffe68.js';
|
|
7
7
|
export { PlasmicImg } from './render/PlasmicImg/index.js';
|
|
8
8
|
import ReactDOM__default from 'react-dom';
|
|
9
|
-
export { P as PlasmicRootProvider, u as useIsSSR } from './ssr-
|
|
9
|
+
export { P as PlasmicRootProvider, T as Trans, g as genTranslatableString, u as useIsSSR } from './ssr-a8081074.js';
|
|
10
10
|
import { useFocusRing } from 'react-aria';
|
|
11
11
|
|
|
12
12
|
function renderStack(as, props, hasGap, ref) {
|
|
@@ -383,7 +383,7 @@ function PlasmicIcon(props) {
|
|
|
383
383
|
return React.createElement(PlasmicIconType, __assign({}, rest));
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
function PlasmicLink(props) {
|
|
386
|
+
var PlasmicLink = React__default.forwardRef(function PlasmicLink(props, ref) {
|
|
387
387
|
// props.href is required for nextjs; if no props.href,
|
|
388
388
|
// then we just render the default anchor element
|
|
389
389
|
if (props.platform === "nextjs" && props.href) {
|
|
@@ -396,13 +396,13 @@ function PlasmicLink(props) {
|
|
|
396
396
|
"prefetch",
|
|
397
397
|
"locale",
|
|
398
398
|
];
|
|
399
|
-
return React__default.createElement(props.component, pick.apply(void 0, __spreadArray([props], nextjsProps)), React__default.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], nextjsProps)))));
|
|
399
|
+
return React__default.createElement(props.component, pick.apply(void 0, __spreadArray([props], nextjsProps)), React__default.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], nextjsProps)), { ref: ref })));
|
|
400
400
|
}
|
|
401
401
|
if (props.platform === "gatsby" && isInternalHref(props.href)) {
|
|
402
|
-
return React__default.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href }));
|
|
402
|
+
return React__default.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
|
|
403
403
|
}
|
|
404
|
-
return React__default.createElement("a", __assign({}, omit(props, "component", "platform")));
|
|
405
|
-
}
|
|
404
|
+
return React__default.createElement("a", __assign({}, omit(props, "component", "platform"), { ref: ref }));
|
|
405
|
+
});
|
|
406
406
|
function isInternalHref(href) {
|
|
407
407
|
return /^\/(?!\/)/.test(href);
|
|
408
408
|
}
|