@plasmicapp/react-web 0.2.161 → 0.2.162
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/react-web.esm.js
CHANGED
|
@@ -20,6 +20,7 @@ import { Item, Section } from '@react-stately/collections';
|
|
|
20
20
|
import { useSeparator } from '@react-aria/separator';
|
|
21
21
|
import { useMenuTriggerState } from '@react-stately/menu';
|
|
22
22
|
import { usePress } from '@react-aria/interactions';
|
|
23
|
+
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
23
24
|
import { useListBox, useOption, useListBoxSection } from '@react-aria/listbox';
|
|
24
25
|
import { useSelect as useSelect$1, HiddenSelect } from '@react-aria/select';
|
|
25
26
|
import { useSelectState } from '@react-stately/select';
|
|
@@ -3172,6 +3173,58 @@ function useCheckbox(plasmicClass, props, config, ref) {
|
|
|
3172
3173
|
};
|
|
3173
3174
|
}
|
|
3174
3175
|
|
|
3176
|
+
function deriveItemsFromProps(props, opts) {
|
|
3177
|
+
if (opts.itemsProp && opts.itemsProp in props) {
|
|
3178
|
+
if (!opts.ItemComponent || !opts.SectionComponent) {
|
|
3179
|
+
throw new Error("You may need to re-generate your Plasmic* files");
|
|
3180
|
+
}
|
|
3181
|
+
var items = props[opts.itemsProp];
|
|
3182
|
+
return deriveItemsFromItemsProp(items, {
|
|
3183
|
+
ItemComponent: opts.ItemComponent,
|
|
3184
|
+
SectionComponent: opts.SectionComponent
|
|
3185
|
+
});
|
|
3186
|
+
} else {
|
|
3187
|
+
return deriveItemsFromChildren(props.children, opts);
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
function deriveItemsFromItemsProp(items, opts) {
|
|
3191
|
+
var _items$map;
|
|
3192
|
+
var ItemComponent = opts.ItemComponent,
|
|
3193
|
+
SectionComponent = opts.SectionComponent;
|
|
3194
|
+
var disabledKeys = [];
|
|
3195
|
+
var transform = function transform(item) {
|
|
3196
|
+
if (typeof item === "string") {
|
|
3197
|
+
return React__default.createElement(ItemComponent, {
|
|
3198
|
+
key: item,
|
|
3199
|
+
value: item
|
|
3200
|
+
}, item);
|
|
3201
|
+
} else if ("children" in item) {
|
|
3202
|
+
return React__default.createElement(SectionComponent, {
|
|
3203
|
+
key: item.title,
|
|
3204
|
+
title: item.title
|
|
3205
|
+
}, item.children.map(function (x) {
|
|
3206
|
+
return transform(x);
|
|
3207
|
+
}));
|
|
3208
|
+
} else {
|
|
3209
|
+
var _item$label;
|
|
3210
|
+
if (item.isDisabled) {
|
|
3211
|
+
disabledKeys.push(item.value);
|
|
3212
|
+
}
|
|
3213
|
+
return React__default.createElement(ItemComponent, {
|
|
3214
|
+
key: item.value,
|
|
3215
|
+
value: item.value,
|
|
3216
|
+
textValue: item.textValue,
|
|
3217
|
+
isDisabled: item.isDisabled
|
|
3218
|
+
}, (_item$label = item.label) != null ? _item$label : item.value);
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
return {
|
|
3222
|
+
items: (_items$map = items == null ? void 0 : items.map(function (x) {
|
|
3223
|
+
return transform(x);
|
|
3224
|
+
})) != null ? _items$map : [],
|
|
3225
|
+
disabledKeys: disabledKeys
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3175
3228
|
/**
|
|
3176
3229
|
* Given children of a component like Select or Menu, derive the items
|
|
3177
3230
|
* that we will pass into the Collections API. These will be
|
|
@@ -3248,6 +3301,28 @@ function deriveItemsFromChildren(children, opts) {
|
|
|
3248
3301
|
disabledKeys: disabledKeys
|
|
3249
3302
|
};
|
|
3250
3303
|
}
|
|
3304
|
+
function useDerivedItems(props, opts) {
|
|
3305
|
+
var children = props.children;
|
|
3306
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
3307
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
3308
|
+
invalidChildError = opts.invalidChildError,
|
|
3309
|
+
requireItemValue = opts.requireItemValue,
|
|
3310
|
+
ItemComponent = opts.ItemComponent,
|
|
3311
|
+
SectionComponent = opts.SectionComponent,
|
|
3312
|
+
itemsProp = opts.itemsProp;
|
|
3313
|
+
var items = itemsProp ? props[itemsProp] : undefined;
|
|
3314
|
+
return React__default.useMemo(function () {
|
|
3315
|
+
return deriveItemsFromProps(props, {
|
|
3316
|
+
itemPlumeType: itemPlumeType,
|
|
3317
|
+
sectionPlumeType: sectionPlumeType,
|
|
3318
|
+
invalidChildError: invalidChildError,
|
|
3319
|
+
requireItemValue: requireItemValue,
|
|
3320
|
+
itemsProp: itemsProp,
|
|
3321
|
+
ItemComponent: ItemComponent,
|
|
3322
|
+
SectionComponent: SectionComponent
|
|
3323
|
+
});
|
|
3324
|
+
}, [children, items, itemPlumeType, sectionPlumeType, invalidChildError, requireItemValue, ItemComponent, SectionComponent]);
|
|
3325
|
+
}
|
|
3251
3326
|
function useDerivedItemsFromChildren(children, opts) {
|
|
3252
3327
|
var itemPlumeType = opts.itemPlumeType,
|
|
3253
3328
|
sectionPlumeType = opts.sectionPlumeType,
|
|
@@ -3798,18 +3873,20 @@ var COLLECTION_OPTS$1 = {
|
|
|
3798
3873
|
* with the secret derived `_node` prop. That means Option and OptionGroup
|
|
3799
3874
|
* render functions can assume that _node is passed in.
|
|
3800
3875
|
*/
|
|
3801
|
-
function useAriaSelectProps(props) {
|
|
3876
|
+
function useAriaSelectProps(props, config) {
|
|
3802
3877
|
var value = props.value,
|
|
3803
3878
|
defaultValue = props.defaultValue,
|
|
3804
|
-
children = props.children,
|
|
3805
3879
|
onChange = props.onChange,
|
|
3806
3880
|
rest = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
3807
|
-
var
|
|
3881
|
+
var _useDerivedItems = useDerivedItems(props, _extends({}, COLLECTION_OPTS$1, {
|
|
3808
3882
|
invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select",
|
|
3809
|
-
requireItemValue: true
|
|
3883
|
+
requireItemValue: true,
|
|
3884
|
+
ItemComponent: config.OptionComponent,
|
|
3885
|
+
SectionComponent: config.OptionGroupComponent,
|
|
3886
|
+
itemsProp: "options"
|
|
3810
3887
|
})),
|
|
3811
|
-
items =
|
|
3812
|
-
disabledKeys =
|
|
3888
|
+
items = _useDerivedItems.items,
|
|
3889
|
+
disabledKeys = _useDerivedItems.disabledKeys;
|
|
3813
3890
|
var collectionChildRenderer = useCallback(function (child) {
|
|
3814
3891
|
return renderAsCollectionChild(child, COLLECTION_OPTS$1);
|
|
3815
3892
|
}, []);
|
|
@@ -3840,7 +3917,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3840
3917
|
ref = null;
|
|
3841
3918
|
}
|
|
3842
3919
|
useEnsureSSRProvider();
|
|
3843
|
-
var _useAriaSelectProps = useAriaSelectProps(props),
|
|
3920
|
+
var _useAriaSelectProps = useAriaSelectProps(props, config),
|
|
3844
3921
|
ariaProps = _useAriaSelectProps.ariaProps;
|
|
3845
3922
|
var placement = props.placement;
|
|
3846
3923
|
var state = useSelectState(ariaProps);
|
|
@@ -3853,6 +3930,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3853
3930
|
autoFocus = props.autoFocus,
|
|
3854
3931
|
placeholder = props.placeholder,
|
|
3855
3932
|
selectedContent = props.selectedContent;
|
|
3933
|
+
var canvasCtx = usePlasmicCanvasContext();
|
|
3856
3934
|
var _useAriaSelect = useSelect$1(ariaProps, state, triggerRef),
|
|
3857
3935
|
triggerPressProps = _useAriaSelect.triggerProps,
|
|
3858
3936
|
menuProps = _useAriaSelect.menuProps;
|
|
@@ -3886,7 +3964,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3886
3964
|
ref: rootRef
|
|
3887
3965
|
}),
|
|
3888
3966
|
wrapChildren: function wrapChildren(children) {
|
|
3889
|
-
return createElement(Fragment, null, createElement(HiddenSelect, {
|
|
3967
|
+
return createElement(Fragment, null, !canvasCtx && createElement(HiddenSelect, {
|
|
3890
3968
|
state: state,
|
|
3891
3969
|
triggerRef: triggerRef,
|
|
3892
3970
|
name: name,
|
|
@@ -3894,7 +3972,7 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
3894
3972
|
}), children);
|
|
3895
3973
|
}
|
|
3896
3974
|
}, _overrides[config.trigger] = {
|
|
3897
|
-
props: mergeProps(triggerProps, {
|
|
3975
|
+
props: mergeProps(canvasCtx ? {} : triggerProps, {
|
|
3898
3976
|
ref: triggerRef,
|
|
3899
3977
|
autoFocus: autoFocus,
|
|
3900
3978
|
disabled: !!isDisabled,
|
|
@@ -3986,13 +4064,14 @@ function ListBoxWrapper(props) {
|
|
|
3986
4064
|
menuProps = props.menuProps,
|
|
3987
4065
|
children = props.children;
|
|
3988
4066
|
var ref = useRef(null);
|
|
4067
|
+
var canvasCtx = usePlasmicCanvasContext();
|
|
3989
4068
|
var _useListBox = useListBox(_extends({}, menuProps, {
|
|
3990
4069
|
isVirtualized: false,
|
|
3991
4070
|
autoFocus: state.focusStrategy || true,
|
|
3992
4071
|
disallowEmptySelection: true
|
|
3993
4072
|
}), state, ref),
|
|
3994
4073
|
listBoxProps = _useListBox.listBoxProps;
|
|
3995
|
-
return cloneElement(children, mergeProps(children.props, listBoxProps, {
|
|
4074
|
+
return cloneElement(children, mergeProps(children.props, canvasCtx ? {} : listBoxProps, {
|
|
3996
4075
|
style: noOutline(),
|
|
3997
4076
|
ref: ref
|
|
3998
4077
|
}));
|
|
@@ -4014,6 +4093,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4014
4093
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
4015
4094
|
}
|
|
4016
4095
|
var children = props.children;
|
|
4096
|
+
var canvasCtx = usePlasmicCanvasContext();
|
|
4017
4097
|
var rootRef = useRef(null);
|
|
4018
4098
|
var onRef = mergeRefs(rootRef, outerRef);
|
|
4019
4099
|
// We pass in the Node secretly as an undocumented prop from <Select />
|
|
@@ -4028,7 +4108,8 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4028
4108
|
key: node.key,
|
|
4029
4109
|
shouldSelectOnPressUp: true,
|
|
4030
4110
|
shouldFocusOnHover: true,
|
|
4031
|
-
isVirtualized: false
|
|
4111
|
+
isVirtualized: false,
|
|
4112
|
+
shouldUseVirtualFocus: !!canvasCtx
|
|
4032
4113
|
}, state, rootRef),
|
|
4033
4114
|
optionProps = _useAriaOption.optionProps,
|
|
4034
4115
|
labelProps = _useAriaOption.labelProps;
|
|
@@ -4044,7 +4125,7 @@ function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
|
4044
4125
|
}));
|
|
4045
4126
|
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
4046
4127
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
4047
|
-
props: mergeProps(optionProps, getStyleProps(props), {
|
|
4128
|
+
props: mergeProps(canvasCtx ? {} : optionProps, getStyleProps(props), {
|
|
4048
4129
|
ref: onRef,
|
|
4049
4130
|
style: noOutline()
|
|
4050
4131
|
})
|
|
@@ -4355,7 +4436,8 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
4355
4436
|
def: config.isPlacedRightVariant,
|
|
4356
4437
|
active: placementAxis === "right"
|
|
4357
4438
|
}));
|
|
4358
|
-
var
|
|
4439
|
+
var canvasCtx = usePlasmicCanvasContext();
|
|
4440
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.contentSlot] = canvasCtx ? children : createElement(FocusScope, {
|
|
4359
4441
|
restoreFocus: true
|
|
4360
4442
|
}, createElement(DismissButton, {
|
|
4361
4443
|
onDismiss: state.close
|