@radix-ui/react-select 1.2.2 → 2.0.0-rc.1
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/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import $01b9c$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import {useState as $01b9c$useState, useRef as $01b9c$useRef, createElement as $01b9c$createElement, useCallback as $01b9c$useCallback, forwardRef as $01b9c$forwardRef,
|
|
2
|
+
import {useState as $01b9c$useState, useRef as $01b9c$useRef, createElement as $01b9c$createElement, useCallback as $01b9c$useCallback, forwardRef as $01b9c$forwardRef, Fragment as $01b9c$Fragment, useEffect as $01b9c$useEffect, useMemo as $01b9c$useMemo} from "react";
|
|
3
3
|
import {createPortal as $01b9c$createPortal} from "react-dom";
|
|
4
4
|
import {clamp as $01b9c$clamp} from "@radix-ui/number";
|
|
5
5
|
import {composeEventHandlers as $01b9c$composeEventHandlers} from "@radix-ui/primitive";
|
|
@@ -183,7 +183,7 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ $01b9c$forwardRef
|
|
|
183
183
|
"data-state": context.open ? 'open' : 'closed',
|
|
184
184
|
disabled: isDisabled,
|
|
185
185
|
"data-disabled": isDisabled ? '' : undefined,
|
|
186
|
-
"data-placeholder": context.value
|
|
186
|
+
"data-placeholder": $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? '' : undefined
|
|
187
187
|
}, triggerProps, {
|
|
188
188
|
ref: composedRefs // Enable compatibility with native label or custom `Label` "click" for Safari:
|
|
189
189
|
,
|
|
@@ -231,7 +231,7 @@ const $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /*#__PURE__*/ $01b9c$forwardRef
|
|
|
231
231
|
* -----------------------------------------------------------------------------------------------*/ const $cc7e05a45900e73f$var$VALUE_NAME = 'SelectValue';
|
|
232
232
|
const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ $01b9c$forwardRef((props, forwardedRef)=>{
|
|
233
233
|
// We ignore `className` and `style` as this part shouldn't be styled.
|
|
234
|
-
const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder , ...valueProps } = props;
|
|
234
|
+
const { __scopeSelect: __scopeSelect , className: className , style: style , children: children , placeholder: placeholder = '' , ...valueProps } = props;
|
|
235
235
|
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
|
|
236
236
|
const { onValueNodeHasChildrenChange: onValueNodeHasChildrenChange } = context;
|
|
237
237
|
const hasChildren = children !== undefined;
|
|
@@ -248,7 +248,7 @@ const $cc7e05a45900e73f$export$e288731fd71264f0 = /*#__PURE__*/ $01b9c$forwardRe
|
|
|
248
248
|
style: {
|
|
249
249
|
pointerEvents: 'none'
|
|
250
250
|
}
|
|
251
|
-
}), context.value
|
|
251
|
+
}), $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? /*#__PURE__*/ $01b9c$createElement($01b9c$Fragment, null, placeholder) : children);
|
|
252
252
|
});
|
|
253
253
|
/*#__PURE__*/ Object.assign($cc7e05a45900e73f$export$e288731fd71264f0, {
|
|
254
254
|
displayName: $cc7e05a45900e73f$var$VALUE_NAME
|
|
@@ -862,6 +862,7 @@ const $cc7e05a45900e73f$export$13ef48a934230896 = /*#__PURE__*/ $01b9c$forwardRe
|
|
|
862
862
|
context.onOpenChange(false);
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
|
+
if (value === '') throw new Error('A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.');
|
|
865
866
|
return /*#__PURE__*/ $01b9c$createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
|
|
866
867
|
scope: __scopeSelect,
|
|
867
868
|
value: value,
|
|
@@ -1137,7 +1138,10 @@ const $cc7e05a45900e73f$export$314f4cb8f8099628 = /*#__PURE__*/ $01b9c$forwardRe
|
|
|
1137
1138
|
/*#__PURE__*/ Object.assign($cc7e05a45900e73f$export$314f4cb8f8099628, {
|
|
1138
1139
|
displayName: $cc7e05a45900e73f$var$ARROW_NAME
|
|
1139
1140
|
});
|
|
1140
|
-
/* -----------------------------------------------------------------------------------------------*/
|
|
1141
|
+
/* -----------------------------------------------------------------------------------------------*/ function $cc7e05a45900e73f$var$shouldShowPlaceholder(value) {
|
|
1142
|
+
return value === '' || value === undefined;
|
|
1143
|
+
}
|
|
1144
|
+
const $cc7e05a45900e73f$var$BubbleSelect = /*#__PURE__*/ $01b9c$forwardRef((props, forwardedRef)=>{
|
|
1141
1145
|
const { value: value , ...selectProps } = props;
|
|
1142
1146
|
const ref = $01b9c$useRef(null);
|
|
1143
1147
|
const composedRefs = $01b9c$useComposedRefs(forwardedRef, ref);
|