@openvoxproject/voxblocks 0.14.0 → 0.15.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.
@@ -1,263 +0,0 @@
1
- import { LitElement, html, css, nothing } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
-
4
- export type RecordListItemSize = 'md' | 'sm';
5
-
6
- /**
7
- * A list of linked records — search results, an admin index, anything
8
- * that's a stack of "go to this thing" rows. A grid (heading, meta, end,
9
- * plus a trailing filler column) is always defined here; regular
10
- * `size="md"` items ignore the first three tracks and just render their own
11
- * full-width flex row, while `size="sm"` items opt into them via `subgrid`
12
- * so their columns line up into a real table across every row, sized to
13
- * each column's widest cell like a native `<table>`. The filler column
14
- * absorbs whatever width the three content columns don't use, so every
15
- * item — table row or not — still spans the list's full width instead of
16
- * shrinking to fit its content.
17
- *
18
- * @slot - `<vox-record-list-item>` elements.
19
- */
20
- @customElement('vox-record-list')
21
- export class VoxRecordList extends LitElement {
22
- static styles = css`
23
- :host {
24
- display: grid;
25
- grid-template-columns: repeat(3, max-content) 1fr;
26
- column-gap: var(--vox-space-4);
27
- }
28
- `;
29
-
30
- render() {
31
- return html`<slot></slot>`;
32
- }
33
- }
34
-
35
- /**
36
- * One row in a `<vox-record-list>`: a heading link plus optional metadata
37
- * — pass `<vox-datum>` elements (or anything else) into the default slot.
38
- * Becomes fully navigable (heading and trailing arrow both link to `href`)
39
- * when `href` is set; otherwise renders as a static row.
40
- *
41
- * At `size="sm"`, the arrow drops out and heading/meta/`end` become real
42
- * table columns (via CSS `subgrid`, aligned against every other
43
- * `size="sm"` row in the same `<vox-record-list>`) — suited to a dense
44
- * activity/run log rather than an indexed record. `heading` and the meta
45
- * column each link to `href` individually, since a single grid row can't
46
- * itself be one native link the way a block row can.
47
- *
48
- * @slot - Metadata, e.g. `<vox-datum>` elements.
49
- * @slot end - Trailing content after the meta, e.g. a `<vox-badge>` status.
50
- */
51
- @customElement('vox-record-list-item')
52
- export class VoxRecordListItem extends LitElement {
53
- @property() heading = '';
54
- @property() href?: string;
55
- @property({ reflect: true }) size: RecordListItemSize = 'md';
56
-
57
- static styles = css`
58
- :host {
59
- display: block;
60
- grid-column: 1 / -1;
61
- font-family: var(--vox-font-family-base);
62
- }
63
-
64
- .row {
65
- display: flex;
66
- align-items: center;
67
- justify-content: space-between;
68
- gap: var(--vox-space-4);
69
- padding: var(--vox-space-4) 0;
70
- border-bottom: 1px solid var(--vox-color-divider);
71
- }
72
-
73
- :host(:last-child) .row {
74
- border-bottom: none;
75
- }
76
-
77
- .main {
78
- display: flex;
79
- flex-direction: column;
80
- gap: var(--vox-space-1);
81
- min-width: 0;
82
- }
83
-
84
- .heading {
85
- font-size: 16px;
86
- font-weight: 600;
87
- line-height: 1.4;
88
- }
89
-
90
- a.heading {
91
- color: var(--vox-color-brand-1);
92
- text-decoration: none;
93
- }
94
-
95
- a.heading:hover,
96
- a.heading:focus-visible {
97
- text-decoration: underline;
98
- }
99
-
100
- a.heading:focus-visible {
101
- outline: 2px solid var(--vox-color-brand-1);
102
- outline-offset: 2px;
103
- }
104
-
105
- span.heading {
106
- color: var(--vox-color-text-1);
107
- }
108
-
109
- .meta {
110
- display: flex;
111
- flex-wrap: wrap;
112
- align-items: center;
113
- gap: var(--vox-space-4);
114
- }
115
-
116
- .meta:not(.has-meta) {
117
- display: none;
118
- }
119
-
120
- .arrow {
121
- display: flex;
122
- flex: none;
123
- align-items: center;
124
- justify-content: center;
125
- width: 36px;
126
- height: 36px;
127
- border-radius: var(--vox-radius-full);
128
- background-color: var(--vox-color-bg-soft);
129
- color: var(--vox-color-brand-1);
130
- text-decoration: none;
131
- transition: background-color var(--vox-transition-fast);
132
- }
133
-
134
- .arrow:hover {
135
- background-color: var(--vox-color-brand-soft);
136
- }
137
-
138
- .arrow:focus-visible {
139
- outline: 2px solid var(--vox-color-brand-1);
140
- outline-offset: 2px;
141
- }
142
-
143
- .arrow svg {
144
- width: 16px;
145
- height: 16px;
146
- }
147
-
148
- .end:not(.has-end) {
149
- display: none;
150
- }
151
-
152
- /* Small size: heading, meta, and end each become their own subgrid
153
- column, aligned against the same column in every other size="sm"
154
- row in the parent <vox-record-list> — the arrow drops out since
155
- there's no room for it at this density, and the whole "row" is
156
- really 3 separate grid cells rather than one box, so heading and
157
- the meta cell each link to href individually. */
158
- :host([size='sm']) {
159
- display: grid;
160
- grid-template-columns: subgrid;
161
- grid-column: 1 / -1;
162
- align-items: baseline;
163
- column-gap: var(--vox-space-4);
164
- padding: var(--vox-space-2) 0;
165
- border-bottom: 1px solid var(--vox-color-divider);
166
- font-size: 13px;
167
- }
168
-
169
- :host([size='sm']:last-child) {
170
- border-bottom: none;
171
- }
172
-
173
- :host([size='sm']) .meta {
174
- flex-wrap: nowrap;
175
- gap: var(--vox-space-2);
176
- }
177
-
178
- .cell {
179
- color: var(--vox-color-text-2);
180
- text-decoration: none;
181
- }
182
-
183
- a.cell:hover,
184
- a.cell:focus-visible {
185
- text-decoration: underline;
186
- }
187
-
188
- a.cell:focus-visible {
189
- outline: 2px solid var(--vox-color-brand-1);
190
- outline-offset: 2px;
191
- }
192
- `;
193
-
194
- private hasMeta = false;
195
- private hasEnd = false;
196
-
197
- private handleMetaSlotChange(event: Event) {
198
- const slot = event.target as HTMLSlotElement;
199
- this.hasMeta = slot.assignedNodes({ flatten: true }).length > 0;
200
- this.requestUpdate();
201
- }
202
-
203
- private handleEndSlotChange(event: Event) {
204
- const slot = event.target as HTMLSlotElement;
205
- this.hasEnd = slot.assignedNodes({ flatten: true }).length > 0;
206
- this.requestUpdate();
207
- }
208
-
209
- render() {
210
- if (this.size === 'sm') {
211
- const metaSlot = html`
212
- <span class="meta ${this.hasMeta ? 'has-meta' : ''}">
213
- <slot @slotchange=${this.handleMetaSlotChange}></slot>
214
- </span>
215
- `;
216
-
217
- return html`
218
- ${this.href
219
- ? html`<a class="cell" href=${this.href}>${this.heading}</a>`
220
- : html`<span class="cell">${this.heading}</span>`}
221
- ${this.hasMeta && this.href
222
- ? html`<a class="cell" href=${this.href}>${metaSlot}</a>`
223
- : html`<span class="cell">${metaSlot}</span>`}
224
- <span class="cell">
225
- <slot name="end" @slotchange=${this.handleEndSlotChange}></slot>
226
- </span>
227
- `;
228
- }
229
-
230
- return html`
231
- <div class="row">
232
- <div class="main">
233
- ${this.href
234
- ? html`<a class="heading" href=${this.href}>${this.heading}</a>`
235
- : html`<span class="heading">${this.heading}</span>`}
236
- <div class="meta ${this.hasMeta ? 'has-meta' : ''}">
237
- <slot @slotchange=${this.handleMetaSlotChange}></slot>
238
- </div>
239
- </div>
240
- <span class="end ${this.hasEnd ? 'has-end' : ''}">
241
- <slot name="end" @slotchange=${this.handleEndSlotChange}></slot>
242
- </span>
243
- ${this.href
244
- ? html`
245
- <a class="arrow" href=${this.href} aria-label="View ${this.heading}">
246
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
247
- <path d="M5 12h14" />
248
- <path d="m13 6 6 6-6 6" />
249
- </svg>
250
- </a>
251
- `
252
- : nothing}
253
- </div>
254
- `;
255
- }
256
- }
257
-
258
- declare global {
259
- interface HTMLElementTagNameMap {
260
- 'vox-record-list': VoxRecordList;
261
- 'vox-record-list-item': VoxRecordListItem;
262
- }
263
- }