@plasmicpkgs/react-aria 0.0.49 → 0.0.51
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/.tsbuildinfo +1 -1
- package/dist/ListBoxItemIdManager.d.ts +13 -0
- package/dist/common.d.ts +0 -2
- package/dist/contexts.d.ts +4 -5
- package/dist/react-aria.esm.js +712 -843
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +710 -841
- package/dist/react-aria.js.map +1 -1
- package/dist/registerComboBox.d.ts +9 -17
- package/dist/registerListBox.d.ts +16 -6
- package/dist/registerListBoxItem.d.ts +13 -3
- package/dist/registerSection.d.ts +2 -4
- package/dist/registerSelect.d.ts +9 -18
- package/package.json +2 -2
- package/skinny/ListBoxItemIdManager.d.ts +13 -0
- package/skinny/{common-fa69e9b3.esm.js → common-8ca74873.esm.js} +4 -72
- package/skinny/common-8ca74873.esm.js.map +1 -0
- package/skinny/{common-bfedaf7d.cjs.js → common-c892c339.cjs.js} +4 -82
- package/skinny/common-c892c339.cjs.js.map +1 -0
- package/skinny/common.d.ts +0 -2
- package/skinny/contexts-0a2977d8.esm.js +15 -0
- package/skinny/contexts-0a2977d8.esm.js.map +1 -0
- package/skinny/{contexts-0dec6156.cjs.js → contexts-c26d68f8.cjs.js} +3 -9
- package/skinny/contexts-c26d68f8.cjs.js.map +1 -0
- package/skinny/contexts.d.ts +4 -5
- package/skinny/{interaction-variant-utils-abd0c319.esm.js → interaction-variant-utils-1d94d073.esm.js} +2 -2
- package/skinny/interaction-variant-utils-1d94d073.esm.js.map +1 -0
- package/skinny/{interaction-variant-utils-36f1b397.cjs.js → interaction-variant-utils-9a869063.cjs.js} +2 -2
- package/skinny/interaction-variant-utils-9a869063.cjs.js.map +1 -0
- package/skinny/registerButton.cjs.js +6 -4
- package/skinny/registerButton.cjs.js.map +1 -1
- package/skinny/registerButton.esm.js +4 -2
- package/skinny/registerButton.esm.js.map +1 -1
- package/skinny/registerCheckbox.cjs.js +6 -5
- package/skinny/registerCheckbox.cjs.js.map +1 -1
- package/skinny/registerCheckbox.esm.js +4 -3
- package/skinny/registerCheckbox.esm.js.map +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +8 -7
- package/skinny/registerCheckboxGroup.cjs.js.map +1 -1
- package/skinny/registerCheckboxGroup.esm.js +5 -4
- package/skinny/registerCheckboxGroup.esm.js.map +1 -1
- package/skinny/registerComboBox.cjs.js +73 -253
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.d.ts +9 -17
- package/skinny/registerComboBox.esm.js +74 -254
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerDescription.cjs.js +2 -2
- package/skinny/registerDescription.cjs.js.map +1 -1
- package/skinny/registerDescription.esm.js +1 -1
- package/skinny/registerDialogTrigger.cjs.js +6 -5
- package/skinny/registerDialogTrigger.cjs.js.map +1 -1
- package/skinny/registerDialogTrigger.esm.js +4 -3
- package/skinny/registerDialogTrigger.esm.js.map +1 -1
- package/skinny/registerFieldError.cjs.js +3 -3
- package/skinny/registerFieldError.cjs.js.map +1 -1
- package/skinny/registerFieldError.esm.js +1 -1
- package/skinny/registerForm.cjs.js +3 -3
- package/skinny/registerForm.cjs.js.map +1 -1
- package/skinny/registerForm.esm.js +1 -1
- package/skinny/registerInput.cjs.js +7 -6
- package/skinny/registerInput.cjs.js.map +1 -1
- package/skinny/registerInput.esm.js +5 -4
- package/skinny/registerInput.esm.js.map +1 -1
- package/skinny/registerLabel.cjs.js +3 -3
- package/skinny/registerLabel.cjs.js.map +1 -1
- package/skinny/registerLabel.esm.js +1 -1
- package/skinny/registerListBox-85f61377.esm.js +321 -0
- package/skinny/registerListBox-85f61377.esm.js.map +1 -0
- package/skinny/registerListBox-96ae5783.cjs.js +331 -0
- package/skinny/registerListBox-96ae5783.cjs.js.map +1 -0
- package/skinny/registerListBox.cjs.js +7 -7
- package/skinny/registerListBox.d.ts +16 -6
- package/skinny/registerListBox.esm.js +6 -7
- package/skinny/registerListBox.esm.js.map +1 -1
- package/skinny/registerListBoxItem.cjs.js +96 -13
- package/skinny/registerListBoxItem.cjs.js.map +1 -1
- package/skinny/registerListBoxItem.d.ts +13 -3
- package/skinny/registerListBoxItem.esm.js +95 -12
- package/skinny/registerListBoxItem.esm.js.map +1 -1
- package/skinny/registerModal.cjs.js +5 -4
- package/skinny/registerModal.cjs.js.map +1 -1
- package/skinny/registerModal.esm.js +3 -2
- package/skinny/registerModal.esm.js.map +1 -1
- package/skinny/registerPopover.cjs.js +5 -6
- package/skinny/registerPopover.cjs.js.map +1 -1
- package/skinny/registerPopover.esm.js +3 -4
- package/skinny/registerPopover.esm.js.map +1 -1
- package/skinny/registerRadio.cjs.js +6 -5
- package/skinny/registerRadio.cjs.js.map +1 -1
- package/skinny/registerRadio.esm.js +4 -3
- package/skinny/registerRadio.esm.js.map +1 -1
- package/skinny/registerRadioGroup.cjs.js +8 -7
- package/skinny/registerRadioGroup.cjs.js.map +1 -1
- package/skinny/registerRadioGroup.esm.js +5 -4
- package/skinny/registerRadioGroup.esm.js.map +1 -1
- package/skinny/registerSection.cjs.js +30 -25
- package/skinny/registerSection.cjs.js.map +1 -1
- package/skinny/registerSection.d.ts +2 -4
- package/skinny/registerSection.esm.js +29 -24
- package/skinny/registerSection.esm.js.map +1 -1
- package/skinny/registerSelect.cjs.js +65 -88
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.d.ts +9 -18
- package/skinny/registerSelect.esm.js +61 -84
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerSlider.cjs.js +9 -9
- package/skinny/registerSlider.cjs.js.map +1 -1
- package/skinny/registerSlider.esm.js +5 -5
- package/skinny/registerSliderOutput.cjs.js +4 -4
- package/skinny/registerSliderOutput.cjs.js.map +1 -1
- package/skinny/registerSliderOutput.esm.js +2 -2
- package/skinny/registerSliderThumb.cjs.js +23 -7
- package/skinny/registerSliderThumb.cjs.js.map +1 -1
- package/skinny/registerSliderThumb.esm.js +21 -5
- package/skinny/registerSliderThumb.esm.js.map +1 -1
- package/skinny/registerSliderTrack.cjs.js +7 -7
- package/skinny/registerSliderTrack.cjs.js.map +1 -1
- package/skinny/registerSliderTrack.esm.js +3 -3
- package/skinny/registerSwitch.cjs.js +6 -5
- package/skinny/registerSwitch.cjs.js.map +1 -1
- package/skinny/registerSwitch.esm.js +4 -3
- package/skinny/registerSwitch.esm.js.map +1 -1
- package/skinny/registerText.cjs.js +3 -3
- package/skinny/registerText.cjs.js.map +1 -1
- package/skinny/registerText.esm.js +1 -1
- package/skinny/registerTextArea.cjs.js +6 -5
- package/skinny/registerTextArea.cjs.js.map +1 -1
- package/skinny/registerTextArea.esm.js +4 -3
- package/skinny/registerTextArea.esm.js.map +1 -1
- package/skinny/registerTextField.cjs.js +8 -7
- package/skinny/registerTextField.cjs.js.map +1 -1
- package/skinny/registerTextField.esm.js +5 -4
- package/skinny/registerTextField.esm.js.map +1 -1
- package/skinny/registerTooltip.cjs.js +2 -2
- package/skinny/registerTooltip.cjs.js.map +1 -1
- package/skinny/registerTooltip.esm.js +1 -1
- package/skinny/utils-8dbb4d1f.cjs.js +79 -0
- package/skinny/utils-8dbb4d1f.cjs.js.map +1 -0
- package/skinny/utils-c7662a47.esm.js +69 -0
- package/skinny/utils-c7662a47.esm.js.map +1 -0
- package/dist/option-utils.d.ts +0 -42
- package/dist/registerHeader.d.ts +0 -5
- package/skinny/ErrorBoundary-c6b111d3.esm.js +0 -20
- package/skinny/ErrorBoundary-c6b111d3.esm.js.map +0 -1
- package/skinny/ErrorBoundary-e9b86248.cjs.js +0 -22
- package/skinny/ErrorBoundary-e9b86248.cjs.js.map +0 -1
- package/skinny/common-bfedaf7d.cjs.js.map +0 -1
- package/skinny/common-fa69e9b3.esm.js.map +0 -1
- package/skinny/contexts-0dec6156.cjs.js.map +0 -1
- package/skinny/contexts-9a8234bf.esm.js +0 -17
- package/skinny/contexts-9a8234bf.esm.js.map +0 -1
- package/skinny/interaction-variant-utils-36f1b397.cjs.js.map +0 -1
- package/skinny/interaction-variant-utils-abd0c319.esm.js.map +0 -1
- package/skinny/option-utils.d.ts +0 -42
- package/skinny/registerHeader.cjs.js +0 -55
- package/skinny/registerHeader.cjs.js.map +0 -1
- package/skinny/registerHeader.d.ts +0 -5
- package/skinny/registerHeader.esm.js +0 -48
- package/skinny/registerHeader.esm.js.map +0 -1
- package/skinny/registerListBox-b3f2891a.esm.js +0 -298
- package/skinny/registerListBox-b3f2891a.esm.js.map +0 -1
- package/skinny/registerListBox-f4801dbd.cjs.js +0 -310
- package/skinny/registerListBox-f4801dbd.cjs.js.map +0 -1
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { mergeProps } from '@react-aria/utils';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ListBox } from 'react-aria-components';
|
|
4
|
-
import { a as makeComponentName, r as registerComponentHelper, h as hasParent } from './common-fa69e9b3.esm.js';
|
|
5
|
-
import { a as PlasmicListBoxContext, f as PlasmicSectionContext, g as PlasmicItemContext } from './contexts-9a8234bf.esm.js';
|
|
6
|
-
import { registerListBoxItem, makeDefaultListBoxItemChildren } from './registerListBoxItem.esm.js';
|
|
7
|
-
import { registerSection } from './registerSection.esm.js';
|
|
8
|
-
|
|
9
|
-
function useStrictOptions(props) {
|
|
10
|
-
const { options, optionInfo } = props;
|
|
11
|
-
return React.useMemo(() => {
|
|
12
|
-
return deriveStrictOptions({ options, optionInfo });
|
|
13
|
-
}, [options, optionInfo]);
|
|
14
|
-
}
|
|
15
|
-
function deriveStrictOptions(props) {
|
|
16
|
-
var _a;
|
|
17
|
-
const { options, optionInfo } = props;
|
|
18
|
-
let sectionCount = 0;
|
|
19
|
-
const makeStrict = (op) => {
|
|
20
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
21
|
-
if (!op) {
|
|
22
|
-
return void 0;
|
|
23
|
-
} else if (typeof op === "string" || typeof op === "number") {
|
|
24
|
-
const item = {
|
|
25
|
-
id: op
|
|
26
|
-
};
|
|
27
|
-
return item;
|
|
28
|
-
} else if (optionInfo) {
|
|
29
|
-
const info = optionInfo(op);
|
|
30
|
-
if (info.type === "option-group") {
|
|
31
|
-
const section = {
|
|
32
|
-
type: "option-group",
|
|
33
|
-
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),
|
|
34
|
-
label: info.label,
|
|
35
|
-
key: `option-group-${sectionCount}`
|
|
36
|
-
};
|
|
37
|
-
sectionCount += 1;
|
|
38
|
-
return section;
|
|
39
|
-
} else {
|
|
40
|
-
let item = info;
|
|
41
|
-
if (!("id" in item)) {
|
|
42
|
-
item = {
|
|
43
|
-
type: "option",
|
|
44
|
-
id: JSON.stringify(item)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return item;
|
|
48
|
-
}
|
|
49
|
-
} else if (typeof op === "object") {
|
|
50
|
-
if ("items" in op) {
|
|
51
|
-
const section = {
|
|
52
|
-
type: "option-group",
|
|
53
|
-
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),
|
|
54
|
-
label: op.label,
|
|
55
|
-
key: `option-group-${sectionCount}`
|
|
56
|
-
};
|
|
57
|
-
sectionCount += 1;
|
|
58
|
-
return section;
|
|
59
|
-
} else {
|
|
60
|
-
let item = op;
|
|
61
|
-
if (!("id" in item)) {
|
|
62
|
-
item = {
|
|
63
|
-
type: "option",
|
|
64
|
-
id: JSON.stringify(item)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return item;
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
return void 0;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
|
|
74
|
-
const optionText = (op) => {
|
|
75
|
-
var _a2;
|
|
76
|
-
return (_a2 = op.label) != null ? _a2 : op.id;
|
|
77
|
-
};
|
|
78
|
-
return { options: strictOptions, optionText };
|
|
79
|
-
}
|
|
80
|
-
function flattenOptions(options) {
|
|
81
|
-
if (!options) {
|
|
82
|
-
return [];
|
|
83
|
-
} else {
|
|
84
|
-
return options.flatMap(
|
|
85
|
-
(op) => {
|
|
86
|
-
var _a;
|
|
87
|
-
return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function makeOptionsPropType() {
|
|
93
|
-
const type = {
|
|
94
|
-
type: "array",
|
|
95
|
-
itemType: {
|
|
96
|
-
type: "object",
|
|
97
|
-
nameFunc: (item) => item.label || item.id,
|
|
98
|
-
fields: {
|
|
99
|
-
type: {
|
|
100
|
-
type: "choice",
|
|
101
|
-
options: [
|
|
102
|
-
{ value: "option", label: "Option" },
|
|
103
|
-
{ value: "option-group", label: "Option Group" }
|
|
104
|
-
],
|
|
105
|
-
defaultValue: "option"
|
|
106
|
-
},
|
|
107
|
-
id: {
|
|
108
|
-
type: "string",
|
|
109
|
-
hidden: (_ps, _ctx, { item }) => item.type !== "option"
|
|
110
|
-
},
|
|
111
|
-
label: "string",
|
|
112
|
-
items: {
|
|
113
|
-
type: "array",
|
|
114
|
-
displayName: "Options",
|
|
115
|
-
hidden: (_ps, _ctx, { item }) => {
|
|
116
|
-
return item.type !== "option-group";
|
|
117
|
-
},
|
|
118
|
-
itemType: {
|
|
119
|
-
type: "object",
|
|
120
|
-
nameFunc: (item) => item.label || item.id,
|
|
121
|
-
fields: {
|
|
122
|
-
id: "string",
|
|
123
|
-
label: "string"
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
defaultValue: [
|
|
130
|
-
{
|
|
131
|
-
id: "option1",
|
|
132
|
-
label: "Option 1",
|
|
133
|
-
type: "option"
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: "option2",
|
|
137
|
-
label: "Option 2",
|
|
138
|
-
type: "option"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
label: "Section 1",
|
|
142
|
-
type: "option-group",
|
|
143
|
-
items: [
|
|
144
|
-
{
|
|
145
|
-
id: "section-1-1",
|
|
146
|
-
label: "Section item 1",
|
|
147
|
-
type: "option"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
id: "section-1-2",
|
|
151
|
-
label: "Section item 2",
|
|
152
|
-
type: "option"
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
};
|
|
158
|
-
return type;
|
|
159
|
-
}
|
|
160
|
-
function makeValuePropType() {
|
|
161
|
-
const type = {
|
|
162
|
-
type: "choice",
|
|
163
|
-
options: (ps) => {
|
|
164
|
-
const { options, optionText } = deriveStrictOptions(ps);
|
|
165
|
-
return flattenOptions(options).map((op) => ({
|
|
166
|
-
value: op.id,
|
|
167
|
-
label: optionText(op)
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
return type;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
var __defProp = Object.defineProperty;
|
|
175
|
-
var __defProps = Object.defineProperties;
|
|
176
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
177
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
178
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
179
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
180
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
181
|
-
var __spreadValues = (a, b) => {
|
|
182
|
-
for (var prop in b || (b = {}))
|
|
183
|
-
if (__hasOwnProp.call(b, prop))
|
|
184
|
-
__defNormalProp(a, prop, b[prop]);
|
|
185
|
-
if (__getOwnPropSymbols)
|
|
186
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
187
|
-
if (__propIsEnum.call(b, prop))
|
|
188
|
-
__defNormalProp(a, prop, b[prop]);
|
|
189
|
-
}
|
|
190
|
-
return a;
|
|
191
|
-
};
|
|
192
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
193
|
-
var __objRest = (source, exclude) => {
|
|
194
|
-
var target = {};
|
|
195
|
-
for (var prop in source)
|
|
196
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
197
|
-
target[prop] = source[prop];
|
|
198
|
-
if (source != null && __getOwnPropSymbols)
|
|
199
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
200
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
201
|
-
target[prop] = source[prop];
|
|
202
|
-
}
|
|
203
|
-
return target;
|
|
204
|
-
};
|
|
205
|
-
function BaseListBox(props) {
|
|
206
|
-
const contextProps = React.useContext(PlasmicListBoxContext);
|
|
207
|
-
const isStandalone = !contextProps;
|
|
208
|
-
const _a = props, { options: _rawOptions, setControlContextData } = _a, rest = __objRest(_a, ["options", "setControlContextData"]);
|
|
209
|
-
const { options } = useStrictOptions(props);
|
|
210
|
-
const _b = mergeProps(
|
|
211
|
-
contextProps,
|
|
212
|
-
rest,
|
|
213
|
-
isStandalone ? { items: options } : {}
|
|
214
|
-
), { renderItem, renderSection } = _b, mergedProps = __objRest(_b, ["renderItem", "renderSection"]);
|
|
215
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
216
|
-
parent: isStandalone ? void 0 : {}
|
|
217
|
-
});
|
|
218
|
-
return /* @__PURE__ */ React.createElement(ListBox, __spreadValues({}, mergedProps), (item) => {
|
|
219
|
-
var _a2;
|
|
220
|
-
if (item.type === "option-group") {
|
|
221
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
222
|
-
PlasmicSectionContext.Provider,
|
|
223
|
-
{
|
|
224
|
-
value: {
|
|
225
|
-
renderItem,
|
|
226
|
-
key: (_a2 = item.key) != null ? _a2 : item.label,
|
|
227
|
-
section: item
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
renderSection == null ? void 0 : renderSection(item)
|
|
231
|
-
));
|
|
232
|
-
} else {
|
|
233
|
-
return /* @__PURE__ */ React.createElement(PlasmicItemContext.Provider, { value: item }, renderItem == null ? void 0 : renderItem(item));
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
const LIST_BOX_COMPONENT_NAME = makeComponentName("listbox");
|
|
238
|
-
function registerListBox(loader, overrides) {
|
|
239
|
-
const listBoxItemMeta = registerListBoxItem(loader, {
|
|
240
|
-
parentComponentName: LIST_BOX_COMPONENT_NAME
|
|
241
|
-
});
|
|
242
|
-
const sectionMeta = registerSection(loader, {
|
|
243
|
-
parentComponentName: LIST_BOX_COMPONENT_NAME
|
|
244
|
-
});
|
|
245
|
-
registerComponentHelper(
|
|
246
|
-
loader,
|
|
247
|
-
BaseListBox,
|
|
248
|
-
{
|
|
249
|
-
name: LIST_BOX_COMPONENT_NAME,
|
|
250
|
-
displayName: "Aria ListBox",
|
|
251
|
-
importPath: "@plasmicpkgs/react-aria/skinny/registerListBox",
|
|
252
|
-
importName: "BaseListBox",
|
|
253
|
-
defaultStyles: {
|
|
254
|
-
width: "250px",
|
|
255
|
-
borderWidth: "1px",
|
|
256
|
-
borderStyle: "solid",
|
|
257
|
-
borderColor: "black"
|
|
258
|
-
},
|
|
259
|
-
props: {
|
|
260
|
-
options: __spreadProps(__spreadValues({}, makeOptionsPropType()), {
|
|
261
|
-
displayName: "Items",
|
|
262
|
-
hidden: hasParent
|
|
263
|
-
}),
|
|
264
|
-
renderItem: {
|
|
265
|
-
type: "slot",
|
|
266
|
-
displayName: "Render Item",
|
|
267
|
-
renderPropParams: ["itemProps"],
|
|
268
|
-
defaultValue: {
|
|
269
|
-
type: "component",
|
|
270
|
-
name: listBoxItemMeta.name,
|
|
271
|
-
props: {
|
|
272
|
-
children: makeDefaultListBoxItemChildren(
|
|
273
|
-
"Item (itemProps.label)",
|
|
274
|
-
"Connect with `itemProps` in the data picker to display list box items"
|
|
275
|
-
)
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
renderSection: {
|
|
280
|
-
type: "slot",
|
|
281
|
-
displayName: "Render Section",
|
|
282
|
-
renderPropParams: ["sectionProps"],
|
|
283
|
-
defaultValue: {
|
|
284
|
-
type: "component",
|
|
285
|
-
name: sectionMeta.name,
|
|
286
|
-
styles: {
|
|
287
|
-
backgroundColor: "#F4FAFF"
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
overrides
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export { BaseListBox as B, LIST_BOX_COMPONENT_NAME as L, makeValuePropType as a, flattenOptions as f, makeOptionsPropType as m, registerListBox as r, useStrictOptions as u };
|
|
298
|
-
//# sourceMappingURL=registerListBox-b3f2891a.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox-b3f2891a.esm.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport { hasParent } from \"./common\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any>,\n HasControlContextData {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, setControlContextData, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n setControlContextData?.({\n parent: isStandalone ? undefined : {},\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: hasParent,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EA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
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('@react-aria/utils');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var reactAriaComponents = require('react-aria-components');
|
|
6
|
-
var common = require('./common-bfedaf7d.cjs.js');
|
|
7
|
-
var contexts = require('./contexts-0dec6156.cjs.js');
|
|
8
|
-
var registerListBoxItem = require('./registerListBoxItem.cjs.js');
|
|
9
|
-
var registerSection = require('./registerSection.cjs.js');
|
|
10
|
-
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
-
|
|
15
|
-
function useStrictOptions(props) {
|
|
16
|
-
const { options, optionInfo } = props;
|
|
17
|
-
return React__default.default.useMemo(() => {
|
|
18
|
-
return deriveStrictOptions({ options, optionInfo });
|
|
19
|
-
}, [options, optionInfo]);
|
|
20
|
-
}
|
|
21
|
-
function deriveStrictOptions(props) {
|
|
22
|
-
var _a;
|
|
23
|
-
const { options, optionInfo } = props;
|
|
24
|
-
let sectionCount = 0;
|
|
25
|
-
const makeStrict = (op) => {
|
|
26
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
27
|
-
if (!op) {
|
|
28
|
-
return void 0;
|
|
29
|
-
} else if (typeof op === "string" || typeof op === "number") {
|
|
30
|
-
const item = {
|
|
31
|
-
id: op
|
|
32
|
-
};
|
|
33
|
-
return item;
|
|
34
|
-
} else if (optionInfo) {
|
|
35
|
-
const info = optionInfo(op);
|
|
36
|
-
if (info.type === "option-group") {
|
|
37
|
-
const section = {
|
|
38
|
-
type: "option-group",
|
|
39
|
-
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),
|
|
40
|
-
label: info.label,
|
|
41
|
-
key: `option-group-${sectionCount}`
|
|
42
|
-
};
|
|
43
|
-
sectionCount += 1;
|
|
44
|
-
return section;
|
|
45
|
-
} else {
|
|
46
|
-
let item = info;
|
|
47
|
-
if (!("id" in item)) {
|
|
48
|
-
item = {
|
|
49
|
-
type: "option",
|
|
50
|
-
id: JSON.stringify(item)
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return item;
|
|
54
|
-
}
|
|
55
|
-
} else if (typeof op === "object") {
|
|
56
|
-
if ("items" in op) {
|
|
57
|
-
const section = {
|
|
58
|
-
type: "option-group",
|
|
59
|
-
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),
|
|
60
|
-
label: op.label,
|
|
61
|
-
key: `option-group-${sectionCount}`
|
|
62
|
-
};
|
|
63
|
-
sectionCount += 1;
|
|
64
|
-
return section;
|
|
65
|
-
} else {
|
|
66
|
-
let item = op;
|
|
67
|
-
if (!("id" in item)) {
|
|
68
|
-
item = {
|
|
69
|
-
type: "option",
|
|
70
|
-
id: JSON.stringify(item)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return item;
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
return void 0;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const strictOptions = (_a = options == null ? void 0 : options.map(makeStrict)) == null ? void 0 : _a.filter((x) => !!x);
|
|
80
|
-
const optionText = (op) => {
|
|
81
|
-
var _a2;
|
|
82
|
-
return (_a2 = op.label) != null ? _a2 : op.id;
|
|
83
|
-
};
|
|
84
|
-
return { options: strictOptions, optionText };
|
|
85
|
-
}
|
|
86
|
-
function flattenOptions(options) {
|
|
87
|
-
if (!options) {
|
|
88
|
-
return [];
|
|
89
|
-
} else {
|
|
90
|
-
return options.flatMap(
|
|
91
|
-
(op) => {
|
|
92
|
-
var _a;
|
|
93
|
-
return op.type === "option-group" ? (_a = op.items) != null ? _a : [] : op;
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function makeOptionsPropType() {
|
|
99
|
-
const type = {
|
|
100
|
-
type: "array",
|
|
101
|
-
itemType: {
|
|
102
|
-
type: "object",
|
|
103
|
-
nameFunc: (item) => item.label || item.id,
|
|
104
|
-
fields: {
|
|
105
|
-
type: {
|
|
106
|
-
type: "choice",
|
|
107
|
-
options: [
|
|
108
|
-
{ value: "option", label: "Option" },
|
|
109
|
-
{ value: "option-group", label: "Option Group" }
|
|
110
|
-
],
|
|
111
|
-
defaultValue: "option"
|
|
112
|
-
},
|
|
113
|
-
id: {
|
|
114
|
-
type: "string",
|
|
115
|
-
hidden: (_ps, _ctx, { item }) => item.type !== "option"
|
|
116
|
-
},
|
|
117
|
-
label: "string",
|
|
118
|
-
items: {
|
|
119
|
-
type: "array",
|
|
120
|
-
displayName: "Options",
|
|
121
|
-
hidden: (_ps, _ctx, { item }) => {
|
|
122
|
-
return item.type !== "option-group";
|
|
123
|
-
},
|
|
124
|
-
itemType: {
|
|
125
|
-
type: "object",
|
|
126
|
-
nameFunc: (item) => item.label || item.id,
|
|
127
|
-
fields: {
|
|
128
|
-
id: "string",
|
|
129
|
-
label: "string"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
defaultValue: [
|
|
136
|
-
{
|
|
137
|
-
id: "option1",
|
|
138
|
-
label: "Option 1",
|
|
139
|
-
type: "option"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
id: "option2",
|
|
143
|
-
label: "Option 2",
|
|
144
|
-
type: "option"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
label: "Section 1",
|
|
148
|
-
type: "option-group",
|
|
149
|
-
items: [
|
|
150
|
-
{
|
|
151
|
-
id: "section-1-1",
|
|
152
|
-
label: "Section item 1",
|
|
153
|
-
type: "option"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
id: "section-1-2",
|
|
157
|
-
label: "Section item 2",
|
|
158
|
-
type: "option"
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
};
|
|
164
|
-
return type;
|
|
165
|
-
}
|
|
166
|
-
function makeValuePropType() {
|
|
167
|
-
const type = {
|
|
168
|
-
type: "choice",
|
|
169
|
-
options: (ps) => {
|
|
170
|
-
const { options, optionText } = deriveStrictOptions(ps);
|
|
171
|
-
return flattenOptions(options).map((op) => ({
|
|
172
|
-
value: op.id,
|
|
173
|
-
label: optionText(op)
|
|
174
|
-
}));
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
return type;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var __defProp = Object.defineProperty;
|
|
181
|
-
var __defProps = Object.defineProperties;
|
|
182
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
183
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
184
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
185
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
186
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
187
|
-
var __spreadValues = (a, b) => {
|
|
188
|
-
for (var prop in b || (b = {}))
|
|
189
|
-
if (__hasOwnProp.call(b, prop))
|
|
190
|
-
__defNormalProp(a, prop, b[prop]);
|
|
191
|
-
if (__getOwnPropSymbols)
|
|
192
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
193
|
-
if (__propIsEnum.call(b, prop))
|
|
194
|
-
__defNormalProp(a, prop, b[prop]);
|
|
195
|
-
}
|
|
196
|
-
return a;
|
|
197
|
-
};
|
|
198
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
199
|
-
var __objRest = (source, exclude) => {
|
|
200
|
-
var target = {};
|
|
201
|
-
for (var prop in source)
|
|
202
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
203
|
-
target[prop] = source[prop];
|
|
204
|
-
if (source != null && __getOwnPropSymbols)
|
|
205
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
206
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
207
|
-
target[prop] = source[prop];
|
|
208
|
-
}
|
|
209
|
-
return target;
|
|
210
|
-
};
|
|
211
|
-
function BaseListBox(props) {
|
|
212
|
-
const contextProps = React__default.default.useContext(contexts.PlasmicListBoxContext);
|
|
213
|
-
const isStandalone = !contextProps;
|
|
214
|
-
const _a = props, { options: _rawOptions, setControlContextData } = _a, rest = __objRest(_a, ["options", "setControlContextData"]);
|
|
215
|
-
const { options } = useStrictOptions(props);
|
|
216
|
-
const _b = utils.mergeProps(
|
|
217
|
-
contextProps,
|
|
218
|
-
rest,
|
|
219
|
-
isStandalone ? { items: options } : {}
|
|
220
|
-
), { renderItem, renderSection } = _b, mergedProps = __objRest(_b, ["renderItem", "renderSection"]);
|
|
221
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
222
|
-
parent: isStandalone ? void 0 : {}
|
|
223
|
-
});
|
|
224
|
-
return /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.ListBox, __spreadValues({}, mergedProps), (item) => {
|
|
225
|
-
var _a2;
|
|
226
|
-
if (item.type === "option-group") {
|
|
227
|
-
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
228
|
-
contexts.PlasmicSectionContext.Provider,
|
|
229
|
-
{
|
|
230
|
-
value: {
|
|
231
|
-
renderItem,
|
|
232
|
-
key: (_a2 = item.key) != null ? _a2 : item.label,
|
|
233
|
-
section: item
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
renderSection == null ? void 0 : renderSection(item)
|
|
237
|
-
));
|
|
238
|
-
} else {
|
|
239
|
-
return /* @__PURE__ */ React__default.default.createElement(contexts.PlasmicItemContext.Provider, { value: item }, renderItem == null ? void 0 : renderItem(item));
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
const LIST_BOX_COMPONENT_NAME = common.makeComponentName("listbox");
|
|
244
|
-
function registerListBox(loader, overrides) {
|
|
245
|
-
const listBoxItemMeta = registerListBoxItem.registerListBoxItem(loader, {
|
|
246
|
-
parentComponentName: LIST_BOX_COMPONENT_NAME
|
|
247
|
-
});
|
|
248
|
-
const sectionMeta = registerSection.registerSection(loader, {
|
|
249
|
-
parentComponentName: LIST_BOX_COMPONENT_NAME
|
|
250
|
-
});
|
|
251
|
-
common.registerComponentHelper(
|
|
252
|
-
loader,
|
|
253
|
-
BaseListBox,
|
|
254
|
-
{
|
|
255
|
-
name: LIST_BOX_COMPONENT_NAME,
|
|
256
|
-
displayName: "Aria ListBox",
|
|
257
|
-
importPath: "@plasmicpkgs/react-aria/skinny/registerListBox",
|
|
258
|
-
importName: "BaseListBox",
|
|
259
|
-
defaultStyles: {
|
|
260
|
-
width: "250px",
|
|
261
|
-
borderWidth: "1px",
|
|
262
|
-
borderStyle: "solid",
|
|
263
|
-
borderColor: "black"
|
|
264
|
-
},
|
|
265
|
-
props: {
|
|
266
|
-
options: __spreadProps(__spreadValues({}, makeOptionsPropType()), {
|
|
267
|
-
displayName: "Items",
|
|
268
|
-
hidden: common.hasParent
|
|
269
|
-
}),
|
|
270
|
-
renderItem: {
|
|
271
|
-
type: "slot",
|
|
272
|
-
displayName: "Render Item",
|
|
273
|
-
renderPropParams: ["itemProps"],
|
|
274
|
-
defaultValue: {
|
|
275
|
-
type: "component",
|
|
276
|
-
name: listBoxItemMeta.name,
|
|
277
|
-
props: {
|
|
278
|
-
children: registerListBoxItem.makeDefaultListBoxItemChildren(
|
|
279
|
-
"Item (itemProps.label)",
|
|
280
|
-
"Connect with `itemProps` in the data picker to display list box items"
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
renderSection: {
|
|
286
|
-
type: "slot",
|
|
287
|
-
displayName: "Render Section",
|
|
288
|
-
renderPropParams: ["sectionProps"],
|
|
289
|
-
defaultValue: {
|
|
290
|
-
type: "component",
|
|
291
|
-
name: sectionMeta.name,
|
|
292
|
-
styles: {
|
|
293
|
-
backgroundColor: "#F4FAFF"
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
overrides
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
exports.BaseListBox = BaseListBox;
|
|
304
|
-
exports.LIST_BOX_COMPONENT_NAME = LIST_BOX_COMPONENT_NAME;
|
|
305
|
-
exports.flattenOptions = flattenOptions;
|
|
306
|
-
exports.makeOptionsPropType = makeOptionsPropType;
|
|
307
|
-
exports.makeValuePropType = makeValuePropType;
|
|
308
|
-
exports.registerListBox = registerListBox;
|
|
309
|
-
exports.useStrictOptions = useStrictOptions;
|
|
310
|
-
//# sourceMappingURL=registerListBox-f4801dbd.cjs.js.map
|