@vc-shell/vc-app-skill 2.11.0 → 2.12.0

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.
Files changed (20) hide show
  1. package/package.json +1 -1
  2. package/runtime/VERSION +1 -1
  3. package/runtime/knowledge/components.json +6396 -0
  4. package/runtime/knowledge/docs/_BUILD_HASH.md +1 -1
  5. package/runtime/knowledge/docs/core/blade-navigation/table-query-state/useTableQueryState.docs.md +1 -1
  6. package/runtime/knowledge/docs/core/plugins/i18n/i18n.docs.md +34 -8
  7. package/runtime/knowledge/docs/modules/assets/assets-details.docs.md +107 -40
  8. package/runtime/knowledge/docs/modules/assets-manager/assets-folder-manager.docs.md +201 -0
  9. package/runtime/knowledge/docs/modules/assets-manager/assets-manager.docs.md +1 -0
  10. package/runtime/knowledge/docs/ui/components/atoms/vc-badge/vc-badge.docs.md +16 -14
  11. package/runtime/knowledge/docs/ui/components/atoms/vc-button/vc-button.docs.md +24 -11
  12. package/runtime/knowledge/docs/ui/components/molecules/vc-accordion/vc-accordion.docs.md +18 -4
  13. package/runtime/knowledge/docs/ui/components/molecules/vc-dropdown/vc-dropdown.docs.md +71 -43
  14. package/runtime/knowledge/docs/ui/components/molecules/vc-input/vc-input.docs.md +56 -46
  15. package/runtime/knowledge/docs/ui/components/molecules/vc-popover/vc-popover.docs.md +2 -0
  16. package/runtime/knowledge/docs/ui/components/molecules/vc-switch/vc-switch.docs.md +4 -3
  17. package/runtime/knowledge/docs/ui/components/organisms/vc-data-table/vc-data-table.docs.md +140 -26
  18. package/runtime/knowledge/docs/ui/components/organisms/vc-search-bar/vc-search-bar.docs.md +284 -0
  19. package/runtime/knowledge/docs/ui/components/organisms/vc-sidebar/vc-sidebar.docs.md +46 -28
  20. package/runtime/knowledge/index.md +14 -0
@@ -1030,7 +1030,7 @@ Filters not tied to a specific column -- displayed in a separate filter panel:
1030
1030
  </VcDataTable>
1031
1031
  ```
1032
1032
 
1033
- A filter icon button appears in the toolbar. Clicking it opens the global filter panel.
1033
+ A filter icon button appears in the toolbar. Clicking it opens the global filter panel. With [`search-bar`](#search-bar-opt-in) the same filters become chips and a Filters panel in the search bar; the `@filter` payload is the same.
1034
1034
 
1035
1035
  ### Combining Column and Global Filters
1036
1036
 
@@ -1069,7 +1069,108 @@ function onSearch(value: string) {
1069
1069
  }
1070
1070
  ```
1071
1071
 
1072
- The search bar appears above the table. When `global-filters` are also set, the filter button renders beside the search input.
1072
+ The search bar appears above the table. When `global-filters` are also set, the filter button renders beside the search input. Content of the `search-header-actions` slot renders in the same toolbar row.
1073
+
1074
+ ### Search bar (opt-in)
1075
+
1076
+ Set `search-bar` to replace the search header with `VcSearchBar`: the search, applied filters as chips, a Filters panel, saved views, a filter status in the footer and an empty state that names what filtered the rows out. Without `search-bar` the table renders the classic header described above; the default may change in the next major version.
1077
+
1078
+ ```vue
1079
+ <VcDataTable :items="orders" :total-count="totalCount" :pagination="pagination" state-key="orders-list" searchable search-bar :global-filters="orderFilters" :search-views="orderViews" :unfiltered-count="allOrdersCount" @filter="onFilter" @search="onSearch">
1080
+ <template #search-header-actions>
1081
+ <VcButton icon="lucide-download" variant="outline" size="sm">Export</VcButton>
1082
+ </template>
1083
+ <VcColumn id="number" field="number" title="Number" />
1084
+ </VcDataTable>
1085
+ ```
1086
+
1087
+ ```ts
1088
+ const orderViews: SearchBarView[] = [
1089
+ { id: "open", name: "Open orders", values: { status: ["New", "Processing"] }, default: true },
1090
+ { id: "paid", name: "Paid", values: { status: ["Paid"] } },
1091
+ ];
1092
+ ```
1093
+
1094
+ - **Header.** The bar sits in a header with the table's `--table-header-bg` and `--table-header-border`. Content of the `search-header-actions` slot sits at the end of the bar's row (see [Search bar slots](#search-bar-slots)).
1095
+ - **Search.** Typing emits `update:searchValue` and `search` once per pause (`searchDebounce`), so a screen that loads on `v-model:search-value` does not load on every keystroke. A change that moves the search and the filters together ("Clear all", a typed `field:value` chip) emits `search` right before `filter`, not after the pause. The table owns the search text: `searchValue` from the parent shows in the bar.
1096
+ - **Filters.** `global-filters` become the bar's fields. The `@filter` payload is the same flat object, merged with column filters; date ranges are split into their two fields. Column filters stay outside the bar: they are not counted, not shown as chips and not cleared by the bar.
1097
+ - **Wide bar layout.** `search-bar-variant="inline"` (default) shows applied filters as chips in the row; `"summary"` shows the applied field names on the Filters button instead.
1098
+ - **Counts.** `filter-counts` gives a result count per option value, per filter id (`{ status: { Paid: 12 } }`); the Filters panel shows them when given.
1099
+ - **Views.** `search-views` are views from code; one may be the `default` the list opens on. The view selector sits next to the blade title. With a `state-key`, users save their own views in `localStorage` under `VC_SEARCHBAR_<STATE-KEY>`, separate from the column layout, also when `state-storage` is `"session"`. The search text is not part of a view.
1100
+ - **Footer status.** Next to the range text the footer reads `filtered from 120 · 2 filters + search · Clear all` while bar filters or search are applied. "filtered from M" appears only when `unfiltered-count` is set; a footer under 520px shows just the filter part and "Clear all". "Clear all" clears the bar's filters and the search and selects the "All" view; column filters stay. The status shows only with `pagination`; on a phone the summary line under the bar shows it instead.
1101
+ - **Empty state.** When the result is empty because of bar filters or search, the table names the reason ("No results match “acme” with 2 filters"), lists the applied filters as removable tags, and offers "Clear search" and "Clear filters". The `not-found` slot and `not-found-state` win over it.
1102
+
1103
+ ### Search bar slots
1104
+
1105
+ With `search-bar`, two slots place custom content around the bar:
1106
+
1107
+ - `#header` renders above everything, full width. Put list-wide content here: breadcrumbs, a list/grid toggle, a title.
1108
+ - `#search-header-actions` renders in the bar's row, after the Filters button, at its own width; the bar takes the rest and picks its mode from that width. On a phone the row is the search, the filter icon and the slot. Keep it to one or two buttons.
1109
+
1110
+ When you turn on `search-bar` for a screen that has wide content (breadcrumbs, several buttons) in `#search-header-actions`, move that content to `#header`. In development the table warns in the console once when the slot takes more than 40% of the row.
1111
+
1112
+ `#search-header-actions` gets the bar's status as slot props (`SearchBarSlotProps`); `#not-found` gets the same plus two actions (`SearchBarNotFoundSlotProps`). Without `search-bar` both slots get no props.
1113
+
1114
+ | Prop | Type | Description |
1115
+ | -------------- | ------------------------------------------- | -------------------------------------------------------------------------------- |
1116
+ | `mode` | `"wide" \| "medium" \| "narrow" \| "phone"` | The bar's width mode (wide from 720px, medium from 480px), `"phone"` on a phone. |
1117
+ | `filtered` | `boolean` | Filters or search text applied. |
1118
+ | `filterCount` | `number` | Number of bar filters with a value. |
1119
+ | `search` | `string` | The search text. |
1120
+ | `clearAll` | `() => void` | Clears the filters and the search in one `@filter`. |
1121
+ | `clearSearch` | `() => void` | `#not-found` only. Clears the search, keeps the filters. |
1122
+ | `clearFilters` | `() => void` | `#not-found` only. Clears the filters, keeps the search. |
1123
+
1124
+ ```vue
1125
+ <VcDataTable :items="orders" state-key="orders-list" searchable search-bar :global-filters="orderFilters">
1126
+ <template #header>
1127
+ <VcBreadcrumbs :items="breadcrumbs" />
1128
+ </template>
1129
+ <template #search-header-actions="{ mode }">
1130
+ <VcButton v-if="mode === 'narrow' || mode === 'phone'" icon="lucide-download" variant="outline" size="sm" aria-label="Export" />
1131
+ <VcButton v-else icon="lucide-download" variant="outline" size="sm">Export</VcButton>
1132
+ </template>
1133
+ <template #not-found="{ search, clearAll }">
1134
+ <p>Nothing matches "{{ search }}"</p>
1135
+ <VcButton size="sm" @click="clearAll">Clear all</VcButton>
1136
+ </template>
1137
+ <VcColumn id="number" field="number" title="Number" />
1138
+ </VcDataTable>
1139
+ ```
1140
+
1141
+ ### Filters and the view in the URL
1142
+
1143
+ With `search-bar` and a `state-key`, the applied filters are kept in the blade URL under `<state-key>_filters` and the current view under `<state-key>_view`, next to `<state-key>_sort`, `_search` and `_page` (see [URL query persistence](#url-query-persistence)). A copied link opens the screen with the same filters and view, and a reload keeps them. When the table opens with filters in the URL (or a default view), it emits `@filter` once before the screen's own `onMounted`, so a handler that keeps the filters in the screen's query lets the first load in `onMounted` use them, as it uses a search or sort restored in setup. Nothing is emitted when there is nothing to apply.
1144
+
1145
+ The table holds the bar's state: if the bar unmounts (no `searchable`, `global-filters` or `search-header-actions` left) and comes back, it shows the filters of the last `@filter` payload, with or without a `state-key`. Without a `state-key` nothing outlives the table.
1146
+
1147
+ - The value is compact and readable, for example `?orders_filters=status:Paid,New;created:7d;total:>=100`. The full format is in the VcSearchBar docs, "Filters and the View in the URL".
1148
+ - Relative dates stay relative: `created:7d` always means the last 7 days from the day the link is opened.
1149
+ - The search words are not part of `_filters`; `useTableSearch` keeps them in `_search`.
1150
+ - A blade without a URL, a table outside a blade, or a table without `state-key` remembers no filters.
1151
+
1152
+ ### Filters from other modules (`searchName`)
1153
+
1154
+ With `search-bar`, modules can add fields and views to a list with `registerExternalSearchFilters({ id, targetBlades, fields, views })`. By default the table's bar answers to the blade's name; set `search-name` to address it by another name (a table outside a blade, or two tables in one blade). A table without `search-bar` ignores these registrations (in development, `search-name` without `search-bar` logs a warning). Registered fields show the bar even on a table without `searchable` and `global-filters`.
1155
+
1156
+ ### VcTableAdapter
1157
+
1158
+ Legacy `VcTableAdapter` screens keep the classic header. Pass `search-bar` to the adapter to get the bar: the legacy filters button and `search-header-actions` sit at the end of the bar's row, and with no `global-filters` the bar shows only the search.
1159
+
1160
+ ### Your own bar
1161
+
1162
+ For full control over the bar's state, leave `searchable` and `global-filters` off and put your own `VcSearchBar` into the `#header` slot; load data from the bar's `v-model` or `@change` instead of the table's events:
1163
+
1164
+ ```vue
1165
+ <VcDataTable :items="orders" :loading="loading">
1166
+ <template #header>
1167
+ <VcSearchBar v-model="query" :fields="orderFields" storage-key="orders-list" @change="load" />
1168
+ </template>
1169
+ ...
1170
+ </VcDataTable>
1171
+ ```
1172
+
1173
+ `VcSearchBar` also works on its own, on any blade or in any component, with or without a table.
1073
1174
 
1074
1175
  ---
1075
1176
 
@@ -1123,7 +1224,7 @@ async function loadNextPage() {
1123
1224
  !!! tip "Use unique state keys"
1124
1225
  Every table in your application must have a distinct `state-key`. Two tables sharing the same key will silently overwrite each other's persisted column widths, order, and hidden/shown column lists.
1125
1226
 
1126
- Persist column widths, column order, and column visibility across page reloads. Column layout is stored in `localStorage`/`sessionStorage` (keyed by `state-key`). Sort, search, and the current page are NOT persisted by the table itself -- use the state composables with a matching `stateKey` instead (see [URL query persistence](#url-query-persistence) below). Selection, column filters, and other transient state are session-scoped and are deliberately excluded from any persistence:
1227
+ Persist column widths, column order, and column visibility across page reloads. Column layout is stored in `localStorage`/`sessionStorage` (keyed by `state-key`). Sort, search, and the current page are NOT persisted by the table itself -- use the state composables with a matching `stateKey` instead (see [URL query persistence](#url-query-persistence) below). Selection, column filters, and other transient state are session-scoped and are deliberately excluded from any persistence. With `search-bar`, the bar keeps saved views and the applied filters under the same key (see [Filters and the view in the URL](#filters-and-the-view-in-the-url)):
1127
1228
 
1128
1229
  ```vue
1129
1230
  <VcDataTable :items="products" state-key="product-list">
@@ -1165,8 +1266,8 @@ Sort, search, and the current page are owned by the state composables, not by `V
1165
1266
  To persist query state to the blade URL, use `useDataTableSort`, `useTableSearch`, and `useDataTablePagination` with a matching `stateKey`. Each composable restores its slice from the URL on creation and persists changes via `router.replace` (no history entries added).
1166
1267
 
1167
1268
  - **Namespacing:** URL keys are prefixed with the `stateKey` value -- e.g. `?offers_list_sort=name:DESC&offers_list_search=foo&offers_list_page=2`. Use the same string for all three composables on a given page.
1168
- - **Keys:** `<stateKey>_sort` (`field:ASC` / `field:DESC`), `<stateKey>_search`, `<stateKey>_page` (1-based).
1169
- - **Scope:** sort, search, and page only. Column layout still uses localStorage/sessionStorage; column filters and selection are not persisted.
1269
+ - **Keys:** `<stateKey>_sort` (`field:ASC` / `field:DESC`), `<stateKey>_search`, `<stateKey>_page` (1-based). With `search-bar`, the table's bar adds `<stateKey>_filters` and `<stateKey>_view` on its own when the table has the same `state-key` (see [Filters and the view in the URL](#filters-and-the-view-in-the-url)).
1270
+ - **Scope:** sort, search, page and, with `search-bar`, the bar's filters and view. Column layout still uses localStorage/sessionStorage; column filters and selection are not persisted.
1170
1271
 
1171
1272
  Canonical list-page pattern:
1172
1273
 
@@ -1632,18 +1733,31 @@ function onRowRemove(event: { data: Product; index: number; cancel: () => void }
1632
1733
  | `searchPlaceholder` | `string` | `"Search..."` | Placeholder text. |
1633
1734
  | `searchDebounce` | `number` | `300` | Debounce delay in ms. |
1634
1735
 
1736
+ ### Opt-in Search Bar
1737
+
1738
+ These props apply only with `searchBar`.
1739
+
1740
+ | Prop | Type | Default | Description |
1741
+ | ------------------ | ---------------------------------------- | ---------- | ----------------------------------------------------------------------------------- |
1742
+ | `searchBar` | `boolean` | `false` | Show `VcSearchBar` instead of the classic search header. |
1743
+ | `searchBarVariant` | `"inline" \| "summary"` | `"inline"` | Wide bar: chips in the row, or the applied field names on the Filters button. |
1744
+ | `searchViews` | `SearchBarView[]` | -- | Views from code; one may be the `default`. |
1745
+ | `searchName` | `string` | -- | Bar name for external filters. Defaults to the blade's name. |
1746
+ | `filterCounts` | `Record<string, Record<string, number>>` | -- | Result count per option value, per filter id. |
1747
+ | `unfilteredCount` | `number` | -- | Rows without the bar's filters and search; the footer status reads "filtered from". |
1748
+
1635
1749
  ### Filters
1636
1750
 
1637
- | Prop | Type | Default | Description |
1638
- | --------------- | ---------------------- | ------- | ---------------------------------- |
1639
- | `globalFilters` | `GlobalFilterConfig[]` | -- | Global filter panel configuration. |
1751
+ | Prop | Type | Default | Description |
1752
+ | --------------- | ---------------------- | ------- | ---------------------------------------------------------------- |
1753
+ | `globalFilters` | `GlobalFilterConfig[]` | -- | Global filter panel configuration (bar fields with `searchBar`). |
1640
1754
 
1641
1755
  ### State Persistence
1642
1756
 
1643
- | Prop | Type | Default | Description |
1644
- | -------------- | ---------------------- | --------- | ------------------------------------------------------ |
1645
- | `stateKey` | `string` | -- | Key for persisting state. Omit to disable persistence. |
1646
- | `stateStorage` | `"local" \| "session"` | `"local"` | Storage backend. |
1757
+ | Prop | Type | Default | Description |
1758
+ | -------------- | ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
1759
+ | `stateKey` | `string` | -- | Key for persisting state; with `searchBar` also the key of saved views and URL filters. Omit to disable persistence. |
1760
+ | `stateStorage` | `"local" \| "session"` | `"local"` | Storage backend. |
1647
1761
 
1648
1762
  ### Empty States
1649
1763
 
@@ -1751,20 +1865,20 @@ function onRowRemove(event: { data: Product; index: number; cancel: () => void }
1751
1865
 
1752
1866
  ## VcDataTable Slots Reference
1753
1867
 
1754
- | Slot | Props | Description |
1755
- | ----------------------- | --------------------------------------------------------------- | ------------------------------------------------------------ |
1756
- | `default` | -- | VcColumn declarations (required). |
1757
- | `header` | -- | Custom header content above the table. |
1758
- | `footer` | -- | Custom footer content below the table body. |
1759
- | `search-header-actions` | -- | Extra buttons in the search toolbar (beside filter icon). |
1760
- | `selection-banner` | `{ count, totalCount, isSelectAll, selectAll, clearSelection }` | Custom selection banner. |
1761
- | `expansion` | `{ data: T, index: number }` | Content rendered below an expanded row (desktop and mobile). |
1762
- | `empty` | -- | Custom empty state (no items, no search). |
1763
- | `not-found` | -- | Custom not-found state (no items + active search/filters). |
1764
- | `loading` | -- | Custom loading state. |
1765
- | `groupheader` | `{ data: T, index: number }` | Custom row group header. |
1766
- | `groupfooter` | `{ data: T, index: number }` | Custom row group footer. |
1767
- | `pagination` | `{ pages, currentPage, onPageClick }` | Custom pagination replacing built-in VcPagination. |
1868
+ | Slot | Props | Description |
1869
+ | ----------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
1870
+ | `default` | -- | VcColumn declarations (required). |
1871
+ | `header` | -- | Custom header content above the table. |
1872
+ | `footer` | -- | Custom footer content below the table body. |
1873
+ | `search-header-actions` | `SearchBarSlotProps` with `searchBar`, else -- | Extra buttons in the search toolbar (beside filter icon); at the end of the bar's row with `searchBar`. |
1874
+ | `selection-banner` | `{ count, totalCount, isSelectAll, selectAll, clearSelection }` | Custom selection banner. |
1875
+ | `expansion` | `{ data: T, index: number }` | Content rendered below an expanded row (desktop and mobile). |
1876
+ | `empty` | -- | Custom empty state (no items, no search). |
1877
+ | `not-found` | `SearchBarNotFoundSlotProps` with `searchBar`, else -- | Custom not-found state (no items + active search/filters). |
1878
+ | `loading` | -- | Custom loading state. |
1879
+ | `groupheader` | `{ data: T, index: number }` | Custom row group header. |
1880
+ | `groupfooter` | `{ data: T, index: number }` | Custom row group footer. |
1881
+ | `pagination` | `{ pages, currentPage, onPageClick }` | Custom pagination replacing built-in VcPagination. |
1768
1882
 
1769
1883
  ---
1770
1884
 
@@ -0,0 +1,284 @@
1
+ ---
2
+ title: VcSearchBar
3
+ category: components
4
+ group: data-display
5
+ ---
6
+
7
+ # VcSearchBar
8
+
9
+ Search, applied filters and saved views for a list screen, in one row. It holds the filter state and reports it as plain filter values. `VcDataTable` renders it when you set `search-bar`; it also works on its own.
10
+
11
+ ::storybook id="data-display-vcsearchbar--wide-blade"
12
+
13
+ ## When to Use
14
+
15
+ - Use **VcSearchBar** for a list screen with a search and a few filters that users combine and save as views.
16
+ - Use it standalone when the data is not a table (cards, a gallery, a tree).
17
+ - When NOT to use: for a single text box with no filters, use `VcInput`; for a filter inside one table column, use `VcColumn` `filter`.
18
+
19
+ ## Three Ways to Use It
20
+
21
+ ### 1. On a table: `search-bar`
22
+
23
+ Set `search-bar` on `VcDataTable` next to `searchable` and `global-filters`. The table renders the bar instead of its classic search header and forwards `@search` and `@filter` as before. Without `search-bar` the table keeps the classic header. See [VcDataTable](../vc-data-table), "Search bar (opt-in)".
24
+
25
+ ```vue
26
+ <VcDataTable :items="orders" state-key="orders-list" searchable search-bar :global-filters="orderFilters" :search-views="orderViews" @filter="onFilter" @search="onSearch" />
27
+ ```
28
+
29
+ ### 2. Your own bar in the `#header` slot
30
+
31
+ For full control over the state, leave `searchable` and `global-filters` off and put the bar into the table's `#header` slot. Load data from the bar's `v-model` or `@change`.
32
+
33
+ ```vue
34
+ <VcDataTable :items="orders" :loading="loading">
35
+ <template #header>
36
+ <VcSearchBar v-model="query" :fields="orderFields" :views="orderViews" storage-key="orders-list" @change="load" />
37
+ </template>
38
+ </VcDataTable>
39
+ ```
40
+
41
+ ### 3. Standalone
42
+
43
+ ```vue
44
+ <VcSearchBar v-model="query" :fields="fields" storage-key="orders" @change="load" />
45
+ ```
46
+
47
+ ## Layout
48
+
49
+ The bar is one row of 36px controls with its own 16px side and 8px top and bottom padding, so it needs no wrapper: the search, a divider, the applied filters as chips, then the split **Filters** button.
50
+
51
+ - **Search** takes the remaining width (at least 200px or 22% of the bar). It has a clear button when it holds text and a `/` hint when it is empty and unfocused.
52
+ - **Chips** read "Field: value" (several values: "First +1"), in the order the filters were applied. A click opens the field's editor in a popover; the × removes the filter. Toggle fields show just their name. Chips that do not fit go behind a **+N** button that opens the hidden fields as an accordion.
53
+ - **Filters** opens the [Filters panel](#filters-panel). With filters applied it shows the count and a × part that clears them all.
54
+ - The bar has no slots. Put your own buttons next to it, or use the table's `search-header-actions` slot.
55
+
56
+ The layout follows the bar's own width:
57
+
58
+ | Width | Layout |
59
+ | ----------- | ------------------------------------------------------------------------------------------------------------------- |
60
+ | 720px+ | Wide: chips in the row (`variant="inline"`), or the applied field names on the Filters button (`variant="summary"`) |
61
+ | 480-719px | Medium: no chips; the Filters button holds the count and the × that clears all |
62
+ | under 480px | Narrow: the Filters button is a funnel icon with a count badge; the search shows the short default placeholder |
63
+
64
+ ::storybook id="data-display-vcsearchbar--medium-blade"
65
+
66
+ ### Search syntax
67
+
68
+ - Typing `field:` suggests the field's values; `field:value` followed by a space becomes a chip when the value matches an option's value or label exactly (any case), or is the start of only one of them. A start shared by several options (`status:p` for Pending and Paid) stays text and keeps the suggestions open. The field name is the field's `key` (default: its `id`).
69
+ - A word of 2 or more letters suggests the fields it matches. ↑ and ↓ move through the suggestions, Enter picks one.
70
+ - An unknown field or value (`foo:bar`, `status:xyz`) stays search text.
71
+
72
+ ### Keyboard
73
+
74
+ - `/` focuses the search of the active blade (or of a bar outside blades) when no text field has focus.
75
+ - Backspace in an empty search removes the last chip.
76
+ - Esc closes the suggestions, then clears the text, then leaves the search. It never closes the blade.
77
+ - A chip's editor, "+N", the Filters panel and the views menu take the focus when they open; Tab stays inside them, Esc closes them and returns the focus to their button. ↑, ↓, Home and End move through the views menu.
78
+ - Removing a chip with its × moves the focus to the next chip, else to "+N", the Filters button or the search.
79
+
80
+ ## Filters Panel
81
+
82
+ On desktop the panel is a 360px popover aligned to the end of the Filters button. Everything in it applies at once.
83
+
84
+ - **Header:** "Filters · N active" and a close button.
85
+ - **Toggles:** toggle fields as switches, with a count when one is given.
86
+ - **Fields:** an accordion of the other fields, each with its value summary (or "Any") and a × when set. The first applied field starts open (or the first field when none is applied).
87
+ - **Editors:** a list field has checkboxes, a find box over 6 options, an "Only" link on hover and dimmed options with a zero count; a select with `operators: ["any", "not"]` adds "Is any of" and "Is not". A date field has "Any time", the relative ranges and a custom range. A number field has From and To (applied on Enter or with Apply) and optional presets. A custom field shows your component.
88
+ - **Unsaved row:** while the filters differ from the current view, a row above the footer offers revert, "Save" (not for "All") and "Save as view…".
89
+ - **Footer:** "N results · applied instantly" (with `result-count`) and **Clear filters**.
90
+
91
+ ::storybook id="data-display-vcsearchbar--filters-panel"
92
+
93
+ ## Saved Views
94
+
95
+ A view is a named set of filter values. The search text is not part of a view and never makes it modified.
96
+
97
+ - **All** is the system view: no filters. It always exists and cannot be changed.
98
+ - **Module views** come from the `views` prop and from [external registrations](#external-filters-and-views). One may be the `default`: the bar opens on it when the URL names no view and the bar starts with no values.
99
+ - **User views** are saved with "Save as new view…" and kept per browser in `localStorage` under `VC_SEARCHBAR_<KEY>` (the `storage-key` upper-cased). Each has a "⋯" menu with Rename and Delete; deleting the current one selects "All".
100
+
101
+ ```ts
102
+ const orderViews: SearchBarView[] = [
103
+ { id: "open", name: "Open orders", values: { status: ["New", "Processing"] }, default: true },
104
+ { id: "paid", name: "Paid", values: { status: ["Paid"] } },
105
+ ];
106
+ ```
107
+
108
+ Selecting a view replaces the filters. Any other change keeps the current view and marks it **Modified**; changing it back (in any order) clears the mark. The selector never switches to another view on its own because the filters happen to match it, with one exception: removing the last filter of a view selects "All", as Clear all does.
109
+
110
+ While modified, the view menu offers "Save changes to “X”" (not for "All"; for a module view it stores the change in this browser), "Save as new view…" and "Revert to “X”".
111
+
112
+ ### Where the selector is
113
+
114
+ - **In a blade:** next to the blade title: a bookmark, the view name, a "Modified" badge and a chevron. The bar registers it with the blade; the screen adds nothing. With two bars in one blade the first one gets the header and the other shows the selector in its own row.
115
+ - **Outside a blade:** at the start of the bar's row.
116
+ - **On a phone:** the views are chips at the top of the filters sheet; the current one is filled and marked `*` when modified.
117
+
118
+ `view-counts` adds a count per view to the menu.
119
+
120
+ ::storybook id="data-display-vcsearchbar--modified-view"
121
+
122
+ ## Props
123
+
124
+ | Prop | Type | Default | Description |
125
+ | ----------------- | ---------------------------------------- | ---------- | ------------------------------------------------------------------------------------- |
126
+ | `modelValue` | `SearchBarState` | - | `{ search, values }`. Optional: without it the bar keeps its own state |
127
+ | `fields` | `SearchBarField[]` | `[]` | Filters offered by this screen |
128
+ | `views` | `SearchBarView[]` | - | Module views; one may be the `default` |
129
+ | `storageKey` | `string` | - | Key of the user views and of the filters and view in the blade URL |
130
+ | `variant` | `"inline" \| "summary"` | `"inline"` | Wide bar: chips in the row, or the applied field names on the Filters button |
131
+ | `counts` | `Record<string, Record<string, number>>` | - | Result count per option value, per field id (`{ status: { Paid: 12 } }`) |
132
+ | `viewCounts` | `Record<string, number>` | - | Result count per view id, shown in the view menu |
133
+ | `resultCount` | `number` | - | Result count of the current filters: the panel footer and "Show N results" |
134
+ | `unfilteredCount` | `number` | - | Rows without the bar's filters and search: "filtered from M" in the phone summary |
135
+ | `placeholder` | `string` | - | Search placeholder and accessible name; a narrow bar shows the short default instead |
136
+ | `searchDebounce` | `number` | `300` | Delay in ms before the typed text reaches the state, `change` and `search` |
137
+ | `name` | `string` | - | Target of external filters and views; defaults to the name of the blade the bar is in |
138
+ | `searchable` | `boolean` | `true` | Show the search input |
139
+ | `disabled` | `boolean` | `false` | Disable the bar |
140
+
141
+ ## Events
142
+
143
+ | Event | Payload | Description |
144
+ | ------------------- | ----------------- | ------------------------------------------------------------------------------------------------------ |
145
+ | `update:modelValue` | `SearchBarState` | Any change of search text or values |
146
+ | `change` | `SearchBarChange` | `{ search, filters, state }`. One per user action; the debounced text counts too |
147
+ | `update:search` | `string` | Every keystroke, undebounced |
148
+ | `search` | `string` | The debounced search text |
149
+ | `update:mode` | `SearchBarMode` | The bar's width mode (`wide`, `medium`, `narrow`), or `phone` on a phone; at mount and on every change |
150
+
151
+ `change.filters` holds the filters as plain values keyed by field, with relative dates resolved.
152
+
153
+ ## Fields
154
+
155
+ A field is `{ id, label, filter, key?, operators? }`. `filter` selects the kind; the existing `ColumnFilterConfig` shapes keep working.
156
+
157
+ | Kind | `filter` | Value in `state.values[id]` |
158
+ | ---------- | ---------------------------------------- | -------------------------------------------------------------- |
159
+ | Text | `true` or `"field"` | `string` |
160
+ | Select | `{ options, multiple? }` | `string`, `string[]`, or `NotValue` when `operators` has `not` |
161
+ | Date range | `{ range: [startField, endField] }` | `{ start?, end? }` or a `RelativeDate` |
162
+ | Toggle | `{ toggle: true }` | `boolean` |
163
+ | Number | `{ number: true, min?, max?, presets? }` | `NumberValue` |
164
+ | Custom | `{ component, label, parse? }` | whatever your component emits |
165
+
166
+ Value shapes added by the bar:
167
+
168
+ ```ts
169
+ type NumberValue = { op: "gte" | "lte" | "eq" | "between"; min?: number; max?: number };
170
+ type NotValue = { not: string[] };
171
+ type RelativeDate = { relative: "today" | "7d" | "30d" };
172
+ ```
173
+
174
+ - `NumberValue`: `gte` and `eq` carry `min`, `lte` carries `max`, `between` carries both. The editor writes `gte`, `lte` or `between`; `eq` comes only from code or a link.
175
+ - `NotValue`: the chip reads "Field: not Value".
176
+ - `RelativeDate`: the date editor's relative ranges. The bar resolves it to concrete dates in `change.filters`.
177
+ - `key` is the field name in the search syntax (default: `id`).
178
+ - `FilterOption.count` shows a count next to the option; the `counts` prop overrides it per state.
179
+
180
+ ### Custom editors
181
+
182
+ A custom field gives a component and a label function. The component receives `modelValue` and emits `update:modelValue`. `label(value)` is the text on the chip after `Name:`.
183
+
184
+ A value read back from the URL or from a saved view is untrusted input. Give `parse(raw)` to check it: `raw` is the JSON-parsed value, return the value to apply or `undefined` to drop it (a throw drops it too). Without `parse` the bar accepts only a primitive, an array of primitives or a plain object whose entries are those, and drops anything with a `__proto__`, `constructor` or `prototype` key.
185
+
186
+ ```ts
187
+ const fields: SearchBarField[] = [
188
+ {
189
+ id: "rating",
190
+ label: "Rating",
191
+ filter: {
192
+ component: StarsEditor,
193
+ label: (v) => `${v}+ stars`,
194
+ parse: (raw) => (typeof raw === "number" && raw >= 1 && raw <= 5 ? raw : undefined),
195
+ },
196
+ },
197
+ ];
198
+ ```
199
+
200
+ ## Search text and `v-model`
201
+
202
+ `v-model` carries the whole state, search text included; `state.search` follows the input after `search-debounce`. A filter changed while the text waits for that pause takes the text with it: `search` fires first, then one `change` carries both.
203
+
204
+ When the parent writes `v-model`, the bar updates its state, the input and the URL but emits neither `change` nor `search`: the parent that wrote the value loads the data itself. A write while the typed text waits for its pause drops that text. The table drives its bar this way (Clear all, the empty state's actions). The search text is never part of a view or of the remembered filters.
205
+
206
+ ## Filters and the View in the URL
207
+
208
+ Inside a blade that has a URL, the applied filters go to the URL query under `<storage-key>_filters` and the current view under `<storage-key>_view`, next to the table's `_sort`, `_search` and `_page`. A link to the screen opens it with the same filters and view, and a reload keeps them.
209
+
210
+ - On mount, the values of `v-model` come first, then the URL's, then the default view. A `v-model` with a search and no values keeps its search and takes the URL's values. Values the bar starts with win over the default view: it is not applied, and the view reads as "All", modified, unless the URL names a view.
211
+ - A link that names a view but has no filters (`orders_view=overdue` from a dashboard) opens the view with its values. A view registered after mount applies when it arrives, unless a filter was set meanwhile.
212
+ - If filters were restored (or a view applied), the bar emits `update:modelValue` and `change` once so the data can be loaded; it emits nothing when there is nothing to apply.
213
+ - Every applied change rewrites the value; with nothing applied the parameter is removed. The current view is always written, "All" as `_view=all`; a link without `_view` opens the default view.
214
+ - A view id that no longer exists (a deleted user view) shows as "All", modified while its filters apply; the filters still apply.
215
+ - A blade without a URL, a bar outside a blade, or a bar without `storage-key` remembers nothing.
216
+
217
+ The value is short and readable: fields are separated by `;`, each one is `id:value`.
218
+
219
+ | Value | Example |
220
+ | -------------------- | ------------------------------------------------------------ |
221
+ | Select, multi-select | `status:Paid,New` |
222
+ | Excluded values | `!status:Paid` |
223
+ | Relative date | `created:7d` (also `today`, `30d`) |
224
+ | Date range | `created:2026-01-01..2026-01-31`, `created:2026-01-01..` |
225
+ | Toggle | `overdue:1` |
226
+ | Number | `total:>=100`, `total:<=100`, `total:=100`, `total:100..200` |
227
+ | Text | `name:Acme` |
228
+ | Custom editor | the value as JSON |
229
+
230
+ Relative dates stay relative: a link with `created:7d` opened next week shows that week's last 7 days. A `;`, `,`, `:` or `\` inside a value is escaped with `\`. Malformed parts are skipped. A part for a field the bar does not have yet stays in the URL and applies when the field appears. A field that goes away (an external registration removed) leaves `change.filters`, but its part stays in the URL and its value comes back with the field.
231
+
232
+ ## On a Phone
233
+
234
+ - The bar is the search and a 36px Filters icon button with a count badge. A summary line under it reads "N results · View\* · filtered from M · K filters · Clear all" ("N items" when nothing is filtered). The view shows when it is not the system view or when its values were changed ("All\*"). The search has no `/` hint.
235
+ - The Filters button opens a bottom sheet: "Clear" on the left, "Filters" with the count, "Done" on the right; the views as chips with the unsaved row; the same fields as the desktop panel with larger rows; and a full-width "Show N results" button ("No matching results" at 0).
236
+ - A chip editor and the view menu are not used on a phone; everything goes through the sheet.
237
+
238
+ ::storybook id="data-display-vcsearchbar--phone-filters-sheet"
239
+
240
+ ## External Filters and Views
241
+
242
+ Modules add fields and views to another module's screen:
243
+
244
+ ```ts
245
+ import { registerExternalSearchFilters, unregisterExternalSearchFilters } from "@vc-shell/framework";
246
+
247
+ registerExternalSearchFilters({
248
+ id: "reviews-rating",
249
+ targetBlades: ["orders"],
250
+ priority: 100,
251
+ fields: [{ id: "rating", label: "Rating", filter: { number: true } }],
252
+ views: [{ id: "top-rated", name: "Top rated", values: { rating: { op: "gte", min: 4 } } }],
253
+ });
254
+
255
+ unregisterExternalSearchFilters("reviews-rating");
256
+ ```
257
+
258
+ - `targetBlades` lists blade names, compared case-insensitively. A bar answers to the name of the blade it sits in.
259
+ - Set the `name` prop to address a bar by another name: a bar outside a blade, or two bars in one blade. On `VcDataTable` the same prop is `search-name`.
260
+ - Contributed fields and views come after the screen's own, ordered by `priority` (lower first, default 100). Registering an existing `id` replaces it. The registry is reactive: a module that loads after the blade opened still reaches it.
261
+ - A field that registers late (a contributed one, or `fields` loaded after mount) still gets its value from the URL: that part of the URL is kept until the field arrives, then applies as one `change`.
262
+
263
+ ## Known Limitations
264
+
265
+ - User views keep object and array values by reference: treat view values as immutable. Custom values must be cloneable to be saved in a view.
266
+ - Two bars with the same `storage-key` on one page keep separate caches and can overwrite each other.
267
+ - Views use `localStorage` even when `VcDataTable` has `state-storage="session"`.
268
+ - Back and forward navigation inside an open blade does not update the bar: the URL is read when the bar mounts.
269
+ - In the table, the restored `@filter` is sent before the screen's own `onMounted`. A screen whose `onMounted` load builds its query from scratch, ignoring what `@filter` set, still sends an unfiltered request after the filtered one: keep the filters in the query that load reads.
270
+ - The date editor's relative ranges have no arrow-key navigation.
271
+ - A click on a button in Safari does not focus it, so focus is not returned to it after a popover closes.
272
+
273
+ ## Common Mistakes
274
+
275
+ - Putting a `VcSearchBar` into `#header` and also setting `search-bar` on the table: the table renders its own bar as well. Use one.
276
+ - Expecting user views or URL filters without `storage-key`: views live in memory and nothing goes to the URL. `VcDataTable` with `search-bar` and no `state-key` warns about it in development.
277
+ - Passing `v-model` with values and expecting the default view: values the bar starts with win.
278
+ - Targeting external filters with a module name instead of the blade name.
279
+
280
+ ## Related Components
281
+
282
+ - [VcDataTable](../vc-data-table): renders this bar with `search-bar`.
283
+ - [VcBlade](../vc-blade): shows the view selector next to its title.
284
+ - [VcInput](../../molecules/vc-input): a plain text input.
@@ -50,34 +50,35 @@ const open = ref(false);
50
50
 
51
51
  ## Props
52
52
 
53
- | Prop | Type | Default | Description |
54
- | ---------------- | -------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------- |
55
- | `modelValue` | `boolean` | _required_ | Open/close state (v-model). |
56
- | `position` | `"left" \| "right" \| "bottom"` | `"right"` | Slide-in direction. |
57
- | `size` | `"sm" \| "md" \| "lg" \| "full"` | `"sm"` | Panel size preset. Width (left/right) 300/380/520px/100vw; height (bottom) 40/56/72/100dvh. |
58
- | `variant` | `"default" \| "elevated" \| "minimal"` | `"default"` | Visual style. |
59
- | `width` | `number \| string` | -- | Custom width override (left/right positions). |
60
- | `height` | `number \| string` | -- | Custom height override (bottom position). |
61
- | `title` | `string` | `""` | Header title text. |
62
- | `subtitle` | `string` | `""` | Header subtitle text. |
63
- | `showOverlay` | `boolean` | `true` | Show backdrop overlay. |
64
- | `closeOnOverlay` | `boolean` | `true` | Close when clicking overlay. |
65
- | `closeOnEscape` | `boolean` | `true` | Close on Escape key. |
66
- | `closeButton` | `boolean` | `true` | Show close button in header. |
67
- | `trapFocus` | `boolean` | `true` | Trap keyboard focus inside panel. |
68
- | `lockScroll` | `boolean` | `true` | Prevent body scroll while open. |
69
- | `inset` | `boolean` | `true` | Add rounded inset gap from viewport edges. |
70
- | `returnFocus` | `boolean` | `true` | Restore focus to the trigger element on close. |
71
- | `autoFocus` | `boolean` | `true` | Focus the first focusable element on open. |
72
- | `teleport` | `boolean` | `true` | Teleport the panel to a target (disabled toggles it off). |
73
- | `teleportTo` | `string \| HTMLElement` | -- | Teleport target selector or element. |
74
- | `ariaLabel` | `string` | `""` | Accessible label for the dialog. |
75
- | `closeAriaLabel` | `string` | `"Close sidebar"` | Accessible label for the close button. |
76
- | `zIndex` | `number` | `9200` | Stacking order of the sidebar container. |
77
- | `closeThreshold` | `number` | `0.3` | Swipe fraction of panel height needed to dismiss (bottom). |
78
- | `draggable` | `boolean` | `false` | Enable swipe-to-dismiss (bottom only). |
79
- | `dragHandle` | `boolean` | `false` | Show iOS-style drag handle bar. |
80
- | `forceMount` | `boolean` | `false` | Keep the panel content mounted (hidden, inert) while closed. |
53
+ | Prop | Type | Default | Description |
54
+ | ---------------- | -------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------- |
55
+ | `modelValue` | `boolean` | _required_ | Open/close state (v-model). |
56
+ | `position` | `"left" \| "right" \| "bottom"` | `"right"` | Slide-in direction. |
57
+ | `size` | `"sm" \| "md" \| "lg" \| "full"` | `"sm"` | Panel size preset. Width (left/right) 300/380/520px/100vw; height (bottom) 40/56/72/100dvh. |
58
+ | `variant` | `"default" \| "elevated" \| "minimal"` | `"default"` | Visual style. |
59
+ | `width` | `number \| string` | -- | Custom width override (left/right positions). |
60
+ | `height` | `number \| string` | -- | Custom height override (bottom position). |
61
+ | `title` | `string` | `""` | Header title text. |
62
+ | `subtitle` | `string` | `""` | Header subtitle text. |
63
+ | `showOverlay` | `boolean` | `true` | Show backdrop overlay. |
64
+ | `closeOnOverlay` | `boolean` | `true` | Close when clicking overlay. |
65
+ | `closeOnEscape` | `boolean` | `true` | Close on Escape key. |
66
+ | `closeButton` | `boolean` | `true` | Show close button in header. |
67
+ | `trapFocus` | `boolean` | `true` | Trap keyboard focus inside panel. |
68
+ | `lockScroll` | `boolean` | `true` | Prevent body scroll while open. |
69
+ | `inset` | `boolean` | `true` | Add rounded inset gap from viewport edges. |
70
+ | `returnFocus` | `boolean` | `true` | Restore focus to the trigger element on close. |
71
+ | `autoFocus` | `boolean` | `true` | Focus the first focusable element on open. |
72
+ | `teleport` | `boolean` | `true` | Teleport the panel to a target (disabled toggles it off). |
73
+ | `teleportTo` | `string \| HTMLElement` | -- | Teleport target selector or element. |
74
+ | `ariaLabel` | `string` | `""` | Accessible label for the dialog. |
75
+ | `closeAriaLabel` | `string` | `"Close sidebar"` | Accessible label for the close button. |
76
+ | `zIndex` | `number` | `9200` | Stacking order of the sidebar container. |
77
+ | `closeThreshold` | `number` | `0.3` | Swipe fraction of panel height needed to dismiss (bottom). |
78
+ | `draggable` | `boolean` | `false` | Enable swipe-to-dismiss (bottom only). |
79
+ | `dragHandle` | `boolean` | `false` | Show iOS-style drag handle bar. |
80
+ | `forceMount` | `boolean` | `false` | Keep the panel content mounted (hidden, inert) while closed. |
81
+ | `panelClass` | `string` | -- | Extra class on the teleported root (`.vc-sidebar`, which holds the overlay and the panel), to style one sidebar. |
81
82
 
82
83
  ## Events
83
84
 
@@ -244,6 +245,23 @@ function resetFilters() {
244
245
  - The `minimal` variant removes the header background and border, useful for lightweight panels that blend into the content.
245
246
  - Use the `header` slot to completely replace the default header when you need a custom layout (e.g., tabs in the header, search input, breadcrumbs).
246
247
 
248
+ ## CSS Custom Properties
249
+
250
+ Set them on the sidebar's root (`panelClass` puts a class there) to style one sidebar.
251
+
252
+ | Property | Default | Description |
253
+ | ----------------------------------- | ---------------------- | --------------------------------------------------------- |
254
+ | `--vc-sidebar-bg-color` | `var(--additional-50)` | Panel background |
255
+ | `--vc-sidebar-overlay-color` | `var(--overlay-bg)` | Overlay behind the panel |
256
+ | `--vc-sidebar-shadow` | `var(--shadow-md)` | Panel shadow |
257
+ | `--vc-sidebar-radius` | `16px` | Corner radius of an elevated or bottom panel |
258
+ | `--vc-sidebar-inset-gap` | `12px` | Gap around an elevated panel |
259
+ | `--vc-sidebar-bottom-max-height` | `96dvh` | Maximum height of a bottom sheet |
260
+ | `--vc-sidebar-bottom-duration` | `0.32s` | Slide duration of a bottom sheet |
261
+ | `--vc-sidebar-handle-padding-block` | `12px` | Space above and below the drag handle (one or two values) |
262
+ | `--vc-sidebar-handle-width` | `100px` | Width of the drag handle bar |
263
+ | `--vc-sidebar-handle-height` | `6px` | Height of the drag handle bar |
264
+
247
265
  ## Accessibility
248
266
 
249
267
  - Uses `role="dialog"` with `aria-modal` when overlay is shown.