@nickpaustian/tela 0.2.0 → 0.4.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.
@@ -31,9 +31,10 @@
31
31
 
32
32
  <p class="note error" $show="state.error">{{ state.error }}</p>
33
33
 
34
- <!-- The library itself, in a dialog. The same grid and inspector the
35
- standalone browser mounts: one implementation, two hosts. -->
36
- <div class="scrim" $show="state.open" @click="backdrop" @keydown.escape="close">
34
+ <!-- The library itself, in a dialog: the same frame as the Media page,
35
+ in its picking mode. Mounted only while open, so a page of image
36
+ fields is not a page of libraries. -->
37
+ <div class="scrim" $show="state.open" @click="backdrop" @keydown.escape="escape" $ref="scrim">
37
38
  <div class="dialog" role="dialog" aria-modal="true" $aria-labelledby="'media-title-' + props.path">
38
39
  <div class="dialog-head">
39
40
  <h2 class="dialog-title" $id="'media-title-' + props.path">Choose an image</h2>
@@ -43,8 +44,7 @@
43
44
  </div>
44
45
 
45
46
  <div class="dialog-body px">
46
- <AssetGrid />
47
- <AssetInspector />
47
+ <LibraryFrame $if="state.open" $mode="'pick'" />
48
48
  </div>
49
49
 
50
50
  <div class="dialog-foot">
@@ -61,8 +61,8 @@
61
61
  </view>
62
62
 
63
63
  <logic lang="ts">
64
- import { reactive, onMounted, onUnmounted, defineProps, shared } from '@lightspeed-js/core'
65
- import { SELECTED } from '@pseudolux-ui/media-library'
64
+ import { reactive, onMounted, onUnmounted, defineProps, defineRefs, shared } from '@lightspeed-js/core'
65
+ import { SELECTED, CHOSEN, PEEK } from '@pseudolux-ui/media-library'
66
66
 
67
67
  /**
68
68
  * Choose a picture from the media library, without going to make an entry first.
@@ -101,16 +101,26 @@ readonly.subscribe(readReadonly)
101
101
 
102
102
  const cell = () => shared('entry:value:' + props.path)
103
103
 
104
- // What the grid and inspector are looking at. The same cell they talk to each
105
- // other through, so choosing here is just reading it.
104
+ const refs = defineRefs()
105
+
106
+ // The picture the library is looking at in its picking mode. Choosing here
107
+ // is just reading it.
108
+ const chosen = shared(CHOSEN)
109
+ // The picture open in the library's editor, and the one it is peeking at.
106
110
  const selected = shared(SELECTED)
111
+ const peek = shared(PEEK)
107
112
 
108
- selected.subscribe((asset) => {
113
+ chosen.subscribe((asset) => {
114
+ if (!state.open) return
109
115
  state.pickedId = asset ? asset.id : ''
110
116
  state.pickedLabel = asset ? (asset.filename || asset.id) : ''
111
117
  })
112
118
 
113
119
  function open() {
120
+ chosen.value = null
121
+ peek.value = null
122
+ state.pickedId = ''
123
+ state.pickedLabel = ''
114
124
  state.open = true
115
125
  state.error = ''
116
126
  }
@@ -118,6 +128,16 @@ function open() {
118
128
  function close() {
119
129
  state.open = false
120
130
  selected.value = null
131
+ chosen.value = null
132
+ peek.value = null
133
+ }
134
+
135
+ // Escape closes whatever is on top. The library's editor, quick look and
136
+ // upload screen open over this dialog and close themselves first.
137
+ function escape() {
138
+ const over = refs.scrim ? Array.from(refs.scrim.querySelectorAll('.dialog-body [aria-modal="true"]')) : []
139
+ if (over.some((one) => one.offsetParent !== null)) return
140
+ close()
121
141
  }
122
142
 
123
143
  // Only the backdrop itself, never a click that happened to bubble out of the
@@ -202,7 +222,10 @@ onMounted(() => {
202
222
  onUnmounted(() => {
203
223
  // The dialog is gone; nothing should still be "selected" for the next field
204
224
  // that mounts one.
205
- if (state.open) selected.value = null
225
+ if (state.open) {
226
+ selected.value = null
227
+ chosen.value = null
228
+ }
206
229
  })
207
230
  </logic>
208
231
 
@@ -267,8 +290,8 @@ onUnmounted(() => {
267
290
  .dialog {
268
291
  display: flex;
269
292
  flex-direction: column;
270
- width: min(72rem, 100%);
271
- max-height: 100%;
293
+ width: min(84rem, 100%);
294
+ height: 100%;
272
295
  border: 1px solid var(--border);
273
296
  border-radius: var(--r-l);
274
297
  background: var(--surface);
@@ -291,13 +314,14 @@ onUnmounted(() => {
291
314
  margin: 0;
292
315
  }
293
316
 
294
- /* The grid takes the room; the inspector is a column beside it. */
317
+ /* The library brings its own bar and gutters, and scrolls inside the dialog. */
295
318
  .dialog-body {
296
- display: grid;
297
- grid-template-columns: minmax(0, 1fr) 20rem;
298
- gap: var(--sp-4);
299
- padding: var(--sp-4) var(--sp-5);
319
+ display: block;
320
+ flex: 1;
321
+ min-height: 0;
322
+ padding: 0;
300
323
  overflow: auto;
324
+ --px-frame-gutter: var(--sp-5);
301
325
  }
302
326
 
303
327
  .dialog-foot {
@@ -318,9 +342,4 @@ onUnmounted(() => {
318
342
  font-weight: var(--fw-medium);
319
343
  }
320
344
 
321
- @media (max-width: 56rem) {
322
- .dialog-body {
323
- grid-template-columns: minmax(0, 1fr);
324
- }
325
- }
326
345
  </style>
@@ -0,0 +1,188 @@
1
+ <view>
2
+ <span class="picture" $class="state.compact ? 'is-compact' : ''" $if="state.shown">
3
+ <!-- Pressing the small picture shows it large. A popover, so Escape and a
4
+ press outside put it away and nothing has to be written for either. -->
5
+ <button class="picture-open" type="button" $popovertarget="state.id" $aria-label="'See ' + state.title + ' larger'" $if="state.src">
6
+ <img class="picture-thumb" $src="state.src" alt="" loading="lazy" />
7
+ </button>
8
+ <span class="picture-words" $if="!state.compact">
9
+ <span class="picture-title">{{ state.title }}</span>
10
+ <span class="picture-note" $class="state.described ? '' : 'is-missing'">{{ state.note }}</span>
11
+ <span class="picture-note" $if="state.credit">{{ state.credit }}</span>
12
+ </span>
13
+ <span class="picture-large" popover $id="state.id" $if="state.src">
14
+ <img $src="state.src" $alt="state.alt" />
15
+ <span class="picture-caption">{{ state.title }}<span $if="state.size"> · {{ state.size }}</span></span>
16
+ </span>
17
+ </span>
18
+ </view>
19
+
20
+ <logic lang="ts">
21
+ import { defineProps, reactive, onMounted, onUpdate } from '@lightspeed-js/core'
22
+
23
+ /**
24
+ * A chosen picture, small, with what is said about it.
25
+ *
26
+ * A summary component for a picture field as a group glances at it: the
27
+ * picture itself rather than its name, the words a screen reader will be
28
+ * given, and a larger look for whoever wants one. `value` is the field's
29
+ * block (the picture and the words written for this use of it) or a media
30
+ * entry's id on its own. `compact` draws the picture alone, for a row of several.
31
+ */
32
+ const props = defineProps({
33
+ value: { default: null },
34
+ options: { default: {} },
35
+ })
36
+
37
+ let made = 0
38
+ const state = reactive({
39
+ id: 'picture-' + Math.random().toString(36).slice(2, 8) + (++made).toString(36),
40
+ shown: false,
41
+ compact: false,
42
+ src: '',
43
+ title: '',
44
+ alt: '',
45
+ note: '',
46
+ described: true,
47
+ credit: '',
48
+ size: '',
49
+ mediaAlt: '',
50
+ mediaCredit: '',
51
+ })
52
+
53
+ const held = () => (props.value && typeof props.value === 'object' ? props.value : { picture: props.value })
54
+ const pictureOf = () => held()[(props.options && props.options.picture) || 'picture'] || ''
55
+
56
+ let showing = ''
57
+
58
+ async function load() {
59
+ const id = pictureOf()
60
+ state.compact = Boolean(props.options && props.options.compact)
61
+ const words = held()
62
+ if (!id || typeof id !== 'string') {
63
+ showing = ''
64
+ state.shown = false
65
+ return
66
+ }
67
+
68
+ let media = {}
69
+ if (id !== showing) {
70
+ showing = id
71
+ const response = await fetch('/api/entries/media/' + encodeURIComponent(id), { credentials: 'same-origin' })
72
+ if (id !== showing) return
73
+ const found = response.ok ? await response.json() : null
74
+ media = (found && found.entry && found.entry.data) || {}
75
+ state.src = media.file ? '/api/media/file/' + String(media.file).split('/').map(encodeURIComponent).join('/') : ''
76
+ state.title = media.title || media.file || 'A picture'
77
+ state.size = media.width && media.height ? media.width + ' × ' + media.height : ''
78
+ state.mediaAlt = media.altText || media.alt || ''
79
+ state.mediaCredit = media.credit || ''
80
+ }
81
+
82
+ state.alt = words.alt || state.mediaAlt || ''
83
+ state.described = Boolean(state.alt)
84
+ state.note = state.alt ? 'Alt text: ' + state.alt : 'No alt text'
85
+ const credit = words.credit || state.mediaCredit || ''
86
+ state.credit = credit ? 'Credit: ' + credit : ''
87
+ state.shown = true
88
+ }
89
+
90
+ onMounted(load)
91
+ onUpdate(load)
92
+ </logic>
93
+
94
+ <style>
95
+ .picture {
96
+ display: inline-flex;
97
+ align-items: center;
98
+ gap: var(--sp-3);
99
+ min-width: 0;
100
+ }
101
+
102
+ .picture-open {
103
+ flex: none;
104
+ padding: 0;
105
+ border: 1px solid var(--border);
106
+ border-radius: var(--r-m);
107
+ background: var(--surface-2);
108
+ overflow: hidden;
109
+ cursor: zoom-in;
110
+ }
111
+
112
+ .picture-open:hover {
113
+ border-color: var(--accent);
114
+ }
115
+
116
+ .picture-open:focus-visible {
117
+ outline: 3px solid var(--focus);
118
+ outline-offset: 2px;
119
+ }
120
+
121
+ .picture-thumb {
122
+ display: block;
123
+ width: 96px;
124
+ height: 64px;
125
+ object-fit: cover;
126
+ }
127
+
128
+ .picture.is-compact .picture-thumb {
129
+ width: 72px;
130
+ height: 48px;
131
+ }
132
+
133
+ .picture-words {
134
+ display: flex;
135
+ flex-direction: column;
136
+ gap: 2px;
137
+ min-width: 0;
138
+ font-size: var(--fs-s);
139
+ }
140
+
141
+ .picture-title {
142
+ color: var(--text);
143
+ overflow-wrap: anywhere;
144
+ }
145
+
146
+ .picture-note {
147
+ color: var(--text-3);
148
+ overflow-wrap: anywhere;
149
+ }
150
+
151
+ .picture-note.is-missing {
152
+ color: var(--warn);
153
+ }
154
+
155
+ .picture-large {
156
+ max-width: min(90vw, 960px);
157
+ max-height: 90vh;
158
+ padding: var(--sp-3);
159
+ border: 1px solid var(--border);
160
+ border-radius: var(--r-l);
161
+ background: var(--surface);
162
+ color: var(--text);
163
+ box-shadow: var(--shadow-2);
164
+ }
165
+
166
+ .picture-large:popover-open {
167
+ display: flex;
168
+ flex-direction: column;
169
+ gap: var(--sp-2);
170
+ }
171
+
172
+ .picture-large::backdrop {
173
+ background: var(--scrim);
174
+ }
175
+
176
+ .picture-large img {
177
+ display: block;
178
+ max-width: 100%;
179
+ max-height: calc(90vh - 80px);
180
+ object-fit: contain;
181
+ border-radius: var(--r-m);
182
+ }
183
+
184
+ .picture-caption {
185
+ color: var(--text-2);
186
+ font-size: var(--fs-s);
187
+ }
188
+ </style>
@@ -0,0 +1,69 @@
1
+ <view>
2
+ <span class="pictures">
3
+ <span class="pictures-row">
4
+ <Dynamic $for="one in state.shown" $key="one.key" $is="'picturesummary'" $value="one.value" $options="state.each" />
5
+ <span class="pictures-more" $if="state.more">{{ state.more }}</span>
6
+ </span>
7
+ <span class="pictures-caption" $if="state.caption">{{ state.caption }}</span>
8
+ </span>
9
+ </view>
10
+
11
+ <logic lang="ts">
12
+ import { defineProps, reactive, onUpdate } from '@lightspeed-js/core'
13
+
14
+ /**
15
+ * The pictures a list holds, small and in a row, each one opening large.
16
+ *
17
+ * A summary component for a list whose rows each carry a picture - tiles,
18
+ * slides, logos - as a group or a shut section glances at it. `value` is the
19
+ * rows' picture blocks; `caption` is what the rows say in words.
20
+ */
21
+ const props = defineProps({
22
+ value: { default: [] },
23
+ options: { default: {} },
24
+ })
25
+
26
+ const MOST = 6
27
+
28
+ function seen() {
29
+ const all = Array.isArray(props.value) ? props.value : []
30
+ const options = props.options || {}
31
+ return {
32
+ shown: all.slice(0, MOST).map((value, index) => ({ key: String(index), value })),
33
+ more: all.length > MOST ? '+' + (all.length - MOST) + ' more' : '',
34
+ caption: options.caption || '',
35
+ each: { picture: options.picture || 'picture', compact: true },
36
+ }
37
+ }
38
+
39
+ const state = reactive(seen())
40
+
41
+ onUpdate(() => Object.assign(state, seen()))
42
+ </logic>
43
+
44
+ <style>
45
+ .pictures {
46
+ display: flex;
47
+ flex-direction: column;
48
+ gap: var(--sp-2);
49
+ min-width: 0;
50
+ }
51
+
52
+ .pictures-row {
53
+ display: flex;
54
+ flex-wrap: wrap;
55
+ align-items: center;
56
+ gap: var(--sp-2);
57
+ }
58
+
59
+ .pictures-more,
60
+ .pictures-caption {
61
+ color: var(--text-3);
62
+ font-size: var(--fs-s);
63
+ }
64
+
65
+ .pictures-caption {
66
+ color: var(--text);
67
+ overflow-wrap: anywhere;
68
+ }
69
+ </style>
@@ -116,14 +116,21 @@
116
116
  @click="openOptions(row, $event)"
117
117
  ><span class="icon icon-more" aria-hidden="true"></span></button>
118
118
 
119
- <button
120
- class="btn btn-ghost btn-sm btn-icon sec-toggle"
121
- type="button"
122
- $show="!state.arranging"
123
- $aria-expanded="row.open ? 'true' : 'false'"
124
- $aria-label="row.toggleLabel"
125
- @click="toggle(row, $event)"
126
- ><span class="icon" $class="row.open ? 'icon-chevron-up' : 'icon-chevron-down'" aria-hidden="true"></span></button>
119
+ <!-- How much of a row to show, as a group of fields has it: one
120
+ line, a glance, or the fields. Last in the head, where the eye goes to
121
+ open something. -->
122
+ <div class="sec-density" role="group" $show="!state.arranging && !row.choosing" $aria-label="'How much of ' + row.blockLabel + ' to show'">
123
+ <button type="button" $aria-pressed="row.mode === 'minimal' ? 'true' : 'false'" aria-label="Minimal" title="Minimal: one line" @click="setMode(row, 'minimal', $event)">
124
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M4 12h16"></path></svg>
125
+ </button>
126
+ <button type="button" $aria-pressed="row.mode === 'summary' ? 'true' : 'false'" aria-label="Summary" title="Summary: what's in it at a glance" @click="setMode(row, 'summary', $event)">
127
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M4 8h16M4 13h10M4 18h12"></path></svg>
128
+ </button>
129
+ <button type="button" $aria-pressed="row.mode === 'full' ? 'true' : 'false'" aria-label="Full" title="Full: edit everything" @click="setMode(row, 'full', $event)">
130
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="4" width="16" height="16" rx="2"></rect><path d="M4 10h16"></path></svg>
131
+ </button>
132
+ </div>
133
+
127
134
  </div>
128
135
 
129
136
  <div class="menu sec-menu" popover role="menu" $id="row.menuId" $aria-label="row.optionsLabel">
@@ -149,6 +156,17 @@
149
156
  </button>
150
157
  </div>
151
158
 
159
+ <!-- Shut, a row glances at what it holds: the same rows a group's
160
+ summary shows. A row inside a section has the same three states as
161
+ the section it is in. -->
162
+ <div class="sec-glance" $if="row.glance.length > 0 && !state.arranging">
163
+ <div class="sec-glance-row" $for="part in row.glance" $key="part.key">
164
+ <span class="sec-glance-label">{{ part.label }}</span>
165
+ <span class="sec-glance-text" $if="part.text">{{ part.text }}</span>
166
+ <Dynamic $if="part.component" $is="part.component" $value="part.value" $options="part.options" />
167
+ </div>
168
+ </div>
169
+
152
170
  <div class="sec-body" $show="row.open && !state.arranging">
153
171
  <!-- Not chosen yet. The row exists, holds its place in the order, and
154
172
  says what it could become. -->
@@ -297,6 +315,7 @@ import { watchShown } from '../components/visibility.ts'
297
315
  import { LANDING_MS, createReorder } from '../components/reorder.ts'
298
316
  import { offeredBlocks } from '../content/placement.ts'
299
317
  import { keyLabel } from '../keys.ts'
318
+ import { REST, THIS_BROWSER, defaultGlance, memoryKey, readMemory } from '../content/glance.ts'
300
319
 
301
320
  /**
302
321
  * A list of field groups.
@@ -321,6 +340,12 @@ const props = defineProps({
321
340
  // which component renders each of a row's fields.
322
341
  const issues = shared('entry:issues', {})
323
342
  const ui = shared('entry:ui', {})
343
+
344
+ /** How closed sections rest on this page: the page's choice, what was last chosen for the collection, or summaries. */
345
+ const pageRest = shared('groups:rest', '')
346
+ const collectionName = ((shared('route').value || {}).params || {}).collection || ''
347
+ const closedShow = () =>
348
+ pageRest.value || readMemory(typeof localStorage === 'undefined' ? undefined : localStorage, memoryKey(THIS_BROWSER, collectionName)).rest || REST
324
349
  const readOnly = shared('entry:readonly', false)
325
350
 
326
351
  const cell = (key) => shared(key)
@@ -424,6 +449,9 @@ watchShown(props.field, props.path, shared, (shown) => {
424
449
  * open itself without overriding a reader who deliberately closed it.
425
450
  */
426
451
  const openState = {}
452
+ /** How each section rests while shut, where somebody chose for that one section. */
453
+ let restState = {}
454
+ const restOf = (key) => restState[key] || closedShow()
427
455
 
428
456
  /** The row being dragged, by key. Null when nothing is. */
429
457
  let dragKey = null
@@ -554,7 +582,6 @@ function rebuild() {
554
582
  ' goes here, ' + (index + 1) + ' of ' + rows.length,
555
583
  gripLabel: 'Move ' + called + (shapes.length > 1 ? ', ' + blockLabel : ''),
556
584
  optionsLabel: called.charAt(0).toUpperCase() + called.slice(1) + ' options',
557
- toggleLabel: (open ? 'Collapse ' : 'Expand ') + called,
558
585
  problems: wrong + ' to fix',
559
586
  shape,
560
587
  fields: shape.map((field) => ({
@@ -575,6 +602,8 @@ function rebuild() {
575
602
  invalid,
576
603
  open,
577
604
  summary: label || automatic,
605
+ mode: open ? 'full' : restOf(key),
606
+ glance: !open && !choosing && restOf(key) === 'summary' ? glanceOf(shape, rowPath, automatic) : [],
578
607
  automatic,
579
608
  label,
580
609
  renameLabel: 'Name for ' + singular + ' ' + (index + 1) + ', only shown to editors',
@@ -585,6 +614,16 @@ function rebuild() {
585
614
  state.anyOpen = state.rows.some((row) => row.open)
586
615
  }
587
616
 
617
+ /**
618
+ * What a shut section shows of itself, when closed sections show summaries.
619
+ * The row its title already says is left out, so a section that holds one
620
+ * line of words does not say it twice.
621
+ */
622
+ function glanceOf(shape, rowPath, title) {
623
+ const values = gatherAt(shape, rowPath + '.', (cell) => shared(cell).value)
624
+ return defaultGlance(shape, values, { registered: window.telaComponents }).filter((row) => !row.text || row.text.trim() !== String(title || '').trim())
625
+ }
626
+
588
627
  /**
589
628
  * What to call a row when it is closed.
590
629
  *
@@ -621,6 +660,14 @@ function toggle(row, event) {
621
660
  rebuild()
622
661
  }
623
662
 
663
+ /** One section set to one line, a glance or its fields. */
664
+ function setMode(row, mode, event) {
665
+ stop(event)
666
+ openState[row.key] = mode === 'full'
667
+ if (mode !== 'full') restState[row.key] = mode
668
+ rebuild()
669
+ }
670
+
624
671
  /** The head opens and closes its section, except where a control in it was meant. */
625
672
  function headClick(row, event) {
626
673
  if (state.arranging) return
@@ -1179,6 +1226,11 @@ onUpdate(rebuild)
1179
1226
  issues.subscribe(rebuild)
1180
1227
  ui.subscribe(rebuild)
1181
1228
  readOnly.subscribe(rebuild)
1229
+ // Said for the whole page, so it is said for every section: what one was set to on its own gives way.
1230
+ pageRest.subscribe(() => {
1231
+ restState = {}
1232
+ rebuild()
1233
+ })
1182
1234
  </logic>
1183
1235
 
1184
1236
  <style>
@@ -1283,7 +1335,7 @@ readOnly.subscribe(rebuild)
1283
1335
  }
1284
1336
 
1285
1337
  .sorting .sec:not(.dragging) .sec-options,
1286
- .sorting .sec:not(.dragging) .sec-toggle {
1338
+ .sorting .sec:not(.dragging) .sec-density {
1287
1339
  visibility: hidden;
1288
1340
  }
1289
1341
 
@@ -1642,4 +1694,60 @@ readOnly.subscribe(rebuild)
1642
1694
  .mini[data-kind="spacer"] i { width: 100%; height: 6px; background: var(--border); opacity: 1; }
1643
1695
  .mini[data-kind="spacer"] i:nth-child(2) { flex: 1; margin: 6px 0; border: 1px dashed var(--border-strong); border-radius: 4px; background: none; }
1644
1696
  .mini[data-kind="spacer"] i:nth-child(n + 4) { display: none; }
1697
+
1698
+ .sec-glance {
1699
+ display: flex;
1700
+ flex-direction: column;
1701
+ gap: var(--sp-3);
1702
+ padding: 0 var(--sp-4) var(--sp-4);
1703
+ }
1704
+
1705
+ .sec-glance-row {
1706
+ display: grid;
1707
+ grid-template-columns: minmax(100px, 180px) minmax(0, 1fr);
1708
+ align-items: baseline;
1709
+ gap: var(--sp-2) var(--sp-4);
1710
+ font-size: var(--fs-s);
1711
+ }
1712
+
1713
+ .sec-glance-label {
1714
+ color: var(--text-3);
1715
+ }
1716
+
1717
+ .sec-glance-text {
1718
+ color: var(--text);
1719
+ overflow-wrap: anywhere;
1720
+ }
1721
+
1722
+ .sec-density {
1723
+ display: inline-flex;
1724
+ flex: none;
1725
+ padding: 3px;
1726
+ border: 1px solid var(--border);
1727
+ border-radius: var(--r-m);
1728
+ background: var(--surface-2);
1729
+ }
1730
+
1731
+ .sec-density button {
1732
+ display: grid;
1733
+ place-items: center;
1734
+ width: 32px;
1735
+ height: 28px;
1736
+ border: 0;
1737
+ border-radius: var(--r-s);
1738
+ background: transparent;
1739
+ color: var(--text-3);
1740
+ cursor: pointer;
1741
+ }
1742
+
1743
+ .sec-density button[aria-pressed="true"] {
1744
+ background: var(--surface);
1745
+ color: var(--text);
1746
+ box-shadow: var(--shadow-1);
1747
+ }
1748
+
1749
+ .sec-density button:focus-visible {
1750
+ outline: 3px solid var(--focus);
1751
+ outline-offset: 2px;
1752
+ }
1645
1753
  </style>
@@ -293,6 +293,15 @@ export interface Field {
293
293
  * what was saved, so it keeps up as somebody types.
294
294
  */
295
295
  peek?: SummaryPart[]
296
+ /**
297
+ * What a group shows as a summary: a read-only glance at what is inside,
298
+ * one part to a row. The same parts as `peek` and a collection's summary,
299
+ * so a part is words or a summary component and never markup. Left out, the
300
+ * group glances at each field that holds something, by its type.
301
+ */
302
+ glance?: SummaryPart[]
303
+ /** How a group rests while it is not being edited: its glance, or one line. `summary` unless said. */
304
+ rest?: "summary" | "minimal"
296
305
  /** For `reference`: several rather than one. */
297
306
  many?: boolean
298
307
  /**
@@ -673,6 +682,14 @@ export interface TelaConfig {
673
682
  * logged and never fails the publish.
674
683
  */
675
684
  afterPublish?: PublishHook[]
685
+ /**
686
+ * Lists gathered from everything published, each written to
687
+ * `content/data/<name>.json` as `{ values: [...] }` and kept up to date by
688
+ * every publish and takedown: the videos on the site, for a server that
689
+ * will only stream those. Run `tela republish` after adding one or changing
690
+ * what it gathers, since a list only learns of an entry when it is published.
691
+ */
692
+ gathered?: GatheredList[]
676
693
  /**
677
694
  * The site's name, as search results and link cards give it. Collections
678
695
  * with `seo` add it to titles in search results unless they say otherwise.
@@ -738,6 +755,15 @@ export interface TelaConfig {
738
755
  components?: string[]
739
756
  }
740
757
 
758
+ export interface GatheredList {
759
+ /** The file's name, and the `cms:data:<name>` cell. Not a collection's name. */
760
+ name: string
761
+ /** What one published entry adds to the list. Text or numbers; anything else is left out. */
762
+ from: (data: Record<string, unknown>, entry: { collection: string }) => Iterable<unknown> | null | undefined
763
+ /** Only entries of these collections. All of them when left out. */
764
+ collections?: string[]
765
+ }
766
+
741
767
  export interface PublishHook {
742
768
  /** POSTed `{ event, commit, files, cells, collections }`. */
743
769
  url: string
@@ -1114,7 +1140,18 @@ export function defineConfig(config: TelaConfig): TelaConfig {
1114
1140
  else if (collection.version !== undefined) throw new Error(`${collection.name}: only a data source has a \`version\`.`)
1115
1141
  }
1116
1142
 
1117
- for (const hook of config.afterPublish ?? []) checkHook(hook, known)
1143
+ const gatheredNames = new Set<string>()
1144
+ for (const list of config.gathered ?? []) {
1145
+ if (!/^[a-z][a-z0-9-]*$/.test(list.name)) throw new Error(`gathered: "${list.name}" must start lowercase and use letters, digits and hyphens.`)
1146
+ if (known.has(list.name)) throw new Error(`gathered: "${list.name}" is a collection's name, and would be written over its data.`)
1147
+ if (gatheredNames.has(list.name)) throw new Error(`gathered: "${list.name}" is declared twice.`)
1148
+ const unknown = (list.collections ?? []).filter((name) => !known.has(name))
1149
+ if (unknown.length) throw new Error(`gathered: ${list.name} names ${unknown.join(", ")}, which no collection is called.`)
1150
+ gatheredNames.add(list.name)
1151
+ }
1152
+
1153
+ // A hook may wait on a gathered list as it would a data source.
1154
+ for (const hook of config.afterPublish ?? []) checkHook(hook, new Set([...known, ...gatheredNames]))
1118
1155
 
1119
1156
  const declared = declaredCollections.find((c) => c.name === "users")
1120
1157
 
@@ -1202,6 +1239,7 @@ export function defineConfig(config: TelaConfig): TelaConfig {
1202
1239
  ...(config.siteAliases?.length ? { siteAliases: config.siteAliases } : {}),
1203
1240
  ...(config.dataAddress ? { dataAddress: config.dataAddress } : {}),
1204
1241
  ...(config.afterPublish?.length ? { afterPublish: config.afterPublish } : {}),
1242
+ ...(config.gathered?.length ? { gathered: config.gathered } : {}),
1205
1243
  ...(config.siteName ? { siteName: config.siteName } : {}),
1206
1244
  ...(config.userNames ? { userNames: true } : {}),
1207
1245
  }