tyrell-components 1.0.0-RC16 → 1.0.0-RC17
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/css/tyrell-colors-static.css +14 -0
- package/css/tyrell-theme.css +6 -5
- package/css/tyrell.css +9 -7
- package/dist/tyrell-colors-static.css +1 -1
- package/dist/tyrell-theme.css +1 -1
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +23 -15
- package/lib/base/ty-component.js +63 -26
- package/lib/components/button.d.ts +14 -0
- package/lib/components/button.js +55 -7
- package/lib/components/calendar-month.d.ts +7 -1
- package/lib/components/calendar-month.js +35 -28
- package/lib/components/calendar-navigation.js +19 -6
- package/lib/components/calendar.d.ts +26 -3
- package/lib/components/calendar.js +104 -64
- package/lib/components/checkbox.d.ts +8 -1
- package/lib/components/checkbox.js +27 -6
- package/lib/components/copy.d.ts +2 -0
- package/lib/components/copy.js +15 -31
- package/lib/components/date-picker.d.ts +53 -18
- package/lib/components/date-picker.js +217 -146
- package/lib/components/file-upload.d.ts +4 -1
- package/lib/components/file-upload.js +23 -5
- package/lib/components/input.d.ts +73 -3
- package/lib/components/input.js +157 -22
- package/lib/components/modal.d.ts +2 -0
- package/lib/components/modal.js +97 -17
- package/lib/components/option.js +7 -5
- package/lib/components/popup.js +115 -15
- package/lib/components/radio.d.ts +10 -1
- package/lib/components/radio.js +22 -29
- package/lib/components/resize-observer.js +2 -0
- package/lib/components/scroll-container.js +2 -0
- package/lib/components/select.d.ts +54 -5
- package/lib/components/select.js +136 -26
- package/lib/components/selected-tags.d.ts +7 -1
- package/lib/components/selected-tags.js +10 -1
- package/lib/components/switch.d.ts +9 -1
- package/lib/components/switch.js +27 -6
- package/lib/components/tabs.js +1 -1
- package/lib/components/textarea.d.ts +47 -2
- package/lib/components/textarea.js +81 -17
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/styles/button.js +21 -19
- package/lib/styles/calendar-month.js +1 -1
- package/lib/styles/calendar.js +3 -0
- package/lib/styles/checkbox.js +11 -5
- package/lib/styles/date-picker.js +16 -4
- package/lib/styles/file-upload.d.ts +1 -1
- package/lib/styles/file-upload.js +3 -3
- package/lib/styles/icon.d.ts +1 -1
- package/lib/styles/icon.js +2 -2
- package/lib/styles/input.js +6 -10
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.js +4 -0
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.js +2 -0
- package/lib/styles/radio.js +12 -6
- package/lib/styles/select-base.js +24 -3
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +4 -0
- package/lib/styles/switch.js +10 -5
- package/lib/styles/tag.js +2 -1
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +7 -0
- package/lib/utils/calendar-utils.d.ts +49 -0
- package/lib/utils/calendar-utils.js +63 -6
- package/lib/utils/property-manager.d.ts +6 -0
- package/lib/utils/property-manager.js +15 -5
- package/lib/utils/scroll-lock.d.ts +10 -4
- package/lib/utils/scroll-lock.js +102 -2
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +98 -2
- package/lib/utils/validity.js +244 -8
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -2
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -403
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1315
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -389
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1301
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -725
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -568
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -23
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
package/lib/components/switch.js
CHANGED
|
@@ -3,6 +3,7 @@ import { TyComponent } from "../base/ty-component.js";
|
|
|
3
3
|
import { ensureStyles } from "../utils/styles.js";
|
|
4
4
|
import { syncCustomFlavorSheet } from "../utils/flavor-sheet.js";
|
|
5
5
|
import { switchStyles, switchCustomFlavorCss } from "../styles/switch.js";
|
|
6
|
+
import { nativeMessage } from "../utils/validity.js";
|
|
6
7
|
export class TySwitch extends TyComponent {
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
@@ -18,6 +19,9 @@ ensureStyles(shadow, { css: switchStyles, id: "ty-switch" });
|
|
|
18
19
|
onConnect() {
|
|
19
20
|
this.setupEventListeners();
|
|
20
21
|
this._syncCustomFlavor();
|
|
22
|
+
const el = this.shadowRoot.querySelector(".switch-container");
|
|
23
|
+
if (el && this.shadowRoot.activeElement !== el)
|
|
24
|
+
el.classList.remove("focused");
|
|
21
25
|
}
|
|
22
26
|
onDisconnect() {
|
|
23
27
|
this.removeEventListeners();
|
|
@@ -44,8 +48,7 @@ return classes.join(" ");
|
|
|
44
48
|
handleSwitchClick(e) {
|
|
45
49
|
if (this.disabled)
|
|
46
50
|
return;
|
|
47
|
-
|
|
48
|
-
return;
|
|
51
|
+
this.showFocusRing(e instanceof KeyboardEvent);
|
|
49
52
|
const newValue = !this.checked;
|
|
50
53
|
this.checked = newValue;
|
|
51
54
|
setTimeout(() => {
|
|
@@ -59,6 +62,9 @@ this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true
|
|
|
59
62
|
this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
|
|
60
63
|
}, 0);
|
|
61
64
|
}
|
|
65
|
+
showFocusRing(on) {
|
|
66
|
+
this.shadowRoot?.querySelector(".switch-container")?.classList.toggle("focused", on);
|
|
67
|
+
}
|
|
62
68
|
handleSwitchKeydown(e) {
|
|
63
69
|
if (this.disabled)
|
|
64
70
|
return;
|
|
@@ -106,7 +112,7 @@ if (!el)
|
|
|
106
112
|
return;
|
|
107
113
|
this._clickHandler = (e) => this.handleSwitchClick(e);
|
|
108
114
|
this._keydownHandler = (e) => this.handleSwitchKeydown(e);
|
|
109
|
-
this._focusHandler = () => el.classList.
|
|
115
|
+
this._focusHandler = () => el.classList.toggle("focused", el.matches(":focus-visible"));
|
|
110
116
|
this._blurHandler = () => el.classList.remove("focused");
|
|
111
117
|
this.addEventListener("click", this._clickHandler);
|
|
112
118
|
el.addEventListener("keydown", this._keydownHandler);
|
|
@@ -121,7 +127,8 @@ const classes = this.buildClassList();
|
|
|
121
127
|
if (!switchEl) {
|
|
122
128
|
switchEl = document.createElement("div");
|
|
123
129
|
switchEl.className = "switch-container " + classes;
|
|
124
|
-
|
|
130
|
+
if (!this.disabled)
|
|
131
|
+
switchEl.tabIndex = 0;
|
|
125
132
|
switchEl.setAttribute("role", "switch");
|
|
126
133
|
switchEl.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
127
134
|
switchEl.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
@@ -135,8 +142,13 @@ switchEl.appendChild(track);
|
|
|
135
142
|
shadow.appendChild(switchEl);
|
|
136
143
|
}
|
|
137
144
|
else {
|
|
145
|
+
const focused = switchEl.classList.contains("focused") && shadow.activeElement === switchEl;
|
|
138
146
|
switchEl.className = "switch-container " + classes;
|
|
139
|
-
switchEl.
|
|
147
|
+
switchEl.classList.toggle("focused", focused && !this.disabled);
|
|
148
|
+
if (this.disabled)
|
|
149
|
+
switchEl.removeAttribute("tabindex");
|
|
150
|
+
else
|
|
151
|
+
switchEl.tabIndex = 0;
|
|
140
152
|
switchEl.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
141
153
|
switchEl.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
142
154
|
switchEl.setAttribute("aria-required", this.required ? "true" : "false");
|
|
@@ -145,6 +157,13 @@ this.setupEventListeners();
|
|
|
145
157
|
this.applyLabelName(switchEl);
|
|
146
158
|
this.updateValidity();
|
|
147
159
|
}
|
|
160
|
+
focus(options) {
|
|
161
|
+
const el = this.shadowRoot?.querySelector(".switch-container");
|
|
162
|
+
if (el)
|
|
163
|
+
el.focus(options);
|
|
164
|
+
else
|
|
165
|
+
super.focus(options);
|
|
166
|
+
}
|
|
148
167
|
updateValidity() {
|
|
149
168
|
const anchor = this.shadowRoot?.querySelector(".switch-container");
|
|
150
169
|
if (this.disabled) {
|
|
@@ -152,7 +171,7 @@ this.applyValidity({});
|
|
|
152
171
|
return;
|
|
153
172
|
}
|
|
154
173
|
if (this.required && !this.checked) {
|
|
155
|
-
this.applyValidity({ valueMissing: true }, "
|
|
174
|
+
this.applyValidity({ valueMissing: true }, nativeMessage("input", { type: "checkbox", switch: true, required: true }), anchor ?? undefined);
|
|
156
175
|
}
|
|
157
176
|
else {
|
|
158
177
|
this.applyValidity({});
|
|
@@ -175,6 +194,8 @@ set flavor(value) { this.setProperty("flavor", value); }
|
|
|
175
194
|
get form() { return this._internals.form; }
|
|
176
195
|
}
|
|
177
196
|
TySwitch.formAssociated = true;
|
|
197
|
+
TySwitch.delegatesFocus = true;
|
|
198
|
+
TySwitch.labelClicks = true;
|
|
178
199
|
TySwitch.properties = {
|
|
179
200
|
checked: {
|
|
180
201
|
type: "boolean",
|
package/lib/components/tabs.js
CHANGED
|
@@ -251,7 +251,7 @@ marker.style.top = `${position.top}px`;
|
|
|
251
251
|
marker.style.width = `${position.width}px`;
|
|
252
252
|
marker.style.height = `${position.height}px`;
|
|
253
253
|
if (snap) {
|
|
254
|
-
marker.
|
|
254
|
+
marker.getBoundingClientRect();
|
|
255
255
|
marker.style.transition = '';
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -21,6 +21,10 @@ export interface TyTextareaElement extends HTMLElement {
|
|
|
21
21
|
label?: string;
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
required?: boolean;
|
|
24
|
+
minLength?: number;
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
tooShortMessage?: string;
|
|
27
|
+
tooLongMessage?: string;
|
|
24
28
|
error?: string;
|
|
25
29
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
26
30
|
rows?: string | number;
|
|
@@ -63,6 +67,26 @@ export declare class TyTextarea extends TyComponent<TextareaState> implements Ty
|
|
|
63
67
|
visual: boolean;
|
|
64
68
|
default: boolean;
|
|
65
69
|
};
|
|
70
|
+
minlength: {
|
|
71
|
+
type: "string";
|
|
72
|
+
visual: boolean;
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
maxlength: {
|
|
76
|
+
type: "string";
|
|
77
|
+
visual: boolean;
|
|
78
|
+
default: string;
|
|
79
|
+
};
|
|
80
|
+
tooShortMessage: {
|
|
81
|
+
type: "string";
|
|
82
|
+
visual: boolean;
|
|
83
|
+
default: string;
|
|
84
|
+
};
|
|
85
|
+
tooLongMessage: {
|
|
86
|
+
type: "string";
|
|
87
|
+
visual: boolean;
|
|
88
|
+
default: string;
|
|
89
|
+
};
|
|
66
90
|
error: {
|
|
67
91
|
type: "string";
|
|
68
92
|
visual: boolean;
|
|
@@ -125,8 +149,18 @@ export declare class TyTextarea extends TyComponent<TextareaState> implements Ty
|
|
|
125
149
|
set label(v: string);
|
|
126
150
|
get disabled(): boolean;
|
|
127
151
|
set disabled(v: boolean);
|
|
152
|
+
/** Focus the inner <textarea>: the host itself isn't focusable. */
|
|
153
|
+
focus(options?: FocusOptions): void;
|
|
128
154
|
get required(): boolean;
|
|
129
155
|
set required(v: boolean);
|
|
156
|
+
get minLength(): number;
|
|
157
|
+
set minLength(v: number);
|
|
158
|
+
get maxLength(): number;
|
|
159
|
+
set maxLength(v: number);
|
|
160
|
+
get tooShortMessage(): string;
|
|
161
|
+
set tooShortMessage(v: string);
|
|
162
|
+
get tooLongMessage(): string;
|
|
163
|
+
set tooLongMessage(v: string);
|
|
130
164
|
get error(): string;
|
|
131
165
|
set error(v: string);
|
|
132
166
|
get size(): 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -157,9 +191,20 @@ export declare class TyTextarea extends TyComponent<TextareaState> implements Ty
|
|
|
157
191
|
private buildClassList;
|
|
158
192
|
private applyHeightConstraints;
|
|
159
193
|
private setupTextareaEvents;
|
|
194
|
+
private removeTextareaEvents;
|
|
160
195
|
protected render(): void;
|
|
161
|
-
/**
|
|
162
|
-
*
|
|
196
|
+
/**
|
|
197
|
+
* minlength goes on the inner <textarea> for the browser's own too-short
|
|
198
|
+
* message after the user types, maxlength so typing stops at the limit
|
|
199
|
+
* (like ty-input).
|
|
200
|
+
*/
|
|
201
|
+
private syncConstraintAttributes;
|
|
202
|
+
/**
|
|
203
|
+
* required + empty => valueMissing (the browser's own message); otherwise
|
|
204
|
+
* minlength / maxlength, worded like ty-input's (lengthValidity). Empty
|
|
205
|
+
* values only fail `required`, like native. Disabled fields are barred
|
|
206
|
+
* from constraint validation.
|
|
207
|
+
*/
|
|
163
208
|
private updateValidity;
|
|
164
209
|
}
|
|
165
210
|
export {};
|
|
@@ -4,7 +4,8 @@ import { ensureStyles } from '../utils/styles.js';
|
|
|
4
4
|
import { textareaStyles } from '../styles/textarea.js';
|
|
5
5
|
import { CustomScrollbar, isCustomScrollbarEnabled } from '../utils/custom-scrollbar.js';
|
|
6
6
|
import { customScrollbarStyles } from '../styles/custom-scrollbar.js';
|
|
7
|
-
|
|
7
|
+
import { nativeMessage, lengthValidity, toLimit } from '../utils/validity.js';
|
|
8
|
+
import { REQUIRED_ICON_SVG } from '../utils/icons.js';
|
|
8
9
|
export class TyTextarea extends TyComponent {
|
|
9
10
|
constructor() {
|
|
10
11
|
super();
|
|
@@ -13,6 +14,9 @@ this._dummyEl = null;
|
|
|
13
14
|
this._scrollbar = null;
|
|
14
15
|
this._isFocused = false;
|
|
15
16
|
this.handleInputEvent = (e) => {
|
|
17
|
+
this._userEdited = true;
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
e.stopImmediatePropagation();
|
|
16
20
|
const target = e.target;
|
|
17
21
|
const newValue = target.value;
|
|
18
22
|
this.value = newValue;
|
|
@@ -30,6 +34,8 @@ this._valueAtFocus = this.value;
|
|
|
30
34
|
};
|
|
31
35
|
this.handleBlurEvent = (e) => {
|
|
32
36
|
this._isFocused = false;
|
|
37
|
+
if (this._userEdited)
|
|
38
|
+
this.revealValidity();
|
|
33
39
|
if (this._valueAtFocus !== null && this.value !== this._valueAtFocus) {
|
|
34
40
|
this.emitValueEvent('change', e);
|
|
35
41
|
}
|
|
@@ -42,20 +48,22 @@ ensureStyles(shadow, { css: customScrollbarStyles, id: 'ty-custom-scrollbar' });
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
onConnect() {
|
|
51
|
+
this.updateFormValue();
|
|
52
|
+
if (this._rendered) {
|
|
53
|
+
this.render();
|
|
54
|
+
if (this._textareaEl)
|
|
55
|
+
this.setupTextareaEvents(this._textareaEl);
|
|
56
|
+
}
|
|
45
57
|
}
|
|
46
58
|
onDisconnect() {
|
|
47
59
|
this._destroyScrollbar();
|
|
48
|
-
if (this._textareaEl)
|
|
49
|
-
|
|
50
|
-
this._textareaEl.parentNode?.replaceChild(newTextarea, this._textareaEl);
|
|
51
|
-
this._textareaEl = null;
|
|
52
|
-
}
|
|
53
|
-
this._dummyEl = null;
|
|
60
|
+
if (this._textareaEl)
|
|
61
|
+
this.removeTextareaEvents(this._textareaEl);
|
|
54
62
|
}
|
|
55
63
|
onPropertiesChanged(changes) {
|
|
56
64
|
}
|
|
57
65
|
getFormValue() {
|
|
58
|
-
return this.getProperty('value') ||
|
|
66
|
+
return this.getProperty('value') || '';
|
|
59
67
|
}
|
|
60
68
|
get value() { return this.getProperty('value'); }
|
|
61
69
|
set value(v) { this.setProperty('value', v); }
|
|
@@ -67,8 +75,19 @@ get label() { return this.getProperty('label'); }
|
|
|
67
75
|
set label(v) { this.setProperty('label', v); }
|
|
68
76
|
get disabled() { return this.getProperty('disabled'); }
|
|
69
77
|
set disabled(v) { this.setProperty('disabled', v); }
|
|
78
|
+
focus(options) {
|
|
79
|
+
this.shadowRoot?.querySelector('textarea')?.focus(options);
|
|
80
|
+
}
|
|
70
81
|
get required() { return this.getProperty('required'); }
|
|
71
82
|
set required(v) { this.setProperty('required', v); }
|
|
83
|
+
get minLength() { return toLimit(this.getProperty('minlength')) ?? -1; }
|
|
84
|
+
set minLength(v) { this.setProperty('minlength', v == null || v < 0 ? '' : String(v)); }
|
|
85
|
+
get maxLength() { return toLimit(this.getProperty('maxlength')) ?? -1; }
|
|
86
|
+
set maxLength(v) { this.setProperty('maxlength', v == null || v < 0 ? '' : String(v)); }
|
|
87
|
+
get tooShortMessage() { return this.getProperty('tooShortMessage'); }
|
|
88
|
+
set tooShortMessage(v) { this.setProperty('tooShortMessage', v ?? ''); }
|
|
89
|
+
get tooLongMessage() { return this.getProperty('tooLongMessage'); }
|
|
90
|
+
set tooLongMessage(v) { this.setProperty('tooLongMessage', v ?? ''); }
|
|
72
91
|
get error() { return this.getProperty('error'); }
|
|
73
92
|
set error(v) { this.setProperty('error', v); }
|
|
74
93
|
get size() {
|
|
@@ -175,6 +194,10 @@ textareaEl.style.overflowY = 'hidden';
|
|
|
175
194
|
this._destroyScrollbar();
|
|
176
195
|
}
|
|
177
196
|
}
|
|
197
|
+
else if (maxHeight !== null && measuredHeight >= maxHeight && !this._scrollbar) {
|
|
198
|
+
textareaEl.style.overflowY = 'auto';
|
|
199
|
+
this._setupScrollbar(textareaEl);
|
|
200
|
+
}
|
|
178
201
|
this._scrollbar?.update();
|
|
179
202
|
}
|
|
180
203
|
_setupScrollbar(textareaEl) {
|
|
@@ -211,7 +234,7 @@ value: this.value,
|
|
|
211
234
|
originalEvent
|
|
212
235
|
}
|
|
213
236
|
};
|
|
214
|
-
|
|
237
|
+
this.dispatchEvent(new CustomEvent(type, data));
|
|
215
238
|
}
|
|
216
239
|
buildClassList() {
|
|
217
240
|
const classes = [this.size];
|
|
@@ -241,6 +264,11 @@ textareaEl.addEventListener('input', this.handleInputEvent);
|
|
|
241
264
|
textareaEl.addEventListener('focus', this.handleFocusEvent);
|
|
242
265
|
textareaEl.addEventListener('blur', this.handleBlurEvent);
|
|
243
266
|
}
|
|
267
|
+
removeTextareaEvents(textareaEl) {
|
|
268
|
+
textareaEl.removeEventListener('input', this.handleInputEvent);
|
|
269
|
+
textareaEl.removeEventListener('focus', this.handleFocusEvent);
|
|
270
|
+
textareaEl.removeEventListener('blur', this.handleBlurEvent);
|
|
271
|
+
}
|
|
244
272
|
render() {
|
|
245
273
|
const root = this.shadowRoot;
|
|
246
274
|
const existingContainer = root.querySelector('.textarea-container');
|
|
@@ -250,18 +278,19 @@ const existingError = root.querySelector('.error-message');
|
|
|
250
278
|
if (existingContainer && existingTextarea) {
|
|
251
279
|
if (this.label) {
|
|
252
280
|
if (existingLabel) {
|
|
253
|
-
existingLabel.innerHTML = this.label
|
|
254
|
-
|
|
255
|
-
existingLabel.style.display = 'block';
|
|
281
|
+
existingLabel.innerHTML = `${this.label}${this.required ? `<span class="required-icon">${REQUIRED_ICON_SVG}</span>` : ''}`;
|
|
282
|
+
existingLabel.style.display = 'flex';
|
|
256
283
|
}
|
|
257
284
|
}
|
|
258
285
|
else if (existingLabel) {
|
|
259
286
|
existingLabel.style.display = 'none';
|
|
260
287
|
}
|
|
288
|
+
if (existingTextarea.value !== (this.value || ''))
|
|
261
289
|
existingTextarea.value = this.value || '';
|
|
262
290
|
existingTextarea.placeholder = this.placeholder || '';
|
|
263
291
|
existingTextarea.disabled = this.disabled;
|
|
264
292
|
existingTextarea.required = this.required;
|
|
293
|
+
this.syncConstraintAttributes(existingTextarea);
|
|
265
294
|
existingTextarea.className = this.buildClassList();
|
|
266
295
|
if (this.label)
|
|
267
296
|
existingTextarea.setAttribute('aria-label', this.label);
|
|
@@ -301,9 +330,8 @@ container.className = 'textarea-container';
|
|
|
301
330
|
const labelEl = document.createElement('label');
|
|
302
331
|
labelEl.className = 'ty-field-label';
|
|
303
332
|
if (this.label) {
|
|
304
|
-
labelEl.innerHTML = this.label
|
|
305
|
-
|
|
306
|
-
labelEl.style.display = 'block';
|
|
333
|
+
labelEl.innerHTML = `${this.label}${this.required ? `<span class="required-icon">${REQUIRED_ICON_SVG}</span>` : ''}`;
|
|
334
|
+
labelEl.style.display = 'flex';
|
|
307
335
|
}
|
|
308
336
|
else {
|
|
309
337
|
labelEl.style.display = 'none';
|
|
@@ -313,6 +341,7 @@ textareaEl.value = this.value || '';
|
|
|
313
341
|
textareaEl.placeholder = this.placeholder || '';
|
|
314
342
|
textareaEl.disabled = this.disabled;
|
|
315
343
|
textareaEl.required = this.required;
|
|
344
|
+
this.syncConstraintAttributes(textareaEl);
|
|
316
345
|
textareaEl.className = this.buildClassList();
|
|
317
346
|
if (this.label)
|
|
318
347
|
textareaEl.setAttribute('aria-label', this.label);
|
|
@@ -364,6 +393,11 @@ this._textareaEl = textareaEl;
|
|
|
364
393
|
}
|
|
365
394
|
this.updateValidity();
|
|
366
395
|
}
|
|
396
|
+
syncConstraintAttributes(ta) {
|
|
397
|
+
const set = (name, limit) => limit !== null ? ta.setAttribute(name, String(limit)) : ta.removeAttribute(name);
|
|
398
|
+
set('minlength', toLimit(this.getProperty('minlength')));
|
|
399
|
+
set('maxlength', toLimit(this.getProperty('maxlength')));
|
|
400
|
+
}
|
|
367
401
|
updateValidity() {
|
|
368
402
|
const ta = this.shadowRoot?.querySelector('textarea');
|
|
369
403
|
if (this.disabled) {
|
|
@@ -371,12 +405,22 @@ this.applyValidity({});
|
|
|
371
405
|
return;
|
|
372
406
|
}
|
|
373
407
|
const current = ta ? ta.value : String(this.value ?? '');
|
|
374
|
-
if (
|
|
375
|
-
this.
|
|
408
|
+
if (current.trim() === '') {
|
|
409
|
+
if (this.required) {
|
|
410
|
+
this.applyValidity({ valueMissing: true }, nativeMessage('textarea', { required: true }), ta ?? undefined);
|
|
376
411
|
}
|
|
377
412
|
else {
|
|
378
413
|
this.applyValidity({});
|
|
379
414
|
}
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const { tooShort, tooLong } = lengthValidity(current, {
|
|
418
|
+
minlength: this.getProperty('minlength'),
|
|
419
|
+
maxlength: this.getProperty('maxlength'),
|
|
420
|
+
tooShortMessage: this.tooShortMessage,
|
|
421
|
+
tooLongMessage: this.tooLongMessage,
|
|
422
|
+
}, ta);
|
|
423
|
+
this.applyValidity({ tooShort: !!tooShort, tooLong: !!tooLong }, tooShort ?? tooLong, ta ?? undefined);
|
|
380
424
|
}
|
|
381
425
|
}
|
|
382
426
|
TyTextarea.formAssociated = true;
|
|
@@ -412,6 +456,26 @@ type: 'boolean',
|
|
|
412
456
|
visual: true,
|
|
413
457
|
default: false
|
|
414
458
|
},
|
|
459
|
+
minlength: {
|
|
460
|
+
type: 'string',
|
|
461
|
+
visual: true,
|
|
462
|
+
default: ''
|
|
463
|
+
},
|
|
464
|
+
maxlength: {
|
|
465
|
+
type: 'string',
|
|
466
|
+
visual: true,
|
|
467
|
+
default: ''
|
|
468
|
+
},
|
|
469
|
+
tooShortMessage: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
visual: true,
|
|
472
|
+
default: ''
|
|
473
|
+
},
|
|
474
|
+
tooLongMessage: {
|
|
475
|
+
type: 'string',
|
|
476
|
+
visual: true,
|
|
477
|
+
default: ''
|
|
478
|
+
},
|
|
415
479
|
error: {
|
|
416
480
|
type: 'string',
|
|
417
481
|
visual: true,
|
package/lib/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ declare global {
|
|
|
75
75
|
tyResizeObserver: {
|
|
76
76
|
getSize: (id: string) => ResizeSize | undefined;
|
|
77
77
|
onResize: (id: string, callback: ResizeCallback) => () => void;
|
|
78
|
+
getAllSizes: () => Record<string, ResizeSize>;
|
|
78
79
|
sizes: Record<string, ResizeSize>;
|
|
79
80
|
};
|
|
80
81
|
tyLoader: {
|
package/lib/index.js
CHANGED
package/lib/styles/button.js
CHANGED
|
@@ -69,11 +69,26 @@ color: var(--ty-button-color, ${ink('-strong')});
|
|
|
69
69
|
export const buttonCustomFlavorCss = (base) => solidFlavor(base, 'neutral') + outlinedFlavor(base, 'neutral') + ghostFlavor(base, 'neutral');
|
|
70
70
|
export const buttonStyles = `
|
|
71
71
|
:host {
|
|
72
|
-
|
|
72
|
+
--_rung: var(--ty-button-height);
|
|
73
|
+
display: inline-grid;
|
|
74
|
+
grid-template: minmax(var(--_rung), 1fr) / minmax(min-content, 1fr);
|
|
75
|
+
height: fit-content;
|
|
73
76
|
font-family: inherit;
|
|
74
77
|
}
|
|
78
|
+
:host([action]) {
|
|
79
|
+
--_rung: var(--ty-button-action-size);
|
|
80
|
+
}
|
|
81
|
+
:host([action]:not([wide])) {
|
|
82
|
+
width: fit-content;
|
|
83
|
+
aspect-ratio: 1;
|
|
84
|
+
}
|
|
75
85
|
:host([wide]) {
|
|
76
|
-
display:
|
|
86
|
+
display: grid;
|
|
87
|
+
flex-grow: 1;
|
|
88
|
+
max-height: var(--_rung);
|
|
89
|
+
grid-template-rows: minmax(var(--_rung), max-content);
|
|
90
|
+
}
|
|
91
|
+
:host([wide]) button {
|
|
77
92
|
flex-grow: 1;
|
|
78
93
|
}
|
|
79
94
|
:host {
|
|
@@ -140,6 +155,7 @@ align-items: center;
|
|
|
140
155
|
justify-content: center;
|
|
141
156
|
gap: var(--ty-button-gap);
|
|
142
157
|
height: var(--ty-button-height);
|
|
158
|
+
min-height: 100%;
|
|
143
159
|
padding: var(--ty-button-pad-y) var(--ty-button-pad-x);
|
|
144
160
|
font-size: var(--ty-button-font);
|
|
145
161
|
line-height: var(--ty-button-leading);
|
|
@@ -214,13 +230,11 @@ justify-content: center;
|
|
|
214
230
|
::slotted(ty-icon) {
|
|
215
231
|
flex-shrink: 0;
|
|
216
232
|
}
|
|
217
|
-
:host([wide]) button {
|
|
218
|
-
flex-grow: 1;
|
|
219
|
-
}
|
|
220
233
|
button.action {
|
|
221
234
|
gap: 0px !important;
|
|
222
|
-
height:
|
|
223
|
-
width: var(--ty-button-action-size);
|
|
235
|
+
height: auto;
|
|
236
|
+
min-width: var(--ty-button-action-size);
|
|
237
|
+
min-height: var(--ty-button-action-size);
|
|
224
238
|
padding: 0px !important;
|
|
225
239
|
}
|
|
226
240
|
button.action ::slotted(ty-icon) {
|
|
@@ -272,18 +286,6 @@ button.pill.xs { padding-left: 1em; padding-right: 1em; }
|
|
|
272
286
|
button.pill.sm { padding-left: 1.125em; padding-right: 1.125em; }
|
|
273
287
|
button.pill.lg { padding-left: 1.5em; padding-right: 1.5em; }
|
|
274
288
|
button.pill.xl { padding-left: 1.75em; padding-right: 1.75em; }
|
|
275
|
-
button.pill:has(ty-icon:only-child),
|
|
276
|
-
button.pill:has(slot[name="start"]:only-child),
|
|
277
|
-
button.pill:has(slot[name="end"]:only-child) {
|
|
278
|
-
padding: 0;
|
|
279
|
-
aspect-ratio: 1;
|
|
280
|
-
min-width: var(--ty-size-md);
|
|
281
|
-
}
|
|
282
|
-
button.pill.xs:has(ty-icon:only-child) { min-width: 1.375rem; min-height: 1.375rem; }
|
|
283
|
-
button.pill.sm:has(ty-icon:only-child) { min-width: 1.5rem; min-height: 1.5rem; }
|
|
284
|
-
button.pill.md:has(ty-icon:only-child) { min-width: 2rem; min-height: 2rem; }
|
|
285
|
-
button.pill.lg:has(ty-icon:only-child) { min-width: 2.25rem; min-height: 2.25rem; }
|
|
286
|
-
button.pill.xl:has(ty-icon:only-child) { min-width: 2.5rem; min-height: 2.5rem; }
|
|
287
289
|
button.solid {
|
|
288
290
|
--_ring: var(--ty-color-neutral);
|
|
289
291
|
--_solid-bg: var(--ty-button-bg, var(--ty-solid-neutral));
|
|
@@ -124,7 +124,7 @@ color: var(--ty-calendar-weekend-color, var(--ty-calendar-day-color, var(--ty-te
|
|
|
124
124
|
color: var(--ty-calendar-other-month-color, color-mix(in oklab, var(--ty-text-faint) 65%, transparent));
|
|
125
125
|
}
|
|
126
126
|
.calendar-day-cell.other-month:hover {
|
|
127
|
-
color: var(--ty-calendar-day-hover-color, var(--ty-text-soft
|
|
127
|
+
color: var(--ty-calendar-day-hover-color, var(--ty-text-soft));
|
|
128
128
|
background-color: var(--ty-calendar-day-hover-bg, var(--ty-bg-neutral-soft));
|
|
129
129
|
}
|
|
130
130
|
.calendar-day-cell.disabled {
|
package/lib/styles/calendar.js
CHANGED
package/lib/styles/checkbox.js
CHANGED
|
@@ -14,14 +14,21 @@ export const checkboxStyles = `
|
|
|
14
14
|
:host {
|
|
15
15
|
display: inline-flex;
|
|
16
16
|
width: auto;
|
|
17
|
-
|
|
17
|
+
height: 1.25em;
|
|
18
|
+
height: 1lh;
|
|
19
|
+
align-items: center;
|
|
20
|
+
vertical-align: baseline;
|
|
21
|
+
overflow: visible;
|
|
22
|
+
}
|
|
23
|
+
:host::before {
|
|
24
|
+
content: "\\200b";
|
|
25
|
+
width: 0;
|
|
18
26
|
}
|
|
19
27
|
.checkbox-container {
|
|
20
28
|
display: inline-flex;
|
|
29
|
+
flex-shrink: 0;
|
|
21
30
|
align-items: center;
|
|
22
31
|
justify-content: center;
|
|
23
|
-
min-height: 1.25em;
|
|
24
|
-
min-height: 1lh;
|
|
25
32
|
outline: none;
|
|
26
33
|
transition: var(--ty-local-transition, all 0.15s ease-in-out);
|
|
27
34
|
user-select: none;
|
|
@@ -42,8 +49,7 @@ color: var(--checkbox-color-off-hover, color-mix(in oklab, var(--ty-text) 50%, t
|
|
|
42
49
|
.checkbox-container[aria-checked="true"] {
|
|
43
50
|
color: var(--checkbox-color, var(--ty-text));
|
|
44
51
|
}
|
|
45
|
-
.checkbox-container.focused
|
|
46
|
-
.checkbox-container:focus-visible {
|
|
52
|
+
.checkbox-container.focused {
|
|
47
53
|
box-shadow: 0 0 0 3px var(--checkbox-ring, color-mix(in oklab, var(--ty-color-primary) 25%, transparent));
|
|
48
54
|
}
|
|
49
55
|
.checkbox-icon {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FLAVORS } from "../types/common.js";
|
|
2
2
|
import { fieldSizeVars } from "./field-size.js";
|
|
3
|
-
const datePickerFlavor = (f, fb) => {
|
|
3
|
+
const datePickerFlavor = (f, fb, also = "") => {
|
|
4
4
|
const c = (s) => fb
|
|
5
5
|
? s
|
|
6
6
|
? `var(--ty-color-${f}${s}, var(--ty-color-${f}, var(--ty-color-${fb}${s})))`
|
|
@@ -9,7 +9,7 @@ const c = (s) => fb
|
|
|
9
9
|
? `var(--ty-color-${f}${s}, var(--ty-color-${f}))`
|
|
10
10
|
: `var(--ty-color-${f})`;
|
|
11
11
|
return `
|
|
12
|
-
:host([flavor="${f}"]) {
|
|
12
|
+
:host([flavor="${f}"])${also} {
|
|
13
13
|
--date-picker-accent: var(--ty-input-${f}-border, ${c("-soft")});
|
|
14
14
|
--date-picker-accent-bold: ${c("")};
|
|
15
15
|
--date-picker-ring: color-mix(in oklab, ${c("")} 15%, transparent);
|
|
@@ -26,6 +26,7 @@ return `
|
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
28
|
};
|
|
29
|
+
const errorLook = `,\n:host([error]:not([error=""]))`;
|
|
29
30
|
export const datePickerCustomFlavorCss = (base) => datePickerFlavor(base, "neutral");
|
|
30
31
|
export const datePickerStyles = `
|
|
31
32
|
${fieldSizeVars}
|
|
@@ -92,7 +93,7 @@ align-items: center;
|
|
|
92
93
|
justify-content: center;
|
|
93
94
|
flex-shrink: 0;
|
|
94
95
|
margin-right: 0.5rem;
|
|
95
|
-
color: var(--ty-
|
|
96
|
+
color: var(--ty-text-soft);
|
|
96
97
|
}
|
|
97
98
|
.date-picker-stub ::slotted(ty-icon[slot="start"]) {
|
|
98
99
|
width: 1em;
|
|
@@ -133,7 +134,18 @@ opacity: 0.6;
|
|
|
133
134
|
border-color: var(--date-picker-accent-bold, var(--ty-date-picker-border-focus));
|
|
134
135
|
box-shadow: 0 0 0 3px var(--date-picker-ring, var(--ty-date-picker-shadow-focus));
|
|
135
136
|
}
|
|
136
|
-
${FLAVORS.filter((f) => f !== "neutral").map((f) => datePickerFlavor(f)).join("")}
|
|
137
|
+
${FLAVORS.filter((f) => f !== "neutral").map((f) => datePickerFlavor(f, undefined, f === "danger" ? errorLook : "")).join("")}
|
|
138
|
+
.error-message {
|
|
139
|
+
font-size: var(--ty-font-xs);
|
|
140
|
+
line-height: var(--ty-leading-xs);
|
|
141
|
+
letter-spacing: var(--ty-tracking-xs);
|
|
142
|
+
color: var(--ty-color-danger);
|
|
143
|
+
margin-top: 4px;
|
|
144
|
+
padding-left: var(--ty-field-outer-pad-x);
|
|
145
|
+
}
|
|
146
|
+
.date-picker-stub.error:not([disabled]) {
|
|
147
|
+
background: var(--ty-bg-danger-soft);
|
|
148
|
+
}
|
|
137
149
|
.stub-text {
|
|
138
150
|
flex: 1;
|
|
139
151
|
white-space: nowrap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fileUploadStyles = "\n:host {\n display: block;\n font-family: inherit;\n width: 100%;\n}\n\n.file-upload-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n box-sizing: border-box;\n}\n\n.upload-label {\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n letter-spacing: var(--ty-tracking-sm);\n font-weight: var(--ty-font-medium);\n color: var(--ty-label-color);\n margin-bottom: 6px;\n padding-left: 4px;\n display: flex;\n align-items: center;\n}\n\n.required-icon {\n color: var(--ty-color-danger);\n margin-left: 4px;\n font-size: 0.75rem;\n line-height: 1;\n}\n\n.drop-zone {\n border: 2px dashed var(--ty-border);\n border-radius: var(--ty-radius-base);\n padding: 2rem 1.5rem;\n text-align: center;\n cursor: pointer;\n transition: var(--ty-local-transition, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease);\n outline: none;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n min-height: 140px;\n user-select: none;\n}\n\n.drop-zone:hover:not(.disabled) {\n border-color: var(--ty-input-border-hover);\n background: var(--ty-surface-content);\n}\n\n.drop-zone.focused {\n border-color: var(--ty-input-border-focus);\n box-shadow: 0 0 0 3px var(--ty-input-shadow-focus);\n}\n\n.drop-zone.drag-active {\n border-color: var(--ty-color-primary);\n border-style: solid;\n background: var(--ty-bg-primary-);\n}\n\n.drop-zone.drag-active .upload-icon {\n color: var(--ty-color-primary);\n transform: translateY(-2px);\n}\n\n.drop-zone.has-files {\n min-height: 80px;\n padding: 1.25rem 1.5rem;\n}\n\n.drop-zone.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.drop-zone.error {\n border-color: var(--ty-color-danger);\n}\n\n.drop-zone.error:not(.disabled) {\n background: var(--ty-bg-danger-);\n}\n\n.upload-icon {\n color: var(--ty-text-faint);\n width: 2.5rem;\n height: 2.5rem;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: var(--ty-local-transition, color 0.15s ease, transform 0.15s ease);\n pointer-events: none;\n}\n\n.upload-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.upload-hint {\n color: var(--ty-text-soft);\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n pointer-events: none;\n}\n\n.browse-link {\n color: var(--ty-color-primary);\n font-weight: var(--ty-font-medium);\n}\n\n.upload-sub-hint {\n color: var(--ty-text-faint);\n font-size: var(--ty-font-xs);\n line-height: var(--ty-leading-xs);\n pointer-events: none;\n}\n\n.file-list {\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n margin-top: 0.5rem;\n}\n\n.file-item {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n border-radius: var(--ty-radius-base);\n background: var(--ty-surface-content);\n border: 1px solid var(--ty-border-soft);\n}\n\n.file-icon {\n color: var(--ty-text-faint);\n flex-shrink: 0;\n width: 1rem;\n height: 1rem;\n display: flex;\n align-items: center;\n}\n\n.file-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.file-name {\n flex: 1;\n font-size: var(--ty-font-sm);\n color: var(--ty-text);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n}\n\n.file-size {\n font-size: var(--ty-font-xs);\n color: var(--ty-text-faint);\n flex-shrink: 0;\n font-variant-numeric: tabular-nums;\n}\n\n.file-remove {\n flex-shrink: 0;\n cursor: pointer;\n color: var(--ty-text-faint);\n width: 1.25rem;\n height: 1.25rem;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: var(--ty-local-transition, color 0.15s ease, background-color 0.15s ease);\n border: none;\n background: none;\n padding: 0;\n outline: none;\n}\n\n.file-remove:hover {\n color: var(--ty-color-danger);\n background: var(--ty-bg-danger-);\n}\n\n.file-remove:focus-visible {\n box-shadow: 0 0 0 2px var(--ty-color-danger);\n}\n\n.file-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.error-message {\n font-size: var(--ty-font-xs);\n line-height: var(--ty-leading-xs);\n color: var(--ty-color-danger);\n margin-top: 4px;\n padding-left: 4px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .drop-zone,\n .upload-icon,\n .file-remove {\n transition: none;\n }\n}\n\n@media (prefers-contrast: high) {\n .drop-zone {\n border-width: 3px;\n }\n}\n";
|
|
1
|
+
export declare const fileUploadStyles = "\n:host {\n display: block;\n font-family: inherit;\n width: 100%;\n}\n\n.file-upload-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n box-sizing: border-box;\n}\n\n.upload-label {\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n letter-spacing: var(--ty-tracking-sm);\n font-weight: var(--ty-font-medium);\n color: var(--ty-label-color);\n margin-bottom: 6px;\n padding-left: 4px;\n display: flex;\n align-items: center;\n}\n\n.required-icon {\n color: var(--ty-color-danger);\n margin-left: 4px;\n font-size: 0.75rem;\n line-height: 1;\n}\n\n.drop-zone {\n border: 2px dashed var(--ty-border);\n border-radius: var(--ty-radius-base);\n padding: 2rem 1.5rem;\n text-align: center;\n cursor: pointer;\n transition: var(--ty-local-transition, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease);\n outline: none;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n min-height: 140px;\n user-select: none;\n}\n\n.drop-zone:hover:not(.disabled) {\n border-color: var(--ty-input-border-hover);\n background: var(--ty-surface-content);\n}\n\n.drop-zone.focused {\n border-color: var(--ty-input-border-focus);\n box-shadow: 0 0 0 3px var(--ty-input-shadow-focus);\n}\n\n.drop-zone.drag-active {\n border-color: var(--ty-color-primary);\n border-style: solid;\n background: var(--ty-bg-primary-soft);\n}\n\n.drop-zone.drag-active .upload-icon {\n color: var(--ty-color-primary);\n transform: translateY(-2px);\n}\n\n.drop-zone.has-files {\n min-height: 80px;\n padding: 1.25rem 1.5rem;\n}\n\n.drop-zone.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.drop-zone.error {\n border-color: var(--ty-color-danger);\n}\n\n.drop-zone.error:not(.disabled) {\n background: var(--ty-bg-danger-soft);\n}\n\n.upload-icon {\n color: var(--ty-text-faint);\n width: 2.5rem;\n height: 2.5rem;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: var(--ty-local-transition, color 0.15s ease, transform 0.15s ease);\n pointer-events: none;\n}\n\n.upload-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.upload-hint {\n color: var(--ty-text-soft);\n font-size: var(--ty-font-sm);\n line-height: var(--ty-leading-sm);\n pointer-events: none;\n}\n\n.browse-link {\n color: var(--ty-color-primary);\n font-weight: var(--ty-font-medium);\n}\n\n.upload-sub-hint {\n color: var(--ty-text-faint);\n font-size: var(--ty-font-xs);\n line-height: var(--ty-leading-xs);\n pointer-events: none;\n}\n\n.file-list {\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n margin-top: 0.5rem;\n}\n\n.file-item {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n border-radius: var(--ty-radius-base);\n background: var(--ty-surface-content);\n border: 1px solid var(--ty-border-soft);\n}\n\n.file-icon {\n color: var(--ty-text-faint);\n flex-shrink: 0;\n width: 1rem;\n height: 1rem;\n display: flex;\n align-items: center;\n}\n\n.file-icon svg {\n width: 100%;\n height: 100%;\n}\n\n.file-name {\n flex: 1;\n font-size: var(--ty-font-sm);\n color: var(--ty-text);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n min-width: 0;\n}\n\n.file-size {\n font-size: var(--ty-font-xs);\n color: var(--ty-text-faint);\n flex-shrink: 0;\n font-variant-numeric: tabular-nums;\n}\n\n.file-remove {\n flex-shrink: 0;\n cursor: pointer;\n color: var(--ty-text-faint);\n width: 1.25rem;\n height: 1.25rem;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: var(--ty-local-transition, color 0.15s ease, background-color 0.15s ease);\n border: none;\n background: none;\n padding: 0;\n outline: none;\n}\n\n.file-remove:hover {\n color: var(--ty-color-danger);\n background: var(--ty-bg-danger-soft);\n}\n\n.file-remove:focus-visible {\n box-shadow: 0 0 0 2px var(--ty-color-danger);\n}\n\n.file-remove svg {\n width: 12px;\n height: 12px;\n}\n\n.error-message {\n font-size: var(--ty-font-xs);\n line-height: var(--ty-leading-xs);\n color: var(--ty-color-danger);\n margin-top: 4px;\n padding-left: 4px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .drop-zone,\n .upload-icon,\n .file-remove {\n transition: none;\n }\n}\n\n@media (prefers-contrast: high) {\n .drop-zone {\n border-width: 3px;\n }\n}\n";
|
|
@@ -54,7 +54,7 @@ box-shadow: 0 0 0 3px var(--ty-input-shadow-focus);
|
|
|
54
54
|
.drop-zone.drag-active {
|
|
55
55
|
border-color: var(--ty-color-primary);
|
|
56
56
|
border-style: solid;
|
|
57
|
-
background: var(--ty-bg-primary-);
|
|
57
|
+
background: var(--ty-bg-primary-soft);
|
|
58
58
|
}
|
|
59
59
|
.drop-zone.drag-active .upload-icon {
|
|
60
60
|
color: var(--ty-color-primary);
|
|
@@ -73,7 +73,7 @@ pointer-events: none;
|
|
|
73
73
|
border-color: var(--ty-color-danger);
|
|
74
74
|
}
|
|
75
75
|
.drop-zone.error:not(.disabled) {
|
|
76
|
-
background: var(--ty-bg-danger-);
|
|
76
|
+
background: var(--ty-bg-danger-soft);
|
|
77
77
|
}
|
|
78
78
|
.upload-icon {
|
|
79
79
|
color: var(--ty-text-faint);
|
|
@@ -165,7 +165,7 @@ outline: none;
|
|
|
165
165
|
}
|
|
166
166
|
.file-remove:hover {
|
|
167
167
|
color: var(--ty-color-danger);
|
|
168
|
-
background: var(--ty-bg-danger-);
|
|
168
|
+
background: var(--ty-bg-danger-soft);
|
|
169
169
|
}
|
|
170
170
|
.file-remove:focus-visible {
|
|
171
171
|
box-shadow: 0 0 0 2px var(--ty-color-danger);
|