@evoke-tech/stencil-ui-kit 0.1.0 → 0.2.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/README.md +120 -20
- package/dist/cjs/evoke-alert_20.cjs.entry.js +1047 -0
- package/dist/cjs/evoke-ui.cjs.js +2 -2
- package/dist/cjs/{index-B8xS0y1i.js → index-BpJ5gu8f.js} +146 -5
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +13 -1
- package/dist/collection/components/evoke-alert/evoke-alert.css +17 -6
- package/dist/collection/components/evoke-alert/evoke-alert.js +25 -1
- package/dist/collection/components/evoke-app-bar/evoke-app-bar.css +13 -0
- package/dist/collection/components/evoke-app-bar/evoke-app-bar.js +94 -0
- package/dist/collection/components/evoke-badge/evoke-badge.css +13 -0
- package/dist/collection/components/evoke-badge/evoke-badge.js +162 -0
- package/dist/collection/components/evoke-button/evoke-button.css +16 -2
- package/dist/collection/components/evoke-button/evoke-button.js +117 -5
- package/dist/collection/components/evoke-card/evoke-card.css +9 -1
- package/dist/collection/components/evoke-card/evoke-card.js +75 -1
- package/dist/collection/components/evoke-checkbox/evoke-checkbox.css +7 -1
- package/dist/collection/components/evoke-checkbox/evoke-checkbox.js +31 -2
- package/dist/collection/components/evoke-chip/evoke-chip.css +16 -0
- package/dist/collection/components/evoke-chip/evoke-chip.js +149 -0
- package/dist/collection/components/evoke-input/evoke-input.css +11 -3
- package/dist/collection/components/evoke-input/evoke-input.js +103 -13
- package/dist/collection/components/evoke-modal/evoke-modal.css +21 -5
- package/dist/collection/components/evoke-modal/evoke-modal.js +129 -4
- package/dist/collection/components/evoke-pagination/evoke-pagination.css +12 -0
- package/dist/collection/components/evoke-pagination/evoke-pagination.js +156 -0
- package/dist/collection/components/evoke-progress/evoke-progress.css +12 -0
- package/dist/collection/components/evoke-progress/evoke-progress.js +146 -0
- package/dist/collection/components/evoke-quantity-stepper/evoke-quantity-stepper.css +20 -0
- package/dist/collection/components/evoke-quantity-stepper/evoke-quantity-stepper.js +201 -0
- package/dist/collection/components/evoke-radio-group/evoke-radio-group.css +14 -1
- package/dist/collection/components/evoke-radio-group/evoke-radio-group.js +34 -8
- package/dist/collection/components/evoke-select/evoke-select.css +25 -4
- package/dist/collection/components/evoke-select/evoke-select.js +245 -15
- package/dist/collection/components/evoke-switch/evoke-switch.css +16 -0
- package/dist/collection/components/evoke-switch/evoke-switch.js +151 -0
- package/dist/collection/components/evoke-table/evoke-table.css +20 -0
- package/dist/collection/components/evoke-table/evoke-table.js +222 -0
- package/dist/collection/components/evoke-tabs/evoke-tabs.css +20 -0
- package/dist/collection/components/evoke-tabs/evoke-tabs.js +179 -0
- package/dist/collection/components/evoke-textarea/evoke-textarea.css +19 -0
- package/dist/collection/components/evoke-textarea/evoke-textarea.js +328 -0
- package/dist/collection/components/evoke-toast/evoke-toast.css +24 -0
- package/dist/collection/components/evoke-toast/evoke-toast.js +225 -0
- package/dist/collection/components/evoke-tooltip/evoke-tooltip.css +22 -0
- package/dist/collection/components/evoke-tooltip/evoke-tooltip.js +119 -0
- package/dist/collection/utils/icons.js +29 -0
- package/dist/components/evoke-alert.js +1 -1
- package/dist/components/evoke-app-bar.d.ts +11 -0
- package/dist/components/evoke-app-bar.js +1 -0
- package/dist/components/evoke-badge.d.ts +11 -0
- package/dist/components/evoke-badge.js +1 -0
- package/dist/components/evoke-button.js +1 -1
- package/dist/components/evoke-card.js +1 -1
- package/dist/components/evoke-checkbox.js +1 -1
- package/dist/components/evoke-chip.d.ts +11 -0
- package/dist/components/evoke-chip.js +1 -0
- package/dist/components/evoke-input.js +1 -1
- package/dist/components/evoke-modal.js +1 -1
- package/dist/components/evoke-pagination.d.ts +11 -0
- package/dist/components/evoke-pagination.js +1 -0
- package/dist/components/evoke-progress.d.ts +11 -0
- package/dist/components/evoke-progress.js +1 -0
- package/dist/components/evoke-quantity-stepper.d.ts +11 -0
- package/dist/components/evoke-quantity-stepper.js +1 -0
- package/dist/components/evoke-radio-group.js +1 -1
- package/dist/components/evoke-select.js +1 -1
- package/dist/components/evoke-switch.d.ts +11 -0
- package/dist/components/evoke-switch.js +1 -0
- package/dist/components/evoke-table.d.ts +11 -0
- package/dist/components/evoke-table.js +1 -0
- package/dist/components/evoke-tabs.d.ts +11 -0
- package/dist/components/evoke-tabs.js +1 -0
- package/dist/components/evoke-textarea.d.ts +11 -0
- package/dist/components/evoke-textarea.js +1 -0
- package/dist/components/evoke-toast.d.ts +11 -0
- package/dist/components/evoke-toast.js +1 -0
- package/dist/components/evoke-tooltip.d.ts +11 -0
- package/dist/components/evoke-tooltip.js +1 -0
- package/dist/components/icons.js +1 -0
- package/dist/esm/evoke-alert_20.entry.js +1026 -0
- package/dist/esm/evoke-ui.js +3 -3
- package/dist/esm/{index-BtM1wZ-I.js → index-C-5sEjU8.js} +146 -6
- package/dist/esm/loader.js +3 -3
- package/dist/evoke-ui/evoke-ui.css +1 -1
- package/dist/evoke-ui/evoke-ui.esm.js +1 -1
- package/dist/evoke-ui/p-0841be89.entry.js +1 -0
- package/dist/evoke-ui/p-C-5sEjU8.js +3 -0
- package/dist/themes/bootstrap.css +3 -0
- package/dist/themes/material.css +3 -0
- package/dist/themes/tailwind.css +3 -0
- package/dist/themes/tokens.css +4 -1
- package/dist/types/components/evoke-alert/evoke-alert.d.ts +2 -0
- package/dist/types/components/evoke-app-bar/evoke-app-bar.d.ts +14 -0
- package/dist/types/components/evoke-badge/evoke-badge.d.ts +17 -0
- package/dist/types/components/evoke-button/evoke-button.d.ts +12 -2
- package/dist/types/components/evoke-card/evoke-card.d.ts +9 -0
- package/dist/types/components/evoke-checkbox/evoke-checkbox.d.ts +5 -0
- package/dist/types/components/evoke-chip/evoke-chip.d.ts +14 -0
- package/dist/types/components/evoke-input/evoke-input.d.ts +9 -1
- package/dist/types/components/evoke-modal/evoke-modal.d.ts +19 -1
- package/dist/types/components/evoke-pagination/evoke-pagination.d.ts +15 -0
- package/dist/types/components/evoke-progress/evoke-progress.d.ts +13 -0
- package/dist/types/components/evoke-quantity-stepper/evoke-quantity-stepper.d.ts +18 -0
- package/dist/types/components/evoke-radio-group/evoke-radio-group.d.ts +4 -2
- package/dist/types/components/evoke-select/evoke-select.d.ts +31 -6
- package/dist/types/components/evoke-switch/evoke-switch.d.ts +15 -0
- package/dist/types/components/evoke-table/evoke-table.d.ts +29 -0
- package/dist/types/components/evoke-tabs/evoke-tabs.d.ts +21 -0
- package/dist/types/components/evoke-textarea/evoke-textarea.d.ts +28 -0
- package/dist/types/components/evoke-toast/evoke-toast.d.ts +24 -0
- package/dist/types/components/evoke-tooltip/evoke-tooltip.d.ts +17 -0
- package/dist/types/components.d.ts +1237 -18
- package/dist/types/utils/icons.d.ts +25 -0
- package/package.json +11 -4
- package/dist/cjs/evoke-alert_6.cjs.entry.js +0 -172
- package/dist/cjs/evoke-card.cjs.entry.js +0 -20
- package/dist/cjs/evoke-modal.cjs.entry.js +0 -34
- package/dist/esm/evoke-alert_6.entry.js +0 -165
- package/dist/esm/evoke-card.entry.js +0 -18
- package/dist/esm/evoke-modal.entry.js +0 -32
- package/dist/evoke-ui/p-243075cd.entry.js +0 -1
- package/dist/evoke-ui/p-605d4757.entry.js +0 -1
- package/dist/evoke-ui/p-9a6eaeb6.entry.js +0 -1
- package/dist/evoke-ui/p-BtM1wZ-I.js +0 -3
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { renderIcon } from "../../utils/icons";
|
|
3
|
+
export class EvokeTable {
|
|
4
|
+
constructor() {
|
|
5
|
+
/** Columns as an array of { key, label, sortable?, align? } or a JSON string of the same */
|
|
6
|
+
this.columns = [];
|
|
7
|
+
/** Rows as an array of objects keyed by column key, or a JSON string of the same */
|
|
8
|
+
this.rows = [];
|
|
9
|
+
/** Alternate row shading */
|
|
10
|
+
this.striped = false;
|
|
11
|
+
/** Allow sorting on columns marked `sortable` (or all columns if none are marked) */
|
|
12
|
+
this.sortable = false;
|
|
13
|
+
/** Visually hidden/visible table caption for screen readers */
|
|
14
|
+
this.caption = '';
|
|
15
|
+
this.emptyText = 'No data';
|
|
16
|
+
this.sortKey = '';
|
|
17
|
+
this.sortDir = 'asc';
|
|
18
|
+
}
|
|
19
|
+
parse(v) {
|
|
20
|
+
if (Array.isArray(v))
|
|
21
|
+
return v;
|
|
22
|
+
try {
|
|
23
|
+
const p = JSON.parse(v);
|
|
24
|
+
return Array.isArray(p) ? p : [];
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
toggleSort(key) {
|
|
31
|
+
this.sortDir = this.sortKey === key && this.sortDir === 'asc' ? 'desc' : 'asc';
|
|
32
|
+
this.sortKey = key;
|
|
33
|
+
this.evokeSort.emit({ key, direction: this.sortDir });
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const cols = this.parse(this.columns);
|
|
37
|
+
const anyMarked = cols.some((c) => c.sortable);
|
|
38
|
+
const isSortable = (c) => this.sortable && (anyMarked ? !!c.sortable : true);
|
|
39
|
+
let rows = [...this.parse(this.rows)];
|
|
40
|
+
if (this.sortKey) {
|
|
41
|
+
const k = this.sortKey;
|
|
42
|
+
const dir = this.sortDir === 'asc' ? 1 : -1;
|
|
43
|
+
rows.sort((a, b) => {
|
|
44
|
+
const x = a[k], y = b[k];
|
|
45
|
+
if (x == null)
|
|
46
|
+
return 1;
|
|
47
|
+
if (y == null)
|
|
48
|
+
return -1;
|
|
49
|
+
return (typeof x === 'number' && typeof y === 'number' ? x - y : String(x).localeCompare(String(y), undefined, { numeric: true })) * dir;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return (h("div", { class: "evoke-table__wrap" }, h("table", { class: `evoke-table ${this.striped ? 'evoke-table--striped' : ''}`.trim() }, this.caption && h("caption", { class: "evoke-table__caption" }, this.caption), h("thead", null, h("tr", null, cols.map((c) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const active = this.sortKey === c.key;
|
|
55
|
+
return (h("th", { scope: "col", class: `evoke-table__th evoke-table__cell--${(_a = c.align) !== null && _a !== void 0 ? _a : 'left'}`, "aria-sort": isSortable(c) ? (active ? (this.sortDir === 'asc' ? 'ascending' : 'descending') : 'none') : undefined }, isSortable(c) ? (h("button", { type: "button", class: "evoke-table__sort", onClick: () => this.toggleSort(c.key) }, c.label, renderIcon(active ? (this.sortDir === 'asc' ? 'arrow-up' : 'arrow-down') : 'sort', `evoke-table__sort-icon ${active ? 'evoke-table__sort-icon--active' : ''}`.trim()))) : (c.label)));
|
|
56
|
+
}))), h("tbody", null, rows.length === 0 ? (h("tr", null, h("td", { class: "evoke-table__empty", colSpan: Math.max(cols.length, 1) }, this.emptyText))) : (rows.map((r) => (h("tr", { class: "evoke-table__row" }, cols.map((c) => { var _a; return h("td", { class: `evoke-table__td evoke-table__cell--${(_a = c.align) !== null && _a !== void 0 ? _a : 'left'}` }, r[c.key] == null ? '' : String(r[c.key])); })))))))));
|
|
57
|
+
}
|
|
58
|
+
static get is() { return "evoke-table"; }
|
|
59
|
+
static get originalStyleUrls() {
|
|
60
|
+
return {
|
|
61
|
+
"$": ["evoke-table.css"]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static get styleUrls() {
|
|
65
|
+
return {
|
|
66
|
+
"$": ["evoke-table.css"]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static get properties() {
|
|
70
|
+
return {
|
|
71
|
+
"columns": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"mutable": false,
|
|
74
|
+
"complexType": {
|
|
75
|
+
"original": "{ key: string; label: string; sortable?: boolean; align?: 'left' | 'center' | 'right' }[] | string",
|
|
76
|
+
"resolved": "string | { key: string; label: string; sortable?: boolean; align?: \"center\" | \"right\" | \"left\"; }[]",
|
|
77
|
+
"references": {}
|
|
78
|
+
},
|
|
79
|
+
"required": false,
|
|
80
|
+
"optional": false,
|
|
81
|
+
"docs": {
|
|
82
|
+
"tags": [],
|
|
83
|
+
"text": "Columns as an array of { key, label, sortable?, align? } or a JSON string of the same"
|
|
84
|
+
},
|
|
85
|
+
"getter": false,
|
|
86
|
+
"setter": false,
|
|
87
|
+
"reflect": false,
|
|
88
|
+
"attribute": "columns",
|
|
89
|
+
"defaultValue": "[]"
|
|
90
|
+
},
|
|
91
|
+
"rows": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"mutable": false,
|
|
94
|
+
"complexType": {
|
|
95
|
+
"original": "Record<string, string | number | boolean | null>[] | string",
|
|
96
|
+
"resolved": "Record<string, string | number | boolean>[] | string",
|
|
97
|
+
"references": {
|
|
98
|
+
"Record": {
|
|
99
|
+
"location": "global",
|
|
100
|
+
"id": "global::Record"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"required": false,
|
|
105
|
+
"optional": false,
|
|
106
|
+
"docs": {
|
|
107
|
+
"tags": [],
|
|
108
|
+
"text": "Rows as an array of objects keyed by column key, or a JSON string of the same"
|
|
109
|
+
},
|
|
110
|
+
"getter": false,
|
|
111
|
+
"setter": false,
|
|
112
|
+
"reflect": false,
|
|
113
|
+
"attribute": "rows",
|
|
114
|
+
"defaultValue": "[]"
|
|
115
|
+
},
|
|
116
|
+
"striped": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"mutable": false,
|
|
119
|
+
"complexType": {
|
|
120
|
+
"original": "boolean",
|
|
121
|
+
"resolved": "boolean",
|
|
122
|
+
"references": {}
|
|
123
|
+
},
|
|
124
|
+
"required": false,
|
|
125
|
+
"optional": false,
|
|
126
|
+
"docs": {
|
|
127
|
+
"tags": [],
|
|
128
|
+
"text": "Alternate row shading"
|
|
129
|
+
},
|
|
130
|
+
"getter": false,
|
|
131
|
+
"setter": false,
|
|
132
|
+
"reflect": false,
|
|
133
|
+
"attribute": "striped",
|
|
134
|
+
"defaultValue": "false"
|
|
135
|
+
},
|
|
136
|
+
"sortable": {
|
|
137
|
+
"type": "boolean",
|
|
138
|
+
"mutable": false,
|
|
139
|
+
"complexType": {
|
|
140
|
+
"original": "boolean",
|
|
141
|
+
"resolved": "boolean",
|
|
142
|
+
"references": {}
|
|
143
|
+
},
|
|
144
|
+
"required": false,
|
|
145
|
+
"optional": false,
|
|
146
|
+
"docs": {
|
|
147
|
+
"tags": [],
|
|
148
|
+
"text": "Allow sorting on columns marked `sortable` (or all columns if none are marked)"
|
|
149
|
+
},
|
|
150
|
+
"getter": false,
|
|
151
|
+
"setter": false,
|
|
152
|
+
"reflect": false,
|
|
153
|
+
"attribute": "sortable",
|
|
154
|
+
"defaultValue": "false"
|
|
155
|
+
},
|
|
156
|
+
"caption": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"mutable": false,
|
|
159
|
+
"complexType": {
|
|
160
|
+
"original": "string",
|
|
161
|
+
"resolved": "string",
|
|
162
|
+
"references": {}
|
|
163
|
+
},
|
|
164
|
+
"required": false,
|
|
165
|
+
"optional": false,
|
|
166
|
+
"docs": {
|
|
167
|
+
"tags": [],
|
|
168
|
+
"text": "Visually hidden/visible table caption for screen readers"
|
|
169
|
+
},
|
|
170
|
+
"getter": false,
|
|
171
|
+
"setter": false,
|
|
172
|
+
"reflect": false,
|
|
173
|
+
"attribute": "caption",
|
|
174
|
+
"defaultValue": "''"
|
|
175
|
+
},
|
|
176
|
+
"emptyText": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "string",
|
|
181
|
+
"resolved": "string",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": ""
|
|
189
|
+
},
|
|
190
|
+
"getter": false,
|
|
191
|
+
"setter": false,
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"attribute": "empty-text",
|
|
194
|
+
"defaultValue": "'No data'"
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
static get states() {
|
|
199
|
+
return {
|
|
200
|
+
"sortKey": {},
|
|
201
|
+
"sortDir": {}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
static get events() {
|
|
205
|
+
return [{
|
|
206
|
+
"method": "evokeSort",
|
|
207
|
+
"name": "evokeSort",
|
|
208
|
+
"bubbles": true,
|
|
209
|
+
"cancelable": true,
|
|
210
|
+
"composed": true,
|
|
211
|
+
"docs": {
|
|
212
|
+
"tags": [],
|
|
213
|
+
"text": "Fired after a header is sorted: { key, direction } where direction is 'asc' or 'desc'"
|
|
214
|
+
},
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "{ key: string; direction: 'asc' | 'desc' }",
|
|
217
|
+
"resolved": "{ key: string; direction: \"desc\" | \"asc\"; }",
|
|
218
|
+
"references": {}
|
|
219
|
+
}
|
|
220
|
+
}];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
evoke-tabs { display: block; min-width: 0; max-width: 100%; }
|
|
2
|
+
evoke-tabs .evoke-tabs { font-family: var(--evoke-font, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif); color: var(--evoke-text, #1a1a1a); }
|
|
3
|
+
evoke-tabs .evoke-tabs__list { display: flex; gap: 4px; overflow-x: auto; }
|
|
4
|
+
evoke-tabs .evoke-tabs__tab { flex: none; font: inherit; font-size: 1rem; padding: 12px 20px; background: transparent; border: 0; color: var(--evoke-text-muted, #6b6b6b); cursor: pointer; transition: color 0.15s, background-color 0.15s, filter 0.15s; }
|
|
5
|
+
evoke-tabs .evoke-tabs__tab:hover:not(:disabled):not(.evoke-tabs__tab--active) { color: var(--evoke-text, #1a1a1a); }
|
|
6
|
+
evoke-tabs .evoke-tabs__tab:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
7
|
+
evoke-tabs .evoke-tabs__tab:focus-visible { outline: none; box-shadow: var(--evoke-focus-ring, 0 0 0 3px rgba(11, 21, 96, 0.15)); }
|
|
8
|
+
/* underline */
|
|
9
|
+
evoke-tabs .evoke-tabs--underline .evoke-tabs__list { border-bottom: 1px solid var(--evoke-border, #dedede); gap: 0; }
|
|
10
|
+
evoke-tabs .evoke-tabs--underline .evoke-tabs__tab { border-bottom: 2px solid transparent; margin-bottom: -1px; }
|
|
11
|
+
evoke-tabs .evoke-tabs--underline .evoke-tabs__tab:hover:not(:disabled):not(.evoke-tabs__tab--active) { border-bottom-color: var(--evoke-border, #dedede); }
|
|
12
|
+
evoke-tabs .evoke-tabs--underline .evoke-tabs__tab--active { color: var(--evoke-primary-text, #cc3d0d); border-bottom-color: var(--evoke-primary, #ff5316); font-weight: 500; }
|
|
13
|
+
evoke-tabs .evoke-tabs--underline .evoke-tabs__tab:active:not(:disabled) { background: var(--evoke-surface-muted, #f5f5f5); }
|
|
14
|
+
/* pill */
|
|
15
|
+
evoke-tabs .evoke-tabs--pill .evoke-tabs__tab { border-radius: var(--evoke-radius-button, 9999px); padding: 8px 20px; }
|
|
16
|
+
evoke-tabs .evoke-tabs--pill .evoke-tabs__tab:hover:not(:disabled):not(.evoke-tabs__tab--active) { background: var(--evoke-surface-muted, #f5f5f5); }
|
|
17
|
+
evoke-tabs .evoke-tabs--pill .evoke-tabs__tab--active { background: var(--evoke-primary, #ff5316); color: var(--evoke-primary-contrast, #ffffff); }
|
|
18
|
+
evoke-tabs .evoke-tabs--pill .evoke-tabs__tab:active:not(:disabled) { filter: brightness(0.85); }
|
|
19
|
+
evoke-tabs .evoke-tabs__panel { padding: 16px 0; }
|
|
20
|
+
evoke-tabs .evoke-tabs__panel:focus-visible { outline: none; box-shadow: var(--evoke-focus-ring, 0 0 0 3px rgba(11, 21, 96, 0.15)); border-radius: var(--evoke-radius-field, 8px); }
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { parseOptions } from "../../utils/options";
|
|
3
|
+
export class EvokeTabs {
|
|
4
|
+
constructor() {
|
|
5
|
+
/** Tabs as an array of { label, value, disabled? } or a JSON string of the same */
|
|
6
|
+
this.options = [];
|
|
7
|
+
/** Value of the active tab. Defaults to the first enabled tab. */
|
|
8
|
+
this.value = '';
|
|
9
|
+
/** Underline tabs or pill tabs */
|
|
10
|
+
this.appearance = 'underline';
|
|
11
|
+
/** Accessible name for the tab list */
|
|
12
|
+
this.label = '';
|
|
13
|
+
this.uid = Math.random().toString(36).slice(2, 9);
|
|
14
|
+
this.onKeyDown = (e) => {
|
|
15
|
+
const keys = ['ArrowRight', 'ArrowLeft', 'Home', 'End'];
|
|
16
|
+
if (!keys.includes(e.key))
|
|
17
|
+
return;
|
|
18
|
+
const tabs = this.tabs;
|
|
19
|
+
const enabled = tabs.map((t, i) => (t.disabled ? -1 : i)).filter((i) => i >= 0);
|
|
20
|
+
if (enabled.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
const cur = tabs.findIndex((t) => t.value === this.activeValue);
|
|
24
|
+
const pos = enabled.indexOf(cur);
|
|
25
|
+
let next = enabled[0];
|
|
26
|
+
if (e.key === 'ArrowRight')
|
|
27
|
+
next = enabled[(pos + 1) % enabled.length];
|
|
28
|
+
else if (e.key === 'ArrowLeft')
|
|
29
|
+
next = enabled[(pos - 1 + enabled.length) % enabled.length];
|
|
30
|
+
else if (e.key === 'End')
|
|
31
|
+
next = enabled[enabled.length - 1];
|
|
32
|
+
const btn = this.el.querySelectorAll('[role="tab"]')[next];
|
|
33
|
+
btn === null || btn === void 0 ? void 0 : btn.focus();
|
|
34
|
+
this.select(tabs[next].value);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
get tabs() {
|
|
38
|
+
return parseOptions(this.options);
|
|
39
|
+
}
|
|
40
|
+
get activeValue() {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const tabs = this.tabs;
|
|
43
|
+
return tabs.some((t) => t.value === this.value && !t.disabled) ? this.value : (_b = (_a = tabs.find((t) => !t.disabled)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
|
|
44
|
+
}
|
|
45
|
+
select(v) {
|
|
46
|
+
if (v === this.value)
|
|
47
|
+
return;
|
|
48
|
+
this.value = v;
|
|
49
|
+
this.evokeChange.emit(v);
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
const active = this.activeValue;
|
|
53
|
+
return (h("div", { key: '0eb147989be035ae85cc6778f7c5205ff450bbf0', class: `evoke-tabs evoke-tabs--${this.appearance}` }, h("div", { key: '2bed606eed52a8186fc6fdca50c179555a57de8c', class: "evoke-tabs__list", role: "tablist", "aria-label": this.label || undefined, onKeyDown: this.onKeyDown }, this.tabs.map((t) => {
|
|
54
|
+
const on = t.value === active;
|
|
55
|
+
return (h("button", { type: "button", role: "tab", id: `evoke-tab-${this.uid}-${t.value}`, class: `evoke-tabs__tab ${on ? 'evoke-tabs__tab--active' : ''}`.trim(), "aria-selected": on ? 'true' : 'false', "aria-controls": `evoke-panel-${this.uid}`, tabindex: on ? 0 : -1, disabled: t.disabled, onClick: () => this.select(t.value) }, t.label));
|
|
56
|
+
})), h("div", { key: 'b80df36c152b9b189e359a1d59106eb9372d1d62', class: "evoke-tabs__panel", role: "tabpanel", id: `evoke-panel-${this.uid}`, "aria-labelledby": active ? `evoke-tab-${this.uid}-${active}` : undefined, tabindex: 0 }, h("slot", { key: 'df28c424c9fd41a51f6068d04cf1f71605207d9d' }))));
|
|
57
|
+
}
|
|
58
|
+
static get is() { return "evoke-tabs"; }
|
|
59
|
+
static get originalStyleUrls() {
|
|
60
|
+
return {
|
|
61
|
+
"$": ["evoke-tabs.css"]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static get styleUrls() {
|
|
65
|
+
return {
|
|
66
|
+
"$": ["evoke-tabs.css"]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static get properties() {
|
|
70
|
+
return {
|
|
71
|
+
"options": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"mutable": false,
|
|
74
|
+
"complexType": {
|
|
75
|
+
"original": "EvokeOption[] | string",
|
|
76
|
+
"resolved": "EvokeOption[] | string",
|
|
77
|
+
"references": {
|
|
78
|
+
"EvokeOption": {
|
|
79
|
+
"location": "import",
|
|
80
|
+
"path": "../../utils/options",
|
|
81
|
+
"id": "src/utils/options.ts::EvokeOption",
|
|
82
|
+
"referenceLocation": "EvokeOption"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"required": false,
|
|
87
|
+
"optional": false,
|
|
88
|
+
"docs": {
|
|
89
|
+
"tags": [],
|
|
90
|
+
"text": "Tabs as an array of { label, value, disabled? } or a JSON string of the same"
|
|
91
|
+
},
|
|
92
|
+
"getter": false,
|
|
93
|
+
"setter": false,
|
|
94
|
+
"reflect": false,
|
|
95
|
+
"attribute": "options",
|
|
96
|
+
"defaultValue": "[]"
|
|
97
|
+
},
|
|
98
|
+
"value": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"mutable": true,
|
|
101
|
+
"complexType": {
|
|
102
|
+
"original": "string",
|
|
103
|
+
"resolved": "string",
|
|
104
|
+
"references": {}
|
|
105
|
+
},
|
|
106
|
+
"required": false,
|
|
107
|
+
"optional": false,
|
|
108
|
+
"docs": {
|
|
109
|
+
"tags": [],
|
|
110
|
+
"text": "Value of the active tab. Defaults to the first enabled tab."
|
|
111
|
+
},
|
|
112
|
+
"getter": false,
|
|
113
|
+
"setter": false,
|
|
114
|
+
"reflect": false,
|
|
115
|
+
"attribute": "value",
|
|
116
|
+
"defaultValue": "''"
|
|
117
|
+
},
|
|
118
|
+
"appearance": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"mutable": false,
|
|
121
|
+
"complexType": {
|
|
122
|
+
"original": "'underline' | 'pill'",
|
|
123
|
+
"resolved": "\"pill\" | \"underline\"",
|
|
124
|
+
"references": {}
|
|
125
|
+
},
|
|
126
|
+
"required": false,
|
|
127
|
+
"optional": false,
|
|
128
|
+
"docs": {
|
|
129
|
+
"tags": [],
|
|
130
|
+
"text": "Underline tabs or pill tabs"
|
|
131
|
+
},
|
|
132
|
+
"getter": false,
|
|
133
|
+
"setter": false,
|
|
134
|
+
"reflect": false,
|
|
135
|
+
"attribute": "appearance",
|
|
136
|
+
"defaultValue": "'underline'"
|
|
137
|
+
},
|
|
138
|
+
"label": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "string",
|
|
143
|
+
"resolved": "string",
|
|
144
|
+
"references": {}
|
|
145
|
+
},
|
|
146
|
+
"required": false,
|
|
147
|
+
"optional": false,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": "Accessible name for the tab list"
|
|
151
|
+
},
|
|
152
|
+
"getter": false,
|
|
153
|
+
"setter": false,
|
|
154
|
+
"reflect": false,
|
|
155
|
+
"attribute": "label",
|
|
156
|
+
"defaultValue": "''"
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
static get events() {
|
|
161
|
+
return [{
|
|
162
|
+
"method": "evokeChange",
|
|
163
|
+
"name": "evokeChange",
|
|
164
|
+
"bubbles": true,
|
|
165
|
+
"cancelable": true,
|
|
166
|
+
"composed": true,
|
|
167
|
+
"docs": {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": "Emits the value of the newly selected tab"
|
|
170
|
+
},
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string",
|
|
173
|
+
"resolved": "string",
|
|
174
|
+
"references": {}
|
|
175
|
+
}
|
|
176
|
+
}];
|
|
177
|
+
}
|
|
178
|
+
static get elementRef() { return "el"; }
|
|
179
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
evoke-textarea { display: block; }
|
|
2
|
+
evoke-textarea .evoke-field { display: flex; flex-direction: column; gap: 0.5rem; font-family: var(--evoke-font, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif); font-size: var(--evoke-font-size, 16px); color: var(--evoke-text, #1a1a1a); }
|
|
3
|
+
evoke-textarea .evoke-field__input {
|
|
4
|
+
box-sizing: border-box; width: 100%; padding: 14px 24px; border: 1px solid var(--evoke-border, #dedede); border-radius: var(--evoke-radius-field, 8px);
|
|
5
|
+
background: var(--evoke-surface, #ffffff); color: var(--evoke-text, #1a1a1a); font: inherit; line-height: 1.5; resize: vertical;
|
|
6
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
7
|
+
}
|
|
8
|
+
evoke-textarea .evoke-field__textarea--auto { resize: none; overflow: hidden; }
|
|
9
|
+
evoke-textarea .evoke-field__input::placeholder { color: var(--evoke-text-muted, #6b6b6b); }
|
|
10
|
+
evoke-textarea .evoke-field__input:hover:not(:disabled):not(:focus) { border-color: var(--evoke-text-muted, #6b6b6b); }
|
|
11
|
+
evoke-textarea .evoke-field__input:focus { outline: none; border-color: var(--evoke-secondary, #0b1560); box-shadow: var(--evoke-focus-ring, 0 0 0 3px rgba(11, 21, 96, 0.15)); }
|
|
12
|
+
evoke-textarea .evoke-field__input:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
13
|
+
evoke-textarea .evoke-field__input--error { border-color: var(--evoke-danger, #dc2626); }
|
|
14
|
+
evoke-textarea .evoke-field__footer { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.875rem; }
|
|
15
|
+
evoke-textarea .evoke-field__footer:empty { display: none; }
|
|
16
|
+
evoke-textarea .evoke-field__hint { color: var(--evoke-text-muted, #6b6b6b); }
|
|
17
|
+
evoke-textarea .evoke-field__error { color: var(--evoke-danger, #dc2626); }
|
|
18
|
+
evoke-textarea .evoke-field__counter { margin-left: auto; color: var(--evoke-text-muted, #6b6b6b); }
|
|
19
|
+
evoke-textarea .evoke-field__counter--full { color: var(--evoke-danger, #dc2626); }
|