@chromvoid/uikit 0.1.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 (246) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +96 -0
  3. package/dist/components/cv-accordion-item.d.ts +69 -0
  4. package/dist/components/cv-accordion-item.js +176 -0
  5. package/dist/components/cv-accordion.d.ts +79 -0
  6. package/dist/components/cv-accordion.js +310 -0
  7. package/dist/components/cv-alert-dialog.d.ts +86 -0
  8. package/dist/components/cv-alert-dialog.js +393 -0
  9. package/dist/components/cv-alert.d.ts +48 -0
  10. package/dist/components/cv-alert.js +156 -0
  11. package/dist/components/cv-badge.d.ts +56 -0
  12. package/dist/components/cv-badge.js +280 -0
  13. package/dist/components/cv-breadcrumb-item.d.ts +35 -0
  14. package/dist/components/cv-breadcrumb-item.js +64 -0
  15. package/dist/components/cv-breadcrumb.d.ts +39 -0
  16. package/dist/components/cv-breadcrumb.js +160 -0
  17. package/dist/components/cv-button.d.ts +83 -0
  18. package/dist/components/cv-button.js +541 -0
  19. package/dist/components/cv-callout.d.ts +32 -0
  20. package/dist/components/cv-callout.js +221 -0
  21. package/dist/components/cv-card.d.ts +48 -0
  22. package/dist/components/cv-card.js +269 -0
  23. package/dist/components/cv-carousel-slide.d.ts +25 -0
  24. package/dist/components/cv-carousel-slide.js +51 -0
  25. package/dist/components/cv-carousel.d.ts +96 -0
  26. package/dist/components/cv-carousel.js +457 -0
  27. package/dist/components/cv-checkbox.d.ts +84 -0
  28. package/dist/components/cv-checkbox.js +274 -0
  29. package/dist/components/cv-combobox-group.d.ts +15 -0
  30. package/dist/components/cv-combobox-group.js +34 -0
  31. package/dist/components/cv-combobox-option.d.ts +30 -0
  32. package/dist/components/cv-combobox-option.js +66 -0
  33. package/dist/components/cv-combobox.d.ts +135 -0
  34. package/dist/components/cv-combobox.js +834 -0
  35. package/dist/components/cv-command-item.d.ts +30 -0
  36. package/dist/components/cv-command-item.js +68 -0
  37. package/dist/components/cv-command-palette.d.ts +105 -0
  38. package/dist/components/cv-command-palette.js +578 -0
  39. package/dist/components/cv-context-menu.d.ts +98 -0
  40. package/dist/components/cv-context-menu.js +515 -0
  41. package/dist/components/cv-copy-button.d.ts +61 -0
  42. package/dist/components/cv-copy-button.js +318 -0
  43. package/dist/components/cv-date-picker.d.ts +161 -0
  44. package/dist/components/cv-date-picker.js +803 -0
  45. package/dist/components/cv-dialog.d.ts +89 -0
  46. package/dist/components/cv-dialog.js +459 -0
  47. package/dist/components/cv-disclosure.d.ts +57 -0
  48. package/dist/components/cv-disclosure.js +241 -0
  49. package/dist/components/cv-drawer.d.ts +102 -0
  50. package/dist/components/cv-drawer.js +595 -0
  51. package/dist/components/cv-feed-article.d.ts +26 -0
  52. package/dist/components/cv-feed-article.js +52 -0
  53. package/dist/components/cv-feed.d.ts +62 -0
  54. package/dist/components/cv-feed.js +310 -0
  55. package/dist/components/cv-grid-cell.d.ts +30 -0
  56. package/dist/components/cv-grid-cell.js +57 -0
  57. package/dist/components/cv-grid-column.d.ts +30 -0
  58. package/dist/components/cv-grid-column.js +43 -0
  59. package/dist/components/cv-grid-row.d.ts +30 -0
  60. package/dist/components/cv-grid-row.js +42 -0
  61. package/dist/components/cv-grid.d.ts +119 -0
  62. package/dist/components/cv-grid.js +567 -0
  63. package/dist/components/cv-icon.d.ts +57 -0
  64. package/dist/components/cv-icon.js +352 -0
  65. package/dist/components/cv-input.d.ts +127 -0
  66. package/dist/components/cv-input.js +482 -0
  67. package/dist/components/cv-landmark.d.ts +32 -0
  68. package/dist/components/cv-landmark.js +62 -0
  69. package/dist/components/cv-link.d.ts +22 -0
  70. package/dist/components/cv-link.js +99 -0
  71. package/dist/components/cv-listbox-group.d.ts +15 -0
  72. package/dist/components/cv-listbox-group.js +42 -0
  73. package/dist/components/cv-listbox.d.ts +81 -0
  74. package/dist/components/cv-listbox.js +388 -0
  75. package/dist/components/cv-menu-button.d.ts +118 -0
  76. package/dist/components/cv-menu-button.js +822 -0
  77. package/dist/components/cv-menu-group.d.ts +20 -0
  78. package/dist/components/cv-menu-group.js +48 -0
  79. package/dist/components/cv-menu-item.d.ts +52 -0
  80. package/dist/components/cv-menu-item.js +105 -0
  81. package/dist/components/cv-menu.d.ts +62 -0
  82. package/dist/components/cv-menu.js +414 -0
  83. package/dist/components/cv-meter.d.ts +66 -0
  84. package/dist/components/cv-meter.js +154 -0
  85. package/dist/components/cv-number.d.ts +139 -0
  86. package/dist/components/cv-number.js +553 -0
  87. package/dist/components/cv-option.d.ts +30 -0
  88. package/dist/components/cv-option.js +84 -0
  89. package/dist/components/cv-popover.d.ts +87 -0
  90. package/dist/components/cv-popover.js +373 -0
  91. package/dist/components/cv-progress-ring.d.ts +45 -0
  92. package/dist/components/cv-progress-ring.js +169 -0
  93. package/dist/components/cv-progress.d.ts +45 -0
  94. package/dist/components/cv-progress.js +148 -0
  95. package/dist/components/cv-radio-group.d.ts +79 -0
  96. package/dist/components/cv-radio-group.js +398 -0
  97. package/dist/components/cv-radio.d.ts +36 -0
  98. package/dist/components/cv-radio.js +123 -0
  99. package/dist/components/cv-select-group.d.ts +15 -0
  100. package/dist/components/cv-select-group.js +44 -0
  101. package/dist/components/cv-select-option.d.ts +30 -0
  102. package/dist/components/cv-select-option.js +66 -0
  103. package/dist/components/cv-select.d.ts +128 -0
  104. package/dist/components/cv-select.js +666 -0
  105. package/dist/components/cv-sidebar-item.d.ts +26 -0
  106. package/dist/components/cv-sidebar-item.js +142 -0
  107. package/dist/components/cv-sidebar.d.ts +171 -0
  108. package/dist/components/cv-sidebar.js +767 -0
  109. package/dist/components/cv-slider-multi-thumb.d.ts +73 -0
  110. package/dist/components/cv-slider-multi-thumb.js +374 -0
  111. package/dist/components/cv-slider.d.ts +84 -0
  112. package/dist/components/cv-slider.js +328 -0
  113. package/dist/components/cv-spinbutton.d.ts +121 -0
  114. package/dist/components/cv-spinbutton.js +486 -0
  115. package/dist/components/cv-spinner.d.ts +18 -0
  116. package/dist/components/cv-spinner.js +95 -0
  117. package/dist/components/cv-switch.d.ts +81 -0
  118. package/dist/components/cv-switch.js +285 -0
  119. package/dist/components/cv-tab-panel.d.ts +20 -0
  120. package/dist/components/cv-tab-panel.js +37 -0
  121. package/dist/components/cv-tab.d.ts +40 -0
  122. package/dist/components/cv-tab.js +132 -0
  123. package/dist/components/cv-table-cell.d.ts +31 -0
  124. package/dist/components/cv-table-cell.js +49 -0
  125. package/dist/components/cv-table-column.d.ts +37 -0
  126. package/dist/components/cv-table-column.js +63 -0
  127. package/dist/components/cv-table-row.d.ts +30 -0
  128. package/dist/components/cv-table-row.js +45 -0
  129. package/dist/components/cv-table.d.ts +147 -0
  130. package/dist/components/cv-table.js +607 -0
  131. package/dist/components/cv-tabs.d.ts +70 -0
  132. package/dist/components/cv-tabs.js +524 -0
  133. package/dist/components/cv-textarea.d.ts +108 -0
  134. package/dist/components/cv-textarea.js +328 -0
  135. package/dist/components/cv-toast-region.d.ts +39 -0
  136. package/dist/components/cv-toast-region.js +162 -0
  137. package/dist/components/cv-toast.d.ts +67 -0
  138. package/dist/components/cv-toast.js +315 -0
  139. package/dist/components/cv-toolbar-item.d.ts +25 -0
  140. package/dist/components/cv-toolbar-item.js +72 -0
  141. package/dist/components/cv-toolbar-separator.d.ts +25 -0
  142. package/dist/components/cv-toolbar-separator.js +45 -0
  143. package/dist/components/cv-toolbar.d.ts +63 -0
  144. package/dist/components/cv-toolbar.js +295 -0
  145. package/dist/components/cv-tooltip.d.ts +83 -0
  146. package/dist/components/cv-tooltip.js +455 -0
  147. package/dist/components/cv-treegrid-cell.d.ts +30 -0
  148. package/dist/components/cv-treegrid-cell.js +57 -0
  149. package/dist/components/cv-treegrid-column.d.ts +37 -0
  150. package/dist/components/cv-treegrid-column.js +53 -0
  151. package/dist/components/cv-treegrid-row.d.ts +55 -0
  152. package/dist/components/cv-treegrid-row.js +90 -0
  153. package/dist/components/cv-treegrid.d.ts +96 -0
  154. package/dist/components/cv-treegrid.js +632 -0
  155. package/dist/components/cv-treeitem.d.ts +58 -0
  156. package/dist/components/cv-treeitem.js +144 -0
  157. package/dist/components/cv-treeview.d.ts +70 -0
  158. package/dist/components/cv-treeview.js +396 -0
  159. package/dist/components/cv-window-splitter.d.ts +79 -0
  160. package/dist/components/cv-window-splitter.js +316 -0
  161. package/dist/components/index.d.ts +94 -0
  162. package/dist/components/index.js +79 -0
  163. package/dist/dialog/create-dialog-controller.d.ts +31 -0
  164. package/dist/dialog/create-dialog-controller.js +320 -0
  165. package/dist/dialog/index.d.ts +2 -0
  166. package/dist/dialog/index.js +1 -0
  167. package/dist/form-associated/FormAssociatedReatomElement.d.ts +25 -0
  168. package/dist/form-associated/FormAssociatedReatomElement.js +70 -0
  169. package/dist/form-associated/withFormAssociated.d.ts +5 -0
  170. package/dist/form-associated/withFormAssociated.js +1 -0
  171. package/dist/index.d.ts +10 -0
  172. package/dist/index.js +9 -0
  173. package/dist/reatom-lit/ReatomLitElement.d.ts +27 -0
  174. package/dist/reatom-lit/ReatomLitElement.js +118 -0
  175. package/dist/reatom-lit/html.d.ts +4 -0
  176. package/dist/reatom-lit/html.js +10 -0
  177. package/dist/reatom-lit/index.d.ts +4 -0
  178. package/dist/reatom-lit/index.js +4 -0
  179. package/dist/reatom-lit/watch.d.ts +15 -0
  180. package/dist/reatom-lit/watch.js +40 -0
  181. package/dist/reatom-lit/withReatomElement.d.ts +4 -0
  182. package/dist/reatom-lit/withReatomElement.js +57 -0
  183. package/dist/register.d.ts +1 -0
  184. package/dist/register.js +84 -0
  185. package/dist/styles/component-styles.d.ts +4 -0
  186. package/dist/styles/component-styles.js +78 -0
  187. package/dist/theme/cv-theme-provider.d.ts +32 -0
  188. package/dist/theme/cv-theme-provider.js +110 -0
  189. package/dist/theme/index.d.ts +4 -0
  190. package/dist/theme/index.js +2 -0
  191. package/dist/theme/theme-engine.d.ts +4 -0
  192. package/dist/theme/theme-engine.js +67 -0
  193. package/dist/theme/tokens.css +265 -0
  194. package/dist/theme/types.d.ts +7 -0
  195. package/dist/theme/types.js +1 -0
  196. package/dist/toast/create-toast-controller.d.ts +12 -0
  197. package/dist/toast/create-toast-controller.js +12 -0
  198. package/dist/toast/index.d.ts +2 -0
  199. package/dist/toast/index.js +1 -0
  200. package/package.json +146 -0
  201. package/specs/_template.md +110 -0
  202. package/specs/components/accordion.md +207 -0
  203. package/specs/components/alert.md +83 -0
  204. package/specs/components/badge.md +183 -0
  205. package/specs/components/breadcrumb.md +152 -0
  206. package/specs/components/button.md +227 -0
  207. package/specs/components/callout.md +153 -0
  208. package/specs/components/card.md +192 -0
  209. package/specs/components/carousel.md +232 -0
  210. package/specs/components/checkbox.md +141 -0
  211. package/specs/components/combobox.md +427 -0
  212. package/specs/components/context-menu.md +375 -0
  213. package/specs/components/copy-button.md +236 -0
  214. package/specs/components/date-picker.md +290 -0
  215. package/specs/components/dialog.md +184 -0
  216. package/specs/components/disclosure.md +151 -0
  217. package/specs/components/drawer.md +216 -0
  218. package/specs/components/feed.md +266 -0
  219. package/specs/components/grid.md +423 -0
  220. package/specs/components/input.md +237 -0
  221. package/specs/components/landmark.md +92 -0
  222. package/specs/components/link.md +117 -0
  223. package/specs/components/listbox.md +327 -0
  224. package/specs/components/menu.md +508 -0
  225. package/specs/components/meter.md +148 -0
  226. package/specs/components/number.md +268 -0
  227. package/specs/components/option.md +167 -0
  228. package/specs/components/popover.md +207 -0
  229. package/specs/components/progress-ring.md +134 -0
  230. package/specs/components/progress.md +110 -0
  231. package/specs/components/radio.md +208 -0
  232. package/specs/components/select.md +305 -0
  233. package/specs/components/sidebar.md +204 -0
  234. package/specs/components/spinbutton.md +157 -0
  235. package/specs/components/spinner.md +83 -0
  236. package/specs/components/switch.md +145 -0
  237. package/specs/components/table.md +372 -0
  238. package/specs/components/tabs.md +242 -0
  239. package/specs/components/textarea.md +166 -0
  240. package/specs/components/theme.md +364 -0
  241. package/specs/components/toast.md +198 -0
  242. package/specs/components/toolbar.md +258 -0
  243. package/specs/components/tooltip.md +152 -0
  244. package/specs/components/treegrid.md +363 -0
  245. package/specs/components/treeview.md +263 -0
  246. package/specs/components/window-splitter.md +225 -0
@@ -0,0 +1,482 @@
1
+ import { createInput } from '@chromvoid/headless-ui/input';
2
+ import { css, html, nothing } from 'lit';
3
+ import { FormAssociatedReatomElement } from '../form-associated/FormAssociatedReatomElement.js';
4
+ let cvInputNonce = 0;
5
+ export class CVInput extends FormAssociatedReatomElement {
6
+ static elementName = 'cv-input';
7
+ static hostDisplay = 'inline-block';
8
+ static get properties() {
9
+ return {
10
+ value: { type: String },
11
+ type: { type: String },
12
+ placeholder: { type: String },
13
+ disabled: { type: Boolean, reflect: true },
14
+ readonly: { type: Boolean, reflect: true },
15
+ required: { type: Boolean, reflect: true },
16
+ clearable: { type: Boolean, reflect: true },
17
+ passwordToggle: { type: Boolean, reflect: true, attribute: 'password-toggle' },
18
+ size: { type: String, reflect: true },
19
+ variant: { type: String, reflect: true },
20
+ name: { type: String },
21
+ autofocus: { type: Boolean, reflect: true },
22
+ autocomplete: { type: String },
23
+ maxlength: { type: Number },
24
+ invalid: { type: Boolean, reflect: true },
25
+ };
26
+ }
27
+ model;
28
+ _valueOnFocus = '';
29
+ defaultValue = '';
30
+ didCaptureDefaultValue = false;
31
+ didAutoFocus = false;
32
+ constructor() {
33
+ super();
34
+ this.value = '';
35
+ this.type = 'text';
36
+ this.placeholder = '';
37
+ this.disabled = false;
38
+ this.readonly = false;
39
+ this.required = false;
40
+ this.clearable = false;
41
+ this.passwordToggle = false;
42
+ this.size = 'medium';
43
+ this.variant = 'outlined';
44
+ this.name = '';
45
+ this.autofocus = false;
46
+ this.autocomplete = '';
47
+ this.maxlength = undefined;
48
+ this.invalid = false;
49
+ this.model = this.createModel();
50
+ }
51
+ static styles = [
52
+ css `
53
+ :host {
54
+ --cv-input-height: 36px;
55
+ --cv-input-padding-inline: var(--cv-space-3, 12px);
56
+ --cv-input-font-size: var(--cv-font-size-base, 14px);
57
+ --cv-input-border-radius: var(--cv-radius-sm, 6px);
58
+ --cv-input-border-color: var(--cv-color-border, #2a3245);
59
+ --cv-input-background: transparent;
60
+ --cv-input-color: var(--cv-color-text, #e8ecf6);
61
+ --cv-input-placeholder-color: var(--cv-color-text-muted, #6b7a99);
62
+ --cv-input-focus-ring: 0 0 0 2px var(--cv-color-primary, #65d7ff);
63
+ --cv-input-icon-size: 1em;
64
+ --cv-input-gap: var(--cv-space-2, 8px);
65
+ --cv-input-transition-duration: var(--cv-duration-fast, 120ms);
66
+ }
67
+
68
+ [part='base'] {
69
+ gap: var(--cv-input-gap);
70
+ padding-inline: var(--cv-input-padding-inline);
71
+ height: var(--cv-input-height);
72
+ font-size: var(--cv-input-font-size);
73
+ border-radius: var(--cv-input-border-radius);
74
+ border: 1px solid var(--cv-input-border-color);
75
+ background: var(--cv-input-background);
76
+ color: var(--cv-input-color);
77
+ cursor: text;
78
+ transition:
79
+ border-color var(--cv-input-transition-duration) var(--cv-easing-standard, ease),
80
+ background var(--cv-input-transition-duration) var(--cv-easing-standard, ease),
81
+ box-shadow var(--cv-input-transition-duration) var(--cv-easing-standard, ease);
82
+ box-sizing: border-box;
83
+ width: 100%;
84
+ }
85
+
86
+ [part='input'] {
87
+ width: 100%;
88
+ border: none;
89
+ outline: none;
90
+ background: transparent;
91
+ color: inherit;
92
+ font: inherit;
93
+ padding: 0;
94
+ margin: 0;
95
+ }
96
+
97
+ [part='input']::placeholder {
98
+ color: var(--cv-input-placeholder-color);
99
+ }
100
+
101
+ [part='prefix'],
102
+ [part='suffix'],
103
+ [part='clear-button'],
104
+ [part='password-toggle'] {
105
+ font-size: var(--cv-input-icon-size);
106
+ }
107
+
108
+ [part='clear-button'],
109
+ [part='password-toggle'] {
110
+ cursor: pointer;
111
+ user-select: none;
112
+ }
113
+
114
+ [part='password-toggle-icon'] {
115
+ width: var(--cv-input-icon-size, 1em);
116
+ height: var(--cv-input-icon-size, 1em);
117
+ display: block;
118
+ }
119
+
120
+ [part='form-control-label'] {
121
+ display: block;
122
+ }
123
+
124
+ [part='form-control-help-text'] {
125
+ display: block;
126
+ }
127
+
128
+ /* --- variant: outlined (default) --- */
129
+ :host([variant='outlined']) [part='base'] {
130
+ border-color: var(--cv-input-border-color);
131
+ background: var(--cv-input-background);
132
+ }
133
+
134
+ /* --- variant: filled --- */
135
+ :host([variant='filled']) [part='base'] {
136
+ background: var(--cv-color-surface, #141923);
137
+ border-color: transparent;
138
+ }
139
+
140
+ /* --- focused --- */
141
+ :host([focused]) [part='base'] {
142
+ box-shadow: var(--cv-input-focus-ring);
143
+ }
144
+
145
+ :host([invalid]) [part='base'] {
146
+ border-color: var(--cv-color-danger, #ef4444);
147
+ }
148
+
149
+ :host([invalid][focused]) [part='base'] {
150
+ box-shadow: 0 0 0 2px color-mix(in oklch, var(--cv-color-danger, #ef4444) 35%, transparent);
151
+ }
152
+
153
+ /* --- sizes --- */
154
+ :host([size='small']) {
155
+ --cv-input-height: 30px;
156
+ --cv-input-padding-inline: var(--cv-space-2, 8px);
157
+ --cv-input-font-size: var(--cv-font-size-sm, 13px);
158
+ }
159
+
160
+ :host([size='large']) {
161
+ --cv-input-height: 42px;
162
+ --cv-input-padding-inline: var(--cv-space-4, 16px);
163
+ --cv-input-font-size: var(--cv-font-size-md, 16px);
164
+ }
165
+
166
+ /* --- disabled --- */
167
+ :host([disabled]) [part='base'] {
168
+ opacity: 0.55;
169
+ cursor: not-allowed;
170
+ }
171
+
172
+ :host([disabled]) [part='input'] {
173
+ cursor: not-allowed;
174
+ }
175
+
176
+ /* --- readonly --- */
177
+ :host([readonly]) [part='base'] {
178
+ cursor: default;
179
+ }
180
+
181
+ :host([readonly]) [part='input'] {
182
+ cursor: default;
183
+ }
184
+ `,
185
+ ];
186
+ static define() {
187
+ if (!customElements.get(this.elementName)) {
188
+ customElements.define(this.elementName, this);
189
+ }
190
+ }
191
+ connectedCallback() {
192
+ super.connectedCallback();
193
+ if (!this.didCaptureDefaultValue) {
194
+ this.defaultValue = this.value;
195
+ this.didCaptureDefaultValue = true;
196
+ }
197
+ }
198
+ updated(changedProperties) {
199
+ super.updated(changedProperties);
200
+ if ((changedProperties.has('autofocus') || changedProperties.size === 0) && this.autofocus) {
201
+ this.scheduleAutofocus();
202
+ }
203
+ }
204
+ willUpdate(changedProperties) {
205
+ super.willUpdate(changedProperties);
206
+ if (changedProperties.has('value') && this.model.state.value() !== this.value) {
207
+ this.model.actions.setValue(this.value);
208
+ }
209
+ if (changedProperties.has('type')) {
210
+ this.model.actions.setType(this.type);
211
+ }
212
+ if (changedProperties.has('disabled')) {
213
+ this.model.actions.setDisabled(this.isEffectivelyDisabled());
214
+ }
215
+ if (changedProperties.has('readonly')) {
216
+ this.model.actions.setReadonly(this.readonly);
217
+ }
218
+ if (changedProperties.has('required')) {
219
+ this.model.actions.setRequired(this.required);
220
+ }
221
+ if (changedProperties.has('placeholder')) {
222
+ this.model.actions.setPlaceholder(this.placeholder);
223
+ }
224
+ if (changedProperties.has('clearable')) {
225
+ this.model.actions.setClearable(this.clearable);
226
+ }
227
+ if (changedProperties.has('passwordToggle')) {
228
+ this.model.actions.setPasswordToggle(this.passwordToggle);
229
+ }
230
+ // Reflect headless state to host attributes
231
+ this.toggleAttribute('focused', this.model.state.focused());
232
+ this.toggleAttribute('filled', this.model.state.filled());
233
+ this.syncFormAssociatedState();
234
+ }
235
+ onFormDisabledChanged(_disabled) {
236
+ this.model.actions.setDisabled(this.isEffectivelyDisabled());
237
+ }
238
+ onFormReset() {
239
+ this.value = this.defaultValue;
240
+ this.model.actions.setValue(this.defaultValue);
241
+ }
242
+ onFormStateRestore(state) {
243
+ if (typeof state !== 'string')
244
+ return;
245
+ this.value = state;
246
+ this.model.actions.setValue(state);
247
+ }
248
+ focus(options) {
249
+ const input = this.shadowRoot?.querySelector('[part="input"]');
250
+ if (input) {
251
+ input.focus(options);
252
+ return;
253
+ }
254
+ super.focus(options);
255
+ }
256
+ select() {
257
+ const input = this.shadowRoot?.querySelector('[part="input"]');
258
+ input?.select();
259
+ }
260
+ createModel() {
261
+ return createInput({
262
+ idBase: `cv-input-${++cvInputNonce}`,
263
+ value: this.value,
264
+ type: this.type,
265
+ disabled: this.isEffectivelyDisabled(),
266
+ readonly: this.readonly,
267
+ required: this.required,
268
+ placeholder: this.placeholder,
269
+ clearable: this.clearable,
270
+ passwordToggle: this.passwordToggle,
271
+ onInput: (value) => {
272
+ this.value = value;
273
+ this.dispatchEvent(new CustomEvent('cv-input', {
274
+ detail: { value },
275
+ bubbles: true,
276
+ composed: true,
277
+ }));
278
+ },
279
+ onClear: () => {
280
+ this.value = '';
281
+ this.dispatchEvent(new CustomEvent('cv-clear', {
282
+ detail: {},
283
+ bubbles: true,
284
+ composed: true,
285
+ }));
286
+ },
287
+ });
288
+ }
289
+ isEffectivelyDisabled() {
290
+ return this.disabled || this.formDisabled;
291
+ }
292
+ isFormAssociatedDisabled() {
293
+ return this.isEffectivelyDisabled();
294
+ }
295
+ getFormAssociatedValue() {
296
+ return this.model.state.value();
297
+ }
298
+ getFormAssociatedValidity() {
299
+ const value = this.model.state.value();
300
+ if (this.invalid) {
301
+ return {
302
+ flags: { customError: true },
303
+ message: 'Invalid value',
304
+ };
305
+ }
306
+ if (this.required && value.length === 0) {
307
+ return {
308
+ flags: { valueMissing: true },
309
+ message: 'Please fill out this field.',
310
+ };
311
+ }
312
+ return { flags: {} };
313
+ }
314
+ scheduleAutofocus() {
315
+ if (this.didAutoFocus || !this.autofocus || this.isEffectivelyDisabled())
316
+ return;
317
+ this.didAutoFocus = true;
318
+ queueMicrotask(() => {
319
+ this.focus({ preventScroll: true });
320
+ });
321
+ }
322
+ handleNativeInput(event) {
323
+ const target = event.target;
324
+ this.model.actions.handleInput(target.value);
325
+ this.syncFormAssociatedState();
326
+ }
327
+ handleNativeFocus() {
328
+ this._valueOnFocus = this.model.state.value();
329
+ this.model.actions.setFocused(true);
330
+ this.requestUpdate();
331
+ this.dispatchEvent(new CustomEvent('cv-focus', {
332
+ detail: {},
333
+ bubbles: true,
334
+ composed: true,
335
+ }));
336
+ }
337
+ handleNativeBlur() {
338
+ this.model.actions.setFocused(false);
339
+ this.requestUpdate();
340
+ const currentValue = this.model.state.value();
341
+ this.dispatchEvent(new CustomEvent('cv-blur', {
342
+ detail: {},
343
+ bubbles: true,
344
+ composed: true,
345
+ }));
346
+ if (currentValue !== this._valueOnFocus) {
347
+ this.dispatchEvent(new CustomEvent('cv-change', {
348
+ detail: { value: currentValue },
349
+ bubbles: true,
350
+ composed: true,
351
+ }));
352
+ }
353
+ this.syncFormAssociatedState();
354
+ }
355
+ handleNativeKeyDown(event) {
356
+ if (event.key === 'Enter' &&
357
+ !event.defaultPrevented &&
358
+ !event.shiftKey &&
359
+ !event.altKey &&
360
+ !event.ctrlKey &&
361
+ !event.metaKey) {
362
+ const form = this.form ?? this.closest('form');
363
+ if (form) {
364
+ event.preventDefault();
365
+ form.requestSubmit();
366
+ }
367
+ }
368
+ const wasFilled = this.model.state.filled();
369
+ this.model.actions.handleKeyDown(event);
370
+ // If Escape cleared the value, the onClear callback already dispatched cv-clear
371
+ // but we need to sync the local value
372
+ if (wasFilled && !this.model.state.filled()) {
373
+ this.value = '';
374
+ }
375
+ this.syncFormAssociatedState();
376
+ }
377
+ handleClearClick() {
378
+ this.model.actions.clear();
379
+ // onClear callback handles the cv-clear event dispatch and value sync
380
+ this.value = this.model.state.value();
381
+ this.syncFormAssociatedState();
382
+ }
383
+ handlePasswordToggleClick() {
384
+ this.model.actions.togglePasswordVisibility();
385
+ this.requestUpdate();
386
+ }
387
+ render() {
388
+ const inputProps = this.model.contracts.getInputProps();
389
+ const clearButtonProps = this.model.contracts.getClearButtonProps();
390
+ const passwordToggleProps = this.model.contracts.getPasswordToggleProps();
391
+ const passwordVisible = this.model.state.passwordVisible();
392
+ const resolvedAutocomplete = this.autocomplete || inputProps.autocomplete;
393
+ const maxLength = typeof this.maxlength === 'number' && Number.isFinite(this.maxlength) ? this.maxlength : null;
394
+ return html `
395
+ <span part="form-control-label"><slot name="label"></slot></span>
396
+ <div part="base" class="cv-u-control-shell">
397
+ <span part="prefix" class="cv-u-icon-slot"><slot name="prefix"></slot></span>
398
+ <input
399
+ part="input"
400
+ class="cv-u-fill"
401
+ id=${inputProps.id}
402
+ type=${inputProps.type}
403
+ .value=${this.model.state.value()}
404
+ tabindex=${inputProps.tabindex}
405
+ aria-disabled=${inputProps['aria-disabled'] ?? nothing}
406
+ aria-readonly=${inputProps['aria-readonly'] ?? nothing}
407
+ aria-required=${inputProps['aria-required'] ?? nothing}
408
+ aria-invalid=${this.invalid ? 'true' : nothing}
409
+ placeholder=${inputProps.placeholder ?? nothing}
410
+ name=${this.name || nothing}
411
+ maxlength=${maxLength ?? nothing}
412
+ ?disabled=${inputProps.disabled}
413
+ ?readonly=${inputProps.readonly}
414
+ autocomplete=${resolvedAutocomplete ?? nothing}
415
+ @input=${this.handleNativeInput}
416
+ @focus=${this.handleNativeFocus}
417
+ @blur=${this.handleNativeBlur}
418
+ @keydown=${this.handleNativeKeyDown}
419
+ />
420
+ <span
421
+ part="clear-button"
422
+ class="cv-u-icon-slot"
423
+ role=${clearButtonProps.role}
424
+ aria-label=${clearButtonProps['aria-label']}
425
+ tabindex=${clearButtonProps.tabindex}
426
+ ?hidden=${clearButtonProps.hidden}
427
+ aria-hidden=${clearButtonProps['aria-hidden'] ?? nothing}
428
+ @click=${this.handleClearClick}
429
+ >
430
+ <slot name="clear-icon">&times;</slot>
431
+ </span>
432
+ <span
433
+ part="password-toggle"
434
+ class="cv-u-icon-slot"
435
+ role=${passwordToggleProps.role}
436
+ aria-label=${passwordToggleProps['aria-label']}
437
+ aria-pressed=${passwordToggleProps['aria-pressed']}
438
+ tabindex=${passwordToggleProps.tabindex}
439
+ ?hidden=${passwordToggleProps.hidden}
440
+ aria-hidden=${passwordToggleProps['aria-hidden'] ?? nothing}
441
+ @click=${this.handlePasswordToggleClick}
442
+ >
443
+ ${passwordVisible
444
+ ? html `
445
+ <slot name="hide-password-icon"
446
+ ><svg
447
+ part="password-toggle-icon"
448
+ viewBox="0 0 24 24"
449
+ fill="none"
450
+ stroke="currentColor"
451
+ stroke-width="2"
452
+ stroke-linecap="round"
453
+ stroke-linejoin="round"
454
+ >
455
+ <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94" />
456
+ <path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19" />
457
+ <path d="M14.12 14.12a3 3 0 1 1-4.24-4.24" />
458
+ <line x1="1" y1="1" x2="23" y2="23" /></svg
459
+ ></slot>
460
+ `
461
+ : html `
462
+ <slot name="show-password-icon"
463
+ ><svg
464
+ part="password-toggle-icon"
465
+ viewBox="0 0 24 24"
466
+ fill="none"
467
+ stroke="currentColor"
468
+ stroke-width="2"
469
+ stroke-linecap="round"
470
+ stroke-linejoin="round"
471
+ >
472
+ <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
473
+ <circle cx="12" cy="12" r="3" /></svg
474
+ ></slot>
475
+ `}
476
+ </span>
477
+ <span part="suffix" class="cv-u-icon-slot"><slot name="suffix"></slot></span>
478
+ </div>
479
+ <span part="form-control-help-text"><slot name="help-text"></slot></span>
480
+ `;
481
+ }
482
+ }
@@ -0,0 +1,32 @@
1
+ import { type LandmarkType } from '@chromvoid/headless-ui/landmarks';
2
+ import type { PropertyValues } from 'lit';
3
+ import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
4
+ export declare class CVLandmark extends ReatomLitElement {
5
+ static elementName: string;
6
+ static get properties(): {
7
+ type: {
8
+ type: StringConstructor;
9
+ reflect: boolean;
10
+ };
11
+ label: {
12
+ type: StringConstructor;
13
+ reflect: boolean;
14
+ };
15
+ labelId: {
16
+ type: StringConstructor;
17
+ attribute: string;
18
+ reflect: boolean;
19
+ };
20
+ };
21
+ type: LandmarkType;
22
+ label: string;
23
+ labelId: string;
24
+ private readonly idBase;
25
+ private model;
26
+ constructor();
27
+ static styles: import("lit").CSSResult[];
28
+ static define(): void;
29
+ willUpdate(changedProperties: PropertyValues): void;
30
+ private createModel;
31
+ protected render(): import("lit").TemplateResult<1>;
32
+ }
@@ -0,0 +1,62 @@
1
+ import { createLandmark } from '@chromvoid/headless-ui/landmarks';
2
+ import { css, html, nothing } from 'lit';
3
+ import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
4
+ let cvLandmarkNonce = 0;
5
+ export class CVLandmark extends ReatomLitElement {
6
+ static elementName = 'cv-landmark';
7
+ static get properties() {
8
+ return {
9
+ type: { type: String, reflect: true },
10
+ label: { type: String, reflect: true },
11
+ labelId: { type: String, attribute: 'label-id', reflect: true },
12
+ };
13
+ }
14
+ idBase = `cv-landmark-${++cvLandmarkNonce}`;
15
+ model;
16
+ constructor() {
17
+ super();
18
+ this.type = 'region';
19
+ this.label = '';
20
+ this.labelId = '';
21
+ this.model = this.createModel();
22
+ }
23
+ static styles = [
24
+ css `
25
+ :host {
26
+ display: block;
27
+ }
28
+ `,
29
+ ];
30
+ static define() {
31
+ if (!customElements.get(this.elementName)) {
32
+ customElements.define(this.elementName, this);
33
+ }
34
+ }
35
+ willUpdate(changedProperties) {
36
+ super.willUpdate(changedProperties);
37
+ if (changedProperties.has('type') || changedProperties.has('label') || changedProperties.has('labelId')) {
38
+ this.model = this.createModel();
39
+ }
40
+ }
41
+ createModel() {
42
+ return createLandmark({
43
+ idBase: this.idBase,
44
+ type: this.type,
45
+ label: this.label || undefined,
46
+ labelId: this.labelId || undefined,
47
+ });
48
+ }
49
+ render() {
50
+ const props = this.model.contracts.getLandmarkProps();
51
+ return html `
52
+ <section
53
+ role=${props.role}
54
+ aria-label=${props['aria-label'] ?? nothing}
55
+ aria-labelledby=${props['aria-labelledby'] ?? nothing}
56
+ part="base"
57
+ >
58
+ <slot></slot>
59
+ </section>
60
+ `;
61
+ }
62
+ }
@@ -0,0 +1,22 @@
1
+ import type { PropertyValues } from 'lit';
2
+ import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
3
+ export declare class CVLink extends ReatomLitElement {
4
+ static elementName: string;
5
+ static get properties(): {
6
+ href: {
7
+ type: StringConstructor;
8
+ reflect: boolean;
9
+ };
10
+ };
11
+ href: string;
12
+ private readonly idBase;
13
+ private model;
14
+ constructor();
15
+ static styles: import("lit").CSSResult[];
16
+ static define(): void;
17
+ willUpdate(changedProperties: PropertyValues): void;
18
+ private createModel;
19
+ private handleClick;
20
+ private handleKeyDown;
21
+ protected render(): import("lit").TemplateResult<1>;
22
+ }
@@ -0,0 +1,99 @@
1
+ import { createLink } from '@chromvoid/headless-ui/link';
2
+ import { css, html, nothing } from 'lit';
3
+ import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
4
+ let cvLinkNonce = 0;
5
+ export class CVLink extends ReatomLitElement {
6
+ static elementName = 'cv-link';
7
+ static get properties() {
8
+ return {
9
+ href: { type: String, reflect: true },
10
+ };
11
+ }
12
+ idBase = `cv-link-${++cvLinkNonce}`;
13
+ model;
14
+ constructor() {
15
+ super();
16
+ this.href = '';
17
+ this.model = this.createModel();
18
+ }
19
+ static styles = [
20
+ css `
21
+ :host {
22
+ display: inline-block;
23
+ }
24
+
25
+ [part='base'] {
26
+ display: inline-flex;
27
+ align-items: center;
28
+ gap: var(--cv-link-gap, var(--cv-space-1, 4px));
29
+ color: var(--cv-link-color, var(--cv-color-primary, #65d7ff));
30
+ text-decoration: var(--cv-link-text-decoration, underline);
31
+ text-underline-offset: 3px;
32
+ text-decoration-thickness: 1px;
33
+ transition: color var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease);
34
+ }
35
+
36
+ :host(:hover) [part='base'] {
37
+ color: var(--cv-link-color-hover, color-mix(in oklab, var(--cv-color-primary, #65d7ff) 78%, white));
38
+ text-decoration: var(--cv-link-text-decoration-hover, none);
39
+ }
40
+
41
+ :host(:active) [part='base'] {
42
+ color: var(--cv-link-color-active, color-mix(in oklab, var(--cv-color-primary, #65d7ff) 60%, white));
43
+ }
44
+
45
+ [part='base']:focus-visible {
46
+ outline: 2px solid var(--cv-link-outline-color, var(--cv-color-primary, #65d7ff));
47
+ outline-offset: var(--cv-link-outline-offset, 2px);
48
+ border-radius: 4px;
49
+ }
50
+ `,
51
+ ];
52
+ static define() {
53
+ if (!customElements.get(this.elementName)) {
54
+ customElements.define(this.elementName, this);
55
+ }
56
+ }
57
+ willUpdate(changedProperties) {
58
+ super.willUpdate(changedProperties);
59
+ if (changedProperties.has('href')) {
60
+ this.model = this.createModel();
61
+ }
62
+ }
63
+ createModel() {
64
+ return createLink({
65
+ idBase: this.idBase,
66
+ href: this.href || undefined,
67
+ isSemanticHost: true,
68
+ onPress: () => {
69
+ this.dispatchEvent(new CustomEvent('press', {
70
+ detail: { href: this.href },
71
+ bubbles: true,
72
+ composed: true,
73
+ }));
74
+ },
75
+ });
76
+ }
77
+ handleClick(event) {
78
+ this.model.contracts.getLinkProps().onClick(event);
79
+ }
80
+ handleKeyDown(event) {
81
+ this.model.contracts.getLinkProps().onKeyDown(event);
82
+ }
83
+ render() {
84
+ const props = this.model.contracts.getLinkProps();
85
+ return html `
86
+ <a
87
+ id=${props.id}
88
+ href=${props.href ?? nothing}
89
+ part="base"
90
+ @click=${this.handleClick}
91
+ @keydown=${this.handleKeyDown}
92
+ >
93
+ <span part="prefix"><slot name="prefix"></slot></span>
94
+ <span part="label"><slot></slot></span>
95
+ <span part="suffix"><slot name="suffix"></slot></span>
96
+ </a>
97
+ `;
98
+ }
99
+ }