@reliability-design/web 1.4.5 → 1.4.7

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 (142) hide show
  1. package/CHANGELOG.md +211 -49
  2. package/dist/components/rel-accordion/README.md +132 -132
  3. package/dist/components/rel-alert/README.md +145 -141
  4. package/dist/components/rel-autocomplete/README.md +156 -61
  5. package/dist/components/rel-avatar/README.md +116 -130
  6. package/dist/components/rel-badge/README.md +98 -93
  7. package/dist/components/rel-breadcrumb/README.md +96 -102
  8. package/dist/components/rel-button/README.md +160 -130
  9. package/dist/components/rel-calendar/README.md +109 -109
  10. package/dist/components/rel-card/README.md +75 -94
  11. package/dist/components/rel-cardmedia/README.md +100 -127
  12. package/dist/components/rel-carousel/README.md +184 -166
  13. package/dist/components/rel-checkbox/README.md +93 -75
  14. package/dist/components/rel-chip/README.md +132 -121
  15. package/dist/components/rel-container/README.md +107 -99
  16. package/dist/components/rel-date-picker/README.md +200 -289
  17. package/dist/components/rel-divider/README.md +78 -100
  18. package/dist/components/rel-drawer/README.md +187 -200
  19. package/dist/components/rel-kbd/README.md +141 -151
  20. package/dist/components/rel-menu/README.md +178 -151
  21. package/dist/components/rel-menubar/README.md +218 -329
  22. package/dist/components/rel-otp/README.md +170 -440
  23. package/dist/components/rel-pagination/README.md +100 -424
  24. package/dist/components/rel-popover/README.md +203 -568
  25. package/dist/components/rel-progress/README.md +88 -110
  26. package/dist/components/rel-radio/README.md +131 -135
  27. package/dist/components/rel-range-picker/README.md +162 -0
  28. package/dist/components/rel-resizable/README.md +199 -140
  29. package/dist/components/rel-segmented-button/README.md +155 -141
  30. package/dist/components/rel-select/README.md +154 -93
  31. package/dist/components/rel-sheet/README.md +168 -224
  32. package/dist/components/rel-skeleton/README.md +103 -0
  33. package/dist/components/rel-slider/README.md +130 -135
  34. package/dist/components/rel-snackbar/README.md +162 -134
  35. package/dist/components/rel-stepper/README.md +158 -160
  36. package/dist/components/rel-switch/README.md +108 -102
  37. package/dist/components/rel-tab/README.md +171 -163
  38. package/dist/components/rel-textfield/README.md +159 -69
  39. package/dist/components/rel-time-picker/README.md +122 -157
  40. package/dist/components/rel-toast/README.md +157 -148
  41. package/dist/components/rel-tooltip/README.md +108 -103
  42. package/dist/components/rel-upload/README.md +220 -0
  43. package/dist/index.d.mts +1387 -350
  44. package/dist/index.d.ts +1387 -350
  45. package/dist/index.js +5863 -3600
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +5864 -3592
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/styles/vars.css +877 -866
  50. package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
  51. package/package.json +4 -3
  52. package/dist/components/rel-accordion/rel-accordion.ts +0 -336
  53. package/dist/components/rel-alert/rel-alert.ts +0 -305
  54. package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -689
  55. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  56. package/dist/components/rel-badge/rel-badge.ts +0 -170
  57. package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
  58. package/dist/components/rel-button/rel-button.ts +0 -560
  59. package/dist/components/rel-calendar/index.ts +0 -1
  60. package/dist/components/rel-calendar/rel-calendar.ts +0 -519
  61. package/dist/components/rel-card/rel-card.ts +0 -88
  62. package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
  63. package/dist/components/rel-carousel/index.ts +0 -1
  64. package/dist/components/rel-carousel/rel-carousel.ts +0 -700
  65. package/dist/components/rel-chart/README.md +0 -286
  66. package/dist/components/rel-chart/index.ts +0 -1
  67. package/dist/components/rel-chart/rel-chart.ts +0 -754
  68. package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
  69. package/dist/components/rel-chip/rel-chip.ts +0 -472
  70. package/dist/components/rel-container/rel-container.ts +0 -95
  71. package/dist/components/rel-date-picker/date-format.test.ts +0 -43
  72. package/dist/components/rel-date-picker/date-format.ts +0 -47
  73. package/dist/components/rel-date-picker/index.ts +0 -1
  74. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1237
  75. package/dist/components/rel-divider/rel-divider.ts +0 -54
  76. package/dist/components/rel-drawer/index.ts +0 -1
  77. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  78. package/dist/components/rel-drawer/rel-drawer.ts +0 -604
  79. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  80. package/dist/components/rel-layout/rel-layout.ts +0 -49
  81. package/dist/components/rel-menu/rel-menu.ts +0 -535
  82. package/dist/components/rel-menubar/index.ts +0 -2
  83. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  84. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  85. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  86. package/dist/components/rel-nav-menu/README.md +0 -289
  87. package/dist/components/rel-nav-menu/index.ts +0 -3
  88. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  89. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  90. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  91. package/dist/components/rel-navbar/README.md +0 -126
  92. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  93. package/dist/components/rel-otp/index.ts +0 -1
  94. package/dist/components/rel-otp/rel-otp.ts +0 -517
  95. package/dist/components/rel-pagination/index.ts +0 -1
  96. package/dist/components/rel-pagination/rel-pagination.ts +0 -509
  97. package/dist/components/rel-popover/index.ts +0 -2
  98. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  99. package/dist/components/rel-popover/rel-popover.ts +0 -444
  100. package/dist/components/rel-progress/rel-progress.ts +0 -225
  101. package/dist/components/rel-radio/rel-radio.ts +0 -305
  102. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1331
  103. package/dist/components/rel-resizable/index.ts +0 -3
  104. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  105. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  106. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  107. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -213
  108. package/dist/components/rel-select/rel-select.ts +0 -1385
  109. package/dist/components/rel-sheet/rel-sheet.ts +0 -465
  110. package/dist/components/rel-sidebar/README.md +0 -209
  111. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1185
  112. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -134
  113. package/dist/components/rel-slider/rel-slider.ts +0 -670
  114. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -325
  115. package/dist/components/rel-stepper/rel-stepper.ts +0 -565
  116. package/dist/components/rel-switch/rel-switch.ts +0 -197
  117. package/dist/components/rel-tab/rel-tab.ts +0 -264
  118. package/dist/components/rel-table/README.md +0 -178
  119. package/dist/components/rel-table/rel-table-body.ts +0 -22
  120. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  121. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  122. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  123. package/dist/components/rel-table/rel-table-head.ts +0 -47
  124. package/dist/components/rel-table/rel-table-header.ts +0 -22
  125. package/dist/components/rel-table/rel-table-row.ts +0 -37
  126. package/dist/components/rel-table/rel-table.ts +0 -62
  127. package/dist/components/rel-textfield/rel-textfield.ts +0 -866
  128. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1126
  129. package/dist/components/rel-toast/rel-toast.ts +0 -204
  130. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -190
  131. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  132. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  133. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  134. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  135. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  136. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  137. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  138. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  139. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  140. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  141. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  142. package/dist/components/rel-upload/rel-upload.ts +0 -943
@@ -1,866 +0,0 @@
1
- import { LitElement, html, css, nothing, PropertyValues } from "lit";
2
- import { customElement, property, state } from "lit/decorators.js";
3
- import "@reliability-design/icons/rel-icon";
4
-
5
- export type TextFieldState = "default" | "error" | "disabled";
6
- export type TextFieldSize = "small" | "medium" | "large";
7
- export type TextFieldVariant = "default" | "underline" | "legend";
8
-
9
- /**
10
- * How a field presents its label. Shared by `<rel-textfield>`, `<rel-select>`
11
- * and `<rel-autocomplete>` so the three stay in step.
12
- * - `"default"` — static label above the control
13
- * - `"floating"` — label rests over the placeholder, animates onto the border
14
- * - `"none"` — no label renders; supply `fieldAriaLabel` /
15
- * `fieldAriaLabelledby` to keep an accessible name
16
- */
17
- export type FieldLabelStyle = "default" | "floating" | "none";
18
-
19
- @customElement("rel-textfield")
20
- export class RelTextfield extends LitElement {
21
- @property({ type: String }) label?: string;
22
- @property({ type: String }) placeholder: string = "";
23
- @property({ type: String }) type: string = "text";
24
- @property({ type: String }) value: string = "";
25
- @property({ type: String }) leftIcon?: string;
26
- @property({ type: String }) rightIcon?: string;
27
- /** Makes the trailing icon interactive (pointer + focusable) and emits
28
- * `rel-right-icon-click` — e.g. a password show/hide toggle or clear button. */
29
- @property({ type: Boolean, attribute: "clickable-right-icon" }) clickableRightIcon = false;
30
- /** Accessible label for the trailing icon when it is clickable. */
31
- @property({ type: String, attribute: "right-icon-aria-label" }) rightIconAriaLabel?: string;
32
- @property({ type: String }) supportingText?: string;
33
- @property({ type: String }) state: TextFieldState = "default";
34
- @property({ type: String }) size: TextFieldSize = "medium";
35
- /**
36
- * Label presentation. Left `undefined` the deprecated `floatingLabel` boolean
37
- * decides, so existing markup keeps working; set explicitly and it wins.
38
- * Declares `attribute` because Lit would otherwise only listen for the
39
- * all-lowercase `labelstyle`.
40
- */
41
- @property({ type: String, attribute: "label-style", reflect: true })
42
- labelStyle?: FieldLabelStyle;
43
- /** @deprecated Use `labelStyle="floating"`. Kept permanently as an alias. */
44
- @property({ type: Boolean, reflect: true }) floatingLabel = false;
45
- /**
46
- * Accessible name for the input. Required when `labelStyle="none"`, since no
47
- * `<label>` renders and a placeholder is not a valid naming mechanism.
48
- */
49
- @property({ type: String, attribute: "field-aria-label" }) fieldAriaLabel?: string;
50
- /** IDREF list of external element(s) naming the input. Wins over `fieldAriaLabel`. */
51
- @property({ type: String, attribute: "field-aria-labelledby" }) fieldAriaLabelledby?: string;
52
- @property({ type: String, reflect: true }) variant: TextFieldVariant = "default";
53
- @property({ type: Boolean }) disabled = false;
54
- @property({ type: Boolean }) required = false;
55
- @property({ type: Boolean, reflect: true }) multiline = false;
56
- @property({ type: Number }) rows = 3;
57
-
58
- // ── Standardized input API (senior-team spec) ──────────────────────────────
59
- // Prefer these over the deprecated aliases: prefixIcon (was leftIcon),
60
- // helperText (was supportingText), error (was state="error").
61
- @property({ type: String }) prefixIcon?: string;
62
- @property({ type: String }) prefixIconAriaLabel?: string;
63
- @property({ type: Boolean }) error = false;
64
- @property({ type: String }) errorMessage?: string;
65
- @property({ type: String }) helperText?: string;
66
- @property({ type: Boolean }) readonly = false;
67
- @property({ type: Number }) maxLength?: number;
68
- @property({ type: String }) name?: string;
69
- @property({ type: Boolean, reflect: true }) fullWidth = true;
70
-
71
- @state() private internalState: "default" | "focused" = "default";
72
- private _wasError = false;
73
-
74
- private uniqueId = `textfield-${Math.random().toString(36).slice(2)}`;
75
-
76
- private get isDisabled() {
77
- return this.disabled || this.state === "disabled";
78
- }
79
-
80
- private get isError() {
81
- return this.error || this.state === "error";
82
- }
83
-
84
- // prefixIcon supersedes the deprecated leftIcon
85
- private get leadingIcon() {
86
- return this.prefixIcon ?? this.leftIcon;
87
- }
88
-
89
- // helperText supersedes the deprecated supportingText
90
- private get helper() {
91
- return this.helperText ?? this.supportingText;
92
- }
93
-
94
- /** labelStyle supersedes the deprecated floatingLabel boolean. */
95
- private get resolvedLabelStyle(): FieldLabelStyle {
96
- if (this.labelStyle) return this.labelStyle;
97
- return this.floatingLabel ? "floating" : "default";
98
- }
99
-
100
- /** True when no visible label renders and the input needs an ARIA name. */
101
- private get labelHidden() {
102
- return this.resolvedLabelStyle === "none";
103
- }
104
-
105
- static styles = css`
106
- :host {
107
- color: var(--rel-text-default);
108
- display: block;
109
- font-family: var(--rel-fonts-font-family);
110
- }
111
-
112
- /* Wrapper */
113
- .textfield-wrapper {
114
- display: flex;
115
- flex-direction: column;
116
- gap: var(--rel-spacing-2xs);
117
- width: 100%;
118
- }
119
-
120
- /* Label */
121
- .textfield-label {
122
- color: var(--rel-text-label);
123
-
124
- font-family: var(--rel-body-sm-medium-font-family);
125
-
126
- font-weight: var(--rel-body-sm-medium-font-weight);
127
-
128
- font-size: var(--rel-body-sm-medium-font-size);
129
-
130
- line-height: var(--rel-body-sm-medium-line-height);
131
-
132
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
133
-
134
- }
135
-
136
- .required-mark {
137
- color: var(--rel-text-danger);
138
- margin-left: 2px;
139
- }
140
-
141
- /* ── labelStyle="none" ──
142
- No label renders. An empty spacer holds the label row's full height so the
143
- input box still bottom-aligns with labelled siblings in a form row.
144
- The reserve covers label line-height + the wrapper gap, and the negative
145
- margin cancels the flex gap that would otherwise sit below it — so
146
- --rel-field-label-reserve: 0 collapses the row to genuinely zero
147
- (toolbars, table cells), not just to the leftover gap. */
148
- .label-reserve {
149
- flex: none;
150
- height: var(
151
- --rel-field-label-reserve,
152
- calc(var(--rel-body-sm-medium-line-height) + var(--rel-spacing-2xs))
153
- );
154
- margin-bottom: calc(-1 * var(--rel-spacing-2xs));
155
- }
156
-
157
- /* Floating label variant */
158
- :host([floatinglabel]) .textfield-wrapper {
159
- gap: 0;
160
- }
161
-
162
- :host([floatinglabel]) .textfield-container {
163
- overflow: visible;
164
- position: relative;
165
- padding-top: 0;
166
- }
167
-
168
- :host([floatinglabel]) .textfield-label {
169
- position: absolute;
170
- left: var(--rel-spacing-sm);
171
- top: 50%;
172
- transform: translateY(-50%);
173
- color: var(--rel-text-placeholder);
174
- pointer-events: none;
175
- transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, transform 0.15s ease;
176
- background: var(--rel-bg-neutral);
177
- padding: 0 2px;
178
- z-index: 1;
179
- white-space: nowrap;
180
- font-family: var(--rel-body-md-regular-font-family);
181
- font-weight: var(--rel-body-md-regular-font-weight);
182
- font-size: var(--rel-body-md-regular-font-size);
183
- line-height: var(--rel-body-md-regular-line-height);
184
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
185
- }
186
-
187
- /* Floating label in multiline mode anchors to top instead of vertical center */
188
- :host([floatinglabel][multiline]) .textfield-label {
189
- top: var(--rel-spacing-sm);
190
- transform: none;
191
- }
192
-
193
- :host([floatinglabel]) .textfield-wrapper.focused .textfield-label,
194
- :host([floatinglabel]) .textfield-wrapper.has-value .textfield-label {
195
- top: 0;
196
- transform: translateY(-50%);
197
- color: var(--rel-text-default);
198
- font-family: var(--rel-body-xs-regular-font-family);
199
- font-weight: var(--rel-body-xs-regular-font-weight);
200
- font-size: var(--rel-body-xs-regular-font-size);
201
- line-height: var(--rel-body-xs-regular-line-height);
202
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
203
- }
204
-
205
- :host([floatinglabel]) .textfield-wrapper.error .textfield-label {
206
- color: var(--rel-text-danger);
207
- }
208
-
209
- :host([floatinglabel]) .textfield-wrapper.focused:not(.error) .textfield-label {
210
- color: var(--rel-text-default);
211
- }
212
-
213
- :host([floatinglabel]) .textfield-wrapper.focused.error .textfield-label,
214
- :host([floatinglabel]) .textfield-wrapper.has-value.error .textfield-label {
215
- top: 0;
216
- transform: translateY(-50%);
217
- color: var(--rel-text-danger);
218
- font-family: var(--rel-body-xs-regular-font-family);
219
- font-weight: var(--rel-body-xs-regular-font-weight);
220
- font-size: var(--rel-body-xs-regular-font-size);
221
- line-height: var(--rel-body-xs-regular-line-height);
222
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
223
- }
224
-
225
- :host([floatinglabel]) .textfield-input {
226
- padding-top: var(--rel-spacing-sm);
227
- padding-bottom: var(--rel-spacing-sm);
228
- }
229
-
230
- :host([floatinglabel]) .textfield-input.has-left-icon {
231
- padding-left: var(--rel-spacing-2xl);
232
- }
233
-
234
- :host([floatinglabel]) .textfield-label.has-left-icon {
235
- left: var(--rel-spacing-2xl);
236
- }
237
-
238
- :host([floatinglabel]) .textfield-wrapper.focused .textfield-label.has-left-icon,
239
- :host([floatinglabel]) .textfield-wrapper.has-value .textfield-label.has-left-icon {
240
- left: var(--rel-spacing-sm);
241
- }
242
-
243
- :host([floatinglabel]) .textfield-wrapper.disabled .textfield-label {
244
- background: var(--rel-bg-neutral-elevated-1);
245
- }
246
-
247
- /* Container */
248
- .textfield-container {
249
- display: flex;
250
- align-items: center;
251
- position: relative;
252
- border: 1px solid var(--rel-border-default);
253
- border-radius: var(--rel-border-radius-xs);
254
- background: var(--rel-bg-neutral);
255
- overflow: hidden;
256
- transition: border 0.2s;
257
- }
258
-
259
- .textfield-container.disabled {
260
- background: var(--rel-bg-neutral-elevated-1);
261
- cursor: not-allowed;
262
- }
263
-
264
- .textfield-container.multiline {
265
- overflow: visible;
266
- align-items: flex-start;
267
- }
268
-
269
- /* Input */
270
- .textfield-input {
271
- flex: 1;
272
- border: none;
273
- outline: none;
274
- padding: var(--rel-spacing-xs) var(--rel-spacing-sm);
275
- background: transparent;
276
- color: var(--rel-text-body);
277
- font-family: var(--rel-body-md-regular-font-family);
278
- font-weight: var(--rel-body-md-regular-font-weight);
279
- font-size: var(--rel-body-md-regular-font-size);
280
- line-height: var(--rel-body-md-regular-line-height);
281
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
282
- }
283
-
284
- .textfield-input:disabled {
285
- cursor: not-allowed;
286
- color: var(--rel-text-disabled);
287
- }
288
-
289
- /* Textarea */
290
- textarea.textfield-input {
291
- resize: vertical;
292
- min-height: 80px;
293
- width: 100%;
294
- box-sizing: border-box;
295
- }
296
-
297
- textarea.textfield-input::-webkit-scrollbar {
298
- width: 4px;
299
- }
300
- textarea.textfield-input::-webkit-scrollbar-track {
301
- background: transparent;
302
- }
303
- textarea.textfield-input::-webkit-scrollbar-thumb {
304
- background: var(--rel-text-placeholder);
305
- border-radius: 2px;
306
- }
307
-
308
- .icon {
309
- position: absolute;
310
- display: flex;
311
- pointer-events: none;
312
- color: var(--rel-text-placeholder);
313
- }
314
-
315
- .icon.left {
316
- left: 8px;
317
- }
318
-
319
- .icon.right {
320
- right: 8px;
321
- }
322
-
323
- /* Interactive trailing icon (e.g. password show/hide) */
324
- .icon.right.clickable {
325
- pointer-events: auto;
326
- cursor: pointer;
327
- border-radius: var(--rel-border-radius-xs, 4px);
328
- }
329
- .icon.right.clickable:hover {
330
- color: var(--rel-text-body);
331
- }
332
- .icon.right.clickable:focus-visible {
333
- outline: 2px solid var(--rel-border-focus);
334
- outline-offset: 2px;
335
- }
336
-
337
- .textfield-wrapper.small .textfield-support {
338
- font-weight: var(--rel-body-xs-medium-font-weight);
339
- }
340
-
341
- .textfield-wrapper.small .textfield-input {
342
- padding: var(--rel-spacing-xs) var(--rel-spacing-sm);
343
- font-family: var(--rel-body-sm-regular-font-family);
344
- font-weight: var(--rel-body-sm-regular-font-weight);
345
- font-size: var(--rel-body-sm-regular-font-size);
346
- line-height: var(--rel-body-sm-regular-line-height);
347
- letter-spacing: var(--rel-body-sm-regular-letter-spacing);
348
- }
349
-
350
- .textfield-wrapper.medium .textfield-input {
351
- padding: var(--rel-spacing-sm) var(--rel-spacing-md);
352
- font-family: var(--rel-body-md-regular-font-family);
353
- font-weight: var(--rel-body-md-regular-font-weight);
354
- font-size: var(--rel-body-md-regular-font-size);
355
- line-height: var(--rel-body-md-regular-line-height);
356
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
357
- }
358
-
359
- .textfield-wrapper.large .textfield-input {
360
- padding: var(--rel-spacing-md) var(--rel-spacing-md);
361
- font-family: var(--rel-body-lg-regular-font-family);
362
- font-weight: var(--rel-body-lg-regular-font-weight);
363
- font-size: var(--rel-body-lg-regular-font-size);
364
- line-height: var(--rel-body-lg-regular-line-height);
365
- letter-spacing: var(--rel-body-lg-regular-letter-spacing);
366
- }
367
-
368
- /* Adjust padding when icons are present */
369
- .textfield-wrapper .textfield-input.has-left-icon {
370
- padding-left: var(--rel-spacing-2xl);
371
- }
372
-
373
- .textfield-wrapper .textfield-input.has-right-icon {
374
- padding-right: var(--rel-spacing-2xl);
375
- }
376
-
377
- /* States */
378
- /* Hover (Figma State=Hover): border-strong at 1px — no focus ring */
379
- .textfield-wrapper:not(.focused):not(.error):not(.disabled) .textfield-container:hover {
380
- border-color: var(--rel-border-strong);
381
- }
382
-
383
- .textfield-wrapper.focused .textfield-container {
384
- border-color: var(--rel-text-default);
385
- }
386
-
387
- .textfield-input:focus-visible {
388
- outline: none;
389
- }
390
-
391
- .textfield-wrapper.focused .textfield-container,
392
- .textfield-container:focus-within {
393
- border-color: var(--rel-border-strong);
394
- box-shadow: 0 0 0 1px var(--rel-border-strong);
395
- }
396
-
397
- .textfield-wrapper.error .textfield-container,
398
- .textfield-wrapper.error .textfield-container:focus-within {
399
- border-color: var(--rel-border-danger);
400
- box-shadow: none;
401
- }
402
-
403
- .textfield-wrapper.disabled .textfield-container {
404
- border-color: var(--rel-border-default);
405
- }
406
-
407
- .textfield-wrapper.disabled .textfield-label {
408
- color: var(--rel-text-disabled);
409
- }
410
-
411
- /* Supporting text */
412
- .textfield-support {
413
- color: var(--rel-text-caption);
414
-
415
- font-family: var(--rel-body-xs-regular-font-family);
416
-
417
- font-weight: var(--rel-body-xs-regular-font-weight);
418
-
419
- font-size: var(--rel-body-xs-regular-font-size);
420
-
421
- line-height: var(--rel-body-xs-regular-line-height);
422
-
423
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
424
-
425
- }
426
-
427
- .textfield-support.error {
428
- color: var(--rel-text-danger);
429
- }
430
-
431
- /* Placeholder */
432
- .textfield-input::placeholder {
433
- color: var(--rel-text-placeholder);
434
- }
435
-
436
- :host([floatinglabel]) .textfield-input::placeholder {
437
- opacity: 0;
438
- }
439
-
440
- :host([floatinglabel]) .textfield-wrapper.focused .textfield-input::placeholder {
441
- opacity: 1;
442
- }
443
-
444
- /* Suppress Chrome autofill blue background */
445
- .textfield-input:-webkit-autofill,
446
- .textfield-input:-webkit-autofill:hover,
447
- .textfield-input:-webkit-autofill:focus {
448
- -webkit-box-shadow: 0 0 0px 1000px var(--rel-bg-surface) inset;
449
- -webkit-text-fill-color: var(--rel-text-default);
450
- }
451
-
452
- /* ── Underline variant ── */
453
- :host([variant="underline"]) .textfield-container {
454
- border: none;
455
- border-bottom: 2px solid var(--rel-border-default);
456
- border-radius: 0;
457
- background: var(--rel-bg-neutral-elevated-1);
458
- box-shadow: none;
459
- overflow: visible;
460
- }
461
-
462
- :host([variant="underline"]) .textfield-wrapper:not(.focused):not(.error):not(.disabled) .textfield-container:hover {
463
- border-bottom-color: var(--rel-border-strong);
464
- }
465
-
466
- :host([variant="underline"]) .textfield-wrapper.focused .textfield-container,
467
- :host([variant="underline"]) .textfield-container:focus-within {
468
- border-bottom: 2px solid var(--rel-text-default);
469
- box-shadow: none;
470
- }
471
-
472
- :host([variant="underline"]) .textfield-wrapper.error .textfield-container {
473
- border-bottom: 2px solid var(--rel-border-danger);
474
- box-shadow: none;
475
- }
476
-
477
- :host([variant="underline"]) .textfield-wrapper.disabled .textfield-container {
478
- border-bottom: 2px solid var(--rel-border-default);
479
- background: var(--rel-bg-neutral-elevated-1);
480
- }
481
-
482
- /* Remove border radius on input for underline variant */
483
- :host([variant="underline"]) .textfield-input {
484
- background: transparent;
485
- }
486
-
487
- /* Dark mode — underline variant uses same border colors as default */
488
- :host-context([data-theme="dark"]) :host([variant="underline"]) .textfield-container,
489
- :host-context(.dark) :host([variant="underline"]) .textfield-container {
490
- background: var(--rel-bg-neutral-elevated-1);
491
- border-bottom-color: var(--rel-border-default);
492
- }
493
-
494
- /* ── Full-width control (fullWidth defaults true → block, fills parent) ── */
495
- :host(:not([fullwidth])) {
496
- display: inline-block;
497
- width: auto;
498
- }
499
- :host(:not([fullwidth])) .textfield-wrapper {
500
- width: auto;
501
- }
502
-
503
- /* ── Legend (notched-outline) variant ──
504
- Native <fieldset>/<legend>: the legend notches the top border and stays
505
- fixed in place across all states (no float/animation). */
506
- :host([variant="legend"]) .field-fieldset {
507
- position: relative;
508
- margin: 0;
509
- min-inline-size: 0;
510
- padding: 0;
511
- border: 1px solid var(--rel-border-default);
512
- border-radius: var(--rel-border-radius-xs);
513
- background: var(--rel-bg-neutral);
514
- transition: border-color 0.2s;
515
- }
516
-
517
- :host([variant="legend"]) .field-legend {
518
- margin-left: var(--rel-spacing-sm);
519
- padding: 0 var(--rel-spacing-2xs);
520
- color: var(--rel-text-label);
521
- font-family: var(--rel-body-sm-medium-font-family);
522
- font-weight: var(--rel-body-sm-medium-font-weight);
523
- font-size: var(--rel-body-sm-medium-font-size);
524
- line-height: var(--rel-body-sm-medium-line-height);
525
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
526
- }
527
-
528
- :host([variant="legend"]) .textfield-input {
529
- width: 100%;
530
- box-sizing: border-box;
531
- }
532
-
533
- /* labelStyle="none" + legend: nothing to seat in the notch, so drop the
534
- legend entirely and let the top border run continuous. */
535
- :host([label-style="none"][variant="legend"]) .field-legend {
536
- display: none;
537
- }
538
-
539
- /* Prefix icon (legend): vertically centered; input inset via has-left-icon */
540
- :host([variant="legend"]) .icon.left {
541
- top: 50%;
542
- left: var(--rel-spacing-sm);
543
- transform: translateY(-50%);
544
- }
545
- :host([variant="legend"]) .field-fieldset.multiline .icon.left {
546
- top: var(--rel-spacing-sm);
547
- transform: none;
548
- }
549
-
550
- /* Hover */
551
- :host([variant="legend"]) .field-fieldset:hover {
552
- border-color: var(--rel-border-accent);
553
- border-color: var(--rel-text-placeholder);
554
- }
555
-
556
- /* Focus — border-color only. A box-shadow/outline ring hugs the full
557
- rectangular border-box and would draw across the notch, appearing to
558
- strike through the legend. The legend also recolors on focus (below). */
559
- :host([variant="legend"]) .textfield-wrapper.focused .field-fieldset,
560
- :host([variant="legend"]) .field-fieldset:focus-within {
561
- border-color: var(--rel-border-focus);
562
- box-shadow: none;
563
- }
564
- :host([variant="legend"]) .textfield-wrapper.focused .field-legend,
565
- :host([variant="legend"]) .field-fieldset:focus-within .field-legend {
566
- color: var(--rel-border-focus);
567
- }
568
-
569
- /* Error */
570
- :host([variant="legend"]) .textfield-wrapper.error .field-fieldset {
571
- border-color: var(--rel-border-danger);
572
- box-shadow: none;
573
- }
574
- :host([variant="legend"]) .textfield-wrapper.error .field-legend {
575
- color: var(--rel-text-danger);
576
- }
577
-
578
- /* Disabled */
579
- :host([variant="legend"]) .textfield-wrapper.disabled .field-fieldset {
580
- background: var(--rel-bg-neutral-elevated-1);
581
- border-color: var(--rel-border-default);
582
- cursor: not-allowed;
583
- }
584
- :host([variant="legend"]) .textfield-wrapper.disabled .field-legend {
585
- color: var(--rel-text-disabled);
586
- }
587
-
588
- /* Readonly */
589
- :host([variant="legend"]) .textfield-wrapper.readonly .field-fieldset {
590
- cursor: default;
591
- }
592
-
593
- /* Legend font tracks size */
594
- :host([variant="legend"]) .textfield-wrapper.small .field-legend {
595
-
596
- font-family: var(--rel-body-xs-regular-font-family);
597
-
598
- font-weight: var(--rel-body-xs-regular-font-weight);
599
-
600
- font-size: var(--rel-body-xs-regular-font-size);
601
-
602
- line-height: var(--rel-body-xs-regular-line-height);
603
-
604
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
605
-
606
- }
607
- :host([variant="legend"]) .textfield-wrapper.large .field-legend {
608
-
609
- font-family: var(--rel-body-md-regular-font-family);
610
-
611
- font-weight: var(--rel-body-md-regular-font-weight);
612
-
613
- font-size: var(--rel-body-md-regular-font-size);
614
-
615
- line-height: var(--rel-body-md-regular-line-height);
616
-
617
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
618
-
619
- }
620
- `;
621
-
622
- connectedCallback() {
623
- super.connectedCallback();
624
- const leftIcon = this.getAttribute('lefticon') || this.getAttribute('leftIcon');
625
- if (leftIcon) this.leftIcon = leftIcon;
626
- const rightIcon = this.getAttribute('righticon') || this.getAttribute('rightIcon');
627
- if (rightIcon) this.rightIcon = rightIcon;
628
- }
629
-
630
- willUpdate(changed: PropertyValues<this>) {
631
- // Keep the deprecated boolean an accurate mirror of labelStyle. This is what
632
- // lets every `:host([floatinglabel])` rule below stay untouched — the
633
- // reflected attribute is still the single styling hook for the floating form.
634
- if (changed.has("labelStyle") && this.labelStyle) {
635
- this.floatingLabel = this.labelStyle === "floating";
636
- }
637
- }
638
-
639
- private _warnedNoName = false;
640
-
641
- updated() {
642
- if (this._warnedNoName || !this.labelHidden) return;
643
- if (this.fieldAriaLabel || this.fieldAriaLabelledby || this.getAttribute("aria-label")) return;
644
- this._warnedNoName = true;
645
- console.warn(
646
- '<rel-textfield label-style="none"> has no accessible name. Set ' +
647
- "`field-aria-label` or `field-aria-labelledby` — a placeholder is not a " +
648
- "valid naming mechanism.",
649
- this
650
- );
651
- }
652
-
653
- /** Focuses the inner input/textarea (the host itself is not focusable). */
654
- focus(options?: FocusOptions) {
655
- (this.renderRoot.querySelector("input, textarea") as HTMLElement | null)?.focus(options);
656
- }
657
-
658
- private handleFocus() {
659
- if (!this.isDisabled) {
660
- this.internalState = "focused";
661
- }
662
- }
663
-
664
- private handleBlur() {
665
- if (this.internalState === "focused") {
666
- this.internalState = "default";
667
- }
668
- }
669
-
670
- private handleRightIconClick(e: Event) {
671
- if (!this.clickableRightIcon) return;
672
- e.stopPropagation();
673
- this.dispatchEvent(
674
- new CustomEvent("rel-right-icon-click", { bubbles: true, composed: true })
675
- );
676
- }
677
-
678
- private handleRightIconKeydown(e: KeyboardEvent) {
679
- if (!this.clickableRightIcon) return;
680
- if (e.key === "Enter" || e.key === " ") {
681
- e.preventDefault();
682
- this.handleRightIconClick(e);
683
- }
684
- }
685
-
686
- private handleInput(e: Event) {
687
- const input = e.target as HTMLInputElement;
688
- this.value = input.value;
689
- if (this.state === "error" && this.value) {
690
- this._wasError = true;
691
- this.state = "default";
692
- } else if (this._wasError && !this.value) {
693
- this._wasError = false;
694
- this.state = "error";
695
- }
696
- this.dispatchEvent(
697
- new CustomEvent<string>("rel-change", {
698
- detail: this.value,
699
- bubbles: true,
700
- composed: true,
701
- })
702
- );
703
- }
704
-
705
- render() {
706
- const isError = this.isError;
707
- const stateClass = this.isDisabled ? "disabled" : isError ? "error" : "default";
708
- const leadingIcon = this.leadingIcon;
709
- const inputId = this.id || this.uniqueId;
710
- const legendId = `${inputId}-legend`;
711
-
712
- // errorMessage replaces the helper only when in error AND explicitly set;
713
- // otherwise the (deprecated) supportingText/helperText shows as before.
714
- const belowText = isError && this.errorMessage ? this.errorMessage : this.helper;
715
- const describedById = belowText ? `${inputId}-desc` : undefined;
716
-
717
- const wrapperClasses = [
718
- "textfield-wrapper",
719
- this.size,
720
- stateClass,
721
- this.readonly ? "readonly" : "",
722
- this.internalState === "focused" ? "focused" : "",
723
- this.value ? "has-value" : "",
724
- ].filter(Boolean).join(" ");
725
-
726
- const inputClasses = [
727
- "textfield-input",
728
- !this.multiline && leadingIcon ? "has-left-icon" : "",
729
- !this.multiline && this.rightIcon && this.variant !== "legend" ? "has-right-icon" : "",
730
- ]
731
- .filter(Boolean)
732
- .join(" ");
733
-
734
- const labelStyle = this.resolvedLabelStyle;
735
- const labelHidden = labelStyle === "none";
736
-
737
- const labelTemplate = (extraClass = "") => {
738
- if (!this.label || labelHidden) return "";
739
- return html`<label
740
- part="label"
741
- class="textfield-label${extraClass}"
742
- for="${inputId}"
743
- >${this.label}${this.required ? html`<span class="required-mark" aria-hidden="true">*</span>` : ""}</label>`;
744
- };
745
-
746
- // With no visible label the <label for> / <legend> naming path is gone, so
747
- // fieldAriaLabelledby → fieldAriaLabel take over. An explicit labelledby
748
- // always wins; aria-label only fills in when nothing else names the input.
749
- const legendLabelledby =
750
- this.variant === "legend" && this.label && !labelHidden ? legendId : undefined;
751
- const ariaLabelledby = this.fieldAriaLabelledby ?? legendLabelledby;
752
- const hasVisibleLabel = !labelHidden && !!this.label;
753
- const ariaLabel = !hasVisibleLabel && !ariaLabelledby ? this.fieldAriaLabel : undefined;
754
-
755
- const inputTemplate = this.multiline
756
- ? html`<textarea part="input"
757
- id="${inputId}"
758
- class="${inputClasses}"
759
- placeholder="${this.placeholder}"
760
- .value="${this.value}"
761
- rows="${this.rows}"
762
- name="${this.name ?? nothing}"
763
- maxlength="${this.maxLength ?? nothing}"
764
- ?disabled="${this.isDisabled}"
765
- ?readonly="${this.readonly}"
766
- ?required="${this.required}"
767
- aria-invalid="${isError}"
768
- aria-required="${this.required}"
769
- aria-label="${ariaLabel ?? nothing}"
770
- aria-labelledby="${ariaLabelledby ?? nothing}"
771
- aria-describedby="${describedById ?? nothing}"
772
- @focus="${this.handleFocus}"
773
- @blur="${this.handleBlur}"
774
- @input="${this.handleInput}"
775
- ></textarea>`
776
- : html`<input part="input"
777
- type="${this.type}"
778
- id="${inputId}"
779
- class="${inputClasses}"
780
- placeholder="${this.placeholder}"
781
- .value="${this.value}"
782
- name="${this.name ?? nothing}"
783
- maxlength="${this.maxLength ?? nothing}"
784
- ?disabled="${this.isDisabled}"
785
- ?readonly="${this.readonly}"
786
- ?required="${this.required}"
787
- aria-invalid="${isError}"
788
- aria-required="${this.required}"
789
- aria-label="${ariaLabel ?? nothing}"
790
- aria-labelledby="${ariaLabelledby ?? nothing}"
791
- aria-describedby="${describedById ?? nothing}"
792
- @focus="${this.handleFocus}"
793
- @blur="${this.handleBlur}"
794
- @input="${this.handleInput}"
795
- />`;
796
-
797
- const leadingIconTemplate = leadingIcon
798
- ? html`<rel-icon
799
- name="${leadingIcon}"
800
- size="sm"
801
- class="icon left"
802
- role="${this.prefixIconAriaLabel ? "img" : nothing}"
803
- aria-label="${this.prefixIconAriaLabel ?? nothing}"
804
- aria-hidden="${this.prefixIconAriaLabel ? nothing : "true"}"
805
- ></rel-icon>`
806
- : "";
807
-
808
- const belowTemplate = belowText
809
- ? html`<div part="helper" class="textfield-support ${isError ? "error" : ""}" id="${describedById}">
810
- ${belowText}
811
- </div>`
812
- : "";
813
-
814
- if (this.variant === "legend") {
815
- const fieldsetClass = ["field-fieldset", this.multiline ? "multiline" : ""].filter(Boolean).join(" ");
816
- // The <legend> MUST be the fieldset's first child with no preceding
817
- // whitespace/text or binding-comment, otherwise the browser won't cut the
818
- // notch in the top border. So it's rendered flush against the tag open and
819
- // is always present (only its content is dynamic).
820
- return html`
821
- <div class="${wrapperClasses}">
822
- <fieldset part="control" class="${fieldsetClass}"><legend class="field-legend" id="${legendId}">${labelHidden ? "" : this.label ?? ""}${this.required && !labelHidden ? html`<span class="required-mark" aria-hidden="true">*</span>` : ""}</legend>
823
- ${!this.multiline ? leadingIconTemplate : ""}
824
- ${inputTemplate}
825
- </fieldset>
826
- ${belowTemplate}
827
- </div>
828
- `;
829
- }
830
-
831
- return html`
832
- <div class="${wrapperClasses}">
833
- ${labelHidden
834
- ? html`<div class="label-reserve" aria-hidden="true"></div>`
835
- : labelStyle !== "floating"
836
- ? labelTemplate()
837
- : ""}
838
-
839
- <div part="control" class="${["textfield-container", this.isDisabled ? "disabled" : "", this.multiline ? "multiline" : ""].filter(Boolean).join(" ")}">
840
- ${labelStyle === "floating"
841
- ? labelTemplate(leadingIcon && !this.multiline ? " has-left-icon" : "")
842
- : ""}
843
- ${!this.multiline ? leadingIconTemplate : ""}
844
-
845
- ${inputTemplate}
846
-
847
- ${!this.multiline && this.rightIcon
848
- ? html`<rel-icon
849
- part="right-icon"
850
- name="${this.rightIcon}"
851
- size="${this.clickableRightIcon ? "md" : "sm"}"
852
- class="icon right ${this.clickableRightIcon ? "clickable" : ""}"
853
- role="${this.clickableRightIcon ? "button" : nothing}"
854
- tabindex="${this.clickableRightIcon ? "0" : nothing}"
855
- aria-label="${this.clickableRightIcon ? (this.rightIconAriaLabel ?? nothing) : nothing}"
856
- @click="${(e: Event) => this.handleRightIconClick(e)}"
857
- @keydown="${(e: KeyboardEvent) => this.handleRightIconKeydown(e)}"
858
- ></rel-icon>`
859
- : ""}
860
- </div>
861
-
862
- ${belowTemplate}
863
- </div>
864
- `;
865
- }
866
- }