@f-ewald/components 1.22.2 → 1.23.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.
- package/custom-elements.json +598 -6
- package/dist/address-autocomplete.d.ts +14 -0
- package/dist/address-autocomplete.d.ts.map +1 -1
- package/dist/address-autocomplete.js +205 -3
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/autocomplete-input.d.ts +14 -0
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +205 -3
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/form-field.d.ts +29 -1
- package/dist/form-field.d.ts.map +1 -1
- package/dist/form-field.js +376 -4
- package/dist/form-field.js.map +1 -1
- package/dist/text-area.d.ts +9 -0
- package/dist/text-area.d.ts.map +1 -1
- package/dist/text-area.js +123 -11
- package/dist/text-area.js.map +1 -1
- package/dist/utils/form-field-control.d.ts +15 -0
- package/dist/utils/form-field-control.d.ts.map +1 -0
- package/dist/utils/form-field-control.js +7 -0
- package/dist/utils/form-field-control.js.map +1 -0
- package/docs/address-autocomplete.md +9 -0
- package/docs/autocomplete-input.md +9 -1
- package/docs/design-language.md +11 -0
- package/docs/form-field.md +18 -0
- package/docs/text-area.md +9 -1
- package/llms.txt +32 -11
- package/package.json +1 -1
package/dist/text-area.js
CHANGED
|
@@ -4,15 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { LitElement, css, html } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
7
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
import { tokens } from "./tokens.js";
|
|
10
|
+
import { formFieldControl, } from "./utils/form-field-control.js";
|
|
11
|
+
let instanceCount = 0;
|
|
10
12
|
/**
|
|
11
13
|
* Plain multi-line text field — a thin, tokenized wrapper around a native
|
|
12
14
|
* `<textarea>`, styled to match the other value-entry form fields
|
|
13
15
|
* (autocomplete-input, form-select, ...). Not a rich editor; use `readonly`
|
|
14
16
|
* to display pre-formatted text (e.g. an error message) that the user can
|
|
15
17
|
* still select and copy, typically paired with `<copy-link-button>`.
|
|
18
|
+
* Supports `form-field`'s opt-in floating-label mode when slotted inside it.
|
|
16
19
|
*
|
|
17
20
|
* @element text-area
|
|
18
21
|
* @fires input - Fires on every keystroke; detail: { value: string }.
|
|
@@ -31,6 +34,16 @@ let TextArea = class TextArea extends LitElement {
|
|
|
31
34
|
this.readonly = false;
|
|
32
35
|
/** Disables the field entirely (no interaction, dimmed). */
|
|
33
36
|
this.disabled = false;
|
|
37
|
+
this._formFieldConfig = null;
|
|
38
|
+
this.#textareaId = `text-area-field-${++instanceCount}`;
|
|
39
|
+
}
|
|
40
|
+
#textareaId;
|
|
41
|
+
/**
|
|
42
|
+
* Applies or clears label configuration supplied by a wrapping `form-field`.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
[formFieldControl](config) {
|
|
46
|
+
this._formFieldConfig = config;
|
|
34
47
|
}
|
|
35
48
|
static { this.styles = [
|
|
36
49
|
tokens,
|
|
@@ -38,6 +51,9 @@ let TextArea = class TextArea extends LitElement {
|
|
|
38
51
|
:host {
|
|
39
52
|
display: block;
|
|
40
53
|
}
|
|
54
|
+
.field-shell {
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
41
57
|
textarea {
|
|
42
58
|
display: block;
|
|
43
59
|
box-sizing: border-box;
|
|
@@ -61,6 +77,69 @@ let TextArea = class TextArea extends LitElement {
|
|
|
61
77
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
62
78
|
resize: vertical;
|
|
63
79
|
}
|
|
80
|
+
.floating-label {
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: 0.5rem;
|
|
83
|
+
left: 0.75rem;
|
|
84
|
+
right: 0.75rem;
|
|
85
|
+
z-index: 1;
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: baseline;
|
|
88
|
+
gap: 0.25rem;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
color: var(--ui-text-muted, #64748b);
|
|
91
|
+
font-family: var(
|
|
92
|
+
--ui-font,
|
|
93
|
+
ui-sans-serif,
|
|
94
|
+
system-ui,
|
|
95
|
+
sans-serif,
|
|
96
|
+
"Apple Color Emoji",
|
|
97
|
+
"Segoe UI Emoji",
|
|
98
|
+
"Segoe UI Symbol",
|
|
99
|
+
"Noto Color Emoji"
|
|
100
|
+
);
|
|
101
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
102
|
+
font-weight: var(--ui-font-weight-regular, 400);
|
|
103
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
text-overflow: ellipsis;
|
|
106
|
+
cursor: text;
|
|
107
|
+
transition:
|
|
108
|
+
top 150ms ease,
|
|
109
|
+
font-size 150ms ease;
|
|
110
|
+
}
|
|
111
|
+
.field-shell.floating textarea {
|
|
112
|
+
min-height: 3rem;
|
|
113
|
+
padding-top: 1.25rem;
|
|
114
|
+
}
|
|
115
|
+
.field-shell.floating.has-value .floating-label,
|
|
116
|
+
.field-shell.floating:focus-within .floating-label {
|
|
117
|
+
top: 0.25rem;
|
|
118
|
+
font-size: var(--ui-font-size-xs, 0.6875rem);
|
|
119
|
+
}
|
|
120
|
+
.field-shell.floating:not(.has-value):not(:focus-within) textarea::placeholder {
|
|
121
|
+
opacity: 0;
|
|
122
|
+
}
|
|
123
|
+
.field-shell.disabled .floating-label {
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
opacity: 0.6;
|
|
126
|
+
}
|
|
127
|
+
.required-mark {
|
|
128
|
+
flex: 0 0 auto;
|
|
129
|
+
color: var(--ui-danger, #dc2626);
|
|
130
|
+
}
|
|
131
|
+
.sr-only {
|
|
132
|
+
position: absolute;
|
|
133
|
+
width: 1px;
|
|
134
|
+
height: 1px;
|
|
135
|
+
margin: -1px;
|
|
136
|
+
padding: 0;
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
clip: rect(0 0 0 0);
|
|
139
|
+
clip-path: inset(50%);
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
border: 0;
|
|
142
|
+
}
|
|
64
143
|
textarea:read-only {
|
|
65
144
|
background: var(--ui-surface-muted, #f8fafc);
|
|
66
145
|
}
|
|
@@ -83,6 +162,15 @@ let TextArea = class TextArea extends LitElement {
|
|
|
83
162
|
color: GrayText;
|
|
84
163
|
opacity: 1;
|
|
85
164
|
}
|
|
165
|
+
.field-shell.disabled .floating-label {
|
|
166
|
+
color: GrayText;
|
|
167
|
+
opacity: 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
@media (prefers-reduced-motion: reduce) {
|
|
171
|
+
.floating-label {
|
|
172
|
+
transition: none;
|
|
173
|
+
}
|
|
86
174
|
}
|
|
87
175
|
`,
|
|
88
176
|
]; }
|
|
@@ -102,16 +190,37 @@ let TextArea = class TextArea extends LitElement {
|
|
|
102
190
|
this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value }, bubbles: true, composed: true }));
|
|
103
191
|
}
|
|
104
192
|
render() {
|
|
193
|
+
const floating = Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);
|
|
105
194
|
return html `
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
195
|
+
<div
|
|
196
|
+
class="field-shell ${floating ? "floating" : ""} ${this.value
|
|
197
|
+
? "has-value"
|
|
198
|
+
: ""} ${this.disabled ? "disabled" : ""}"
|
|
199
|
+
>
|
|
200
|
+
${floating
|
|
201
|
+
? html `
|
|
202
|
+
<label class="floating-label" for=${this.#textareaId}>
|
|
203
|
+
<span>${this._formFieldConfig.label}</span>
|
|
204
|
+
${this._formFieldConfig.required
|
|
205
|
+
? html `
|
|
206
|
+
<span class="required-mark" aria-hidden="true">*</span>
|
|
207
|
+
<span class="sr-only"> (required)</span>
|
|
208
|
+
`
|
|
209
|
+
: nothing}
|
|
210
|
+
</label>
|
|
211
|
+
`
|
|
212
|
+
: nothing}
|
|
213
|
+
<textarea
|
|
214
|
+
id=${this.#textareaId}
|
|
215
|
+
.value=${this.value}
|
|
216
|
+
rows=${this.rows}
|
|
217
|
+
placeholder=${this.placeholder}
|
|
218
|
+
?readonly=${this.readonly}
|
|
219
|
+
?disabled=${this.disabled}
|
|
220
|
+
@input=${this._onInput}
|
|
221
|
+
@change=${this._onChange}
|
|
222
|
+
></textarea>
|
|
223
|
+
</div>
|
|
115
224
|
`;
|
|
116
225
|
}
|
|
117
226
|
};
|
|
@@ -130,6 +239,9 @@ __decorate([
|
|
|
130
239
|
__decorate([
|
|
131
240
|
property({ type: Boolean })
|
|
132
241
|
], TextArea.prototype, "disabled", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
state()
|
|
244
|
+
], TextArea.prototype, "_formFieldConfig", void 0);
|
|
133
245
|
TextArea = __decorate([
|
|
134
246
|
customElement("text-area")
|
|
135
247
|
], TextArea);
|
package/dist/text-area.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-area.js","sourceRoot":"","sources":["../src/text-area.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;GAUG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL,4BAA4B;Q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AAI,CAAC,QAAQ;oBACb,IAAI,CAAC,QAAQ;iBAChB,IAAI,CAAC,QAAQ;kBACZ,IAAI,CAAC,SAAS;;KAE3B,CAAC;IACJ,CAAC;CACF,CAAA;AAnGa;IAAX,QAAQ,EAAE;uCAAY;AAEK;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAU;AAEzB;IAAX,QAAQ,EAAE;6CAAkB;AAEA;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAVnC,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAqGpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Plain multi-line text field — a thin, tokenized wrapper around a native\n * `<textarea>`, styled to match the other value-entry form fields\n * (autocomplete-input, form-select, ...). Not a rich editor; use `readonly`\n * to display pre-formatted text (e.g. an error message) that the user can\n * still select and copy, typically paired with `<copy-link-button>`.\n *\n * @element text-area\n * @fires input - Fires on every keystroke; detail: { value: string }.\n * @fires change - Native change semantics (on blur, if the value changed); detail: { value: string }.\n */\n@customElement(\"text-area\")\nexport class TextArea extends LitElement {\n /** Current text content. */\n @property() value = \"\";\n /** Visible row count (native `<textarea rows>`). */\n @property({ type: Number }) rows = 4;\n /** Placeholder text shown when empty. */\n @property() placeholder = \"\";\n /** When true, the value can be selected/copied but not edited. */\n @property({ type: Boolean }) readonly = false;\n /** Disables the field entirely (no interaction, dimmed). */\n @property({ type: Boolean }) disabled = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n resize: vertical;\n }\n textarea:read-only {\n background: var(--ui-surface-muted, #f8fafc);\n }\n textarea:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n textarea:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n textarea:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n textarea:disabled {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n private _onInput(e: Event): void {\n // The native textarea's own \"input\" event is composed (crosses the shadow\n // boundary) — stop it so only our re-dispatched CustomEvent (carrying\n // `detail.value`) reaches consumers. Otherwise the native event bubbles\n // out afterwards too, re-invoking the same \"input\" listener with a plain\n // UIEvent whose `detail` defaults to 0, clobbering consumer state.\n e.stopPropagation();\n this.value = (e.target as HTMLTextAreaElement).value;\n this.dispatchEvent(\n new CustomEvent(\"input\", { detail: { value: this.value }, bubbles: true, composed: true }),\n );\n }\n\n private _onChange(e: Event): void {\n e.stopPropagation();\n this.value = (e.target as HTMLTextAreaElement).value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value: this.value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n return html`\n <textarea\n .value=${this.value}\n rows=${this.rows}\n placeholder=${this.placeholder}\n ?readonly=${this.readonly}\n ?disabled=${this.disabled}\n @input=${this._onInput}\n @change=${this._onChange}\n ></textarea>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"text-area\": TextArea;\n }\n}\n"]}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A;;;qBAGH;gBACH,CAAC,CAAC,OAAO;;aAEd;YACH,CAAC,CAAC,OAAO;;eAEJ,IAAI,CAAC,WAAW;mBACZ,IAAI,CAAC,KAAK;iBACZ,IAAI,CAAC,IAAI;wBACF,IAAI,CAAC,WAAW;sBAClB,IAAI,CAAC,QAAQ;sBACb,IAAI,CAAC,QAAQ;mBAChB,IAAI,CAAC,QAAQ;oBACZ,IAAI,CAAC,SAAS;;;KAG7B,CAAC;IACJ,CAAC;CACF,CAAA;AAhNa;IAAX,QAAQ,EAAE;uCAAY;AAEK;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAU;AAEzB;IAAX,QAAQ,EAAE;6CAAkB;AAEA;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAkB;AAE7B;IAAhB,KAAK,EAAE;kDAAgE;AAZ7D,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAkNpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n type FormFieldControlConfig,\n} from \"./utils/form-field-control.js\";\n\nlet instanceCount = 0;\n\n/**\n * Plain multi-line text field — a thin, tokenized wrapper around a native\n * `<textarea>`, styled to match the other value-entry form fields\n * (autocomplete-input, form-select, ...). Not a rich editor; use `readonly`\n * to display pre-formatted text (e.g. an error message) that the user can\n * still select and copy, typically paired with `<copy-link-button>`.\n * Supports `form-field`'s opt-in floating-label mode when slotted inside it.\n *\n * @element text-area\n * @fires input - Fires on every keystroke; detail: { value: string }.\n * @fires change - Native change semantics (on blur, if the value changed); detail: { value: string }.\n */\n@customElement(\"text-area\")\nexport class TextArea extends LitElement {\n /** Current text content. */\n @property() value = \"\";\n /** Visible row count (native `<textarea rows>`). */\n @property({ type: Number }) rows = 4;\n /** Placeholder text shown when empty. */\n @property() placeholder = \"\";\n /** When true, the value can be selected/copied but not edited. */\n @property({ type: Boolean }) readonly = false;\n /** Disables the field entirely (no interaction, dimmed). */\n @property({ type: Boolean }) disabled = false;\n\n @state() private _formFieldConfig: FormFieldControlConfig | null = null;\n\n readonly #textareaId = `text-area-field-${++instanceCount}`;\n\n /**\n * Applies or clears label configuration supplied by a wrapping `form-field`.\n * @private\n */\n [formFieldControl](config: FormFieldControlConfig | null): void {\n this._formFieldConfig = config;\n }\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .field-shell {\n position: relative;\n }\n textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n resize: vertical;\n }\n .floating-label {\n position: absolute;\n top: 0.5rem;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n overflow: hidden;\n color: var(--ui-text-muted, #64748b);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n font-size 150ms ease;\n }\n .field-shell.floating textarea {\n min-height: 3rem;\n padding-top: 1.25rem;\n }\n .field-shell.floating.has-value .floating-label,\n .field-shell.floating:focus-within .floating-label {\n top: 0.25rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .field-shell.floating:not(.has-value):not(:focus-within) textarea::placeholder {\n opacity: 0;\n }\n .field-shell.disabled .floating-label {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .required-mark {\n flex: 0 0 auto;\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n textarea:read-only {\n background: var(--ui-surface-muted, #f8fafc);\n }\n textarea:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n textarea:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n textarea:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n textarea:disabled {\n color: GrayText;\n opacity: 1;\n }\n .field-shell.disabled .floating-label {\n color: GrayText;\n opacity: 1;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .floating-label {\n transition: none;\n }\n }\n `,\n ];\n\n private _onInput(e: Event): void {\n // The native textarea's own \"input\" event is composed (crosses the shadow\n // boundary) — stop it so only our re-dispatched CustomEvent (carrying\n // `detail.value`) reaches consumers. Otherwise the native event bubbles\n // out afterwards too, re-invoking the same \"input\" listener with a plain\n // UIEvent whose `detail` defaults to 0, clobbering consumer state.\n e.stopPropagation();\n this.value = (e.target as HTMLTextAreaElement).value;\n this.dispatchEvent(\n new CustomEvent(\"input\", { detail: { value: this.value }, bubbles: true, composed: true }),\n );\n }\n\n private _onChange(e: Event): void {\n e.stopPropagation();\n this.value = (e.target as HTMLTextAreaElement).value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value: this.value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n const floating =\n Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);\n return html`\n <div\n class=\"field-shell ${floating ? \"floating\" : \"\"} ${this.value\n ? \"has-value\"\n : \"\"} ${this.disabled ? \"disabled\" : \"\"}\"\n >\n ${floating\n ? html`\n <label class=\"floating-label\" for=${this.#textareaId}>\n <span>${this._formFieldConfig!.label}</span>\n ${this._formFieldConfig!.required\n ? html`\n <span class=\"required-mark\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\"> (required)</span>\n `\n : nothing}\n </label>\n `\n : nothing}\n <textarea\n id=${this.#textareaId}\n .value=${this.value}\n rows=${this.rows}\n placeholder=${this.placeholder}\n ?readonly=${this.readonly}\n ?disabled=${this.disabled}\n @input=${this._onInput}\n @change=${this._onChange}\n ></textarea>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"text-area\": TextArea;\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Configuration supplied by `form-field` to a supported text control. */
|
|
2
|
+
export interface FormFieldControlConfig {
|
|
3
|
+
label: string;
|
|
4
|
+
required: boolean;
|
|
5
|
+
floating: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Internal protocol key used to configure controls across their shadow boundary. */
|
|
8
|
+
export declare const formFieldControl: unique symbol;
|
|
9
|
+
/** A text control that can render label configuration supplied by `form-field`. */
|
|
10
|
+
export interface FormFieldControl extends HTMLElement {
|
|
11
|
+
[formFieldControl](config: FormFieldControlConfig | null): void;
|
|
12
|
+
}
|
|
13
|
+
/** Returns whether an assigned element implements the internal form-field protocol. */
|
|
14
|
+
export declare function supportsFormFieldControl(element: Element): element is FormFieldControl;
|
|
15
|
+
//# sourceMappingURL=form-field-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field-control.d.ts","sourceRoot":"","sources":["../../src/utils/form-field-control.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,eAA+B,CAAC;AAE7D,mFAAmF;AACnF,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;CACjE;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gBAAgB,CAEtF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Internal protocol key used to configure controls across their shadow boundary. */
|
|
2
|
+
export const formFieldControl = Symbol("form-field-control");
|
|
3
|
+
/** Returns whether an assigned element implements the internal form-field protocol. */
|
|
4
|
+
export function supportsFormFieldControl(element) {
|
|
5
|
+
return element instanceof HTMLElement && formFieldControl in element;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=form-field-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field-control.js","sourceRoot":"","sources":["../../src/utils/form-field-control.ts"],"names":[],"mappings":"AAOA,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAO7D,uFAAuF;AACvF,MAAM,UAAU,wBAAwB,CAAC,OAAgB;IACvD,OAAO,OAAO,YAAY,WAAW,IAAI,gBAAgB,IAAI,OAAO,CAAC;AACvE,CAAC","sourcesContent":["/** Configuration supplied by `form-field` to a supported text control. */\nexport interface FormFieldControlConfig {\n label: string;\n required: boolean;\n floating: boolean;\n}\n\n/** Internal protocol key used to configure controls across their shadow boundary. */\nexport const formFieldControl = Symbol(\"form-field-control\");\n\n/** A text control that can render label configuration supplied by `form-field`. */\nexport interface FormFieldControl extends HTMLElement {\n [formFieldControl](config: FormFieldControlConfig | null): void;\n}\n\n/** Returns whether an assigned element implements the internal form-field protocol. */\nexport function supportsFormFieldControl(element: Element): element is FormFieldControl {\n return element instanceof HTMLElement && formFieldControl in element;\n}\n"]}
|
|
@@ -13,6 +13,9 @@ Supports two suggestion sources:
|
|
|
13
13
|
request. Useful for small/fixed address lists, offline use, or tests.
|
|
14
14
|
Takes priority over `endpoint` whenever it's non-null.
|
|
15
15
|
|
|
16
|
+
Set `clearable` to show an in-field clear action whenever a value is
|
|
17
|
+
present.
|
|
18
|
+
|
|
16
19
|
## Install
|
|
17
20
|
|
|
18
21
|
```js
|
|
@@ -23,6 +26,7 @@ import "@f-ewald/components/address-autocomplete.js";
|
|
|
23
26
|
|
|
24
27
|
```html
|
|
25
28
|
<address-autocomplete
|
|
29
|
+
clearable
|
|
26
30
|
placeholder="Start typing an address…"
|
|
27
31
|
access-token="pk.your-mapbox-token"
|
|
28
32
|
></address-autocomplete>
|
|
@@ -36,6 +40,7 @@ import "@f-ewald/components/address-autocomplete.js";
|
|
|
36
40
|
| `placeholder` | `placeholder` | `string` | `""` | Placeholder text shown when the input is empty. |
|
|
37
41
|
| `required` | `required` | `boolean` | `false` | Marks the input as required for native form validation. |
|
|
38
42
|
| `disabled` | `disabled` | `boolean` | `false` | Disables the input and closes its suggestion popup. |
|
|
43
|
+
| `clearable` | `clearable` | `boolean` | `false` | Shows an in-field clear action while the control has a value. |
|
|
39
44
|
| `types` | `types` | `string` | `"address"` | Mapbox `types` param, e.g. "address" or "address,poi". |
|
|
40
45
|
| `endpoint` | `endpoint` | `string` | `"https://api.mapbox.com/search/geocode/v6/forward"` | Geocoding endpoint URL. Defaults to the Mapbox Geocoding v6 forward URL. |
|
|
41
46
|
| `accessToken` | `access-token` | `string` | `""` | Mapbox access token. Required for requests to succeed. |
|
|
@@ -51,6 +56,7 @@ import "@f-ewald/components/address-autocomplete.js";
|
|
|
51
56
|
| Event | Description |
|
|
52
57
|
| --- | --- |
|
|
53
58
|
| `address-select` | A suggestion was picked; detail: AddressSuggestion. |
|
|
59
|
+
| `input` | Native-compatible input event fired while editing or clearing. |
|
|
54
60
|
|
|
55
61
|
## Slots
|
|
56
62
|
|
|
@@ -61,9 +67,12 @@ _None._
|
|
|
61
67
|
| Custom property |
|
|
62
68
|
| --- |
|
|
63
69
|
| `--ui-border` |
|
|
70
|
+
| `--ui-danger` |
|
|
64
71
|
| `--ui-focus-ring` |
|
|
65
72
|
| `--ui-font` |
|
|
66
73
|
| `--ui-font-size-sm` |
|
|
74
|
+
| `--ui-font-size-xs` |
|
|
75
|
+
| `--ui-font-weight-regular` |
|
|
67
76
|
| `--ui-line-height-tight` |
|
|
68
77
|
| `--ui-primary` |
|
|
69
78
|
| `--ui-radius-sm` |
|
|
@@ -18,6 +18,9 @@ Supports two suggestion sources:
|
|
|
18
18
|
request. Useful for small/fixed lists, offline use, or tests. Takes
|
|
19
19
|
priority over `endpoint` whenever it's non-null.
|
|
20
20
|
|
|
21
|
+
Set `clearable` to show an in-field clear action whenever a value is
|
|
22
|
+
present.
|
|
23
|
+
|
|
21
24
|
## Install
|
|
22
25
|
|
|
23
26
|
```js
|
|
@@ -28,7 +31,7 @@ import "@f-ewald/components/autocomplete-input.js";
|
|
|
28
31
|
|
|
29
32
|
```html
|
|
30
33
|
<form>
|
|
31
|
-
<autocomplete-input name="language" placeholder="Start typing a language…"></autocomplete-input>
|
|
34
|
+
<autocomplete-input clearable name="language" placeholder="Start typing a language…"></autocomplete-input>
|
|
32
35
|
</form>
|
|
33
36
|
<script type="module">
|
|
34
37
|
// Local mode: filters client-side, no network request.
|
|
@@ -50,6 +53,7 @@ import "@f-ewald/components/autocomplete-input.js";
|
|
|
50
53
|
| `placeholder` | `placeholder` | `string` | `""` | Placeholder text shown when the input is empty. |
|
|
51
54
|
| `required` | `required` | `boolean` | `false` | Marks the input as required for native form validation. |
|
|
52
55
|
| `disabled` | `disabled` | `boolean` | `false` | Disables the input and closes its suggestion popup. |
|
|
56
|
+
| `clearable` | `clearable` | `boolean` | `false` | Shows an in-field clear action while the control has a value. |
|
|
53
57
|
| `endpoint` | `endpoint` | `string` | `""` | API endpoint queried in API mode. Ignored when `options` is set. |
|
|
54
58
|
| `queryParam` | `query-param` | `string` | `"q"` | Query string parameter name the current input text is sent under. |
|
|
55
59
|
| `debounce` | `debounce` | `number` | `300` | Debounce delay (ms) before firing a request/filter after typing. |
|
|
@@ -62,6 +66,7 @@ import "@f-ewald/components/autocomplete-input.js";
|
|
|
62
66
|
| Event | Description |
|
|
63
67
|
| --- | --- |
|
|
64
68
|
| `option-select` | An option was picked; detail: AutocompleteOption. |
|
|
69
|
+
| `input` | Native-compatible input event fired while editing or clearing. |
|
|
65
70
|
|
|
66
71
|
## Slots
|
|
67
72
|
|
|
@@ -72,9 +77,12 @@ _None._
|
|
|
72
77
|
| Custom property |
|
|
73
78
|
| --- |
|
|
74
79
|
| `--ui-border` |
|
|
80
|
+
| `--ui-danger` |
|
|
75
81
|
| `--ui-focus-ring` |
|
|
76
82
|
| `--ui-font` |
|
|
77
83
|
| `--ui-font-size-sm` |
|
|
84
|
+
| `--ui-font-size-xs` |
|
|
85
|
+
| `--ui-font-weight-regular` |
|
|
78
86
|
| `--ui-line-height-tight` |
|
|
79
87
|
| `--ui-primary` |
|
|
80
88
|
| `--ui-radius-sm` |
|
package/docs/design-language.md
CHANGED
|
@@ -84,6 +84,15 @@ literal values are migrated onto them.
|
|
|
84
84
|
|
|
85
85
|
- Standard interactive controls share a single `2rem` height; padding is
|
|
86
86
|
applied by role (inline text, icon-only, standalone) rather than ad hoc.
|
|
87
|
+
- An autocomplete's opt-in in-field clear action remains a `2rem` target with
|
|
88
|
+
an 18px standalone icon. It overlays reserved trailing input padding, so
|
|
89
|
+
enabling or showing it never changes the field's outer dimensions.
|
|
90
|
+
- `form-field[floating-label]` is the explicit text-field exception: supported
|
|
91
|
+
single-line controls grow to `3rem` so an `--ui-font-size-xs` label and the
|
|
92
|
+
entered value remain distinct. Empty, unfocused labels rest at the normal
|
|
93
|
+
placeholder position; focus or content floats the label to the top-left.
|
|
94
|
+
Native and package text areas reserve equivalent top space but retain their
|
|
95
|
+
row-driven height. Unsupported controls keep the normal external label.
|
|
87
96
|
- Icons are `14px` inline (next to text) and `18px` standalone; icon-only tap
|
|
88
97
|
targets are `32px`.
|
|
89
98
|
- Control corners use `--ui-radius-sm` (4px); enclosing surfaces use
|
|
@@ -118,6 +127,8 @@ literal values are migrated onto them.
|
|
|
118
127
|
duration.
|
|
119
128
|
- Nonessential transitions and animations must be removed under
|
|
120
129
|
`prefers-reduced-motion: reduce`.
|
|
130
|
+
- Floating-label position/type transitions use the normal 120–250ms range and
|
|
131
|
+
become instantaneous under reduced motion.
|
|
121
132
|
- Progress spinners may become static indicators in reduced motion.
|
|
122
133
|
- Components driven by timers must clean up on disconnect.
|
|
123
134
|
|
package/docs/form-field.md
CHANGED
|
@@ -6,6 +6,11 @@ form. Purely presentational — composes whatever control is slotted
|
|
|
6
6
|
(`form-select`, `multi-select`, `autocomplete-input`, `ui-checkbox`, etc.)
|
|
7
7
|
without intercepting its events or value.
|
|
8
8
|
|
|
9
|
+
Set `floating-label` for supported text controls (`input`, `textarea`,
|
|
10
|
+
`autocomplete-input`, `address-autocomplete`, and `text-area`). The label
|
|
11
|
+
then rests inside an empty field and moves to a smaller top-left position
|
|
12
|
+
while focused or non-empty. Other controls keep the external label.
|
|
13
|
+
|
|
9
14
|
The label wraps the default slot for a best-effort visual/click
|
|
10
15
|
association only: every existing value-entry control encapsulates its
|
|
11
16
|
real `<input>` inside its own shadow DOM, so there is no light-DOM `id` a
|
|
@@ -30,6 +35,12 @@ import "@f-ewald/components/form-field.js";
|
|
|
30
35
|
<form-field label="Terms" required error="You must accept to continue">
|
|
31
36
|
<ui-checkbox label="I agree to the terms"></ui-checkbox>
|
|
32
37
|
</form-field>
|
|
38
|
+
<form-field floating-label label="Email">
|
|
39
|
+
<input type="email" placeholder="name@example.com" />
|
|
40
|
+
</form-field>
|
|
41
|
+
<form-field floating-label label="Language">
|
|
42
|
+
<autocomplete-input clearable placeholder="Start typing…"></autocomplete-input>
|
|
43
|
+
</form-field>
|
|
33
44
|
```
|
|
34
45
|
|
|
35
46
|
## Attributes / properties
|
|
@@ -40,6 +51,7 @@ import "@f-ewald/components/form-field.js";
|
|
|
40
51
|
| `hint` | `hint` | `string` | `""` | Optional helper text shown below the control when there's no `error`. |
|
|
41
52
|
| `error` | `error` | `string` | `""` | Optional error text; replaces the `hint` display when non-empty. |
|
|
42
53
|
| `required` | `required` | `boolean` | `false` | Shows a required indicator next to the label. |
|
|
54
|
+
| `floatingLabel` | `floating-label` | `boolean` | `false` | Moves labels inside supported text controls until they receive focus or content. |
|
|
43
55
|
|
|
44
56
|
## Events
|
|
45
57
|
|
|
@@ -53,11 +65,17 @@ _None._
|
|
|
53
65
|
|
|
54
66
|
| Custom property |
|
|
55
67
|
| --- |
|
|
68
|
+
| `--ui-border` |
|
|
56
69
|
| `--ui-danger` |
|
|
70
|
+
| `--ui-focus-ring` |
|
|
57
71
|
| `--ui-font` |
|
|
58
72
|
| `--ui-font-size-sm` |
|
|
59
73
|
| `--ui-font-size-xs` |
|
|
60
74
|
| `--ui-font-weight-medium` |
|
|
75
|
+
| `--ui-font-weight-regular` |
|
|
61
76
|
| `--ui-line-height-tight` |
|
|
77
|
+
| `--ui-primary` |
|
|
78
|
+
| `--ui-radius-sm` |
|
|
79
|
+
| `--ui-surface` |
|
|
62
80
|
| `--ui-text` |
|
|
63
81
|
| `--ui-text-muted` |
|
package/docs/text-area.md
CHANGED
|
@@ -5,6 +5,7 @@ Plain multi-line text field — a thin, tokenized wrapper around a native
|
|
|
5
5
|
(autocomplete-input, form-select, ...). Not a rich editor; use `readonly`
|
|
6
6
|
to display pre-formatted text (e.g. an error message) that the user can
|
|
7
7
|
still select and copy, typically paired with `<copy-link-button>`.
|
|
8
|
+
Supports `form-field`'s opt-in floating-label mode when slotted inside it.
|
|
8
9
|
|
|
9
10
|
## Install
|
|
10
11
|
|
|
@@ -15,7 +16,9 @@ import "@f-ewald/components/text-area.js";
|
|
|
15
16
|
## Usage
|
|
16
17
|
|
|
17
18
|
```html
|
|
18
|
-
<
|
|
19
|
+
<form-field floating-label label="Description">
|
|
20
|
+
<text-area placeholder="Describe the issue…" rows="4"></text-area>
|
|
21
|
+
</form-field>
|
|
19
22
|
<text-area readonly value="Error code: 429 - No deployments available for selected model."></text-area>
|
|
20
23
|
```
|
|
21
24
|
|
|
@@ -45,12 +48,17 @@ _None._
|
|
|
45
48
|
| Custom property |
|
|
46
49
|
| --- |
|
|
47
50
|
| `--ui-border` |
|
|
51
|
+
| `--ui-danger` |
|
|
48
52
|
| `--ui-focus-ring` |
|
|
49
53
|
| `--ui-font` |
|
|
50
54
|
| `--ui-font-size-sm` |
|
|
55
|
+
| `--ui-font-size-xs` |
|
|
56
|
+
| `--ui-font-weight-regular` |
|
|
51
57
|
| `--ui-line-height-normal` |
|
|
58
|
+
| `--ui-line-height-tight` |
|
|
52
59
|
| `--ui-primary` |
|
|
53
60
|
| `--ui-radius-sm` |
|
|
54
61
|
| `--ui-surface` |
|
|
55
62
|
| `--ui-surface-muted` |
|
|
56
63
|
| `--ui-text` |
|
|
64
|
+
| `--ui-text-muted` |
|
package/llms.txt
CHANGED
|
@@ -56,15 +56,19 @@ Supports two suggestion sources:
|
|
|
56
56
|
request. Useful for small/fixed address lists, offline use, or tests.
|
|
57
57
|
Takes priority over `endpoint` whenever it's non-null.
|
|
58
58
|
|
|
59
|
+
Set `clearable` to show an in-field clear action whenever a value is
|
|
60
|
+
present.
|
|
61
|
+
|
|
59
62
|
Import: `import "@f-ewald/components/address-autocomplete.js";`
|
|
60
63
|
|
|
61
|
-
Properties: `value` (attribute `value`) : string, default ""; `placeholder` (attribute `placeholder`) : string, default ""; `required` (attribute `required`) : boolean, default false; `disabled` (attribute `disabled`) : boolean, default false; `types` (attribute `types`) : string, default "address"; `endpoint` (attribute `endpoint`) : string, default "https://api.mapbox.com/search/geocode/v6/forward"; `accessToken` (attribute `access-token`) : string, default ""; `bbox` (attribute `bbox`) : string, default ""; `proximity` (attribute `proximity`) : string, default ""; `debounce` (attribute `debounce`) : number, default 300; `minLength` (attribute `min-length`) : number, default 3; `suggestions` (JS property only) : AddressSuggestion[] | null, default null; `selectedSuggestion` (JS property only) : AddressSuggestion | null, default —
|
|
62
|
-
Events: `address-select`
|
|
63
|
-
CSS custom properties: `--ui-border`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-shadow`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
64
|
+
Properties: `value` (attribute `value`) : string, default ""; `placeholder` (attribute `placeholder`) : string, default ""; `required` (attribute `required`) : boolean, default false; `disabled` (attribute `disabled`) : boolean, default false; `clearable` (attribute `clearable`) : boolean, default false; `types` (attribute `types`) : string, default "address"; `endpoint` (attribute `endpoint`) : string, default "https://api.mapbox.com/search/geocode/v6/forward"; `accessToken` (attribute `access-token`) : string, default ""; `bbox` (attribute `bbox`) : string, default ""; `proximity` (attribute `proximity`) : string, default ""; `debounce` (attribute `debounce`) : number, default 300; `minLength` (attribute `min-length`) : number, default 3; `suggestions` (JS property only) : AddressSuggestion[] | null, default null; `selectedSuggestion` (JS property only) : AddressSuggestion | null, default —
|
|
65
|
+
Events: `address-select`, `input`
|
|
66
|
+
CSS custom properties: `--ui-border`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-regular`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-shadow`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
64
67
|
|
|
65
68
|
Example:
|
|
66
69
|
```html
|
|
67
70
|
<address-autocomplete
|
|
71
|
+
clearable
|
|
68
72
|
placeholder="Start typing an address…"
|
|
69
73
|
access-token="pk.your-mapbox-token"
|
|
70
74
|
></address-autocomplete>
|
|
@@ -220,16 +224,19 @@ Supports two suggestion sources:
|
|
|
220
224
|
request. Useful for small/fixed lists, offline use, or tests. Takes
|
|
221
225
|
priority over `endpoint` whenever it's non-null.
|
|
222
226
|
|
|
227
|
+
Set `clearable` to show an in-field clear action whenever a value is
|
|
228
|
+
present.
|
|
229
|
+
|
|
223
230
|
Import: `import "@f-ewald/components/autocomplete-input.js";`
|
|
224
231
|
|
|
225
|
-
Properties: `value` (attribute `value`) : string, default ""; `placeholder` (attribute `placeholder`) : string, default ""; `required` (attribute `required`) : boolean, default false; `disabled` (attribute `disabled`) : boolean, default false; `endpoint` (attribute `endpoint`) : string, default ""; `queryParam` (attribute `query-param`) : string, default "q"; `debounce` (attribute `debounce`) : number, default 300; `minLength` (attribute `min-length`) : number, default 3; `options` (JS property only) : AutocompleteOption[] | null, default null; `selectedOption` (JS property only) : AutocompleteOption | null, default —
|
|
226
|
-
Events: `option-select`
|
|
227
|
-
CSS custom properties: `--ui-border`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-shadow`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
232
|
+
Properties: `value` (attribute `value`) : string, default ""; `placeholder` (attribute `placeholder`) : string, default ""; `required` (attribute `required`) : boolean, default false; `disabled` (attribute `disabled`) : boolean, default false; `clearable` (attribute `clearable`) : boolean, default false; `endpoint` (attribute `endpoint`) : string, default ""; `queryParam` (attribute `query-param`) : string, default "q"; `debounce` (attribute `debounce`) : number, default 300; `minLength` (attribute `min-length`) : number, default 3; `options` (JS property only) : AutocompleteOption[] | null, default null; `selectedOption` (JS property only) : AutocompleteOption | null, default —
|
|
233
|
+
Events: `option-select`, `input`
|
|
234
|
+
CSS custom properties: `--ui-border`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-regular`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-shadow`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
228
235
|
|
|
229
236
|
Example:
|
|
230
237
|
```html
|
|
231
238
|
<form>
|
|
232
|
-
<autocomplete-input name="language" placeholder="Start typing a language…"></autocomplete-input>
|
|
239
|
+
<autocomplete-input clearable name="language" placeholder="Start typing a language…"></autocomplete-input>
|
|
233
240
|
</form>
|
|
234
241
|
<script type="module">
|
|
235
242
|
// Local mode: filters client-side, no network request.
|
|
@@ -662,6 +669,11 @@ form. Purely presentational — composes whatever control is slotted
|
|
|
662
669
|
(`form-select`, `multi-select`, `autocomplete-input`, `ui-checkbox`, etc.)
|
|
663
670
|
without intercepting its events or value.
|
|
664
671
|
|
|
672
|
+
Set `floating-label` for supported text controls (`input`, `textarea`,
|
|
673
|
+
`autocomplete-input`, `address-autocomplete`, and `text-area`). The label
|
|
674
|
+
then rests inside an empty field and moves to a smaller top-left position
|
|
675
|
+
while focused or non-empty. Other controls keep the external label.
|
|
676
|
+
|
|
665
677
|
The label wraps the default slot for a best-effort visual/click
|
|
666
678
|
association only: every existing value-entry control encapsulates its
|
|
667
679
|
real `<input>` inside its own shadow DOM, so there is no light-DOM `id` a
|
|
@@ -673,9 +685,9 @@ shadow-encapsulated input for the same reason. The error message uses
|
|
|
673
685
|
|
|
674
686
|
Import: `import "@f-ewald/components/form-field.js";`
|
|
675
687
|
|
|
676
|
-
Properties: `label` (attribute `label`) : string, default ""; `hint` (attribute `hint`) : string, default ""; `error` (attribute `error`) : string, default ""; `required` (attribute `required`) : boolean, default false
|
|
688
|
+
Properties: `label` (attribute `label`) : string, default ""; `hint` (attribute `hint`) : string, default ""; `error` (attribute `error`) : string, default ""; `required` (attribute `required`) : boolean, default false; `floatingLabel` (attribute `floating-label`) : boolean, default false
|
|
677
689
|
Events: none
|
|
678
|
-
CSS custom properties: `--ui-danger`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-line-height-tight`, `--ui-text`, `--ui-text-muted`
|
|
690
|
+
CSS custom properties: `--ui-border`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-medium`, `--ui-font-weight-regular`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-text`, `--ui-text-muted`
|
|
679
691
|
|
|
680
692
|
Example:
|
|
681
693
|
```html
|
|
@@ -685,6 +697,12 @@ Example:
|
|
|
685
697
|
<form-field label="Terms" required error="You must accept to continue">
|
|
686
698
|
<ui-checkbox label="I agree to the terms"></ui-checkbox>
|
|
687
699
|
</form-field>
|
|
700
|
+
<form-field floating-label label="Email">
|
|
701
|
+
<input type="email" placeholder="name@example.com" />
|
|
702
|
+
</form-field>
|
|
703
|
+
<form-field floating-label label="Language">
|
|
704
|
+
<autocomplete-input clearable placeholder="Start typing…"></autocomplete-input>
|
|
705
|
+
</form-field>
|
|
688
706
|
```
|
|
689
707
|
|
|
690
708
|
## <form-select>
|
|
@@ -1810,16 +1828,19 @@ Plain multi-line text field — a thin, tokenized wrapper around a native
|
|
|
1810
1828
|
(autocomplete-input, form-select, ...). Not a rich editor; use `readonly`
|
|
1811
1829
|
to display pre-formatted text (e.g. an error message) that the user can
|
|
1812
1830
|
still select and copy, typically paired with `<copy-link-button>`.
|
|
1831
|
+
Supports `form-field`'s opt-in floating-label mode when slotted inside it.
|
|
1813
1832
|
|
|
1814
1833
|
Import: `import "@f-ewald/components/text-area.js";`
|
|
1815
1834
|
|
|
1816
1835
|
Properties: `value` (attribute `value`) : string, default ""; `rows` (attribute `rows`) : number, default 4; `placeholder` (attribute `placeholder`) : string, default ""; `readonly` (attribute `readonly`) : boolean, default false; `disabled` (attribute `disabled`) : boolean, default false
|
|
1817
1836
|
Events: `input`, `change`
|
|
1818
|
-
CSS custom properties: `--ui-border`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-line-height-normal`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`
|
|
1837
|
+
CSS custom properties: `--ui-border`, `--ui-danger`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-size-xs`, `--ui-font-weight-regular`, `--ui-line-height-normal`, `--ui-line-height-tight`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
1819
1838
|
|
|
1820
1839
|
Example:
|
|
1821
1840
|
```html
|
|
1822
|
-
<
|
|
1841
|
+
<form-field floating-label label="Description">
|
|
1842
|
+
<text-area placeholder="Describe the issue…" rows="4"></text-area>
|
|
1843
|
+
</form-field>
|
|
1823
1844
|
<text-area readonly value="Error code: 429 - No deployments available for selected model."></text-area>
|
|
1824
1845
|
```
|
|
1825
1846
|
|