![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@purpurds/autocomplete
Advanced tools
import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
import * as AutocompleteStories from "./src/autocomplete.stories"; import packageInfo from "./package.json";
Version {packageInfo.version}
Add the dependency to your consumer app like "@purpurds/purpur": "^x.y.z"
In MyApp.tsx
import "@purpurds/purpur/styles";
In MyComponent.tsx
import { Autocomplete, Option, TextField } from "@purpurds/purpur";
import { useState } from "React";
export const MyComponent = () => {
const options: Options[] = [
/* Your options */
];
const [selectedOption, setSelectedOption] = useState<Option>();
return (
<Autocomplete
id="autocomplete"
listboxLabel="Label for listbox, for a11y (describe the options)"
selectedOption={selectedOption}
onSelect={selectedOption}
options={options}
selectedOption
renderInput={(inputProps) => (
<TextField
{...inputProps}
label="Text Field"
id="autocomplete-input"
type="text"
placeholder="Write something"
/>
)}
/>
);
};
import { Autocomplete, Option, SearchField } from "@purpurds/purpur";
import { useState } from "React";
export const MyComponent = () => {
const options: Options[] = [
/* Your options */
];
const [selectedOption, setSelectedOption] = useState<Option>();
const [inputValue, setInputValue] = useState("");
return (
<Autocomplete
id="autocomplete"
listboxLabel="Label for listbox, for a11y (describe the options)"
selectedOption={selectedOption}
onSelect={selectedOption}
options={options}
selectedOption
onInputChange={setInputValue}
inputValue={inputValue}
renderInput={(inputProps) => (
<SearchField
{...inputProps}
label="Text Field"
id="autocomplete-input"
type="text"
placeholder="Write something"
onClear={() => setInputValue("")}
clearButtonAllyLabel="Rensa sökfältet"
variant="button-attached"
iconOnlySearchButton
searchButtonLabel="Search"
/>
)}
/>
);
};
renderOption
function (using Purpur TextField)Highlight parts of the option labels that are matching the input value
import { Autocomplete, Option, Paragraph, TextField } from "@purpurds/purpur";
import { useState } from "React";
export const MyComponent = () => {
const options: Options[] = [
/* Your options */
];
const [inputValue, setInputValue] = useState("");
const [selectedOption, setSelectedOption] = useState<Option>();
function renderOption(option: Option) {
const optionText = option.label;
if (!inputValue.trim()) {
return optionText;
}
const escapeRegExp = (str = "") => str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
const regex = new RegExp(`(${escapeRegExp(inputValue)})`, "gi");
const parts = optionText.split(regex);
return (
<Paragraph>
{parts
.filter((part) => part)
.map((part, i) =>
regex.test(part) ? <strong key={i}>{part}</strong> : <span key={i}>{part}</span>
)}
</Paragraph>
);
}
return (
<Autocomplete
id="autocomplete"
listboxLabel="Label for listbox, for a11y (describe the options)"
selectedOption={selectedOption}
onSelect={setSelectedOption}
onInputChange={setInputValue}
inputValue={inputValue}
renderOption={renderOption}
options={options}
renderInput={(inputProps) => (
<TextField {...inputProps} label="With renderOption" id="autocomplete-input" type="text" />
)}
/>
);
};
FAQs
import { Meta, Stories, ArgTypes, Primary, Subtitle } from "@storybook/blocks";
The npm package @purpurds/autocomplete receives a total of 0 weekly downloads. As such, @purpurds/autocomplete popularity was classified as not popular.
We found that @purpurds/autocomplete demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.