@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.
Files changed (199) hide show
  1. package/.claude/project.md +556 -0
  2. package/.github/workflows/js_build_and_deploy.yaml +9 -10
  3. package/dist/custom-elements.json +13575 -8856
  4. package/dist/vscode.html-custom-data.json +583 -48
  5. package/dist/web-types.json +1441 -181
  6. package/dist/zn.d.ts +1645 -660
  7. package/dist/zn.min.css +1 -1
  8. package/dist/zn.min.js +1412 -893
  9. package/docs/_utilities/code-previews.cjs +10 -1
  10. package/docs/assets/scripts/docs.js +42 -18
  11. package/docs/data/data-table.json +229 -66
  12. package/docs/data/empty.json +6 -0
  13. package/docs/data/products-table.json +41 -193
  14. package/docs/pages/components/action-bar.md +121 -6
  15. package/docs/pages/components/alert.md +118 -15
  16. package/docs/pages/components/animated-button.md +299 -0
  17. package/docs/pages/components/audio-select.md +534 -0
  18. package/docs/pages/components/bulk-actions.md +79 -5
  19. package/docs/pages/components/button-group.md +235 -27
  20. package/docs/pages/components/button.md +139 -1
  21. package/docs/pages/components/chart.md +365 -9
  22. package/docs/pages/components/checkbox.md +387 -58
  23. package/docs/pages/components/chip.md +253 -33
  24. package/docs/pages/components/collapsible.md +393 -46
  25. package/docs/pages/components/cols.md +152 -30
  26. package/docs/pages/components/confirm.md +182 -16
  27. package/docs/pages/components/copy-button.md +169 -6
  28. package/docs/pages/components/data-select.md +194 -15
  29. package/docs/pages/components/data-table-filter.md +96 -5
  30. package/docs/pages/components/data-table-search.md +451 -0
  31. package/docs/pages/components/data-table-sort.md +66 -5
  32. package/docs/pages/components/data-table.md +727 -66
  33. package/docs/pages/components/datepicker.md +402 -7
  34. package/docs/pages/components/defined-label.md +120 -5
  35. package/docs/pages/components/dialog.md +339 -59
  36. package/docs/pages/components/dropdown.md +366 -11
  37. package/docs/pages/components/editor.md +604 -7
  38. package/docs/pages/components/empty-state.md +315 -16
  39. package/docs/pages/components/expanding-action.md +212 -28
  40. package/docs/pages/components/file.md +421 -12
  41. package/docs/pages/components/filter-container.md +158 -5
  42. package/docs/pages/components/filter-wrapper.md +167 -6
  43. package/docs/pages/components/form-group.md +383 -6
  44. package/docs/pages/components/hover-container.md +237 -6
  45. package/docs/pages/components/icon-picker.md +121 -0
  46. package/docs/pages/components/icon.md +454 -48
  47. package/docs/pages/components/inline-edit.md +787 -19
  48. package/docs/pages/components/input-group.md +207 -13
  49. package/docs/pages/components/input.md +194 -0
  50. package/docs/pages/components/item.md +18 -0
  51. package/docs/pages/components/key-container.md +115 -0
  52. package/docs/pages/components/key.md +101 -0
  53. package/docs/pages/components/menu.md +512 -6
  54. package/docs/pages/components/note.md +239 -36
  55. package/docs/pages/components/opt-group.md +107 -0
  56. package/docs/pages/components/pagination.md +332 -6
  57. package/docs/pages/components/pane.md +222 -6
  58. package/docs/pages/components/panel.md +213 -26
  59. package/docs/pages/components/popup.md +1354 -6
  60. package/docs/pages/components/priority-list.md +233 -0
  61. package/docs/pages/components/progress-bar.md +387 -6
  62. package/docs/pages/components/radio-group.md +242 -5
  63. package/docs/pages/components/radio.md +474 -6
  64. package/docs/pages/components/rating.md +331 -7
  65. package/docs/pages/components/reveal.md +524 -6
  66. package/docs/pages/components/scroll-container.md +552 -6
  67. package/docs/pages/components/select.md +762 -160
  68. package/docs/pages/components/skeleton.md +473 -30
  69. package/docs/pages/components/slideout.md +261 -5
  70. package/docs/pages/components/sp.md +99 -41
  71. package/docs/pages/components/split-button.md +347 -9
  72. package/docs/pages/components/split-pane.md +445 -6
  73. package/docs/pages/components/stat.md +549 -9
  74. package/docs/pages/components/status-indicator.md +230 -1
  75. package/docs/pages/components/stepper.md +563 -6
  76. package/docs/pages/components/tabs.md +439 -13
  77. package/docs/pages/components/textarea.md +415 -17
  78. package/docs/pages/components/tile.md +385 -26
  79. package/docs/pages/components/toggle.md +424 -6
  80. package/docs/pages/components/tooltip.md +367 -0
  81. package/docs/pages/components/translation-group.md +210 -0
  82. package/docs/pages/components/translations.md +319 -19
  83. package/docs/pages/components/vertical-stepper.md +401 -8
  84. package/docs/pages/components/well.md +300 -3
  85. package/docs/pages/getting-started/form-controls.md +162 -0
  86. package/docs/pages/index.md +116 -15
  87. package/package.json +5 -6
  88. package/scss/_global-spacing.scss +4 -0
  89. package/scss/_root.scss +2 -2
  90. package/scss/boot.scss +19 -0
  91. package/scss/shared/layout.scss +5 -0
  92. package/scss/themes/_light.scss +3 -3
  93. package/src/components/alert/alert.scss +1 -0
  94. package/src/components/animated-button/README.md +306 -0
  95. package/src/components/animated-button/animated-button.component.ts +229 -0
  96. package/src/components/animated-button/animated-button.scss +228 -0
  97. package/src/components/animated-button/animated-button.test.ts +143 -0
  98. package/src/components/animated-button/index.ts +12 -0
  99. package/src/components/button/button.component.ts +5 -0
  100. package/src/components/button-group/button-group.component.ts +25 -13
  101. package/src/components/button-group/button-group.scss +6 -0
  102. package/src/components/checkbox/checkbox.component.ts +4 -0
  103. package/src/components/checkbox/checkbox.scss +7 -4
  104. package/src/components/checkbox-group/checkbox-group.scss +7 -0
  105. package/src/components/chip/chip.component.ts +7 -2
  106. package/src/components/chip/chip.scss +16 -2
  107. package/src/components/collapsible/collapsible.component.ts +27 -20
  108. package/src/components/cols/cols.component.ts +14 -2
  109. package/src/components/cols/cols.scss +6 -12
  110. package/src/components/confirm/confirm.component.ts +7 -0
  111. package/src/components/copy-button/copy-button.component.ts +12 -11
  112. package/src/components/data-select/data-select.component.ts +215 -44
  113. package/src/components/data-select/data-select.scss +66 -6
  114. package/src/components/data-select/providers/currency-data-provider.ts +20 -6
  115. package/src/components/data-select/providers/provider.ts +1 -0
  116. package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
  117. package/src/components/data-table/data-table.component.ts +81 -22
  118. package/src/components/data-table-search/data-table-search.component.ts +184 -0
  119. package/src/components/data-table-search/data-table-search.scss +17 -0
  120. package/src/components/data-table-search/data-table-search.test.ts +11 -0
  121. package/src/components/data-table-search/index.ts +12 -0
  122. package/src/components/datepicker/datepicker.component.ts +347 -13
  123. package/src/components/dialog/dialog.component.ts +1 -1
  124. package/src/components/empty-state/empty-state.scss +6 -1
  125. package/src/components/header/header.scss +3 -3
  126. package/src/components/icon/icon.component.ts +23 -1
  127. package/src/components/icon/icon.scss +23 -0
  128. package/src/components/icon-picker/brand-icons.ts +24 -0
  129. package/src/components/icon-picker/icon-picker.component.ts +407 -0
  130. package/src/components/icon-picker/icon-picker.scss +205 -0
  131. package/src/components/icon-picker/index.ts +12 -0
  132. package/src/components/icon-picker/line-icons.ts +612 -0
  133. package/src/components/icon-picker/material-icons.ts +14543 -0
  134. package/src/components/inline-edit/inline-edit.component.ts +190 -46
  135. package/src/components/inline-edit/inline-edit.scss +29 -0
  136. package/src/components/inline-edit/inline-edit.test.ts +314 -1
  137. package/src/components/input/input.component.ts +324 -5
  138. package/src/components/input/input.scss +87 -0
  139. package/src/components/input-group/input-group.component.ts +28 -7
  140. package/src/components/input-group/input-group.scss +48 -10
  141. package/src/components/item/item.component.ts +24 -3
  142. package/src/components/item/item.scss +18 -0
  143. package/src/components/key/index.ts +12 -0
  144. package/src/components/key/key.component.ts +47 -0
  145. package/src/components/key/key.scss +38 -0
  146. package/src/components/key-container/index.ts +12 -0
  147. package/src/components/key-container/key-container.component.ts +142 -0
  148. package/src/components/key-container/key-container.scss +33 -0
  149. package/src/components/menu-item/menu-item.component.ts +20 -0
  150. package/src/components/menu-item/menu-item.scss +69 -2
  151. package/src/components/navbar/navbar.component.ts +103 -11
  152. package/src/components/navbar/navbar.scss +6 -1
  153. package/src/components/opt-group/index.ts +12 -0
  154. package/src/components/opt-group/opt-group.component.ts +74 -0
  155. package/src/components/opt-group/opt-group.scss +37 -0
  156. package/src/components/opt-group/opt-group.test.ts +27 -0
  157. package/src/components/option/option.component.ts +1 -16
  158. package/src/components/option/option.scss +4 -0
  159. package/src/components/panel/panel.component.ts +10 -8
  160. package/src/components/panel/panel.scss +20 -0
  161. package/src/components/priority-list/index.ts +12 -0
  162. package/src/components/priority-list/priority-list.component.ts +611 -0
  163. package/src/components/priority-list/priority-list.scss +185 -0
  164. package/src/components/priority-list/priority-list.test.ts +139 -0
  165. package/src/components/progress-bar/progress-bar.component.ts +22 -16
  166. package/src/components/radio/radio.scss +10 -3
  167. package/src/components/select/select.component.ts +812 -72
  168. package/src/components/select/select.scss +108 -2
  169. package/src/components/select/select.test.ts +147 -2
  170. package/src/components/settings-container/settings-container.component.ts +44 -19
  171. package/src/components/settings-container/settings-container.scss +1 -1
  172. package/src/components/skeleton/skeleton.component.ts +6 -1
  173. package/src/components/slideout/slideout.scss +8 -3
  174. package/src/components/sp/sp.component.ts +3 -1
  175. package/src/components/sp/sp.scss +19 -0
  176. package/src/components/stepper/stepper.component.ts +16 -10
  177. package/src/components/textarea/textarea.scss +0 -4
  178. package/src/components/tile/tile.component.ts +12 -3
  179. package/src/components/tile/tile.scss +1 -1
  180. package/src/components/timer/timer.component.ts +15 -2
  181. package/src/components/toggle/toggle.component.ts +29 -26
  182. package/src/components/toggle/toggle.scss +13 -1
  183. package/src/components/translation-group/index.ts +12 -0
  184. package/src/components/translation-group/translation-group.component.ts +207 -0
  185. package/src/components/translation-group/translation-group.scss +8 -0
  186. package/src/components/translations/translations.component.ts +90 -44
  187. package/src/components/translations/translations.scss +4 -0
  188. package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
  189. package/src/events/events.ts +12 -7
  190. package/src/events/zn-language-change.ts +7 -0
  191. package/src/events/zn-purchase.ts +11 -0
  192. package/src/events/zn-redirect.ts +7 -0
  193. package/src/events/zn-reorder.ts +7 -0
  194. package/src/events/zn-search-change.ts +11 -0
  195. package/src/events/zn-submit.ts +1 -1
  196. package/src/form-control.scss +4 -0
  197. package/src/internal/form-navigation.ts +510 -0
  198. package/src/internal/form.ts +6 -0
  199. package/src/zinc.ts +91 -83
@@ -1,25 +1,420 @@
1
1
  ---
2
2
  meta:
3
3
  title: Datepicker
4
- description:
4
+ description: Datepickers allow users to select dates from an interactive calendar interface.
5
5
  layout: component
6
6
  ---
7
7
 
8
+ ## Examples
9
+
10
+ ### Basic Datepicker with Label
11
+
12
+ Use the `label` attribute to give the datepicker an accessible label.
13
+
8
14
  ```html:preview
9
- <zn-datepicker></zn-datepicker>
15
+ <zn-datepicker label="Event date"></zn-datepicker>
10
16
  ```
11
17
 
12
- ## Examples
18
+ :::tip
19
+ This component works with standard `<form>` elements. Please refer to the section on [form controls](/getting-started/form-controls) to learn more about form submission and client-side validation.
20
+ :::
21
+
22
+ ### Help Text
23
+
24
+ Add descriptive help text to a datepicker with the `help-text` attribute. For help text that contains HTML, use the `help-text` slot instead.
25
+
26
+ ```html:preview
27
+ <zn-datepicker label="Appointment date" help-text="Select your preferred date for the appointment"></zn-datepicker>
28
+ <br />
29
+ <zn-datepicker label="Appointment date">
30
+ <div slot="help-text">Select your <strong>preferred date</strong> for the appointment</div>
31
+ </zn-datepicker>
32
+ ```
33
+
34
+ ### Label with Tooltip
35
+
36
+ Use the `label-tooltip` attribute to add text that appears in a tooltip triggered by an info icon next to the label.
37
+
38
+ :::tip
39
+ **Usage:** Use a **label tooltip** to provide helpful but non-essential instructions or examples to guide people when selecting a date. Use **help text** to communicate instructions or requirements for selecting a date without errors.
40
+ :::
41
+
42
+ ```html:preview
43
+ <zn-datepicker label="Event date" label-tooltip="Choose a date that works best for your schedule. You can reschedule up to 24 hours before the event." help-text="Select a date at least 3 days from today"></zn-datepicker>
44
+ ```
45
+
46
+ ### Label with Context Note
47
+
48
+ Use the `context-note` attribute to add text that provides additional context or reference. For text that contains HTML, use the `context-note` slot. **Note:** On small screens the context note will wrap below the label if there isn't enough room next to the label.
49
+
50
+ :::tip
51
+ **Usage:** Use a **context note** to provide secondary contextual data, especially dynamic data, that would help people when selecting a date. Use **help text** to communicate instructions or requirements for selecting a date without errors.
52
+ :::
53
+
54
+ ```html:preview
55
+ <zn-datepicker label="Delivery date" context-note="Next available: Jan 25" help-text="Standard delivery takes 3-5 business days"></zn-datepicker>
56
+ <br />
57
+ <zn-datepicker label="Delivery date" help-text="Standard delivery takes 3-5 business days">
58
+ <div slot="context-note">Next available: <strong>Jan 25</strong></div>
59
+ </zn-datepicker>
60
+ ```
61
+
62
+ ### Placeholders
63
+
64
+ Use the `placeholder` attribute to add a placeholder.
65
+
66
+ ```html:preview
67
+ <zn-datepicker label="Select date" placeholder="MM/DD/YYYY"></zn-datepicker>
68
+ ```
69
+
70
+ ### Date Formats
71
+
72
+ Use the `format` attribute to customize how dates are displayed and entered. The default format is `dd/MM/yyyy` (European style).
73
+
74
+ ```html:preview
75
+ <zn-datepicker label="European format (default)" format="dd/MM/yyyy" placeholder="31/12/2024"></zn-datepicker>
76
+ <br />
77
+ <zn-datepicker label="US format" format="MM/dd/yyyy" placeholder="12/31/2024"></zn-datepicker>
78
+ <br />
79
+ <zn-datepicker label="ISO format" format="yyyy-MM-dd" placeholder="2024-12-31"></zn-datepicker>
80
+ <br />
81
+ <zn-datepicker label="European with dashes" format="dd-MM-yyyy" placeholder="31-12-2024"></zn-datepicker>
82
+ ```
83
+
84
+ :::tip
85
+ The format controls both how dates are displayed in the input and what format the datepicker expects when users type dates manually. Date separators are automatically inserted as you type, making it easy to enter dates without manual formatting. Invalid characters are blocked, and dates are validated against the specified format.
86
+ :::
87
+
88
+ ### Initial Value
13
89
 
14
- ### Range
90
+ Set the `value` attribute to provide an initial date selection. The value should match the format specified.
15
91
 
16
92
  ```html:preview
17
- <zn-datepicker range></zn-datepicker>
93
+ <zn-datepicker label="Event date" format="dd/MM/yyyy" value="15/01/2026"></zn-datepicker>
94
+ <br />
95
+ <zn-datepicker label="Event date (US)" format="MM/dd/yyyy" value="01/15/2026"></zn-datepicker>
18
96
  ```
19
97
 
98
+ ### Disabled
20
99
 
21
- ### Second Example
100
+ Use the `disabled` attribute to disable a datepicker.
101
+
102
+ ```html:preview
103
+ <zn-datepicker label="Event date" disabled></zn-datepicker>
104
+ ```
105
+
106
+ ### Read-only
107
+
108
+ Use the `readonly` attribute to make the datepicker read-only. Users can still open the calendar to view dates but cannot change the selection.
109
+
110
+ ```html:preview
111
+ <zn-datepicker label="Contract start date" value="01/01/2026" readonly></zn-datepicker>
112
+ ```
113
+
114
+ ### Sizes
115
+
116
+ Use the `size` attribute to change a datepicker's size. Size `medium` is the default.
117
+
118
+ ```html:preview
119
+ <zn-datepicker label="Small datepicker" size="small"></zn-datepicker>
120
+ <br />
121
+ <zn-datepicker label="Medium datepicker" size="medium"></zn-datepicker>
122
+ <br />
123
+ <zn-datepicker label="Large datepicker" size="large"></zn-datepicker>
124
+ ```
125
+
126
+ ### Range Selection
127
+
128
+ Use the `range` attribute to allow users to select a date range instead of a single date.
129
+
130
+ ```html:preview
131
+ <zn-datepicker label="Event dates" range help-text="Select start and end dates for your event"></zn-datepicker>
132
+ ```
133
+
134
+ ### Disabling Past Dates
135
+
136
+ Use the `disable-past-dates` attribute to prevent users from selecting dates in the past. This is useful for scheduling future events or appointments.
137
+
138
+ ```html:preview
139
+ <zn-datepicker label="Appointment date" disable-past-dates help-text="Only future dates can be selected"></zn-datepicker>
140
+ ```
141
+
142
+ ### Minimum Date
143
+
144
+ Use the `min-date` attribute to set the earliest selectable date. This overrides `disable-past-dates` if both are set. Accepts a date string or Date object.
145
+
146
+ ```html:preview
147
+ <zn-datepicker label="Reservation date" min-date="01/20/2026" help-text="Reservations available starting January 20, 2026"></zn-datepicker>
148
+ ```
149
+
150
+ ### Maximum Date
151
+
152
+ Use the `max-date` attribute to set the latest selectable date. Accepts a date string or Date object.
153
+
154
+ ```html:preview
155
+ <zn-datepicker label="Early bird registration" max-date="02/28/2026" help-text="Early bird pricing ends February 28, 2026"></zn-datepicker>
156
+ ```
22
157
 
23
- TODO
158
+ ### Date Range Constraints
159
+
160
+ Combine `min-date` and `max-date` to constrain the selectable date range.
161
+
162
+ ```html:preview
163
+ <zn-datepicker
164
+ label="Conference dates"
165
+ min-date="03/01/2026"
166
+ max-date="03/15/2026"
167
+ range
168
+ help-text="Select dates within the conference period (March 1-15, 2026)">
169
+ </zn-datepicker>
170
+ ```
171
+
172
+ ### Clearable
173
+
174
+ Use the `clearable` attribute to add a "Clear" button to the calendar popup, allowing users to easily remove a selected date.
175
+
176
+ ```html:preview
177
+ <zn-datepicker label="Event date" clearable value="03/15/2026"></zn-datepicker>
178
+ ```
179
+
180
+ ### Prefix & Suffix Slots
181
+
182
+ Use the `prefix` and `suffix` slots to add icons or text elements.
183
+
184
+ :::warning
185
+ **Note:** `ts_form_for` doesn't support slots. Prefix and suffix icons cannot be added when rendering `zn-datepicker` with `ts_form_for`.
186
+ :::
187
+
188
+ ```html:preview
189
+ <zn-datepicker label="Event date">
190
+ <zn-icon src="event_available" slot="prefix"></zn-icon>
191
+ </zn-datepicker>
192
+ <br />
193
+ <zn-datepicker label="Deadline">
194
+ <span slot="suffix" style="color: var(--zn-color-danger-600); font-weight: 500;">Required</span>
195
+ </zn-datepicker>
196
+ ```
197
+
198
+ ### Form Integration
199
+
200
+ Datepicker components work seamlessly with standard HTML forms. The datepicker's `name` attribute determines the key in the form data.
201
+
202
+ ```html:preview
203
+ <form id="datepicker-form">
204
+ <zn-datepicker name="startDate" label="Start date" required></zn-datepicker>
205
+ <br />
206
+ <zn-datepicker name="endDate" label="End date" required></zn-datepicker>
207
+ <br />
208
+ <zn-datepicker name="dateRange" label="Date range" range></zn-datepicker>
209
+ <br />
210
+ <zn-button type="submit" variant="primary">Submit</zn-button>
211
+ <zn-button type="reset">Reset</zn-button>
212
+ </form>
213
+
214
+ <script type="module">
215
+ const form = document.getElementById('datepicker-form');
216
+
217
+ // Wait for controls to be defined before attaching form listeners
218
+ await Promise.all([
219
+ customElements.whenDefined('zn-button'),
220
+ customElements.whenDefined('zn-datepicker')
221
+ ]).then(() => {
222
+ form.addEventListener('submit', (e) => {
223
+ e.preventDefault();
224
+ const formData = new FormData(form);
225
+ const data = Object.fromEntries(formData);
226
+ alert('Form submitted!\n\n' + JSON.stringify(data, null, 2));
227
+ });
228
+ });
229
+ </script>
230
+ ```
231
+
232
+ ### Validation
233
+
234
+ Datepicker components support native HTML validation attributes like `required`. The component will show validation states and messages automatically.
235
+
236
+ ```html:preview
237
+ <form id="validation-form" class="form-spacing">
238
+ <zn-datepicker
239
+ name="eventDate"
240
+ label="Event date"
241
+ required
242
+ help-text="This field is required">
243
+ </zn-datepicker>
244
+
245
+ <zn-datepicker
246
+ name="meetingDate"
247
+ label="Meeting date"
248
+ required
249
+ disable-past-dates
250
+ help-text="Please select a future date">
251
+ </zn-datepicker>
252
+
253
+ <zn-button type="submit" variant="primary">Submit</zn-button>
254
+ </form>
255
+
256
+ <script type="module">
257
+ const validationForm = document.getElementById('validation-form');
258
+
259
+ // Wait for controls to be defined before attaching form listeners
260
+ await Promise.all([
261
+ customElements.whenDefined('zn-button'),
262
+ customElements.whenDefined('zn-datepicker')
263
+ ]).then(() => {
264
+ validationForm.addEventListener('submit', (e) => {
265
+ e.preventDefault();
266
+ const formData = new FormData(validationForm);
267
+ const data = Object.fromEntries(formData);
268
+ alert('Form is valid!\n\n' + JSON.stringify(data, null, 2));
269
+ });
270
+ });
271
+ </script>
272
+ ```
273
+
274
+ You can also use custom validation with the `setCustomValidity()` method:
275
+
276
+ ```html:preview
277
+ <form id="custom-validation-form">
278
+ <zn-datepicker id="booking-date" name="bookingDate" label="Booking date"></zn-datepicker>
279
+ <br />
280
+ <zn-button type="submit" variant="primary">Submit</zn-button>
281
+ </form>
282
+
283
+ <script type="module">
284
+ const customValidationForm = document.getElementById('custom-validation-form');
285
+ const bookingDate = document.getElementById('booking-date');
286
+
287
+ bookingDate.addEventListener('zn-change', () => {
288
+ const selectedDate = new Date(bookingDate.value);
289
+ const dayOfWeek = selectedDate.getDay();
290
+
291
+ // Disallow weekends (0 = Sunday, 6 = Saturday)
292
+ if (dayOfWeek === 0 || dayOfWeek === 6) {
293
+ bookingDate.setCustomValidity('Bookings are only available on weekdays');
294
+ } else {
295
+ bookingDate.setCustomValidity('');
296
+ }
297
+ });
298
+
299
+ // Wait for controls to be defined before attaching form listeners
300
+ await Promise.all([
301
+ customElements.whenDefined('zn-button'),
302
+ customElements.whenDefined('zn-datepicker')
303
+ ]).then(() => {
304
+ customValidationForm.addEventListener('submit', (e) => {
305
+ e.preventDefault();
306
+ if (customValidationForm.reportValidity()) {
307
+ alert('Form is valid!');
308
+ }
309
+ });
310
+ });
311
+ </script>
312
+ ```
313
+
314
+ ### Events
315
+
316
+ The datepicker component emits several events you can listen to:
317
+
318
+ ```html:preview
319
+ <div class="form-spacing">
320
+ <zn-datepicker id="event-example" label="Select a date"></zn-datepicker>
321
+
322
+ <div style="margin-top: 1rem; padding: 1rem; background: var(--zn-color-neutral-100); border-radius: 4px;">
323
+ <strong>Event Log:</strong>
324
+ <div id="event-log" style="margin-top: 0.5rem; font-family: monospace; font-size: 0.875rem;"></div>
325
+ </div>
326
+ </div>
327
+
328
+ <script type="module">
329
+ const datepicker = document.getElementById('event-example');
330
+ const eventLog = document.getElementById('event-log');
331
+
332
+ function logEvent(eventName, detail) {
333
+ const time = new Date().toLocaleTimeString();
334
+ const message = `[${time}] ${eventName}${detail ? ': ' + JSON.stringify(detail) : ''}`;
335
+ eventLog.innerHTML = message + '<br>' + eventLog.innerHTML;
336
+ // Keep only last 5 events
337
+ const lines = eventLog.innerHTML.split('<br>');
338
+ if (lines.length > 5) {
339
+ eventLog.innerHTML = lines.slice(0, 5).join('<br>');
340
+ }
341
+ }
342
+
343
+ datepicker.addEventListener('zn-change', (e) => logEvent('zn-change', { value: e.target.value }));
344
+ datepicker.addEventListener('zn-input', (e) => logEvent('zn-input'));
345
+ datepicker.addEventListener('zn-focus', (e) => logEvent('zn-focus'));
346
+ datepicker.addEventListener('zn-blur', (e) => logEvent('zn-blur'));
347
+ datepicker.addEventListener('zn-invalid', (e) => logEvent('zn-invalid'));
348
+ </script>
349
+ ```
350
+
351
+ ### Programmatic Control
352
+
353
+ You can control the datepicker programmatically using its methods:
354
+
355
+ ```html:preview
356
+ <div class="form-spacing">
357
+ <zn-datepicker id="programmatic-datepicker" label="Programmatic control"></zn-datepicker>
358
+
359
+ <div style="margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap;">
360
+ <zn-button id="focus-btn" size="small">Focus</zn-button>
361
+ <zn-button id="blur-btn" size="small">Blur</zn-button>
362
+ <zn-button id="set-value-btn" size="small">Set Value</zn-button>
363
+ <zn-button id="clear-value-btn" size="small">Clear Value</zn-button>
364
+ <zn-button id="check-validity-btn" size="small">Check Validity</zn-button>
365
+ </div>
366
+ </div>
367
+
368
+ <script type="module">
369
+ const datepicker = document.getElementById('programmatic-datepicker');
370
+
371
+ document.getElementById('focus-btn').addEventListener('click', () => datepicker.focus());
372
+ document.getElementById('blur-btn').addEventListener('click', () => datepicker.blur());
373
+ document.getElementById('set-value-btn').addEventListener('click', () => {
374
+ datepicker.value = '02/14/2026';
375
+ });
376
+ document.getElementById('clear-value-btn').addEventListener('click', () => {
377
+ datepicker.value = '';
378
+ });
379
+ document.getElementById('check-validity-btn').addEventListener('click', () => {
380
+ alert('Valid: ' + datepicker.checkValidity());
381
+ });
382
+ </script>
383
+ ```
384
+
385
+ ### Customizing Label Position
386
+
387
+ Use [CSS parts](#css-parts) to customize the way form controls are drawn. This example uses CSS grid to position the label to the left of the control, but the possible orientations are nearly endless. The same technique works for inputs, textareas, selects, and similar form controls.
388
+
389
+ ```html:preview
390
+ <zn-datepicker class="label-on-left" label="Date" help-text="Select a date"></zn-datepicker>
391
+ <zn-datepicker class="label-on-left" label="Range" range help-text="Select a date range"></zn-datepicker>
392
+
393
+ <style>
394
+ .label-on-left {
395
+ --label-width: 3.75rem;
396
+ --gap-width: 1rem;
397
+ }
398
+
399
+ .label-on-left + .label-on-left {
400
+ margin-top: var(--zn-spacing-medium);
401
+ }
402
+
403
+ .label-on-left::part(form-control) {
404
+ display: grid;
405
+ grid: auto / var(--label-width) 1fr;
406
+ gap: var(--zn-spacing-3x-small) var(--gap-width);
407
+ align-items: center;
408
+ }
409
+
410
+ .label-on-left::part(form-control-label) {
411
+ text-align: right;
412
+ }
413
+
414
+ .label-on-left::part(form-control-help-text) {
415
+ grid-column-start: 2;
416
+ }
417
+ </style>
418
+ ```
24
419
 
25
420
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  meta:
3
3
  title: Defined Label
4
- description:
4
+ description: A labeled input component with dropdown suggestions for predefined label-value pairs. Supports custom labels, searchable options, and both select and text input fields for label values.
5
5
  layout: component
6
6
  ---
7
7
 
@@ -15,12 +15,127 @@ layout: component
15
15
 
16
16
  ## Examples
17
17
 
18
- ### First Example
18
+ ### Basic Usage with Text Input
19
19
 
20
- TODO
20
+ Create labels with free-form text values by defining labels without options.
21
21
 
22
- ### Second Example
22
+ ```html:preview
23
+ <zn-defined-label
24
+ predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;category&quot;,&quot;options&quot;:[]}]">
25
+ </zn-defined-label>
26
+ ```
27
+
28
+ ### Labels with Dropdown Options
29
+
30
+ Define labels with predefined value options for structured data entry.
31
+
32
+ ```html:preview
33
+ <zn-defined-label
34
+ predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;,&quot;critical&quot;]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[&quot;open&quot;,&quot;in progress&quot;,&quot;closed&quot;]},{&quot;name&quot;:&quot;type&quot;,&quot;options&quot;:[&quot;bug&quot;,&quot;feature&quot;,&quot;improvement&quot;]}]">
35
+ </zn-defined-label>
36
+ ```
37
+
38
+ ### Allow Custom Labels
39
+
40
+ Enable users to create their own labels using the `allow-custom` attribute.
41
+
42
+ ```html:preview
43
+ <zn-defined-label
44
+ allow-custom
45
+ predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[&quot;open&quot;,&quot;closed&quot;]}]">
46
+ </zn-defined-label>
47
+ ```
48
+
49
+ ### Mixed Input Types
50
+
51
+ Combine labels with dropdown options and free-text values.
52
+
53
+ ```html:preview
54
+ <zn-defined-label
55
+ allow-custom
56
+ predefined-labels="[{&quot;name&quot;:&quot;department&quot;,&quot;options&quot;:[&quot;engineering&quot;,&quot;sales&quot;,&quot;marketing&quot;,&quot;support&quot;]},{&quot;name&quot;:&quot;project&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;version&quot;,&quot;options&quot;:[&quot;1.0&quot;,&quot;2.0&quot;,&quot;3.0&quot;]},{&quot;name&quot;:&quot;assignee&quot;,&quot;options&quot;:[]}]">
57
+ </zn-defined-label>
58
+ ```
59
+
60
+ ### Different Input Sizes
61
+
62
+ Control the input size using the `input-size` attribute.
63
+
64
+ ```html:preview
65
+ <div class="form-spacing">
66
+ <zn-defined-label
67
+ input-size="small"
68
+ predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
69
+ </zn-defined-label>
70
+
71
+ <zn-defined-label
72
+ input-size="medium"
73
+ predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
74
+ </zn-defined-label>
75
+
76
+ <zn-defined-label
77
+ input-size="large"
78
+ predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
79
+ </zn-defined-label>
80
+ </div>
81
+ ```
82
+
83
+ ### Disabled State
23
84
 
24
- TODO
85
+ Disable the input using the `disabled` attribute.
86
+
87
+ ```html:preview
88
+ <zn-defined-label
89
+ disabled
90
+ predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;]}]">
91
+ </zn-defined-label>
92
+ ```
93
+
94
+ ### Custom Name Attribute
95
+
96
+ Specify a custom form field name using the `name` attribute.
97
+
98
+ ```html:preview
99
+ <form>
100
+ <zn-defined-label
101
+ name="custom-label"
102
+ allow-custom
103
+ predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
104
+ </zn-defined-label>
105
+ </form>
106
+ ```
107
+
108
+ ### Issue Tracking Labels
109
+
110
+ A practical example for issue tracking systems.
111
+
112
+ ```html:preview
113
+ <zn-defined-label
114
+ allow-custom
115
+ predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;p0&quot;,&quot;p1&quot;,&quot;p2&quot;,&quot;p3&quot;]},{&quot;name&quot;:&quot;type&quot;,&quot;options&quot;:[&quot;bug&quot;,&quot;feature&quot;,&quot;task&quot;,&quot;epic&quot;]},{&quot;name&quot;:&quot;component&quot;,&quot;options&quot;:[&quot;frontend&quot;,&quot;backend&quot;,&quot;api&quot;,&quot;database&quot;]},{&quot;name&quot;:&quot;environment&quot;,&quot;options&quot;:[&quot;dev&quot;,&quot;staging&quot;,&quot;production&quot;]},{&quot;name&quot;:&quot;assignee&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;sprint&quot;,&quot;options&quot;:[]}]">
116
+ </zn-defined-label>
117
+ ```
118
+
119
+ ### Content Tagging
120
+
121
+ Use for tagging content with categories and metadata.
122
+
123
+ ```html:preview
124
+ <zn-defined-label
125
+ allow-custom
126
+ predefined-labels="[{&quot;name&quot;:&quot;category&quot;,&quot;options&quot;:[&quot;article&quot;,&quot;tutorial&quot;,&quot;guide&quot;,&quot;reference&quot;]},{&quot;name&quot;:&quot;difficulty&quot;,&quot;options&quot;:[&quot;beginner&quot;,&quot;intermediate&quot;,&quot;advanced&quot;]},{&quot;name&quot;:&quot;language&quot;,&quot;options&quot;:[&quot;javascript&quot;,&quot;python&quot;,&quot;java&quot;,&quot;go&quot;]},{&quot;name&quot;:&quot;topic&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;author&quot;,&quot;options&quot;:[]}]">
127
+ </zn-defined-label>
128
+ ```
129
+
130
+ ### E-commerce Product Labels
131
+
132
+ Label products with attributes and characteristics.
133
+
134
+ ```html:preview
135
+ <zn-defined-label
136
+ allow-custom
137
+ predefined-labels="[{&quot;name&quot;:&quot;size&quot;,&quot;options&quot;:[&quot;xs&quot;,&quot;s&quot;,&quot;m&quot;,&quot;l&quot;,&quot;xl&quot;,&quot;xxl&quot;]},{&quot;name&quot;:&quot;color&quot;,&quot;options&quot;:[&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;,&quot;black&quot;,&quot;white&quot;]},{&quot;name&quot;:&quot;material&quot;,&quot;options&quot;:[&quot;cotton&quot;,&quot;polyester&quot;,&quot;wool&quot;,&quot;silk&quot;]},{&quot;name&quot;:&quot;season&quot;,&quot;options&quot;:[&quot;spring&quot;,&quot;summer&quot;,&quot;fall&quot;,&quot;winter&quot;]},{&quot;name&quot;:&quot;brand&quot;,&quot;options&quot;:[]}]">
138
+ </zn-defined-label>
139
+ ```
25
140
 
26
141