@strapi/ui-primitives 2.0.0-rc.20 → 2.0.0-rc.22
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/components/Combobox/Combobox.d.ts +1 -0
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -195,7 +195,8 @@ const Combobox = (props) => {
|
|
|
195
195
|
filterValue: filterValueProp,
|
|
196
196
|
defaultFilterValue,
|
|
197
197
|
onFilterValueChange,
|
|
198
|
-
isPrintableCharacter = defaultIsPrintableCharacter
|
|
198
|
+
isPrintableCharacter = defaultIsPrintableCharacter,
|
|
199
|
+
visible = false
|
|
199
200
|
} = props;
|
|
200
201
|
const [trigger, setTrigger] = React.useState(null);
|
|
201
202
|
const [viewport, setViewport] = React.useState(null);
|
|
@@ -284,6 +285,7 @@ const Combobox = (props) => {
|
|
|
284
285
|
onFilterValueChange: setFilterValue,
|
|
285
286
|
onVisuallyFocussedItemChange: setVisuallyFocussedItem,
|
|
286
287
|
isPrintableCharacter,
|
|
288
|
+
visible,
|
|
287
289
|
children
|
|
288
290
|
}
|
|
289
291
|
) });
|
|
@@ -851,18 +853,29 @@ const ComboboxItemIndicator = React.forwardRef((props, forwardedRef) => {
|
|
|
851
853
|
ComboboxItemIndicator.displayName = ITEM_INDICATOR_NAME$1;
|
|
852
854
|
const NO_VALUE_FOUND_NAME = "ComboboxNoValueFound";
|
|
853
855
|
const ComboboxNoValueFound = React.forwardRef((props, ref) => {
|
|
854
|
-
const {
|
|
856
|
+
const {
|
|
857
|
+
textValue = "",
|
|
858
|
+
filterValue = "",
|
|
859
|
+
visible = false,
|
|
860
|
+
locale,
|
|
861
|
+
autocomplete
|
|
862
|
+
} = useComboboxContext(NO_VALUE_FOUND_NAME);
|
|
855
863
|
const [items, setItems] = React.useState([]);
|
|
856
864
|
const { subscribe } = useCollection$1(void 0);
|
|
857
865
|
const { startsWith, contains } = useFilter(locale, { sensitivity: "base" });
|
|
858
866
|
React.useEffect(() => {
|
|
859
867
|
const unsub = subscribe((state) => {
|
|
860
|
-
|
|
868
|
+
if (visible) {
|
|
869
|
+
const filteredItems = state.filter((item) => item.type !== "create");
|
|
870
|
+
setItems(filteredItems);
|
|
871
|
+
} else {
|
|
872
|
+
setItems(state);
|
|
873
|
+
}
|
|
861
874
|
});
|
|
862
875
|
return () => {
|
|
863
876
|
unsub();
|
|
864
877
|
};
|
|
865
|
-
}, [subscribe]);
|
|
878
|
+
}, [visible, subscribe]);
|
|
866
879
|
if (autocomplete.type === "none" && items.length > 0)
|
|
867
880
|
return null;
|
|
868
881
|
if (autocomplete.type === "list" && autocomplete.filter === "startsWith" && items.some((item) => startsWith(item.textValue, textValue))) {
|
|
@@ -911,7 +924,7 @@ const ComboboxCreateItem = React.forwardRef((props, ref) => {
|
|
|
911
924
|
unsub();
|
|
912
925
|
};
|
|
913
926
|
}, [textValue, subscribe, getItems]);
|
|
914
|
-
if (!textValue || !show) {
|
|
927
|
+
if ((!textValue || !show) && !context.visible) {
|
|
915
928
|
return null;
|
|
916
929
|
}
|
|
917
930
|
return /* @__PURE__ */ jsx(
|
|
@@ -934,7 +947,7 @@ const ComboboxCreateItem = React.forwardRef((props, ref) => {
|
|
|
934
947
|
...restProps,
|
|
935
948
|
id,
|
|
936
949
|
ref: composedRefs,
|
|
937
|
-
|
|
950
|
+
onClick: composeEventHandlers$1(restProps.onPointerUp, handleSelect)
|
|
938
951
|
}
|
|
939
952
|
)
|
|
940
953
|
}
|