Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-md/autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-md/autocomplete - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [4.0.1](https://github.com/mlaursen/react-md/compare/v4.0.0...v4.0.1) (2021-11-27)
### Other Internal Changes
* Updated imports to use `import type` when possible ([ba96bb6](https://github.com/mlaursen/react-md/commit/ba96bb62eeddcc0879f6d584aa670850203561e6))
# [4.0.0](https://github.com/mlaursen/react-md/compare/v3.1.1...v4.0.0) (2021-11-24)

@@ -8,0 +20,0 @@

18

es/AutoComplete.js

@@ -23,2 +23,18 @@ var __assign = (this && this.__assign) || function () {

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

@@ -100,3 +116,3 @@ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {

if (isListboxOptionProps(datum)) {
optionProps = omit(datum, __spreadArray([labelKey, valueKey], omitKeys, true));
optionProps = omit(datum, __spreadArray([labelKey, valueKey], __read(omitKeys), false));
}

@@ -103,0 +119,0 @@ return (_jsx(Option, __assign({}, optionProps, { id: resultId, selected: false, focused: resultId === activeId, ref: itemRefs[i], onClick: function () { return handleAutoComplete(i); } }, { children: _jsx(HighlightedResult, __assign({ id: "".concat(resultId, "-match"), style: highlightStyle, className: highlightClassName, value: propValue !== null && propValue !== void 0 ? propValue : value, enabled: highlight, repeatable: highlightReapeating }, { children: getResultLabel(datum, labelKey, value) }), void 0) }), resultId));

@@ -12,2 +12,18 @@ var __assign = (this && this.__assign) || function () {

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import { useCallback, useEffect, useRef, useState, } from "react";

@@ -25,5 +41,5 @@ import { useFixedPositioning, } from "@react-md/transition";

var suggestionsId = _a.suggestionsId, data = _a.data, propValue = _a.propValue, _c = _a.defaultValue, defaultValue = _c === void 0 ? "" : _c, 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;
var _d = useEnsuredRef(forwardedRef), ref = _d[0], refHandler = _d[1];
var _d = __read(useEnsuredRef(forwardedRef), 2), ref = _d[0], refHandler = _d[1];
var filter = getFilterFunction(filterFn);
var _e = useState(function () {
var _e = __read(useState(function () {
var _a;

@@ -42,3 +58,3 @@ 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 });

};
}), _f = _e[0], stateValue = _f.value, match = _f.match, stateFilteredData = _f.filteredData, setState = _e[1];
}), 2), _f = _e[0], stateValue = _f.value, match = _f.match, stateFilteredData = _f.filteredData, setState = _e[1];
var filteredData = filterFn === "none" ? data : stateFilteredData;

@@ -89,3 +105,3 @@ var startsWith = (_b = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _b !== void 0 ? _b : isInlineAutocomplete;

}, [setValue, onChange]);
var _g = useToggle(false), visible = _g[0], show = _g[1], hide = _g[2];
var _g = __read(useToggle(false), 3), visible = _g[0], show = _g[1], hide = _g[2];
var isTouch = useIsUserInteractionMode("touch");

@@ -92,0 +108,0 @@ var disableShowOnFocus = propDisableShowOnFocus !== null && propDisableShowOnFocus !== void 0 ? propDisableShowOnFocus : isTouch;

2

lib/AutoComplete.d.ts
/// <reference types="react" />
import { AutoCompleteProps } from "./types";
import type { AutoCompleteProps } from "./types";
/**

@@ -4,0 +4,0 @@ * An AutoComplete is an accessible combobox widget that allows for real-time

@@ -24,2 +24,18 @@ "use strict";

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

@@ -106,3 +122,3 @@ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {

if ((0, form_1.isListboxOptionProps)(datum)) {
optionProps = (0, utils_1.omit)(datum, __spreadArray([labelKey, valueKey], omitKeys, true));
optionProps = (0, utils_1.omit)(datum, __spreadArray([labelKey, valueKey], __read(omitKeys), false));
}

@@ -109,0 +125,0 @@ return ((0, jsx_runtime_1.jsx)(form_1.Option, __assign({}, optionProps, { id: resultId, selected: false, focused: resultId === activeId, ref: itemRefs[i], onClick: function () { return handleAutoComplete(i); } }, { children: (0, jsx_runtime_1.jsx)(HighlightedResult_1.HighlightedResult, __assign({ id: "".concat(resultId, "-match"), style: highlightStyle, className: highlightClassName, value: propValue !== null && propValue !== void 0 ? propValue : value, enabled: highlight, repeatable: highlightReapeating }, { children: getResultLabel(datum, labelKey, value) }), void 0) }), resultId));

@@ -1,2 +0,2 @@

import { CSSProperties, ReactElement, ReactNode } from "react";
import type { CSSProperties, ReactElement, ReactNode } from "react";
export interface HighlightedResultProps {

@@ -3,0 +3,0 @@ /**

import { ChangeEventHandler, CSSProperties, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, MouseEventHandler, Ref } from "react";
import { ListElement } from "@react-md/list";
import type { ListElement } from "@react-md/list";
import { FixedPositioningTransitionCallbacks } from "@react-md/transition";
import { ItemRefList } from "@react-md/utils";
import { AutoCompleteData, AutoCompleteListboxPositionOptions, AutoCompleteProps } from "./types";
import type { AutoCompleteData, AutoCompleteListboxPositionOptions, AutoCompleteProps } from "./types";
declare type EventHandlers = Pick<HTMLAttributes<HTMLInputElement>, "onBlur" | "onFocus" | "onChange" | "onClick" | "onKeyDown">;

@@ -7,0 +7,0 @@ export declare type RequiredAutoCompleteProps = Required<Pick<AutoCompleteProps, "data" | "filter" | "filterOptions" | "filterOnNoValue" | "valueKey" | "getResultId" | "getResultValue" | "clearOnAutoComplete">>;

@@ -13,2 +13,18 @@ "use strict";

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -28,5 +44,5 @@ exports.useAutoComplete = void 0;

var suggestionsId = _a.suggestionsId, data = _a.data, propValue = _a.propValue, _c = _a.defaultValue, defaultValue = _c === void 0 ? "" : _c, 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;
var _d = (0, utils_1.useEnsuredRef)(forwardedRef), ref = _d[0], refHandler = _d[1];
var _d = __read((0, utils_1.useEnsuredRef)(forwardedRef), 2), ref = _d[0], refHandler = _d[1];
var filter = (0, utils_2.getFilterFunction)(filterFn);
var _e = (0, react_1.useState)(function () {
var _e = __read((0, react_1.useState)(function () {
var _a;

@@ -45,3 +61,3 @@ 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 });

};
}), _f = _e[0], stateValue = _f.value, match = _f.match, stateFilteredData = _f.filteredData, setState = _e[1];
}), 2), _f = _e[0], stateValue = _f.value, match = _f.match, stateFilteredData = _f.filteredData, setState = _e[1];
var filteredData = filterFn === "none" ? data : stateFilteredData;

@@ -92,3 +108,3 @@ var startsWith = (_b = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.startsWith) !== null && _b !== void 0 ? _b : isInlineAutocomplete;

}, [setValue, onChange]);
var _g = (0, utils_1.useToggle)(false), visible = _g[0], show = _g[1], hide = _g[2];
var _g = __read((0, utils_1.useToggle)(false), 3), visible = _g[0], show = _g[1], hide = _g[2];
var isTouch = (0, utils_1.useIsUserInteractionMode)("touch");

@@ -95,0 +111,0 @@ var disableShowOnFocus = propDisableShowOnFocus !== null && propDisableShowOnFocus !== void 0 ? propDisableShowOnFocus : isTouch;

@@ -1,3 +0,3 @@

import { ReactNode } from "react";
import { AutoCompleteData, AutoCompleteFilterFunction, FilterFunction } from "./types";
import type { ReactNode } from "react";
import type { AutoCompleteData, AutoCompleteFilterFunction, FilterFunction } from "./types";
/**

@@ -4,0 +4,0 @@ * Generates an id for each result in the autocomplete's listbox.

{
"name": "@react-md/autocomplete",
"version": "4.0.0",
"version": "4.0.1",
"description": "",

@@ -34,10 +34,10 @@ "main": "./lib/index.js",

"dependencies": {
"@react-md/form": "^4.0.0",
"@react-md/list": "^4.0.0",
"@react-md/portal": "^4.0.0",
"@react-md/states": "^4.0.0",
"@react-md/theme": "^4.0.0",
"@react-md/transition": "^4.0.0",
"@react-md/typography": "^4.0.0",
"@react-md/utils": "^4.0.0",
"@react-md/form": "^4.0.1",
"@react-md/list": "^4.0.1",
"@react-md/portal": "^4.0.1",
"@react-md/states": "^4.0.1",
"@react-md/theme": "^4.0.1",
"@react-md/transition": "^4.0.1",
"@react-md/typography": "^4.0.1",
"@react-md/utils": "^4.0.1",
"classnames": "^2.3.1"

@@ -56,3 +56,3 @@ },

},
"gitHead": "a9f2d64a777698fa65bb3196f6063cdd8321f5cb"
"gitHead": "0df0f24d688ea7c867b7ef656ee9887f00215705"
}

@@ -14,3 +14,3 @@ import {

} from "react";
import { ListElement } from "@react-md/list";
import type { ListElement } from "@react-md/list";
import {

@@ -31,3 +31,3 @@ FixedPositioningTransitionCallbacks,

import {
import type {
AutoCompleteData,

@@ -34,0 +34,0 @@ AutoCompleteListboxPositionOptions,

@@ -1,5 +0,5 @@

import { ReactNode } from "react";
import type { ReactNode } from "react";
import { caseInsensitiveFilter, fuzzyFilter } from "@react-md/utils";
import {
import type {
AutoCompleteData,

@@ -6,0 +6,0 @@ AutoCompleteFilterFunction,

/// <reference types="react" />
import { AutoCompleteProps } from "./types";
import type { AutoCompleteProps } from "./types";
/**

@@ -4,0 +4,0 @@ * An AutoComplete is an accessible combobox widget that allows for real-time

@@ -1,2 +0,2 @@

import { CSSProperties, ReactElement, ReactNode } from "react";
import type { CSSProperties, ReactElement, ReactNode } from "react";
export interface HighlightedResultProps {

@@ -3,0 +3,0 @@ /**

import { ChangeEventHandler, CSSProperties, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, MouseEventHandler, Ref } from "react";
import { ListElement } from "@react-md/list";
import type { ListElement } from "@react-md/list";
import { FixedPositioningTransitionCallbacks } from "@react-md/transition";
import { ItemRefList } from "@react-md/utils";
import { AutoCompleteData, AutoCompleteListboxPositionOptions, AutoCompleteProps } from "./types";
import type { AutoCompleteData, AutoCompleteListboxPositionOptions, AutoCompleteProps } from "./types";
declare type EventHandlers = Pick<HTMLAttributes<HTMLInputElement>, "onBlur" | "onFocus" | "onChange" | "onClick" | "onKeyDown">;

@@ -7,0 +7,0 @@ export declare type RequiredAutoCompleteProps = Required<Pick<AutoCompleteProps, "data" | "filter" | "filterOptions" | "filterOnNoValue" | "valueKey" | "getResultId" | "getResultValue" | "clearOnAutoComplete">>;

@@ -1,3 +0,3 @@

import { ReactNode } from "react";
import { AutoCompleteData, AutoCompleteFilterFunction, FilterFunction } from "./types";
import type { ReactNode } from "react";
import type { AutoCompleteData, AutoCompleteFilterFunction, FilterFunction } from "./types";
/**

@@ -4,0 +4,0 @@ * Generates an id for each result in the autocomplete's listbox.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc