@kubex/zinc 1.0.25 → 1.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/project.md +556 -0
- package/.github/workflows/js_build_and_deploy.yaml +9 -10
- package/dist/custom-elements.json +13575 -8856
- package/dist/vscode.html-custom-data.json +583 -48
- package/dist/web-types.json +1441 -181
- package/dist/zn.d.ts +1645 -660
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1412 -893
- package/docs/_utilities/code-previews.cjs +10 -1
- package/docs/assets/scripts/docs.js +42 -18
- package/docs/data/data-table.json +229 -66
- package/docs/data/empty.json +6 -0
- package/docs/data/products-table.json +41 -193
- package/docs/pages/components/action-bar.md +121 -6
- package/docs/pages/components/alert.md +118 -15
- package/docs/pages/components/animated-button.md +299 -0
- package/docs/pages/components/audio-select.md +534 -0
- package/docs/pages/components/bulk-actions.md +79 -5
- package/docs/pages/components/button-group.md +235 -27
- package/docs/pages/components/button.md +139 -1
- package/docs/pages/components/chart.md +365 -9
- package/docs/pages/components/checkbox.md +387 -58
- package/docs/pages/components/chip.md +253 -33
- package/docs/pages/components/collapsible.md +393 -46
- package/docs/pages/components/cols.md +152 -30
- package/docs/pages/components/confirm.md +182 -16
- package/docs/pages/components/copy-button.md +169 -6
- package/docs/pages/components/data-select.md +194 -15
- package/docs/pages/components/data-table-filter.md +96 -5
- package/docs/pages/components/data-table-search.md +451 -0
- package/docs/pages/components/data-table-sort.md +66 -5
- package/docs/pages/components/data-table.md +727 -66
- package/docs/pages/components/datepicker.md +402 -7
- package/docs/pages/components/defined-label.md +120 -5
- package/docs/pages/components/dialog.md +339 -59
- package/docs/pages/components/dropdown.md +366 -11
- package/docs/pages/components/editor.md +604 -7
- package/docs/pages/components/empty-state.md +315 -16
- package/docs/pages/components/expanding-action.md +212 -28
- package/docs/pages/components/file.md +421 -12
- package/docs/pages/components/filter-container.md +158 -5
- package/docs/pages/components/filter-wrapper.md +167 -6
- package/docs/pages/components/form-group.md +383 -6
- package/docs/pages/components/hover-container.md +237 -6
- package/docs/pages/components/icon-picker.md +121 -0
- package/docs/pages/components/icon.md +454 -48
- package/docs/pages/components/inline-edit.md +787 -19
- package/docs/pages/components/input-group.md +207 -13
- package/docs/pages/components/input.md +194 -0
- package/docs/pages/components/item.md +18 -0
- package/docs/pages/components/key-container.md +115 -0
- package/docs/pages/components/key.md +101 -0
- package/docs/pages/components/menu.md +512 -6
- package/docs/pages/components/note.md +239 -36
- package/docs/pages/components/opt-group.md +107 -0
- package/docs/pages/components/pagination.md +332 -6
- package/docs/pages/components/pane.md +222 -6
- package/docs/pages/components/panel.md +213 -26
- package/docs/pages/components/popup.md +1354 -6
- package/docs/pages/components/priority-list.md +233 -0
- package/docs/pages/components/progress-bar.md +387 -6
- package/docs/pages/components/radio-group.md +242 -5
- package/docs/pages/components/radio.md +474 -6
- package/docs/pages/components/rating.md +331 -7
- package/docs/pages/components/reveal.md +524 -6
- package/docs/pages/components/scroll-container.md +552 -6
- package/docs/pages/components/select.md +762 -160
- package/docs/pages/components/skeleton.md +473 -30
- package/docs/pages/components/slideout.md +261 -5
- package/docs/pages/components/sp.md +99 -41
- package/docs/pages/components/split-button.md +347 -9
- package/docs/pages/components/split-pane.md +445 -6
- package/docs/pages/components/stat.md +549 -9
- package/docs/pages/components/status-indicator.md +230 -1
- package/docs/pages/components/stepper.md +563 -6
- package/docs/pages/components/tabs.md +439 -13
- package/docs/pages/components/textarea.md +415 -17
- package/docs/pages/components/tile.md +385 -26
- package/docs/pages/components/toggle.md +424 -6
- package/docs/pages/components/tooltip.md +367 -0
- package/docs/pages/components/translation-group.md +210 -0
- package/docs/pages/components/translations.md +319 -19
- package/docs/pages/components/vertical-stepper.md +401 -8
- package/docs/pages/components/well.md +300 -3
- package/docs/pages/getting-started/form-controls.md +162 -0
- package/docs/pages/index.md +116 -15
- package/package.json +5 -6
- package/scss/_global-spacing.scss +4 -0
- package/scss/_root.scss +2 -2
- package/scss/boot.scss +19 -0
- package/scss/shared/layout.scss +5 -0
- package/scss/themes/_light.scss +3 -3
- package/src/components/alert/alert.scss +1 -0
- package/src/components/animated-button/README.md +306 -0
- package/src/components/animated-button/animated-button.component.ts +229 -0
- package/src/components/animated-button/animated-button.scss +228 -0
- package/src/components/animated-button/animated-button.test.ts +143 -0
- package/src/components/animated-button/index.ts +12 -0
- package/src/components/button/button.component.ts +5 -0
- package/src/components/button-group/button-group.component.ts +25 -13
- package/src/components/button-group/button-group.scss +6 -0
- package/src/components/checkbox/checkbox.component.ts +4 -0
- package/src/components/checkbox/checkbox.scss +7 -4
- package/src/components/checkbox-group/checkbox-group.scss +7 -0
- package/src/components/chip/chip.component.ts +7 -2
- package/src/components/chip/chip.scss +16 -2
- package/src/components/collapsible/collapsible.component.ts +27 -20
- package/src/components/cols/cols.component.ts +14 -2
- package/src/components/cols/cols.scss +6 -12
- package/src/components/confirm/confirm.component.ts +7 -0
- package/src/components/copy-button/copy-button.component.ts +12 -11
- package/src/components/data-select/data-select.component.ts +215 -44
- package/src/components/data-select/data-select.scss +66 -6
- package/src/components/data-select/providers/currency-data-provider.ts +20 -6
- package/src/components/data-select/providers/provider.ts +1 -0
- package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
- package/src/components/data-table/data-table.component.ts +81 -22
- package/src/components/data-table-search/data-table-search.component.ts +184 -0
- package/src/components/data-table-search/data-table-search.scss +17 -0
- package/src/components/data-table-search/data-table-search.test.ts +11 -0
- package/src/components/data-table-search/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +347 -13
- package/src/components/dialog/dialog.component.ts +1 -1
- package/src/components/empty-state/empty-state.scss +6 -1
- package/src/components/header/header.scss +3 -3
- package/src/components/icon/icon.component.ts +23 -1
- package/src/components/icon/icon.scss +23 -0
- package/src/components/icon-picker/brand-icons.ts +24 -0
- package/src/components/icon-picker/icon-picker.component.ts +407 -0
- package/src/components/icon-picker/icon-picker.scss +205 -0
- package/src/components/icon-picker/index.ts +12 -0
- package/src/components/icon-picker/line-icons.ts +612 -0
- package/src/components/icon-picker/material-icons.ts +14543 -0
- package/src/components/inline-edit/inline-edit.component.ts +190 -46
- package/src/components/inline-edit/inline-edit.scss +29 -0
- package/src/components/inline-edit/inline-edit.test.ts +314 -1
- package/src/components/input/input.component.ts +324 -5
- package/src/components/input/input.scss +87 -0
- package/src/components/input-group/input-group.component.ts +28 -7
- package/src/components/input-group/input-group.scss +48 -10
- package/src/components/item/item.component.ts +24 -3
- package/src/components/item/item.scss +18 -0
- package/src/components/key/index.ts +12 -0
- package/src/components/key/key.component.ts +47 -0
- package/src/components/key/key.scss +38 -0
- package/src/components/key-container/index.ts +12 -0
- package/src/components/key-container/key-container.component.ts +142 -0
- package/src/components/key-container/key-container.scss +33 -0
- package/src/components/menu-item/menu-item.component.ts +20 -0
- package/src/components/menu-item/menu-item.scss +69 -2
- package/src/components/navbar/navbar.component.ts +103 -11
- package/src/components/navbar/navbar.scss +6 -1
- package/src/components/opt-group/index.ts +12 -0
- package/src/components/opt-group/opt-group.component.ts +74 -0
- package/src/components/opt-group/opt-group.scss +37 -0
- package/src/components/opt-group/opt-group.test.ts +27 -0
- package/src/components/option/option.component.ts +1 -16
- package/src/components/option/option.scss +4 -0
- package/src/components/panel/panel.component.ts +10 -8
- package/src/components/panel/panel.scss +20 -0
- package/src/components/priority-list/index.ts +12 -0
- package/src/components/priority-list/priority-list.component.ts +611 -0
- package/src/components/priority-list/priority-list.scss +185 -0
- package/src/components/priority-list/priority-list.test.ts +139 -0
- package/src/components/progress-bar/progress-bar.component.ts +22 -16
- package/src/components/radio/radio.scss +10 -3
- package/src/components/select/select.component.ts +812 -72
- package/src/components/select/select.scss +108 -2
- package/src/components/select/select.test.ts +147 -2
- package/src/components/settings-container/settings-container.component.ts +44 -19
- package/src/components/settings-container/settings-container.scss +1 -1
- package/src/components/skeleton/skeleton.component.ts +6 -1
- package/src/components/slideout/slideout.scss +8 -3
- package/src/components/sp/sp.component.ts +3 -1
- package/src/components/sp/sp.scss +19 -0
- package/src/components/stepper/stepper.component.ts +16 -10
- package/src/components/textarea/textarea.scss +0 -4
- package/src/components/tile/tile.component.ts +12 -3
- package/src/components/tile/tile.scss +1 -1
- package/src/components/timer/timer.component.ts +15 -2
- package/src/components/toggle/toggle.component.ts +29 -26
- package/src/components/toggle/toggle.scss +13 -1
- package/src/components/translation-group/index.ts +12 -0
- package/src/components/translation-group/translation-group.component.ts +207 -0
- package/src/components/translation-group/translation-group.scss +8 -0
- package/src/components/translations/translations.component.ts +90 -44
- package/src/components/translations/translations.scss +4 -0
- package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
- package/src/events/events.ts +12 -7
- package/src/events/zn-language-change.ts +7 -0
- package/src/events/zn-purchase.ts +11 -0
- package/src/events/zn-redirect.ts +7 -0
- package/src/events/zn-reorder.ts +7 -0
- package/src/events/zn-search-change.ts +11 -0
- package/src/events/zn-submit.ts +1 -1
- package/src/form-control.scss +4 -0
- package/src/internal/form-navigation.ts +510 -0
- package/src/internal/form.ts +6 -0
- package/src/zinc.ts +91 -83
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
---
|
|
2
|
+
meta:
|
|
3
|
+
title: Data Table Search
|
|
4
|
+
description: A search component for data tables with debounced input and support for additional form controls.
|
|
5
|
+
layout: component
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Examples
|
|
9
|
+
|
|
10
|
+
### Basic Search
|
|
11
|
+
|
|
12
|
+
Use the `zn-data-table-search` component to provide search functionality for data tables. The component includes a search input with a search icon prefix and is clearable by default.
|
|
13
|
+
|
|
14
|
+
```html:preview
|
|
15
|
+
<zn-data-table-search></zn-data-table-search>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
:::tip
|
|
19
|
+
This component works with standard `<form>` elements and integrates seamlessly with data tables. The search input is debounced to prevent excessive event firing while the user types.
|
|
20
|
+
:::
|
|
21
|
+
|
|
22
|
+
### Custom Placeholder
|
|
23
|
+
|
|
24
|
+
Use the `placeholder` attribute to customize the input placeholder text.
|
|
25
|
+
|
|
26
|
+
```html:preview
|
|
27
|
+
<zn-data-table-search placeholder="Search products..."></zn-data-table-search>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Help Text
|
|
31
|
+
|
|
32
|
+
Add descriptive help text to guide users with the `help-text` attribute.
|
|
33
|
+
|
|
34
|
+
```html:preview
|
|
35
|
+
<zn-data-table-search
|
|
36
|
+
placeholder="Search users..."
|
|
37
|
+
help-text="Search by name, email, or user ID">
|
|
38
|
+
</zn-data-table-search>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Default Value
|
|
42
|
+
|
|
43
|
+
Set a default search value using the `value` attribute.
|
|
44
|
+
|
|
45
|
+
```html:preview
|
|
46
|
+
<zn-data-table-search value="example search" placeholder="Search..."></zn-data-table-search>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Custom Field Name
|
|
50
|
+
|
|
51
|
+
Use the `name` attribute to set a custom field name for form submission. The default name is "search".
|
|
52
|
+
|
|
53
|
+
```html:preview
|
|
54
|
+
<zn-data-table-search name="query" placeholder="Search..."></zn-data-table-search>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Debounce Delay
|
|
58
|
+
|
|
59
|
+
Control the debounce delay using the `debounce-delay` attribute. The default is 350 milliseconds.
|
|
60
|
+
|
|
61
|
+
```html:preview
|
|
62
|
+
<zn-data-table-search
|
|
63
|
+
debounce-delay="1000"
|
|
64
|
+
placeholder="Search..."
|
|
65
|
+
help-text="1 second debounce delay">
|
|
66
|
+
</zn-data-table-search>
|
|
67
|
+
<br />
|
|
68
|
+
<zn-data-table-search
|
|
69
|
+
debounce-delay="100"
|
|
70
|
+
placeholder="Search..."
|
|
71
|
+
help-text="100ms debounce delay (very responsive)">
|
|
72
|
+
</zn-data-table-search>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Search URI
|
|
76
|
+
|
|
77
|
+
Use the `search-uri` attribute to specify a URI for search operations. This will be included in the `zn-search-change` event detail.
|
|
78
|
+
|
|
79
|
+
```html:preview
|
|
80
|
+
<zn-data-table-search
|
|
81
|
+
search-uri="/api/products/search"
|
|
82
|
+
placeholder="Search products...">
|
|
83
|
+
</zn-data-table-search>
|
|
84
|
+
|
|
85
|
+
<script type="module">
|
|
86
|
+
const search = document.querySelector('zn-data-table-search');
|
|
87
|
+
|
|
88
|
+
await customElements.whenDefined('zn-data-table-search');
|
|
89
|
+
|
|
90
|
+
search.addEventListener('zn-search-change', (event) => {
|
|
91
|
+
console.log('Search URI:', event.detail.searchUri);
|
|
92
|
+
console.log('Search value:', event.detail.value);
|
|
93
|
+
});
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Listening to Search Events
|
|
98
|
+
|
|
99
|
+
The component emits a `zn-search-change` event when the search value changes (after the debounce delay). The event detail includes the search value, any additional form data from slotted inputs, and the search URI if provided.
|
|
100
|
+
|
|
101
|
+
```html:preview
|
|
102
|
+
<zn-data-table-search class="search-demo" placeholder="Type to search..."></zn-data-table-search>
|
|
103
|
+
|
|
104
|
+
<div class="search-results" style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: var(--zn-border-radius-medium);">
|
|
105
|
+
<strong>Search Results:</strong>
|
|
106
|
+
<div class="results-content">No search performed yet</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<script type="module">
|
|
110
|
+
const search = document.querySelector('.search-demo');
|
|
111
|
+
const resultsDiv = document.querySelector('.results-content');
|
|
112
|
+
|
|
113
|
+
await customElements.whenDefined('zn-data-table-search');
|
|
114
|
+
|
|
115
|
+
search.addEventListener('zn-search-change', (event) => {
|
|
116
|
+
const { value, formData, searchUri } = event.detail;
|
|
117
|
+
if (value) {
|
|
118
|
+
resultsDiv.textContent = `Searching for: "${value}"`;
|
|
119
|
+
} else {
|
|
120
|
+
resultsDiv.textContent = 'Search cleared';
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
</script>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Additional Form Controls
|
|
127
|
+
|
|
128
|
+
The component supports slotting additional form controls that will be included in the search event data. This is useful for adding filters or other search parameters.
|
|
129
|
+
|
|
130
|
+
```html:preview
|
|
131
|
+
<zn-data-table-search placeholder="Search...">
|
|
132
|
+
<zn-select name="category" value="all">
|
|
133
|
+
<zn-option value="all">All Categories</zn-option>
|
|
134
|
+
<zn-option value="electronics">Electronics</zn-option>
|
|
135
|
+
<zn-option value="books">Books</zn-option>
|
|
136
|
+
<zn-option value="clothing">Clothing</zn-option>
|
|
137
|
+
</zn-select>
|
|
138
|
+
|
|
139
|
+
<zn-select name="status" value="active">
|
|
140
|
+
<zn-option value="all">All Status</zn-option>
|
|
141
|
+
<zn-option value="active">Active</zn-option>
|
|
142
|
+
<zn-option value="inactive">Inactive</zn-option>
|
|
143
|
+
</zn-select>
|
|
144
|
+
</zn-data-table-search>
|
|
145
|
+
|
|
146
|
+
<div class="filter-results" style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: var(--zn-border-radius-medium);">
|
|
147
|
+
<strong>Search Parameters:</strong>
|
|
148
|
+
<pre class="filter-content" style="margin-top: 0.5rem; font-size: 0.875rem;">No search performed yet</pre>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<script type="module">
|
|
152
|
+
const filterSearch = document.querySelectorAll('zn-data-table-search')[document.querySelectorAll('zn-data-table-search').length - 1];
|
|
153
|
+
const filterResults = document.querySelector('.filter-content');
|
|
154
|
+
|
|
155
|
+
await customElements.whenDefined('zn-data-table-search');
|
|
156
|
+
|
|
157
|
+
filterSearch.addEventListener('zn-search-change', (event) => {
|
|
158
|
+
const { value, formData } = event.detail;
|
|
159
|
+
filterResults.textContent = JSON.stringify({
|
|
160
|
+
search: value,
|
|
161
|
+
...formData
|
|
162
|
+
}, null, 2);
|
|
163
|
+
});
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
:::tip
|
|
168
|
+
Slotted form controls are hidden from view but their values are collected and included in the `formData` property of the `zn-search-change` event. This allows you to manage additional search parameters without cluttering the UI.
|
|
169
|
+
:::
|
|
170
|
+
|
|
171
|
+
### Supported Slotted Input Types
|
|
172
|
+
|
|
173
|
+
The following input types are supported in the default slot and will have their values included in the form data:
|
|
174
|
+
|
|
175
|
+
- `zn-input`
|
|
176
|
+
- `zn-select`
|
|
177
|
+
- `zn-query-builder`
|
|
178
|
+
- `zn-multiselect`
|
|
179
|
+
- `zn-params-select`
|
|
180
|
+
- `zn-datepicker`
|
|
181
|
+
- Native HTML `input`, `select`, and `textarea` elements
|
|
182
|
+
|
|
183
|
+
```html:preview
|
|
184
|
+
<zn-data-table-search placeholder="Search users...">
|
|
185
|
+
<zn-select name="role">
|
|
186
|
+
<zn-option value="">All Roles</zn-option>
|
|
187
|
+
<zn-option value="admin">Admin</zn-option>
|
|
188
|
+
<zn-option value="user">User</zn-option>
|
|
189
|
+
</zn-select>
|
|
190
|
+
|
|
191
|
+
<zn-datepicker name="dateFrom"></zn-datepicker>
|
|
192
|
+
<zn-datepicker name="dateTo"></zn-datepicker>
|
|
193
|
+
|
|
194
|
+
<input type="hidden" name="includeArchived" value="false" />
|
|
195
|
+
</zn-data-table-search>
|
|
196
|
+
|
|
197
|
+
<div class="advanced-results" style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: var(--zn-border-radius-medium);">
|
|
198
|
+
<strong>All Search Parameters:</strong>
|
|
199
|
+
<pre class="advanced-content" style="margin-top: 0.5rem; font-size: 0.875rem;">No search performed yet</pre>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<script type="module">
|
|
203
|
+
const advancedSearch = document.querySelectorAll('zn-data-table-search')[document.querySelectorAll('zn-data-table-search').length - 1];
|
|
204
|
+
const advancedResults = document.querySelector('.advanced-content');
|
|
205
|
+
|
|
206
|
+
await customElements.whenDefined('zn-data-table-search');
|
|
207
|
+
await customElements.whenDefined('zn-datepicker');
|
|
208
|
+
|
|
209
|
+
advancedSearch.addEventListener('zn-search-change', (event) => {
|
|
210
|
+
const { value, formData } = event.detail;
|
|
211
|
+
advancedResults.textContent = JSON.stringify({
|
|
212
|
+
search: value,
|
|
213
|
+
...formData
|
|
214
|
+
}, null, 2);
|
|
215
|
+
});
|
|
216
|
+
</script>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Programmatic Control
|
|
220
|
+
|
|
221
|
+
You can programmatically control the search component by setting its `value` property or by calling the clear functionality through the internal input component.
|
|
222
|
+
|
|
223
|
+
```html:preview
|
|
224
|
+
<zn-data-table-search class="programmatic-search" placeholder="Search..."></zn-data-table-search>
|
|
225
|
+
|
|
226
|
+
<div style="margin-top: 1rem; display: flex; gap: 0.5rem;">
|
|
227
|
+
<zn-button class="set-value-btn" variant="primary" outline>Set Value</zn-button>
|
|
228
|
+
<zn-button class="clear-value-btn" variant="default" outline>Clear Value</zn-button>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<script type="module">
|
|
232
|
+
const progSearch = document.querySelector('.programmatic-search');
|
|
233
|
+
const setBtn = document.querySelector('.set-value-btn');
|
|
234
|
+
const clearBtn = document.querySelector('.clear-value-btn');
|
|
235
|
+
|
|
236
|
+
await Promise.all([
|
|
237
|
+
customElements.whenDefined('zn-data-table-search'),
|
|
238
|
+
customElements.whenDefined('zn-button')
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
setBtn.addEventListener('click', () => {
|
|
242
|
+
progSearch.value = 'programmatic value';
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
clearBtn.addEventListener('click', () => {
|
|
246
|
+
progSearch.value = '';
|
|
247
|
+
});
|
|
248
|
+
</script>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Integration with Data Tables
|
|
252
|
+
|
|
253
|
+
The `zn-data-table-search` component is designed to work seamlessly with the `zn-data-table` component. Here's a complete example showing how to integrate search functionality with a data table:
|
|
254
|
+
|
|
255
|
+
```html:preview
|
|
256
|
+
<zn-data-table-search
|
|
257
|
+
class="table-search"
|
|
258
|
+
search-uri="/api/users"
|
|
259
|
+
placeholder="Search users by name or email...">
|
|
260
|
+
</zn-data-table-search>
|
|
261
|
+
|
|
262
|
+
<div class="search-status" style="margin: 1rem 0; padding: 0.75rem; background: var(--zn-color-primary-50); border-radius: var(--zn-border-radius-medium); font-size: 0.875rem;">
|
|
263
|
+
Ready to search
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<script type="module">
|
|
267
|
+
const tableSearch = document.querySelector('.table-search');
|
|
268
|
+
const statusDiv = document.querySelector('.search-status');
|
|
269
|
+
|
|
270
|
+
await customElements.whenDefined('zn-data-table-search');
|
|
271
|
+
|
|
272
|
+
tableSearch.addEventListener('zn-search-change', async (event) => {
|
|
273
|
+
const { value, searchUri } = event.detail;
|
|
274
|
+
|
|
275
|
+
if (!value) {
|
|
276
|
+
statusDiv.textContent = 'Search cleared - showing all results';
|
|
277
|
+
statusDiv.style.background = 'var(--zn-color-neutral-50)';
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
statusDiv.textContent = `Searching for "${value}" at ${searchUri}...`;
|
|
282
|
+
statusDiv.style.background = 'var(--zn-color-warning-50)';
|
|
283
|
+
|
|
284
|
+
// Simulate API call
|
|
285
|
+
setTimeout(() => {
|
|
286
|
+
statusDiv.textContent = `Found results for "${value}"`;
|
|
287
|
+
statusDiv.style.background = 'var(--zn-color-success-50)';
|
|
288
|
+
}, 500);
|
|
289
|
+
});
|
|
290
|
+
</script>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
:::tip
|
|
294
|
+
**Usage Pattern:** Use `zn-data-table-search` as the primary search interface for data tables. The component handles debouncing automatically, so you can safely make API calls in response to the `zn-search-change` event without worrying about excessive requests.
|
|
295
|
+
:::
|
|
296
|
+
|
|
297
|
+
### Form Integration
|
|
298
|
+
|
|
299
|
+
The component implements the `ZincFormControl` interface and can be used within forms. The search value will be submitted with the form.
|
|
300
|
+
|
|
301
|
+
```html:preview
|
|
302
|
+
<form class="search-form">
|
|
303
|
+
<zn-data-table-search
|
|
304
|
+
name="userSearch"
|
|
305
|
+
placeholder="Search users...">
|
|
306
|
+
</zn-data-table-search>
|
|
307
|
+
|
|
308
|
+
<zn-button type="submit" variant="primary" style="margin-top: 1rem;">
|
|
309
|
+
Submit Form
|
|
310
|
+
</zn-button>
|
|
311
|
+
</form>
|
|
312
|
+
|
|
313
|
+
<div class="form-output" style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: var(--zn-border-radius-medium);">
|
|
314
|
+
<strong>Form Data:</strong>
|
|
315
|
+
<pre class="form-content" style="margin-top: 0.5rem; font-size: 0.875rem;">No form submission yet</pre>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
<script type="module">
|
|
319
|
+
const searchForm = document.querySelector('.search-form');
|
|
320
|
+
const formOutput = document.querySelector('.form-content');
|
|
321
|
+
|
|
322
|
+
await Promise.all([
|
|
323
|
+
customElements.whenDefined('zn-data-table-search'),
|
|
324
|
+
customElements.whenDefined('zn-button')
|
|
325
|
+
]);
|
|
326
|
+
|
|
327
|
+
searchForm.addEventListener('submit', (e) => {
|
|
328
|
+
e.preventDefault();
|
|
329
|
+
const formData = new FormData(searchForm);
|
|
330
|
+
const data = Object.fromEntries(formData);
|
|
331
|
+
formOutput.textContent = JSON.stringify(data, null, 2);
|
|
332
|
+
});
|
|
333
|
+
</script>
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Getting Form Data
|
|
337
|
+
|
|
338
|
+
Use the `getFormData()` method to retrieve all form data from the search component and any slotted input elements.
|
|
339
|
+
|
|
340
|
+
```html:preview
|
|
341
|
+
<zn-data-table-search
|
|
342
|
+
class="form-data-search"
|
|
343
|
+
name="search"
|
|
344
|
+
value="test search"
|
|
345
|
+
placeholder="Search...">
|
|
346
|
+
<zn-select name="filter" value="active">
|
|
347
|
+
<zn-option value="all">All</zn-option>
|
|
348
|
+
<zn-option value="active">Active</zn-option>
|
|
349
|
+
<zn-option value="inactive">Inactive</zn-option>
|
|
350
|
+
</zn-select>
|
|
351
|
+
<input type="hidden" name="page" value="1" />
|
|
352
|
+
</zn-data-table-search>
|
|
353
|
+
|
|
354
|
+
<zn-button class="get-data-btn" variant="primary" outline style="margin-top: 1rem;">
|
|
355
|
+
Get Form Data
|
|
356
|
+
</zn-button>
|
|
357
|
+
|
|
358
|
+
<div class="data-output" style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-50); border-radius: var(--zn-border-radius-medium);">
|
|
359
|
+
<strong>Form Data Object:</strong>
|
|
360
|
+
<pre class="data-content" style="margin-top: 0.5rem; font-size: 0.875rem;">Click the button to retrieve form data</pre>
|
|
361
|
+
</div>
|
|
362
|
+
|
|
363
|
+
<script type="module">
|
|
364
|
+
const formDataSearch = document.querySelector('.form-data-search');
|
|
365
|
+
const getDataBtn = document.querySelector('.get-data-btn');
|
|
366
|
+
const dataOutput = document.querySelector('.data-content');
|
|
367
|
+
|
|
368
|
+
await Promise.all([
|
|
369
|
+
customElements.whenDefined('zn-data-table-search'),
|
|
370
|
+
customElements.whenDefined('zn-button'),
|
|
371
|
+
customElements.whenDefined('zn-select')
|
|
372
|
+
]);
|
|
373
|
+
|
|
374
|
+
getDataBtn.addEventListener('click', () => {
|
|
375
|
+
const formData = formDataSearch.getFormData();
|
|
376
|
+
dataOutput.textContent = JSON.stringify(formData, null, 2);
|
|
377
|
+
});
|
|
378
|
+
</script>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Usage Guidelines
|
|
382
|
+
|
|
383
|
+
### When to Use
|
|
384
|
+
|
|
385
|
+
- **Data Table Filtering:** Use as the primary search interface for data tables and lists
|
|
386
|
+
- **Real-time Search:** When you need debounced search input to reduce API calls
|
|
387
|
+
- **Complex Filtering:** When you need to combine search with additional filter parameters
|
|
388
|
+
- **Form Integration:** When search needs to be part of a larger form submission
|
|
389
|
+
|
|
390
|
+
### Best Practices
|
|
391
|
+
|
|
392
|
+
1. **Placeholder Text:** Use clear, descriptive placeholder text that indicates what users can search for
|
|
393
|
+
2. **Help Text:** Provide help text when the search behavior isn't obvious or when there are special search features
|
|
394
|
+
3. **Debounce Delay:** The default 350ms delay works well for most cases. Increase it for expensive operations, decrease it for very fast searches
|
|
395
|
+
4. **Search URI:** Always provide a `search-uri` when the search data will be sent to a specific endpoint
|
|
396
|
+
5. **Event Handling:** Handle the `zn-search-change` event to trigger searches. The event includes both the search value and any additional form data
|
|
397
|
+
6. **Loading States:** Show loading indicators during search operations to provide feedback to users
|
|
398
|
+
|
|
399
|
+
### Accessibility
|
|
400
|
+
|
|
401
|
+
The component is built with accessibility in mind:
|
|
402
|
+
|
|
403
|
+
- Uses semantic HTML with proper input type (`search`)
|
|
404
|
+
- Includes a visible search icon prefix for visual recognition
|
|
405
|
+
- Supports keyboard navigation and clearing via the clearable input
|
|
406
|
+
- Integrates with form validation and submission
|
|
407
|
+
- Provides proper labeling through the help-text attribute
|
|
408
|
+
|
|
409
|
+
## Properties
|
|
410
|
+
|
|
411
|
+
| Property | Attribute | Type | Default | Description |
|
|
412
|
+
|----------------|------------------|----------|--------------|-------------|
|
|
413
|
+
| `name` | `name` | `string` | `'search'` | The name of the search input field for form submission |
|
|
414
|
+
| `value` | `value` | `string` | `''` | The current search value |
|
|
415
|
+
| `placeholder` | `placeholder` | `string` | `'Search...'`| The placeholder text for the search input |
|
|
416
|
+
| `helpText` | `help-text` | `string` | `''` | Help text displayed below the search input |
|
|
417
|
+
| `searchUri` | `search-uri` | `string` | `undefined` | Optional URI to use for search operations |
|
|
418
|
+
| `debounceDelay`| `debounce-delay` | `number` | `350` | The delay in milliseconds before triggering a search after the user stops typing |
|
|
419
|
+
|
|
420
|
+
## Events
|
|
421
|
+
|
|
422
|
+
| Event | Description | Event Detail |
|
|
423
|
+
|--------------------|-------------|--------------|
|
|
424
|
+
| `zn-search-change` | Emitted when the search value changes after the debounce delay. Also emitted immediately when the search is cleared. | `{ value: string, formData: Record<string, any>, searchUri?: string }` |
|
|
425
|
+
|
|
426
|
+
## Methods
|
|
427
|
+
|
|
428
|
+
| Method | Description |
|
|
429
|
+
|----------------|-------------|
|
|
430
|
+
| `getFormData()` | Returns an object containing all form data from the search input and any slotted form controls |
|
|
431
|
+
| `checkValidity()` | Checks the validity of the form control (always returns `true` for this component) |
|
|
432
|
+
| `reportValidity()` | Reports the validity of the form control (always returns `true` for this component) |
|
|
433
|
+
| `setCustomValidity()` | Sets custom validity (no-op for this component, but required by the form control interface) |
|
|
434
|
+
| `getForm()` | Returns the parent form element if one exists |
|
|
435
|
+
|
|
436
|
+
## Slots
|
|
437
|
+
|
|
438
|
+
| Name | Description |
|
|
439
|
+
|-----------|-------------|
|
|
440
|
+
| (default) | Additional form inputs to be included in the search form data. Slotted elements are hidden but their values are collected. |
|
|
441
|
+
|
|
442
|
+
## CSS Parts
|
|
443
|
+
|
|
444
|
+
| Part | Description |
|
|
445
|
+
|--------|-------------|
|
|
446
|
+
| `base` | The component's base wrapper |
|
|
447
|
+
|
|
448
|
+
## Dependencies
|
|
449
|
+
|
|
450
|
+
- `zn-input` - Used for the search input field
|
|
451
|
+
- `zn-icon` - Used for the search icon prefix
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Data Table Sort
|
|
4
|
-
description:
|
|
4
|
+
description: A sorting control component that displays a dropdown with field selection and sort direction (ascending/descending) options, with clear and update actions.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -11,10 +11,71 @@ layout: component
|
|
|
11
11
|
|
|
12
12
|
## Examples
|
|
13
13
|
|
|
14
|
-
###
|
|
14
|
+
### Basic Usage
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
The data table sort component provides a dropdown interface for sorting data.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
```html:preview
|
|
19
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### In Table Header
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
Typically used in data table headers for sorting functionality.
|
|
25
|
+
|
|
26
|
+
```html:preview
|
|
27
|
+
<div style="display: flex; gap: 10px; align-items: center;">
|
|
28
|
+
<span>Product List</span>
|
|
29
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
30
|
+
</div>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### With Action Bar
|
|
34
|
+
|
|
35
|
+
Combine with other table controls in an action bar.
|
|
36
|
+
|
|
37
|
+
```html:preview
|
|
38
|
+
<zn-action-bar>
|
|
39
|
+
<zn-button slot="menu" color="transparent">All Items</zn-button>
|
|
40
|
+
<zn-button slot="menu" color="transparent">Active</zn-button>
|
|
41
|
+
<zn-button slot="menu" color="transparent">Archived</zn-button>
|
|
42
|
+
|
|
43
|
+
<zn-data-table-sort slot="actions"></zn-data-table-sort>
|
|
44
|
+
<zn-button slot="actions" icon="filter_alt" color="transparent"></zn-button>
|
|
45
|
+
<zn-button slot="actions" icon="refresh" color="transparent"></zn-button>
|
|
46
|
+
</zn-action-bar>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Multiple Sort Controls
|
|
50
|
+
|
|
51
|
+
Use multiple sort controls for different sections or views.
|
|
52
|
+
|
|
53
|
+
```html:preview
|
|
54
|
+
<div class="form-spacing">
|
|
55
|
+
<div>
|
|
56
|
+
<h4>Customer List</h4>
|
|
57
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div>
|
|
61
|
+
<h4>Order History</h4>
|
|
62
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<div>
|
|
66
|
+
<h4>Product Inventory</h4>
|
|
67
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Compact Layout
|
|
73
|
+
|
|
74
|
+
The component automatically uses a compact size suitable for table headers.
|
|
75
|
+
|
|
76
|
+
```html:preview
|
|
77
|
+
<div style="display: flex; align-items: center; padding: 10px; background: var(--zn-color-neutral-50); border-radius: 4px;">
|
|
78
|
+
<span style="font-weight: bold; margin-right: auto;">Results (123)</span>
|
|
79
|
+
<zn-data-table-sort></zn-data-table-sort>
|
|
80
|
+
</div>
|
|
81
|
+
```
|