@react-md/autocomplete
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
@@ -5,2 +5,3 @@ export { default as AutoComplete } from "./AutoComplete"; | ||
export { isResultOf } from "./utils"; | ||
export * from "./types"; | ||
//# sourceMappingURL=index.js.map |
@@ -22,2 +22,3 @@ var __assign = (this && this.__assign) || function () { | ||
export default function useAutoComplete(_a) { | ||
var _b; | ||
var suggestionsId = _a.suggestionsId, data = _a.data, filterFn = _a.filter, filterOptions = _a.filterOptions, filterOnNoValue = _a.filterOnNoValue, valueKey = _a.valueKey, getResultId = _a.getResultId, getResultValue = _a.getResultValue, onBlur = _a.onBlur, onFocus = _a.onFocus, onClick = _a.onClick, onChange = _a.onChange, onKeyDown = _a.onKeyDown, forwardedRef = _a.forwardedRef, onAutoComplete = _a.onAutoComplete, clearOnAutoComplete = _a.clearOnAutoComplete, anchor = _a.anchor, xMargin = _a.xMargin, yMargin = _a.yMargin, vwMargin = _a.vwMargin, vhMargin = _a.vhMargin, transformOrigin = _a.transformOrigin, listboxWidth = _a.listboxWidth, listboxStyle = _a.listboxStyle, preventOverlap = _a.preventOverlap, disableSwapping = _a.disableSwapping, disableVHBounds = _a.disableVHBounds, closeOnResize = _a.closeOnResize, closeOnScroll = _a.closeOnScroll, propDisableShowOnFocus = _a.disableShowOnFocus, isListAutocomplete = _a.isListAutocomplete, isInlineAutocomplete = _a.isInlineAutocomplete; | ||
@@ -30,3 +31,3 @@ var inputRef = useRef(null); | ||
var filter = getFilterFunction(filterFn); | ||
var _b = useState(function () { | ||
var _c = useState(function () { | ||
var _a; | ||
@@ -39,6 +40,6 @@ var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: (_a = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _a !== void 0 ? _a : isInlineAutocomplete }); | ||
}; | ||
}), _c = _b[0], value = _c.value, match = _c.match, stateFilteredData = _c.filteredData, setState = _b[1]; | ||
}), _d = _c[0], value = _d.value, match = _d.match, stateFilteredData = _d.filteredData, setState = _c[1]; | ||
var filteredData = filterFn === "none" ? data : stateFilteredData; | ||
var startsWith = (_b = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _b !== void 0 ? _b : isInlineAutocomplete; | ||
var setValue = useCallback(function (nextValue) { | ||
var _a; | ||
var isBackspace = value.length > nextValue.length || | ||
@@ -48,3 +49,3 @@ (!!match && value.length === nextValue.length); | ||
if (nextValue || filterOnNoValue) { | ||
var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: (_a = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _a !== void 0 ? _a : isInlineAutocomplete }); | ||
var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: startsWith }); | ||
filtered = filter(nextValue, data, options); | ||
@@ -71,2 +72,3 @@ } | ||
match, | ||
startsWith, | ||
valueKey, | ||
@@ -85,3 +87,3 @@ ]); | ||
}, [setValue, onChange]); | ||
var _d = useToggle(false), visible = _d[0], show = _d[1], hide = _d[2]; | ||
var _e = useToggle(false), visible = _e[0], show = _e[1], hide = _e[2]; | ||
var isTouch = useIsUserInteractionMode("touch"); | ||
@@ -148,3 +150,3 @@ var disableShowOnFocus = propDisableShowOnFocus !== null && propDisableShowOnFocus !== void 0 ? propDisableShowOnFocus : isTouch; | ||
var listboxRef = useRef(null); | ||
var _e = useActiveDescendantMovement(__assign(__assign({}, MovementPresets.VERTICAL_COMBOBOX), { getId: getResultId, items: filteredData, baseId: suggestionsId, onChange: function (_a, itemRefs) { | ||
var _f = useActiveDescendantMovement(__assign(__assign({}, MovementPresets.VERTICAL_COMBOBOX), { getId: getResultId, items: filteredData, baseId: suggestionsId, onChange: function (_a, itemRefs) { | ||
var index = _a.index, items = _a.items, target = _a.target; | ||
@@ -221,3 +223,3 @@ // the default scroll into view behavior for aria-activedescendant | ||
} | ||
} })), activeId = _e.activeId, itemRefs = _e.itemRefs, handleKeyDown = _e.onKeyDown, focusedIndex = _e.focusedIndex, setFocusedIndex = _e.setFocusedIndex; | ||
} })), activeId = _f.activeId, itemRefs = _f.itemRefs, handleKeyDown = _f.onKeyDown, focusedIndex = _f.focusedIndex, setFocusedIndex = _f.setFocusedIndex; | ||
useCloseOnOutsideClick({ | ||
@@ -228,3 +230,3 @@ enabled: visible, | ||
}); | ||
var _f = useFixedPositioning({ | ||
var _g = useFixedPositioning({ | ||
fixedTo: function () { return inputRef.current; }, | ||
@@ -248,3 +250,3 @@ anchor: anchor, | ||
disableVHBounds: disableVHBounds, | ||
}), style = _f.style, onEnter = _f.onEnter, onEntering = _f.onEntering, onEntered = _f.onEntered, onExited = _f.onExited, updateStyle = _f.updateStyle; | ||
}), style = _g.style, onEnter = _g.onEnter, onEntering = _g.onEntering, onEntered = _g.onEntered, onExited = _g.onExited, updateStyle = _g.updateStyle; | ||
useEffect(function () { | ||
@@ -251,0 +253,0 @@ if (!focused.current || autocompleted.current) { |
@@ -13,2 +13,21 @@ "use strict"; | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -32,9 +51,2 @@ var t = {}; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -41,0 +53,0 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var AutoComplete_1 = require("./AutoComplete"); | ||
exports.AutoComplete = AutoComplete_1.default; | ||
Object.defineProperty(exports, "AutoComplete", { enumerable: true, get: function () { return AutoComplete_1.default; } }); | ||
var HighlightedResult_1 = require("./HighlightedResult"); | ||
exports.HighlightedResult = HighlightedResult_1.default; | ||
__export(require("./HighlightedResult")); | ||
Object.defineProperty(exports, "HighlightedResult", { enumerable: true, get: function () { return HighlightedResult_1.default; } }); | ||
__exportStar(require("./HighlightedResult"), exports); | ||
var utils_1 = require("./utils"); | ||
exports.isResultOf = utils_1.isResultOf; | ||
Object.defineProperty(exports, "isResultOf", { enumerable: true, get: function () { return utils_1.isResultOf; } }); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -24,2 +24,3 @@ "use strict"; | ||
function useAutoComplete(_a) { | ||
var _b; | ||
var suggestionsId = _a.suggestionsId, data = _a.data, filterFn = _a.filter, filterOptions = _a.filterOptions, filterOnNoValue = _a.filterOnNoValue, valueKey = _a.valueKey, getResultId = _a.getResultId, getResultValue = _a.getResultValue, onBlur = _a.onBlur, onFocus = _a.onFocus, onClick = _a.onClick, onChange = _a.onChange, onKeyDown = _a.onKeyDown, forwardedRef = _a.forwardedRef, onAutoComplete = _a.onAutoComplete, clearOnAutoComplete = _a.clearOnAutoComplete, anchor = _a.anchor, xMargin = _a.xMargin, yMargin = _a.yMargin, vwMargin = _a.vwMargin, vhMargin = _a.vhMargin, transformOrigin = _a.transformOrigin, listboxWidth = _a.listboxWidth, listboxStyle = _a.listboxStyle, preventOverlap = _a.preventOverlap, disableSwapping = _a.disableSwapping, disableVHBounds = _a.disableVHBounds, closeOnResize = _a.closeOnResize, closeOnScroll = _a.closeOnScroll, propDisableShowOnFocus = _a.disableShowOnFocus, isListAutocomplete = _a.isListAutocomplete, isInlineAutocomplete = _a.isInlineAutocomplete; | ||
@@ -32,3 +33,3 @@ var inputRef = react_1.useRef(null); | ||
var filter = utils_2.getFilterFunction(filterFn); | ||
var _b = react_1.useState(function () { | ||
var _c = react_1.useState(function () { | ||
var _a; | ||
@@ -41,6 +42,6 @@ var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: (_a = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _a !== void 0 ? _a : isInlineAutocomplete }); | ||
}; | ||
}), _c = _b[0], value = _c.value, match = _c.match, stateFilteredData = _c.filteredData, setState = _b[1]; | ||
}), _d = _c[0], value = _d.value, match = _d.match, stateFilteredData = _d.filteredData, setState = _c[1]; | ||
var filteredData = filterFn === "none" ? data : stateFilteredData; | ||
var startsWith = (_b = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _b !== void 0 ? _b : isInlineAutocomplete; | ||
var setValue = react_1.useCallback(function (nextValue) { | ||
var _a; | ||
var isBackspace = value.length > nextValue.length || | ||
@@ -50,3 +51,3 @@ (!!match && value.length === nextValue.length); | ||
if (nextValue || filterOnNoValue) { | ||
var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: (_a = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _a !== void 0 ? _a : isInlineAutocomplete }); | ||
var options = __assign(__assign({}, filterOptions), { valueKey: valueKey, getItemValue: getResultValue, startsWith: startsWith }); | ||
filtered = filter(nextValue, data, options); | ||
@@ -73,2 +74,3 @@ } | ||
match, | ||
startsWith, | ||
valueKey, | ||
@@ -87,3 +89,3 @@ ]); | ||
}, [setValue, onChange]); | ||
var _d = utils_1.useToggle(false), visible = _d[0], show = _d[1], hide = _d[2]; | ||
var _e = utils_1.useToggle(false), visible = _e[0], show = _e[1], hide = _e[2]; | ||
var isTouch = utils_1.useIsUserInteractionMode("touch"); | ||
@@ -150,3 +152,3 @@ var disableShowOnFocus = propDisableShowOnFocus !== null && propDisableShowOnFocus !== void 0 ? propDisableShowOnFocus : isTouch; | ||
var listboxRef = react_1.useRef(null); | ||
var _e = utils_1.useActiveDescendantMovement(__assign(__assign({}, utils_1.MovementPresets.VERTICAL_COMBOBOX), { getId: getResultId, items: filteredData, baseId: suggestionsId, onChange: function (_a, itemRefs) { | ||
var _f = utils_1.useActiveDescendantMovement(__assign(__assign({}, utils_1.MovementPresets.VERTICAL_COMBOBOX), { getId: getResultId, items: filteredData, baseId: suggestionsId, onChange: function (_a, itemRefs) { | ||
var index = _a.index, items = _a.items, target = _a.target; | ||
@@ -223,3 +225,3 @@ // the default scroll into view behavior for aria-activedescendant | ||
} | ||
} })), activeId = _e.activeId, itemRefs = _e.itemRefs, handleKeyDown = _e.onKeyDown, focusedIndex = _e.focusedIndex, setFocusedIndex = _e.setFocusedIndex; | ||
} })), activeId = _f.activeId, itemRefs = _f.itemRefs, handleKeyDown = _f.onKeyDown, focusedIndex = _f.focusedIndex, setFocusedIndex = _f.setFocusedIndex; | ||
utils_1.useCloseOnOutsideClick({ | ||
@@ -230,3 +232,3 @@ enabled: visible, | ||
}); | ||
var _f = transition_1.useFixedPositioning({ | ||
var _g = transition_1.useFixedPositioning({ | ||
fixedTo: function () { return inputRef.current; }, | ||
@@ -250,3 +252,3 @@ anchor: anchor, | ||
disableVHBounds: disableVHBounds, | ||
}), style = _f.style, onEnter = _f.onEnter, onEntering = _f.onEntering, onEntered = _f.onEntered, onExited = _f.onExited, updateStyle = _f.updateStyle; | ||
}), style = _g.style, onEnter = _g.onEnter, onEntering = _g.onEntering, onEntered = _g.onEntered, onExited = _g.onExited, updateStyle = _g.updateStyle; | ||
react_1.useEffect(function () { | ||
@@ -253,0 +255,0 @@ if (!focused.current || autocompleted.current) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isResultOf = exports.getFilterFunction = exports.noFilter = exports.getResultValue = exports.getResultLabel = exports.getResultId = void 0; | ||
var utils_1 = require("@react-md/utils"); | ||
@@ -4,0 +5,0 @@ /** |
{ | ||
"name": "@react-md/autocomplete", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "", | ||
@@ -41,10 +41,10 @@ "scripts": { | ||
"dependencies": { | ||
"@react-md/form": "^2.0.0-beta.0", | ||
"@react-md/list": "^2.0.0-beta.0", | ||
"@react-md/form": "^2.0.0-beta.1", | ||
"@react-md/list": "^2.0.0-beta.1", | ||
"@react-md/portal": "^2.0.0-beta.0", | ||
"@react-md/states": "^2.0.0-beta.0", | ||
"@react-md/theme": "^2.0.0-beta.0", | ||
"@react-md/transition": "^2.0.0-beta.0", | ||
"@react-md/typography": "^2.0.0-beta.0", | ||
"@react-md/utils": "^2.0.0-beta.0", | ||
"@react-md/states": "^2.0.0-beta.1", | ||
"@react-md/theme": "^2.0.0-beta.1", | ||
"@react-md/transition": "^2.0.0-beta.1", | ||
"@react-md/typography": "^2.0.0-beta.1", | ||
"@react-md/utils": "^2.0.0-beta.1", | ||
"classnames": "^2.2.6" | ||
@@ -61,3 +61,3 @@ }, | ||
}, | ||
"gitHead": "8d754a2c2734ee98eaf571e348a836cf12a9f104" | ||
"gitHead": "76642fca0cf36307a5431d67a8eb4abe0a7b18a6" | ||
} |
@@ -156,2 +156,3 @@ import { | ||
const filteredData = filterFn === "none" ? data : stateFilteredData; | ||
const startsWith = filterOptions?.startsWith ?? isInlineAutocomplete; | ||
@@ -170,3 +171,3 @@ const setValue = useCallback( | ||
getItemValue: getResultValue, | ||
startsWith: filterOptions?.startsWith ?? isInlineAutocomplete, | ||
startsWith, | ||
}; | ||
@@ -199,2 +200,3 @@ | ||
match, | ||
startsWith, | ||
valueKey, | ||
@@ -201,0 +203,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192285
3632
+ Addednanoid@3.3.7(transitive)
- Removednanoid@3.3.8(transitive)
Updated@react-md/form@^2.0.0-beta.1
Updated@react-md/list@^2.0.0-beta.1