@plasmicapp/react-web 0.2.161 → 0.2.163
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 +22 -0
- package/dist/plume/collection-utils.d.ts +41 -0
- package/dist/plume/select/select.d.ts +12 -0
- package/dist/react-web.cjs.development.js +95 -13
- 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 +95 -13
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +4 -4
- package/skinny/dist/{collection-utils-b5d4be02.js → collection-utils-3496fd68.js} +66 -2
- package/skinny/dist/collection-utils-3496fd68.js.map +1 -0
- package/skinny/dist/plume/collection-utils.d.ts +41 -0
- package/skinny/dist/plume/menu/index.js +1 -1
- package/skinny/dist/plume/select/index.js +18 -10
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/select/select.d.ts +12 -0
- package/skinny/dist/plume/triggered-overlay/index.js +5 -3
- package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
- package/skinny/dist/collection-utils-b5d4be02.js.map +0 -1
package/dist/all.d.ts
CHANGED
|
@@ -1015,6 +1015,17 @@ interface SectionLikeProps {
|
|
|
1015
1015
|
* A list of items that belong in this group
|
|
1016
1016
|
*/
|
|
1017
1017
|
children?: React__default.ReactNode;
|
|
1018
|
+
}
|
|
1019
|
+
declare type ItemJson = LeafItemJson | SectionJson;
|
|
1020
|
+
declare type LeafItemJson = string | {
|
|
1021
|
+
value: string;
|
|
1022
|
+
label?: string;
|
|
1023
|
+
textValue?: string;
|
|
1024
|
+
isDisabled?: boolean;
|
|
1025
|
+
};
|
|
1026
|
+
interface SectionJson {
|
|
1027
|
+
title: string;
|
|
1028
|
+
children: ItemJson[];
|
|
1018
1029
|
}
|
|
1019
1030
|
|
|
1020
1031
|
interface BaseMenuGroupProps extends SectionLikeProps, StyleProps {
|
|
@@ -1191,6 +1202,15 @@ interface BaseSelectProps extends DOMProps, AriaLabelingProps, FocusableDOMProps
|
|
|
1191
1202
|
* List of Select.Options
|
|
1192
1203
|
*/
|
|
1193
1204
|
children?: React.ReactNode;
|
|
1205
|
+
/**
|
|
1206
|
+
* List of options as an array, instead of using `children` prop. If this
|
|
1207
|
+
* is passed in, then `children` is ignored.
|
|
1208
|
+
*
|
|
1209
|
+
* The options can be a list of strings, or a list of objects with
|
|
1210
|
+
* fields `value` (for the value of the option), `label` (for what's rendered
|
|
1211
|
+
* in the option), and `isDisabled` (if the option should be disabled).
|
|
1212
|
+
*/
|
|
1213
|
+
options?: ItemJson[];
|
|
1194
1214
|
/**
|
|
1195
1215
|
* Whether the Select is currently open
|
|
1196
1216
|
*/
|
|
@@ -1251,6 +1271,8 @@ interface SelectConfig<C extends AnyPlasmicClass> {
|
|
|
1251
1271
|
trigger: keyof PlasmicClassOverrides<C>;
|
|
1252
1272
|
overlay: keyof PlasmicClassOverrides<C>;
|
|
1253
1273
|
optionsContainer: keyof PlasmicClassOverrides<C>;
|
|
1274
|
+
OptionComponent?: React.ComponentType<ItemLikeProps>;
|
|
1275
|
+
OptionGroupComponent?: React.ComponentType<SectionLikeProps>;
|
|
1254
1276
|
}
|
|
1255
1277
|
interface SelectState {
|
|
1256
1278
|
open: () => void;
|
|
@@ -107,6 +107,32 @@ export interface SectionLikeProps {
|
|
|
107
107
|
children?: React.ReactNode;
|
|
108
108
|
}
|
|
109
109
|
declare type LoaderAwareSectionLikeProps = SectionLikeProps | PlasmicLoaderProps<SectionLikeProps>;
|
|
110
|
+
export declare type ItemJson = LeafItemJson | SectionJson;
|
|
111
|
+
export declare type LeafItemJson = string | {
|
|
112
|
+
value: string;
|
|
113
|
+
label?: string;
|
|
114
|
+
textValue?: string;
|
|
115
|
+
isDisabled?: boolean;
|
|
116
|
+
};
|
|
117
|
+
export interface SectionJson {
|
|
118
|
+
title: string;
|
|
119
|
+
children: ItemJson[];
|
|
120
|
+
}
|
|
121
|
+
export declare function deriveItemsFromProps(props: any, opts: {
|
|
122
|
+
itemPlumeType: string;
|
|
123
|
+
sectionPlumeType?: string;
|
|
124
|
+
invalidChildError?: string;
|
|
125
|
+
requireItemValue: boolean;
|
|
126
|
+
ItemComponent?: React.ComponentType<ItemLikeProps>;
|
|
127
|
+
SectionComponent?: React.ComponentType<SectionLikeProps>;
|
|
128
|
+
itemsProp?: string;
|
|
129
|
+
}): {
|
|
130
|
+
items: JSX.Element[];
|
|
131
|
+
disabledKeys: string[];
|
|
132
|
+
} | {
|
|
133
|
+
items: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>[];
|
|
134
|
+
disabledKeys: React.Key[];
|
|
135
|
+
};
|
|
110
136
|
/**
|
|
111
137
|
* Given children of a component like Select or Menu, derive the items
|
|
112
138
|
* that we will pass into the Collections API. These will be
|
|
@@ -124,6 +150,21 @@ export declare function deriveItemsFromChildren<T extends React.ReactElement>(ch
|
|
|
124
150
|
items: T[];
|
|
125
151
|
disabledKeys: React.Key[];
|
|
126
152
|
};
|
|
153
|
+
export declare function useDerivedItems(props: any, opts: {
|
|
154
|
+
itemPlumeType: string;
|
|
155
|
+
sectionPlumeType?: string;
|
|
156
|
+
invalidChildError?: string;
|
|
157
|
+
requireItemValue: boolean;
|
|
158
|
+
ItemComponent?: React.ComponentType<ItemLikeProps>;
|
|
159
|
+
SectionComponent?: React.ComponentType<SectionLikeProps>;
|
|
160
|
+
itemsProp?: string;
|
|
161
|
+
}): {
|
|
162
|
+
items: JSX.Element[];
|
|
163
|
+
disabledKeys: string[];
|
|
164
|
+
} | {
|
|
165
|
+
items: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>[];
|
|
166
|
+
disabledKeys: React.Key[];
|
|
167
|
+
};
|
|
127
168
|
export declare function useDerivedItemsFromChildren<T extends React.ReactElement>(children: React.ReactNode, opts: {
|
|
128
169
|
itemPlumeType: string;
|
|
129
170
|
sectionPlumeType?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Placement } from "@react-types/overlays";
|
|
2
2
|
import { AriaLabelingProps, DOMProps, FocusableDOMProps, FocusableProps, InputBase } from "@react-types/shared";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { ItemJson, ItemLikeProps, SectionLikeProps } from "../collection-utils";
|
|
4
5
|
import { AnyPlasmicClass, PlasmicClassArgs, PlasmicClassOverrides, PlasmicClassVariants, VariantDef } from "../plume-utils";
|
|
5
6
|
import { StyleProps } from "../props-utils";
|
|
6
7
|
export interface BaseSelectProps extends DOMProps, AriaLabelingProps, FocusableDOMProps, InputBase, FocusableProps, StyleProps {
|
|
@@ -20,6 +21,15 @@ export interface BaseSelectProps extends DOMProps, AriaLabelingProps, FocusableD
|
|
|
20
21
|
* List of Select.Options
|
|
21
22
|
*/
|
|
22
23
|
children?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* List of options as an array, instead of using `children` prop. If this
|
|
26
|
+
* is passed in, then `children` is ignored.
|
|
27
|
+
*
|
|
28
|
+
* The options can be a list of strings, or a list of objects with
|
|
29
|
+
* fields `value` (for the value of the option), `label` (for what's rendered
|
|
30
|
+
* in the option), and `isDisabled` (if the option should be disabled).
|
|
31
|
+
*/
|
|
32
|
+
options?: ItemJson[];
|
|
23
33
|
/**
|
|
24
34
|
* Whether the Select is currently open
|
|
25
35
|
*/
|
|
@@ -80,6 +90,8 @@ interface SelectConfig<C extends AnyPlasmicClass> {
|
|
|
80
90
|
trigger: keyof PlasmicClassOverrides<C>;
|
|
81
91
|
overlay: keyof PlasmicClassOverrides<C>;
|
|
82
92
|
optionsContainer: keyof PlasmicClassOverrides<C>;
|
|
93
|
+
OptionComponent?: React.ComponentType<ItemLikeProps>;
|
|
94
|
+
OptionGroupComponent?: React.ComponentType<SectionLikeProps>;
|
|
83
95
|
}
|
|
84
96
|
interface SelectState {
|
|
85
97
|
open: () => void;
|
|
@@ -25,6 +25,7 @@ var collections = require('@react-stately/collections');
|
|
|
25
25
|
var separator = require('@react-aria/separator');
|
|
26
26
|
var menu$1 = require('@react-stately/menu');
|
|
27
27
|
var interactions = require('@react-aria/interactions');
|
|
28
|
+
var host = require('@plasmicapp/host');
|
|
28
29
|
var listbox = require('@react-aria/listbox');
|
|
29
30
|
var select = require('@react-aria/select');
|
|
30
31
|
var select$1 = require('@react-stately/select');
|
|
@@ -3177,6 +3178,58 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
3177
3178
|
};
|
|
3178
3179
|
}
|
|
3179
3180
|
|
|
3181
|
+
function deriveItemsFromProps(props, opts) {
|
|
3182
|
+
if (opts.itemsProp && opts.itemsProp in props) {
|
|
3183
|
+
if (!opts.ItemComponent || !opts.SectionComponent) {
|
|
3184
|
+
throw new Error("You may need to re-generate your Plasmic* files");
|
|
3185
|
+
}
|
|
3186
|
+
var items = props[opts.itemsProp];
|
|
3187
|
+
return deriveItemsFromItemsProp(items, {
|
|
3188
|
+
ItemComponent: opts.ItemComponent,
|
|
3189
|
+
SectionComponent: opts.SectionComponent
|
|
3190
|
+
});
|
|
3191
|
+
} else {
|
|
3192
|
+
return deriveItemsFromChildren(props.children, opts);
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
function deriveItemsFromItemsProp(items, opts) {
|
|
3196
|
+
var _items$map;
|
|
3197
|
+
var ItemComponent = opts.ItemComponent,
|
|
3198
|
+
SectionComponent = opts.SectionComponent;
|
|
3199
|
+
var disabledKeys = [];
|
|
3200
|
+
var transform = function transform(item) {
|
|
3201
|
+
if (typeof item === "string") {
|
|
3202
|
+
return React__default.createElement(ItemComponent, {
|
|
3203
|
+
key: item,
|
|
3204
|
+
value: item
|
|
3205
|
+
}, item);
|
|
3206
|
+
} else if ("children" in item) {
|
|
3207
|
+
return React__default.createElement(SectionComponent, {
|
|
3208
|
+
key: item.title,
|
|
3209
|
+
title: item.title
|
|
3210
|
+
}, item.children.map(function (x) {
|
|
3211
|
+
return transform(x);
|
|
3212
|
+
}));
|
|
3213
|
+
} else {
|
|
3214
|
+
var _item$label;
|
|
3215
|
+
if (item.isDisabled) {
|
|
3216
|
+
disabledKeys.push(item.value);
|
|
3217
|
+
}
|
|
3218
|
+
return React__default.createElement(ItemComponent, {
|
|
3219
|
+
key: item.value,
|
|
3220
|
+
value: item.value,
|
|
3221
|
+
textValue: item.textValue,
|
|
3222
|
+
isDisabled: item.isDisabled
|
|
3223
|
+
}, (_item$label = item.label) != null ? _item$label : item.value);
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
return {
|
|
3227
|
+
items: (_items$map = items == null ? void 0 : items.map(function (x) {
|
|
3228
|
+
return transform(x);
|
|
3229
|
+
})) != null ? _items$map : [],
|
|
3230
|
+
disabledKeys: disabledKeys
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3180
3233
|
/**
|
|
3181
3234
|
* Given children of a component like Select or Menu, derive the items
|
|
3182
3235
|
* that we will pass into the Collections API. These will be
|
|
@@ -3253,6 +3306,28 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
3253
3306
|
disabledKeys: disabledKeys
|
|
3254
3307
|
};
|
|
3255
3308
|
}
|
|
3309
|
+
function useDerivedItems(props, opts) {
|
|
3310
|
+
var children = props.children;
|
|
3311
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
3312
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
3313
|
+
invalidChildError = opts.invalidChildError,
|
|
3314
|
+
requireItemValue = opts.requireItemValue,
|
|
3315
|
+
ItemComponent = opts.ItemComponent,
|
|
3316
|
+
SectionComponent = opts.SectionComponent,
|
|
3317
|
+
itemsProp = opts.itemsProp;
|
|
3318
|
+
var items = itemsProp ? props[itemsProp] : undefined;
|
|
3319
|
+
return React__default.useMemo(function () {
|
|
3320
|
+
return deriveItemsFromProps(props, {
|
|
3321
|
+
itemPlumeType: itemPlumeType,
|
|
3322
|
+
sectionPlumeType: sectionPlumeType,
|
|
3323
|
+
invalidChildError: invalidChildError,
|
|
3324
|
+
requireItemValue: requireItemValue,
|
|
3325
|
+
itemsProp: itemsProp,
|
|
3326
|
+
ItemComponent: ItemComponent,
|
|
3327
|
+
SectionComponent: SectionComponent
|
|
3328
|
+
});
|
|
3329
|
+
}, [children, items, itemPlumeType, sectionPlumeType, invalidChildError, requireItemValue, ItemComponent, SectionComponent]);
|
|
3330
|
+
}
|
|
3256
3331
|
function useDerivedItemsFromChildren(children, opts) {
|
|
3257
3332
|
var itemPlumeType = opts.itemPlumeType,
|
|
3258
3333
|
sectionPlumeType = opts.sectionPlumeType,
|
|
@@ -3803,18 +3878,20 @@ var COLLECTION_OPTS$1 = {
|
|
|
3803
3878
|
* with the secret derived `_node` prop. That means Option and OptionGroup
|
|
3804
3879
|
* render functions can assume that _node is passed in.
|
|
3805
3880
|
*/
|
|
3806
|
-
function useAriaSelectProps(props) {
|
|
3881
|
+
function useAriaSelectProps(props, config) {
|
|
3807
3882
|
var value = props.value,
|
|
3808
3883
|
defaultValue = props.defaultValue,
|
|
3809
|
-
children = props.children,
|
|
3810
3884
|
onChange = props.onChange,
|
|
3811
3885
|
rest = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
3812
|
-
var
|
|
3886
|
+
var _useDerivedItems = useDerivedItems(props, _extends({}, COLLECTION_OPTS$1, {
|
|
3813
3887
|
invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select",
|
|
3814
|
-
requireItemValue: true
|
|
3888
|
+
requireItemValue: true,
|
|
3889
|
+
ItemComponent: config.OptionComponent,
|
|
3890
|
+
SectionComponent: config.OptionGroupComponent,
|
|
3891
|
+
itemsProp: "options"
|
|
3815
3892
|
})),
|
|
3816
|
-
items =
|
|
3817
|
-
disabledKeys =
|
|
3893
|
+
items = _useDerivedItems.items,
|
|
3894
|
+
disabledKeys = _useDerivedItems.disabledKeys;
|
|
3818
3895
|
var collectionChildRenderer = React.useCallback(function (child) {
|
|
3819
3896
|
return renderAsCollectionChild(child, COLLECTION_OPTS$1);
|
|
3820
3897
|
}, []);
|
|
@@ -3845,7 +3922,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3845
3922
|
ref = null;
|
|
3846
3923
|
}
|
|
3847
3924
|
useEnsureSSRProvider();
|
|
3848
|
-
var _useAriaSelectProps = useAriaSelectProps(props),
|
|
3925
|
+
var _useAriaSelectProps = useAriaSelectProps(props, config),
|
|
3849
3926
|
ariaProps = _useAriaSelectProps.ariaProps;
|
|
3850
3927
|
var placement = props.placement;
|
|
3851
3928
|
var state = select$1.useSelectState(ariaProps);
|
|
@@ -3858,6 +3935,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3858
3935
|
autoFocus = props.autoFocus,
|
|
3859
3936
|
placeholder = props.placeholder,
|
|
3860
3937
|
selectedContent = props.selectedContent;
|
|
3938
|
+
var canvasCtx = host.usePlasmicCanvasContext();
|
|
3861
3939
|
var _useAriaSelect = select.useSelect(ariaProps, state, triggerRef),
|
|
3862
3940
|
triggerPressProps = _useAriaSelect.triggerProps,
|
|
3863
3941
|
menuProps = _useAriaSelect.menuProps;
|
|
@@ -3891,7 +3969,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3891
3969
|
ref: rootRef
|
|
3892
3970
|
}),
|
|
3893
3971
|
wrapChildren: function wrapChildren(children) {
|
|
3894
|
-
return React.createElement(React.Fragment, null, React.createElement(select.HiddenSelect, {
|
|
3972
|
+
return React.createElement(React.Fragment, null, !canvasCtx && React.createElement(select.HiddenSelect, {
|
|
3895
3973
|
state: state,
|
|
3896
3974
|
triggerRef: triggerRef,
|
|
3897
3975
|
name: name,
|
|
@@ -3899,7 +3977,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3899
3977
|
}), children);
|
|
3900
3978
|
}
|
|
3901
3979
|
}, _overrides[config.trigger] = {
|
|
3902
|
-
props: mergeProps(triggerProps, {
|
|
3980
|
+
props: mergeProps(canvasCtx ? {} : triggerProps, {
|
|
3903
3981
|
ref: triggerRef,
|
|
3904
3982
|
autoFocus: autoFocus,
|
|
3905
3983
|
disabled: !!isDisabled,
|
|
@@ -3991,13 +4069,14 @@ function ListBoxWrapper(props) {
|
|
|
3991
4069
|
menuProps = props.menuProps,
|
|
3992
4070
|
children = props.children;
|
|
3993
4071
|
var ref = React.useRef(null);
|
|
4072
|
+
var canvasCtx = host.usePlasmicCanvasContext();
|
|
3994
4073
|
var _useListBox = listbox.useListBox(_extends({}, menuProps, {
|
|
3995
4074
|
isVirtualized: false,
|
|
3996
4075
|
autoFocus: state.focusStrategy || true,
|
|
3997
4076
|
disallowEmptySelection: true
|
|
3998
4077
|
}), state, ref),
|
|
3999
4078
|
listBoxProps = _useListBox.listBoxProps;
|
|
4000
|
-
return React.cloneElement(children, mergeProps(children.props, listBoxProps, {
|
|
4079
|
+
return React.cloneElement(children, mergeProps(children.props, canvasCtx ? {} : listBoxProps, {
|
|
4001
4080
|
style: noOutline(),
|
|
4002
4081
|
ref: ref
|
|
4003
4082
|
}));
|
|
@@ -4019,6 +4098,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4019
4098
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
4020
4099
|
}
|
|
4021
4100
|
var children = props.children;
|
|
4101
|
+
var canvasCtx = host.usePlasmicCanvasContext();
|
|
4022
4102
|
var rootRef = React.useRef(null);
|
|
4023
4103
|
var onRef = mergeRefs(rootRef, outerRef);
|
|
4024
4104
|
// We pass in the Node secretly as an undocumented prop from <Select />
|
|
@@ -4033,7 +4113,8 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4033
4113
|
key: node.key,
|
|
4034
4114
|
shouldSelectOnPressUp: true,
|
|
4035
4115
|
shouldFocusOnHover: true,
|
|
4036
|
-
isVirtualized: false
|
|
4116
|
+
isVirtualized: false,
|
|
4117
|
+
shouldUseVirtualFocus: !!canvasCtx
|
|
4037
4118
|
}, state, rootRef),
|
|
4038
4119
|
optionProps = _useAriaOption.optionProps,
|
|
4039
4120
|
labelProps = _useAriaOption.labelProps;
|
|
@@ -4049,7 +4130,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4049
4130
|
}));
|
|
4050
4131
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
4051
4132
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
4052
|
-
props: mergeProps(optionProps, getStyleProps(props), {
|
|
4133
|
+
props: mergeProps(canvasCtx ? {} : optionProps, getStyleProps(props), {
|
|
4053
4134
|
ref: onRef,
|
|
4054
4135
|
style: noOutline()
|
|
4055
4136
|
})
|
|
@@ -4360,7 +4441,8 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
4360
4441
|
def: config.isPlacedRightVariant,
|
|
4361
4442
|
active: placementAxis === "right"
|
|
4362
4443
|
}));
|
|
4363
|
-
var
|
|
4444
|
+
var canvasCtx = host.usePlasmicCanvasContext();
|
|
4445
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.contentSlot] = canvasCtx ? children : React.createElement(focus.FocusScope, {
|
|
4364
4446
|
restoreFocus: true
|
|
4365
4447
|
}, React.createElement(overlays.DismissButton, {
|
|
4366
4448
|
onDismiss: state.close
|