import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React from 'react';
import { AriaLiveRegion } from '@workday/canvas-kit-react/common';
import { FormField } from '@workday/canvas-kit-react/form-field';
import { Flex } from '@workday/canvas-kit-react/layout';
import { BodyText, Heading } from '@workday/canvas-kit-react/text';
import { TextInput } from '@workday/canvas-kit-react/text-input';
import { createStyles, px2rem } from '@workday/canvas-kit-styling';
import { system } from '@workday/canvas-tokens-web';
const fruits = [
    'Apples',
    'Oranges',
    'Bananas',
    'Lemons',
    'Limes',
    'Strawberries',
    'Raspberries',
    'Blackberries',
];
const liveRegionStyle = createStyles({
    border: `${px2rem(1)} solid ${system.color.brand.focus.caution.outer}`,
    backgroundColor: system.color.brand.surface.caution.strong,
    padding: system.padding.xs,
});
const listStyles = createStyles({
    paddingInlineStart: '0',
});
const listItemStyles = createStyles({
    listStyle: 'none',
    paddingInlineStart: '0',
});
const flexStyles = createStyles({
    gap: system.gap.md,
});
let filteredFruits = fruits;
export const FilterListWithLiveStatus = () => {
    const [filter, setFilter] = React.useState('');
    function handleFilter(e) {
        filteredFruits = fruits.filter(i => i.toUpperCase().indexOf(e.target.value.toUpperCase()) >= 0);
        setFilter(e.target.value);
    }
    return (_jsxs(_Fragment, { children: [_jsxs(Flex, { cs: flexStyles, children: [_jsx(Heading, { size: "small", children: "Fruits" }), _jsx(AriaLiveRegion, { children: _jsx(BodyText, { size: "small", cs: liveRegionStyle, children: `Showing ${filteredFruits.length} of ${fruits.length}` }) })] }), _jsxs(FormField, { children: [_jsx(FormField.Label, { children: "Filter Items:" }), _jsx(FormField.Input, { as: TextInput, value: filter, onChange: handleFilter })] }), _jsx("ul", { className: listStyles, children: filteredFruits.map(i => (_jsx(BodyText, { size: "small", as: "li", cs: listItemStyles, children: i }, i))) })] }));
};
