import * as React from "react"; import { StoryFn, Meta } from "@storybook/react"; import { TextInputWithBadges } from "../index"; import { InputStoryWrapper } from "../../../decorators/inputStoryWrapper"; import TextInputWithBadgesStoryHelper from "./helpers/TextInputWithBadgesStoryHelper"; import { Typeahead } from "../../typeahead"; import TextInputWithBadgesTypeaheadStoryHelper from "./helpers/TextInputWithBadgesTypeaheadStoryHelper"; const typeaheadItems = [ { value: "exosphere", label: "Exosphere" }, { value: "thermosphere", label: "Thermosphere" }, { value: "mesosphere", label: "Mesosphere" }, { value: "stratosphere", label: "Stratosphere" }, { value: "ozone-layer", label: "Ozone Layer" }, { value: "troposphere", label: "Troposphere" } ]; const defaultBadges = [ { label: "Badge one", value: "badge-one" }, { label: "Badge two", value: "badge-two" }, { label: "Badge three", value: "badge-three" } ]; export default { title: "Forms/TextInputWithBadges", decorators: [Story => {Story()}], component: TextInputWithBadges, argTypes: { hintContent: { inputLabel: { control: { type: "text" } }, control: { type: "text" } }, tooltipContent: { control: { type: "text" } }, errors: { control: { disable: true } } }, args: { appearance: "standard", inputLabel: "Default Input Label" } } as Meta; const Template: StoryFn = args => ( {({ badges, badgeChangeHandler }) => ( )} ); export const Default = { render: Template }; export const DontAddBadgeOnBlur = { render: args => ( {({ badges, badgeChangeHandler }) => ( )} ) }; export const UsedWithTypeaheadPrefilledWBadges = { render: args => ( {({ items, selectHandler, selectedItems, badgeChangeHandler, badges }) => { return ( !badges.map(badge => badge.value).includes(item.value) )} selectedItems={selectedItems} keepOpenOnSelect={false} resetInputOnSelect={true} textField={ } onSelect={selectHandler} /> ); }} ) };