@plasmicpkgs/react-aria 0.0.2
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/LICENSE.md +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/contexts.d.ts +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/option-utils.d.ts +51 -0
- package/dist/react-aria.esm.js +1191 -0
- package/dist/react-aria.esm.js.map +1 -0
- package/dist/react-aria.js +1198 -0
- package/dist/react-aria.js.map +1 -0
- package/dist/registerButton.d.ts +4 -0
- package/dist/registerComboBox.d.ts +21 -0
- package/dist/registerHeader.d.ts +5 -0
- package/dist/registerInput.d.ts +5 -0
- package/dist/registerLabel.d.ts +5 -0
- package/dist/registerListBox.d.ts +14 -0
- package/dist/registerListBoxItem.d.ts +7 -0
- package/dist/registerPopover.d.ts +7 -0
- package/dist/registerSection.d.ts +14 -0
- package/dist/registerSelect.d.ts +23 -0
- package/dist/utils.d.ts +18 -0
- package/package.json +74 -0
- package/skinny/contexts-c0294d96.cjs.js +24 -0
- package/skinny/contexts-c0294d96.cjs.js.map +1 -0
- package/skinny/contexts-fd3e1077.esm.js +12 -0
- package/skinny/contexts-fd3e1077.esm.js.map +1 -0
- package/skinny/contexts.d.ts +14 -0
- package/skinny/option-utils-0db61f6d.cjs.js +162 -0
- package/skinny/option-utils-0db61f6d.cjs.js.map +1 -0
- package/skinny/option-utils-765a1782.esm.js +153 -0
- package/skinny/option-utils-765a1782.esm.js.map +1 -0
- package/skinny/option-utils.d.ts +51 -0
- package/skinny/registerButton.cjs.js +31 -0
- package/skinny/registerButton.cjs.js.map +1 -0
- package/skinny/registerButton.d.ts +4 -0
- package/skinny/registerButton.esm.js +26 -0
- package/skinny/registerButton.esm.js.map +1 -0
- package/skinny/registerComboBox.cjs.js +291 -0
- package/skinny/registerComboBox.cjs.js.map +1 -0
- package/skinny/registerComboBox.d.ts +21 -0
- package/skinny/registerComboBox.esm.js +284 -0
- package/skinny/registerComboBox.esm.js.map +1 -0
- package/skinny/registerHeader.cjs.js +51 -0
- package/skinny/registerHeader.cjs.js.map +1 -0
- package/skinny/registerHeader.d.ts +5 -0
- package/skinny/registerHeader.esm.js +44 -0
- package/skinny/registerHeader.esm.js.map +1 -0
- package/skinny/registerInput.cjs.js +78 -0
- package/skinny/registerInput.cjs.js.map +1 -0
- package/skinny/registerInput.d.ts +5 -0
- package/skinny/registerInput.esm.js +71 -0
- package/skinny/registerInput.esm.js.map +1 -0
- package/skinny/registerLabel.cjs.js +59 -0
- package/skinny/registerLabel.cjs.js.map +1 -0
- package/skinny/registerLabel.d.ts +5 -0
- package/skinny/registerLabel.esm.js +52 -0
- package/skinny/registerLabel.esm.js.map +1 -0
- package/skinny/registerListBox.cjs.js +145 -0
- package/skinny/registerListBox.cjs.js.map +1 -0
- package/skinny/registerListBox.d.ts +14 -0
- package/skinny/registerListBox.esm.js +138 -0
- package/skinny/registerListBox.esm.js.map +1 -0
- package/skinny/registerListBoxItem.cjs.js +72 -0
- package/skinny/registerListBoxItem.cjs.js.map +1 -0
- package/skinny/registerListBoxItem.d.ts +7 -0
- package/skinny/registerListBoxItem.esm.js +65 -0
- package/skinny/registerListBoxItem.esm.js.map +1 -0
- package/skinny/registerPopover.cjs.js +111 -0
- package/skinny/registerPopover.cjs.js.map +1 -0
- package/skinny/registerPopover.d.ts +7 -0
- package/skinny/registerPopover.esm.js +104 -0
- package/skinny/registerPopover.esm.js.map +1 -0
- package/skinny/registerSection.cjs.js +82 -0
- package/skinny/registerSection.cjs.js.map +1 -0
- package/skinny/registerSection.d.ts +14 -0
- package/skinny/registerSection.esm.js +75 -0
- package/skinny/registerSection.esm.js.map +1 -0
- package/skinny/registerSelect.cjs.js +199 -0
- package/skinny/registerSelect.cjs.js.map +1 -0
- package/skinny/registerSelect.d.ts +23 -0
- package/skinny/registerSelect.esm.js +189 -0
- package/skinny/registerSelect.esm.js.map +1 -0
- package/skinny/utils-044c7f37.cjs.js +74 -0
- package/skinny/utils-044c7f37.cjs.js.map +1 -0
- package/skinny/utils-d92b3b76.esm.js +64 -0
- package/skinny/utils-d92b3b76.esm.js.map +1 -0
- package/skinny/utils.d.ts +18 -0
|
@@ -0,0 +1,1191 @@
|
|
|
1
|
+
import { Button, ComboBox, ComboBoxStateContext, Input, Label, ListBoxItem, ListBoxContext, ListBox, PopoverContext, Popover, Header, Section, Collection, SelectValue, Select } from 'react-aria-components';
|
|
2
|
+
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
3
|
+
import { useFilter } from '@react-aria/i18n';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { mergeProps } from '@react-aria/utils';
|
|
6
|
+
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
7
|
+
|
|
8
|
+
var __defProp$9 = Object.defineProperty;
|
|
9
|
+
var __defProps$3 = Object.defineProperties;
|
|
10
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues$9 = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
18
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols$9)
|
|
20
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
21
|
+
if (__propIsEnum$9.call(b, prop))
|
|
22
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
27
|
+
function registerComponentHelper(loader, component, meta, overrides) {
|
|
28
|
+
if (overrides) {
|
|
29
|
+
meta = __spreadProps$3(__spreadValues$9(__spreadValues$9({}, meta), overrides), {
|
|
30
|
+
props: __spreadValues$9(__spreadValues$9({}, meta.props), overrides.props)
|
|
31
|
+
});
|
|
32
|
+
if (overrides.parentComponentName) {
|
|
33
|
+
meta.name = makeChildComponentName(
|
|
34
|
+
overrides.parentComponentName,
|
|
35
|
+
meta.name
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (loader) {
|
|
40
|
+
loader.registerComponent(component, meta);
|
|
41
|
+
} else {
|
|
42
|
+
registerComponent(component, meta);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function makeComponentName(name) {
|
|
46
|
+
return `plasmic-react-aria-${name}`;
|
|
47
|
+
}
|
|
48
|
+
function makeChildComponentName(fullParentName, fullChildName) {
|
|
49
|
+
if (!fullParentName) {
|
|
50
|
+
return fullChildName;
|
|
51
|
+
}
|
|
52
|
+
return `${fullParentName}-${fullChildName.replace(
|
|
53
|
+
"plasmic-react-aria-",
|
|
54
|
+
""
|
|
55
|
+
)}`;
|
|
56
|
+
}
|
|
57
|
+
function extractPlasmicDataProps(props) {
|
|
58
|
+
return Object.fromEntries(
|
|
59
|
+
Object.entries(props).filter(
|
|
60
|
+
([key, val]) => key.startsWith("data-plasmic-")
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function withoutNils(array) {
|
|
65
|
+
return array.filter((x) => x != null);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function registerButton(loader, overrides) {
|
|
69
|
+
registerComponentHelper(
|
|
70
|
+
loader,
|
|
71
|
+
Button,
|
|
72
|
+
{
|
|
73
|
+
name: "plasmic-react-aria-button",
|
|
74
|
+
displayName: "BaseButton",
|
|
75
|
+
importPath: "@plasmicpkgs/react-aria/registerButton",
|
|
76
|
+
importName: "BaseButton",
|
|
77
|
+
props: {
|
|
78
|
+
children: {
|
|
79
|
+
type: "slot"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
overrides
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const PlasmicLabelContext = React.createContext(void 0);
|
|
88
|
+
const PlasmicListBoxContext = React.createContext(void 0);
|
|
89
|
+
const PlasmicPopoverContext = React.createContext(void 0);
|
|
90
|
+
const PlasmicItemContext = React.createContext(void 0);
|
|
91
|
+
const PlasmicSectionContext = React.createContext(void 0);
|
|
92
|
+
const PlasmicHeaderContext = React.createContext(void 0);
|
|
93
|
+
const PlasmicInputContext = React.createContext(void 0);
|
|
94
|
+
|
|
95
|
+
function useStrictOptions(props) {
|
|
96
|
+
const { options, optionInfo } = props;
|
|
97
|
+
return React.useMemo(() => {
|
|
98
|
+
return deriveStrictOptions({ options, optionInfo });
|
|
99
|
+
}, [options, optionInfo]);
|
|
100
|
+
}
|
|
101
|
+
function deriveStrictOptions(props) {
|
|
102
|
+
var _a;
|
|
103
|
+
const { options, optionInfo } = props;
|
|
104
|
+
let sectionCount = 0;
|
|
105
|
+
const makeStrict = (op) => {
|
|
106
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
107
|
+
if (!op) {
|
|
108
|
+
return void 0;
|
|
109
|
+
} else if (typeof op === "string" || typeof op === "number") {
|
|
110
|
+
const item = {
|
|
111
|
+
value: op
|
|
112
|
+
};
|
|
113
|
+
return item;
|
|
114
|
+
} else if (optionInfo) {
|
|
115
|
+
const info = optionInfo(op);
|
|
116
|
+
if (info.type === "section") {
|
|
117
|
+
const section = {
|
|
118
|
+
type: "section",
|
|
119
|
+
items: (_c = (_b = (_a2 = info.items) == null ? void 0 : _a2.map) == null ? void 0 : _b.call(_a2, (item) => makeStrict(item))) == null ? void 0 : _c.filter((x) => !!x),
|
|
120
|
+
label: info.label,
|
|
121
|
+
key: `section-${sectionCount}`
|
|
122
|
+
};
|
|
123
|
+
sectionCount += 1;
|
|
124
|
+
return section;
|
|
125
|
+
} else {
|
|
126
|
+
let item = info;
|
|
127
|
+
if (!("value" in item)) {
|
|
128
|
+
item = {
|
|
129
|
+
type: "item",
|
|
130
|
+
value: JSON.stringify(item)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return item;
|
|
134
|
+
}
|
|
135
|
+
} else if (typeof op === "object") {
|
|
136
|
+
if ("items" in op) {
|
|
137
|
+
const section = {
|
|
138
|
+
type: "section",
|
|
139
|
+
items: (_f = (_e = (_d = op.items) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (item) => makeStrict(item))) == null ? void 0 : _f.filter((x) => !!x),
|
|
140
|
+
label: op.label,
|
|
141
|
+
key: `section-${sectionCount}`
|
|
142
|
+
};
|
|
143
|
+
sectionCount += 1;
|
|
144
|
+
return section;
|
|
145
|
+
} else {
|
|
146
|
+
let item = op;
|
|
147
|
+
if (!("value" in item)) {
|
|
148
|
+
item = {
|
|
149
|
+
type: "item",
|
|
150
|
+
value: JSON.stringify(item)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return item;
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
|
|
160
|
+
const optionText = (op) => {
|
|
161
|
+
var _a2;
|
|
162
|
+
return (_a2 = op.label) != null ? _a2 : op.value;
|
|
163
|
+
};
|
|
164
|
+
return { options: strictOptions, optionText };
|
|
165
|
+
}
|
|
166
|
+
function flattenOptions(options) {
|
|
167
|
+
if (!options) {
|
|
168
|
+
return [];
|
|
169
|
+
} else {
|
|
170
|
+
return options.flatMap(
|
|
171
|
+
(op) => {
|
|
172
|
+
var _a;
|
|
173
|
+
return op.type === "section" ? (_a = op.items) != null ? _a : [] : op;
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function makeOptionsPropType() {
|
|
179
|
+
const type = {
|
|
180
|
+
type: "array",
|
|
181
|
+
itemType: {
|
|
182
|
+
type: "object",
|
|
183
|
+
nameFunc: (item) => item.label || item.value,
|
|
184
|
+
fields: {
|
|
185
|
+
type: {
|
|
186
|
+
type: "choice",
|
|
187
|
+
options: [
|
|
188
|
+
{ value: "option", label: "Option" },
|
|
189
|
+
{ value: "option-group", label: "Option Group" }
|
|
190
|
+
],
|
|
191
|
+
defaultValue: "option"
|
|
192
|
+
},
|
|
193
|
+
value: {
|
|
194
|
+
type: "string",
|
|
195
|
+
hidden: (_ps, _ctx, { item }) => item.type !== "option"
|
|
196
|
+
},
|
|
197
|
+
label: "string",
|
|
198
|
+
items: {
|
|
199
|
+
type: "array",
|
|
200
|
+
displayName: "Options",
|
|
201
|
+
hidden: (_ps, _ctx, { item }) => {
|
|
202
|
+
return item.type !== "option-group";
|
|
203
|
+
},
|
|
204
|
+
itemType: {
|
|
205
|
+
type: "object",
|
|
206
|
+
nameFunc: (item) => item.label || item.value,
|
|
207
|
+
fields: {
|
|
208
|
+
value: "string",
|
|
209
|
+
label: "string"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
defaultValue: [
|
|
216
|
+
{
|
|
217
|
+
value: "option1",
|
|
218
|
+
label: "Option 1",
|
|
219
|
+
type: "option"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
value: "option2",
|
|
223
|
+
label: "Option 2",
|
|
224
|
+
type: "option"
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
};
|
|
228
|
+
return type;
|
|
229
|
+
}
|
|
230
|
+
function makeValuePropType() {
|
|
231
|
+
const type = {
|
|
232
|
+
type: "choice",
|
|
233
|
+
options: (ps) => {
|
|
234
|
+
const { options, optionText } = deriveStrictOptions(ps);
|
|
235
|
+
return flattenOptions(options).map((op) => ({
|
|
236
|
+
value: op.value,
|
|
237
|
+
label: optionText(op)
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
return type;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
var __defProp$8 = Object.defineProperty;
|
|
245
|
+
var __defProps$2 = Object.defineProperties;
|
|
246
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
247
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
248
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
249
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
250
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
251
|
+
var __spreadValues$8 = (a, b) => {
|
|
252
|
+
for (var prop in b || (b = {}))
|
|
253
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
254
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
255
|
+
if (__getOwnPropSymbols$8)
|
|
256
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
257
|
+
if (__propIsEnum$8.call(b, prop))
|
|
258
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
259
|
+
}
|
|
260
|
+
return a;
|
|
261
|
+
};
|
|
262
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
263
|
+
function BaseComboBox(props) {
|
|
264
|
+
const {
|
|
265
|
+
value,
|
|
266
|
+
onChange,
|
|
267
|
+
menuTrigger,
|
|
268
|
+
filterValue,
|
|
269
|
+
onFilterValueChange,
|
|
270
|
+
valueType,
|
|
271
|
+
allowsCustomValue,
|
|
272
|
+
placeholder,
|
|
273
|
+
previewOpen,
|
|
274
|
+
onOpenChange,
|
|
275
|
+
isDisabled,
|
|
276
|
+
className,
|
|
277
|
+
style,
|
|
278
|
+
structure,
|
|
279
|
+
name
|
|
280
|
+
} = props;
|
|
281
|
+
const { options, optionText } = useStrictOptions(props);
|
|
282
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
283
|
+
const [showAllOptions, setShowAllOptions] = React.useState(false);
|
|
284
|
+
const filteredOptions = React.useMemo(() => {
|
|
285
|
+
if (!filterValue || filterValue.trim().length === 0) {
|
|
286
|
+
return options;
|
|
287
|
+
}
|
|
288
|
+
if (!options) {
|
|
289
|
+
return options;
|
|
290
|
+
}
|
|
291
|
+
const filterOptions = (options2) => {
|
|
292
|
+
return withoutNils(
|
|
293
|
+
options2.map((op) => {
|
|
294
|
+
if (op.type === "section") {
|
|
295
|
+
return __spreadProps$2(__spreadValues$8({}, op), {
|
|
296
|
+
items: op.items ? filterOptions(op.items) : void 0
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
if (contains(optionText(op), filterValue)) {
|
|
300
|
+
return op;
|
|
301
|
+
} else {
|
|
302
|
+
return void 0;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
return filterOptions(options);
|
|
309
|
+
}, [options, filterValue, contains]);
|
|
310
|
+
const flattenedOptions = React.useMemo(
|
|
311
|
+
() => flattenOptions(options),
|
|
312
|
+
[options]
|
|
313
|
+
);
|
|
314
|
+
const disabledKeys = flattenedOptions.filter((op) => op.isDisabled).map((op) => op.value);
|
|
315
|
+
const onSelectionChange = React.useCallback(
|
|
316
|
+
(key) => {
|
|
317
|
+
const selectedOption = flattenedOptions == null ? void 0 : flattenedOptions.find((op) => op.value === key);
|
|
318
|
+
if (valueType === "text") {
|
|
319
|
+
if (selectedOption) {
|
|
320
|
+
onChange == null ? void 0 : onChange(optionText(selectedOption));
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
onChange == null ? void 0 : onChange(key);
|
|
324
|
+
}
|
|
325
|
+
if (selectedOption) {
|
|
326
|
+
onFilterValueChange == null ? void 0 : onFilterValueChange(optionText(selectedOption));
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
[onChange, onFilterValueChange, flattenedOptions, optionText]
|
|
330
|
+
);
|
|
331
|
+
const onInputValueChange = React.useCallback(
|
|
332
|
+
(newValue) => {
|
|
333
|
+
onFilterValueChange == null ? void 0 : onFilterValueChange(newValue);
|
|
334
|
+
setShowAllOptions(false);
|
|
335
|
+
if (valueType === "text") {
|
|
336
|
+
if (allowsCustomValue) {
|
|
337
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
338
|
+
} else {
|
|
339
|
+
const matchingOption = flattenedOptions == null ? void 0 : flattenedOptions.find(
|
|
340
|
+
(op) => optionText(op) === newValue
|
|
341
|
+
);
|
|
342
|
+
if (matchingOption) {
|
|
343
|
+
onChange == null ? void 0 : onChange(optionText(matchingOption));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
[
|
|
349
|
+
onFilterValueChange,
|
|
350
|
+
onChange,
|
|
351
|
+
flattenedOptions,
|
|
352
|
+
optionText,
|
|
353
|
+
valueType,
|
|
354
|
+
allowsCustomValue
|
|
355
|
+
]
|
|
356
|
+
);
|
|
357
|
+
const onBlur = React.useCallback(() => {
|
|
358
|
+
if (!allowsCustomValue) {
|
|
359
|
+
const selectedOption = flattenedOptions == null ? void 0 : flattenedOptions.find(
|
|
360
|
+
(op) => valueType === "text" ? optionText(op) === value : op.value === value
|
|
361
|
+
);
|
|
362
|
+
if (selectedOption) {
|
|
363
|
+
const selectedOptionText = optionText(selectedOption);
|
|
364
|
+
if (selectedOptionText !== filterValue) {
|
|
365
|
+
onFilterValueChange == null ? void 0 : onFilterValueChange(selectedOptionText);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}, [
|
|
370
|
+
allowsCustomValue,
|
|
371
|
+
valueType,
|
|
372
|
+
flattenedOptions,
|
|
373
|
+
value,
|
|
374
|
+
optionText,
|
|
375
|
+
onFilterValueChange
|
|
376
|
+
]);
|
|
377
|
+
return /* @__PURE__ */ React.createElement(
|
|
378
|
+
ComboBox,
|
|
379
|
+
__spreadValues$8({
|
|
380
|
+
selectedKey: value,
|
|
381
|
+
onSelectionChange,
|
|
382
|
+
isDisabled,
|
|
383
|
+
className,
|
|
384
|
+
style,
|
|
385
|
+
items: showAllOptions ? options : filteredOptions,
|
|
386
|
+
menuTrigger,
|
|
387
|
+
inputValue: filterValue,
|
|
388
|
+
onInputChange: onInputValueChange,
|
|
389
|
+
allowsCustomValue,
|
|
390
|
+
disabledKeys,
|
|
391
|
+
onOpenChange: (isOpen, trigger) => {
|
|
392
|
+
if (isOpen && trigger === "manual") {
|
|
393
|
+
setShowAllOptions(true);
|
|
394
|
+
} else {
|
|
395
|
+
setShowAllOptions(false);
|
|
396
|
+
}
|
|
397
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen);
|
|
398
|
+
},
|
|
399
|
+
onBlur,
|
|
400
|
+
formValue: valueType === "text" ? "text" : "key",
|
|
401
|
+
name
|
|
402
|
+
}, extractPlasmicDataProps(props)),
|
|
403
|
+
/* @__PURE__ */ React.createElement(
|
|
404
|
+
PlasmicListBoxContext.Provider,
|
|
405
|
+
{
|
|
406
|
+
value: {
|
|
407
|
+
makeItemProps: (item) => ({
|
|
408
|
+
key: item.value,
|
|
409
|
+
textValue: optionText(item),
|
|
410
|
+
children: optionText(item)
|
|
411
|
+
}),
|
|
412
|
+
makeSectionProps: (section) => ({
|
|
413
|
+
section,
|
|
414
|
+
key: section.key
|
|
415
|
+
}),
|
|
416
|
+
getItemType: (option) => option.type === "section" ? "section" : "item"
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
/* @__PURE__ */ React.createElement(PlasmicInputContext.Provider, { value: { placeholder } }, structure)
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ React.createElement(BaseComboBoxEffects, { previewOpen })
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
function BaseComboBoxEffects(props) {
|
|
425
|
+
const { previewOpen } = props;
|
|
426
|
+
const comboBoxState = React.useContext(ComboBoxStateContext);
|
|
427
|
+
const prevPreviewOpenRef = React.useRef(previewOpen);
|
|
428
|
+
React.useEffect(() => {
|
|
429
|
+
if (comboBoxState) {
|
|
430
|
+
if (previewOpen) {
|
|
431
|
+
comboBoxState.open(void 0, "manual");
|
|
432
|
+
} else if (prevPreviewOpenRef.current) {
|
|
433
|
+
comboBoxState.close();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
prevPreviewOpenRef.current = previewOpen;
|
|
437
|
+
}, [previewOpen, comboBoxState, prevPreviewOpenRef]);
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
function registerComboBox(loader) {
|
|
441
|
+
const rootName = makeComponentName("combobox");
|
|
442
|
+
registerComponentHelper(loader, BaseComboBox, {
|
|
443
|
+
name: rootName,
|
|
444
|
+
displayName: "BaseComboBox",
|
|
445
|
+
importPath: "@plasmicpkgs/react-aria/registerComboBox",
|
|
446
|
+
importName: "BaseComboBox",
|
|
447
|
+
props: {
|
|
448
|
+
options: makeOptionsPropType(),
|
|
449
|
+
value: makeValuePropType(),
|
|
450
|
+
onChange: {
|
|
451
|
+
type: "eventHandler",
|
|
452
|
+
argTypes: [{ name: "value", type: "string" }]
|
|
453
|
+
},
|
|
454
|
+
filterValue: {
|
|
455
|
+
type: "string"
|
|
456
|
+
},
|
|
457
|
+
onFilterValueChange: {
|
|
458
|
+
type: "eventHandler",
|
|
459
|
+
argTypes: [{ name: "value", type: "string" }]
|
|
460
|
+
},
|
|
461
|
+
isDisabled: {
|
|
462
|
+
type: "boolean"
|
|
463
|
+
},
|
|
464
|
+
valueType: {
|
|
465
|
+
displayName: "`value` Type",
|
|
466
|
+
type: "choice",
|
|
467
|
+
options: [
|
|
468
|
+
{ value: "value", label: "By option value" },
|
|
469
|
+
{ value: "text", label: "By option text" }
|
|
470
|
+
],
|
|
471
|
+
defaultValueHint: "value",
|
|
472
|
+
description: "This controls whether `value` and `onChange` are option values or option text. Choosing `text` allows you to optionally allow a custom value that's not in the provided list of options.",
|
|
473
|
+
advanced: true
|
|
474
|
+
},
|
|
475
|
+
allowsCustomValue: {
|
|
476
|
+
type: "boolean",
|
|
477
|
+
displayName: "Allows custom value?",
|
|
478
|
+
description: "Allows entering a value that is not one of the options",
|
|
479
|
+
hidden: (ps) => ps.valueType !== "text",
|
|
480
|
+
advanced: true
|
|
481
|
+
},
|
|
482
|
+
onOpenChange: {
|
|
483
|
+
type: "eventHandler",
|
|
484
|
+
argTypes: [{ name: "isOpen", type: "boolean" }]
|
|
485
|
+
},
|
|
486
|
+
structure: {
|
|
487
|
+
type: "slot"
|
|
488
|
+
},
|
|
489
|
+
previewOpen: {
|
|
490
|
+
type: "boolean",
|
|
491
|
+
displayName: "Preview opened?",
|
|
492
|
+
description: "Preview opened state while designing in Plasmic editor",
|
|
493
|
+
editOnly: true
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
states: {
|
|
497
|
+
value: {
|
|
498
|
+
type: "writable",
|
|
499
|
+
valueProp: "value",
|
|
500
|
+
onChangeProp: "onChange",
|
|
501
|
+
variableType: "text"
|
|
502
|
+
},
|
|
503
|
+
filterValue: {
|
|
504
|
+
type: "writable",
|
|
505
|
+
valueProp: "filterValue",
|
|
506
|
+
onChangeProp: "onFilterValueChange",
|
|
507
|
+
variableType: "text"
|
|
508
|
+
},
|
|
509
|
+
isOpen: {
|
|
510
|
+
type: "readonly",
|
|
511
|
+
onChangeProp: "onOpenChange",
|
|
512
|
+
variableType: "boolean"
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
var __defProp$7 = Object.defineProperty;
|
|
519
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
520
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
521
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
522
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
523
|
+
var __spreadValues$7 = (a, b) => {
|
|
524
|
+
for (var prop in b || (b = {}))
|
|
525
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
526
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
527
|
+
if (__getOwnPropSymbols$7)
|
|
528
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
529
|
+
if (__propIsEnum$7.call(b, prop))
|
|
530
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
531
|
+
}
|
|
532
|
+
return a;
|
|
533
|
+
};
|
|
534
|
+
function BaseInput(props) {
|
|
535
|
+
const contextProps = React.useContext(PlasmicInputContext);
|
|
536
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadValues$7({}, mergeProps(contextProps, props)));
|
|
537
|
+
}
|
|
538
|
+
function registerInput(loader, overrides) {
|
|
539
|
+
registerComponentHelper(
|
|
540
|
+
loader,
|
|
541
|
+
BaseInput,
|
|
542
|
+
{
|
|
543
|
+
name: makeComponentName("input"),
|
|
544
|
+
displayName: "BaseInput",
|
|
545
|
+
importPath: "@plasmicpkgs/react-aria/registerInput",
|
|
546
|
+
importName: "BaseInput",
|
|
547
|
+
props: {
|
|
548
|
+
className: {
|
|
549
|
+
type: "class",
|
|
550
|
+
displayName: "Styles in different states",
|
|
551
|
+
selectors: [
|
|
552
|
+
{
|
|
553
|
+
selector: ":self[data-hovered]",
|
|
554
|
+
label: "Hovered"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
selector: ":self[data-focused]",
|
|
558
|
+
label: "Focused"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
selector: ":self[data-focus-visible]",
|
|
562
|
+
label: "Focus visible"
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
selector: ":self[data-disabled]",
|
|
566
|
+
label: "Disabled"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
selector: ":self::placeholder",
|
|
570
|
+
label: "Placeholder"
|
|
571
|
+
}
|
|
572
|
+
]
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
overrides
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
var __defProp$6 = Object.defineProperty;
|
|
581
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
582
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
583
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
584
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
585
|
+
var __spreadValues$6 = (a, b) => {
|
|
586
|
+
for (var prop in b || (b = {}))
|
|
587
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
588
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
589
|
+
if (__getOwnPropSymbols$6)
|
|
590
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
591
|
+
if (__propIsEnum$6.call(b, prop))
|
|
592
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
593
|
+
}
|
|
594
|
+
return a;
|
|
595
|
+
};
|
|
596
|
+
function BaseLabel(props) {
|
|
597
|
+
const contextProps = React.useContext(PlasmicLabelContext);
|
|
598
|
+
return /* @__PURE__ */ React.createElement(Label, __spreadValues$6({}, mergeProps(contextProps, props)));
|
|
599
|
+
}
|
|
600
|
+
function registerLabel(loader, overrides) {
|
|
601
|
+
registerComponentHelper(
|
|
602
|
+
loader,
|
|
603
|
+
BaseLabel,
|
|
604
|
+
{
|
|
605
|
+
name: "plasmic-react-aria-label",
|
|
606
|
+
displayName: "BaseLabel",
|
|
607
|
+
importPath: "@plasmicpkgs/react-aria/registerLabel",
|
|
608
|
+
importName: "BaseLabel",
|
|
609
|
+
props: {
|
|
610
|
+
children: {
|
|
611
|
+
type: "slot",
|
|
612
|
+
defaultValue: {
|
|
613
|
+
type: "text",
|
|
614
|
+
value: "Label"
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
overrides
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
var __defProp$5 = Object.defineProperty;
|
|
624
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
625
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
626
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
627
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
628
|
+
var __spreadValues$5 = (a, b) => {
|
|
629
|
+
for (var prop in b || (b = {}))
|
|
630
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
631
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
632
|
+
if (__getOwnPropSymbols$5)
|
|
633
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
634
|
+
if (__propIsEnum$5.call(b, prop))
|
|
635
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
636
|
+
}
|
|
637
|
+
return a;
|
|
638
|
+
};
|
|
639
|
+
function BaseListBoxItem(props) {
|
|
640
|
+
var _a;
|
|
641
|
+
const contextProps = React.useContext(PlasmicItemContext);
|
|
642
|
+
const mergedProps = mergeProps(contextProps, props);
|
|
643
|
+
return /* @__PURE__ */ React.createElement(ListBoxItem, __spreadValues$5({ id: (_a = mergedProps.key) != null ? _a : void 0 }, mergedProps));
|
|
644
|
+
}
|
|
645
|
+
function registerListBoxItem(loader, overrides) {
|
|
646
|
+
registerComponentHelper(
|
|
647
|
+
loader,
|
|
648
|
+
BaseListBoxItem,
|
|
649
|
+
{
|
|
650
|
+
name: makeComponentName("item"),
|
|
651
|
+
displayName: "BaseListBoxItem",
|
|
652
|
+
importPath: "@plasmicpkgs/react-aria/registerListBoxItem",
|
|
653
|
+
importName: "BaseListBoxItem",
|
|
654
|
+
props: {
|
|
655
|
+
className: {
|
|
656
|
+
type: "class",
|
|
657
|
+
displayName: "Styles in different states",
|
|
658
|
+
selectors: [
|
|
659
|
+
{
|
|
660
|
+
selector: ":self[data-selected]",
|
|
661
|
+
label: "Selected"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
selector: ":self[data-focused], :self[data-hovered]",
|
|
665
|
+
label: "Focused"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
selector: ":self[data-disabled]",
|
|
669
|
+
label: "Disabled"
|
|
670
|
+
}
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
overrides
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
var __defProp$4 = Object.defineProperty;
|
|
680
|
+
var __defProps$1 = Object.defineProperties;
|
|
681
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
682
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
683
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
684
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
685
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
686
|
+
var __spreadValues$4 = (a, b) => {
|
|
687
|
+
for (var prop in b || (b = {}))
|
|
688
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
689
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
690
|
+
if (__getOwnPropSymbols$4)
|
|
691
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
692
|
+
if (__propIsEnum$4.call(b, prop))
|
|
693
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
694
|
+
}
|
|
695
|
+
return a;
|
|
696
|
+
};
|
|
697
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
698
|
+
var __objRest$2 = (source, exclude) => {
|
|
699
|
+
var target = {};
|
|
700
|
+
for (var prop in source)
|
|
701
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
702
|
+
target[prop] = source[prop];
|
|
703
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
704
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
705
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
706
|
+
target[prop] = source[prop];
|
|
707
|
+
}
|
|
708
|
+
return target;
|
|
709
|
+
};
|
|
710
|
+
const STANDALONE_PROPS = {
|
|
711
|
+
getItemType: (item) => item.type,
|
|
712
|
+
items: [
|
|
713
|
+
{ type: "item", value: "op1", label: "Option 1" },
|
|
714
|
+
{ type: "item", value: "op2", label: "Option 2" },
|
|
715
|
+
{ type: "item", value: "op3", label: "Option 3" },
|
|
716
|
+
{
|
|
717
|
+
type: "section",
|
|
718
|
+
label: "Section 1",
|
|
719
|
+
items: [
|
|
720
|
+
{ type: "item", value: "s1op1", label: "Section 1 Option 1" },
|
|
721
|
+
{ type: "item", value: "s1op2", label: "Section 1 Option 2" },
|
|
722
|
+
{ type: "item", value: "s1op3", label: "Section 1 Option 3" }
|
|
723
|
+
]
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
type: "section",
|
|
727
|
+
label: "Section 2",
|
|
728
|
+
items: [
|
|
729
|
+
{ type: "item", value: "s2op1", label: "Section 2 Option 1" },
|
|
730
|
+
{ type: "item", value: "s2op2", label: "Section 2 Option 2" },
|
|
731
|
+
{ type: "item", value: "s2op3", label: "Section 2 Option 3" }
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
],
|
|
735
|
+
makeItemProps: (item) => ({
|
|
736
|
+
key: item.value,
|
|
737
|
+
textValue: item.label,
|
|
738
|
+
children: item.label
|
|
739
|
+
}),
|
|
740
|
+
makeSectionProps: (section) => ({
|
|
741
|
+
section,
|
|
742
|
+
key: section.label
|
|
743
|
+
})
|
|
744
|
+
};
|
|
745
|
+
function BaseListBox(props) {
|
|
746
|
+
const contextProps = React.useContext(PlasmicListBoxContext);
|
|
747
|
+
const isStandalone = !React.useContext(ListBoxContext);
|
|
748
|
+
const _a = mergeProps(contextProps, props, isStandalone ? STANDALONE_PROPS : {}), {
|
|
749
|
+
makeItemProps,
|
|
750
|
+
makeSectionProps,
|
|
751
|
+
renderItem,
|
|
752
|
+
renderSection,
|
|
753
|
+
getItemType
|
|
754
|
+
} = _a, rest = __objRest$2(_a, [
|
|
755
|
+
"makeItemProps",
|
|
756
|
+
"makeSectionProps",
|
|
757
|
+
"renderItem",
|
|
758
|
+
"renderSection",
|
|
759
|
+
"getItemType"
|
|
760
|
+
]);
|
|
761
|
+
return /* @__PURE__ */ React.createElement(ListBox, __spreadValues$4({}, mergeProps(contextProps, rest)), (item) => {
|
|
762
|
+
if ((getItemType == null ? void 0 : getItemType(item)) === "section") {
|
|
763
|
+
const sectionProps = makeSectionProps == null ? void 0 : makeSectionProps(item);
|
|
764
|
+
return /* @__PURE__ */ React.createElement(
|
|
765
|
+
PlasmicSectionContext.Provider,
|
|
766
|
+
{
|
|
767
|
+
key: sectionProps == null ? void 0 : sectionProps.key,
|
|
768
|
+
value: __spreadProps$1(__spreadValues$4({}, sectionProps), { makeItemProps, renderItem })
|
|
769
|
+
},
|
|
770
|
+
renderSection == null ? void 0 : renderSection(item)
|
|
771
|
+
);
|
|
772
|
+
} else {
|
|
773
|
+
const itemProps = makeItemProps == null ? void 0 : makeItemProps(item);
|
|
774
|
+
return /* @__PURE__ */ React.createElement(PlasmicItemContext.Provider, { key: itemProps == null ? void 0 : itemProps.key, value: itemProps }, renderItem == null ? void 0 : renderItem(item));
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function registerListBox(loader, overrides) {
|
|
779
|
+
registerComponentHelper(
|
|
780
|
+
loader,
|
|
781
|
+
BaseListBox,
|
|
782
|
+
{
|
|
783
|
+
name: makeComponentName("listbox"),
|
|
784
|
+
displayName: "BaseListBox",
|
|
785
|
+
importPath: "@plasmicpkgs/react-aria/registerListBox",
|
|
786
|
+
importName: "BaseListBox",
|
|
787
|
+
props: {
|
|
788
|
+
renderItem: {
|
|
789
|
+
type: "slot",
|
|
790
|
+
displayName: "Render Item",
|
|
791
|
+
renderPropParams: ["item"]
|
|
792
|
+
},
|
|
793
|
+
renderSection: {
|
|
794
|
+
type: "slot",
|
|
795
|
+
displayName: "Render Section",
|
|
796
|
+
renderPropParams: ["section"]
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
overrides
|
|
801
|
+
);
|
|
802
|
+
registerListBoxItem(loader, {
|
|
803
|
+
parentComponentName: makeComponentName("listbox")
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
var __defProp$3 = Object.defineProperty;
|
|
808
|
+
var __defProps = Object.defineProperties;
|
|
809
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
810
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
811
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
812
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
813
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
814
|
+
var __spreadValues$3 = (a, b) => {
|
|
815
|
+
for (var prop in b || (b = {}))
|
|
816
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
817
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
818
|
+
if (__getOwnPropSymbols$3)
|
|
819
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
820
|
+
if (__propIsEnum$3.call(b, prop))
|
|
821
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
822
|
+
}
|
|
823
|
+
return a;
|
|
824
|
+
};
|
|
825
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
826
|
+
var __objRest$1 = (source, exclude) => {
|
|
827
|
+
var target = {};
|
|
828
|
+
for (var prop in source)
|
|
829
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
830
|
+
target[prop] = source[prop];
|
|
831
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
832
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
833
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
834
|
+
target[prop] = source[prop];
|
|
835
|
+
}
|
|
836
|
+
return target;
|
|
837
|
+
};
|
|
838
|
+
function BasePopover(props) {
|
|
839
|
+
const _a = props, restProps = __objRest$1(_a, ["resetClassName"]);
|
|
840
|
+
const isStandalone = !React.useContext(PopoverContext);
|
|
841
|
+
const contextProps = React.useContext(PlasmicPopoverContext);
|
|
842
|
+
const canvas = usePlasmicCanvasContext();
|
|
843
|
+
const mergedProps = mergeProps(contextProps, restProps, {
|
|
844
|
+
className: `${props.resetClassName}`
|
|
845
|
+
});
|
|
846
|
+
if (isStandalone) {
|
|
847
|
+
const triggerRef = React.useRef(null);
|
|
848
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React.createElement(
|
|
849
|
+
Popover,
|
|
850
|
+
__spreadProps(__spreadValues$3({}, mergedProps), {
|
|
851
|
+
triggerRef,
|
|
852
|
+
isNonModal: true,
|
|
853
|
+
isOpen: true
|
|
854
|
+
})
|
|
855
|
+
));
|
|
856
|
+
} else {
|
|
857
|
+
return /* @__PURE__ */ React.createElement(Popover, __spreadProps(__spreadValues$3({}, mergedProps), { isNonModal: !!canvas }));
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function registerPopover(loader, overrides) {
|
|
861
|
+
registerComponentHelper(
|
|
862
|
+
loader,
|
|
863
|
+
BasePopover,
|
|
864
|
+
{
|
|
865
|
+
name: "plasmic-react-aria-popover",
|
|
866
|
+
displayName: "BasePopover",
|
|
867
|
+
importPath: "@plasmicpkgs/react-aria/registerPopover",
|
|
868
|
+
importName: "BasePopover",
|
|
869
|
+
props: {
|
|
870
|
+
children: {
|
|
871
|
+
type: "slot"
|
|
872
|
+
},
|
|
873
|
+
offset: {
|
|
874
|
+
type: "number",
|
|
875
|
+
displayName: "Offset",
|
|
876
|
+
description: "Additional offset applied vertically between the popover and its trigger",
|
|
877
|
+
defaultValueHint: 0
|
|
878
|
+
},
|
|
879
|
+
placement: {
|
|
880
|
+
type: "choice",
|
|
881
|
+
description: "Default placement of the popover relative to the trigger, if there is enough space",
|
|
882
|
+
options: [
|
|
883
|
+
"bottom",
|
|
884
|
+
"bottom left",
|
|
885
|
+
"bottom right",
|
|
886
|
+
"top",
|
|
887
|
+
"top left",
|
|
888
|
+
"top right"
|
|
889
|
+
]
|
|
890
|
+
},
|
|
891
|
+
resetClassName: {
|
|
892
|
+
type: "themeResetClass"
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
styleSections: true
|
|
896
|
+
},
|
|
897
|
+
overrides
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
var __defProp$2 = Object.defineProperty;
|
|
902
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
903
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
904
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
905
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
906
|
+
var __spreadValues$2 = (a, b) => {
|
|
907
|
+
for (var prop in b || (b = {}))
|
|
908
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
909
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
910
|
+
if (__getOwnPropSymbols$2)
|
|
911
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
912
|
+
if (__propIsEnum$2.call(b, prop))
|
|
913
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
914
|
+
}
|
|
915
|
+
return a;
|
|
916
|
+
};
|
|
917
|
+
function BaseHeader(props) {
|
|
918
|
+
const contextProps = React.useContext(PlasmicHeaderContext);
|
|
919
|
+
return /* @__PURE__ */ React.createElement(Header, __spreadValues$2({}, mergeProps(contextProps, props)));
|
|
920
|
+
}
|
|
921
|
+
function registerHeader(loader, overrides) {
|
|
922
|
+
registerComponentHelper(
|
|
923
|
+
loader,
|
|
924
|
+
BaseHeader,
|
|
925
|
+
{
|
|
926
|
+
name: makeComponentName("header"),
|
|
927
|
+
displayName: "BaseHeader",
|
|
928
|
+
importPath: "@plasmicpkgs/react-aria/registerHeader",
|
|
929
|
+
importName: "BaseHeader",
|
|
930
|
+
props: {}
|
|
931
|
+
},
|
|
932
|
+
overrides
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
var __defProp$1 = Object.defineProperty;
|
|
937
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
938
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
939
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
940
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
941
|
+
var __spreadValues$1 = (a, b) => {
|
|
942
|
+
for (var prop in b || (b = {}))
|
|
943
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
944
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
945
|
+
if (__getOwnPropSymbols$1)
|
|
946
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
947
|
+
if (__propIsEnum$1.call(b, prop))
|
|
948
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
949
|
+
}
|
|
950
|
+
return a;
|
|
951
|
+
};
|
|
952
|
+
var __objRest = (source, exclude) => {
|
|
953
|
+
var target = {};
|
|
954
|
+
for (var prop in source)
|
|
955
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
956
|
+
target[prop] = source[prop];
|
|
957
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
958
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
959
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
960
|
+
target[prop] = source[prop];
|
|
961
|
+
}
|
|
962
|
+
return target;
|
|
963
|
+
};
|
|
964
|
+
function BaseSection(props) {
|
|
965
|
+
const contextProps = React.useContext(PlasmicSectionContext);
|
|
966
|
+
const mergedProps = mergeProps(contextProps, props);
|
|
967
|
+
const _a = mergedProps, { section, renderHeader, key, makeItemProps, renderItem } = _a, rest = __objRest(_a, ["section", "renderHeader", "key", "makeItemProps", "renderItem"]);
|
|
968
|
+
return /* @__PURE__ */ React.createElement(Section, __spreadValues$1({ id: key != null ? key : void 0 }, rest), /* @__PURE__ */ React.createElement(PlasmicHeaderContext.Provider, { value: { children: section == null ? void 0 : section.label } }, renderHeader == null ? void 0 : renderHeader(section)), /* @__PURE__ */ React.createElement(Collection, { items: section == null ? void 0 : section.items }, (item) => {
|
|
969
|
+
const itemProps = makeItemProps == null ? void 0 : makeItemProps(item);
|
|
970
|
+
return /* @__PURE__ */ React.createElement(PlasmicItemContext.Provider, { key: itemProps == null ? void 0 : itemProps.key, value: itemProps }, renderItem == null ? void 0 : renderItem(item));
|
|
971
|
+
}));
|
|
972
|
+
}
|
|
973
|
+
function registerSection(loader, overrides) {
|
|
974
|
+
registerComponentHelper(
|
|
975
|
+
loader,
|
|
976
|
+
BaseSection,
|
|
977
|
+
{
|
|
978
|
+
name: makeComponentName("section"),
|
|
979
|
+
displayName: "BaseSection",
|
|
980
|
+
importPath: "@plasmicpkgs/react-aria/registerSection",
|
|
981
|
+
importName: "BaseSection",
|
|
982
|
+
props: {
|
|
983
|
+
renderHeader: {
|
|
984
|
+
type: "slot",
|
|
985
|
+
displayName: "Render section header",
|
|
986
|
+
renderPropParams: ["section"]
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
overrides
|
|
991
|
+
);
|
|
992
|
+
const thisName = makeChildComponentName(
|
|
993
|
+
overrides == null ? void 0 : overrides.parentComponentName,
|
|
994
|
+
makeComponentName("section")
|
|
995
|
+
);
|
|
996
|
+
registerHeader(loader, {
|
|
997
|
+
parentComponentName: thisName
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
var __defProp = Object.defineProperty;
|
|
1002
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1003
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1004
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1005
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1006
|
+
var __spreadValues = (a, b) => {
|
|
1007
|
+
for (var prop in b || (b = {}))
|
|
1008
|
+
if (__hasOwnProp.call(b, prop))
|
|
1009
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1010
|
+
if (__getOwnPropSymbols)
|
|
1011
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1012
|
+
if (__propIsEnum.call(b, prop))
|
|
1013
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1014
|
+
}
|
|
1015
|
+
return a;
|
|
1016
|
+
};
|
|
1017
|
+
const SELECT_NAME = makeComponentName("select");
|
|
1018
|
+
function BaseSelect(props) {
|
|
1019
|
+
const {
|
|
1020
|
+
value,
|
|
1021
|
+
onChange,
|
|
1022
|
+
placeholder,
|
|
1023
|
+
previewOpen,
|
|
1024
|
+
onOpenChange,
|
|
1025
|
+
isDisabled,
|
|
1026
|
+
className,
|
|
1027
|
+
style,
|
|
1028
|
+
structure,
|
|
1029
|
+
renderOption,
|
|
1030
|
+
name,
|
|
1031
|
+
"aria-label": ariaLabel
|
|
1032
|
+
} = props;
|
|
1033
|
+
const { options, optionText } = useStrictOptions(props);
|
|
1034
|
+
const canvas = usePlasmicCanvasContext();
|
|
1035
|
+
const disabledKeys = flattenOptions(options).filter((op) => op.isDisabled).map((op) => op.value);
|
|
1036
|
+
return /* @__PURE__ */ React.createElement(
|
|
1037
|
+
Select,
|
|
1038
|
+
__spreadValues(__spreadValues({
|
|
1039
|
+
placeholder,
|
|
1040
|
+
selectedKey: value,
|
|
1041
|
+
onSelectionChange: onChange,
|
|
1042
|
+
onOpenChange,
|
|
1043
|
+
isDisabled,
|
|
1044
|
+
className,
|
|
1045
|
+
style,
|
|
1046
|
+
name,
|
|
1047
|
+
"aria-label": ariaLabel
|
|
1048
|
+
}, previewOpen && canvas ? { isOpen: previewOpen } : void 0), extractPlasmicDataProps(props)),
|
|
1049
|
+
/* @__PURE__ */ React.createElement(
|
|
1050
|
+
PlasmicListBoxContext.Provider,
|
|
1051
|
+
{
|
|
1052
|
+
value: {
|
|
1053
|
+
items: options,
|
|
1054
|
+
disabledKeys,
|
|
1055
|
+
makeItemProps: (item) => ({
|
|
1056
|
+
key: item.value,
|
|
1057
|
+
textValue: optionText(item),
|
|
1058
|
+
children: renderOption ? renderOption(item) : optionText(item)
|
|
1059
|
+
}),
|
|
1060
|
+
makeSectionProps: (section) => ({
|
|
1061
|
+
section,
|
|
1062
|
+
key: section.key
|
|
1063
|
+
}),
|
|
1064
|
+
getItemType: (option) => option.type === "section" ? "section" : "item"
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
structure
|
|
1068
|
+
)
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
function registerSelect(loader) {
|
|
1072
|
+
registerComponentHelper(loader, BaseSelect, {
|
|
1073
|
+
name: SELECT_NAME,
|
|
1074
|
+
displayName: "BaseSelect",
|
|
1075
|
+
importPath: "@plasmicpkgs/react-aria/registerSelect",
|
|
1076
|
+
importName: "BaseSelect",
|
|
1077
|
+
props: {
|
|
1078
|
+
options: makeOptionsPropType(),
|
|
1079
|
+
placeholder: {
|
|
1080
|
+
type: "string"
|
|
1081
|
+
},
|
|
1082
|
+
isDisabled: {
|
|
1083
|
+
type: "boolean"
|
|
1084
|
+
},
|
|
1085
|
+
value: makeValuePropType(),
|
|
1086
|
+
onChange: {
|
|
1087
|
+
type: "eventHandler",
|
|
1088
|
+
argTypes: [{ name: "value", type: "string" }]
|
|
1089
|
+
},
|
|
1090
|
+
previewOpen: {
|
|
1091
|
+
type: "boolean",
|
|
1092
|
+
displayName: "Preview opened?",
|
|
1093
|
+
description: "Preview opened state while designing in Plasmic editor",
|
|
1094
|
+
editOnly: true
|
|
1095
|
+
},
|
|
1096
|
+
onOpenChange: {
|
|
1097
|
+
type: "eventHandler",
|
|
1098
|
+
argTypes: [{ name: "isOpen", type: "boolean" }]
|
|
1099
|
+
},
|
|
1100
|
+
// optionValue: {
|
|
1101
|
+
// type: "string",
|
|
1102
|
+
// displayName: "Field key for an option's value",
|
|
1103
|
+
// hidden: (ps) =>
|
|
1104
|
+
// !ps.options ||
|
|
1105
|
+
// !ps.options[0] ||
|
|
1106
|
+
// typeof ps.options[0] === "string" ||
|
|
1107
|
+
// "value" in ps.options[0],
|
|
1108
|
+
// exprHint:
|
|
1109
|
+
// "Return a function that takes in an option object, and returns the key to use",
|
|
1110
|
+
// },
|
|
1111
|
+
// optionText: {
|
|
1112
|
+
// type: "string",
|
|
1113
|
+
// displayName: "Field key for an option's text value",
|
|
1114
|
+
// hidden: (ps) =>
|
|
1115
|
+
// !ps.options ||
|
|
1116
|
+
// !ps.options[0] ||
|
|
1117
|
+
// typeof ps.options[0] === "string" ||
|
|
1118
|
+
// "value" in ps.options[0],
|
|
1119
|
+
// exprHint:
|
|
1120
|
+
// "Return a function that takes in an option object, and returns the text value to use",
|
|
1121
|
+
// },
|
|
1122
|
+
// optionDisabled: {
|
|
1123
|
+
// type: "string",
|
|
1124
|
+
// displayName: "Field key for whether an option is disabled",
|
|
1125
|
+
// hidden: (ps) =>
|
|
1126
|
+
// !ps.options ||
|
|
1127
|
+
// !ps.options[0] ||
|
|
1128
|
+
// typeof ps.options[0] === "string" ||
|
|
1129
|
+
// "value" in ps.options[0],
|
|
1130
|
+
// exprHint:
|
|
1131
|
+
// "Return a function that takes in an option object, and returns true if option should be disabled",
|
|
1132
|
+
// },
|
|
1133
|
+
structure: {
|
|
1134
|
+
type: "slot"
|
|
1135
|
+
},
|
|
1136
|
+
// renderOption: {
|
|
1137
|
+
// type: "slot",
|
|
1138
|
+
// displayName: "Custom render option",
|
|
1139
|
+
// renderPropParams: ["item"],
|
|
1140
|
+
// hidePlaceholder: true
|
|
1141
|
+
// },
|
|
1142
|
+
name: {
|
|
1143
|
+
type: "string",
|
|
1144
|
+
displayName: "Form field key",
|
|
1145
|
+
description: "Name of the input, when submitting in an HTML form",
|
|
1146
|
+
advanced: true
|
|
1147
|
+
},
|
|
1148
|
+
"aria-label": {
|
|
1149
|
+
type: "string",
|
|
1150
|
+
displayName: "Aria Label",
|
|
1151
|
+
description: "Label for this input, if no visible label is used",
|
|
1152
|
+
advanced: true
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
states: {
|
|
1156
|
+
value: {
|
|
1157
|
+
type: "writable",
|
|
1158
|
+
valueProp: "value",
|
|
1159
|
+
onChangeProp: "onChange",
|
|
1160
|
+
variableType: "text"
|
|
1161
|
+
},
|
|
1162
|
+
isOpen: {
|
|
1163
|
+
type: "readonly",
|
|
1164
|
+
onChangeProp: "onOpenChange",
|
|
1165
|
+
variableType: "boolean"
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
registerComponentHelper(loader, SelectValue, {
|
|
1170
|
+
name: makeComponentName("select-value"),
|
|
1171
|
+
displayName: "Base Selected Value",
|
|
1172
|
+
importPath: "@plasmicpkgs/react-aria/registerSelect",
|
|
1173
|
+
importName: "SelectValue",
|
|
1174
|
+
parentComponentName: SELECT_NAME,
|
|
1175
|
+
props: {}
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
function registerAll(loader) {
|
|
1180
|
+
registerSelect(loader);
|
|
1181
|
+
registerComboBox(loader);
|
|
1182
|
+
registerButton(loader);
|
|
1183
|
+
registerLabel(loader);
|
|
1184
|
+
registerListBox(loader);
|
|
1185
|
+
registerPopover(loader);
|
|
1186
|
+
registerInput(loader);
|
|
1187
|
+
registerSection(loader);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
export { registerAll };
|
|
1191
|
+
//# sourceMappingURL=react-aria.esm.js.map
|