@wallarm-org/design-system 4.16.1-rc-fix-escape-outside-layer-stack.1 → 4.16.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "4.16.0",
3
- "generatedAt": "2026-11-13T06:55:12.603Z",
3
+ "generatedAt": "2026-11-13T08:25:03.533Z",
4
4
  "components": [
5
5
  {
6
6
  "name": "Accordion",
@@ -11988,6 +11988,41 @@
11988
11988
  "name": "asChild",
11989
11989
  "type": "boolean | undefined",
11990
11990
  "required": false
11991
+ },
11992
+ {
11993
+ "name": "title",
11994
+ "type": "string | undefined",
11995
+ "required": false
11996
+ },
11997
+ {
11998
+ "name": "defaultChecked",
11999
+ "type": "boolean | undefined",
12000
+ "required": false
12001
+ },
12002
+ {
12003
+ "name": "defaultValue",
12004
+ "type": "string | number | readonly string[] | undefined",
12005
+ "required": false
12006
+ },
12007
+ {
12008
+ "name": "autoFocus",
12009
+ "type": "boolean | undefined",
12010
+ "required": false
12011
+ },
12012
+ {
12013
+ "name": "tabIndex",
12014
+ "type": "number | undefined",
12015
+ "required": false
12016
+ },
12017
+ {
12018
+ "name": "rel",
12019
+ "type": "string | undefined",
12020
+ "required": false
12021
+ },
12022
+ {
12023
+ "name": "onChange",
12024
+ "type": "ChangeEventHandler<T, Element> | undefined",
12025
+ "required": false
11991
12026
  }
11992
12027
  ]
11993
12028
  },
@@ -12406,6 +12441,41 @@
12406
12441
  "name": "asChild",
12407
12442
  "type": "boolean | undefined",
12408
12443
  "required": false
12444
+ },
12445
+ {
12446
+ "name": "title",
12447
+ "type": "string | undefined",
12448
+ "required": false
12449
+ },
12450
+ {
12451
+ "name": "defaultChecked",
12452
+ "type": "boolean | undefined",
12453
+ "required": false
12454
+ },
12455
+ {
12456
+ "name": "defaultValue",
12457
+ "type": "string | number | readonly string[] | undefined",
12458
+ "required": false
12459
+ },
12460
+ {
12461
+ "name": "autoFocus",
12462
+ "type": "boolean | undefined",
12463
+ "required": false
12464
+ },
12465
+ {
12466
+ "name": "tabIndex",
12467
+ "type": "number | undefined",
12468
+ "required": false
12469
+ },
12470
+ {
12471
+ "name": "rel",
12472
+ "type": "string | undefined",
12473
+ "required": false
12474
+ },
12475
+ {
12476
+ "name": "onChange",
12477
+ "type": "ChangeEventHandler<T, Element> | undefined",
12478
+ "required": false
12409
12479
  }
12410
12480
  ]
12411
12481
  },
@@ -21581,8 +21651,7 @@
21581
21651
  {
21582
21652
  "name": "disabled",
21583
21653
  "type": "boolean | undefined",
21584
- "required": false,
21585
- "defaultValue": "false"
21654
+ "required": false
21586
21655
  },
21587
21656
  {
21588
21657
  "name": "name",
@@ -21683,8 +21752,7 @@
21683
21752
  {
21684
21753
  "name": "error",
21685
21754
  "type": "{ true: string; false: string; }",
21686
- "required": false,
21687
- "defaultValue": "false"
21755
+ "required": false
21688
21756
  },
21689
21757
  {
21690
21758
  "name": "data-testid",
@@ -25167,8 +25235,7 @@
25167
25235
  {
25168
25236
  "name": "error",
25169
25237
  "type": "boolean | undefined",
25170
- "required": false,
25171
- "defaultValue": "false"
25238
+ "required": false
25172
25239
  },
25173
25240
  {
25174
25241
  "name": "data-testid",
@@ -27346,8 +27413,7 @@
27346
27413
  {
27347
27414
  "name": "disabled",
27348
27415
  "type": "boolean | undefined",
27349
- "required": false,
27350
- "defaultValue": "false"
27416
+ "required": false
27351
27417
  },
27352
27418
  {
27353
27419
  "name": "name",
@@ -27403,8 +27469,7 @@
27403
27469
  {
27404
27470
  "name": "error",
27405
27471
  "type": "{ true: string; false: string; }",
27406
- "required": false,
27407
- "defaultValue": "false"
27472
+ "required": false
27408
27473
  },
27409
27474
  {
27410
27475
  "name": "autoComplete",
@@ -32402,7 +32467,7 @@
32402
32467
  },
32403
32468
  {
32404
32469
  "name": "WithSearch",
32405
- "code": "import { createListCollection } from '@ark-ui/react/collection';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { SquareArrowOutUpRight } from '@wallarm-org/design-system/icons';\nimport { Select, SelectButton, SelectClearTrigger, SelectContent, SelectEmptyState, SelectFooter, SelectGroup, SelectGroupLabel, SelectHeader, SelectOption, SelectOptionDescription, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\nimport { HStack } from '@wallarm-org/design-system/Stack';\n\nexport const WithSearch = () => {\n const collection = createListCollection({\n items: skillsWithoutIcons,\n groupBy: item => item.category ?? '',\n itemToString: item => item.label,\n });\n\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(collection);\n\n return (\n <div className='w-300'>\n <Select collection={collection}>\n <SelectButton />\n\n <SelectPositioner>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.group().map(([category, group], index) => (\n <SelectGroup key={category}>\n <SelectGroupLabel>\n {category}\n {index === 0 && <SelectClearTrigger>Clear all</SelectClearTrigger>}\n </SelectGroupLabel>\n {group.map(skill => (\n <SelectOption key={skill.value} item={skill}>\n <SelectOptionText>{skill.label}</SelectOptionText>\n {skill.description && (\n <SelectOptionDescription>{skill.description}</SelectOptionDescription>\n )}\n <SelectOptionIndicator />\n </SelectOption>\n ))}\n </SelectGroup>\n ))\n )}\n </SelectContent>\n\n <SelectFooter>\n <HStack justify='between'>\n <Button variant='ghost' color='neutral' size='small'>\n <SquareArrowOutUpRight />\n See all\n </Button>\n\n <HStack justify='end'>\n <Button variant='ghost' color='neutral' size='small'>\n Cancel\n </Button>\n\n <Button variant='primary' color='brand' size='small'>\n Apply\n </Button>\n </HStack>\n </HStack>\n </SelectFooter>\n </SelectPositioner>\n </Select>\n </div>\n );\n};",
32470
+ "code": "import { createListCollection } from '@ark-ui/react/collection';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { SquareArrowOutUpRight } from '@wallarm-org/design-system/icons';\nimport { Select, SelectButton, SelectClearTrigger, SelectContent, SelectEmptyState, SelectFooter, SelectGroup, SelectGroupLabel, SelectHeader, SelectOption, SelectOptionDescription, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\nimport { HStack } from '@wallarm-org/design-system/Stack';\n\nexport const WithSearch = () => {\n const collection = createListCollection({\n items: skillsWithoutIcons,\n groupBy: item => item.category ?? '',\n itemToString: item => item.label,\n });\n\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(collection);\n\n return (\n <div className='w-300'>\n <Select collection={filteredCollection} data-testid='select-with-search'>\n <SelectButton />\n\n <SelectPositioner>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.group().map(([category, group], index) => (\n <SelectGroup key={category}>\n <SelectGroupLabel>\n {category}\n {index === 0 && <SelectClearTrigger>Clear all</SelectClearTrigger>}\n </SelectGroupLabel>\n {group.map(skill => (\n <SelectOption key={skill.value} item={skill}>\n <SelectOptionText>{skill.label}</SelectOptionText>\n {skill.description && (\n <SelectOptionDescription>{skill.description}</SelectOptionDescription>\n )}\n <SelectOptionIndicator />\n </SelectOption>\n ))}\n </SelectGroup>\n ))\n )}\n </SelectContent>\n\n <SelectFooter>\n <HStack justify='between'>\n <Button variant='ghost' color='neutral' size='small'>\n <SquareArrowOutUpRight />\n See all\n </Button>\n\n <HStack justify='end'>\n <Button variant='ghost' color='neutral' size='small'>\n Cancel\n </Button>\n\n <Button variant='primary' color='brand' size='small'>\n Apply\n </Button>\n </HStack>\n </HStack>\n </SelectFooter>\n </SelectPositioner>\n </Select>\n </div>\n );\n};",
32406
32471
  "storyFile": "Select/Select.stories.tsx",
32407
32472
  "storyTitle": "Inputs/Select",
32408
32473
  "description": "`SelectSearchInput` with the `useSelectSearch` hook, plus `SelectEmptyState` for when\nnothing matches. Add search once the list outgrows a glance — roughly ten options."
@@ -41790,8 +41855,7 @@
41790
41855
  {
41791
41856
  "name": "disabled",
41792
41857
  "type": "boolean | undefined",
41793
- "required": false,
41794
- "defaultValue": "false"
41858
+ "required": false
41795
41859
  },
41796
41860
  {
41797
41861
  "name": "name",
@@ -41842,8 +41906,7 @@
41842
41906
  {
41843
41907
  "name": "error",
41844
41908
  "type": "{ true: string; false: string; }",
41845
- "required": false,
41846
- "defaultValue": "false"
41909
+ "required": false
41847
41910
  },
41848
41911
  {
41849
41912
  "name": "data-testid",
@@ -1686,7 +1686,7 @@
1686
1686
  "view toggle"
1687
1687
  ],
1688
1688
  "order": 90,
1689
- "markdown": "# Filtering\n\nPick the control by the shape of the values; every filter applies on pick.\n\n## When to use\n\n| Need | Use | Not |\n| --- | --- | --- |\n| Text match on name or ID | `SearchInput` in `PageToolbar` | `Input` with a search icon |\n| One status with counts | `SegmentedTabs` + `NumericBadge` | `FilterDropdown` |\n| One flat attribute, one value | `FilterDropdown` with `allLabel` | `Select` in a toolbar |\n| One flat attribute, several values | `FilterDropdown multiple` | `Checkbox` rows |\n| A hierarchy (organization › deployment › application) | `FilterCascade` | Nested `DropdownMenu`s |\n| Over four attributes, operators, AND/OR | `FilterInput` | Five `FilterDropdown`s |\n| A value in a form | `Select` + `SelectInput` in `Field` | `FilterDropdown` |\n| Pick rows from a large set | `Dialog width={960}` + selectable `Table` | A huge multi `Select` |\n| Table or schema view | `SegmentedControl` with icons | `Tabs` |\n\nThere is no `FilterBar`, `PageFilters` or `Combobox` (use `Select` + `useSelectSearch`), and no `onApply` prop.\n\n## Rules\n\n**Filter bar layout**\n\n- `PageToolbar` owns the 24px gutter and 12px gap. **Never** add `gap-*`, `px-*` or `py-*` to it.\n- Wrap `SearchInput` and the filters in one `<div className='flex items-center gap-8'>`.\n- `SearchInput` is `w-[320px]` in a toolbar, `flex-1` in a dialog.\n- A view toggle goes last with `className='ml-auto'`.\n- **Never** set a width on filter triggers; they hug their text up to 180px.\n- **Never** stack two `SegmentedTabs` in one toolbar.\n\n**FilterDropdown**\n\n- Always give it a `label`; it names the trigger and aria-label.\n- If the attribute is exclusive, use `allLabel` («All …» resets). If values combine, use `multiple` (OR-ed).\n- Build `collection` with `createListCollection({ items, groupBy })`.\n- Render options from `useFilterDropdown().groups` in a child component so they follow the search.\n- `details.value` of `[]` means unset. Pass counts as `hint`.\n- **Never** put `FilterDropdown` in a form or add an Apply button to a filter menu.\n\n**FilterCascade**\n\n- Import all cascade parts from `@wallarm-org/design-system/FilterCascade`, never the root.\n- Build `collection` with `createFilterCascadeCollection(items, accessors)`; plain `{ value, label, children }` items need no accessors.\n- If a level loads on demand, pass `loadChildren` and mark parents `hasChildren`. If a parent is pickable, pass `parentLabel`.\n- If the menu needs a toggle (\"Own only\"), use `FilterCascadeCheckboxItem` in `FilterCascadeSection`; you keep its state.\n- **Never** leave a description empty; show \"No policies\" for zero.\n\n**FilterInput**\n\n- Pass `fields` (`name`, `label`, `type`, `values`) and `value` / `onChange(ExprNode | null)`. Its menus and chips are built in.\n\n**Searchable select**\n\n- Put `SelectSearchInput` in `SelectHeader`, wired to `useSelectSearch`. Pass the original collection to `Select`; render `filteredCollection`.\n- If the menu must match the trigger, pass `positioning={{ sameWidth: true }}` and `SelectPositioner className='min-w-full max-w-full'`; otherwise it is 240–320px.\n- Option icons: set `icon` on each item.\n- For several values use `SelectInput multiple`. `SelectButtonTag` is a trigger, not a chip list.\n\n**Picker dialog**\n\n- Use `Dialog width={960}`; there is no `DIALOG_SIZES`.\n- Dialog parts own the 24px gutter. **Never** pad them. `DialogBody` has no `className`: put `flex flex-col gap-8` on a child div, search and tabs in `flex items-center gap-12`.\n- Pass `getRowId` so selection survives search and paging.\n- Primary is `disabled` \"Add users\" until rows are picked, then \"Add 1 user\", \"Add 3 users\".\n\n## Examples\n\nA filter bar over a table: search, a multiple and a single filter, a scope chip, and the view toggle last.\n\nEvery pick applies at once. When the filters match nothing, the table offers \"Reset filters\",\nwhich clears the search and every filter.\n\n```tsx story=Default\nimport { useState } from 'react';\nimport { Badge } from '@wallarm-org/design-system/Badge';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\nimport { FilterDropdown, FilterDropdownAllOption, FilterDropdownContent, FilterDropdownFooter, FilterDropdownOption, FilterDropdownTrigger, type FilterDropdownValueChangeDetails, useFilterDropdown } from '@wallarm-org/design-system/FilterDropdown';\nimport { FilterX, List, SearchX, Workflow } from '@wallarm-org/design-system/icons';\nimport { Page, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\nimport { type TableCellContext, type TableColumnDef, Table, TableEmptyState } from '@wallarm-org/design-system/Table';\n\nexport const Default = () => {\n const [query, setQuery] = useState('');\n const [types, setTypes] = useState<string[]>([]);\n const [status, setStatus] = useState<string[]>([]);\n const [scope, setScope] = useState<string[]>([]);\n const [view, setView] = useState('table');\n\n const TYPE_LABELS: Record<AttackType, string> = {\n sqli: 'SQL injection',\n xss: 'XSS',\n rce: 'RCE',\n ptrav: 'Path traversal',\n ssrf: 'SSRF',\n };\n const typeItems = Object.entries(TYPE_LABELS).map(([value, label]) => ({\n value,\n label,\n count: ATTACKS.filter(attack => attack.type === value).length,\n }));\n const typeOptions = createListCollection({ items: typeItems });\n const statusOptions = createListCollection({\n items: [\n { value: 'blocked', label: 'Blocked' },\n { value: 'monitored', label: 'Monitored' },\n ],\n });\n const scopeOptions = createFilterCascadeCollection(SCOPES);\n\n const renderType = ({ row }: TableCellContext<Attack, unknown>) => TYPE_LABELS[row.original.type];\n\n const renderStatus = ({ row }: TableCellContext<Attack, unknown>) =>\n row.original.status === 'blocked' ? (\n <Badge variant='dotted' type='secondary' color='red'>\n Blocked\n </Badge>\n ) : (\n <Badge variant='dotted' type='secondary' color='yellow'>\n Monitored\n </Badge>\n );\n\n const columns: TableColumnDef<Attack>[] = [\n { accessorKey: 'type', header: 'Type', size: 160, cell: renderType },\n { accessorKey: 'path', header: 'Request', size: 280 },\n { accessorKey: 'source', header: 'Source IP', size: 160 },\n { accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },\n { accessorKey: 'hits', header: 'Hits', size: 100 },\n ];\n\n const search = query.trim().toLowerCase();\n const rows = ATTACKS.filter(\n attack =>\n (attack.path.toLowerCase().includes(search) || attack.source.includes(search)) &&\n (types.length === 0 || types.includes(attack.type)) &&\n (status.length === 0 || status.includes(attack.status)) &&\n (scope.length === 0 || attack.deployment === scope[0]) &&\n (scope.length < 2 || attack.application === scope[1]),\n );\n\n const handleTypesChange = (details: FilterDropdownValueChangeDetails) => setTypes(details.value);\n const handleStatusChange = (details: FilterDropdownValueChangeDetails) =>\n setStatus(details.value);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n\n const handleReset = () => {\n setQuery('');\n setTypes([]);\n setStatus([]);\n setScope([]);\n };\n\n return (\n <Page name='attacks' fullSize fixedHeight data-testid='attacks-page'>\n <PageHeader>\n <PageHeaderGroup className='flex-1'>\n <PageTitle>Attacks</PageTitle>\n <PageDescription>\n Malicious requests the filtering nodes detected in the last 7 days.\n </PageDescription>\n </PageHeaderGroup>\n </PageHeader>\n\n <PageToolbar>\n <div className='flex items-center gap-8'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search request or IP'\n className='w-[320px]'\n data-testid='attacks-search'\n />\n <FilterDropdown\n label='Type'\n multiple\n collection={typeOptions}\n value={types}\n onValueChange={handleTypesChange}\n data-testid='attacks-type-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n {/* Under 8 options the menu has no search, so the options are listed directly.\n From 8, render them from `useFilterDropdown().groups` in a child component. */}\n {typeItems.map(item => (\n <FilterDropdownOption key={item.value} item={item} hint={item.count} />\n ))}\n <FilterDropdownFooter />\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterDropdown\n label='Status'\n allLabel='All statuses'\n collection={statusOptions}\n value={status}\n onValueChange={handleStatusChange}\n data-testid='attacks-status-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n <FilterDropdownAllOption />\n {statusOptions.items.map(item => (\n <FilterDropdownOption key={item.value} item={item} />\n ))}\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterCascade\n label='Scope'\n collection={scopeOptions}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='attacks-scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent />\n </FilterCascade>\n </div>\n <SegmentedControl\n value={view}\n onChange={setView}\n className='ml-auto'\n data-testid='attacks-view-toggle'\n >\n <SegmentedControlItem value='table'>\n <List />\n <span className='sr-only'>Table view</span>\n </SegmentedControlItem>\n <SegmentedControlItem value='schema'>\n <Workflow />\n <span className='sr-only'>Schema view</span>\n </SegmentedControlItem>\n </SegmentedControl>\n </PageToolbar>\n\n <PageContent>\n <Table\n aria-label='Attacks'\n data={rows}\n columns={columns}\n getRowId={getAttackId}\n data-testid='attacks-table'\n >\n <TableEmptyState>\n <EmptyState type='collection-empty' data-testid='attacks-no-results'>\n <EmptyStateIllustration>\n <SearchX />\n </EmptyStateIllustration>\n <EmptyStateMessage>\n <EmptyStateTitle>No results found</EmptyStateTitle>\n <EmptyStateDescription>\n No attacks match your search or filters.\n </EmptyStateDescription>\n </EmptyStateMessage>\n <EmptyStateActions>\n <Button size='medium' variant='outline' color='neutral' onClick={handleReset}>\n <FilterX />\n Reset filters\n </Button>\n </EmptyStateActions>\n </EmptyState>\n </TableEmptyState>\n </Table>\n </PageContent>\n </Page>\n );\n};\n```\n\nFrom eight options a filter menu gets a search, and its options follow the query.\n\nOptions are grouped by deployment and carry attack counts. On reopen, picked options are\npinned under «Selected»; a query with no match shows an empty message and keeps the menu open.\n\n```tsx story=SearchableFilter\nimport { useState } from 'react';\nimport { FilterDropdown, FilterDropdownTrigger, type FilterDropdownValueChangeDetails } from '@wallarm-org/design-system/FilterDropdown';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\n\nexport const SearchableFilter = () => {\n const [applications, setApplications] = useState<string[]>([]);\n const applicationOptions = createListCollection({\n items: APPLICATIONS,\n groupBy: item => item.deployment,\n });\n\n const handleApplicationsChange = (details: FilterDropdownValueChangeDetails) =>\n setApplications(details.value);\n\n return (\n <div className='p-24'>\n <FilterDropdown\n label='Application'\n multiple\n collection={applicationOptions}\n value={applications}\n onValueChange={handleApplicationsChange}\n data-testid='applications-filter'\n >\n <FilterDropdownTrigger />\n <ApplicationMenu />\n </FilterDropdown>\n </div>\n );\n};\n```\n\nA scope chip whose applications load on demand and whose deployments can be picked.\n\nEach option shows its policy count, \"No policies\" for zero. ✕ on the trigger returns to every\nscope, not one level up.\n\n```tsx story=ScopeFilter\nimport { useState } from 'react';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeItems, type FilterCascadeLevelData, FilterCascadeLevels, FilterCascadeParentItem, FilterCascadeSearch, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\n\nexport const ScopeFilter = () => {\n const [scope, setScope] = useState<string[]>([]);\n const scopes = createFilterCascadeCollection(DEPLOYMENTS, {\n getValue: node => node.id,\n getLabel: node => node.name,\n hasChildren: node => node.kind === 'deployment',\n getIcon: node => (\n <span\n aria-hidden\n className={\n node.kind === 'deployment'\n ? 'size-6 rounded-full bg-badge-sky-strong'\n : 'size-6 rounded-full bg-badge-teal-strong'\n }\n />\n ),\n getDescription: node =>\n node.policies === 0\n ? 'No policies'\n : `${node.policies} ${node.policies === 1 ? 'policy' : 'policies'}`,\n });\n\n const loadApplications = (deployment: ScopeNode) => fetchApplications(deployment.id);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n const renderLevel = (level: FilterCascadeLevelData) =>\n level.depth === 0 ? (\n <FilterCascadeItems />\n ) : (\n <>\n <FilterCascadeParentItem />\n <FilterCascadeItems />\n </>\n );\n\n return (\n <div className='p-24'>\n <FilterCascade\n label='Scope'\n collection={scopes}\n loadChildren={loadApplications}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent>\n <FilterCascadeSearch placeholder='Search' />\n <FilterCascadeLevels>{renderLevel}</FilterCascadeLevels>\n </FilterCascadeContent>\n </FilterCascade>\n </div>\n );\n};\n```\n\nA searchable select in a form, with the menu matching the trigger.\n\nA settings field saves on pick, with no Save button. A query with no match shows\n`SelectEmptyState` and keeps the menu open.\n\n```tsx story=SearchableSelect\nimport { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={timeZones}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};\n```\n\nA picker dialog whose primary counts the selection: disabled \"Add users\", then \"Add 2 users\".\n\nSearch and status tabs sit over a selectable `Table`. Picked rows stay picked while the search\nchanges, because rows are keyed by `getRowId`.\n\n```tsx story=PickerDialog\nimport { useState } from 'react';\nimport { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogFooterControls, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';\nimport { EmptyState, EmptyStateDescription, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { UserPlus } from '@wallarm-org/design-system/icons';\nimport { NumericBadge } from '@wallarm-org/design-system/NumericBadge';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';\nimport { type TableCellContext, type TableColumnDef, type TableRowSelectionState, Table } from '@wallarm-org/design-system/Table';\n\nexport const PickerDialog = () => {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [status, setStatus] = useState('all');\n const [selection, setSelection] = useState<TableRowSelectionState>({});\n\n const renderMember = ({ row }: TableCellContext<Member, unknown>) => (\n <Avatar size='md'>\n <AvatarFallback name={row.original.name} />\n <AvatarContent>\n <AvatarName>{row.original.name}</AvatarName>\n <AvatarDescription>{row.original.email}</AvatarDescription>\n </AvatarContent>\n </Avatar>\n );\n\n const renderStatus = ({ row }: TableCellContext<Member, unknown>) =>\n row.original.status === 'active' ? 'Active' : 'Invited';\n\n const columns: TableColumnDef<Member>[] = [\n { accessorKey: 'name', header: 'User', size: 520, cell: renderMember },\n { accessorKey: 'status', header: 'Status', size: 200, cell: renderStatus },\n ];\n\n const search = query.trim().toLowerCase();\n const matching = MEMBERS.filter(\n member =>\n member.name.toLowerCase().includes(search) || member.email.toLowerCase().includes(search),\n );\n const activeCount = matching.filter(member => member.status === 'active').length;\n const invitedCount = matching.length - activeCount;\n const rows = status === 'all' ? matching : matching.filter(member => member.status === status);\n const count = Object.keys(selection).length;\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setQuery('');\n setStatus('all');\n setSelection({});\n }\n };\n const handleOpen = () => setOpen(true);\n const handleAdd = () => {\n onAddUsers(Object.keys(selection));\n handleOpenChange(false);\n };\n\n return (\n <div className='p-24'>\n <Button size='medium' onClick={handleOpen} data-testid='members-add'>\n <UserPlus />\n Add users\n </Button>\n <Dialog open={open} onOpenChange={handleOpenChange} width={960} data-testid='members-picker'>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add users to Security team</DialogTitle>\n </DialogHeader>\n <DialogBody>\n <div className='flex flex-col gap-8'>\n <div className='flex items-center gap-12'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search name or email'\n className='flex-1'\n data-testid='members-search'\n />\n <SegmentedTabs\n value={status}\n onChange={setStatus}\n data-testid='members-status-tabs'\n >\n <SegmentedTabsList>\n <SegmentedTabsTrigger value='all'>\n All <NumericBadge>{matching.length}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='active'>\n Active <NumericBadge>{activeCount}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='invited'>\n Invited <NumericBadge>{invitedCount}</NumericBadge>\n </SegmentedTabsTrigger>\n </SegmentedTabsList>\n </SegmentedTabs>\n </div>\n <Table\n aria-label='Users to add'\n data={rows}\n columns={columns}\n getRowId={getMemberId}\n rowSelection={selection}\n onRowSelectionChange={setSelection}\n data-testid='members-table'\n >\n {rows.length === 0 && (\n <EmptyState type='collection-empty' data-testid='members-no-results'>\n <EmptyStateMessage>\n <EmptyStateTitle>No users found</EmptyStateTitle>\n <EmptyStateDescription>No users match your search.</EmptyStateDescription>\n </EmptyStateMessage>\n </EmptyState>\n )}\n </Table>\n </div>\n </DialogBody>\n <DialogFooter>\n <DialogFooterControls>\n <DialogClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Cancel\n </Button>\n </DialogClose>\n <Button\n size='large'\n disabled={count === 0}\n onClick={handleAdd}\n data-testid='members-confirm'\n >\n {count === 0 ? 'Add users' : `Add ${count} ${count === 1 ? 'user' : 'users'}`}\n </Button>\n </DialogFooterControls>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n```\n\n## States\n\n| State | Show | Example component |\n| --- | --- | --- |\n| Unset | Single: `allLabel`; multi: `label` | `FilterDropdownTrigger` |\n| One value / several | \"Type • Lua\" / \"Type • 2\", built in; never custom text or a tag per value | `FilterDropdownTrigger` |\n| Reset one filter | Multi: ✕ or Backspace; single: «All». No per-filter Reset button | `FilterDropdown` |\n| Reset scope | ✕ returns to the page default, not one level up | `FilterCascadeTrigger` |\n| 8+ options | Search appears (`searchThreshold`) | `FilterDropdownSearch`, `SelectSearchInput` |\n| Menu search, no match | Empty message; menu stays open | `FilterDropdownEmpty`, `SelectEmptyState` |\n| Cascade level loading or failed | Built-in loading rows, then Retry | `FilterCascade` |\n| Filters match no rows | `type='collection-empty'` + outline neutral \"Reset filters\"; never a create CTA | `TableEmptyState` |\n| Default value | Pinned first in a \"Suggested\" group | `SelectGroup` |\n| Select on settings page | Saves on pick, toast; no Save button | `Select`, `Toast` |\n| Picker running | Primary `loading`, dialog open; on success close and toast \"3 users added\" | `Button`, `Dialog` |\n| Picker, no match | `EmptyState type='collection-empty'` as a direct `Table` child; `TableEmptyState` is too tall | `EmptyState` |\n| Picker, already a member | Leave the row out of `data` | `Table` |\n\n## What your app owns\n\n| You own | The DS owns |\n| --- | --- |\n| Applying `details.value` to your data | Filter values and trigger text |\n| URL sync (no router integration) | Nothing |\n| \"Reset all\": every filter `[]`, search `''` | Per-filter clear |\n| Option counts (`hint`, `getDescription`); a pinned option goes first in its own `category` | Rendering them |\n| Scope dots: `size-6 rounded-full` span, `bg-badge-violet-strong` / `-sky-strong` / `-teal-strong`, via `getIcon` | The icon slot |\n| Server search: debounce `query`, refetch `data` | Client filtering only |\n| Picker selection across pages: keep `rowSelection` keys (row ids) when `data` changes | Checkbox column |\n| Picker user cell (name, muted email): see [Entity table](./entity-table.md) | Nothing |\n\n## Related\n\n- [Resource list page](./resource-list-page.md), [Entity table](./entity-table.md), [Empty states](./empty-states.md)\n- [Feedback toasts](./feedback-toasts.md), [Settings page](./settings-page.md), [Create and edit forms](./create-edit-forms.md)\n- [Spacing](../foundations/spacing.md)",
1689
+ "markdown": "# Filtering\n\nPick the control by the shape of the values; every filter applies on pick.\n\n## When to use\n\n| Need | Use | Not |\n| --- | --- | --- |\n| Text match on name or ID | `SearchInput` in `PageToolbar` | `Input` with a search icon |\n| One status with counts | `SegmentedTabs` + `NumericBadge` | `FilterDropdown` |\n| One flat attribute, one value | `FilterDropdown` with `allLabel` | `Select` in a toolbar |\n| One flat attribute, several values | `FilterDropdown multiple` | `Checkbox` rows |\n| A hierarchy (organization › deployment › application) | `FilterCascade` | Nested `DropdownMenu`s |\n| Over four attributes, operators, AND/OR | `FilterInput` | Five `FilterDropdown`s |\n| A value in a form | `Select` + `SelectInput` in `Field` | `FilterDropdown` |\n| Pick rows from a large set | `Dialog width={960}` + selectable `Table` | A huge multi `Select` |\n| Table or schema view | `SegmentedControl` with icons | `Tabs` |\n\nThere is no `FilterBar`, `PageFilters` or `Combobox` (use `Select` + `useSelectSearch`), and no `onApply` prop.\n\n## Rules\n\n**Filter bar layout**\n\n- `PageToolbar` owns the 24px gutter and 12px gap. **Never** add `gap-*`, `px-*` or `py-*` to it.\n- Wrap `SearchInput` and the filters in one `<div className='flex items-center gap-8'>`.\n- `SearchInput` is `w-[320px]` in a toolbar, `flex-1` in a dialog.\n- A view toggle goes last with `className='ml-auto'`.\n- **Never** set a width on filter triggers; they hug their text up to 180px.\n- **Never** stack two `SegmentedTabs` in one toolbar.\n\n**FilterDropdown**\n\n- Always give it a `label`; it names the trigger and aria-label.\n- If the attribute is exclusive, use `allLabel` («All …» resets). If values combine, use `multiple` (OR-ed).\n- Build `collection` with `createListCollection({ items, groupBy })`.\n- Render options from `useFilterDropdown().groups` in a child component so they follow the search.\n- `details.value` of `[]` means unset. Pass counts as `hint`.\n- **Never** put `FilterDropdown` in a form or add an Apply button to a filter menu.\n\n**FilterCascade**\n\n- Import all cascade parts from `@wallarm-org/design-system/FilterCascade`, never the root.\n- Build `collection` with `createFilterCascadeCollection(items, accessors)`; plain `{ value, label, children }` items need no accessors.\n- If a level loads on demand, pass `loadChildren` and mark parents `hasChildren`. If a parent is pickable, pass `parentLabel`.\n- If the menu needs a toggle (\"Own only\"), use `FilterCascadeCheckboxItem` in `FilterCascadeSection`; you keep its state.\n- **Never** leave a description empty; show \"No policies\" for zero.\n\n**FilterInput**\n\n- Pass `fields` (`name`, `label`, `type`, `values`) and `value` / `onChange(ExprNode | null)`. Its menus and chips are built in.\n\n**Searchable select**\n\n- Put `SelectSearchInput` in `SelectHeader`, wired to `useSelectSearch`. Pass `filteredCollection` to `Select` and render it, so arrow keys skip hidden options.\n- If the menu must match the trigger, pass `positioning={{ sameWidth: true }}` and `SelectPositioner className='min-w-full max-w-full'`; otherwise it is 240–320px.\n- Option icons: set `icon` on each item.\n- For several values use `SelectInput multiple`. `SelectButtonTag` is a trigger, not a chip list.\n\n**Picker dialog**\n\n- Use `Dialog width={960}`; there is no `DIALOG_SIZES`.\n- Dialog parts own the 24px gutter. **Never** pad them. `DialogBody` has no `className`: put `flex flex-col gap-8` on a child div, search and tabs in `flex items-center gap-12`.\n- Pass `getRowId` so selection survives search and paging.\n- Primary is `disabled` \"Add users\" until rows are picked, then \"Add 1 user\", \"Add 3 users\".\n\n## Examples\n\nA filter bar over a table: search, a multiple and a single filter, a scope chip, and the view toggle last.\n\nEvery pick applies at once. When the filters match nothing, the table offers \"Reset filters\",\nwhich clears the search and every filter.\n\n```tsx story=Default\nimport { useState } from 'react';\nimport { Badge } from '@wallarm-org/design-system/Badge';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\nimport { FilterDropdown, FilterDropdownAllOption, FilterDropdownContent, FilterDropdownFooter, FilterDropdownOption, FilterDropdownTrigger, type FilterDropdownValueChangeDetails, useFilterDropdown } from '@wallarm-org/design-system/FilterDropdown';\nimport { FilterX, List, SearchX, Workflow } from '@wallarm-org/design-system/icons';\nimport { Page, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\nimport { type TableCellContext, type TableColumnDef, Table, TableEmptyState } from '@wallarm-org/design-system/Table';\n\nexport const Default = () => {\n const [query, setQuery] = useState('');\n const [types, setTypes] = useState<string[]>([]);\n const [status, setStatus] = useState<string[]>([]);\n const [scope, setScope] = useState<string[]>([]);\n const [view, setView] = useState('table');\n\n const TYPE_LABELS: Record<AttackType, string> = {\n sqli: 'SQL injection',\n xss: 'XSS',\n rce: 'RCE',\n ptrav: 'Path traversal',\n ssrf: 'SSRF',\n };\n const typeItems = Object.entries(TYPE_LABELS).map(([value, label]) => ({\n value,\n label,\n count: ATTACKS.filter(attack => attack.type === value).length,\n }));\n const typeOptions = createListCollection({ items: typeItems });\n const statusOptions = createListCollection({\n items: [\n { value: 'blocked', label: 'Blocked' },\n { value: 'monitored', label: 'Monitored' },\n ],\n });\n const scopeOptions = createFilterCascadeCollection(SCOPES);\n\n const renderType = ({ row }: TableCellContext<Attack, unknown>) => TYPE_LABELS[row.original.type];\n\n const renderStatus = ({ row }: TableCellContext<Attack, unknown>) =>\n row.original.status === 'blocked' ? (\n <Badge variant='dotted' type='secondary' color='red'>\n Blocked\n </Badge>\n ) : (\n <Badge variant='dotted' type='secondary' color='yellow'>\n Monitored\n </Badge>\n );\n\n const columns: TableColumnDef<Attack>[] = [\n { accessorKey: 'type', header: 'Type', size: 160, cell: renderType },\n { accessorKey: 'path', header: 'Request', size: 280 },\n { accessorKey: 'source', header: 'Source IP', size: 160 },\n { accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },\n { accessorKey: 'hits', header: 'Hits', size: 100 },\n ];\n\n const search = query.trim().toLowerCase();\n const rows = ATTACKS.filter(\n attack =>\n (attack.path.toLowerCase().includes(search) || attack.source.includes(search)) &&\n (types.length === 0 || types.includes(attack.type)) &&\n (status.length === 0 || status.includes(attack.status)) &&\n (scope.length === 0 || attack.deployment === scope[0]) &&\n (scope.length < 2 || attack.application === scope[1]),\n );\n\n const handleTypesChange = (details: FilterDropdownValueChangeDetails) => setTypes(details.value);\n const handleStatusChange = (details: FilterDropdownValueChangeDetails) =>\n setStatus(details.value);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n\n const handleReset = () => {\n setQuery('');\n setTypes([]);\n setStatus([]);\n setScope([]);\n };\n\n return (\n <Page name='attacks' fullSize fixedHeight data-testid='attacks-page'>\n <PageHeader>\n <PageHeaderGroup className='flex-1'>\n <PageTitle>Attacks</PageTitle>\n <PageDescription>\n Malicious requests the filtering nodes detected in the last 7 days.\n </PageDescription>\n </PageHeaderGroup>\n </PageHeader>\n\n <PageToolbar>\n <div className='flex items-center gap-8'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search request or IP'\n className='w-[320px]'\n data-testid='attacks-search'\n />\n <FilterDropdown\n label='Type'\n multiple\n collection={typeOptions}\n value={types}\n onValueChange={handleTypesChange}\n data-testid='attacks-type-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n {/* Under 8 options the menu has no search, so the options are listed directly.\n From 8, render them from `useFilterDropdown().groups` in a child component. */}\n {typeItems.map(item => (\n <FilterDropdownOption key={item.value} item={item} hint={item.count} />\n ))}\n <FilterDropdownFooter />\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterDropdown\n label='Status'\n allLabel='All statuses'\n collection={statusOptions}\n value={status}\n onValueChange={handleStatusChange}\n data-testid='attacks-status-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n <FilterDropdownAllOption />\n {statusOptions.items.map(item => (\n <FilterDropdownOption key={item.value} item={item} />\n ))}\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterCascade\n label='Scope'\n collection={scopeOptions}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='attacks-scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent />\n </FilterCascade>\n </div>\n <SegmentedControl\n value={view}\n onChange={setView}\n className='ml-auto'\n data-testid='attacks-view-toggle'\n >\n <SegmentedControlItem value='table'>\n <List />\n <span className='sr-only'>Table view</span>\n </SegmentedControlItem>\n <SegmentedControlItem value='schema'>\n <Workflow />\n <span className='sr-only'>Schema view</span>\n </SegmentedControlItem>\n </SegmentedControl>\n </PageToolbar>\n\n <PageContent>\n <Table\n aria-label='Attacks'\n data={rows}\n columns={columns}\n getRowId={getAttackId}\n data-testid='attacks-table'\n >\n <TableEmptyState>\n <EmptyState type='collection-empty' data-testid='attacks-no-results'>\n <EmptyStateIllustration>\n <SearchX />\n </EmptyStateIllustration>\n <EmptyStateMessage>\n <EmptyStateTitle>No results found</EmptyStateTitle>\n <EmptyStateDescription>\n No attacks match your search or filters.\n </EmptyStateDescription>\n </EmptyStateMessage>\n <EmptyStateActions>\n <Button size='medium' variant='outline' color='neutral' onClick={handleReset}>\n <FilterX />\n Reset filters\n </Button>\n </EmptyStateActions>\n </EmptyState>\n </TableEmptyState>\n </Table>\n </PageContent>\n </Page>\n );\n};\n```\n\nFrom eight options a filter menu gets a search, and its options follow the query.\n\nOptions are grouped by deployment and carry attack counts. On reopen, picked options are\npinned under «Selected»; a query with no match shows an empty message and keeps the menu open.\n\n```tsx story=SearchableFilter\nimport { useState } from 'react';\nimport { FilterDropdown, FilterDropdownTrigger, type FilterDropdownValueChangeDetails } from '@wallarm-org/design-system/FilterDropdown';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\n\nexport const SearchableFilter = () => {\n const [applications, setApplications] = useState<string[]>([]);\n const applicationOptions = createListCollection({\n items: APPLICATIONS,\n groupBy: item => item.deployment,\n });\n\n const handleApplicationsChange = (details: FilterDropdownValueChangeDetails) =>\n setApplications(details.value);\n\n return (\n <div className='p-24'>\n <FilterDropdown\n label='Application'\n multiple\n collection={applicationOptions}\n value={applications}\n onValueChange={handleApplicationsChange}\n data-testid='applications-filter'\n >\n <FilterDropdownTrigger />\n <ApplicationMenu />\n </FilterDropdown>\n </div>\n );\n};\n```\n\nA scope chip whose applications load on demand and whose deployments can be picked.\n\nEach option shows its policy count, \"No policies\" for zero. ✕ on the trigger returns to every\nscope, not one level up.\n\n```tsx story=ScopeFilter\nimport { useState } from 'react';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeItems, type FilterCascadeLevelData, FilterCascadeLevels, FilterCascadeParentItem, FilterCascadeSearch, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\n\nexport const ScopeFilter = () => {\n const [scope, setScope] = useState<string[]>([]);\n const scopes = createFilterCascadeCollection(DEPLOYMENTS, {\n getValue: node => node.id,\n getLabel: node => node.name,\n hasChildren: node => node.kind === 'deployment',\n getIcon: node => (\n <span\n aria-hidden\n className={\n node.kind === 'deployment'\n ? 'size-6 rounded-full bg-badge-sky-strong'\n : 'size-6 rounded-full bg-badge-teal-strong'\n }\n />\n ),\n getDescription: node =>\n node.policies === 0\n ? 'No policies'\n : `${node.policies} ${node.policies === 1 ? 'policy' : 'policies'}`,\n });\n\n const loadApplications = (deployment: ScopeNode) => fetchApplications(deployment.id);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n const renderLevel = (level: FilterCascadeLevelData) =>\n level.depth === 0 ? (\n <FilterCascadeItems />\n ) : (\n <>\n <FilterCascadeParentItem />\n <FilterCascadeItems />\n </>\n );\n\n return (\n <div className='p-24'>\n <FilterCascade\n label='Scope'\n collection={scopes}\n loadChildren={loadApplications}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent>\n <FilterCascadeSearch placeholder='Search' />\n <FilterCascadeLevels>{renderLevel}</FilterCascadeLevels>\n </FilterCascadeContent>\n </FilterCascade>\n </div>\n );\n};\n```\n\nA searchable select in a form, with the menu matching the trigger.\n\nA settings field saves on pick, with no Save button. A query with no match shows\n`SelectEmptyState` and keeps the menu open.\n\n```tsx story=SearchableSelect\nimport { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={filteredCollection}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};\n```\n\nA picker dialog whose primary counts the selection: disabled \"Add users\", then \"Add 2 users\".\n\nSearch and status tabs sit over a selectable `Table`. Picked rows stay picked while the search\nchanges, because rows are keyed by `getRowId`.\n\n```tsx story=PickerDialog\nimport { useState } from 'react';\nimport { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogFooterControls, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';\nimport { EmptyState, EmptyStateDescription, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { UserPlus } from '@wallarm-org/design-system/icons';\nimport { NumericBadge } from '@wallarm-org/design-system/NumericBadge';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';\nimport { type TableCellContext, type TableColumnDef, type TableRowSelectionState, Table } from '@wallarm-org/design-system/Table';\n\nexport const PickerDialog = () => {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [status, setStatus] = useState('all');\n const [selection, setSelection] = useState<TableRowSelectionState>({});\n\n const renderMember = ({ row }: TableCellContext<Member, unknown>) => (\n <Avatar size='md'>\n <AvatarFallback name={row.original.name} />\n <AvatarContent>\n <AvatarName>{row.original.name}</AvatarName>\n <AvatarDescription>{row.original.email}</AvatarDescription>\n </AvatarContent>\n </Avatar>\n );\n\n const renderStatus = ({ row }: TableCellContext<Member, unknown>) =>\n row.original.status === 'active' ? 'Active' : 'Invited';\n\n const columns: TableColumnDef<Member>[] = [\n { accessorKey: 'name', header: 'User', size: 520, cell: renderMember },\n { accessorKey: 'status', header: 'Status', size: 200, cell: renderStatus },\n ];\n\n const search = query.trim().toLowerCase();\n const matching = MEMBERS.filter(\n member =>\n member.name.toLowerCase().includes(search) || member.email.toLowerCase().includes(search),\n );\n const activeCount = matching.filter(member => member.status === 'active').length;\n const invitedCount = matching.length - activeCount;\n const rows = status === 'all' ? matching : matching.filter(member => member.status === status);\n const count = Object.keys(selection).length;\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setQuery('');\n setStatus('all');\n setSelection({});\n }\n };\n const handleOpen = () => setOpen(true);\n const handleAdd = () => {\n onAddUsers(Object.keys(selection));\n handleOpenChange(false);\n };\n\n return (\n <div className='p-24'>\n <Button size='medium' onClick={handleOpen} data-testid='members-add'>\n <UserPlus />\n Add users\n </Button>\n <Dialog open={open} onOpenChange={handleOpenChange} width={960} data-testid='members-picker'>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add users to Security team</DialogTitle>\n </DialogHeader>\n <DialogBody>\n <div className='flex flex-col gap-8'>\n <div className='flex items-center gap-12'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search name or email'\n className='flex-1'\n data-testid='members-search'\n />\n <SegmentedTabs\n value={status}\n onChange={setStatus}\n data-testid='members-status-tabs'\n >\n <SegmentedTabsList>\n <SegmentedTabsTrigger value='all'>\n All <NumericBadge>{matching.length}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='active'>\n Active <NumericBadge>{activeCount}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='invited'>\n Invited <NumericBadge>{invitedCount}</NumericBadge>\n </SegmentedTabsTrigger>\n </SegmentedTabsList>\n </SegmentedTabs>\n </div>\n <Table\n aria-label='Users to add'\n data={rows}\n columns={columns}\n getRowId={getMemberId}\n rowSelection={selection}\n onRowSelectionChange={setSelection}\n data-testid='members-table'\n >\n {rows.length === 0 && (\n <EmptyState type='collection-empty' data-testid='members-no-results'>\n <EmptyStateMessage>\n <EmptyStateTitle>No users found</EmptyStateTitle>\n <EmptyStateDescription>No users match your search.</EmptyStateDescription>\n </EmptyStateMessage>\n </EmptyState>\n )}\n </Table>\n </div>\n </DialogBody>\n <DialogFooter>\n <DialogFooterControls>\n <DialogClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Cancel\n </Button>\n </DialogClose>\n <Button\n size='large'\n disabled={count === 0}\n onClick={handleAdd}\n data-testid='members-confirm'\n >\n {count === 0 ? 'Add users' : `Add ${count} ${count === 1 ? 'user' : 'users'}`}\n </Button>\n </DialogFooterControls>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n```\n\n## States\n\n| State | Show | Example component |\n| --- | --- | --- |\n| Unset | Single: `allLabel`; multi: `label` | `FilterDropdownTrigger` |\n| One value / several | \"Type • Lua\" / \"Type • 2\", built in; never custom text or a tag per value | `FilterDropdownTrigger` |\n| Reset one filter | Multi: ✕ or Backspace; single: «All». No per-filter Reset button | `FilterDropdown` |\n| Reset scope | ✕ returns to the page default, not one level up | `FilterCascadeTrigger` |\n| 8+ options | Search appears (`searchThreshold`) | `FilterDropdownSearch`, `SelectSearchInput` |\n| Menu search, no match | Empty message; menu stays open | `FilterDropdownEmpty`, `SelectEmptyState` |\n| Cascade level loading or failed | Built-in loading rows, then Retry | `FilterCascade` |\n| Filters match no rows | `type='collection-empty'` + outline neutral \"Reset filters\"; never a create CTA | `TableEmptyState` |\n| Default value | Pinned first in a \"Suggested\" group | `SelectGroup` |\n| Select on settings page | Saves on pick, toast; no Save button | `Select`, `Toast` |\n| Picker running | Primary `loading`, dialog open; on success close and toast \"3 users added\" | `Button`, `Dialog` |\n| Picker, no match | `EmptyState type='collection-empty'` as a direct `Table` child; `TableEmptyState` is too tall | `EmptyState` |\n| Picker, already a member | Leave the row out of `data` | `Table` |\n\n## What your app owns\n\n| You own | The DS owns |\n| --- | --- |\n| Applying `details.value` to your data | Filter values and trigger text |\n| URL sync (no router integration) | Nothing |\n| \"Reset all\": every filter `[]`, search `''` | Per-filter clear |\n| Option counts (`hint`, `getDescription`); a pinned option goes first in its own `category` | Rendering them |\n| Scope dots: `size-6 rounded-full` span, `bg-badge-violet-strong` / `-sky-strong` / `-teal-strong`, via `getIcon` | The icon slot |\n| Server search: debounce `query`, refetch `data` | Client filtering only |\n| Picker selection across pages: keep `rowSelection` keys (row ids) when `data` changes | Checkbox column |\n| Picker user cell (name, muted email): see [Entity table](./entity-table.md) | Nothing |\n\n## Related\n\n- [Resource list page](./resource-list-page.md), [Entity table](./entity-table.md), [Empty states](./empty-states.md)\n- [Feedback toasts](./feedback-toasts.md), [Settings page](./settings-page.md), [Create and edit forms](./create-edit-forms.md)\n- [Spacing](../foundations/spacing.md)",
1690
1690
  "sections": [
1691
1691
  {
1692
1692
  "id": "when-to-use",
@@ -1696,12 +1696,12 @@
1696
1696
  {
1697
1697
  "id": "rules",
1698
1698
  "heading": "Rules",
1699
- "markdown": "**Filter bar layout**\n\n- `PageToolbar` owns the 24px gutter and 12px gap. **Never** add `gap-*`, `px-*` or `py-*` to it.\n- Wrap `SearchInput` and the filters in one `<div className='flex items-center gap-8'>`.\n- `SearchInput` is `w-[320px]` in a toolbar, `flex-1` in a dialog.\n- A view toggle goes last with `className='ml-auto'`.\n- **Never** set a width on filter triggers; they hug their text up to 180px.\n- **Never** stack two `SegmentedTabs` in one toolbar.\n\n**FilterDropdown**\n\n- Always give it a `label`; it names the trigger and aria-label.\n- If the attribute is exclusive, use `allLabel` («All …» resets). If values combine, use `multiple` (OR-ed).\n- Build `collection` with `createListCollection({ items, groupBy })`.\n- Render options from `useFilterDropdown().groups` in a child component so they follow the search.\n- `details.value` of `[]` means unset. Pass counts as `hint`.\n- **Never** put `FilterDropdown` in a form or add an Apply button to a filter menu.\n\n**FilterCascade**\n\n- Import all cascade parts from `@wallarm-org/design-system/FilterCascade`, never the root.\n- Build `collection` with `createFilterCascadeCollection(items, accessors)`; plain `{ value, label, children }` items need no accessors.\n- If a level loads on demand, pass `loadChildren` and mark parents `hasChildren`. If a parent is pickable, pass `parentLabel`.\n- If the menu needs a toggle (\"Own only\"), use `FilterCascadeCheckboxItem` in `FilterCascadeSection`; you keep its state.\n- **Never** leave a description empty; show \"No policies\" for zero.\n\n**FilterInput**\n\n- Pass `fields` (`name`, `label`, `type`, `values`) and `value` / `onChange(ExprNode | null)`. Its menus and chips are built in.\n\n**Searchable select**\n\n- Put `SelectSearchInput` in `SelectHeader`, wired to `useSelectSearch`. Pass the original collection to `Select`; render `filteredCollection`.\n- If the menu must match the trigger, pass `positioning={{ sameWidth: true }}` and `SelectPositioner className='min-w-full max-w-full'`; otherwise it is 240–320px.\n- Option icons: set `icon` on each item.\n- For several values use `SelectInput multiple`. `SelectButtonTag` is a trigger, not a chip list.\n\n**Picker dialog**\n\n- Use `Dialog width={960}`; there is no `DIALOG_SIZES`.\n- Dialog parts own the 24px gutter. **Never** pad them. `DialogBody` has no `className`: put `flex flex-col gap-8` on a child div, search and tabs in `flex items-center gap-12`.\n- Pass `getRowId` so selection survives search and paging.\n- Primary is `disabled` \"Add users\" until rows are picked, then \"Add 1 user\", \"Add 3 users\"."
1699
+ "markdown": "**Filter bar layout**\n\n- `PageToolbar` owns the 24px gutter and 12px gap. **Never** add `gap-*`, `px-*` or `py-*` to it.\n- Wrap `SearchInput` and the filters in one `<div className='flex items-center gap-8'>`.\n- `SearchInput` is `w-[320px]` in a toolbar, `flex-1` in a dialog.\n- A view toggle goes last with `className='ml-auto'`.\n- **Never** set a width on filter triggers; they hug their text up to 180px.\n- **Never** stack two `SegmentedTabs` in one toolbar.\n\n**FilterDropdown**\n\n- Always give it a `label`; it names the trigger and aria-label.\n- If the attribute is exclusive, use `allLabel` («All …» resets). If values combine, use `multiple` (OR-ed).\n- Build `collection` with `createListCollection({ items, groupBy })`.\n- Render options from `useFilterDropdown().groups` in a child component so they follow the search.\n- `details.value` of `[]` means unset. Pass counts as `hint`.\n- **Never** put `FilterDropdown` in a form or add an Apply button to a filter menu.\n\n**FilterCascade**\n\n- Import all cascade parts from `@wallarm-org/design-system/FilterCascade`, never the root.\n- Build `collection` with `createFilterCascadeCollection(items, accessors)`; plain `{ value, label, children }` items need no accessors.\n- If a level loads on demand, pass `loadChildren` and mark parents `hasChildren`. If a parent is pickable, pass `parentLabel`.\n- If the menu needs a toggle (\"Own only\"), use `FilterCascadeCheckboxItem` in `FilterCascadeSection`; you keep its state.\n- **Never** leave a description empty; show \"No policies\" for zero.\n\n**FilterInput**\n\n- Pass `fields` (`name`, `label`, `type`, `values`) and `value` / `onChange(ExprNode | null)`. Its menus and chips are built in.\n\n**Searchable select**\n\n- Put `SelectSearchInput` in `SelectHeader`, wired to `useSelectSearch`. Pass `filteredCollection` to `Select` and render it, so arrow keys skip hidden options.\n- If the menu must match the trigger, pass `positioning={{ sameWidth: true }}` and `SelectPositioner className='min-w-full max-w-full'`; otherwise it is 240–320px.\n- Option icons: set `icon` on each item.\n- For several values use `SelectInput multiple`. `SelectButtonTag` is a trigger, not a chip list.\n\n**Picker dialog**\n\n- Use `Dialog width={960}`; there is no `DIALOG_SIZES`.\n- Dialog parts own the 24px gutter. **Never** pad them. `DialogBody` has no `className`: put `flex flex-col gap-8` on a child div, search and tabs in `flex items-center gap-12`.\n- Pass `getRowId` so selection survives search and paging.\n- Primary is `disabled` \"Add users\" until rows are picked, then \"Add 1 user\", \"Add 3 users\"."
1700
1700
  },
1701
1701
  {
1702
1702
  "id": "examples",
1703
1703
  "heading": "Examples",
1704
- "markdown": "A filter bar over a table: search, a multiple and a single filter, a scope chip, and the view toggle last.\n\nEvery pick applies at once. When the filters match nothing, the table offers \"Reset filters\",\nwhich clears the search and every filter.\n\n```tsx story=Default\nimport { useState } from 'react';\nimport { Badge } from '@wallarm-org/design-system/Badge';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\nimport { FilterDropdown, FilterDropdownAllOption, FilterDropdownContent, FilterDropdownFooter, FilterDropdownOption, FilterDropdownTrigger, type FilterDropdownValueChangeDetails, useFilterDropdown } from '@wallarm-org/design-system/FilterDropdown';\nimport { FilterX, List, SearchX, Workflow } from '@wallarm-org/design-system/icons';\nimport { Page, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\nimport { type TableCellContext, type TableColumnDef, Table, TableEmptyState } from '@wallarm-org/design-system/Table';\n\nexport const Default = () => {\n const [query, setQuery] = useState('');\n const [types, setTypes] = useState<string[]>([]);\n const [status, setStatus] = useState<string[]>([]);\n const [scope, setScope] = useState<string[]>([]);\n const [view, setView] = useState('table');\n\n const TYPE_LABELS: Record<AttackType, string> = {\n sqli: 'SQL injection',\n xss: 'XSS',\n rce: 'RCE',\n ptrav: 'Path traversal',\n ssrf: 'SSRF',\n };\n const typeItems = Object.entries(TYPE_LABELS).map(([value, label]) => ({\n value,\n label,\n count: ATTACKS.filter(attack => attack.type === value).length,\n }));\n const typeOptions = createListCollection({ items: typeItems });\n const statusOptions = createListCollection({\n items: [\n { value: 'blocked', label: 'Blocked' },\n { value: 'monitored', label: 'Monitored' },\n ],\n });\n const scopeOptions = createFilterCascadeCollection(SCOPES);\n\n const renderType = ({ row }: TableCellContext<Attack, unknown>) => TYPE_LABELS[row.original.type];\n\n const renderStatus = ({ row }: TableCellContext<Attack, unknown>) =>\n row.original.status === 'blocked' ? (\n <Badge variant='dotted' type='secondary' color='red'>\n Blocked\n </Badge>\n ) : (\n <Badge variant='dotted' type='secondary' color='yellow'>\n Monitored\n </Badge>\n );\n\n const columns: TableColumnDef<Attack>[] = [\n { accessorKey: 'type', header: 'Type', size: 160, cell: renderType },\n { accessorKey: 'path', header: 'Request', size: 280 },\n { accessorKey: 'source', header: 'Source IP', size: 160 },\n { accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },\n { accessorKey: 'hits', header: 'Hits', size: 100 },\n ];\n\n const search = query.trim().toLowerCase();\n const rows = ATTACKS.filter(\n attack =>\n (attack.path.toLowerCase().includes(search) || attack.source.includes(search)) &&\n (types.length === 0 || types.includes(attack.type)) &&\n (status.length === 0 || status.includes(attack.status)) &&\n (scope.length === 0 || attack.deployment === scope[0]) &&\n (scope.length < 2 || attack.application === scope[1]),\n );\n\n const handleTypesChange = (details: FilterDropdownValueChangeDetails) => setTypes(details.value);\n const handleStatusChange = (details: FilterDropdownValueChangeDetails) =>\n setStatus(details.value);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n\n const handleReset = () => {\n setQuery('');\n setTypes([]);\n setStatus([]);\n setScope([]);\n };\n\n return (\n <Page name='attacks' fullSize fixedHeight data-testid='attacks-page'>\n <PageHeader>\n <PageHeaderGroup className='flex-1'>\n <PageTitle>Attacks</PageTitle>\n <PageDescription>\n Malicious requests the filtering nodes detected in the last 7 days.\n </PageDescription>\n </PageHeaderGroup>\n </PageHeader>\n\n <PageToolbar>\n <div className='flex items-center gap-8'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search request or IP'\n className='w-[320px]'\n data-testid='attacks-search'\n />\n <FilterDropdown\n label='Type'\n multiple\n collection={typeOptions}\n value={types}\n onValueChange={handleTypesChange}\n data-testid='attacks-type-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n {/* Under 8 options the menu has no search, so the options are listed directly.\n From 8, render them from `useFilterDropdown().groups` in a child component. */}\n {typeItems.map(item => (\n <FilterDropdownOption key={item.value} item={item} hint={item.count} />\n ))}\n <FilterDropdownFooter />\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterDropdown\n label='Status'\n allLabel='All statuses'\n collection={statusOptions}\n value={status}\n onValueChange={handleStatusChange}\n data-testid='attacks-status-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n <FilterDropdownAllOption />\n {statusOptions.items.map(item => (\n <FilterDropdownOption key={item.value} item={item} />\n ))}\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterCascade\n label='Scope'\n collection={scopeOptions}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='attacks-scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent />\n </FilterCascade>\n </div>\n <SegmentedControl\n value={view}\n onChange={setView}\n className='ml-auto'\n data-testid='attacks-view-toggle'\n >\n <SegmentedControlItem value='table'>\n <List />\n <span className='sr-only'>Table view</span>\n </SegmentedControlItem>\n <SegmentedControlItem value='schema'>\n <Workflow />\n <span className='sr-only'>Schema view</span>\n </SegmentedControlItem>\n </SegmentedControl>\n </PageToolbar>\n\n <PageContent>\n <Table\n aria-label='Attacks'\n data={rows}\n columns={columns}\n getRowId={getAttackId}\n data-testid='attacks-table'\n >\n <TableEmptyState>\n <EmptyState type='collection-empty' data-testid='attacks-no-results'>\n <EmptyStateIllustration>\n <SearchX />\n </EmptyStateIllustration>\n <EmptyStateMessage>\n <EmptyStateTitle>No results found</EmptyStateTitle>\n <EmptyStateDescription>\n No attacks match your search or filters.\n </EmptyStateDescription>\n </EmptyStateMessage>\n <EmptyStateActions>\n <Button size='medium' variant='outline' color='neutral' onClick={handleReset}>\n <FilterX />\n Reset filters\n </Button>\n </EmptyStateActions>\n </EmptyState>\n </TableEmptyState>\n </Table>\n </PageContent>\n </Page>\n );\n};\n```\n\nFrom eight options a filter menu gets a search, and its options follow the query.\n\nOptions are grouped by deployment and carry attack counts. On reopen, picked options are\npinned under «Selected»; a query with no match shows an empty message and keeps the menu open.\n\n```tsx story=SearchableFilter\nimport { useState } from 'react';\nimport { FilterDropdown, FilterDropdownTrigger, type FilterDropdownValueChangeDetails } from '@wallarm-org/design-system/FilterDropdown';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\n\nexport const SearchableFilter = () => {\n const [applications, setApplications] = useState<string[]>([]);\n const applicationOptions = createListCollection({\n items: APPLICATIONS,\n groupBy: item => item.deployment,\n });\n\n const handleApplicationsChange = (details: FilterDropdownValueChangeDetails) =>\n setApplications(details.value);\n\n return (\n <div className='p-24'>\n <FilterDropdown\n label='Application'\n multiple\n collection={applicationOptions}\n value={applications}\n onValueChange={handleApplicationsChange}\n data-testid='applications-filter'\n >\n <FilterDropdownTrigger />\n <ApplicationMenu />\n </FilterDropdown>\n </div>\n );\n};\n```\n\nA scope chip whose applications load on demand and whose deployments can be picked.\n\nEach option shows its policy count, \"No policies\" for zero. ✕ on the trigger returns to every\nscope, not one level up.\n\n```tsx story=ScopeFilter\nimport { useState } from 'react';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeItems, type FilterCascadeLevelData, FilterCascadeLevels, FilterCascadeParentItem, FilterCascadeSearch, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\n\nexport const ScopeFilter = () => {\n const [scope, setScope] = useState<string[]>([]);\n const scopes = createFilterCascadeCollection(DEPLOYMENTS, {\n getValue: node => node.id,\n getLabel: node => node.name,\n hasChildren: node => node.kind === 'deployment',\n getIcon: node => (\n <span\n aria-hidden\n className={\n node.kind === 'deployment'\n ? 'size-6 rounded-full bg-badge-sky-strong'\n : 'size-6 rounded-full bg-badge-teal-strong'\n }\n />\n ),\n getDescription: node =>\n node.policies === 0\n ? 'No policies'\n : `${node.policies} ${node.policies === 1 ? 'policy' : 'policies'}`,\n });\n\n const loadApplications = (deployment: ScopeNode) => fetchApplications(deployment.id);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n const renderLevel = (level: FilterCascadeLevelData) =>\n level.depth === 0 ? (\n <FilterCascadeItems />\n ) : (\n <>\n <FilterCascadeParentItem />\n <FilterCascadeItems />\n </>\n );\n\n return (\n <div className='p-24'>\n <FilterCascade\n label='Scope'\n collection={scopes}\n loadChildren={loadApplications}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent>\n <FilterCascadeSearch placeholder='Search' />\n <FilterCascadeLevels>{renderLevel}</FilterCascadeLevels>\n </FilterCascadeContent>\n </FilterCascade>\n </div>\n );\n};\n```\n\nA searchable select in a form, with the menu matching the trigger.\n\nA settings field saves on pick, with no Save button. A query with no match shows\n`SelectEmptyState` and keeps the menu open.\n\n```tsx story=SearchableSelect\nimport { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={timeZones}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};\n```\n\nA picker dialog whose primary counts the selection: disabled \"Add users\", then \"Add 2 users\".\n\nSearch and status tabs sit over a selectable `Table`. Picked rows stay picked while the search\nchanges, because rows are keyed by `getRowId`.\n\n```tsx story=PickerDialog\nimport { useState } from 'react';\nimport { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogFooterControls, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';\nimport { EmptyState, EmptyStateDescription, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { UserPlus } from '@wallarm-org/design-system/icons';\nimport { NumericBadge } from '@wallarm-org/design-system/NumericBadge';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';\nimport { type TableCellContext, type TableColumnDef, type TableRowSelectionState, Table } from '@wallarm-org/design-system/Table';\n\nexport const PickerDialog = () => {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [status, setStatus] = useState('all');\n const [selection, setSelection] = useState<TableRowSelectionState>({});\n\n const renderMember = ({ row }: TableCellContext<Member, unknown>) => (\n <Avatar size='md'>\n <AvatarFallback name={row.original.name} />\n <AvatarContent>\n <AvatarName>{row.original.name}</AvatarName>\n <AvatarDescription>{row.original.email}</AvatarDescription>\n </AvatarContent>\n </Avatar>\n );\n\n const renderStatus = ({ row }: TableCellContext<Member, unknown>) =>\n row.original.status === 'active' ? 'Active' : 'Invited';\n\n const columns: TableColumnDef<Member>[] = [\n { accessorKey: 'name', header: 'User', size: 520, cell: renderMember },\n { accessorKey: 'status', header: 'Status', size: 200, cell: renderStatus },\n ];\n\n const search = query.trim().toLowerCase();\n const matching = MEMBERS.filter(\n member =>\n member.name.toLowerCase().includes(search) || member.email.toLowerCase().includes(search),\n );\n const activeCount = matching.filter(member => member.status === 'active').length;\n const invitedCount = matching.length - activeCount;\n const rows = status === 'all' ? matching : matching.filter(member => member.status === status);\n const count = Object.keys(selection).length;\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setQuery('');\n setStatus('all');\n setSelection({});\n }\n };\n const handleOpen = () => setOpen(true);\n const handleAdd = () => {\n onAddUsers(Object.keys(selection));\n handleOpenChange(false);\n };\n\n return (\n <div className='p-24'>\n <Button size='medium' onClick={handleOpen} data-testid='members-add'>\n <UserPlus />\n Add users\n </Button>\n <Dialog open={open} onOpenChange={handleOpenChange} width={960} data-testid='members-picker'>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add users to Security team</DialogTitle>\n </DialogHeader>\n <DialogBody>\n <div className='flex flex-col gap-8'>\n <div className='flex items-center gap-12'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search name or email'\n className='flex-1'\n data-testid='members-search'\n />\n <SegmentedTabs\n value={status}\n onChange={setStatus}\n data-testid='members-status-tabs'\n >\n <SegmentedTabsList>\n <SegmentedTabsTrigger value='all'>\n All <NumericBadge>{matching.length}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='active'>\n Active <NumericBadge>{activeCount}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='invited'>\n Invited <NumericBadge>{invitedCount}</NumericBadge>\n </SegmentedTabsTrigger>\n </SegmentedTabsList>\n </SegmentedTabs>\n </div>\n <Table\n aria-label='Users to add'\n data={rows}\n columns={columns}\n getRowId={getMemberId}\n rowSelection={selection}\n onRowSelectionChange={setSelection}\n data-testid='members-table'\n >\n {rows.length === 0 && (\n <EmptyState type='collection-empty' data-testid='members-no-results'>\n <EmptyStateMessage>\n <EmptyStateTitle>No users found</EmptyStateTitle>\n <EmptyStateDescription>No users match your search.</EmptyStateDescription>\n </EmptyStateMessage>\n </EmptyState>\n )}\n </Table>\n </div>\n </DialogBody>\n <DialogFooter>\n <DialogFooterControls>\n <DialogClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Cancel\n </Button>\n </DialogClose>\n <Button\n size='large'\n disabled={count === 0}\n onClick={handleAdd}\n data-testid='members-confirm'\n >\n {count === 0 ? 'Add users' : `Add ${count} ${count === 1 ? 'user' : 'users'}`}\n </Button>\n </DialogFooterControls>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n```"
1704
+ "markdown": "A filter bar over a table: search, a multiple and a single filter, a scope chip, and the view toggle last.\n\nEvery pick applies at once. When the filters match nothing, the table offers \"Reset filters\",\nwhich clears the search and every filter.\n\n```tsx story=Default\nimport { useState } from 'react';\nimport { Badge } from '@wallarm-org/design-system/Badge';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateIllustration, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\nimport { FilterDropdown, FilterDropdownAllOption, FilterDropdownContent, FilterDropdownFooter, FilterDropdownOption, FilterDropdownTrigger, type FilterDropdownValueChangeDetails, useFilterDropdown } from '@wallarm-org/design-system/FilterDropdown';\nimport { FilterX, List, SearchX, Workflow } from '@wallarm-org/design-system/icons';\nimport { Page, PageContent, PageDescription, PageHeader, PageHeaderGroup, PageTitle, PageToolbar } from '@wallarm-org/design-system/Page';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\nimport { type TableCellContext, type TableColumnDef, Table, TableEmptyState } from '@wallarm-org/design-system/Table';\n\nexport const Default = () => {\n const [query, setQuery] = useState('');\n const [types, setTypes] = useState<string[]>([]);\n const [status, setStatus] = useState<string[]>([]);\n const [scope, setScope] = useState<string[]>([]);\n const [view, setView] = useState('table');\n\n const TYPE_LABELS: Record<AttackType, string> = {\n sqli: 'SQL injection',\n xss: 'XSS',\n rce: 'RCE',\n ptrav: 'Path traversal',\n ssrf: 'SSRF',\n };\n const typeItems = Object.entries(TYPE_LABELS).map(([value, label]) => ({\n value,\n label,\n count: ATTACKS.filter(attack => attack.type === value).length,\n }));\n const typeOptions = createListCollection({ items: typeItems });\n const statusOptions = createListCollection({\n items: [\n { value: 'blocked', label: 'Blocked' },\n { value: 'monitored', label: 'Monitored' },\n ],\n });\n const scopeOptions = createFilterCascadeCollection(SCOPES);\n\n const renderType = ({ row }: TableCellContext<Attack, unknown>) => TYPE_LABELS[row.original.type];\n\n const renderStatus = ({ row }: TableCellContext<Attack, unknown>) =>\n row.original.status === 'blocked' ? (\n <Badge variant='dotted' type='secondary' color='red'>\n Blocked\n </Badge>\n ) : (\n <Badge variant='dotted' type='secondary' color='yellow'>\n Monitored\n </Badge>\n );\n\n const columns: TableColumnDef<Attack>[] = [\n { accessorKey: 'type', header: 'Type', size: 160, cell: renderType },\n { accessorKey: 'path', header: 'Request', size: 280 },\n { accessorKey: 'source', header: 'Source IP', size: 160 },\n { accessorKey: 'status', header: 'Status', size: 140, cell: renderStatus },\n { accessorKey: 'hits', header: 'Hits', size: 100 },\n ];\n\n const search = query.trim().toLowerCase();\n const rows = ATTACKS.filter(\n attack =>\n (attack.path.toLowerCase().includes(search) || attack.source.includes(search)) &&\n (types.length === 0 || types.includes(attack.type)) &&\n (status.length === 0 || status.includes(attack.status)) &&\n (scope.length === 0 || attack.deployment === scope[0]) &&\n (scope.length < 2 || attack.application === scope[1]),\n );\n\n const handleTypesChange = (details: FilterDropdownValueChangeDetails) => setTypes(details.value);\n const handleStatusChange = (details: FilterDropdownValueChangeDetails) =>\n setStatus(details.value);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n\n const handleReset = () => {\n setQuery('');\n setTypes([]);\n setStatus([]);\n setScope([]);\n };\n\n return (\n <Page name='attacks' fullSize fixedHeight data-testid='attacks-page'>\n <PageHeader>\n <PageHeaderGroup className='flex-1'>\n <PageTitle>Attacks</PageTitle>\n <PageDescription>\n Malicious requests the filtering nodes detected in the last 7 days.\n </PageDescription>\n </PageHeaderGroup>\n </PageHeader>\n\n <PageToolbar>\n <div className='flex items-center gap-8'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search request or IP'\n className='w-[320px]'\n data-testid='attacks-search'\n />\n <FilterDropdown\n label='Type'\n multiple\n collection={typeOptions}\n value={types}\n onValueChange={handleTypesChange}\n data-testid='attacks-type-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n {/* Under 8 options the menu has no search, so the options are listed directly.\n From 8, render them from `useFilterDropdown().groups` in a child component. */}\n {typeItems.map(item => (\n <FilterDropdownOption key={item.value} item={item} hint={item.count} />\n ))}\n <FilterDropdownFooter />\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterDropdown\n label='Status'\n allLabel='All statuses'\n collection={statusOptions}\n value={status}\n onValueChange={handleStatusChange}\n data-testid='attacks-status-filter'\n >\n <FilterDropdownTrigger />\n <FilterDropdownContent>\n <FilterDropdownAllOption />\n {statusOptions.items.map(item => (\n <FilterDropdownOption key={item.value} item={item} />\n ))}\n </FilterDropdownContent>\n </FilterDropdown>\n <FilterCascade\n label='Scope'\n collection={scopeOptions}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='attacks-scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent />\n </FilterCascade>\n </div>\n <SegmentedControl\n value={view}\n onChange={setView}\n className='ml-auto'\n data-testid='attacks-view-toggle'\n >\n <SegmentedControlItem value='table'>\n <List />\n <span className='sr-only'>Table view</span>\n </SegmentedControlItem>\n <SegmentedControlItem value='schema'>\n <Workflow />\n <span className='sr-only'>Schema view</span>\n </SegmentedControlItem>\n </SegmentedControl>\n </PageToolbar>\n\n <PageContent>\n <Table\n aria-label='Attacks'\n data={rows}\n columns={columns}\n getRowId={getAttackId}\n data-testid='attacks-table'\n >\n <TableEmptyState>\n <EmptyState type='collection-empty' data-testid='attacks-no-results'>\n <EmptyStateIllustration>\n <SearchX />\n </EmptyStateIllustration>\n <EmptyStateMessage>\n <EmptyStateTitle>No results found</EmptyStateTitle>\n <EmptyStateDescription>\n No attacks match your search or filters.\n </EmptyStateDescription>\n </EmptyStateMessage>\n <EmptyStateActions>\n <Button size='medium' variant='outline' color='neutral' onClick={handleReset}>\n <FilterX />\n Reset filters\n </Button>\n </EmptyStateActions>\n </EmptyState>\n </TableEmptyState>\n </Table>\n </PageContent>\n </Page>\n );\n};\n```\n\nFrom eight options a filter menu gets a search, and its options follow the query.\n\nOptions are grouped by deployment and carry attack counts. On reopen, picked options are\npinned under «Selected»; a query with no match shows an empty message and keeps the menu open.\n\n```tsx story=SearchableFilter\nimport { useState } from 'react';\nimport { FilterDropdown, FilterDropdownTrigger, type FilterDropdownValueChangeDetails } from '@wallarm-org/design-system/FilterDropdown';\nimport { createListCollection } from '@wallarm-org/design-system/Select';\n\nexport const SearchableFilter = () => {\n const [applications, setApplications] = useState<string[]>([]);\n const applicationOptions = createListCollection({\n items: APPLICATIONS,\n groupBy: item => item.deployment,\n });\n\n const handleApplicationsChange = (details: FilterDropdownValueChangeDetails) =>\n setApplications(details.value);\n\n return (\n <div className='p-24'>\n <FilterDropdown\n label='Application'\n multiple\n collection={applicationOptions}\n value={applications}\n onValueChange={handleApplicationsChange}\n data-testid='applications-filter'\n >\n <FilterDropdownTrigger />\n <ApplicationMenu />\n </FilterDropdown>\n </div>\n );\n};\n```\n\nA scope chip whose applications load on demand and whose deployments can be picked.\n\nEach option shows its policy count, \"No policies\" for zero. ✕ on the trigger returns to every\nscope, not one level up.\n\n```tsx story=ScopeFilter\nimport { useState } from 'react';\nimport { createFilterCascadeCollection, FilterCascade, FilterCascadeContent, FilterCascadeItems, type FilterCascadeLevelData, FilterCascadeLevels, FilterCascadeParentItem, FilterCascadeSearch, FilterCascadeTrigger, type FilterCascadeValueChangeDetails } from '@wallarm-org/design-system/FilterCascade';\n\nexport const ScopeFilter = () => {\n const [scope, setScope] = useState<string[]>([]);\n const scopes = createFilterCascadeCollection(DEPLOYMENTS, {\n getValue: node => node.id,\n getLabel: node => node.name,\n hasChildren: node => node.kind === 'deployment',\n getIcon: node => (\n <span\n aria-hidden\n className={\n node.kind === 'deployment'\n ? 'size-6 rounded-full bg-badge-sky-strong'\n : 'size-6 rounded-full bg-badge-teal-strong'\n }\n />\n ),\n getDescription: node =>\n node.policies === 0\n ? 'No policies'\n : `${node.policies} ${node.policies === 1 ? 'policy' : 'policies'}`,\n });\n\n const loadApplications = (deployment: ScopeNode) => fetchApplications(deployment.id);\n const handleScopeChange = (details: FilterCascadeValueChangeDetails) => setScope(details.value);\n const renderLevel = (level: FilterCascadeLevelData) =>\n level.depth === 0 ? (\n <FilterCascadeItems />\n ) : (\n <>\n <FilterCascadeParentItem />\n <FilterCascadeItems />\n </>\n );\n\n return (\n <div className='p-24'>\n <FilterCascade\n label='Scope'\n collection={scopes}\n loadChildren={loadApplications}\n parentLabel='Deployment level'\n value={scope}\n onValueChange={handleScopeChange}\n data-testid='scope-filter'\n >\n <FilterCascadeTrigger />\n <FilterCascadeContent>\n <FilterCascadeSearch placeholder='Search' />\n <FilterCascadeLevels>{renderLevel}</FilterCascadeLevels>\n </FilterCascadeContent>\n </FilterCascade>\n </div>\n );\n};\n```\n\nA searchable select in a form, with the menu matching the trigger.\n\nA settings field saves on pick, with no Save button. A query with no match shows\n`SelectEmptyState` and keeps the menu open.\n\n```tsx story=SearchableSelect\nimport { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={filteredCollection}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};\n```\n\nA picker dialog whose primary counts the selection: disabled \"Add users\", then \"Add 2 users\".\n\nSearch and status tabs sit over a selectable `Table`. Picked rows stay picked while the search\nchanges, because rows are keyed by `getRowId`.\n\n```tsx story=PickerDialog\nimport { useState } from 'react';\nimport { Avatar, AvatarContent, AvatarDescription, AvatarFallback, AvatarName } from '@wallarm-org/design-system/Avatar';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogFooterControls, DialogHeader, DialogTitle } from '@wallarm-org/design-system/Dialog';\nimport { EmptyState, EmptyStateDescription, EmptyStateMessage, EmptyStateTitle } from '@wallarm-org/design-system/EmptyState';\nimport { UserPlus } from '@wallarm-org/design-system/icons';\nimport { NumericBadge } from '@wallarm-org/design-system/NumericBadge';\nimport { SearchInput } from '@wallarm-org/design-system/SearchInput';\nimport { SegmentedTabs, SegmentedTabsList, SegmentedTabsTrigger } from '@wallarm-org/design-system/SegmentedTabs';\nimport { type TableCellContext, type TableColumnDef, type TableRowSelectionState, Table } from '@wallarm-org/design-system/Table';\n\nexport const PickerDialog = () => {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [status, setStatus] = useState('all');\n const [selection, setSelection] = useState<TableRowSelectionState>({});\n\n const renderMember = ({ row }: TableCellContext<Member, unknown>) => (\n <Avatar size='md'>\n <AvatarFallback name={row.original.name} />\n <AvatarContent>\n <AvatarName>{row.original.name}</AvatarName>\n <AvatarDescription>{row.original.email}</AvatarDescription>\n </AvatarContent>\n </Avatar>\n );\n\n const renderStatus = ({ row }: TableCellContext<Member, unknown>) =>\n row.original.status === 'active' ? 'Active' : 'Invited';\n\n const columns: TableColumnDef<Member>[] = [\n { accessorKey: 'name', header: 'User', size: 520, cell: renderMember },\n { accessorKey: 'status', header: 'Status', size: 200, cell: renderStatus },\n ];\n\n const search = query.trim().toLowerCase();\n const matching = MEMBERS.filter(\n member =>\n member.name.toLowerCase().includes(search) || member.email.toLowerCase().includes(search),\n );\n const activeCount = matching.filter(member => member.status === 'active').length;\n const invitedCount = matching.length - activeCount;\n const rows = status === 'all' ? matching : matching.filter(member => member.status === status);\n const count = Object.keys(selection).length;\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) {\n setQuery('');\n setStatus('all');\n setSelection({});\n }\n };\n const handleOpen = () => setOpen(true);\n const handleAdd = () => {\n onAddUsers(Object.keys(selection));\n handleOpenChange(false);\n };\n\n return (\n <div className='p-24'>\n <Button size='medium' onClick={handleOpen} data-testid='members-add'>\n <UserPlus />\n Add users\n </Button>\n <Dialog open={open} onOpenChange={handleOpenChange} width={960} data-testid='members-picker'>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add users to Security team</DialogTitle>\n </DialogHeader>\n <DialogBody>\n <div className='flex flex-col gap-8'>\n <div className='flex items-center gap-12'>\n <SearchInput\n value={query}\n onChange={setQuery}\n placeholder='Search name or email'\n className='flex-1'\n data-testid='members-search'\n />\n <SegmentedTabs\n value={status}\n onChange={setStatus}\n data-testid='members-status-tabs'\n >\n <SegmentedTabsList>\n <SegmentedTabsTrigger value='all'>\n All <NumericBadge>{matching.length}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='active'>\n Active <NumericBadge>{activeCount}</NumericBadge>\n </SegmentedTabsTrigger>\n <SegmentedTabsTrigger value='invited'>\n Invited <NumericBadge>{invitedCount}</NumericBadge>\n </SegmentedTabsTrigger>\n </SegmentedTabsList>\n </SegmentedTabs>\n </div>\n <Table\n aria-label='Users to add'\n data={rows}\n columns={columns}\n getRowId={getMemberId}\n rowSelection={selection}\n onRowSelectionChange={setSelection}\n data-testid='members-table'\n >\n {rows.length === 0 && (\n <EmptyState type='collection-empty' data-testid='members-no-results'>\n <EmptyStateMessage>\n <EmptyStateTitle>No users found</EmptyStateTitle>\n <EmptyStateDescription>No users match your search.</EmptyStateDescription>\n </EmptyStateMessage>\n </EmptyState>\n )}\n </Table>\n </div>\n </DialogBody>\n <DialogFooter>\n <DialogFooterControls>\n <DialogClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Cancel\n </Button>\n </DialogClose>\n <Button\n size='large'\n disabled={count === 0}\n onClick={handleAdd}\n data-testid='members-confirm'\n >\n {count === 0 ? 'Add users' : `Add ${count} ${count === 1 ? 'user' : 'users'}`}\n </Button>\n </DialogFooterControls>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n};\n```"
1705
1705
  },
1706
1706
  {
1707
1707
  "id": "states",
@@ -1737,7 +1737,7 @@
1737
1737
  },
1738
1738
  {
1739
1739
  "name": "SearchableSelect",
1740
- "code": "import { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={timeZones}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};",
1740
+ "code": "import { useState } from 'react';\nimport { Field, FieldDescription, FieldLabel } from '@wallarm-org/design-system/Field';\nimport { createListCollection, Select, SelectContent, SelectEmptyState, SelectHeader, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner, SelectSearchInput, useSelectSearch } from '@wallarm-org/design-system/Select';\n\nexport const SearchableSelect = () => {\n const [timeZone, setTimeZone] = useState('UTC');\n const timeZones = createListCollection({ items: TIME_ZONES });\n const { searchValue, onSearchChange, filteredCollection } = useSelectSearch(timeZones);\n\n const handleTimeZoneChange = (details: { value: string[] }) => {\n const next = details.value[0] ?? timeZone;\n setTimeZone(next);\n onTimeZoneSaved(next);\n };\n\n return (\n <div className='w-[400px] p-24'>\n <Field>\n <FieldLabel>Time zone</FieldLabel>\n <Select\n collection={filteredCollection}\n value={[timeZone]}\n positioning={{ sameWidth: true }}\n onValueChange={handleTimeZoneChange}\n data-testid='timezone-select'\n >\n <SelectInput placeholder='Choose a time zone' data-testid='timezone-input' />\n <SelectPositioner className='min-w-full max-w-full'>\n <SelectHeader>\n <SelectSearchInput value={searchValue} onChange={onSearchChange} />\n </SelectHeader>\n <SelectContent>\n {filteredCollection.size === 0 ? (\n <SelectEmptyState description={`No results for \"${searchValue}\"`} />\n ) : (\n filteredCollection.items.map(item => (\n <SelectOption key={item.value} item={item}>\n <SelectOptionText>{item.label}</SelectOptionText>\n <SelectOptionIndicator />\n </SelectOption>\n ))\n )}\n </SelectContent>\n </SelectPositioner>\n </Select>\n <FieldDescription>\n Dates in reports and on the Attacks page use this time zone.\n </FieldDescription>\n </Field>\n </div>\n );\n};",
1741
1741
  "description": "A settings field saves on pick, with no Save button. A query with no match shows\n`SelectEmptyState` and keeps the menu open."
1742
1742
  },
1743
1743
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "4.16.1-rc-fix-escape-outside-layer-stack.1",
3
+ "version": "4.16.1",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",