@reliability-design/web 1.4.6 → 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 (146) 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 -138
  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 -111
  42. package/dist/components/rel-upload/README.md +220 -0
  43. package/dist/index.d.mts +1147 -340
  44. package/dist/index.d.ts +1147 -340
  45. package/dist/index.js +3451 -3163
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +3416 -3118
  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 +3 -2
  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 -720
  55. package/dist/components/rel-avatar/rel-avatar.ts +0 -142
  56. package/dist/components/rel-badge/rel-badge.ts +0 -175
  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 -565
  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 -723
  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 -483
  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/date-parse.test.ts +0 -116
  74. package/dist/components/rel-date-picker/date-parse.ts +0 -178
  75. package/dist/components/rel-date-picker/index.ts +0 -1
  76. package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
  77. package/dist/components/rel-divider/rel-divider.ts +0 -54
  78. package/dist/components/rel-drawer/index.ts +0 -1
  79. package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
  80. package/dist/components/rel-drawer/rel-drawer.ts +0 -607
  81. package/dist/components/rel-kbd/rel-kbd.ts +0 -188
  82. package/dist/components/rel-layout/rel-layout.ts +0 -49
  83. package/dist/components/rel-menu/rel-menu.ts +0 -541
  84. package/dist/components/rel-menubar/index.ts +0 -2
  85. package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
  86. package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
  87. package/dist/components/rel-menubar/rel-menubar.ts +0 -777
  88. package/dist/components/rel-nav-menu/README.md +0 -289
  89. package/dist/components/rel-nav-menu/index.ts +0 -3
  90. package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
  91. package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
  92. package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
  93. package/dist/components/rel-navbar/README.md +0 -126
  94. package/dist/components/rel-navbar/rel-navbar.ts +0 -105
  95. package/dist/components/rel-otp/index.ts +0 -1
  96. package/dist/components/rel-otp/rel-otp.ts +0 -527
  97. package/dist/components/rel-pagination/index.ts +0 -1
  98. package/dist/components/rel-pagination/rel-pagination.ts +0 -522
  99. package/dist/components/rel-popover/index.ts +0 -2
  100. package/dist/components/rel-popover/rel-popover-content.ts +0 -81
  101. package/dist/components/rel-popover/rel-popover.ts +0 -475
  102. package/dist/components/rel-progress/rel-progress.ts +0 -234
  103. package/dist/components/rel-radio/rel-radio.ts +0 -481
  104. package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
  105. package/dist/components/rel-resizable/index.ts +0 -3
  106. package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
  107. package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
  108. package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
  109. package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
  110. package/dist/components/rel-select/rel-select.ts +0 -1416
  111. package/dist/components/rel-sheet/rel-sheet.ts +0 -610
  112. package/dist/components/rel-sidebar/README.md +0 -209
  113. package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
  114. package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
  115. package/dist/components/rel-slider/rel-slider.ts +0 -673
  116. package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
  117. package/dist/components/rel-stepper/rel-stepper.ts +0 -567
  118. package/dist/components/rel-switch/rel-switch.ts +0 -199
  119. package/dist/components/rel-tab/rel-tab.ts +0 -264
  120. package/dist/components/rel-table/README.md +0 -178
  121. package/dist/components/rel-table/rel-table-body.ts +0 -22
  122. package/dist/components/rel-table/rel-table-caption.ts +0 -30
  123. package/dist/components/rel-table/rel-table-cell.ts +0 -43
  124. package/dist/components/rel-table/rel-table-footer.ts +0 -24
  125. package/dist/components/rel-table/rel-table-head.ts +0 -47
  126. package/dist/components/rel-table/rel-table-header.ts +0 -22
  127. package/dist/components/rel-table/rel-table-row.ts +0 -37
  128. package/dist/components/rel-table/rel-table.ts +0 -62
  129. package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
  130. package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
  131. package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
  132. package/dist/components/rel-time-picker/time-parse.ts +0 -85
  133. package/dist/components/rel-toast/rel-toast.ts +0 -206
  134. package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
  135. package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
  136. package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
  137. package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
  138. package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
  139. package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
  140. package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
  141. package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
  142. package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
  143. package/dist/components/rel-topbar/rel-topbar.ts +0 -446
  144. package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
  145. package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
  146. package/dist/components/rel-upload/rel-upload.ts +0 -968
@@ -1,1054 +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
- * How the prefix block is drawn (Figma `.Preffix` → Style):
10
- * - `"clear"` — bare icon/text, no separator (the legacy `leftIcon` look)
11
- * - `"divider"` — hairline between the prefix and the input
12
- * - `"fill"` — tinted block flush with the control's left edge
13
- */
14
- export type TextFieldPrefixStyle = "clear" | "divider" | "fill";
15
-
16
- /**
17
- * How a field presents its label. Shared by `<rel-textfield>`, `<rel-select>`
18
- * and `<rel-autocomplete>` so the three stay in step.
19
- * - `"default"` — static label above the control
20
- * - `"floating"` — label rests over the placeholder, animates onto the border
21
- * - `"none"` — no label renders; supply `fieldAriaLabel` /
22
- * `fieldAriaLabelledby` to keep an accessible name
23
- */
24
- export type FieldLabelStyle = "default" | "floating" | "none";
25
-
26
- @customElement("rel-textfield")
27
- export class RelTextfield extends LitElement {
28
- @property({ type: String }) label?: string;
29
- @property({ type: String }) placeholder: string = "";
30
- @property({ type: String }) type: string = "text";
31
- @property({ type: String }) value: string = "";
32
- @property({ type: String }) leftIcon?: string;
33
- @property({ type: String }) rightIcon?: string;
34
- /** Makes the trailing icon interactive (pointer + focusable) and emits
35
- * `rel-right-icon-click` — e.g. a password show/hide toggle or clear button. */
36
- @property({ type: Boolean, attribute: "clickable-right-icon" }) clickableRightIcon = false;
37
- /** Accessible label for the trailing icon when it is clickable. */
38
- @property({ type: String, attribute: "right-icon-aria-label" }) rightIconAriaLabel?: string;
39
- // ── Prefix / suffix labels (Figma .Preffix / .Suffix) ───────────────────────
40
- /** Short text rendered before the input, e.g. `"http://"` or `"$"`. Sits in
41
- * the same prefix block as `prefixIcon` and is styled by `prefixStyle`. */
42
- @property({ type: String, attribute: "prefix-text" }) prefixText?: string;
43
- /** Visual treatment of the prefix block — applies to the prefix icon, text
44
- * and slotted `prefix` content alike. See `TextFieldPrefixStyle`. */
45
- @property({ type: String, attribute: "prefix-style" }) prefixStyle: TextFieldPrefixStyle = "clear";
46
- /** Short text rendered after the input, e.g. `"kg"` or `".00"`. Shares the
47
- * suffix block with `rightIcon` and slotted `suffix` content. */
48
- @property({ type: String, attribute: "suffix-text" }) suffixText?: string;
49
- /** Draws a hairline between the input and the suffix block. */
50
- @property({ type: Boolean, attribute: "suffix-divider" }) suffixDivider = false;
51
- @property({ type: String }) supportingText?: string;
52
- @property({ type: String }) state: TextFieldState = "default";
53
- @property({ type: String }) size: TextFieldSize = "medium";
54
- /**
55
- * Label presentation. Left `undefined` the deprecated `floatingLabel` boolean
56
- * decides, so existing markup keeps working; set explicitly and it wins.
57
- * Declares `attribute` because Lit would otherwise only listen for the
58
- * all-lowercase `labelstyle`.
59
- */
60
- @property({ type: String, attribute: "label-style", reflect: true })
61
- labelStyle?: FieldLabelStyle;
62
- /** @deprecated Use `labelStyle="floating"`. Kept permanently as an alias. */
63
- @property({ type: Boolean, reflect: true }) floatingLabel = false;
64
- /**
65
- * Accessible name for the input. Required when `labelStyle="none"`, since no
66
- * `<label>` renders and a placeholder is not a valid naming mechanism.
67
- */
68
- @property({ type: String, attribute: "field-aria-label" }) fieldAriaLabel?: string;
69
- /** IDREF list of external element(s) naming the input. Wins over `fieldAriaLabel`. */
70
- @property({ type: String, attribute: "field-aria-labelledby" }) fieldAriaLabelledby?: string;
71
- @property({ type: String, reflect: true }) variant: TextFieldVariant = "default";
72
- @property({ type: Boolean }) disabled = false;
73
- @property({ type: Boolean }) required = false;
74
- @property({ type: Boolean, reflect: true }) multiline = false;
75
- @property({ type: Number }) rows = 3;
76
-
77
- // ── Standardized input API (senior-team spec) ──────────────────────────────
78
- // Prefer these over the deprecated aliases: prefixIcon (was leftIcon),
79
- // helperText (was supportingText), error (was state="error").
80
- @property({ type: String }) prefixIcon?: string;
81
- @property({ type: String }) prefixIconAriaLabel?: string;
82
- @property({ type: Boolean }) error = false;
83
- @property({ type: String }) errorMessage?: string;
84
- @property({ type: String }) helperText?: string;
85
- @property({ type: Boolean }) readonly = false;
86
- @property({ type: Number }) maxLength?: number;
87
- @property({ type: String }) name?: string;
88
- @property({ type: Boolean, reflect: true }) fullWidth = true;
89
-
90
- @state() private internalState: "default" | "focused" = "default";
91
- /** Whether the `prefix` / `suffix` named slots currently have content. */
92
- @state() private slotted = { prefix: false, suffix: false };
93
- private _wasError = false;
94
- private _prefixObserver?: ResizeObserver;
95
-
96
- private uniqueId = `textfield-${Math.random().toString(36).slice(2)}`;
97
-
98
- private get isDisabled() {
99
- return this.disabled || this.state === "disabled";
100
- }
101
-
102
- private get isError() {
103
- return this.error || this.state === "error";
104
- }
105
-
106
- // prefixIcon supersedes the deprecated leftIcon
107
- private get leadingIcon() {
108
- return this.prefixIcon ?? this.leftIcon;
109
- }
110
-
111
- // helperText supersedes the deprecated supportingText
112
- private get helper() {
113
- return this.helperText ?? this.supportingText;
114
- }
115
-
116
- /** labelStyle supersedes the deprecated floatingLabel boolean. */
117
- private get resolvedLabelStyle(): FieldLabelStyle {
118
- if (this.labelStyle) return this.labelStyle;
119
- return this.floatingLabel ? "floating" : "default";
120
- }
121
-
122
- /** True when no visible label renders and the input needs an ARIA name. */
123
- private get labelHidden() {
124
- return this.resolvedLabelStyle === "none";
125
- }
126
-
127
- static styles = css`
128
- :host {
129
- color: var(--rel-text-default);
130
- display: block;
131
- font-family: var(--rel-fonts-font-family);
132
- }
133
-
134
- /* Wrapper */
135
- .textfield-wrapper {
136
- display: flex;
137
- flex-direction: column;
138
- gap: var(--rel-spacing-2xs);
139
- width: 100%;
140
- }
141
-
142
- /* Label */
143
- .textfield-label {
144
- color: var(--rel-text-label);
145
-
146
- font-family: var(--rel-body-sm-medium-font-family);
147
-
148
- font-weight: var(--rel-body-sm-medium-font-weight);
149
-
150
- font-size: var(--rel-body-sm-medium-font-size);
151
-
152
- line-height: var(--rel-body-sm-medium-line-height);
153
-
154
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
155
-
156
- }
157
-
158
- .required-mark {
159
- color: var(--rel-text-danger);
160
- margin-left: 2px;
161
- }
162
-
163
- /* ── labelStyle="none" ──
164
- No label renders. An empty spacer holds the label row's full height so the
165
- input box still bottom-aligns with labelled siblings in a form row.
166
- The reserve covers label line-height + the wrapper gap, and the negative
167
- margin cancels the flex gap that would otherwise sit below it — so
168
- --rel-field-label-reserve: 0 collapses the row to genuinely zero
169
- (toolbars, table cells), not just to the leftover gap. */
170
- .label-reserve {
171
- flex: none;
172
- height: var(
173
- --rel-field-label-reserve,
174
- calc(var(--rel-body-sm-medium-line-height) + var(--rel-spacing-2xs))
175
- );
176
- margin-bottom: calc(-1 * var(--rel-spacing-2xs));
177
- }
178
-
179
- /* Floating label variant */
180
- :host([floatinglabel]) .textfield-wrapper {
181
- gap: 0;
182
- }
183
-
184
- :host([floatinglabel]) .textfield-container {
185
- overflow: visible;
186
- position: relative;
187
- padding-top: 0;
188
- }
189
-
190
- :host([floatinglabel]) .textfield-label {
191
- position: absolute;
192
- left: var(--rel-spacing-sm);
193
- top: 50%;
194
- transform: translateY(-50%);
195
- color: var(--rel-text-placeholder);
196
- pointer-events: none;
197
- transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, transform 0.15s ease;
198
- background: var(--rel-bg-neutral);
199
- padding: 0 2px;
200
- z-index: 1;
201
- white-space: nowrap;
202
- font-family: var(--rel-body-md-regular-font-family);
203
- font-weight: var(--rel-body-md-regular-font-weight);
204
- font-size: var(--rel-body-md-regular-font-size);
205
- line-height: var(--rel-body-md-regular-line-height);
206
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
207
- }
208
-
209
- /* Floating label in multiline mode anchors to top instead of vertical center */
210
- :host([floatinglabel][multiline]) .textfield-label {
211
- top: var(--rel-spacing-sm);
212
- transform: none;
213
- }
214
-
215
- :host([floatinglabel]) .textfield-wrapper.focused .textfield-label,
216
- :host([floatinglabel]) .textfield-wrapper.has-value .textfield-label {
217
- top: 0;
218
- transform: translateY(-50%);
219
- color: var(--rel-text-default);
220
- font-family: var(--rel-body-xs-regular-font-family);
221
- font-weight: var(--rel-body-xs-regular-font-weight);
222
- font-size: var(--rel-body-xs-regular-font-size);
223
- line-height: var(--rel-body-xs-regular-line-height);
224
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
225
- }
226
-
227
- :host([floatinglabel]) .textfield-wrapper.error .textfield-label {
228
- color: var(--rel-text-danger);
229
- }
230
-
231
- :host([floatinglabel]) .textfield-wrapper.focused:not(.error) .textfield-label {
232
- color: var(--rel-text-default);
233
- }
234
-
235
- :host([floatinglabel]) .textfield-wrapper.focused.error .textfield-label,
236
- :host([floatinglabel]) .textfield-wrapper.has-value.error .textfield-label {
237
- top: 0;
238
- transform: translateY(-50%);
239
- color: var(--rel-text-danger);
240
- font-family: var(--rel-body-xs-regular-font-family);
241
- font-weight: var(--rel-body-xs-regular-font-weight);
242
- font-size: var(--rel-body-xs-regular-font-size);
243
- line-height: var(--rel-body-xs-regular-line-height);
244
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
245
- }
246
-
247
- :host([floatinglabel]) .textfield-input {
248
- padding-top: var(--rel-spacing-sm);
249
- padding-bottom: var(--rel-spacing-sm);
250
- }
251
-
252
- /* The floating label lives inside .textfield-field (the input's own flex
253
- column), so at rest it naturally sits after any prefix block. Once
254
- floated, a "clear" prefix (bare icon — the legacy leftIcon look) lets the
255
- label slide back over the control's left edge, matching Figma's
256
- "Floating Label" frame at x=12; --_rel-tf-prefix-w is the measured
257
- prefix width (ResizeObserver). Divider/fill prefixes are solid blocks,
258
- so the floated label stays in the field column, after them. */
259
- :host([floatinglabel]) .textfield-wrapper.focused .prefix-clear .textfield-label,
260
- :host([floatinglabel]) .textfield-wrapper.has-value .prefix-clear .textfield-label {
261
- left: calc(var(--rel-spacing-sm) - var(--_rel-tf-prefix-w, 0px));
262
- }
263
-
264
- :host([floatinglabel]) .textfield-wrapper.disabled .textfield-label {
265
- background: var(--rel-bg-neutral-elevated-1);
266
- }
267
-
268
- /* Container */
269
- .textfield-container {
270
- display: flex;
271
- align-items: center;
272
- position: relative;
273
- border: 1px solid var(--rel-border-default);
274
- border-radius: var(--rel-border-radius-xs);
275
- background: var(--rel-bg-neutral);
276
- overflow: hidden;
277
- transition: border 0.2s;
278
- }
279
-
280
- .textfield-container.disabled {
281
- background: var(--rel-bg-neutral-elevated-1);
282
- cursor: not-allowed;
283
- }
284
-
285
- .textfield-container.multiline {
286
- overflow: visible;
287
- align-items: flex-start;
288
- }
289
-
290
- /* The input's own column: prefix | field | suffix. Positioned so the
291
- floating label anchors to the input area, not the whole control. */
292
- .textfield-field {
293
- position: relative;
294
- display: flex;
295
- align-items: center;
296
- align-self: stretch;
297
- flex: 1;
298
- min-width: 0;
299
- }
300
-
301
- /* Input */
302
- .textfield-input {
303
- flex: 1;
304
- min-width: 0;
305
- width: 100%;
306
- border: none;
307
- outline: none;
308
- padding: var(--rel-spacing-xs) var(--rel-spacing-sm);
309
- background: transparent;
310
- color: var(--rel-text-body);
311
- font-family: var(--rel-body-md-regular-font-family);
312
- font-weight: var(--rel-body-md-regular-font-weight);
313
- font-size: var(--rel-body-md-regular-font-size);
314
- line-height: var(--rel-body-md-regular-line-height);
315
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
316
- }
317
-
318
- .textfield-input:disabled {
319
- cursor: not-allowed;
320
- color: var(--rel-text-disabled);
321
- }
322
-
323
- /* Textarea */
324
- textarea.textfield-input {
325
- resize: vertical;
326
- min-height: 80px;
327
- width: 100%;
328
- box-sizing: border-box;
329
- }
330
-
331
- textarea.textfield-input::-webkit-scrollbar {
332
- width: 4px;
333
- }
334
- textarea.textfield-input::-webkit-scrollbar-track {
335
- background: transparent;
336
- }
337
- textarea.textfield-input::-webkit-scrollbar-thumb {
338
- background: var(--rel-text-placeholder);
339
- border-radius: 2px;
340
- }
341
-
342
- /* ── Prefix / suffix blocks (Figma .Preffix / .Suffix) ──
343
- Flex children of the control, stretched to its height. Each holds an
344
- icon and/or a short text label plus a named slot for custom content
345
- (a unit dropdown, an action button…). Colour follows Figma: text-default
346
- for both icon and text, like rel-select's trigger icons. */
347
- .textfield-affix {
348
- display: flex;
349
- align-items: center;
350
- align-self: stretch;
351
- flex: none;
352
- gap: var(--rel-spacing-xs);
353
- box-sizing: border-box;
354
- color: var(--rel-text-default);
355
- white-space: nowrap;
356
- transition: border-color 0.2s, background 0.2s;
357
- }
358
-
359
- .textfield-affix.hidden {
360
- display: none;
361
- }
362
-
363
- .textfield-affix rel-icon {
364
- --rel-icon-size: 18px;
365
- flex: none;
366
- }
367
- .textfield-wrapper.small .textfield-affix rel-icon {
368
- --rel-icon-size: 16px;
369
- }
370
- .textfield-wrapper.large .textfield-affix rel-icon {
371
- --rel-icon-size: 20px;
372
- }
373
-
374
- .affix-text {
375
- font-family: var(--rel-body-md-medium-font-family);
376
- font-weight: var(--rel-body-md-medium-font-weight);
377
- font-size: var(--rel-body-md-medium-font-size);
378
- line-height: var(--rel-body-md-medium-line-height);
379
- letter-spacing: var(--rel-body-md-medium-letter-spacing);
380
- }
381
- .textfield-wrapper.small .affix-text {
382
- font-family: var(--rel-body-sm-medium-font-family);
383
- font-weight: var(--rel-body-sm-medium-font-weight);
384
- font-size: var(--rel-body-sm-medium-font-size);
385
- line-height: var(--rel-body-sm-medium-line-height);
386
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
387
- }
388
- .textfield-wrapper.large .affix-text {
389
- font-family: var(--rel-body-lg-medium-font-family);
390
- font-weight: var(--rel-body-lg-medium-font-weight);
391
- font-size: var(--rel-body-lg-medium-font-size);
392
- line-height: var(--rel-body-lg-medium-line-height);
393
- letter-spacing: var(--rel-body-lg-medium-letter-spacing);
394
- }
395
-
396
- /* Prefix — Style=Clear: bare; icon-only keeps the input's own left padding
397
- as the gap, text pads both sides. */
398
- .textfield-affix.prefix {
399
- padding-inline: var(--rel-spacing-sm) 0;
400
- }
401
- .textfield-affix.prefix.has-text {
402
- padding-inline: var(--rel-spacing-sm);
403
- }
404
- /* Style=Divider: hairline on the right */
405
- .textfield-affix.prefix.divider {
406
- padding-inline: var(--rel-spacing-sm);
407
- border-right: 1px solid var(--rel-border-default);
408
- }
409
- /* Style=Fill: tinted block flush with the control's edge, sm gap after */
410
- .textfield-affix.prefix.fill {
411
- padding-inline: var(--rel-spacing-sm);
412
- margin-right: var(--rel-spacing-sm);
413
- background: var(--rel-bg-neutral-elevated-2);
414
- border-radius: calc(var(--rel-border-radius-xs) - 1px) 0 0
415
- calc(var(--rel-border-radius-xs) - 1px);
416
- }
417
-
418
- /* Suffix — Divider=False: pl xs / pr sm; Divider=True: hairline on the left */
419
- .textfield-affix.suffix {
420
- padding-inline: var(--rel-spacing-xs) var(--rel-spacing-sm);
421
- }
422
- .textfield-affix.suffix.divider {
423
- padding-inline: var(--rel-spacing-sm);
424
- border-left: 1px solid var(--rel-border-default);
425
- }
426
-
427
- /* Size=S tightens every inline pad to xs */
428
- .textfield-wrapper.small .textfield-affix.prefix {
429
- padding-inline: var(--rel-spacing-xs) 0;
430
- }
431
- .textfield-wrapper.small .textfield-affix.prefix.has-text,
432
- .textfield-wrapper.small .textfield-affix.prefix.divider,
433
- .textfield-wrapper.small .textfield-affix.prefix.fill,
434
- .textfield-wrapper.small .textfield-affix.suffix,
435
- .textfield-wrapper.small .textfield-affix.suffix.divider {
436
- padding-inline: var(--rel-spacing-xs);
437
- }
438
-
439
- .textfield-wrapper.disabled .textfield-affix {
440
- color: var(--rel-text-disabled);
441
- }
442
-
443
- .icon {
444
- display: flex;
445
- }
446
-
447
- /* Interactive trailing icon (e.g. password show/hide) */
448
- .icon.right.clickable {
449
- cursor: pointer;
450
- border-radius: var(--rel-border-radius-xs, 4px);
451
- }
452
- .icon.right.clickable:hover {
453
- color: var(--rel-text-body);
454
- }
455
- .icon.right.clickable:focus-visible {
456
- outline: 2px solid var(--rel-border-focus);
457
- outline-offset: 2px;
458
- }
459
-
460
- .textfield-wrapper.small .textfield-support {
461
- font-weight: var(--rel-body-xs-medium-font-weight);
462
- }
463
-
464
- .textfield-wrapper.small .textfield-input {
465
- padding: var(--rel-spacing-xs) var(--rel-spacing-sm);
466
- font-family: var(--rel-body-sm-regular-font-family);
467
- font-weight: var(--rel-body-sm-regular-font-weight);
468
- font-size: var(--rel-body-sm-regular-font-size);
469
- line-height: var(--rel-body-sm-regular-line-height);
470
- letter-spacing: var(--rel-body-sm-regular-letter-spacing);
471
- }
472
-
473
- .textfield-wrapper.medium .textfield-input {
474
- padding: var(--rel-spacing-sm) var(--rel-spacing-md);
475
- font-family: var(--rel-body-md-regular-font-family);
476
- font-weight: var(--rel-body-md-regular-font-weight);
477
- font-size: var(--rel-body-md-regular-font-size);
478
- line-height: var(--rel-body-md-regular-line-height);
479
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
480
- }
481
-
482
- .textfield-wrapper.large .textfield-input {
483
- padding: var(--rel-spacing-md) var(--rel-spacing-md);
484
- font-family: var(--rel-body-lg-regular-font-family);
485
- font-weight: var(--rel-body-lg-regular-font-weight);
486
- font-size: var(--rel-body-lg-regular-font-size);
487
- line-height: var(--rel-body-lg-regular-line-height);
488
- letter-spacing: var(--rel-body-lg-regular-letter-spacing);
489
- }
490
-
491
- /* States */
492
- /* Hover (Figma State=Hover): border-strong at 1px — no focus ring */
493
- .textfield-wrapper:not(.focused):not(.error):not(.disabled) .textfield-container:hover {
494
- border-color: var(--rel-border-strong);
495
- }
496
-
497
- .textfield-wrapper.focused .textfield-container {
498
- border-color: var(--rel-text-default);
499
- }
500
-
501
- .textfield-input:focus-visible {
502
- outline: none;
503
- }
504
-
505
- .textfield-wrapper.focused .textfield-container,
506
- .textfield-container:focus-within {
507
- border-color: var(--rel-border-strong);
508
- box-shadow: 0 0 0 1px var(--rel-border-strong);
509
- }
510
-
511
- .textfield-wrapper.error .textfield-container,
512
- .textfield-wrapper.error .textfield-container:focus-within {
513
- border-color: var(--rel-border-danger);
514
- box-shadow: none;
515
- }
516
-
517
- .textfield-wrapper.disabled .textfield-container {
518
- border-color: var(--rel-border-default);
519
- }
520
-
521
- .textfield-wrapper.disabled .textfield-label {
522
- color: var(--rel-text-disabled);
523
- }
524
-
525
- /* Supporting text */
526
- .textfield-support {
527
- color: var(--rel-text-caption);
528
-
529
- font-family: var(--rel-body-xs-regular-font-family);
530
-
531
- font-weight: var(--rel-body-xs-regular-font-weight);
532
-
533
- font-size: var(--rel-body-xs-regular-font-size);
534
-
535
- line-height: var(--rel-body-xs-regular-line-height);
536
-
537
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
538
-
539
- }
540
-
541
- .textfield-support.error {
542
- color: var(--rel-text-danger);
543
- }
544
-
545
- .textfield-support.empty {
546
- margin-top: calc(-1 * var(--rel-spacing-2xs));
547
- }
548
-
549
- /* Placeholder */
550
- .textfield-input::placeholder {
551
- color: var(--rel-text-placeholder);
552
- }
553
-
554
- :host([floatinglabel]) .textfield-input::placeholder {
555
- opacity: 0;
556
- }
557
-
558
- :host([floatinglabel]) .textfield-wrapper.focused .textfield-input::placeholder {
559
- opacity: 1;
560
- }
561
-
562
- /* Suppress Chrome autofill blue background */
563
- .textfield-input:-webkit-autofill,
564
- .textfield-input:-webkit-autofill:hover,
565
- .textfield-input:-webkit-autofill:focus {
566
- -webkit-box-shadow: 0 0 0px 1000px var(--rel-bg-surface) inset;
567
- -webkit-text-fill-color: var(--rel-text-default);
568
- }
569
-
570
- /* ── Underline variant ── */
571
- :host([variant="underline"]) .textfield-container {
572
- border: none;
573
- border-bottom: 2px solid var(--rel-border-default);
574
- border-radius: 0;
575
- background: var(--rel-bg-neutral-elevated-1);
576
- box-shadow: none;
577
- overflow: visible;
578
- }
579
-
580
- :host([variant="underline"]) .textfield-wrapper:not(.focused):not(.error):not(.disabled) .textfield-container:hover {
581
- border-bottom-color: var(--rel-border-strong);
582
- }
583
-
584
- :host([variant="underline"]) .textfield-wrapper.focused .textfield-container,
585
- :host([variant="underline"]) .textfield-container:focus-within {
586
- border-bottom: 2px solid var(--rel-text-default);
587
- box-shadow: none;
588
- }
589
-
590
- :host([variant="underline"]) .textfield-wrapper.error .textfield-container {
591
- border-bottom: 2px solid var(--rel-border-danger);
592
- box-shadow: none;
593
- }
594
-
595
- :host([variant="underline"]) .textfield-wrapper.disabled .textfield-container {
596
- border-bottom: 2px solid var(--rel-border-default);
597
- background: var(--rel-bg-neutral-elevated-1);
598
- }
599
-
600
- /* Remove border radius on input for underline variant */
601
- :host([variant="underline"]) .textfield-input {
602
- background: transparent;
603
- }
604
-
605
- /* Dark mode — underline variant uses same border colors as default */
606
- :host-context([data-theme="dark"]) :host([variant="underline"]) .textfield-container,
607
- :host-context(.dark) :host([variant="underline"]) .textfield-container {
608
- background: var(--rel-bg-neutral-elevated-1);
609
- border-bottom-color: var(--rel-border-default);
610
- }
611
-
612
- /* ── Full-width control (fullWidth defaults true → block, fills parent) ── */
613
- :host(:not([fullwidth])) {
614
- display: inline-block;
615
- width: auto;
616
- }
617
- :host(:not([fullwidth])) .textfield-wrapper {
618
- width: auto;
619
- }
620
-
621
- /* ── Legend (notched-outline) variant ──
622
- Native <fieldset>/<legend>: the legend notches the top border and stays
623
- fixed in place across all states (no float/animation). */
624
- :host([variant="legend"]) .field-fieldset {
625
- position: relative;
626
- margin: 0;
627
- min-inline-size: 0;
628
- padding: 0;
629
- border: 1px solid var(--rel-border-default);
630
- border-radius: var(--rel-border-radius-xs);
631
- background: var(--rel-bg-neutral);
632
- transition: border-color 0.2s;
633
- }
634
-
635
- :host([variant="legend"]) .field-legend {
636
- margin-left: var(--rel-spacing-sm);
637
- padding: 0 var(--rel-spacing-2xs);
638
- color: var(--rel-text-label);
639
- font-family: var(--rel-body-sm-medium-font-family);
640
- font-weight: var(--rel-body-sm-medium-font-weight);
641
- font-size: var(--rel-body-sm-medium-font-size);
642
- line-height: var(--rel-body-sm-medium-line-height);
643
- letter-spacing: var(--rel-body-sm-medium-letter-spacing);
644
- }
645
-
646
- :host([variant="legend"]) .textfield-input {
647
- width: 100%;
648
- box-sizing: border-box;
649
- }
650
-
651
- /* labelStyle="none" + legend: nothing to seat in the notch, so drop the
652
- legend entirely and let the top border run continuous. */
653
- :host([label-style="none"][variant="legend"]) .field-legend {
654
- display: none;
655
- }
656
-
657
- /* Legend: prefix | field | suffix sit in a flex row under the legend. The
658
- fieldset's content box starts below the legend's midline, so a fill
659
- prefix can't reach the top border here — square it off instead. */
660
- :host([variant="legend"]) .field-row {
661
- display: flex;
662
- align-items: center;
663
- }
664
- :host([variant="legend"]) .textfield-affix.prefix.fill {
665
- border-radius: 0;
666
- }
667
-
668
- /* Hover */
669
- :host([variant="legend"]) .field-fieldset:hover {
670
- border-color: var(--rel-border-accent);
671
- border-color: var(--rel-text-placeholder);
672
- }
673
-
674
- /* Focus — border-color only. A box-shadow/outline ring hugs the full
675
- rectangular border-box and would draw across the notch, appearing to
676
- strike through the legend. The legend also recolors on focus (below). */
677
- :host([variant="legend"]) .textfield-wrapper.focused .field-fieldset,
678
- :host([variant="legend"]) .field-fieldset:focus-within {
679
- border-color: var(--rel-border-focus);
680
- box-shadow: none;
681
- }
682
- :host([variant="legend"]) .textfield-wrapper.focused .field-legend,
683
- :host([variant="legend"]) .field-fieldset:focus-within .field-legend {
684
- color: var(--rel-border-focus);
685
- }
686
-
687
- /* Error */
688
- :host([variant="legend"]) .textfield-wrapper.error .field-fieldset {
689
- border-color: var(--rel-border-danger);
690
- box-shadow: none;
691
- }
692
- :host([variant="legend"]) .textfield-wrapper.error .field-legend {
693
- color: var(--rel-text-danger);
694
- }
695
-
696
- /* Disabled */
697
- :host([variant="legend"]) .textfield-wrapper.disabled .field-fieldset {
698
- background: var(--rel-bg-neutral-elevated-1);
699
- border-color: var(--rel-border-default);
700
- cursor: not-allowed;
701
- }
702
- :host([variant="legend"]) .textfield-wrapper.disabled .field-legend {
703
- color: var(--rel-text-disabled);
704
- }
705
-
706
- /* Readonly */
707
- :host([variant="legend"]) .textfield-wrapper.readonly .field-fieldset {
708
- cursor: default;
709
- }
710
-
711
- /* Legend font tracks size */
712
- :host([variant="legend"]) .textfield-wrapper.small .field-legend {
713
-
714
- font-family: var(--rel-body-xs-regular-font-family);
715
-
716
- font-weight: var(--rel-body-xs-regular-font-weight);
717
-
718
- font-size: var(--rel-body-xs-regular-font-size);
719
-
720
- line-height: var(--rel-body-xs-regular-line-height);
721
-
722
- letter-spacing: var(--rel-body-xs-regular-letter-spacing);
723
-
724
- }
725
- :host([variant="legend"]) .textfield-wrapper.large .field-legend {
726
-
727
- font-family: var(--rel-body-md-regular-font-family);
728
-
729
- font-weight: var(--rel-body-md-regular-font-weight);
730
-
731
- font-size: var(--rel-body-md-regular-font-size);
732
-
733
- line-height: var(--rel-body-md-regular-line-height);
734
-
735
- letter-spacing: var(--rel-body-md-regular-letter-spacing);
736
-
737
- }
738
- `;
739
-
740
- connectedCallback() {
741
- super.connectedCallback();
742
- const leftIcon = this.getAttribute('lefticon') || this.getAttribute('leftIcon');
743
- if (leftIcon) this.leftIcon = leftIcon;
744
- const rightIcon = this.getAttribute('righticon') || this.getAttribute('rightIcon');
745
- if (rightIcon) this.rightIcon = rightIcon;
746
- // Seed slot presence from static markup; slotchange keeps it current after.
747
- this.slotted = {
748
- prefix: !!this.querySelector(':scope > [slot="prefix"]'),
749
- suffix: !!this.querySelector(':scope > [slot="suffix"]'),
750
- };
751
- }
752
-
753
- disconnectedCallback() {
754
- super.disconnectedCallback();
755
- this._prefixObserver?.disconnect();
756
- }
757
-
758
- private handleSlotChange(e: Event) {
759
- const slot = e.target as HTMLSlotElement;
760
- const key = slot.name as "prefix" | "suffix";
761
- const has = slot
762
- .assignedNodes({ flatten: true })
763
- .some((n) => n.nodeType === Node.ELEMENT_NODE || (n.textContent ?? "").trim() !== "");
764
- if (this.slotted[key] !== has) this.slotted = { ...this.slotted, [key]: has };
765
- }
766
-
767
- /** Clicking the (non-interactive) prefix/suffix area focuses the input, as a
768
- * label would. Clickable icons and slotted controls keep their own clicks. */
769
- private handleAffixClick(e: Event) {
770
- const target = e.target as HTMLElement;
771
- if (target.closest(".clickable") || target.assignedSlot || target.closest("[slot]")) return;
772
- this.focus();
773
- }
774
-
775
- /** Publishes the prefix block's width as --_rel-tf-prefix-w on its parent so
776
- * the floated label can slide back over a clear-style prefix (see CSS). */
777
- private observePrefix() {
778
- if (typeof ResizeObserver === "undefined") return;
779
- const prefix = this.renderRoot.querySelector<HTMLElement>(".textfield-affix.prefix");
780
- this._prefixObserver ??= new ResizeObserver((entries) => {
781
- for (const entry of entries) {
782
- const el = entry.target as HTMLElement;
783
- el.parentElement?.style.setProperty("--_rel-tf-prefix-w", `${el.offsetWidth}px`);
784
- }
785
- });
786
- this._prefixObserver.disconnect();
787
- if (prefix) this._prefixObserver.observe(prefix);
788
- }
789
-
790
- willUpdate(changed: PropertyValues<this>) {
791
- // Keep the deprecated boolean an accurate mirror of labelStyle. This is what
792
- // lets every `:host([floatinglabel])` rule below stay untouched — the
793
- // reflected attribute is still the single styling hook for the floating form.
794
- if (changed.has("labelStyle") && this.labelStyle) {
795
- this.floatingLabel = this.labelStyle === "floating";
796
- }
797
- }
798
-
799
- private _warnedNoName = false;
800
-
801
- updated() {
802
- this.observePrefix();
803
- if (this._warnedNoName || !this.labelHidden) return;
804
- if (this.fieldAriaLabel || this.fieldAriaLabelledby || this.getAttribute("aria-label")) return;
805
- this._warnedNoName = true;
806
- console.warn(
807
- '<rel-textfield label-style="none"> has no accessible name. Set ' +
808
- "`field-aria-label` or `field-aria-labelledby` — a placeholder is not a " +
809
- "valid naming mechanism.",
810
- this
811
- );
812
- }
813
-
814
- /** Focuses the inner input/textarea (the host itself is not focusable). */
815
- focus(options?: FocusOptions) {
816
- (this.renderRoot.querySelector("input, textarea") as HTMLElement | null)?.focus(options);
817
- }
818
-
819
- private handleFocus() {
820
- if (!this.isDisabled) {
821
- this.internalState = "focused";
822
- }
823
- }
824
-
825
- private handleBlur() {
826
- if (this.internalState === "focused") {
827
- this.internalState = "default";
828
- }
829
- }
830
-
831
- private handleRightIconClick(e: Event) {
832
- if (!this.clickableRightIcon) return;
833
- e.stopPropagation();
834
- this.dispatchEvent(
835
- new CustomEvent("rel-right-icon-click", { bubbles: true, composed: true })
836
- );
837
- }
838
-
839
- private handleRightIconKeydown(e: KeyboardEvent) {
840
- if (!this.clickableRightIcon) return;
841
- if (e.key === "Enter" || e.key === " ") {
842
- e.preventDefault();
843
- this.handleRightIconClick(e);
844
- }
845
- }
846
-
847
- private handleInput(e: Event) {
848
- const input = e.target as HTMLInputElement;
849
- this.value = input.value;
850
- if (this.state === "error" && this.value) {
851
- this._wasError = true;
852
- this.state = "default";
853
- } else if (this._wasError && !this.value) {
854
- this._wasError = false;
855
- this.state = "error";
856
- }
857
- this.dispatchEvent(
858
- new CustomEvent<string>("rel-change", {
859
- detail: this.value,
860
- bubbles: true,
861
- composed: true,
862
- })
863
- );
864
- }
865
-
866
- render() {
867
- const isError = this.isError;
868
- const stateClass = this.isDisabled ? "disabled" : isError ? "error" : "default";
869
- const leadingIcon = this.leadingIcon;
870
- const inputId = this.id || this.uniqueId;
871
- const legendId = `${inputId}-legend`;
872
-
873
- // errorMessage replaces the helper only when in error AND explicitly set;
874
- // otherwise the (deprecated) supportingText/helperText shows as before.
875
- const belowText = isError && this.errorMessage ? this.errorMessage : this.helper;
876
- const describedById = `${inputId}-desc`;
877
-
878
- const wrapperClasses = [
879
- "textfield-wrapper",
880
- this.size,
881
- stateClass,
882
- this.readonly ? "readonly" : "",
883
- this.internalState === "focused" ? "focused" : "",
884
- this.value ? "has-value" : "",
885
- ].filter(Boolean).join(" ");
886
-
887
- const inputClasses = "textfield-input";
888
-
889
- // Prefix / suffix blocks. Hidden (not removed) in multiline mode so the
890
- // named slots stay mounted and slotchange keeps tracking content.
891
- const affixesShown = !this.multiline;
892
- const hasPrefix = affixesShown && !!(leadingIcon || this.prefixText || this.slotted.prefix);
893
- const hasSuffix = affixesShown && !!(this.rightIcon || this.suffixText || this.slotted.suffix);
894
- const prefixClear = hasPrefix && this.prefixStyle === "clear";
895
-
896
- const labelStyle = this.resolvedLabelStyle;
897
- const labelHidden = labelStyle === "none";
898
-
899
- const labelTemplate = (extraClass = "") => {
900
- if (!this.label || labelHidden) return "";
901
- return html`<label
902
- part="label"
903
- class="textfield-label${extraClass}"
904
- for="${inputId}"
905
- >${this.label}${this.required ? html`<span class="required-mark" aria-hidden="true">*</span>` : ""}</label>`;
906
- };
907
-
908
- // With no visible label the <label for> / <legend> naming path is gone, so
909
- // fieldAriaLabelledby → fieldAriaLabel take over. An explicit labelledby
910
- // always wins; aria-label only fills in when nothing else names the input.
911
- const legendLabelledby =
912
- this.variant === "legend" && this.label && !labelHidden ? legendId : undefined;
913
- const ariaLabelledby = this.fieldAriaLabelledby ?? legendLabelledby;
914
- const hasVisibleLabel = !labelHidden && !!this.label;
915
- const ariaLabel = !hasVisibleLabel && !ariaLabelledby ? this.fieldAriaLabel : undefined;
916
-
917
- const inputTemplate = this.multiline
918
- ? html`<textarea part="input"
919
- id="${inputId}"
920
- class="${inputClasses}"
921
- placeholder="${this.placeholder}"
922
- .value="${this.value}"
923
- rows="${this.rows}"
924
- name="${this.name ?? nothing}"
925
- maxlength="${this.maxLength ?? nothing}"
926
- ?disabled="${this.isDisabled}"
927
- ?readonly="${this.readonly}"
928
- ?required="${this.required}"
929
- aria-invalid="${isError}"
930
- aria-required="${this.required}"
931
- aria-label="${ariaLabel ?? nothing}"
932
- aria-labelledby="${ariaLabelledby ?? nothing}"
933
- aria-describedby="${describedById}"
934
- @focus="${this.handleFocus}"
935
- @blur="${this.handleBlur}"
936
- @input="${this.handleInput}"
937
- ></textarea>`
938
- : html`<input part="input"
939
- type="${this.type}"
940
- id="${inputId}"
941
- class="${inputClasses}"
942
- placeholder="${this.placeholder}"
943
- .value="${this.value}"
944
- name="${this.name ?? nothing}"
945
- maxlength="${this.maxLength ?? nothing}"
946
- ?disabled="${this.isDisabled}"
947
- ?readonly="${this.readonly}"
948
- ?required="${this.required}"
949
- aria-invalid="${isError}"
950
- aria-required="${this.required}"
951
- aria-label="${ariaLabel ?? nothing}"
952
- aria-labelledby="${ariaLabelledby ?? nothing}"
953
- aria-describedby="${describedById}"
954
- @focus="${this.handleFocus}"
955
- @blur="${this.handleBlur}"
956
- @input="${this.handleInput}"
957
- />`;
958
-
959
- const leadingIconTemplate = leadingIcon
960
- ? html`<rel-icon
961
- name="${leadingIcon}"
962
- class="icon left"
963
- role="${this.prefixIconAriaLabel ? "img" : nothing}"
964
- aria-label="${this.prefixIconAriaLabel ?? nothing}"
965
- aria-hidden="${this.prefixIconAriaLabel ? nothing : "true"}"
966
- ></rel-icon>`
967
- : "";
968
-
969
- const trailingIconTemplate = this.rightIcon
970
- ? html`<rel-icon
971
- part="right-icon"
972
- name="${this.rightIcon}"
973
- class="icon right ${this.clickableRightIcon ? "clickable" : ""}"
974
- role="${this.clickableRightIcon ? "button" : nothing}"
975
- tabindex="${this.clickableRightIcon ? "0" : nothing}"
976
- aria-label="${this.clickableRightIcon ? (this.rightIconAriaLabel ?? nothing) : nothing}"
977
- aria-hidden="${this.clickableRightIcon ? nothing : "true"}"
978
- @click="${(e: Event) => this.handleRightIconClick(e)}"
979
- @keydown="${(e: KeyboardEvent) => this.handleRightIconKeydown(e)}"
980
- ></rel-icon>`
981
- : "";
982
-
983
- // Order inside each block: slotted content sits outermost (a unit dropdown
984
- // at the far left, an action button at the far right), then icon, then text
985
- // nearest the input.
986
- const prefixClasses = [
987
- "textfield-affix",
988
- "prefix",
989
- this.prefixStyle,
990
- this.prefixText || this.slotted.prefix ? "has-text" : "",
991
- hasPrefix ? "" : "hidden",
992
- ].filter(Boolean).join(" ");
993
- const prefixTemplate = html`<div part="prefix" class="${prefixClasses}" @click="${this.handleAffixClick}">
994
- <slot name="prefix" @slotchange="${this.handleSlotChange}"></slot>
995
- ${hasPrefix ? leadingIconTemplate : ""}
996
- ${hasPrefix && this.prefixText ? html`<span class="affix-text">${this.prefixText}</span>` : ""}
997
- </div>`;
998
-
999
- const suffixClasses = [
1000
- "textfield-affix",
1001
- "suffix",
1002
- this.suffixDivider ? "divider" : "",
1003
- hasSuffix ? "" : "hidden",
1004
- ].filter(Boolean).join(" ");
1005
- const suffixTemplate = html`<div part="suffix" class="${suffixClasses}" @click="${this.handleAffixClick}">
1006
- ${hasSuffix && this.suffixText ? html`<span class="affix-text">${this.suffixText}</span>` : ""}
1007
- ${hasSuffix ? trailingIconTemplate : ""}
1008
- <slot name="suffix" @slotchange="${this.handleSlotChange}"></slot>
1009
- </div>`;
1010
-
1011
- const belowTemplate = html`<div part="helper" class="${["textfield-support", isError ? "error" : "", belowText ? "" : "empty"].filter(Boolean).join(" ")}" id="${describedById}" aria-live="polite">${belowText ?? ""}</div>`;
1012
-
1013
- if (this.variant === "legend") {
1014
- const fieldsetClass = ["field-fieldset", this.multiline ? "multiline" : ""].filter(Boolean).join(" ");
1015
- // The <legend> MUST be the fieldset's first child with no preceding
1016
- // whitespace/text or binding-comment, otherwise the browser won't cut the
1017
- // notch in the top border. So it's rendered flush against the tag open and
1018
- // is always present (only its content is dynamic).
1019
- return html`
1020
- <div class="${wrapperClasses}">
1021
- <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>
1022
- <div class="field-row">
1023
- ${prefixTemplate}
1024
- <div class="textfield-field">${inputTemplate}</div>
1025
- ${suffixTemplate}
1026
- </div>
1027
- </fieldset>
1028
- ${belowTemplate}
1029
- </div>
1030
- `;
1031
- }
1032
-
1033
- return html`
1034
- <div class="${wrapperClasses}">
1035
- ${labelHidden
1036
- ? html`<div class="label-reserve" aria-hidden="true"></div>`
1037
- : labelStyle !== "floating"
1038
- ? labelTemplate()
1039
- : ""}
1040
-
1041
- <div part="control" class="${["textfield-container", this.isDisabled ? "disabled" : "", this.multiline ? "multiline" : "", prefixClear ? "prefix-clear" : ""].filter(Boolean).join(" ")}">
1042
- ${prefixTemplate}
1043
- <div class="textfield-field">
1044
- ${labelStyle === "floating" ? labelTemplate() : ""}
1045
- ${inputTemplate}
1046
- </div>
1047
- ${suffixTemplate}
1048
- </div>
1049
-
1050
- ${belowTemplate}
1051
- </div>
1052
- `;
1053
- }
1054
- }