@arclux/arc-ui 1.0.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/LICENSE +21 -0
- package/README.md +64 -0
- package/package.json +186 -0
- package/src/content/accordion-item.js +27 -0
- package/src/content/accordion.js +151 -0
- package/src/content/animated-number.js +160 -0
- package/src/content/aspect-ratio.js +78 -0
- package/src/content/avatar-group.js +101 -0
- package/src/content/avatar.js +92 -0
- package/src/content/badge.js +98 -0
- package/src/content/callout.js +141 -0
- package/src/content/card.js +75 -0
- package/src/content/carousel.js +300 -0
- package/src/content/code-block.js +152 -0
- package/src/content/collapsible.js +142 -0
- package/src/content/color-swatch.js +86 -0
- package/src/content/column.js +28 -0
- package/src/content/data-table.js +332 -0
- package/src/content/divider.js +153 -0
- package/src/content/empty-state.js +78 -0
- package/src/content/feature-card.js +142 -0
- package/src/content/highlight.js +63 -0
- package/src/content/icon-library.js +30 -0
- package/src/content/icon-registry.js +39 -0
- package/src/content/icon.js +95 -0
- package/src/content/index.js +44 -0
- package/src/content/infinite-scroll.js +144 -0
- package/src/content/kbd.js +40 -0
- package/src/content/markdown.js +294 -0
- package/src/content/marquee.js +166 -0
- package/src/content/meter.js +167 -0
- package/src/content/scroll-area.js +107 -0
- package/src/content/skeleton.js +85 -0
- package/src/content/spinner.js +77 -0
- package/src/content/stack.js +68 -0
- package/src/content/stat.js +72 -0
- package/src/content/step.js +22 -0
- package/src/content/stepper.js +202 -0
- package/src/content/table.js +134 -0
- package/src/content/tag.js +156 -0
- package/src/content/text.js +111 -0
- package/src/content/timeline-item.js +29 -0
- package/src/content/timeline.js +170 -0
- package/src/content/truncate.js +161 -0
- package/src/content/value-card.js +94 -0
- package/src/feedback/alert.js +187 -0
- package/src/feedback/command-item.js +28 -0
- package/src/feedback/command-palette.js +346 -0
- package/src/feedback/context-menu.js +299 -0
- package/src/feedback/dialog.js +298 -0
- package/src/feedback/dropdown-menu.js +259 -0
- package/src/feedback/hover-card.js +186 -0
- package/src/feedback/index.js +17 -0
- package/src/feedback/modal.js +226 -0
- package/src/feedback/notification-panel.js +196 -0
- package/src/feedback/popover.js +184 -0
- package/src/feedback/progress.js +169 -0
- package/src/feedback/sheet.js +249 -0
- package/src/feedback/toast.js +207 -0
- package/src/feedback/tooltip.js +189 -0
- package/src/icons/lucide.d.ts +1915 -0
- package/src/icons/lucide.js +1915 -0
- package/src/icons/phosphor.d.ts +1517 -0
- package/src/icons/phosphor.js +1517 -0
- package/src/icons/types.d.ts +8 -0
- package/src/index.js +9 -0
- package/src/input/button.js +127 -0
- package/src/input/calendar.js +340 -0
- package/src/input/checkbox.js +159 -0
- package/src/input/chip.js +120 -0
- package/src/input/color-picker.js +461 -0
- package/src/input/combobox.js +295 -0
- package/src/input/copy-button.js +144 -0
- package/src/input/date-picker.js +534 -0
- package/src/input/file-upload.js +333 -0
- package/src/input/form.js +179 -0
- package/src/input/icon-button.js +179 -0
- package/src/input/index.js +31 -0
- package/src/input/input.js +158 -0
- package/src/input/multi-select.js +392 -0
- package/src/input/number-input.js +239 -0
- package/src/input/otp-input.js +221 -0
- package/src/input/pin-input.js +294 -0
- package/src/input/radio-group.js +177 -0
- package/src/input/radio.js +28 -0
- package/src/input/rating.js +195 -0
- package/src/input/search.js +371 -0
- package/src/input/segmented-control.js +174 -0
- package/src/input/select.js +267 -0
- package/src/input/slider.js +217 -0
- package/src/input/sortable-list.js +345 -0
- package/src/input/suggestion.js +26 -0
- package/src/input/textarea.js +203 -0
- package/src/input/theme-toggle.js +196 -0
- package/src/input/toggle.js +166 -0
- package/src/layout/app-shell.js +266 -0
- package/src/layout/auth-shell.js +153 -0
- package/src/layout/container.js +37 -0
- package/src/layout/dashboard-grid.js +62 -0
- package/src/layout/index.js +15 -0
- package/src/layout/page-header.js +100 -0
- package/src/layout/page-layout.js +112 -0
- package/src/layout/resizable.js +221 -0
- package/src/layout/section.js +54 -0
- package/src/layout/settings-layout.js +91 -0
- package/src/layout/split-pane.js +172 -0
- package/src/layout/status-bar.js +84 -0
- package/src/layout/toolbar.js +92 -0
- package/src/navigation/breadcrumb-item.js +26 -0
- package/src/navigation/breadcrumb.js +129 -0
- package/src/navigation/drawer.js +183 -0
- package/src/navigation/footer.js +99 -0
- package/src/navigation/index.js +22 -0
- package/src/navigation/link.js +120 -0
- package/src/navigation/nav-item.js +46 -0
- package/src/navigation/navigation-menu.js +687 -0
- package/src/navigation/pagination.js +186 -0
- package/src/navigation/scroll-spy.js +198 -0
- package/src/navigation/scroll-to-top.js +163 -0
- package/src/navigation/sidebar-link.js +28 -0
- package/src/navigation/sidebar-section.js +45 -0
- package/src/navigation/sidebar.js +336 -0
- package/src/navigation/spy-link.js +26 -0
- package/src/navigation/tab.js +26 -0
- package/src/navigation/tabs.js +202 -0
- package/src/navigation/top-bar.js +263 -0
- package/src/navigation/tree-item.js +38 -0
- package/src/navigation/tree-view.js +255 -0
- package/src/shared/index.js +6 -0
- package/src/shared/menu-divider.js +9 -0
- package/src/shared/menu-item.js +30 -0
- package/src/shared/option.js +31 -0
- package/src/shared-styles.js +81 -0
- package/src/tokens.js +445 -0
- package/types/index.d.ts +973 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcSortableList extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
disabled: { type: Boolean, reflect: true },
|
|
7
|
+
_items: { state: true },
|
|
8
|
+
_dragIndex: { state: true },
|
|
9
|
+
_overIndex: { state: true },
|
|
10
|
+
_kbSelected: { state: true },
|
|
11
|
+
_kbMoving: { state: true },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
static styles = [
|
|
15
|
+
tokenStyles,
|
|
16
|
+
css`
|
|
17
|
+
:host { display: block; }
|
|
18
|
+
:host([disabled]) { pointer-events: none; opacity: 0.4; }
|
|
19
|
+
|
|
20
|
+
.sortable {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sortable__item {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: var(--space-sm);
|
|
30
|
+
padding: var(--space-sm) var(--space-md);
|
|
31
|
+
background: var(--bg-card, var(--bg-surface));
|
|
32
|
+
border: 1px solid var(--border-subtle);
|
|
33
|
+
border-radius: var(--radius-md);
|
|
34
|
+
transition: box-shadow var(--transition-fast),
|
|
35
|
+
opacity var(--transition-fast),
|
|
36
|
+
background var(--transition-fast),
|
|
37
|
+
border-color var(--transition-fast);
|
|
38
|
+
cursor: default;
|
|
39
|
+
user-select: none;
|
|
40
|
+
position: relative;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sortable__item:focus-visible {
|
|
44
|
+
outline: none;
|
|
45
|
+
box-shadow: var(--focus-ring);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sortable__item--dragging {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sortable__item--kb-selected {
|
|
54
|
+
border-color: var(--accent-primary);
|
|
55
|
+
box-shadow: 0 0 0 1px var(--accent-primary);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sortable__item--kb-moving {
|
|
59
|
+
border-color: var(--accent-primary);
|
|
60
|
+
box-shadow: 0 0 0 2px var(--accent-primary), 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
61
|
+
background: var(--bg-elevated);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.sortable__item--over-before::before,
|
|
65
|
+
.sortable__item--over-after::after {
|
|
66
|
+
content: '';
|
|
67
|
+
position: absolute;
|
|
68
|
+
left: var(--space-sm);
|
|
69
|
+
right: var(--space-sm);
|
|
70
|
+
height: 2px;
|
|
71
|
+
background: var(--accent-primary);
|
|
72
|
+
border-radius: var(--radius-full);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sortable__item--over-before::before { top: -2px; }
|
|
76
|
+
.sortable__item--over-after::after { bottom: -2px; }
|
|
77
|
+
|
|
78
|
+
.sortable__handle {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: 2px;
|
|
82
|
+
cursor: grab;
|
|
83
|
+
padding: var(--space-xs);
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
color: var(--text-ghost);
|
|
86
|
+
transition: color var(--transition-fast);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sortable__handle:hover { color: var(--text-muted); }
|
|
90
|
+
.sortable__handle:active { cursor: grabbing; }
|
|
91
|
+
|
|
92
|
+
.sortable__grip-row {
|
|
93
|
+
display: flex;
|
|
94
|
+
gap: 2px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sortable__grip-dot {
|
|
98
|
+
width: 3px;
|
|
99
|
+
height: 3px;
|
|
100
|
+
border-radius: var(--radius-full);
|
|
101
|
+
background: currentColor;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.sortable__content {
|
|
105
|
+
flex: 1;
|
|
106
|
+
min-width: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Hidden default slot for collecting children */
|
|
110
|
+
.sortable__slot-host { display: none; }
|
|
111
|
+
|
|
112
|
+
@media (prefers-reduced-motion: reduce) {
|
|
113
|
+
:host *,
|
|
114
|
+
:host *::before,
|
|
115
|
+
:host *::after {
|
|
116
|
+
animation-duration: 0.01ms !important;
|
|
117
|
+
animation-iteration-count: 1 !important;
|
|
118
|
+
transition-duration: 0.01ms !important;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`,
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
constructor() {
|
|
125
|
+
super();
|
|
126
|
+
this.disabled = false;
|
|
127
|
+
this._items = [];
|
|
128
|
+
this._dragIndex = -1;
|
|
129
|
+
this._overIndex = -1;
|
|
130
|
+
this._kbSelected = -1;
|
|
131
|
+
this._kbMoving = false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* ---- Slot management ---- */
|
|
135
|
+
|
|
136
|
+
_onSlotChange(e) {
|
|
137
|
+
const children = e.target.assignedElements({ flatten: true });
|
|
138
|
+
this._items = children.map((el, i) => ({
|
|
139
|
+
node: el,
|
|
140
|
+
originalIndex: i,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* ---- Drag and drop ---- */
|
|
145
|
+
|
|
146
|
+
_onDragStart(e, index) {
|
|
147
|
+
if (this.disabled) return;
|
|
148
|
+
this._dragIndex = index;
|
|
149
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
150
|
+
e.dataTransfer.setData('text/plain', String(index));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_onDragOver(e, index) {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
e.dataTransfer.dropEffect = 'move';
|
|
156
|
+
if (index === this._dragIndex) {
|
|
157
|
+
this._overIndex = -1;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this._overIndex = index;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_onDragLeave() {
|
|
164
|
+
this._overIndex = -1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_onDrop(e, dropIndex) {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
this._overIndex = -1;
|
|
170
|
+
const from = this._dragIndex;
|
|
171
|
+
if (from < 0 || from === dropIndex) return;
|
|
172
|
+
this._moveItem(from, dropIndex);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_onDragEnd() {
|
|
176
|
+
this._dragIndex = -1;
|
|
177
|
+
this._overIndex = -1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* ---- Keyboard reorder ---- */
|
|
181
|
+
|
|
182
|
+
_onKeydown(e, index) {
|
|
183
|
+
if (this.disabled) return;
|
|
184
|
+
|
|
185
|
+
switch (e.key) {
|
|
186
|
+
case ' ':
|
|
187
|
+
case 'Space':
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
if (this._kbMoving) {
|
|
190
|
+
// Confirm placement
|
|
191
|
+
this._kbMoving = false;
|
|
192
|
+
this._kbSelected = -1;
|
|
193
|
+
this._fireOrderChange();
|
|
194
|
+
} else {
|
|
195
|
+
// Select item for moving
|
|
196
|
+
this._kbSelected = index;
|
|
197
|
+
this._kbMoving = false;
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
case 'Enter':
|
|
202
|
+
if (this._kbSelected === index && !this._kbMoving) {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
this._kbMoving = true;
|
|
205
|
+
} else if (this._kbMoving) {
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
this._kbMoving = false;
|
|
208
|
+
this._kbSelected = -1;
|
|
209
|
+
this._fireOrderChange();
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
|
|
213
|
+
case 'Escape':
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
this._kbMoving = false;
|
|
216
|
+
this._kbSelected = -1;
|
|
217
|
+
break;
|
|
218
|
+
|
|
219
|
+
case 'ArrowUp':
|
|
220
|
+
e.preventDefault();
|
|
221
|
+
if (this._kbMoving && this._kbSelected > 0) {
|
|
222
|
+
const from = this._kbSelected;
|
|
223
|
+
this._moveItemInPlace(from, from - 1);
|
|
224
|
+
this._kbSelected = from - 1;
|
|
225
|
+
this._focusItem(this._kbSelected);
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
|
|
229
|
+
case 'ArrowDown':
|
|
230
|
+
e.preventDefault();
|
|
231
|
+
if (this._kbMoving && this._kbSelected < this._items.length - 1) {
|
|
232
|
+
const from = this._kbSelected;
|
|
233
|
+
this._moveItemInPlace(from, from + 1);
|
|
234
|
+
this._kbSelected = from + 1;
|
|
235
|
+
this._focusItem(this._kbSelected);
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
|
|
239
|
+
default:
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* ---- Reordering helpers ---- */
|
|
245
|
+
|
|
246
|
+
_moveItem(from, to) {
|
|
247
|
+
const items = [...this._items];
|
|
248
|
+
const [moved] = items.splice(from, 1);
|
|
249
|
+
items.splice(to, 0, moved);
|
|
250
|
+
this._items = items;
|
|
251
|
+
this._dragIndex = -1;
|
|
252
|
+
this._fireOrderChange();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
_moveItemInPlace(from, to) {
|
|
256
|
+
const items = [...this._items];
|
|
257
|
+
const [moved] = items.splice(from, 1);
|
|
258
|
+
items.splice(to, 0, moved);
|
|
259
|
+
this._items = items;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
_fireOrderChange() {
|
|
263
|
+
this.dispatchEvent(new CustomEvent('arc-change', {
|
|
264
|
+
detail: { order: this._items.map(item => item.originalIndex) },
|
|
265
|
+
bubbles: true,
|
|
266
|
+
composed: true,
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
_focusItem(index) {
|
|
271
|
+
this.updateComplete.then(() => {
|
|
272
|
+
const items = this.shadowRoot.querySelectorAll('.sortable__item');
|
|
273
|
+
items[index]?.focus();
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* ---- Render ---- */
|
|
278
|
+
|
|
279
|
+
_renderGripDots() {
|
|
280
|
+
// 3 rows x 2 dots = 6-dot grip icon
|
|
281
|
+
return html`
|
|
282
|
+
${[0, 1, 2].map(() => html`
|
|
283
|
+
<div class="sortable__grip-row">
|
|
284
|
+
<span class="sortable__grip-dot"></span>
|
|
285
|
+
<span class="sortable__grip-dot"></span>
|
|
286
|
+
</div>
|
|
287
|
+
`)}
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
render() {
|
|
292
|
+
return html`
|
|
293
|
+
<div class="sortable__slot-host">
|
|
294
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
295
|
+
</div>
|
|
296
|
+
<div
|
|
297
|
+
class="sortable"
|
|
298
|
+
part="list"
|
|
299
|
+
role="listbox"
|
|
300
|
+
aria-roledescription="sortable list"
|
|
301
|
+
aria-label="Sortable list"
|
|
302
|
+
>
|
|
303
|
+
${this._items.map((item, i) => {
|
|
304
|
+
const isDragging = i === this._dragIndex;
|
|
305
|
+
const isOverBefore = i === this._overIndex && this._dragIndex > i;
|
|
306
|
+
const isOverAfter = i === this._overIndex && this._dragIndex < i;
|
|
307
|
+
const isKbSelected = i === this._kbSelected && !this._kbMoving;
|
|
308
|
+
const isKbMoving = i === this._kbSelected && this._kbMoving;
|
|
309
|
+
|
|
310
|
+
return html`
|
|
311
|
+
<div
|
|
312
|
+
class="sortable__item
|
|
313
|
+
${isDragging ? 'sortable__item--dragging' : ''}
|
|
314
|
+
${isOverBefore ? 'sortable__item--over-before' : ''}
|
|
315
|
+
${isOverAfter ? 'sortable__item--over-after' : ''}
|
|
316
|
+
${isKbSelected ? 'sortable__item--kb-selected' : ''}
|
|
317
|
+
${isKbMoving ? 'sortable__item--kb-moving' : ''}"
|
|
318
|
+
part="item"
|
|
319
|
+
role="option"
|
|
320
|
+
tabindex="0"
|
|
321
|
+
aria-grabbed=${isDragging || isKbMoving ? 'true' : 'false'}
|
|
322
|
+
aria-roledescription="sortable item"
|
|
323
|
+
draggable="true"
|
|
324
|
+
@dragstart=${(e) => this._onDragStart(e, i)}
|
|
325
|
+
@dragover=${(e) => this._onDragOver(e, i)}
|
|
326
|
+
@dragleave=${this._onDragLeave}
|
|
327
|
+
@drop=${(e) => this._onDrop(e, i)}
|
|
328
|
+
@dragend=${this._onDragEnd}
|
|
329
|
+
@keydown=${(e) => this._onKeydown(e, i)}
|
|
330
|
+
>
|
|
331
|
+
<div class="sortable__handle" part="handle" aria-hidden="true">
|
|
332
|
+
${this._renderGripDots()}
|
|
333
|
+
</div>
|
|
334
|
+
<div class="sortable__content" part="content">
|
|
335
|
+
${item.node?.textContent ?? ''}
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
`;
|
|
339
|
+
})}
|
|
340
|
+
</div>
|
|
341
|
+
`;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
customElements.define('arc-sortable-list', ArcSortableList);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class ArcSuggestion extends LitElement {
|
|
4
|
+
static properties = {
|
|
5
|
+
value: { type: String, reflect: true },
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
static styles = css`
|
|
9
|
+
:host { display: none; }
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.value = '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get label() {
|
|
18
|
+
return this.textContent.trim();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
return html`<slot></slot>`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
customElements.define('arc-suggestion', ArcSuggestion);
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcTextarea extends LitElement {
|
|
5
|
+
static formAssociated = true;
|
|
6
|
+
|
|
7
|
+
static properties = {
|
|
8
|
+
value: { type: String },
|
|
9
|
+
placeholder: { type: String },
|
|
10
|
+
label: { type: String },
|
|
11
|
+
rows: { type: Number },
|
|
12
|
+
maxlength: { type: Number },
|
|
13
|
+
disabled: { type: Boolean, reflect: true },
|
|
14
|
+
readonly: { type: Boolean, reflect: true },
|
|
15
|
+
resize: { type: String, reflect: true },
|
|
16
|
+
error: { type: String },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static styles = [
|
|
20
|
+
tokenStyles,
|
|
21
|
+
css`
|
|
22
|
+
:host { display: block; font-family: var(--font-body); }
|
|
23
|
+
:host([disabled]) { opacity: 0.4; pointer-events: none; }
|
|
24
|
+
|
|
25
|
+
.textarea-wrapper {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: var(--space-xs);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
label {
|
|
32
|
+
font-family: var(--font-accent);
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
font-size: var(--text-xs);
|
|
35
|
+
letter-spacing: 1px;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
color: var(--text-muted);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
textarea {
|
|
41
|
+
font-family: var(--font-body);
|
|
42
|
+
font-size: var(--text-sm);
|
|
43
|
+
line-height: 1.5;
|
|
44
|
+
color: var(--text-primary);
|
|
45
|
+
background: var(--bg-card);
|
|
46
|
+
border: 1px solid var(--border-default);
|
|
47
|
+
border-radius: var(--radius-md);
|
|
48
|
+
padding: var(--space-sm) var(--space-md);
|
|
49
|
+
outline: none;
|
|
50
|
+
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
|
|
51
|
+
width: 100%;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host([resize="none"]) textarea { resize: none; }
|
|
56
|
+
:host([resize="vertical"]) textarea { resize: vertical; }
|
|
57
|
+
:host([resize="horizontal"]) textarea { resize: horizontal; }
|
|
58
|
+
:host([resize="both"]) textarea { resize: both; }
|
|
59
|
+
:host(:not([resize])) textarea { resize: vertical; }
|
|
60
|
+
|
|
61
|
+
textarea::placeholder {
|
|
62
|
+
color: var(--text-muted);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
textarea:hover:not(:disabled):not(:read-only):not(:focus) {
|
|
66
|
+
border-color: var(--border-bright);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
textarea:focus {
|
|
70
|
+
outline: none;
|
|
71
|
+
border-color: rgba(var(--accent-primary-rgb), 0.4);
|
|
72
|
+
box-shadow: var(--focus-glow);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:host([readonly]) textarea {
|
|
76
|
+
cursor: default;
|
|
77
|
+
background: var(--bg-surface);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.error textarea {
|
|
81
|
+
border-color: var(--color-error);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.error textarea:focus {
|
|
85
|
+
outline: none;
|
|
86
|
+
box-shadow: 0 0 0 2px var(--bg-deep), 0 0 0 4px var(--color-error), 0 0 16px rgba(var(--color-error-rgb), 0.2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.footer {
|
|
90
|
+
display: flex;
|
|
91
|
+
justify-content: space-between;
|
|
92
|
+
align-items: center;
|
|
93
|
+
min-height: 20px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.error-message {
|
|
97
|
+
font-size: var(--text-xs);
|
|
98
|
+
color: var(--color-error);
|
|
99
|
+
line-height: 1.4;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.char-count {
|
|
103
|
+
font-size: var(--text-xs);
|
|
104
|
+
color: var(--text-muted);
|
|
105
|
+
margin-left: auto;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.char-count.at-limit {
|
|
109
|
+
color: var(--color-error);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@media (prefers-reduced-motion: reduce) {
|
|
113
|
+
:host *,
|
|
114
|
+
:host *::before,
|
|
115
|
+
:host *::after {
|
|
116
|
+
animation-duration: 0.01ms !important;
|
|
117
|
+
animation-iteration-count: 1 !important;
|
|
118
|
+
transition-duration: 0.01ms !important;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`,
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
constructor() {
|
|
125
|
+
super();
|
|
126
|
+
this._internals = this.attachInternals();
|
|
127
|
+
this.value = '';
|
|
128
|
+
this.placeholder = '';
|
|
129
|
+
this.label = '';
|
|
130
|
+
this.rows = 4;
|
|
131
|
+
this.maxlength = 0;
|
|
132
|
+
this.disabled = false;
|
|
133
|
+
this.readonly = false;
|
|
134
|
+
this.resize = 'vertical';
|
|
135
|
+
this.error = '';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
updated(changed) {
|
|
139
|
+
if (changed.has('value')) {
|
|
140
|
+
this._internals.setFormValue(this.value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_onInput(e) {
|
|
145
|
+
this.value = e.target.value;
|
|
146
|
+
this._internals.setFormValue(this.value);
|
|
147
|
+
this.dispatchEvent(new CustomEvent('arc-input', {
|
|
148
|
+
detail: { value: this.value },
|
|
149
|
+
bubbles: true,
|
|
150
|
+
composed: true,
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_onChange(e) {
|
|
155
|
+
this.value = e.target.value;
|
|
156
|
+
this._internals.setFormValue(this.value);
|
|
157
|
+
this.dispatchEvent(new CustomEvent('arc-change', {
|
|
158
|
+
detail: { value: this.value },
|
|
159
|
+
bubbles: true,
|
|
160
|
+
composed: true,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
render() {
|
|
165
|
+
const hasError = !!this.error;
|
|
166
|
+
const showCounter = this.maxlength > 0;
|
|
167
|
+
const atLimit = showCounter && this.value.length >= this.maxlength;
|
|
168
|
+
|
|
169
|
+
return html`
|
|
170
|
+
<div class="textarea-wrapper ${hasError ? 'error' : ''}" part="wrapper">
|
|
171
|
+
${this.label ? html`
|
|
172
|
+
<label part="label" id="textarea-label">${this.label}</label>
|
|
173
|
+
` : ''}
|
|
174
|
+
<textarea
|
|
175
|
+
part="textarea"
|
|
176
|
+
.value=${this.value}
|
|
177
|
+
placeholder=${this.placeholder}
|
|
178
|
+
rows=${this.rows}
|
|
179
|
+
?disabled=${this.disabled}
|
|
180
|
+
?readonly=${this.readonly}
|
|
181
|
+
maxlength=${this.maxlength > 0 ? this.maxlength : undefined}
|
|
182
|
+
aria-labelledby=${this.label ? 'textarea-label' : undefined}
|
|
183
|
+
aria-invalid=${hasError ? 'true' : 'false'}
|
|
184
|
+
aria-describedby=${hasError ? 'error-msg' : undefined}
|
|
185
|
+
@input=${this._onInput}
|
|
186
|
+
@change=${this._onChange}
|
|
187
|
+
></textarea>
|
|
188
|
+
<div class="footer">
|
|
189
|
+
${hasError ? html`
|
|
190
|
+
<span class="error-message" id="error-msg" role="alert" part="error">${this.error}</span>
|
|
191
|
+
` : html`<span></span>`}
|
|
192
|
+
${showCounter ? html`
|
|
193
|
+
<span class="char-count ${atLimit ? 'at-limit' : ''}" part="counter" aria-live="polite">
|
|
194
|
+
${this.value.length}/${this.maxlength}
|
|
195
|
+
</span>
|
|
196
|
+
` : ''}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
customElements.define('arc-textarea', ArcTextarea);
|