@joralvmel/cosmos-elements 0.2.0 → 0.4.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 (71) hide show
  1. package/README.md +15 -0
  2. package/dist/components/badge/cosm-badge.d.ts +64 -0
  3. package/dist/components/badge/cosm-badge.d.ts.map +1 -0
  4. package/dist/components/badge/cosm-badge.js +162 -0
  5. package/dist/components/badge/cosm-badge.js.map +1 -0
  6. package/dist/components/button/cosm-button.d.ts.map +1 -1
  7. package/dist/components/button/cosm-button.js +2 -0
  8. package/dist/components/button/cosm-button.js.map +1 -1
  9. package/dist/components/calendar/cosm-calendar.d.ts +77 -0
  10. package/dist/components/calendar/cosm-calendar.d.ts.map +1 -0
  11. package/dist/components/calendar/cosm-calendar.js +696 -0
  12. package/dist/components/calendar/cosm-calendar.js.map +1 -0
  13. package/dist/components/checkbox/cosm-checkbox.d.ts +122 -0
  14. package/dist/components/checkbox/cosm-checkbox.d.ts.map +1 -0
  15. package/dist/components/checkbox/cosm-checkbox.js +433 -0
  16. package/dist/components/checkbox/cosm-checkbox.js.map +1 -0
  17. package/dist/components/dialog/cosm-dialog.d.ts +103 -0
  18. package/dist/components/dialog/cosm-dialog.d.ts.map +1 -0
  19. package/dist/components/dialog/cosm-dialog.js +497 -0
  20. package/dist/components/dialog/cosm-dialog.js.map +1 -0
  21. package/dist/components/icon/cosm-icon.d.ts +7 -15
  22. package/dist/components/icon/cosm-icon.d.ts.map +1 -1
  23. package/dist/components/icon/cosm-icon.js +29 -30
  24. package/dist/components/icon/cosm-icon.js.map +1 -1
  25. package/dist/components/icon-button/cosm-icon-button.d.ts +79 -0
  26. package/dist/components/icon-button/cosm-icon-button.d.ts.map +1 -0
  27. package/dist/components/icon-button/cosm-icon-button.js +212 -0
  28. package/dist/components/icon-button/cosm-icon-button.js.map +1 -0
  29. package/dist/components/listbox/cosm-listbox.d.ts +136 -0
  30. package/dist/components/listbox/cosm-listbox.d.ts.map +1 -0
  31. package/dist/components/listbox/cosm-listbox.js +565 -0
  32. package/dist/components/listbox/cosm-listbox.js.map +1 -0
  33. package/dist/components/pagination/cosm-pagination.d.ts +118 -0
  34. package/dist/components/pagination/cosm-pagination.d.ts.map +1 -0
  35. package/dist/components/pagination/cosm-pagination.js +315 -0
  36. package/dist/components/pagination/cosm-pagination.js.map +1 -0
  37. package/dist/components/popover/cosm-popover.d.ts +100 -0
  38. package/dist/components/popover/cosm-popover.d.ts.map +1 -0
  39. package/dist/components/popover/cosm-popover.js +776 -0
  40. package/dist/components/popover/cosm-popover.js.map +1 -0
  41. package/dist/components/radio-group/cosm-radio-group.d.ts +111 -0
  42. package/dist/components/radio-group/cosm-radio-group.d.ts.map +1 -0
  43. package/dist/components/radio-group/cosm-radio-group.js +478 -0
  44. package/dist/components/radio-group/cosm-radio-group.js.map +1 -0
  45. package/dist/components/select/cosm-select.d.ts +126 -0
  46. package/dist/components/select/cosm-select.d.ts.map +1 -0
  47. package/dist/components/select/cosm-select.js +682 -0
  48. package/dist/components/select/cosm-select.js.map +1 -0
  49. package/dist/components/switch/cosm-switch.d.ts +103 -0
  50. package/dist/components/switch/cosm-switch.d.ts.map +1 -0
  51. package/dist/components/switch/cosm-switch.js +359 -0
  52. package/dist/components/switch/cosm-switch.js.map +1 -0
  53. package/dist/components/text-field/cosm-text-field.d.ts +193 -0
  54. package/dist/components/text-field/cosm-text-field.d.ts.map +1 -0
  55. package/dist/components/text-field/cosm-text-field.js +642 -0
  56. package/dist/components/text-field/cosm-text-field.js.map +1 -0
  57. package/dist/components/textarea/cosm-textarea.d.ts +131 -0
  58. package/dist/components/textarea/cosm-textarea.d.ts.map +1 -0
  59. package/dist/components/textarea/cosm-textarea.js +445 -0
  60. package/dist/components/textarea/cosm-textarea.js.map +1 -0
  61. package/dist/custom-elements.json +7605 -78
  62. package/dist/index.d.ts +14 -1
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +13 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/internal/current-page.d.ts +7 -0
  67. package/dist/internal/current-page.d.ts.map +1 -0
  68. package/dist/internal/current-page.js +18 -0
  69. package/dist/internal/current-page.js.map +1 -0
  70. package/llms.md +455 -7
  71. package/package.json +55 -3
@@ -0,0 +1,642 @@
1
+ import { getTextFieldState, textFieldContract, } from '@joralvmel/cosmos-core';
2
+ import { isIconDefinition } from '@joralvmel/cosmos-icons';
3
+ import { eye } from '@joralvmel/cosmos-icons/eye';
4
+ import { eyeOff } from '@joralvmel/cosmos-icons/eye-off';
5
+ import { x } from '@joralvmel/cosmos-icons/x';
6
+ import { css, html, LitElement, nothing } from 'lit';
7
+ import { CosmElement } from '../../internal/cosm-element.js';
8
+ import { define } from '../../internal/define.js';
9
+ import { boxSizing, focusRing } from '../../internal/styles.js';
10
+ import '../icon/cosm-icon.js';
11
+ let instance = 0;
12
+ const styles = css `
13
+ :host {
14
+ --_height: var(--cosm-control-md, 2.5rem);
15
+ --_font-size: var(--cosm-text-sm, 0.875rem);
16
+ display: block;
17
+ inline-size: 20ch;
18
+ min-inline-size: 0;
19
+ max-inline-size: 100%;
20
+ color: var(--cosm-text-field-color, var(--cosm-fg, oklch(0.24 0.01 268)));
21
+ font-family: var(--cosm-font-sans, system-ui, sans-serif);
22
+ }
23
+ :host([size='sm']) {
24
+ --_height: var(--cosm-control-sm, 2rem);
25
+ --_font-size: var(--cosm-text-xs, 0.75rem);
26
+ }
27
+ :host([size='lg']) {
28
+ --_height: var(--cosm-control-lg, 3rem);
29
+ --_font-size: var(--cosm-text-md, 1rem);
30
+ }
31
+ .label {
32
+ display: block;
33
+ overflow-wrap: anywhere;
34
+ margin-block-end: var(--cosm-space-xs, 0.25rem);
35
+ font-size: var(--cosm-text-sm, 0.875rem);
36
+ font-weight: var(--cosm-weight-medium, 500);
37
+ }
38
+ .label-hidden {
39
+ position: absolute;
40
+ width: 1px;
41
+ height: 1px;
42
+ overflow: hidden;
43
+ clip: rect(0, 0, 0, 0);
44
+ white-space: nowrap;
45
+ clip-path: inset(50%);
46
+ }
47
+ .control {
48
+ display: flex;
49
+ min-inline-size: 0;
50
+ align-items: center;
51
+ gap: var(--cosm-space-sm, 0.5rem);
52
+ min-height: var(--_height);
53
+ padding-inline: var(--cosm-space-md, 0.75rem);
54
+ border: 1px solid
55
+ var(--cosm-text-field-border, var(--cosm-border-strong, oklch(0.64 0.01 268)));
56
+ border-radius: var(--cosm-text-field-radius, var(--cosm-radius-md, 0.5rem));
57
+ background: var(--cosm-text-field-background, var(--cosm-bg, oklch(0.985 0.007 268)));
58
+ transition: border-color var(--cosm-duration-fast, 120ms) var(--cosm-easing-standard, ease);
59
+ }
60
+ :host([variant='filled']) .control {
61
+ border-color: var(--cosm-text-field-border, var(--cosm-border-strong, oklch(0.64 0.01 268)));
62
+ background: var(--cosm-text-field-background, var(--cosm-neutral-2, oklch(0.96 0.008 268)));
63
+ }
64
+ :host([invalid]) .control,
65
+ .control[data-invalid='true'] {
66
+ border-color: var(--cosm-danger, oklch(0.55 0.16 19));
67
+ }
68
+ @media (hover: hover) {
69
+ :host .control:hover:where(:has(input:not(:disabled))):where(:not([data-invalid='true'])) {
70
+ border-color: var(--cosm-text-field-border, var(--cosm-primary, oklch(0.55 0.2 268)));
71
+ }
72
+ }
73
+ :host .control:focus-within {
74
+ border-color: var(--cosm-text-field-focus, var(--cosm-focus-ring, oklch(0.55 0.2 268)));
75
+ background: var(
76
+ --cosm-text-field-background,
77
+ var(--cosm-primary-subtle, oklch(0.94 0.024 268))
78
+ );
79
+ box-shadow: inset 0 0 0 1px
80
+ var(--cosm-text-field-focus, var(--cosm-focus-ring, oklch(0.55 0.2 268)));
81
+ }
82
+ .decoration {
83
+ display: inline-flex;
84
+ flex: 0 1 auto;
85
+ min-inline-size: 0;
86
+ max-inline-size: 25%;
87
+ align-items: center;
88
+ gap: var(--cosm-space-xs, 0.25rem);
89
+ color: var(--cosm-text-field-color, var(--cosm-fg-muted, oklch(0.48 0.01 268)));
90
+ font-size: var(--_font-size);
91
+ white-space: nowrap;
92
+ }
93
+ .decoration cosm-icon {
94
+ flex: none;
95
+ width: 1.25em;
96
+ height: 1.25em;
97
+ }
98
+ .start-icon {
99
+ color: var(--cosm-text-field-start-icon-color, inherit);
100
+ }
101
+ .end-icon {
102
+ color: var(--cosm-text-field-end-icon-color, inherit);
103
+ }
104
+ .affix {
105
+ min-inline-size: 0;
106
+ overflow: hidden;
107
+ text-overflow: ellipsis;
108
+ }
109
+ input {
110
+ flex: 1;
111
+ min-width: 0;
112
+ min-height: var(--_height);
113
+ padding: 0;
114
+ border: 0;
115
+ outline: 0;
116
+ background: transparent;
117
+ color: var(--cosm-text-field-color, var(--cosm-fg, oklch(0.24 0.01 268)));
118
+ font: inherit;
119
+ font-size: var(--_font-size);
120
+ }
121
+ input::placeholder {
122
+ color: var(--cosm-text-field-placeholder, var(--cosm-fg-muted, oklch(0.48 0.01 268)));
123
+ opacity: 1;
124
+ }
125
+ :host([clearable]) input[type='search']::-webkit-search-cancel-button {
126
+ -webkit-appearance: none;
127
+ }
128
+ input:focus-visible {
129
+ outline: none;
130
+ }
131
+ .action {
132
+ display: inline-grid;
133
+ flex: none;
134
+ width: max(2rem, var(--_height));
135
+ min-height: max(2rem, var(--_height));
136
+ place-items: center;
137
+ padding: 0;
138
+ border: 0;
139
+ border-radius: var(--cosm-radius-sm, 0.25rem);
140
+ background: transparent;
141
+ color: inherit;
142
+ font: inherit;
143
+ cursor: pointer;
144
+ }
145
+ .action:hover {
146
+ color: var(--cosm-primary-text, oklch(0.45 0.17 268));
147
+ }
148
+ .action:disabled {
149
+ cursor: not-allowed;
150
+ }
151
+ .message {
152
+ display: block;
153
+ overflow-wrap: anywhere;
154
+ margin-block-start: var(--cosm-space-xs, 0.25rem);
155
+ color: var(--cosm-fg-muted, oklch(0.48 0.01 268));
156
+ font-size: var(--cosm-text-xs, 0.75rem);
157
+ }
158
+ .error {
159
+ color: var(--cosm-danger-text, var(--cosm-danger, oklch(0.48 0.14 19)));
160
+ }
161
+ :host([disabled]) {
162
+ opacity: 0.58;
163
+ }
164
+ @media (forced-colors: active) {
165
+ :host .control:focus-within {
166
+ border-color: Highlight;
167
+ outline: 2px solid Highlight;
168
+ outline-offset: -2px;
169
+ box-shadow: none;
170
+ }
171
+ }
172
+ @media (prefers-reduced-motion: reduce) {
173
+ .control {
174
+ transition: none;
175
+ }
176
+ }
177
+ `;
178
+ /**
179
+ * Labeled, single-line text entry with native browser constraints and form association.
180
+ *
181
+ * @tag cosm-text-field
182
+ * @slot - No content slot; use `label`, `helperText` and `errorText` text properties.
183
+ * @csspart label - The visible or visually hidden label.
184
+ * @csspart control - The visual input control.
185
+ * @csspart input - The editable native input.
186
+ * @csspart start - Start icon or prefix decoration.
187
+ * @csspart end - End icon, suffix or action region.
188
+ * @csspart help - Supporting helper text.
189
+ * @csspart error - External or browser constraint error text.
190
+ * @csspart clear-button - Optional accessible clear action.
191
+ * @csspart reveal-button - Optional accessible password visibility action.
192
+ * @fires {CustomEvent<TextFieldChangeDetail>} cosm-change - A value edit or clear proposal.
193
+ * @fires {CustomEvent<TextFieldSubmitDetail>} cosm-submit - The user invoked the submit action.
194
+ * @cssprop --cosm-text-field-background - Control background.
195
+ * @cssprop --cosm-text-field-color - Editable and decoration text color.
196
+ * @cssprop --cosm-text-field-placeholder - Placeholder text color.
197
+ * @cssprop --cosm-text-field-border - Control boundary color.
198
+ * @cssprop --cosm-text-field-focus - Focus indicator color.
199
+ * @cssprop --cosm-text-field-radius - Control corner radius.
200
+ * @cssprop --cosm-text-field-start-icon-color - Start icon color.
201
+ * @cssprop --cosm-text-field-end-icon-color - End icon color.
202
+ */
203
+ export class CosmTextField extends CosmElement {
204
+ static formAssociated = true;
205
+ static shadowRootOptions = {
206
+ ...LitElement.shadowRootOptions,
207
+ delegatesFocus: true,
208
+ };
209
+ static properties = {
210
+ label: {},
211
+ labelHidden: { type: Boolean, reflect: true, attribute: 'label-hidden' },
212
+ value: {},
213
+ defaultValue: { attribute: 'default-value' },
214
+ type: { reflect: true },
215
+ variant: { reflect: true },
216
+ size: { reflect: true },
217
+ placeholder: {},
218
+ helperText: { attribute: 'helper-text' },
219
+ errorText: { attribute: 'error-text' },
220
+ invalid: { type: Boolean, reflect: true },
221
+ required: { type: Boolean, reflect: true },
222
+ disabled: { type: Boolean, reflect: true },
223
+ readOnly: { type: Boolean, reflect: true, attribute: 'read-only' },
224
+ minLength: { type: Number, attribute: 'min-length' },
225
+ maxLength: { type: Number, attribute: 'max-length' },
226
+ pattern: {},
227
+ name: { reflect: true },
228
+ autoComplete: { attribute: 'auto-complete' },
229
+ inputMode: { attribute: 'input-mode' },
230
+ startIcon: { attribute: false },
231
+ endIcon: { attribute: false },
232
+ prefix: {},
233
+ suffix: {},
234
+ clearable: { type: Boolean, reflect: true },
235
+ clearLabel: { attribute: 'clear-label' },
236
+ passwordReveal: { type: Boolean, reflect: true, attribute: 'password-reveal' },
237
+ revealPasswordLabel: { attribute: 'reveal-password-label' },
238
+ hidePasswordLabel: { attribute: 'hide-password-label' },
239
+ };
240
+ static styles = [boxSizing, focusRing, styles];
241
+ /** Framework adapters set this metadata when `value` is actually bound. */
242
+ valueControlled = false;
243
+ #internals;
244
+ #id = `cosm-text-field-${++instance}`;
245
+ #formDisabled = false;
246
+ #passwordVisible = false;
247
+ #composing = false;
248
+ #showNativeError = false;
249
+ #edited = false;
250
+ #hasRendered = false;
251
+ #controlledReconcileCancel = null;
252
+ #pendingControlledRestore = null;
253
+ constructor() {
254
+ super();
255
+ const props = textFieldContract.props;
256
+ this.label = '';
257
+ this.labelHidden = props.labelHidden.default;
258
+ this.value = props.defaultValue.default;
259
+ this.defaultValue = props.defaultValue.default;
260
+ this.type = props.type.default;
261
+ this.variant = props.variant.default;
262
+ this.size = props.size.default;
263
+ this.placeholder = '';
264
+ this.helperText = '';
265
+ this.errorText = '';
266
+ this.invalid = props.invalid.default;
267
+ this.required = props.required.default;
268
+ this.disabled = props.disabled.default;
269
+ this.readOnly = props.readOnly.default;
270
+ this.minLength = undefined;
271
+ this.maxLength = undefined;
272
+ this.pattern = undefined;
273
+ this.name = undefined;
274
+ this.autoComplete = undefined;
275
+ this.inputMode = '';
276
+ this.startIcon = undefined;
277
+ this.endIcon = undefined;
278
+ this.prefix = '';
279
+ this.suffix = '';
280
+ this.clearable = props.clearable.default;
281
+ this.clearLabel = undefined;
282
+ this.passwordReveal = props.passwordReveal.default;
283
+ this.revealPasswordLabel = undefined;
284
+ this.hidePasswordLabel = undefined;
285
+ this.#internals =
286
+ typeof this.attachInternals === 'function' ? this.attachInternals() : undefined;
287
+ }
288
+ connectedCallback() {
289
+ super.connectedCallback();
290
+ this.addEventListener('invalid', this.#invalid);
291
+ }
292
+ disconnectedCallback() {
293
+ this.removeEventListener('invalid', this.#invalid);
294
+ this.#cancelControlledReconcile();
295
+ super.disconnectedCallback();
296
+ }
297
+ /** The associated form, if any. */
298
+ get form() {
299
+ return this.#internals?.form ?? this.closest('form');
300
+ }
301
+ /** Focuses the native editable control. */
302
+ focus(options) {
303
+ this.renderRoot.querySelector('input')?.focus(options);
304
+ }
305
+ /** Returns the native validity state of the inner input. */
306
+ get validity() {
307
+ return this.renderRoot.querySelector('input')?.validity;
308
+ }
309
+ /** Returns the browser's constraint-validation message. */
310
+ get validationMessage() {
311
+ return this.renderRoot.querySelector('input')?.validationMessage ?? '';
312
+ }
313
+ /** Returns whether the input satisfies its native constraints. */
314
+ checkValidity() {
315
+ return this.renderRoot.querySelector('input')?.checkValidity() ?? true;
316
+ }
317
+ /** Checks validity and asks the browser to present its localized message. */
318
+ reportValidity() {
319
+ this.#showNativeError = true;
320
+ this.requestUpdate();
321
+ this.#syncFormState();
322
+ return this.#internals?.reportValidity() ?? this.#input()?.reportValidity() ?? true;
323
+ }
324
+ formDisabledCallback(disabled) {
325
+ this.#formDisabled = disabled;
326
+ this.requestUpdate();
327
+ }
328
+ formResetCallback() {
329
+ this.#showNativeError = false;
330
+ this.#edited = false;
331
+ if (this.valueControlled) {
332
+ this.emit('cosm-change', { value: this.defaultValue ?? '' });
333
+ return;
334
+ }
335
+ this.value = this.defaultValue ?? '';
336
+ }
337
+ formStateRestoreCallback(state) {
338
+ if (typeof state !== 'string')
339
+ return;
340
+ this.#showNativeError = false;
341
+ if (this.valueControlled) {
342
+ this.emit('cosm-change', { value: state });
343
+ return;
344
+ }
345
+ this.value = state;
346
+ }
347
+ willUpdate(changed) {
348
+ if (this.type !== 'password' ||
349
+ !this.passwordReveal ||
350
+ this.disabled ||
351
+ this.#formDisabled ||
352
+ this.readOnly) {
353
+ this.#passwordVisible = false;
354
+ }
355
+ if (this.size !== 'sm' && this.size !== 'md' && this.size !== 'lg') {
356
+ throw new TypeError('Text field size must be sm, md or lg.');
357
+ }
358
+ if (!this.label.trim())
359
+ throw new TypeError('Text field requires a non-empty label.');
360
+ if (this.clearable && !this.clearLabel?.trim()) {
361
+ throw new TypeError('Text field requires clearLabel when clearable is enabled.');
362
+ }
363
+ if (this.passwordReveal &&
364
+ (!this.revealPasswordLabel?.trim() || !this.hidePasswordLabel?.trim())) {
365
+ throw new TypeError('Text field requires revealPasswordLabel and hidePasswordLabel when passwordReveal is enabled.');
366
+ }
367
+ for (const [name, icon] of [
368
+ ['startIcon', this.startIcon],
369
+ ['endIcon', this.endIcon],
370
+ ]) {
371
+ if (icon !== undefined && !isIconDefinition(icon)) {
372
+ throw new TypeError(`Text field ${name} requires a valid IconDefinition.`);
373
+ }
374
+ }
375
+ if (changed.has('defaultValue') && !this.valueControlled && !this.#edited) {
376
+ if (this.#hasRendered || (!this.hasAttribute('value') && this.defaultValue)) {
377
+ this.value = this.defaultValue ?? '';
378
+ }
379
+ }
380
+ }
381
+ updated(changed) {
382
+ this.#hasRendered = true;
383
+ if (changed.has('value')) {
384
+ this.#cancelControlledReconcile();
385
+ const input = this.renderRoot.querySelector('input');
386
+ if (input && !this.#composing && input.value !== (this.value ?? '')) {
387
+ const selection = {
388
+ start: input.selectionStart,
389
+ end: input.selectionEnd,
390
+ direction: input.selectionDirection,
391
+ };
392
+ input.value = this.value ?? '';
393
+ if (selection.start !== null && selection.end !== null) {
394
+ input.setSelectionRange(Math.min(selection.start, input.value.length), Math.min(selection.end, input.value.length), selection.direction ?? undefined);
395
+ }
396
+ }
397
+ }
398
+ this.#syncFormState();
399
+ }
400
+ #input = () => this.renderRoot.querySelector('input');
401
+ #syncFormState() {
402
+ const input = this.#input();
403
+ if (!input || !this.#internals)
404
+ return;
405
+ const currentValue = this.value ?? '';
406
+ this.#internals.setFormValue(this.disabled || this.#formDisabled ? null : currentValue, currentValue);
407
+ const invalidFlags = {};
408
+ for (const key of [
409
+ 'badInput',
410
+ 'patternMismatch',
411
+ 'rangeOverflow',
412
+ 'rangeUnderflow',
413
+ 'stepMismatch',
414
+ 'tooLong',
415
+ 'tooShort',
416
+ 'typeMismatch',
417
+ 'valueMissing',
418
+ ]) {
419
+ if (input.validity[key])
420
+ invalidFlags[key] = true;
421
+ }
422
+ if (input.validity.valid)
423
+ this.#internals.setValidity({});
424
+ else
425
+ this.#internals.setValidity(invalidFlags, input.validationMessage, input);
426
+ }
427
+ #cancelControlledReconcile() {
428
+ this.#controlledReconcileCancel?.();
429
+ this.#controlledReconcileCancel = null;
430
+ this.#pendingControlledRestore = null;
431
+ }
432
+ #scheduleControlledReconcile(input, value) {
433
+ this.#pendingControlledRestore = {
434
+ value,
435
+ selection: {
436
+ start: input.selectionStart,
437
+ end: input.selectionEnd,
438
+ direction: input.selectionDirection,
439
+ },
440
+ input,
441
+ };
442
+ if (this.#controlledReconcileCancel)
443
+ return;
444
+ const reconcile = () => {
445
+ this.#controlledReconcileCancel = null;
446
+ const pending = this.#pendingControlledRestore;
447
+ this.#pendingControlledRestore = null;
448
+ if (!pending || this.value !== pending.value || this.#composing || !pending.input.isConnected)
449
+ return;
450
+ pending.input.value = pending.value;
451
+ if (pending.selection.start !== null && pending.selection.end !== null) {
452
+ pending.input.setSelectionRange(Math.min(pending.selection.start, pending.value.length), Math.min(pending.selection.end, pending.value.length), pending.selection.direction ?? undefined);
453
+ }
454
+ this.#syncFormState();
455
+ };
456
+ if (typeof requestAnimationFrame === 'function') {
457
+ const frame = requestAnimationFrame(reconcile);
458
+ this.#controlledReconcileCancel = () => cancelAnimationFrame(frame);
459
+ }
460
+ else {
461
+ const timeout = setTimeout(reconcile, 0);
462
+ this.#controlledReconcileCancel = () => clearTimeout(timeout);
463
+ }
464
+ }
465
+ #onInput = (event) => {
466
+ const input = event.currentTarget;
467
+ if (this.disabled || this.#formDisabled || this.readOnly) {
468
+ input.value = this.value ?? '';
469
+ return;
470
+ }
471
+ this.#edited = true;
472
+ this.#showNativeError = false;
473
+ const proposedValue = input.value;
474
+ if (!this.valueControlled)
475
+ this.value = proposedValue;
476
+ this.#syncFormState();
477
+ this.emit('cosm-change', { value: proposedValue });
478
+ if (this.valueControlled && !this.#composing) {
479
+ this.#scheduleControlledReconcile(input, this.value ?? '');
480
+ }
481
+ };
482
+ #onCompositionStart = () => {
483
+ this.#cancelControlledReconcile();
484
+ this.#composing = true;
485
+ };
486
+ #onCompositionEnd = (event) => {
487
+ this.#composing = false;
488
+ this.#cancelControlledReconcile();
489
+ if (this.valueControlled) {
490
+ const input = event.currentTarget;
491
+ const selection = {
492
+ start: input.selectionStart,
493
+ end: input.selectionEnd,
494
+ direction: input.selectionDirection,
495
+ };
496
+ input.value = this.value ?? '';
497
+ if (selection.start !== null && selection.end !== null) {
498
+ input.setSelectionRange(Math.min(selection.start, input.value.length), Math.min(selection.end, input.value.length), selection.direction ?? undefined);
499
+ }
500
+ }
501
+ };
502
+ #onBlur = () => {
503
+ this.#showNativeError = true;
504
+ this.#syncFormState();
505
+ this.requestUpdate();
506
+ };
507
+ #onKeyDown = (event) => {
508
+ if (event.key !== 'Enter' || event.isComposing || this.disabled || this.#formDisabled)
509
+ return;
510
+ const value = this.valueControlled ? (this.value ?? '') : (this.#input()?.value ?? '');
511
+ this.emit('cosm-submit', { value });
512
+ this.#syncFormState();
513
+ this.form?.requestSubmit();
514
+ };
515
+ #clear = () => {
516
+ if (this.disabled || this.#formDisabled || this.readOnly)
517
+ return;
518
+ const input = this.#input();
519
+ if (!input)
520
+ return;
521
+ if (!this.valueControlled)
522
+ this.value = '';
523
+ this.#syncFormState();
524
+ this.#edited = true;
525
+ this.emit('cosm-change', { value: '' });
526
+ this.focus();
527
+ queueMicrotask(() => this.focus());
528
+ };
529
+ #togglePassword = () => {
530
+ if (this.disabled || this.#formDisabled || this.readOnly)
531
+ return;
532
+ this.#passwordVisible = !this.#passwordVisible;
533
+ this.requestUpdate();
534
+ };
535
+ #invalid = () => {
536
+ this.#showNativeError = true;
537
+ this.requestUpdate();
538
+ };
539
+ render() {
540
+ const value = this.value ?? '';
541
+ const state = getTextFieldState({
542
+ value,
543
+ disabled: this.disabled || this.#formDisabled,
544
+ readOnly: this.readOnly,
545
+ invalid: this.invalid,
546
+ errorText: this.errorText,
547
+ clearable: this.clearable,
548
+ passwordReveal: this.passwordReveal,
549
+ type: this.type,
550
+ });
551
+ const nativeInvalid = this.#showNativeError && !(this.#input()?.validity.valid ?? true);
552
+ const errorText = this.errorText?.trim() ? this.errorText : '';
553
+ const shownError = errorText || (nativeInvalid ? this.validationMessage : '');
554
+ const invalid = state.invalid || nativeInvalid;
555
+ const describedBy = [
556
+ this.helperText ? `${this.#id}-help` : '',
557
+ shownError ? `${this.#id}-error` : '',
558
+ ]
559
+ .filter(Boolean)
560
+ .join(' ');
561
+ const inputType = this.type === 'password' && this.#passwordVisible ? 'text' : (this.type ?? 'text');
562
+ return html `
563
+ <label
564
+ part="label"
565
+ class=${this.labelHidden ? 'label label-hidden' : 'label'}
566
+ for=${`${this.#id}-input`}
567
+ >${this.label}</label>
568
+ <div part="control" class="control" data-invalid=${invalid ? 'true' : 'false'}>
569
+ ${this.startIcon || this.prefix
570
+ ? html `<span part="start" class="decoration">
571
+ ${this.startIcon
572
+ ? html `<cosm-icon class="start-icon" .icon=${this.startIcon} size="md"></cosm-icon>`
573
+ : nothing}
574
+ ${this.prefix ? html `<span class="affix">${this.prefix}</span>` : nothing}
575
+ </span>`
576
+ : nothing}
577
+ <input
578
+ part="input"
579
+ id=${`${this.#id}-input`}
580
+ type=${inputType}
581
+ .value=${value}
582
+ placeholder=${this.placeholder || nothing}
583
+ ?required=${this.required}
584
+ ?disabled=${this.disabled || this.#formDisabled}
585
+ ?readonly=${this.readOnly}
586
+ minlength=${this.minLength ?? nothing}
587
+ maxlength=${this.maxLength ?? nothing}
588
+ pattern=${this.pattern ?? nothing}
589
+ name=${nothing}
590
+ autocomplete=${this.autoComplete || nothing}
591
+ inputmode=${this.inputMode || nothing}
592
+ aria-invalid=${invalid ? 'true' : nothing}
593
+ aria-describedby=${describedBy || nothing}
594
+ @input=${this.#onInput}
595
+ @compositionstart=${this.#onCompositionStart}
596
+ @compositionend=${this.#onCompositionEnd}
597
+ @blur=${this.#onBlur}
598
+ @keydown=${this.#onKeyDown}
599
+ @invalid=${this.#invalid}
600
+ />
601
+ ${this.suffix || this.endIcon
602
+ ? html `<span part="end" class="decoration">
603
+ ${this.suffix ? html `<span class="affix">${this.suffix}</span>` : nothing}
604
+ ${this.endIcon
605
+ ? html `<cosm-icon class="end-icon" .icon=${this.endIcon} size="md"></cosm-icon>`
606
+ : nothing}
607
+ </span>`
608
+ : nothing}
609
+ ${state.showClearAction
610
+ ? html `<button
611
+ part="clear-button"
612
+ class="action"
613
+ type="button"
614
+ aria-label=${this.clearLabel}
615
+ @click=${this.#clear}
616
+ ><cosm-icon .icon=${x} size="sm"></cosm-icon></button>`
617
+ : nothing}
618
+ ${state.showPasswordReveal
619
+ ? html `<button
620
+ part="reveal-button"
621
+ class="action"
622
+ type="button"
623
+ aria-label=${this.#passwordVisible ? this.hidePasswordLabel : this.revealPasswordLabel}
624
+ aria-pressed=${this.#passwordVisible ? 'true' : 'false'}
625
+ @click=${this.#togglePassword}
626
+ ><cosm-icon .icon=${this.#passwordVisible ? eyeOff : eye} size="sm"></cosm-icon
627
+ ></button>`
628
+ : nothing}
629
+ </div>
630
+ ${this.helperText
631
+ ? html `<span part="help" class="message" id=${`${this.#id}-help`}>${this.helperText}</span>`
632
+ : nothing}
633
+ ${shownError
634
+ ? html `<span part="error" class="message error" id=${`${this.#id}-error`} role="alert"
635
+ >${shownError}</span
636
+ >`
637
+ : nothing}
638
+ `;
639
+ }
640
+ }
641
+ define('cosm-text-field', CosmTextField);
642
+ //# sourceMappingURL=cosm-text-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosm-text-field.js","sourceRoot":"","sources":["../../../src/components/text-field/cosm-text-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAuB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,2BAA2B,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,sBAAsB,CAAC;AAO9B,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;G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