@launchpad-ui/filter 0.11.17 → 0.11.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppliedFilter.d.ts.map +1 -1
- package/dist/AppliedFilterButton.d.ts.map +1 -1
- package/dist/Filter.d.ts +1 -1
- package/dist/Filter.d.ts.map +1 -1
- package/dist/FilterButton.d.ts.map +1 -1
- package/dist/FilterMenu.d.ts +1 -1
- package/dist/FilterMenu.d.ts.map +1 -1
- package/dist/index.es.js +282 -214
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +270 -217
- package/dist/index.js.map +1 -1
- package/dist/style.css +0 -1
- package/package.json +12 -12
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","names":[],"sources":["../src/styles/Filter.module.css","../src/AppliedFilterButton.tsx","../src/FilterMenu.tsx","../src/AppliedFilter.tsx","../src/FilterButton.tsx","../src/Filter.tsx"],"sourcesContent":[":root,\n[data-theme='default'] {\n\t--lp-component-filter-color-bg-clearable: rgb(0 0 0 / 0.15);\n\t--lp-component-filter-color-bg-clearable-focus: rgb(0 0 0 / 0.2);\n\t--lp-component-filter-color-border-clearable-focus: var(--lp-color-gray-800);\n}\n\n[data-theme='dark'] {\n\t--lp-component-filter-color-bg-clearable: rgb(248 248 248 / 0.15);\n\t--lp-component-filter-color-bg-clearable-focus: rgb(248 248 248 / 0.2);\n\t--lp-component-filter-color-border-clearable-focus: var(--lp-color-gray-500);\n}\n\n.filter {\n\tfont-family: var(--lp-font-family-base);\n}\n\n.buttonContainer {\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tposition: relative;\n}\n\n.button {\n\tborder-radius: var(--lp-border-radius-medium);\n\tpadding-top: 0;\n\tpadding-bottom: 0;\n\tline-height: 2rem;\n\tdisplay: flex;\n\talign-items: center;\n\tmargin: 0;\n\tcolor: var(--lp-color-text-ui-primary-base);\n\tbackground-color: var(--lp-color-bg-interactive-secondary-base);\n}\n\n.appliedButton {\n\tcolor: var(--lp-color-text-ui-primary-base);\n\theight: 1.25rem;\n\tbackground-color: var(--lp-color-bg-interactive-secondary-hover);\n\tpadding: 0.125rem 0.375rem;\n\tborder-radius: 0.125rem;\n\tdisplay: flex;\n}\n\n.button,\n.appliedButton {\n\tfont-family: inherit;\n\tfont-size: 0.8125rem;\n\tcursor: pointer;\n\tborder-width: var(--lp-border-width-200);\n\tborder-style: solid;\n\tborder-color: transparent;\n\n\t&:hover {\n\t\tbackground-color: var(--lp-color-bg-interactive-secondary-hover);\n\t\tborder-color: var(--lp-color-border-interactive-secondary-hover);\n\t}\n\n\t&:focus-visible {\n\t\toutline: none;\n\t\tborder-color: var(--lp-color-border-interactive-secondary-focus);\n\t\tbox-shadow:\n\t\t\t0 0 0 2px var(--lp-color-bg-ui-primary),\n\t\t\t0 0 0 4px var(--lp-color-shadow-interactive-focus);\n\t}\n}\n\n.name {\n\tmargin-right: 0.3125rem;\n\tfont-weight: var(--lp-font-weight-medium);\n}\n\n.appliedName {\n\tmargin-right: 0.1875rem;\n}\n\n.description {\n\tcolor: var(--lp-color-text-ui-primary-base);\n\tfont-weight: var(--lp-font-weight-medium);\n}\n\n.description,\n.appliedDescription {\n\tmargin-right: 0.3125rem;\n\tmax-width: 10rem;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.clear {\n\tcursor: pointer;\n\tpadding: 0.1875rem;\n}\n\n.button.isClearable {\n\tpadding-right: 1.9375rem;\n\tbackground-color: var(--lp-component-filter-color-bg-clearable);\n\n\t&:focus,\n\t&:hover,\n\t&:active {\n\t\tbackground-color: var(--lp-component-filter-color-bg-clearable-focus);\n\t\tborder-color: var(--lp-component-filter-color-border-clearable-focus);\n\t}\n}\n\n.button:hover:not(.isClearable),\n.button:focus:not(.isClearable),\n[data-state='open'] .button:not(.isClearable) {\n\tbackground-color: var(--lp-color-bg-interactive-secondary-hover);\n\tborder-color: var(--lp-color-border-interactive-secondary-hover);\n}\n\n.button:focus:not(:focus-visible):not(.isClearable) {\n\t&:hover {\n\t\tbackground-color: var(--lp-color-bg-interactive-secondary-hover);\n\t}\n}\n\n.clearTooltip {\n\tline-height: 1;\n\tposition: absolute;\n\tright: 0.4375rem;\n}\n\n.filterClearButton {\n\ttext-decoration: none;\n\tcolor: var(--lp-color-text-interactive-destructive);\n\tfont-size: 0.8125rem;\n\tfont-weight: var(--lp-font-weight-medium);\n\tpadding: 0.625rem;\n\twidth: 100%;\n\tborder-bottom: 1px solid var(--lp-color-border-interactive-secondary-base);\n}\n\n.filterClearButton:active,\n.filterClearButton:focus,\n.filterClearButton:hover {\n\toutline: none;\n\tbox-shadow: unset;\n\tcolor: var(--lp-color-text-interactive-destructive);\n}\n\n.filterClearButton:active {\n\tborder-bottom-color: var(--lp-color-border-interactive-secondary-active);\n\tbackground-color: var(--lp-color-bg-interactive-secondary-active);\n}\n\n.filterClearButton:focus {\n\tborder-bottom-color: var(--lp-color-border-interactive-secondary-focus);\n\tbackground-color: var(--lp-color-bg-interactive-secondary-focus);\n}\n\n.filterClearButton:hover {\n\tborder-bottom-color: var(--lp-color-border-interactive-secondary-hover);\n\tbackground-color: var(--lp-color-bg-interactive-secondary-hover);\n}\n","import type { ReactNode } from 'react';\n\nimport { Icon } from '@launchpad-ui/icons';\nimport { cx } from 'classix';\nimport { Children, forwardRef } from 'react';\n\nimport styles from './styles/Filter.module.css';\n\ntype AppliedFilterButtonProps = {\n\tname?: ReactNode;\n\tclassName?: string;\n\tchildren: ReactNode;\n\tonClickFilterButton?(): void;\n\t'data-test-id'?: string;\n};\n\ntype Ref = HTMLButtonElement;\n\nconst AppliedFilterButton = forwardRef<Ref, AppliedFilterButtonProps>((props, ref) => {\n\tconst {\n\t\tname,\n\t\tclassName,\n\t\tchildren,\n\t\tonClickFilterButton,\n\t\t'data-test-id': testId = 'applied-filter-button',\n\t} = props;\n\n\tconst hasDescription = Children.count(children) !== 0;\n\n\treturn (\n\t\t<div data-test-id={testId}>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-haspopup\n\t\t\t\tclassName={cx(styles.appliedButton, className)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={onClickFilterButton}\n\t\t\t>\n\t\t\t\t{name && (\n\t\t\t\t\t<span className={styles.appliedName} data-test-id={`${testId}-name`}>\n\t\t\t\t\t\t{name}\n\t\t\t\t\t\t{hasDescription && ':'}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{hasDescription && (\n\t\t\t\t\t<span className={styles.appliedDescription} data-test-id={`${testId}-description`}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t<Icon name=\"chevron-down\" size=\"small\" data-test-id={`${testId}-expand`} />\n\t\t\t</button>\n\t\t</div>\n\t);\n});\n\nAppliedFilterButton.displayName = 'AppliedFilterButton';\n\nexport type { AppliedFilterButtonProps };\nexport { AppliedFilterButton };\n","import type { MenuProps } from '@launchpad-ui/menu';\nimport type { ChangeEvent, ReactNode } from 'react';\n\nimport { Button } from '@launchpad-ui/button';\nimport { Icon } from '@launchpad-ui/icons';\nimport { Menu, MenuDivider, MenuItem, MenuSearch } from '@launchpad-ui/menu';\n\nimport styles from './styles/Filter.module.css';\n\n// biome-ignore lint/suspicious/noExplicitAny: ignore\ntype FilterOption<T = any> = {\n\tname?: ReactNode;\n\tisDisabled?: boolean;\n\tisDivider?: boolean;\n\tisChecked?: boolean;\n\tvalue: T | null;\n\tprojKey?: string;\n\tnested?: boolean;\n\tgroupHeader?: boolean;\n};\n\ntype FilterMenuProps = Pick<MenuProps<string>, 'enableVirtualization' | 'size' | 'data-test-id'> & {\n\toptions: FilterOption[];\n\tonClearFilter?(): void;\n\tenableSearch?: boolean;\n\tsearchValue?: string;\n\tsearchId?: string;\n\tsearchPlaceholder?: string;\n\tsearchAriaLabel?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tonSelect?(): void;\n\tisLoading?: boolean;\n\tdisabledOptionTooltip?: string;\n};\n\nconst FilterMenu = ({\n\toptions,\n\tonClearFilter,\n\tenableSearch,\n\tsearchValue,\n\tsearchPlaceholder,\n\tsearchAriaLabel,\n\tsearchId,\n\tonSelect,\n\tonSearchChange,\n\tisLoading = false,\n\tdisabledOptionTooltip,\n\tenableVirtualization,\n\tsize,\n\t'data-test-id': testId = 'filter-menu',\n}: FilterMenuProps) => {\n\tconst filterOptions = isLoading\n\t\t? [{ name: 'loading...', value: 'loading...', isDisabled: true }]\n\t\t: options;\n\n\treturn (\n\t\t<>\n\t\t\t{onClearFilter && (\n\t\t\t\t<Button\n\t\t\t\t\ttabIndex={0}\n\t\t\t\t\tclassName={styles.filterClearButton}\n\t\t\t\t\tonClick={onClearFilter}\n\t\t\t\t\tkind=\"link\"\n\t\t\t\t\tdata-test-id=\"clear-filter-button\"\n\t\t\t\t>\n\t\t\t\t\tCLEAR FILTER\n\t\t\t\t</Button>\n\t\t\t)}\n\t\t\t<Menu\n\t\t\t\tenableVirtualization={enableVirtualization}\n\t\t\t\tsize={size}\n\t\t\t\tdata-test-id={testId}\n\t\t\t\tonSelect={onSelect}\n\t\t\t>\n\t\t\t\t{enableSearch && (\n\t\t\t\t\t<MenuSearch\n\t\t\t\t\t\tvalue={searchValue}\n\t\t\t\t\t\tid={searchId}\n\t\t\t\t\t\tplaceholder={searchPlaceholder}\n\t\t\t\t\t\tonChange={onSearchChange}\n\t\t\t\t\t\tariaLabel={searchAriaLabel}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{filterOptions.map((option, index) => {\n\t\t\t\t\tif (option.isDivider) {\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: ignore\n\t\t\t\t\t\treturn <MenuDivider key={`divider-${index}`} />;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\titem={option}\n\t\t\t\t\t\t\tdisabled={option.isDisabled}\n\t\t\t\t\t\t\ticon={option.isChecked ? <Icon name=\"check\" /> : undefined}\n\t\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\taria-checked={option.isChecked ? 'true' : undefined}\n\t\t\t\t\t\t\tnested={option.nested}\n\t\t\t\t\t\t\tgroupHeader={option.groupHeader}\n\t\t\t\t\t\t\ttooltip={\n\t\t\t\t\t\t\t\toption.isDisabled && disabledOptionTooltip ? disabledOptionTooltip : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttooltipPlacement=\"right\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.name}\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Menu>\n\t\t</>\n\t);\n};\n\nexport { FilterMenu };\nexport type { FilterOption, FilterMenuProps };\n","import type { ChangeEvent, ReactNode } from 'react';\nimport type { FilterOption } from './FilterMenu';\n\nimport { Dropdown } from '@launchpad-ui/dropdown';\n\nimport { AppliedFilterButton } from './AppliedFilterButton';\nimport { FilterMenu } from './FilterMenu';\n\nconst SEARCH_INPUT_THRESHOLD = 4;\n\ntype AppliedFilterProps = {\n\tsearchValue?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tonClearFilter?(): void;\n\tsearchPlaceholder?: string;\n\tname?: ReactNode;\n\tdescription: ReactNode;\n\toptions: FilterOption[];\n\tclassName?: string;\n\tonStateChange?({ isOpen }: { isOpen?: boolean }): void;\n\tonSelect?(item: FilterOption): void;\n\tisEmpty?: boolean;\n\tisLoading?: boolean;\n\tonClickFilterButton?(): void;\n\tsearchAriaLabel?: string;\n\tsearchId?: string;\n\t'data-test-id'?: string;\n};\n\n/**\n * @deprecated use `Menu` from `@launchpad-ui/components` instead\n *\n * https://launchpad.launchdarkly.com/?path=/docs/components-collections-menu--docs\n */\nconst AppliedFilter = ({\n\tsearchValue,\n\tonSearchChange,\n\tsearchPlaceholder,\n\tname,\n\tdescription,\n\toptions,\n\tclassName,\n\tisEmpty,\n\tisLoading,\n\tonClickFilterButton,\n\tonClearFilter,\n\tsearchAriaLabel,\n\tsearchId,\n\t'data-test-id': testId = 'applied-filter',\n\t...props\n}: AppliedFilterProps) => {\n\tconst enableSearch =\n\t\tonSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD || !isEmpty);\n\n\treturn (\n\t\t<Dropdown targetClassName={className} placement=\"bottom-start\" enableArrow={false} {...props}>\n\t\t\t<AppliedFilterButton\n\t\t\t\tdata-test-id={testId}\n\t\t\t\tname={name}\n\t\t\t\tonClickFilterButton={onClickFilterButton}\n\t\t\t>\n\t\t\t\t{description}\n\t\t\t</AppliedFilterButton>\n\t\t\t<FilterMenu\n\t\t\t\toptions={options}\n\t\t\t\tsearchValue={searchValue}\n\t\t\t\tsearchPlaceholder={searchPlaceholder}\n\t\t\t\tenableSearch={enableSearch}\n\t\t\t\tsearchAriaLabel={searchAriaLabel}\n\t\t\t\tsearchId={searchId}\n\t\t\t\tonSearchChange={onSearchChange}\n\t\t\t\tonClearFilter={onClearFilter}\n\t\t\t\tisLoading={isLoading}\n\t\t\t/>\n\t\t</Dropdown>\n\t);\n};\n\nexport type { AppliedFilterProps };\nexport { AppliedFilter };\n","import type { JSX, MouseEvent, ReactNode, SyntheticEvent } from 'react';\n\nimport { IconButton } from '@launchpad-ui/button';\nimport { Icon } from '@launchpad-ui/icons';\nimport { Tooltip } from '@launchpad-ui/tooltip';\nimport { cx } from 'classix';\nimport { Children, forwardRef, useId } from 'react';\nimport { VisuallyHidden } from 'react-aria/VisuallyHidden';\n\nimport styles from './styles/Filter.module.css';\n\ntype FilterButtonProps = {\n\tname: ReactNode;\n\thideName?: boolean;\n\tisClearable?: boolean;\n\tonClear?(event: SyntheticEvent): void;\n\tclassName?: string;\n\tisSelected?: boolean;\n\tclearTooltip?: string | JSX.Element;\n\tchildren?: ReactNode;\n\tdisabled?: boolean;\n\tonClickFilterButton?(): void;\n\t'data-test-id'?: string;\n\tariaLabel?: string;\n};\n\ntype Ref = HTMLButtonElement;\n\nconst FilterButton = forwardRef<Ref, FilterButtonProps>((props, ref) => {\n\tconst {\n\t\tchildren,\n\t\tname,\n\t\thideName,\n\t\tisClearable,\n\t\tclearTooltip = 'Clear filter',\n\t\tonClear,\n\t\tdisabled,\n\t\tisSelected,\n\t\tonClickFilterButton,\n\t\tclassName,\n\t\t'data-test-id': testId = 'filter-button',\n\t\tariaLabel = 'Clear filter',\n\t\t...rest\n\t} = props;\n\tconst nameId = useId();\n\tconst descriptionId = useId();\n\n\tconst hasDescription = Children.count(children) !== 0;\n\n\tconst nameElement = (\n\t\t<span className={styles.name}>\n\t\t\t{name}\n\t\t\t{hasDescription && ':'}\n\t\t</span>\n\t);\n\n\tconst isDisabled = disabled;\n\n\tconst handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n\t\tif (isDisabled) return event.preventDefault();\n\t\tonClickFilterButton?.();\n\t};\n\n\treturn (\n\t\t<div className={styles.buttonContainer} data-test-id={testId}>\n\t\t\t<button\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-labelledby={`${nameId} ${hasDescription ? descriptionId : ''}`}\n\t\t\t\taria-haspopup\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\taria-disabled={isDisabled}\n\t\t\t\tclassName={cx(styles.button, className, (isClearable || isSelected) && styles.isClearable)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={handleClick}\n\t\t\t>\n\t\t\t\t{hideName ? (\n\t\t\t\t\t<VisuallyHidden id={nameId}>{nameElement}</VisuallyHidden>\n\t\t\t\t) : (\n\t\t\t\t\t<span id={nameId}>{nameElement}</span>\n\t\t\t\t)}\n\t\t\t\t{hasDescription && (\n\t\t\t\t\t<span id={descriptionId} className={styles.description}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!isClearable && <Icon name=\"chevron-down\" size=\"small\" />}\n\t\t\t</button>\n\t\t\t{isClearable && (\n\t\t\t\t<Tooltip targetClassName={styles.clearTooltip} content={clearTooltip}>\n\t\t\t\t\t<IconButton\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\tclassName={styles.clear}\n\t\t\t\t\t\tdata-test-id=\"clear-filter-button\"\n\t\t\t\t\t\ticon={<Icon name=\"cancel\" size=\"small\" />}\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tonClick={onClear}\n\t\t\t\t\t/>\n\t\t\t\t</Tooltip>\n\t\t\t)}\n\t\t</div>\n\t);\n});\n\nFilterButton.displayName = 'FilterButton';\n\nexport { FilterButton };\nexport type { FilterButtonProps };\n","import type { MenuProps } from '@launchpad-ui/menu';\nimport type { ChangeEvent, ReactNode, SyntheticEvent } from 'react';\nimport type { FilterOption } from './FilterMenu';\n\nimport { Dropdown } from '@launchpad-ui/dropdown';\nimport { cx } from 'classix';\n\nimport { FilterButton } from './FilterButton';\nimport { FilterMenu } from './FilterMenu';\nimport styles from './styles/Filter.module.css';\n\nconst SEARCH_INPUT_THRESHOLD = 4;\n\ntype FilterProps = Pick<MenuProps<string>, 'size' | 'enableVirtualization'> & {\n\tsearchValue?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tsearchPlaceholder?: string;\n\tsearchAriaLabel?: string;\n\tname: ReactNode;\n\thideName?: boolean;\n\tdescription: ReactNode;\n\toptions: FilterOption[];\n\tisClearable?: boolean;\n\tonClear?(): void;\n\tclassName?: string;\n\tonStateChange?({ isOpen }: { isOpen?: boolean }): void;\n\tisSelected?: boolean;\n\tsearchId?: string;\n\tonSelect?(item: FilterOption): void;\n\tisEmpty?: boolean;\n\tisLoading?: boolean;\n\tdisabled?: boolean;\n\tonClickFilterButton?(): void;\n\tdisabledOptionTooltip?: string;\n\t'data-test-id'?: string;\n\ttriggerTestId?: string;\n\tclearAriaLabel?: string;\n};\n\n/**\n * @deprecated use `Menu` from `@launchpad-ui/components` instead\n *\n * https://launchpad.launchdarkly.com/?path=/docs/components-collections-menu--docs\n */\nconst Filter = ({\n\tsearchValue,\n\tonSearchChange,\n\tsearchPlaceholder,\n\tsearchAriaLabel,\n\tname,\n\thideName,\n\tdescription,\n\toptions,\n\tisClearable,\n\tonClear,\n\tisSelected,\n\tclassName,\n\tisEmpty,\n\tsearchId,\n\tisLoading,\n\tonClickFilterButton,\n\tdisabledOptionTooltip,\n\t'data-test-id': testId = 'filter',\n\tsize,\n\tdisabled,\n\tenableVirtualization,\n\tclearAriaLabel,\n\t...props\n}: FilterProps) => {\n\tconst enableSearch =\n\t\tonSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD || !isEmpty);\n\n\tconst dropdownClasses = cx(styles.filter, className);\n\n\tconst handleClear = (event: SyntheticEvent) => {\n\t\tevent.preventDefault();\n\t\tonClear?.();\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\ttargetTestId={testId}\n\t\t\tdisabled={disabled}\n\t\t\ttargetClassName={dropdownClasses}\n\t\t\t{...props}\n\t\t>\n\t\t\t<FilterButton\n\t\t\t\tisClearable={isClearable}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tname={name}\n\t\t\t\thideName={hideName}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tisSelected={isSelected}\n\t\t\t\tonClickFilterButton={onClickFilterButton}\n\t\t\t\tariaLabel={clearAriaLabel}\n\t\t\t>\n\t\t\t\t{description}\n\t\t\t</FilterButton>\n\t\t\t<FilterMenu\n\t\t\t\toptions={options}\n\t\t\t\tsearchId={searchId}\n\t\t\t\tsearchValue={searchValue}\n\t\t\t\tsearchPlaceholder={searchPlaceholder}\n\t\t\t\tsearchAriaLabel={searchAriaLabel}\n\t\t\t\tenableSearch={enableSearch}\n\t\t\t\tonSearchChange={onSearchChange}\n\t\t\t\tisLoading={isLoading}\n\t\t\t\tdisabledOptionTooltip={disabledOptionTooltip}\n\t\t\t\tsize={size}\n\t\t\t\tenableVirtualization={enableVirtualization}\n\t\t\t/>\n\t\t</Dropdown>\n\t);\n};\n\nexport { Filter };\nexport type { FilterProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;ACkBA,IAAM,sBAAsB,4BAA2C,OAAO,QAAQ;CACrF,MAAM,EACL,MAAA,QACA,WACA,UACA,qBACA,gBAAgB,SAAS,4BACtB;CAEJ,MAAM,iBAAiB,SAAS,MAAM,SAAS,KAAK;AAEpD,QACC,oBAAC,OAAA;EAAI,gBAAc;YAClB,qBAAC,UAAA;GACA,MAAK;GACL,iBAAA;GACA,WAAW,GAAG,sBAAO,eAAe,UAAU;GACzC;GACL,SAAS;;IAER,UACA,qBAAC,QAAA;KAAK,WAAW,sBAAO;KAAa,gBAAc,GAAG,OAAO;gBAC3D,QACA,kBAAkB,IAAA;MACb;IAEP,kBACA,oBAAC,QAAA;KAAK,WAAW,sBAAO;KAAoB,gBAAc,GAAG,OAAO;KAClE;MACK;IAER,oBAAC,MAAA;KAAK,MAAK;KAAe,MAAK;KAAQ,gBAAc,GAAG,OAAO;;;;GAE3D;EAEN;AAEF,oBAAoB,cAAc;ACpBlC,IAAM,cAAc,EACnB,SACA,eACA,cACA,aACA,mBACA,iBACA,UACA,UACA,gBACA,YAAY,OACZ,uBACA,sBACA,MACA,gBAAgB,SAAS,oBACH;CACtB,MAAM,gBAAgB,YACnB,CAAC;EAAE,MAAM;EAAc,OAAO;EAAc,YAAY;EAAM,CAAC,GAC/D;AAEH,QACC,qBAAA,UAAA,EAAA,UAAA,CACE,iBACA,oBAAC,QAAA;EACA,UAAU;EACV,WAAW,sBAAO;EAClB,SAAS;EACT,MAAK;EACL,gBAAa;YACb;GAEQ,EAEV,qBAAC,MAAA;EACsB;EAChB;EACN,gBAAc;EACJ;aAET,gBACA,oBAAC,YAAA;GACA,OAAO;GACP,IAAI;GACJ,aAAa;GACb,UAAU;GACV,WAAW;IACV,EAEF,cAAc,KAAK,QAAQ,UAAU;AACrC,OAAI,OAAO,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EACJ;EACV,iBAAiB;EACjB,GAAI;aAEJ,oBAAC,cAAA;GACa,aAAA;GACb,SAAS;GACH,MAAA;GACI;GACA;GACE;GACS;GACrB,WAAW;aAEV;IACa,EACf,oBAAC,YAAA;GACS;GACC;GACG;GACM;GACF;GACH;GACE;GACL;GACY;GACjB;GACgB;IACrB,CAAA;GACQ"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/AppliedFilterButton.tsx","../src/FilterMenu.tsx","../src/AppliedFilter.tsx","../src/FilterButton.tsx","../src/Filter.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Children, forwardRef } from 'react';\nimport { cx } from 'classix';\n\nimport { Icon } from '@launchpad-ui/icons';\n\nimport styles from './styles/Filter.module.css';\n\ntype AppliedFilterButtonProps = {\n\tname?: ReactNode;\n\tclassName?: string;\n\tchildren: ReactNode;\n\tonClickFilterButton?(): void;\n\t'data-test-id'?: string;\n};\n\ntype Ref = HTMLButtonElement;\n\nconst AppliedFilterButton = forwardRef<Ref, AppliedFilterButtonProps>((props, ref) => {\n\tconst { name, className, children, onClickFilterButton, 'data-test-id': testId = 'applied-filter-button' } = props;\n\n\tconst hasDescription = Children.count(children) !== 0;\n\n\treturn (\n\t\t<div data-test-id={testId}>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-haspopup\n\t\t\t\tclassName={cx(styles.appliedButton, className)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={onClickFilterButton}\n\t\t\t>\n\t\t\t\t{name && (\n\t\t\t\t\t<span className={styles.appliedName} data-test-id={`${testId}-name`}>\n\t\t\t\t\t\t{name}\n\t\t\t\t\t\t{hasDescription && ':'}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{hasDescription && (\n\t\t\t\t\t<span className={styles.appliedDescription} data-test-id={`${testId}-description`}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t<Icon name=\"chevron-down\" size=\"small\" data-test-id={`${testId}-expand`} />\n\t\t\t</button>\n\t\t</div>\n\t);\n});\n\nAppliedFilterButton.displayName = 'AppliedFilterButton';\n\nexport type { AppliedFilterButtonProps };\nexport { AppliedFilterButton };\n","import type { ChangeEvent, ReactNode } from 'react';\n\nimport { Button } from '@launchpad-ui/button';\nimport { Icon } from '@launchpad-ui/icons';\nimport type { MenuProps } from '@launchpad-ui/menu';\nimport { Menu, MenuDivider, MenuItem, MenuSearch } from '@launchpad-ui/menu';\n\nimport styles from './styles/Filter.module.css';\n\n// `FilterOption` is never parameterized by call sites in this codebase (always used bare as\n// `FilterOption[]`), yet real usages populate `value` with heterogeneous primitive types\n// (strings in some tests/stories, numbers in others) and downstream code reads `value` both\n// as a React `Key` (`key={option.value}`) and via string methods (`option.value.includes(...)`)\n// without narrowing first. `unknown` and `string` were tried and both broke real call sites\n// (see git history on this line) because the actual runtime values aren't homogeneous. `any` is\n// the honest type for \"whatever primitive the consumer's data uses\" until FilterMenu is\n// refactored to require callers to parameterize `FilterOption<T>` explicitly.\n// oxlint-disable-next-line typescript/no-explicit-any -- open generic default; see comment above for why unknown/string don't work here\ntype FilterOption<T = any> = {\n\tname?: ReactNode;\n\tisDisabled?: boolean;\n\tisDivider?: boolean;\n\tisChecked?: boolean;\n\tvalue: T | null;\n\tprojKey?: string;\n\tnested?: boolean;\n\tgroupHeader?: boolean;\n};\n\ntype FilterMenuProps = Pick<MenuProps<string>, 'enableVirtualization' | 'size' | 'data-test-id'> & {\n\toptions: FilterOption[];\n\tonClearFilter?(): void;\n\tenableSearch?: boolean;\n\tsearchValue?: string;\n\tsearchId?: string;\n\tsearchPlaceholder?: string;\n\tsearchAriaLabel?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tonSelect?(): void;\n\tisLoading?: boolean;\n\tdisabledOptionTooltip?: string;\n};\n\nconst FilterMenu = ({\n\toptions,\n\tonClearFilter,\n\tenableSearch,\n\tsearchValue,\n\tsearchPlaceholder,\n\tsearchAriaLabel,\n\tsearchId,\n\tonSelect,\n\tonSearchChange,\n\tisLoading = false,\n\tdisabledOptionTooltip,\n\tenableVirtualization,\n\tsize,\n\t'data-test-id': testId = 'filter-menu',\n}: FilterMenuProps) => {\n\tconst filterOptions = isLoading ? [{ name: 'loading...', value: 'loading...', isDisabled: true }] : options;\n\n\treturn (\n\t\t<>\n\t\t\t{onClearFilter && (\n\t\t\t\t<Button\n\t\t\t\t\ttabIndex={0}\n\t\t\t\t\tclassName={styles.filterClearButton}\n\t\t\t\t\tonClick={onClearFilter}\n\t\t\t\t\tkind=\"link\"\n\t\t\t\t\tdata-test-id=\"clear-filter-button\"\n\t\t\t\t>\n\t\t\t\t\tCLEAR FILTER\n\t\t\t\t</Button>\n\t\t\t)}\n\t\t\t<Menu enableVirtualization={enableVirtualization} size={size} data-test-id={testId} onSelect={onSelect}>\n\t\t\t\t{enableSearch && (\n\t\t\t\t\t<MenuSearch\n\t\t\t\t\t\tvalue={searchValue}\n\t\t\t\t\t\tid={searchId}\n\t\t\t\t\t\tplaceholder={searchPlaceholder}\n\t\t\t\t\t\tonChange={onSearchChange}\n\t\t\t\t\t\tariaLabel={searchAriaLabel}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{filterOptions.map((option, index) => {\n\t\t\t\t\tif (option.isDivider) {\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: ignore\n\t\t\t\t\t\treturn <MenuDivider key={`divider-${index}`} />;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\titem={option}\n\t\t\t\t\t\t\tdisabled={option.isDisabled}\n\t\t\t\t\t\t\ticon={option.isChecked ? <Icon name=\"check\" /> : undefined}\n\t\t\t\t\t\t\tkey={option.value}\n\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\taria-checked={option.isChecked ? 'true' : undefined}\n\t\t\t\t\t\t\tnested={option.nested}\n\t\t\t\t\t\t\tgroupHeader={option.groupHeader}\n\t\t\t\t\t\t\ttooltip={option.isDisabled && disabledOptionTooltip ? disabledOptionTooltip : undefined}\n\t\t\t\t\t\t\ttooltipPlacement=\"right\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.name}\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Menu>\n\t\t</>\n\t);\n};\n\nexport { FilterMenu };\nexport type { FilterOption, FilterMenuProps };\n","import type { ChangeEvent, ReactNode } from 'react';\n\nimport { Dropdown } from '@launchpad-ui/dropdown';\n\nimport { AppliedFilterButton } from './AppliedFilterButton';\nimport type { FilterOption } from './FilterMenu';\nimport { FilterMenu } from './FilterMenu';\n\nconst SEARCH_INPUT_THRESHOLD = 4;\n\ntype AppliedFilterProps = {\n\tsearchValue?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tonClearFilter?(): void;\n\tsearchPlaceholder?: string;\n\tname?: ReactNode;\n\tdescription: ReactNode;\n\toptions: FilterOption[];\n\tclassName?: string;\n\tonStateChange?({ isOpen }: { isOpen?: boolean }): void;\n\tonSelect?(item: FilterOption): void;\n\tisEmpty?: boolean;\n\tisLoading?: boolean;\n\tonClickFilterButton?(): void;\n\tsearchAriaLabel?: string;\n\tsearchId?: string;\n\t'data-test-id'?: string;\n};\n\n/**\n * @deprecated use `Menu` from `@launchpad-ui/components` instead\n *\n * https://launchpad.launchdarkly.com/?path=/docs/components-collections-menu--docs\n */\nconst AppliedFilter = ({\n\tsearchValue,\n\tonSearchChange,\n\tsearchPlaceholder,\n\tname,\n\tdescription,\n\toptions,\n\tclassName,\n\tisEmpty,\n\tisLoading,\n\tonClickFilterButton,\n\tonClearFilter,\n\tsearchAriaLabel,\n\tsearchId,\n\t'data-test-id': testId = 'applied-filter',\n\t...props\n}: AppliedFilterProps) => {\n\tconst enableSearch = onSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD || !isEmpty);\n\n\treturn (\n\t\t<Dropdown targetClassName={className} placement=\"bottom-start\" enableArrow={false} {...props}>\n\t\t\t<AppliedFilterButton data-test-id={testId} name={name} onClickFilterButton={onClickFilterButton}>\n\t\t\t\t{description}\n\t\t\t</AppliedFilterButton>\n\t\t\t<FilterMenu\n\t\t\t\toptions={options}\n\t\t\t\tsearchValue={searchValue}\n\t\t\t\tsearchPlaceholder={searchPlaceholder}\n\t\t\t\tenableSearch={enableSearch}\n\t\t\t\tsearchAriaLabel={searchAriaLabel}\n\t\t\t\tsearchId={searchId}\n\t\t\t\tonSearchChange={onSearchChange}\n\t\t\t\tonClearFilter={onClearFilter}\n\t\t\t\tisLoading={isLoading}\n\t\t\t/>\n\t\t</Dropdown>\n\t);\n};\n\nexport type { AppliedFilterProps };\nexport { AppliedFilter };\n","import type { JSX, MouseEvent, ReactNode, SyntheticEvent } from 'react';\nimport { Children, forwardRef, useId } from 'react';\nimport { VisuallyHidden } from 'react-aria/VisuallyHidden';\nimport { cx } from 'classix';\n\nimport { IconButton } from '@launchpad-ui/button';\nimport { Icon } from '@launchpad-ui/icons';\nimport { Tooltip } from '@launchpad-ui/tooltip';\n\nimport styles from './styles/Filter.module.css';\n\ntype FilterButtonProps = {\n\tname: ReactNode;\n\thideName?: boolean;\n\tisClearable?: boolean;\n\tonClear?(event: SyntheticEvent): void;\n\tclassName?: string;\n\tisSelected?: boolean;\n\tclearTooltip?: string | JSX.Element;\n\tchildren?: ReactNode;\n\tdisabled?: boolean;\n\tonClickFilterButton?(): void;\n\t'data-test-id'?: string;\n\tariaLabel?: string;\n};\n\ntype Ref = HTMLButtonElement;\n\nconst FilterButton = forwardRef<Ref, FilterButtonProps>((props, ref) => {\n\tconst {\n\t\tchildren,\n\t\tname,\n\t\thideName,\n\t\tisClearable,\n\t\tclearTooltip = 'Clear filter',\n\t\tonClear,\n\t\tdisabled,\n\t\tisSelected,\n\t\tonClickFilterButton,\n\t\tclassName,\n\t\t'data-test-id': testId = 'filter-button',\n\t\tariaLabel = 'Clear filter',\n\t\t...rest\n\t} = props;\n\tconst nameId = useId();\n\tconst descriptionId = useId();\n\n\tconst hasDescription = Children.count(children) !== 0;\n\n\tconst nameElement = (\n\t\t<span className={styles.name}>\n\t\t\t{name}\n\t\t\t{hasDescription && ':'}\n\t\t</span>\n\t);\n\n\tconst isDisabled = disabled;\n\n\tconst handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n\t\tif (isDisabled) {\n\t\t\treturn event.preventDefault();\n\t\t}\n\t\tonClickFilterButton?.();\n\t};\n\n\treturn (\n\t\t<div className={styles.buttonContainer} data-test-id={testId}>\n\t\t\t<button\n\t\t\t\t{...rest}\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-labelledby={`${nameId} ${hasDescription ? descriptionId : ''}`}\n\t\t\t\taria-haspopup\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\taria-disabled={isDisabled}\n\t\t\t\tclassName={cx(styles.button, className, (isClearable || isSelected) && styles.isClearable)}\n\t\t\t\tref={ref}\n\t\t\t\tonClick={handleClick}\n\t\t\t>\n\t\t\t\t{hideName ? <VisuallyHidden id={nameId}>{nameElement}</VisuallyHidden> : <span id={nameId}>{nameElement}</span>}\n\t\t\t\t{hasDescription && (\n\t\t\t\t\t<span id={descriptionId} className={styles.description}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{!isClearable && <Icon name=\"chevron-down\" size=\"small\" />}\n\t\t\t</button>\n\t\t\t{isClearable && (\n\t\t\t\t<Tooltip targetClassName={styles.clearTooltip} content={clearTooltip}>\n\t\t\t\t\t<IconButton\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\tclassName={styles.clear}\n\t\t\t\t\t\tdata-test-id=\"clear-filter-button\"\n\t\t\t\t\t\ticon={<Icon name=\"cancel\" size=\"small\" />}\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tonClick={onClear}\n\t\t\t\t\t/>\n\t\t\t\t</Tooltip>\n\t\t\t)}\n\t\t</div>\n\t);\n});\n\nFilterButton.displayName = 'FilterButton';\n\nexport { FilterButton };\nexport type { FilterButtonProps };\n","import type { ChangeEvent, ReactNode, SyntheticEvent } from 'react';\nimport { cx } from 'classix';\n\nimport { Dropdown } from '@launchpad-ui/dropdown';\nimport type { MenuProps } from '@launchpad-ui/menu';\n\nimport { FilterButton } from './FilterButton';\nimport type { FilterOption } from './FilterMenu';\nimport { FilterMenu } from './FilterMenu';\n\nimport styles from './styles/Filter.module.css';\n\nconst SEARCH_INPUT_THRESHOLD = 4;\n\ntype FilterProps = Pick<MenuProps<string>, 'size' | 'enableVirtualization'> & {\n\tsearchValue?: string;\n\tonSearchChange?(event: ChangeEvent<HTMLInputElement>): void;\n\tsearchPlaceholder?: string;\n\tsearchAriaLabel?: string;\n\tname: ReactNode;\n\thideName?: boolean;\n\tdescription: ReactNode;\n\toptions: FilterOption[];\n\tisClearable?: boolean;\n\tonClear?(): void;\n\tclassName?: string;\n\tonStateChange?({ isOpen }: { isOpen?: boolean }): void;\n\tisSelected?: boolean;\n\tsearchId?: string;\n\tonSelect?(item: FilterOption): void;\n\tisEmpty?: boolean;\n\tisLoading?: boolean;\n\tdisabled?: boolean;\n\tonClickFilterButton?(): void;\n\tdisabledOptionTooltip?: string;\n\t'data-test-id'?: string;\n\ttriggerTestId?: string;\n\tclearAriaLabel?: string;\n};\n\n/**\n * @deprecated use `Menu` from `@launchpad-ui/components` instead\n *\n * https://launchpad.launchdarkly.com/?path=/docs/components-collections-menu--docs\n */\nconst Filter = ({\n\tsearchValue,\n\tonSearchChange,\n\tsearchPlaceholder,\n\tsearchAriaLabel,\n\tname,\n\thideName,\n\tdescription,\n\toptions,\n\tisClearable,\n\tonClear,\n\tisSelected,\n\tclassName,\n\tisEmpty,\n\tsearchId,\n\tisLoading,\n\tonClickFilterButton,\n\tdisabledOptionTooltip,\n\t'data-test-id': testId = 'filter',\n\tsize,\n\tdisabled,\n\tenableVirtualization,\n\tclearAriaLabel,\n\t...props\n}: FilterProps) => {\n\tconst enableSearch = onSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD || !isEmpty);\n\n\tconst dropdownClasses = cx(styles.filter, className);\n\n\tconst handleClear = (event: SyntheticEvent) => {\n\t\tevent.preventDefault();\n\t\tonClear?.();\n\t};\n\n\treturn (\n\t\t<Dropdown targetTestId={testId} disabled={disabled} targetClassName={dropdownClasses} {...props}>\n\t\t\t<FilterButton\n\t\t\t\tisClearable={isClearable}\n\t\t\t\tonClear={handleClear}\n\t\t\t\tname={name}\n\t\t\t\thideName={hideName}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tisSelected={isSelected}\n\t\t\t\tonClickFilterButton={onClickFilterButton}\n\t\t\t\tariaLabel={clearAriaLabel}\n\t\t\t>\n\t\t\t\t{description}\n\t\t\t</FilterButton>\n\t\t\t<FilterMenu\n\t\t\t\toptions={options}\n\t\t\t\tsearchId={searchId}\n\t\t\t\tsearchValue={searchValue}\n\t\t\t\tsearchPlaceholder={searchPlaceholder}\n\t\t\t\tsearchAriaLabel={searchAriaLabel}\n\t\t\t\tenableSearch={enableSearch}\n\t\t\t\tonSearchChange={onSearchChange}\n\t\t\t\tisLoading={isLoading}\n\t\t\t\tdisabledOptionTooltip={disabledOptionTooltip}\n\t\t\t\tsize={size}\n\t\t\t\tenableVirtualization={enableVirtualization}\n\t\t\t/>\n\t\t</Dropdown>\n\t);\n};\n\nexport { Filter };\nexport type { FilterProps };\n"],"names":["name","SEARCH_INPUT_THRESHOLD","description","isClearable","clearTooltip"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,sBAAsB,2BAA0C,CAAC,OAAO,QAAQ;AACrF,QAAM,EAAE,MAAAA,OAAM,WAAW,UAAU,qBAAqB,gBAAgB,SAAS,4BAA4B;AAE7G,QAAM,iBAAiB,SAAS,MAAM,QAAQ,MAAM;AAEpD,SACC,oBAAC,OAAA,EAAI,gBAAc,QAClB,UAAA;A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AAA,IAAA;AAAA,IAEF;AAAA,MAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACD,GACD;AAEF;"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
require('./style.css');
|
|
2
|
+
"use strict";
|
|
2
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const dropdown = require("@launchpad-ui/dropdown");
|
|
6
|
+
const react = require("react");
|
|
7
|
+
const classix = require("classix");
|
|
8
|
+
const icons = require("@launchpad-ui/icons");
|
|
9
|
+
const button$1 = require("@launchpad-ui/button");
|
|
10
|
+
const menu = require("@launchpad-ui/menu");
|
|
11
|
+
const VisuallyHidden = require("react-aria/VisuallyHidden");
|
|
12
|
+
const tooltip = require("@launchpad-ui/tooltip");
|
|
12
13
|
const appliedButton = "vLReaG_appliedButton";
|
|
13
14
|
const appliedDescription = "vLReaG_appliedDescription";
|
|
14
15
|
const appliedName = "vLReaG_appliedName";
|
|
@@ -21,222 +22,274 @@ const filter = "vLReaG_filter";
|
|
|
21
22
|
const filterClearButton = "vLReaG_filterClearButton";
|
|
22
23
|
const isClearable = "vLReaG_isClearable";
|
|
23
24
|
const name = "vLReaG_name";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
const styles = {
|
|
26
|
+
appliedButton,
|
|
27
|
+
appliedDescription,
|
|
28
|
+
appliedName,
|
|
29
|
+
button,
|
|
30
|
+
buttonContainer,
|
|
31
|
+
clear,
|
|
32
|
+
clearTooltip,
|
|
33
|
+
description,
|
|
34
|
+
filter,
|
|
35
|
+
filterClearButton,
|
|
36
|
+
isClearable,
|
|
37
|
+
name
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}),
|
|
60
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_icons.Icon, {
|
|
61
|
-
name: "chevron-down",
|
|
62
|
-
size: "small",
|
|
63
|
-
"data-test-id": `${testId}-expand`
|
|
64
|
-
})
|
|
65
|
-
]
|
|
66
|
-
})
|
|
67
|
-
});
|
|
39
|
+
const AppliedFilterButton = /* @__PURE__ */ react.forwardRef((props, ref) => {
|
|
40
|
+
const { name: name2, className, children, onClickFilterButton, "data-test-id": testId = "applied-filter-button" } = props;
|
|
41
|
+
const hasDescription = react.Children.count(children) !== 0;
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-test-id": testId, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
type: "button",
|
|
46
|
+
"aria-haspopup": true,
|
|
47
|
+
className: classix.cx(styles.appliedButton, className),
|
|
48
|
+
ref,
|
|
49
|
+
onClick: onClickFilterButton,
|
|
50
|
+
children: [
|
|
51
|
+
name2 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.appliedName, "data-test-id": `${testId}-name`, children: [
|
|
52
|
+
name2,
|
|
53
|
+
hasDescription && ":"
|
|
54
|
+
] }),
|
|
55
|
+
hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.appliedDescription, "data-test-id": `${testId}-description`, children }),
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "chevron-down", size: "small", "data-test-id": `${testId}-expand` })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
) });
|
|
68
60
|
});
|
|
69
61
|
AppliedFilterButton.displayName = "AppliedFilterButton";
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
62
|
+
const FilterMenu = ({
|
|
63
|
+
options,
|
|
64
|
+
onClearFilter,
|
|
65
|
+
enableSearch,
|
|
66
|
+
searchValue,
|
|
67
|
+
searchPlaceholder,
|
|
68
|
+
searchAriaLabel,
|
|
69
|
+
searchId,
|
|
70
|
+
onSelect,
|
|
71
|
+
onSearchChange,
|
|
72
|
+
isLoading = false,
|
|
73
|
+
disabledOptionTooltip,
|
|
74
|
+
enableVirtualization,
|
|
75
|
+
size,
|
|
76
|
+
"data-test-id": testId = "filter-menu"
|
|
77
|
+
}) => {
|
|
78
|
+
const filterOptions = isLoading ? [{ name: "loading...", value: "loading...", isDisabled: true }] : options;
|
|
79
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
80
|
+
onClearFilter && /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
button$1.Button,
|
|
82
|
+
{
|
|
83
|
+
tabIndex: 0,
|
|
84
|
+
className: styles.filterClearButton,
|
|
85
|
+
onClick: onClearFilter,
|
|
86
|
+
kind: "link",
|
|
87
|
+
"data-test-id": "clear-filter-button",
|
|
88
|
+
children: "CLEAR FILTER"
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsxs(menu.Menu, { enableVirtualization, size, "data-test-id": testId, onSelect, children: [
|
|
92
|
+
enableSearch && /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
menu.MenuSearch,
|
|
94
|
+
{
|
|
95
|
+
value: searchValue,
|
|
96
|
+
id: searchId,
|
|
97
|
+
placeholder: searchPlaceholder,
|
|
98
|
+
onChange: onSearchChange,
|
|
99
|
+
ariaLabel: searchAriaLabel
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
filterOptions.map((option, index) => {
|
|
103
|
+
if (option.isDivider) {
|
|
104
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menu.MenuDivider, {}, `divider-${index}`);
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
menu.MenuItem,
|
|
108
|
+
{
|
|
109
|
+
item: option,
|
|
110
|
+
disabled: option.isDisabled,
|
|
111
|
+
icon: option.isChecked ? /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "check" }) : void 0,
|
|
112
|
+
role: "menuitemradio",
|
|
113
|
+
"aria-checked": option.isChecked ? "true" : void 0,
|
|
114
|
+
nested: option.nested,
|
|
115
|
+
groupHeader: option.groupHeader,
|
|
116
|
+
tooltip: option.isDisabled && disabledOptionTooltip ? disabledOptionTooltip : void 0,
|
|
117
|
+
tooltipPlacement: "right",
|
|
118
|
+
children: option.name
|
|
119
|
+
},
|
|
120
|
+
option.value
|
|
121
|
+
);
|
|
122
|
+
})
|
|
123
|
+
] })
|
|
124
|
+
] });
|
|
110
125
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
const SEARCH_INPUT_THRESHOLD$1 = 4;
|
|
127
|
+
const AppliedFilter = ({
|
|
128
|
+
searchValue,
|
|
129
|
+
onSearchChange,
|
|
130
|
+
searchPlaceholder,
|
|
131
|
+
name: name2,
|
|
132
|
+
description: description2,
|
|
133
|
+
options,
|
|
134
|
+
className,
|
|
135
|
+
isEmpty,
|
|
136
|
+
isLoading,
|
|
137
|
+
onClickFilterButton,
|
|
138
|
+
onClearFilter,
|
|
139
|
+
searchAriaLabel,
|
|
140
|
+
searchId,
|
|
141
|
+
"data-test-id": testId = "applied-filter",
|
|
142
|
+
...props
|
|
143
|
+
}) => {
|
|
144
|
+
const enableSearch = onSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD$1 || !isEmpty);
|
|
145
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dropdown.Dropdown, { targetClassName: className, placement: "bottom-start", enableArrow: false, ...props, children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(AppliedFilterButton, { "data-test-id": testId, name: name2, onClickFilterButton, children: description2 }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
148
|
+
FilterMenu,
|
|
149
|
+
{
|
|
150
|
+
options,
|
|
151
|
+
searchValue,
|
|
152
|
+
searchPlaceholder,
|
|
153
|
+
enableSearch,
|
|
154
|
+
searchAriaLabel,
|
|
155
|
+
searchId,
|
|
156
|
+
onSearchChange,
|
|
157
|
+
onClearFilter,
|
|
158
|
+
isLoading
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
] });
|
|
136
162
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
163
|
+
const FilterButton = /* @__PURE__ */ react.forwardRef((props, ref) => {
|
|
164
|
+
const {
|
|
165
|
+
children,
|
|
166
|
+
name: name2,
|
|
167
|
+
hideName,
|
|
168
|
+
isClearable: isClearable2,
|
|
169
|
+
clearTooltip: clearTooltip2 = "Clear filter",
|
|
170
|
+
onClear,
|
|
171
|
+
disabled,
|
|
172
|
+
isSelected,
|
|
173
|
+
onClickFilterButton,
|
|
174
|
+
className,
|
|
175
|
+
"data-test-id": testId = "filter-button",
|
|
176
|
+
ariaLabel = "Clear filter",
|
|
177
|
+
...rest
|
|
178
|
+
} = props;
|
|
179
|
+
const nameId = react.useId();
|
|
180
|
+
const descriptionId = react.useId();
|
|
181
|
+
const hasDescription = react.Children.count(children) !== 0;
|
|
182
|
+
const nameElement = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles.name, children: [
|
|
183
|
+
name2,
|
|
184
|
+
hasDescription && ":"
|
|
185
|
+
] });
|
|
186
|
+
const isDisabled = disabled;
|
|
187
|
+
const handleClick = (event) => {
|
|
188
|
+
if (isDisabled) {
|
|
189
|
+
return event.preventDefault();
|
|
190
|
+
}
|
|
191
|
+
onClickFilterButton?.();
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.buttonContainer, "data-test-id": testId, children: [
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
195
|
+
"button",
|
|
196
|
+
{
|
|
197
|
+
...rest,
|
|
198
|
+
type: "button",
|
|
199
|
+
"aria-labelledby": `${nameId} ${hasDescription ? descriptionId : ""}`,
|
|
200
|
+
"aria-haspopup": true,
|
|
201
|
+
disabled: isDisabled,
|
|
202
|
+
"aria-disabled": isDisabled,
|
|
203
|
+
className: classix.cx(styles.button, className, (isClearable2 || isSelected) && styles.isClearable),
|
|
204
|
+
ref,
|
|
205
|
+
onClick: handleClick,
|
|
206
|
+
children: [
|
|
207
|
+
hideName ? /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { id: nameId, children: nameElement }) : /* @__PURE__ */ jsxRuntime.jsx("span", { id: nameId, children: nameElement }),
|
|
208
|
+
hasDescription && /* @__PURE__ */ jsxRuntime.jsx("span", { id: descriptionId, className: styles.description, children }),
|
|
209
|
+
!isClearable2 && /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "chevron-down", size: "small" })
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
isClearable2 && /* @__PURE__ */ jsxRuntime.jsx(tooltip.Tooltip, { targetClassName: styles.clearTooltip, content: clearTooltip2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
214
|
+
button$1.IconButton,
|
|
215
|
+
{
|
|
216
|
+
"aria-label": ariaLabel,
|
|
217
|
+
className: styles.clear,
|
|
218
|
+
"data-test-id": "clear-filter-button",
|
|
219
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "cancel", size: "small" }),
|
|
220
|
+
size: "small",
|
|
221
|
+
onClick: onClear
|
|
222
|
+
}
|
|
223
|
+
) })
|
|
224
|
+
] });
|
|
198
225
|
});
|
|
199
226
|
FilterButton.displayName = "FilterButton";
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
227
|
+
const SEARCH_INPUT_THRESHOLD = 4;
|
|
228
|
+
const Filter = ({
|
|
229
|
+
searchValue,
|
|
230
|
+
onSearchChange,
|
|
231
|
+
searchPlaceholder,
|
|
232
|
+
searchAriaLabel,
|
|
233
|
+
name: name2,
|
|
234
|
+
hideName,
|
|
235
|
+
description: description2,
|
|
236
|
+
options,
|
|
237
|
+
isClearable: isClearable2,
|
|
238
|
+
onClear,
|
|
239
|
+
isSelected,
|
|
240
|
+
className,
|
|
241
|
+
isEmpty,
|
|
242
|
+
searchId,
|
|
243
|
+
isLoading,
|
|
244
|
+
onClickFilterButton,
|
|
245
|
+
disabledOptionTooltip,
|
|
246
|
+
"data-test-id": testId = "filter",
|
|
247
|
+
size,
|
|
248
|
+
disabled,
|
|
249
|
+
enableVirtualization,
|
|
250
|
+
clearAriaLabel,
|
|
251
|
+
...props
|
|
252
|
+
}) => {
|
|
253
|
+
const enableSearch = onSearchChange && (!!searchValue || options.length > SEARCH_INPUT_THRESHOLD || !isEmpty);
|
|
254
|
+
const dropdownClasses = classix.cx(styles.filter, className);
|
|
255
|
+
const handleClear = (event) => {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
onClear?.();
|
|
258
|
+
};
|
|
259
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dropdown.Dropdown, { targetTestId: testId, disabled, targetClassName: dropdownClasses, ...props, children: [
|
|
260
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
261
|
+
FilterButton,
|
|
262
|
+
{
|
|
263
|
+
isClearable: isClearable2,
|
|
264
|
+
onClear: handleClear,
|
|
265
|
+
name: name2,
|
|
266
|
+
hideName,
|
|
267
|
+
disabled,
|
|
268
|
+
isSelected,
|
|
269
|
+
onClickFilterButton,
|
|
270
|
+
ariaLabel: clearAriaLabel,
|
|
271
|
+
children: description2
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
FilterMenu,
|
|
276
|
+
{
|
|
277
|
+
options,
|
|
278
|
+
searchId,
|
|
279
|
+
searchValue,
|
|
280
|
+
searchPlaceholder,
|
|
281
|
+
searchAriaLabel,
|
|
282
|
+
enableSearch,
|
|
283
|
+
onSearchChange,
|
|
284
|
+
isLoading,
|
|
285
|
+
disabledOptionTooltip,
|
|
286
|
+
size,
|
|
287
|
+
enableVirtualization
|
|
288
|
+
}
|
|
289
|
+
)
|
|
290
|
+
] });
|
|
237
291
|
};
|
|
238
292
|
exports.AppliedFilter = AppliedFilter;
|
|
239
293
|
exports.Filter = Filter;
|
|
240
294
|
exports.FilterButton = FilterButton;
|
|
241
|
-
|
|
242
|
-
//# sourceMappingURL=index.js.map
|
|
295
|
+
//# sourceMappingURL=index.js.map
|