@clayui/autocomplete
Advanced tools
Comparing version 3.100.0 to 3.101.0
@@ -29,2 +29,6 @@ /** | ||
/** | ||
* Flag to allow an input value not corresponding to an item to be set. | ||
*/ | ||
allowsCustomValue?: boolean; | ||
/** | ||
* The initial value of the active state (uncontrolled). | ||
@@ -31,0 +35,0 @@ */ |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _excluded = ["children"], | ||
_excluded2 = ["UNSAFE_loadingShrink", "active", "as", "alignmentByViewport", "children", "containerElementRef", "defaultActive", "defaultItems", "defaultValue", "direction", "filterKey", "items", "loadingState", "menuTrigger", "messages", "onActiveChange", "onChange", "onItemsChange", "onLoadMore", "value"]; | ||
_excluded2 = ["UNSAFE_loadingShrink", "active", "alignmentByViewport", "allowsCustomValue", "as", "children", "containerElementRef", "defaultActive", "defaultItems", "defaultValue", "direction", "filterKey", "items", "loadingState", "menuTrigger", "messages", "onActiveChange", "onChange", "onItemsChange", "onLoadMore", "value"]; | ||
@@ -86,5 +86,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
externalActive = _ref2.active, | ||
_ = _ref2.alignmentByViewport, | ||
allowsCustomValue = _ref2.allowsCustomValue, | ||
_ref2$as = _ref2.as, | ||
As = _ref2$as === void 0 ? _form.ClayInput : _ref2$as, | ||
_ = _ref2.alignmentByViewport, | ||
children = _ref2.children, | ||
@@ -158,10 +159,37 @@ containerElementRef = _ref2.containerElementRef, | ||
var announcerAPI = (0, _react.useRef)(null); | ||
var isFirst = (0, _shared.useIsFirstRender)(); | ||
var filterFn = (0, _react.useCallback)(function (itemValue) { | ||
return itemValue.match(new RegExp(value.replace(ESCAPE_REGEXP, '\\$&'), 'i')) !== null; | ||
}, [value]); | ||
(0, _react.useEffect)(function () { | ||
if (active === false) { | ||
// Validates that the initial value exists in the items. | ||
if (!allowsCustomValue && !currentItemSelected.current && value && items) { | ||
var hasItem = items.find(function (item) { | ||
if (typeof item === 'string') { | ||
return item === value; | ||
} else if (_typeof(item) === 'object') { | ||
// filter key is not defined and we cannot infer the data type. | ||
if (!filterKey) { | ||
return false; | ||
} | ||
return item[filterKey] === value; | ||
} | ||
}); | ||
if (hasItem) { | ||
currentItemSelected.current = value; | ||
} | ||
} | ||
}, []); | ||
(0, _react.useEffect)(function () { | ||
// Does not update state on first render. | ||
if (isFirst || allowsCustomValue) { | ||
return; | ||
} | ||
if (active === false && currentItemSelected.current !== value) { | ||
setValue(currentItemSelected.current); | ||
} | ||
}, [active]); | ||
var filterFn = (0, _react.useCallback)(function (itemValue) { | ||
return itemValue.match(new RegExp(value.replace(ESCAPE_REGEXP, '\\$&'), 'i')) !== null; | ||
}, [value]); | ||
var filteredItems = (0, _react.useMemo)(function () { | ||
@@ -168,0 +196,0 @@ if (debouncedLoadingChange) { |
{ | ||
"name": "@clayui/autocomplete", | ||
"version": "3.100.0", | ||
"version": "3.101.0", | ||
"description": "ClayAutocomplete component", | ||
@@ -29,7 +29,7 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"@clayui/core": "^3.100.0", | ||
"@clayui/drop-down": "^3.100.0", | ||
"@clayui/form": "^3.100.0", | ||
"@clayui/core": "^3.101.0", | ||
"@clayui/drop-down": "^3.101.0", | ||
"@clayui/form": "^3.101.0", | ||
"@clayui/loading-indicator": "^3.60.0", | ||
"@clayui/shared": "^3.100.0", | ||
"@clayui/shared": "^3.101.0", | ||
"classnames": "^2.2.6", | ||
@@ -46,3 +46,3 @@ "fuzzy": "^0.1.3" | ||
], | ||
"gitHead": "17e85ad6e4587a22803d34705518f4659717b620" | ||
"gitHead": "55f8b720047b2aa4764d5de1302f715db62ed902" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
110364
2677
+ Added@types/react@19.0.8(transitive)
- Removed@types/react@19.0.10(transitive)
Updated@clayui/core@^3.101.0
Updated@clayui/drop-down@^3.101.0
Updated@clayui/form@^3.101.0
Updated@clayui/shared@^3.101.0