@strapi/ui-primitives 2.0.0-rc.21 → 2.0.0-rc.23
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 +18 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ interface RootProps {
|
|
|
35
35
|
filterValue?: string;
|
|
36
36
|
onFilterValueChange?(value: string): void;
|
|
37
37
|
isPrintableCharacter?: (str: string) => boolean;
|
|
38
|
+
visible?: boolean;
|
|
38
39
|
}
|
|
39
40
|
type TriggerProps = PrimitiveDivProps;
|
|
40
41
|
type TextInputProps = React.InputHTMLAttributes<HTMLInputElement>;
|
package/dist/index.js
CHANGED
|
@@ -217,7 +217,8 @@ const Combobox = (props) => {
|
|
|
217
217
|
filterValue: filterValueProp,
|
|
218
218
|
defaultFilterValue,
|
|
219
219
|
onFilterValueChange,
|
|
220
|
-
isPrintableCharacter = defaultIsPrintableCharacter
|
|
220
|
+
isPrintableCharacter = defaultIsPrintableCharacter,
|
|
221
|
+
visible = false
|
|
221
222
|
} = props;
|
|
222
223
|
const [trigger, setTrigger] = React__namespace.useState(null);
|
|
223
224
|
const [viewport, setViewport] = React__namespace.useState(null);
|
|
@@ -306,6 +307,7 @@ const Combobox = (props) => {
|
|
|
306
307
|
onFilterValueChange: setFilterValue,
|
|
307
308
|
onVisuallyFocussedItemChange: setVisuallyFocussedItem,
|
|
308
309
|
isPrintableCharacter,
|
|
310
|
+
visible,
|
|
309
311
|
children
|
|
310
312
|
}
|
|
311
313
|
) });
|
|
@@ -873,18 +875,29 @@ const ComboboxItemIndicator = React__namespace.forwardRef((props, forwardedRef)
|
|
|
873
875
|
ComboboxItemIndicator.displayName = ITEM_INDICATOR_NAME$1;
|
|
874
876
|
const NO_VALUE_FOUND_NAME = "ComboboxNoValueFound";
|
|
875
877
|
const ComboboxNoValueFound = React__namespace.forwardRef((props, ref) => {
|
|
876
|
-
const {
|
|
878
|
+
const {
|
|
879
|
+
textValue = "",
|
|
880
|
+
filterValue = "",
|
|
881
|
+
visible = false,
|
|
882
|
+
locale,
|
|
883
|
+
autocomplete
|
|
884
|
+
} = useComboboxContext(NO_VALUE_FOUND_NAME);
|
|
877
885
|
const [items, setItems] = React__namespace.useState([]);
|
|
878
886
|
const { subscribe } = useCollection$1(void 0);
|
|
879
887
|
const { startsWith, contains } = useFilter(locale, { sensitivity: "base" });
|
|
880
888
|
React__namespace.useEffect(() => {
|
|
881
889
|
const unsub = subscribe((state) => {
|
|
882
|
-
|
|
890
|
+
if (visible) {
|
|
891
|
+
const filteredItems = state.filter((item) => item.type !== "create");
|
|
892
|
+
setItems(filteredItems);
|
|
893
|
+
} else {
|
|
894
|
+
setItems(state);
|
|
895
|
+
}
|
|
883
896
|
});
|
|
884
897
|
return () => {
|
|
885
898
|
unsub();
|
|
886
899
|
};
|
|
887
|
-
}, [subscribe]);
|
|
900
|
+
}, [visible, subscribe]);
|
|
888
901
|
if (autocomplete.type === "none" && items.length > 0)
|
|
889
902
|
return null;
|
|
890
903
|
if (autocomplete.type === "list" && autocomplete.filter === "startsWith" && items.some((item) => startsWith(item.textValue, textValue))) {
|
|
@@ -933,7 +946,7 @@ const ComboboxCreateItem = React__namespace.forwardRef((props, ref) => {
|
|
|
933
946
|
unsub();
|
|
934
947
|
};
|
|
935
948
|
}, [textValue, subscribe, getItems]);
|
|
936
|
-
if (!textValue || !show) {
|
|
949
|
+
if ((!textValue || !show) && !context.visible) {
|
|
937
950
|
return null;
|
|
938
951
|
}
|
|
939
952
|
return /* @__PURE__ */ jsxRuntime.jsx(
|