@pseudolux-ui/media-library 0.0.0-stage → 0.1.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/package.json +22 -4
- package/src/components/AssetGrid.lsp +1777 -0
- package/src/components/AssetInspector.lsp +1622 -0
- package/src/components/BinDialog.lsp +208 -0
- package/src/components/CropEditor.lsp +616 -0
- package/src/components/ResponsiveImage.lsp +297 -0
- package/src/config.ts +137 -0
- package/src/index.ts +33 -0
- package/src/ladder.ts +82 -0
- package/src/port.ts +217 -0
- package/src/styles/px.css +177 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1777 @@
|
|
|
1
|
+
<view>
|
|
2
|
+
<div class="library" $ref="root">
|
|
3
|
+
<div class="px-toolbar">
|
|
4
|
+
<!-- Only when the store can actually do it. Drawn unconditionally, a
|
|
5
|
+
search box over a store without free text matches nothing, and an
|
|
6
|
+
empty grid reads as an empty library rather than as an unsupported
|
|
7
|
+
query. -->
|
|
8
|
+
<label class="px-search search" $show="state.canSearch">
|
|
9
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg>
|
|
10
|
+
<input
|
|
11
|
+
type="search"
|
|
12
|
+
placeholder="Search names, words and labels"
|
|
13
|
+
aria-label="Search pictures"
|
|
14
|
+
$model="state.text"
|
|
15
|
+
@input="onSearch"
|
|
16
|
+
/>
|
|
17
|
+
</label>
|
|
18
|
+
|
|
19
|
+
<!-- The shelves this view may browse. Offered only when the host has a
|
|
20
|
+
list: a selector with nothing in it would say the library has no
|
|
21
|
+
groups, when it is the host that has not said. -->
|
|
22
|
+
<select class="px-select group" $show="state.canBrowseGroups" $model="state.group" @change="filtersChanged" aria-label="Group">
|
|
23
|
+
<option value="">All groups I can see</option>
|
|
24
|
+
<option $for="one in state.groups" $key="one" $value="one" $text="one"></option>
|
|
25
|
+
</select>
|
|
26
|
+
|
|
27
|
+
<input class="file-input" type="file" $ref="fileInput" $accept="state.accept" multiple tabindex="-1" aria-hidden="true" @change="filesChosen" />
|
|
28
|
+
<button class="px-btn px-btn-primary" type="button" $show="state.canUpload && !state.deleted" @click="chooseFiles">
|
|
29
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M12 15V3M7 8l5-5 5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path></svg>
|
|
30
|
+
{{ state.uploadLabel }}
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div class="px-toolbar" $show="state.ready && !state.error">
|
|
35
|
+
<div class="px-row filters" role="group" aria-label="Filters">
|
|
36
|
+
<button class="px-chip chip" type="button" $show="!state.deleted" $aria-pressed="state.missingAlt" @click="toggleMissingAlt">Missing alt text</button>
|
|
37
|
+
<button class="px-chip chip" type="button" $aria-pressed="state.shape === 'landscape'" @click="toggleShape('landscape')">Landscape</button>
|
|
38
|
+
<button class="px-chip chip" type="button" $aria-pressed="state.shape === 'portrait'" @click="toggleShape('portrait')">Portrait</button>
|
|
39
|
+
<button class="px-chip chip" type="button" $aria-pressed="state.thisMonth" @click="toggleThisMonth">Added this month</button>
|
|
40
|
+
<!-- The bin as a filter, where the host has no Bin page of its own.
|
|
41
|
+
Only offered to a side that may restore, because looking at what
|
|
42
|
+
was deleted is only useful to somebody who can bring it back. -->
|
|
43
|
+
<button class="px-chip chip" type="button" $show="state.canRemove && !state.binMode && props.binChip !== false && props.binChip !== 'false'" $aria-pressed="state.deleted" @click="toggleDeleted">In the bin</button>
|
|
44
|
+
<span class="px-chip chip is-on" $show="state.onlyIds.length">
|
|
45
|
+
{{ state.onlyLabel }}
|
|
46
|
+
<button type="button" aria-label="Show every picture" @click="clearOnly"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"></path></svg></button>
|
|
47
|
+
</span>
|
|
48
|
+
<select class="px-select compact" $show="state.canFilterFormat" $model="state.format" @change="filtersChanged" aria-label="Format">
|
|
49
|
+
<option value="">Any format</option>
|
|
50
|
+
<option $for="one in state.formats" $key="one" $value="one" $text="one"></option>
|
|
51
|
+
</select>
|
|
52
|
+
</div>
|
|
53
|
+
<span class="px-subtle count" aria-live="polite" $show="state.ready && !state.error && !state.deleted">{{ state.countLabel }}</span>
|
|
54
|
+
<div class="px-seg" role="group" aria-label="Layout">
|
|
55
|
+
<button type="button" $aria-pressed="state.layout === 'grid'" @click="setLayout('grid')">
|
|
56
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1"></rect><rect x="14" y="3" width="7" height="7" rx="1"></rect><rect x="3" y="14" width="7" height="7" rx="1"></rect><rect x="14" y="14" width="7" height="7" rx="1"></rect></svg>
|
|
57
|
+
Grid
|
|
58
|
+
</button>
|
|
59
|
+
<button type="button" $aria-pressed="state.layout === 'list'" @click="setLayout('list')">
|
|
60
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"></path></svg>
|
|
61
|
+
List
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!-- Where files go, asked before any is sent when there is more than
|
|
67
|
+
one group to choose from. -->
|
|
68
|
+
<section class="frame queue" $show="state.held.length" aria-label="Choose where to upload">
|
|
69
|
+
<div class="queue-head">
|
|
70
|
+
<b class="queue-title">{{ state.heldTitle }}</b>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="hold">
|
|
73
|
+
<label class="hold-into">
|
|
74
|
+
<span>Into</span>
|
|
75
|
+
<select class="px-select compact" $model="state.heldGroup" aria-label="Group to upload to">
|
|
76
|
+
<option $for="one in state.writeGroups" $key="one" $value="one" $text="one"></option>
|
|
77
|
+
</select>
|
|
78
|
+
</label>
|
|
79
|
+
<span class="px-subtle hold-names">{{ state.heldNames }}</span>
|
|
80
|
+
</div>
|
|
81
|
+
<div class="queue-foot">
|
|
82
|
+
<span class="px-subtle">Everyone who can see {{ state.heldGroup }} will be able to use them.</span>
|
|
83
|
+
<span class="px-row">
|
|
84
|
+
<button class="px-btn px-btn-ghost" type="button" @click="cancelHeld">Cancel</button>
|
|
85
|
+
<button class="px-btn px-btn-primary" type="button" @click="sendHeld">{{ state.heldAction }}</button>
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
88
|
+
</section>
|
|
89
|
+
|
|
90
|
+
<!-- Uploads. One row per file; a likely duplicate is a question with both
|
|
91
|
+
pictures side by side, and the rest carry on while it waits. -->
|
|
92
|
+
<section class="frame queue" $show="state.queue.length" aria-label="Upload queue">
|
|
93
|
+
<div class="queue-head">
|
|
94
|
+
<b class="queue-title">{{ state.queueTitle }}</b>
|
|
95
|
+
<span class="px-row counts" aria-live="polite">
|
|
96
|
+
<span class="px-badge px-badge-ok" $show="state.counts.added" $text="state.counts.addedLabel"></span>
|
|
97
|
+
<span class="px-badge px-badge-accent" $show="state.counts.active" $text="state.counts.activeLabel"></span>
|
|
98
|
+
<span class="px-badge px-badge-warn" $show="state.counts.questions" $text="state.counts.questionsLabel"></span>
|
|
99
|
+
<span class="px-badge px-badge-danger" $show="state.counts.failed" $text="state.counts.failedLabel"></span>
|
|
100
|
+
</span>
|
|
101
|
+
<button class="px-btn px-btn-ghost px-btn-sm" type="button" $show="state.finished" @click="closeQueue">Close</button>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div class="queue-item" $for="one in state.queue" $key="one.key">
|
|
105
|
+
<div class="question" $if="one.question" role="group" $aria-labelledby="'upload-q-' + one.key">
|
|
106
|
+
<div class="question-head">
|
|
107
|
+
<svg class="icon-warn" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9"></circle><path d="M9.5 9a2.5 2.5 0 1 1 3.5 2.3c-.7.3-1 .9-1 1.7M12 17h.01"></path></svg>
|
|
108
|
+
<span class="question-title" $id="'upload-q-' + one.key"><b>{{ one.name }}</b> <span class="px-muted">{{ one.questionText }}</span></span>
|
|
109
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" $show="!one.exact" $aria-expanded="one.expanded" @click="toggleCompare(one)">{{ one.expanded ? 'Hide' : 'Compare' }}</button>
|
|
110
|
+
</div>
|
|
111
|
+
<div class="cmp" $show="one.expanded">
|
|
112
|
+
<div>
|
|
113
|
+
<span class="px-eyebrow">You're uploading</span>
|
|
114
|
+
<span class="cmp-pic"><img $src="one.preview" alt="" /></span>
|
|
115
|
+
<span class="cmp-note"><b>{{ one.name }}</b> · {{ one.sizeLabel }}</span>
|
|
116
|
+
</div>
|
|
117
|
+
<div>
|
|
118
|
+
<span class="px-eyebrow">Already in the library</span>
|
|
119
|
+
<span class="cmp-pic"><img $src="one.matchThumb" alt="" /></span>
|
|
120
|
+
<span class="cmp-note"><b>{{ one.matchName }}</b>{{ one.matchMeta }}</span>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="px-row" $show="one.expanded">
|
|
124
|
+
<button class="px-btn px-btn-primary px-btn-sm" type="button" @click="skipUpload(one)">Skip, keep the existing one</button>
|
|
125
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" @click="openExisting(one)">Open existing</button>
|
|
126
|
+
<button class="px-btn px-btn-ghost px-btn-sm" type="button" $show="state.canConfirm" @click="uploadAnyway(one)">Upload anyway</button>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="px-queue-row" $else-if="one.active">
|
|
131
|
+
<span class="q-thumb"><img $src="one.preview" alt="" /></span>
|
|
132
|
+
<span class="q-name">{{ one.name }}</span>
|
|
133
|
+
<span class="px-badge px-badge-neutral" $show="state.manyGroups">{{ one.group }}</span>
|
|
134
|
+
<span class="px-bar q-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" $aria-valuenow="one.pct" $aria-label="one.name"><span $style="one.barStyle"></span></span>
|
|
135
|
+
<span class="px-subtle q-pct">{{ one.pctLabel }}</span>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div class="px-queue-row" $else-if="one.failed">
|
|
139
|
+
<svg class="icon-danger" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9"></circle><path d="M12 8v5M12 16h.01"></path></svg>
|
|
140
|
+
<span class="q-text"><b>{{ one.name }}</b> <span class="text-danger">{{ one.message }}</span> {{ one.help }}</span>
|
|
141
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" $show="one.retryable" @click="retryUpload(one)">Try again</button>
|
|
142
|
+
<button class="px-btn px-btn-ghost px-btn-sm" type="button" @click="dismissUpload(one)">Dismiss</button>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="px-queue-row" $else>
|
|
146
|
+
<svg class="icon-ok" $show="!one.skipped" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>
|
|
147
|
+
<svg class="icon-muted" $show="one.skipped" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"></path></svg>
|
|
148
|
+
<span class="q-thumb"><img $src="one.preview" alt="" /></span>
|
|
149
|
+
<span class="q-name">{{ one.name }}</span>
|
|
150
|
+
<span class="px-badge px-badge-neutral" $show="state.manyGroups && !one.skipped">{{ one.group }}</span>
|
|
151
|
+
<span class="px-subtle" $show="one.note">{{ one.note }}</span>
|
|
152
|
+
<span class="px-badge px-badge-warn" $show="one.needsAlt">No alt text yet</span>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="queue-foot" $show="state.finished && state.newIds.length">
|
|
157
|
+
<span class="px-subtle">They have no alt text yet. Describe them while they are fresh in mind.</span>
|
|
158
|
+
<button class="px-btn px-btn-primary" type="button" @click="describeNew">{{ state.describeLabel }}</button>
|
|
159
|
+
</div>
|
|
160
|
+
</section>
|
|
161
|
+
|
|
162
|
+
<div class="bin-head" $show="state.deleted && state.ready && !state.error">
|
|
163
|
+
<b aria-live="polite">{{ state.binTitle }}</b>
|
|
164
|
+
<span class="px-subtle">Pictures here are hidden from pickers. Open one to restore it.</span>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<!-- First page of a new query: the shape of what is coming, not a word. -->
|
|
168
|
+
<div class="px-grid" $show="state.fresh && state.layout === 'grid'" aria-busy="true" aria-label="Loading pictures">
|
|
169
|
+
<span class="px-skel skel-tile" $for="one in state.skeleton" $key="one"></span>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="frame" $show="state.fresh && state.layout === 'list'" aria-busy="true" aria-label="Loading pictures">
|
|
172
|
+
<div class="px-list-row list-row" $for="one in state.skeleton" $key="one">
|
|
173
|
+
<span class="px-skel skel-thumb"></span><span class="px-skel skel-line"></span><span class="px-skel skel-input"></span><span class="px-skel skel-line"></span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<div class="frame px-empty empty" $show="state.empty" $role="state.error ? 'alert' : null">
|
|
178
|
+
<span class="error-mark" $show="state.error" aria-hidden="true"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"></circle><path d="M12 8v5M12 16h.01"></path></svg></span>
|
|
179
|
+
<h3>{{ state.emptyTitle }}</h3>
|
|
180
|
+
<p class="px-muted empty-body" $show="state.emptyBody">{{ state.emptyBody }}</p>
|
|
181
|
+
<p class="px-subtle" $show="state.error">{{ state.error }}</p>
|
|
182
|
+
<div class="px-row empty-actions">
|
|
183
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" $show="state.error" @click="reload">Try again</button>
|
|
184
|
+
<button class="px-btn px-btn-primary" type="button" $show="state.emptyUpload" @click="chooseFiles">Upload pictures</button>
|
|
185
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" $show="state.emptyMore" @click="loadMore">Look further</button>
|
|
186
|
+
<button class="px-btn px-btn-secondary px-btn-sm" type="button" $show="state.emptyAllGroups" @click="searchAllGroups">Search all groups</button>
|
|
187
|
+
<button class="px-btn px-btn-ghost px-btn-sm" type="button" $show="state.emptyClear" @click="clearAll">Clear</button>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<div class="px-grid" role="listbox" aria-label="Pictures" $ref="grid" $show="state.layout === 'grid' && (state.rows.length || state.processingShown.length) && !state.fresh">
|
|
192
|
+
<!-- Uploads the store is still working on. Not openable: there is
|
|
193
|
+
nothing to open yet. -->
|
|
194
|
+
<span class="px-tile is-processing" role="option" aria-disabled="true" aria-selected="false" $for="one in state.processingShown" $key="one.key">
|
|
195
|
+
<span class="px-pic pic">Processing…</span>
|
|
196
|
+
<span class="px-tile-name">{{ one.name }}</span>
|
|
197
|
+
</span>
|
|
198
|
+
<button
|
|
199
|
+
class="px-tile tile opens"
|
|
200
|
+
type="button"
|
|
201
|
+
role="option"
|
|
202
|
+
$for="asset in state.rows"
|
|
203
|
+
$key="asset.id"
|
|
204
|
+
$data-id="asset.id"
|
|
205
|
+
$aria-selected="asset.id === state.selectedId"
|
|
206
|
+
$aria-label="asset.ariaLabel"
|
|
207
|
+
$tabindex="asset.id === state.focusId ? 0 : -1"
|
|
208
|
+
$title="asset.binnedLabel || null"
|
|
209
|
+
$class="{ 'is-selected': asset.id === state.selectedId, 'is-binned': asset.binned }"
|
|
210
|
+
@click="inspect(asset)"
|
|
211
|
+
@keydown="tileKey($event, asset)"
|
|
212
|
+
>
|
|
213
|
+
<span class="px-pic pic" $class="{ broken: asset.failed }">
|
|
214
|
+
<img class="thumb" $src="asset.thumbnail" $data-id="asset.id" $style="asset.picStyle" alt="" loading="lazy" />
|
|
215
|
+
<!-- An asset whose derivative cannot be made still exists, and the
|
|
216
|
+
row is still the truth about the library. Saying so beats an
|
|
217
|
+
empty tile, which reads as a slow network rather than a bad file. -->
|
|
218
|
+
<span class="broken-note" $show="asset.failed">Preview unavailable</span>
|
|
219
|
+
</span>
|
|
220
|
+
<span class="px-tile-check" $show="asset.id === state.selectedId" aria-hidden="true"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"></path></svg></span>
|
|
221
|
+
<span class="px-tile-flags">
|
|
222
|
+
<span class="px-badge px-badge-danger" $show="asset.binned">In the bin</span>
|
|
223
|
+
<span class="px-badge px-badge-warn" $show="asset.noAlt">No alt text</span>
|
|
224
|
+
<span class="px-badge px-badge-neutral" $show="asset.viewOnly" $title="asset.whyViewOnly"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2"></rect><path d="M8 11V7a4 4 0 0 1 8 0v4"></path></svg>View only</span>
|
|
225
|
+
</span>
|
|
226
|
+
<span class="px-tile-name">{{ asset.label }}</span>
|
|
227
|
+
</button>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<!-- Dense, for tidying words: the alt text is written straight into the
|
|
231
|
+
row. Tab goes to the next row's alt text, and each saves as it is left. -->
|
|
232
|
+
<div class="frame list" role="table" aria-label="Pictures" $show="state.layout === 'list' && state.rows.length && !state.fresh">
|
|
233
|
+
<div class="px-list-row px-list-head list-row" role="row">
|
|
234
|
+
<span role="columnheader">Picture</span>
|
|
235
|
+
<span role="columnheader">Name</span>
|
|
236
|
+
<span role="columnheader" $text="state.deleted ? 'In the bin' : 'Alt text'"></span>
|
|
237
|
+
<span role="columnheader">Groups</span>
|
|
238
|
+
</div>
|
|
239
|
+
<div class="px-list-row list-row" role="row" $for="row in state.rows" $key="row.id" $class="{ 'is-current': row.id === state.selectedId, 'is-binned': row.binned }">
|
|
240
|
+
<span role="cell"><span class="px-pic list-pic" $class="{ broken: row.failed }"><img class="thumb" $src="row.thumbnail" $data-id="row.id" $style="row.picStyle" alt="" loading="lazy" /></span></span>
|
|
241
|
+
<span role="cell" class="name-cell">
|
|
242
|
+
<button class="open-row opens" type="button" $data-id="row.id" $aria-current="row.id === state.selectedId ? 'true' : null" @click="inspect(row)">{{ row.label }}</button>
|
|
243
|
+
</span>
|
|
244
|
+
<span role="cell" class="alt-cell">
|
|
245
|
+
<input
|
|
246
|
+
$if="row.altEditable"
|
|
247
|
+
class="px-input alt"
|
|
248
|
+
type="text"
|
|
249
|
+
$class="{ 'is-missing': !row.altText }"
|
|
250
|
+
$value="row.altText"
|
|
251
|
+
$data-id="row.id"
|
|
252
|
+
placeholder="Missing: describe what it shows"
|
|
253
|
+
$aria-label="'Alt text for ' + row.label"
|
|
254
|
+
@keydown="altKey($event)"
|
|
255
|
+
@blur="saveAlt($event, row)"
|
|
256
|
+
/>
|
|
257
|
+
<span $else-if="row.binned" class="px-subtle">{{ row.binnedLabel }}</span>
|
|
258
|
+
<span $else class="read-only" $title="row.whyViewOnly">
|
|
259
|
+
<span $show="row.altText">{{ row.altText }}</span>
|
|
260
|
+
<span class="px-badge px-badge-warn" $show="!row.altText">No alt text</span>
|
|
261
|
+
<span class="px-badge px-badge-neutral" $show="row.viewOnly">View only</span>
|
|
262
|
+
</span>
|
|
263
|
+
<span class="save-note" $show="row.saveNote" $class="{ 'text-danger': row.saveFailed }">{{ row.saveNote }}</span>
|
|
264
|
+
</span>
|
|
265
|
+
<span role="cell" class="px-subtle">{{ row.groupsLabel }}</span>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div class="more" $show="state.showMore && state.rows.length && !state.fresh">
|
|
270
|
+
<button class="px-btn px-btn-secondary" type="button" $disabled="state.loading" @click="loadMore">
|
|
271
|
+
{{ state.loading ? 'Loading…' : 'Load more' }}
|
|
272
|
+
</button>
|
|
273
|
+
<span class="px-subtle text-danger" role="alert" $show="state.moreError">{{ state.moreError }}</span>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<!-- Drop anywhere in the library. Named for where the files will go, so
|
|
277
|
+
nobody has to guess which group they land in. -->
|
|
278
|
+
<div class="drop" $show="state.dragging" aria-hidden="true">
|
|
279
|
+
<div class="drop-target">
|
|
280
|
+
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 15V3M7 8l5-5 5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path></svg>
|
|
281
|
+
<b>{{ state.dropLabel }}</b>
|
|
282
|
+
<span class="drop-hint" $show="state.typesHint">{{ state.typesHint }}</span>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<span class="sr-only" aria-live="polite">{{ state.announce }}</span>
|
|
287
|
+
</div>
|
|
288
|
+
</view>
|
|
289
|
+
|
|
290
|
+
<logic lang="ts">
|
|
291
|
+
import { reactive, onMounted, onUnmounted, onUpdate, shared, defineProps, defineRefs } from '@lightspeed-js/core'
|
|
292
|
+
import {
|
|
293
|
+
getLibrary,
|
|
294
|
+
thumbnailUrl,
|
|
295
|
+
describedFor,
|
|
296
|
+
defaultView,
|
|
297
|
+
cannotChange,
|
|
298
|
+
canWrite,
|
|
299
|
+
canDescribeView,
|
|
300
|
+
SELECTED,
|
|
301
|
+
CHANGED,
|
|
302
|
+
VIEW,
|
|
303
|
+
PRESETS,
|
|
304
|
+
UPLOAD_TYPES,
|
|
305
|
+
UPLOAD_LIMIT,
|
|
306
|
+
} from '../config.ts'
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The library, as a grid or a list.
|
|
310
|
+
*
|
|
311
|
+
* Paged by cursor rather than by page number, because the store orders by
|
|
312
|
+
* creation time and assets arrive while somebody is looking: page two of a
|
|
313
|
+
* numbered set shifts under you every time an upload lands, and rows repeat.
|
|
314
|
+
*
|
|
315
|
+
* `mode="bin"` opens it on the bin, for a host with a Bin page of its own;
|
|
316
|
+
* such a host also passes `binChip="false"` on its library page, so the bin
|
|
317
|
+
* has one way in rather than two.
|
|
318
|
+
*/
|
|
319
|
+
const props = defineProps({
|
|
320
|
+
mode: { default: 'library' },
|
|
321
|
+
binChip: { default: true },
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
const refs = defineRefs()
|
|
325
|
+
|
|
326
|
+
const PAGE_SIZE = 24
|
|
327
|
+
const LAYOUT_KEY = 'pseudolux:layout'
|
|
328
|
+
const UPLOAD_GROUP_KEY = 'pseudolux:upload-group'
|
|
329
|
+
|
|
330
|
+
const state = reactive({
|
|
331
|
+
assets: [],
|
|
332
|
+
rows: [],
|
|
333
|
+
processing: [],
|
|
334
|
+
processingShown: [],
|
|
335
|
+
skeleton: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
|
336
|
+
text: '',
|
|
337
|
+
format: '',
|
|
338
|
+
formats: [],
|
|
339
|
+
group: '',
|
|
340
|
+
groups: [],
|
|
341
|
+
cursor: '',
|
|
342
|
+
canSearch: false,
|
|
343
|
+
canFilterFormat: false,
|
|
344
|
+
canBrowseGroups: false,
|
|
345
|
+
canRemove: false,
|
|
346
|
+
canUpload: false,
|
|
347
|
+
canConfirm: false,
|
|
348
|
+
writeGroup: '',
|
|
349
|
+
uploadTypes: [],
|
|
350
|
+
uploadLimit: 0,
|
|
351
|
+
accept: 'image/*',
|
|
352
|
+
typesHint: '',
|
|
353
|
+
uploadLabel: 'Upload',
|
|
354
|
+
binMode: false,
|
|
355
|
+
deleted: false,
|
|
356
|
+
binTitle: 'Bin',
|
|
357
|
+
missingAlt: false,
|
|
358
|
+
shape: '',
|
|
359
|
+
thisMonth: false,
|
|
360
|
+
onlyIds: [],
|
|
361
|
+
onlyLabel: '',
|
|
362
|
+
kept: [],
|
|
363
|
+
layout: 'grid',
|
|
364
|
+
canLoadMore: false,
|
|
365
|
+
showMore: false,
|
|
366
|
+
loading: true,
|
|
367
|
+
fresh: true,
|
|
368
|
+
ready: false,
|
|
369
|
+
error: '',
|
|
370
|
+
moreError: '',
|
|
371
|
+
countLabel: '',
|
|
372
|
+
empty: false,
|
|
373
|
+
emptyTitle: '',
|
|
374
|
+
emptyBody: '',
|
|
375
|
+
emptyUpload: false,
|
|
376
|
+
emptyMore: false,
|
|
377
|
+
emptyAllGroups: false,
|
|
378
|
+
emptyClear: false,
|
|
379
|
+
selectedId: '',
|
|
380
|
+
focusId: '',
|
|
381
|
+
dragging: false,
|
|
382
|
+
dropLabel: '',
|
|
383
|
+
uploads: [],
|
|
384
|
+
queue: [],
|
|
385
|
+
queueTitle: '',
|
|
386
|
+
writeGroups: [],
|
|
387
|
+
manyGroups: false,
|
|
388
|
+
held: [],
|
|
389
|
+
heldGroup: '',
|
|
390
|
+
heldTitle: '',
|
|
391
|
+
heldNames: '',
|
|
392
|
+
heldAction: '',
|
|
393
|
+
counts: { added: 0, active: 0, questions: 0, failed: 0, addedLabel: '', activeLabel: '', questionsLabel: '', failedLabel: '' },
|
|
394
|
+
finished: false,
|
|
395
|
+
newIds: [],
|
|
396
|
+
describeLabel: '',
|
|
397
|
+
announce: '',
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
// The panel reads the same cell. Neither component owns the other, which is
|
|
401
|
+
// what lets a picker arrange them differently.
|
|
402
|
+
const selected = shared(SELECTED)
|
|
403
|
+
const changed = shared(CHANGED)
|
|
404
|
+
// The group being browsed is the view the library is looked at as: the panel
|
|
405
|
+
// describes pictures for it, and the rows judge their alt text by it.
|
|
406
|
+
const view = shared(VIEW)
|
|
407
|
+
const presets = shared(PRESETS)
|
|
408
|
+
|
|
409
|
+
const activeView = () => state.group || defaultView() || undefined
|
|
410
|
+
|
|
411
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many)
|
|
412
|
+
|
|
413
|
+
function inspect(asset) {
|
|
414
|
+
state.focusId = asset.id
|
|
415
|
+
// A plain copy, not the reactive row: a cell holding another component's
|
|
416
|
+
// state proxy is a thread between two owners nobody meant to spin.
|
|
417
|
+
selected.value = { ...asset }
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** Belt and braces for the row click.
|
|
421
|
+
*
|
|
422
|
+
* `@click` on the button is the declaration that should carry this. A
|
|
423
|
+
* delegated listener backs it up, because an event on an element inside a
|
|
424
|
+
* `$for` has more than once failed to attach here with no warning and no
|
|
425
|
+
* error - and a library you cannot click is not a library. */
|
|
426
|
+
function openFromClick(event) {
|
|
427
|
+
const root = refs.root
|
|
428
|
+
const button = event.target && event.target.closest ? event.target.closest('.opens') : null
|
|
429
|
+
if (!button || !root || !root.contains(button)) return
|
|
430
|
+
|
|
431
|
+
const id = button.getAttribute('data-id')
|
|
432
|
+
const asset = state.rows.find((one) => one.id === id)
|
|
433
|
+
const current = selected.value
|
|
434
|
+
|
|
435
|
+
// The declared handler may have got there first.
|
|
436
|
+
if (asset && (!current || current.id !== asset.id)) inspect(asset)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
selected.subscribe((asset) => {
|
|
440
|
+
state.selectedId = asset ? asset.id : ''
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
// --- rows ----------------------------------------------------------------------
|
|
444
|
+
|
|
445
|
+
// Which request the answers belong to. A slow first page arriving after a
|
|
446
|
+
// filter changed would otherwise repopulate the grid with results for a query
|
|
447
|
+
// nobody is looking at any more.
|
|
448
|
+
let generation = 0
|
|
449
|
+
let inFlight = null
|
|
450
|
+
|
|
451
|
+
// The asset as the store sent it, by id. A row carries the alt text as the
|
|
452
|
+
// active view reads it, which is not what a save should start from.
|
|
453
|
+
const sources = new Map()
|
|
454
|
+
|
|
455
|
+
const dateFormat = new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short', year: 'numeric' })
|
|
456
|
+
|
|
457
|
+
function present(asset) {
|
|
458
|
+
sources.set(asset.id, asset)
|
|
459
|
+
const width = asset.width || 0
|
|
460
|
+
const height = asset.height || 0
|
|
461
|
+
const label = asset.filename || asset.id
|
|
462
|
+
const current = activeView()
|
|
463
|
+
const seen = describedFor(asset, current)
|
|
464
|
+
const key = current ? current.trim().toLowerCase() : ''
|
|
465
|
+
const ownWords = Boolean(key && asset.views && asset.views[key] && asset.views[key].altText !== undefined)
|
|
466
|
+
const why = cannotChange(asset.tags)
|
|
467
|
+
const binned = Boolean(asset.deletedAt)
|
|
468
|
+
const altText = seen.altText || ''
|
|
469
|
+
// Where the view has its own words, those are what the row shows, so those
|
|
470
|
+
// are what it may save; otherwise the shared words.
|
|
471
|
+
const altEditable = !why && !binned && (!ownWords || canDescribeView(current))
|
|
472
|
+
// Marked only where this side can change some pictures. Where it can
|
|
473
|
+
// change none, every tile would say so and none would stand out.
|
|
474
|
+
const viewOnly = canWrite() && Boolean(why)
|
|
475
|
+
const noAlt = !altText && !binned
|
|
476
|
+
const binnedLabel = binned
|
|
477
|
+
? 'Moved to the bin' + (asset.deletedBy ? ' by ' + asset.deletedBy : '') + ' on ' + dateFormat.format(new Date(asset.deletedAt)) + (asset.deletedReason ? ' · “' + asset.deletedReason + '”' : '')
|
|
478
|
+
: ''
|
|
479
|
+
return {
|
|
480
|
+
...asset,
|
|
481
|
+
label,
|
|
482
|
+
altText,
|
|
483
|
+
thumbnail: thumbnailUrl(asset.id),
|
|
484
|
+
orientation: width && height ? (width > height ? 'landscape' : height > width ? 'portrait' : 'square') : '',
|
|
485
|
+
picStyle: asset.focal ? 'object-position: ' + asset.focal.x + '% ' + asset.focal.y + '%' : '',
|
|
486
|
+
binned,
|
|
487
|
+
binnedLabel,
|
|
488
|
+
noAlt,
|
|
489
|
+
viewOnly,
|
|
490
|
+
whyViewOnly: why,
|
|
491
|
+
altEditable,
|
|
492
|
+
altView: ownWords ? current : '',
|
|
493
|
+
groupsLabel: (asset.tags || []).join(', ') || '—',
|
|
494
|
+
ariaLabel: [label, noAlt ? 'no alt text' : '', viewOnly ? 'view only' : '', binned ? 'in the bin' : ''].filter(Boolean).join(', '),
|
|
495
|
+
failed: false,
|
|
496
|
+
saveNote: '',
|
|
497
|
+
saveFailed: false,
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const monthStart = () => {
|
|
502
|
+
const now = new Date()
|
|
503
|
+
return new Date(now.getFullYear(), now.getMonth(), 1).getTime()
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Filters the store cannot do, judged on the rows already loaded. */
|
|
507
|
+
const narrowed = () => Boolean(state.missingAlt || state.shape || state.thisMonth || state.onlyIds.length)
|
|
508
|
+
|
|
509
|
+
function matches(row) {
|
|
510
|
+
if (state.onlyIds.length && !state.onlyIds.includes(row.id)) return false
|
|
511
|
+
// A row described while "Missing alt text" is on stays until the filters
|
|
512
|
+
// change: vanishing mid-Tab would move every row under the cursor.
|
|
513
|
+
if (state.kept.includes(row.id)) return true
|
|
514
|
+
if (state.missingAlt && row.altText) return false
|
|
515
|
+
if (state.shape && row.orientation !== state.shape) return false
|
|
516
|
+
if (state.thisMonth && !(row.createdAt && Date.parse(row.createdAt) >= monthStart())) return false
|
|
517
|
+
return true
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** Whether the loaded rows are all there is to see for this view. The store
|
|
521
|
+
* lists newest first, so once a row from before this month has arrived,
|
|
522
|
+
* "Added this month" has everything; search may order by relevance, so not
|
|
523
|
+
* with text. Every other narrowing only knows what is loaded. */
|
|
524
|
+
function complete() {
|
|
525
|
+
if (!state.canLoadMore) return true
|
|
526
|
+
const onlyMonth = state.thisMonth && !state.missingAlt && !state.shape && !state.onlyIds.length
|
|
527
|
+
const last = state.assets[state.assets.length - 1]
|
|
528
|
+
return Boolean(onlyMonth && !state.text && last && last.createdAt && Date.parse(last.createdAt) < monthStart())
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function refresh() {
|
|
532
|
+
const rows = state.assets.filter(matches)
|
|
533
|
+
state.rows = rows
|
|
534
|
+
state.processingShown = state.deleted || narrowed() ? [] : state.processing
|
|
535
|
+
|
|
536
|
+
const whole = complete()
|
|
537
|
+
state.showMore = !whole
|
|
538
|
+
const n = rows.length
|
|
539
|
+
state.countLabel = !narrowed()
|
|
540
|
+
? state.canLoadMore
|
|
541
|
+
? plural(n, 'picture', 'pictures') + ' shown · more to load'
|
|
542
|
+
: plural(n, 'picture', 'pictures')
|
|
543
|
+
: whole
|
|
544
|
+
? plural(n, 'picture', 'pictures')
|
|
545
|
+
: n + ' of ' + state.assets.length + ' loaded'
|
|
546
|
+
state.binTitle = 'Bin · ' + (state.canLoadMore ? n + ' shown' : plural(n, 'picture', 'pictures'))
|
|
547
|
+
state.onlyLabel = 'Just uploaded · ' + state.onlyIds.length
|
|
548
|
+
|
|
549
|
+
// One tile takes Tab; the arrows move between the rest.
|
|
550
|
+
if (!rows.some((one) => one.id === state.focusId)) {
|
|
551
|
+
const current = rows.find((one) => one.id === state.selectedId)
|
|
552
|
+
state.focusId = current ? current.id : rows.length ? rows[0].id : ''
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
describeEmpty(rows.length)
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function describeEmpty(count) {
|
|
559
|
+
state.emptyUpload = false
|
|
560
|
+
state.emptyMore = false
|
|
561
|
+
state.emptyAllGroups = false
|
|
562
|
+
state.emptyClear = false
|
|
563
|
+
state.emptyBody = ''
|
|
564
|
+
|
|
565
|
+
if (state.error) {
|
|
566
|
+
state.empty = true
|
|
567
|
+
state.emptyTitle = "Pictures didn't load"
|
|
568
|
+
state.emptyBody = "The library couldn't be reached. Pictures on your sites are not affected."
|
|
569
|
+
return
|
|
570
|
+
}
|
|
571
|
+
state.empty = state.ready && !state.fresh && count === 0 && state.processingShown.length === 0
|
|
572
|
+
if (!state.empty) return
|
|
573
|
+
|
|
574
|
+
if (narrowed() && state.assets.length) {
|
|
575
|
+
const whole = complete()
|
|
576
|
+
state.emptyTitle = whole ? 'Nothing matches these filters' : 'None of the ' + plural(state.assets.length, 'picture', 'pictures') + ' loaded so far match'
|
|
577
|
+
state.emptyBody = whole ? '' : 'These filters look at the pictures already loaded. Look further to check the next ones.'
|
|
578
|
+
state.emptyMore = !whole
|
|
579
|
+
state.emptyClear = true
|
|
580
|
+
} else if (state.text || state.format || narrowed()) {
|
|
581
|
+
state.emptyTitle = state.text ? 'Nothing matches “' + state.text + '”' : 'Nothing matches'
|
|
582
|
+
state.emptyBody = state.group
|
|
583
|
+
? 'Search looks at names, words and labels in ' + state.group + '.'
|
|
584
|
+
: 'Search looks at names, words and labels in the groups you can see.'
|
|
585
|
+
state.emptyAllGroups = Boolean(state.group)
|
|
586
|
+
state.emptyClear = true
|
|
587
|
+
} else if (state.deleted) {
|
|
588
|
+
state.emptyTitle = state.group ? 'Nothing from ' + state.group + ' is in the bin' : 'The bin is empty'
|
|
589
|
+
} else if (state.group) {
|
|
590
|
+
state.emptyTitle = 'No pictures in ' + state.group + ' yet'
|
|
591
|
+
state.emptyUpload = state.canUpload && (!state.writeGroups.length || state.writeGroups.includes(state.group))
|
|
592
|
+
state.emptyBody = state.emptyUpload
|
|
593
|
+
? 'Drop files anywhere here, or choose them. Several at once is fine.'
|
|
594
|
+
: 'Pictures show here once somebody who can change ' + state.group + ' adds them.'
|
|
595
|
+
} else {
|
|
596
|
+
state.emptyTitle = 'No pictures yet'
|
|
597
|
+
state.emptyUpload = state.canUpload
|
|
598
|
+
state.emptyBody = state.emptyUpload ? 'Drop files anywhere here, or choose them. Several at once is fine.' : ''
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function query() {
|
|
603
|
+
return {
|
|
604
|
+
limit: PAGE_SIZE,
|
|
605
|
+
...(state.text ? { text: state.text } : {}),
|
|
606
|
+
...(state.format ? { format: state.format } : {}),
|
|
607
|
+
...(state.deleted ? { deleted: true } : {}),
|
|
608
|
+
...(state.group ? { group: state.group } : {}),
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function readCapabilities(capabilities) {
|
|
613
|
+
// What the store can do decides what the page offers. Read every time
|
|
614
|
+
// rather than once: swapping the search backend changes this answer, and
|
|
615
|
+
// the controls should follow without a rebuild.
|
|
616
|
+
state.canSearch = capabilities.text
|
|
617
|
+
state.canFilterFormat = capabilities.formats.length > 0
|
|
618
|
+
state.formats = capabilities.formats
|
|
619
|
+
state.canRemove = Boolean(capabilities.remove)
|
|
620
|
+
state.canUpload = Boolean(capabilities.upload) && typeof getLibrary().upload === 'function'
|
|
621
|
+
state.canConfirm = typeof getLibrary().confirmUpload === 'function'
|
|
622
|
+
state.writeGroup = capabilities.writeGroup || ''
|
|
623
|
+
state.writeGroups = capabilities.writeGroups && capabilities.writeGroups.length
|
|
624
|
+
? capabilities.writeGroups
|
|
625
|
+
: state.writeGroup ? [state.writeGroup] : []
|
|
626
|
+
state.manyGroups = state.writeGroups.length > 1
|
|
627
|
+
state.uploadLabel = state.writeGroups.length === 1 ? 'Upload to ' + state.writeGroups[0] : 'Upload'
|
|
628
|
+
state.uploadTypes = capabilities.uploadTypes && capabilities.uploadTypes.length ? capabilities.uploadTypes : UPLOAD_TYPES
|
|
629
|
+
state.uploadLimit = capabilities.uploadLimit || UPLOAD_LIMIT
|
|
630
|
+
state.accept = state.uploadTypes.join(',')
|
|
631
|
+
state.typesHint = typeList(state.uploadTypes) + ' · up to ' + megabytes(state.uploadLimit)
|
|
632
|
+
state.groups = capabilities.groups || []
|
|
633
|
+
presets.value = capabilities.presets || []
|
|
634
|
+
state.canBrowseGroups = state.groups.length > 0
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/** `quiet` keeps the rows on screen until the new ones arrive: for a reload
|
|
638
|
+
* nobody asked for, after an upload lands or a picture is binned. */
|
|
639
|
+
async function fetchPage(append, quiet = false) {
|
|
640
|
+
const mine = ++generation
|
|
641
|
+
state.loading = true
|
|
642
|
+
state.error = ''
|
|
643
|
+
state.moreError = ''
|
|
644
|
+
if (!append && !quiet) {
|
|
645
|
+
state.fresh = true
|
|
646
|
+
state.empty = false
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// Abandon the previous request rather than letting it finish unread. It is
|
|
650
|
+
// a page of a query nobody asked for any more, and on a slow link it is also
|
|
651
|
+
// the one still holding the connection.
|
|
652
|
+
if (inFlight) inFlight.abort()
|
|
653
|
+
const controller = new AbortController()
|
|
654
|
+
inFlight = controller
|
|
655
|
+
|
|
656
|
+
try {
|
|
657
|
+
const page = await getLibrary().list(
|
|
658
|
+
append && state.cursor ? { ...query(), cursor: state.cursor } : query(),
|
|
659
|
+
{ signal: controller.signal },
|
|
660
|
+
)
|
|
661
|
+
if (mine !== generation) return
|
|
662
|
+
|
|
663
|
+
readCapabilities(page.capabilities)
|
|
664
|
+
const rows = page.items.map(present)
|
|
665
|
+
state.assets = append ? state.assets.concat(rows) : rows
|
|
666
|
+
state.cursor = page.nextCursor || ''
|
|
667
|
+
state.canLoadMore = Boolean(page.nextCursor)
|
|
668
|
+
state.ready = true
|
|
669
|
+
} catch (err) {
|
|
670
|
+
if (err && err.name === 'AbortError') return
|
|
671
|
+
if (mine !== generation) return
|
|
672
|
+
// The server's own message, under the plain one. Its 400s name the
|
|
673
|
+
// mistake and list the valid values.
|
|
674
|
+
const why = err && err.message ? err.message : 'No answer from the library.'
|
|
675
|
+
if (append) {
|
|
676
|
+
// What is loaded is still true; only the next page is missing.
|
|
677
|
+
state.moreError = "The next pictures didn't load: " + why
|
|
678
|
+
} else {
|
|
679
|
+
state.error = why
|
|
680
|
+
state.assets = []
|
|
681
|
+
}
|
|
682
|
+
state.ready = true
|
|
683
|
+
} finally {
|
|
684
|
+
if (mine === generation) {
|
|
685
|
+
state.loading = false
|
|
686
|
+
state.fresh = false
|
|
687
|
+
refresh()
|
|
688
|
+
if (focusAltPending) focusFirstAlt()
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// A thumbnail that will not load.
|
|
694
|
+
//
|
|
695
|
+
// Listened for on the document in the capture phase rather than declared as
|
|
696
|
+
// `@error` on the image. `error` does not bubble, so it can only be heard on
|
|
697
|
+
// the element itself or on the way down - and a template binding cannot attach
|
|
698
|
+
// to rows that do not exist until the page arrives.
|
|
699
|
+
function thumbnailFailed(event) {
|
|
700
|
+
const target = event.target
|
|
701
|
+
if (!target || !target.classList) return
|
|
702
|
+
// A file the browser cannot draw (a TIFF, say) is still uploading fine.
|
|
703
|
+
if (target.closest && target.closest('.q-thumb, .cmp-pic')) {
|
|
704
|
+
target.style.visibility = 'hidden'
|
|
705
|
+
return
|
|
706
|
+
}
|
|
707
|
+
if (!target.classList.contains('thumb')) return
|
|
708
|
+
const id = target.getAttribute('data-id')
|
|
709
|
+
if (!id) return
|
|
710
|
+
state.assets = state.assets.map((one) => (one.id === id && !one.failed ? { ...one, failed: true } : one))
|
|
711
|
+
refresh()
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function reload(quiet = false) {
|
|
715
|
+
state.cursor = ''
|
|
716
|
+
view.value = activeView() || null
|
|
717
|
+
fetchPage(false, quiet === true)
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function loadMore() {
|
|
721
|
+
fetchPage(true)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// --- the controls -----------------------------------------------------------------
|
|
725
|
+
|
|
726
|
+
function filtersChanged() {
|
|
727
|
+
state.kept = []
|
|
728
|
+
reload()
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function narrowingChanged() {
|
|
732
|
+
state.kept = []
|
|
733
|
+
refresh()
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function toggleMissingAlt() {
|
|
737
|
+
state.missingAlt = !state.missingAlt
|
|
738
|
+
narrowingChanged()
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function toggleShape(shape) {
|
|
742
|
+
state.shape = state.shape === shape ? '' : shape
|
|
743
|
+
narrowingChanged()
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function toggleThisMonth() {
|
|
747
|
+
state.thisMonth = !state.thisMonth
|
|
748
|
+
narrowingChanged()
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function toggleDeleted() {
|
|
752
|
+
state.deleted = !state.deleted
|
|
753
|
+
if (state.deleted) state.missingAlt = false
|
|
754
|
+
filtersChanged()
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function clearOnly() {
|
|
758
|
+
state.onlyIds = []
|
|
759
|
+
narrowingChanged()
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function searchAllGroups() {
|
|
763
|
+
state.group = ''
|
|
764
|
+
filtersChanged()
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function clearAll() {
|
|
768
|
+
const refetch = Boolean(state.text || state.format)
|
|
769
|
+
state.text = ''
|
|
770
|
+
state.format = ''
|
|
771
|
+
state.missingAlt = false
|
|
772
|
+
state.shape = ''
|
|
773
|
+
state.thisMonth = false
|
|
774
|
+
state.onlyIds = []
|
|
775
|
+
state.kept = []
|
|
776
|
+
if (refetch) reload()
|
|
777
|
+
else refresh()
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function setLayout(layout) {
|
|
781
|
+
state.layout = layout
|
|
782
|
+
try {
|
|
783
|
+
localStorage.setItem(LAYOUT_KEY, layout)
|
|
784
|
+
} catch {
|
|
785
|
+
// Remembering is a convenience; a browser that will not store it still
|
|
786
|
+
// shows the layout asked for.
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function restoreLayout() {
|
|
791
|
+
try {
|
|
792
|
+
const saved = localStorage.getItem(LAYOUT_KEY)
|
|
793
|
+
if (saved === 'grid' || saved === 'list') state.layout = saved
|
|
794
|
+
} catch {
|
|
795
|
+
// As above.
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Typing is not a query per keystroke. Each one is a Lambda invocation, and
|
|
800
|
+
// the answers to the prefixes of a word are all thrown away.
|
|
801
|
+
let typingTimer = null
|
|
802
|
+
function onSearch() {
|
|
803
|
+
if (typingTimer) clearTimeout(typingTimer)
|
|
804
|
+
typingTimer = setTimeout(filtersChanged, 250)
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// --- moving through the grid ---------------------------------------------------------
|
|
808
|
+
|
|
809
|
+
const MOVES = ['ArrowRight', 'ArrowLeft', 'ArrowDown', 'ArrowUp', 'Home', 'End']
|
|
810
|
+
|
|
811
|
+
function columns() {
|
|
812
|
+
const grid = refs.grid
|
|
813
|
+
if (!grid) return 1
|
|
814
|
+
return getComputedStyle(grid).gridTemplateColumns.split(' ').filter(Boolean).length || 1
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function tileKey(event, asset) {
|
|
818
|
+
if (!MOVES.includes(event.key)) return
|
|
819
|
+
event.preventDefault()
|
|
820
|
+
|
|
821
|
+
// Tiles still processing sit at the start of the same grid, so a row of
|
|
822
|
+
// the grid is counted from them.
|
|
823
|
+
const offset = state.processingShown.length
|
|
824
|
+
const rows = state.rows
|
|
825
|
+
const at = offset + rows.findIndex((one) => one.id === asset.id)
|
|
826
|
+
const across = columns()
|
|
827
|
+
const step = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: across, ArrowUp: -across }[event.key]
|
|
828
|
+
const target = event.key === 'Home' ? 0 : event.key === 'End' ? rows.length - 1 : at + step - offset
|
|
829
|
+
const next = rows[Math.max(0, Math.min(rows.length - 1, target))]
|
|
830
|
+
if (!next) return
|
|
831
|
+
|
|
832
|
+
state.focusId = next.id
|
|
833
|
+
const tile = refs.grid && refs.grid.querySelector('.tile[data-id="' + CSS.escape(next.id) + '"]')
|
|
834
|
+
if (tile) tile.focus()
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// --- writing alt text in the list ----------------------------------------------------
|
|
838
|
+
|
|
839
|
+
function altInputs() {
|
|
840
|
+
return refs.root ? Array.from(refs.root.querySelectorAll('input.alt')) : []
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/** Tab to the next row's alt text, not the next control: the list is for
|
|
844
|
+
* going down a column of descriptions. Leaving the field saves it. */
|
|
845
|
+
function altKey(event) {
|
|
846
|
+
if (event.key !== 'Tab' && event.key !== 'Enter') return
|
|
847
|
+
const inputs = altInputs()
|
|
848
|
+
const next = inputs[inputs.indexOf(event.target) + (event.shiftKey ? -1 : 1)]
|
|
849
|
+
if (!next) {
|
|
850
|
+
if (event.key === 'Enter') event.target.blur()
|
|
851
|
+
return
|
|
852
|
+
}
|
|
853
|
+
event.preventDefault()
|
|
854
|
+
next.focus()
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function patchAsset(id, patch) {
|
|
858
|
+
state.assets = state.assets.map((one) => (one.id === id ? { ...one, ...patch } : one))
|
|
859
|
+
refresh()
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
async function saveAlt(event, row) {
|
|
863
|
+
const input = event.target
|
|
864
|
+
const value = input.value.trim()
|
|
865
|
+
if (value === (row.altText || '') || !row.altEditable) return
|
|
866
|
+
|
|
867
|
+
const source = sources.get(row.id) || row
|
|
868
|
+
const target = row.altView
|
|
869
|
+
patchAsset(row.id, { saveNote: 'Saving…', saveFailed: false })
|
|
870
|
+
try {
|
|
871
|
+
await getLibrary().describe(row.id, { altText: value || null }, target ? { view: target } : undefined)
|
|
872
|
+
const key = target ? target.trim().toLowerCase() : ''
|
|
873
|
+
const updated = target
|
|
874
|
+
? { ...source, views: { ...source.views, [key]: { ...(source.views && source.views[key]), altText: value } } }
|
|
875
|
+
: { ...source, altText: value || undefined }
|
|
876
|
+
const next = { ...present(updated), saveNote: 'Saved' }
|
|
877
|
+
state.assets = state.assets.map((one) => (one.id === row.id ? next : one))
|
|
878
|
+
if (state.missingAlt && !state.kept.includes(row.id)) state.kept = state.kept.concat([row.id])
|
|
879
|
+
refresh()
|
|
880
|
+
state.announce = 'Saved the alt text for ' + row.label
|
|
881
|
+
} catch (err) {
|
|
882
|
+
const why = err && err.message ? err.message : 'no answer from the library'
|
|
883
|
+
patchAsset(row.id, { saveNote: "Couldn't save: " + why + '. Your words are still in the box.', saveFailed: true })
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
let focusAltPending = false
|
|
888
|
+
|
|
889
|
+
function focusFirstAlt(tries = 20) {
|
|
890
|
+
focusAltPending = false
|
|
891
|
+
// Once the rows have rendered, which is a frame or two after the page.
|
|
892
|
+
requestAnimationFrame(() => {
|
|
893
|
+
const inputs = altInputs().filter((one) => one.offsetParent !== null)
|
|
894
|
+
const first = inputs.find((one) => !one.value.trim()) || inputs[0]
|
|
895
|
+
if (first) first.focus()
|
|
896
|
+
else if (tries > 0) focusFirstAlt(tries - 1)
|
|
897
|
+
})
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// --- adding pictures -----------------------------------------------------------------
|
|
901
|
+
|
|
902
|
+
let uploadKey = 0
|
|
903
|
+
const files = new Map()
|
|
904
|
+
|
|
905
|
+
const EXTENSION = /\.([a-z0-9]+)$/i
|
|
906
|
+
|
|
907
|
+
function megabytes(bytes) {
|
|
908
|
+
const mb = bytes / (1024 * 1024)
|
|
909
|
+
if (mb < 1) return Math.max(1, Math.round(bytes / 1024)) + ' KB'
|
|
910
|
+
return (mb >= 10 ? Math.round(mb) : Math.round(mb * 10) / 10) + ' MB'
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/** Its pixel size, once the browser has read it, beside the bytes. A browser
|
|
914
|
+
* that cannot show the type (TIFF, mostly) leaves just the bytes. */
|
|
915
|
+
function measure(key, preview, bytes) {
|
|
916
|
+
const probe = new Image()
|
|
917
|
+
probe.onload = () => {
|
|
918
|
+
if (probe.naturalWidth) patchUpload(key, { sizeLabel: probe.naturalWidth + ' × ' + probe.naturalHeight + ' · ' + bytes })
|
|
919
|
+
}
|
|
920
|
+
probe.src = preview
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function typeList(types) {
|
|
924
|
+
const names = types.map((one) => one.replace(/^image\//, '').replace('jpeg', 'jpg').replace('svg+xml', 'svg').toUpperCase())
|
|
925
|
+
return names.length > 1 ? names.slice(0, -1).join(', ') + ' or ' + names[names.length - 1] : names[0]
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/** Why a file will not be taken, as a sentence and what to do about it, or
|
|
929
|
+
* null. Checked here so a 200 MB mistake does not spend minutes uploading
|
|
930
|
+
* before the server says the same thing. */
|
|
931
|
+
function refusal(file) {
|
|
932
|
+
if (!state.uploadTypes.includes(file.type)) {
|
|
933
|
+
const ext = (file.name.match(EXTENSION) || [])[1]
|
|
934
|
+
return {
|
|
935
|
+
message: ext ? 'is a ' + ext.toUpperCase() + " file, which the library can't take." : "isn't a picture the library can take.",
|
|
936
|
+
help: 'Save it as ' + typeList(state.uploadTypes) + ' and add it again.',
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (state.uploadLimit && file.size > state.uploadLimit) {
|
|
940
|
+
return {
|
|
941
|
+
message: 'is ' + megabytes(file.size) + ', more than the library takes in one go (' + megabytes(state.uploadLimit) + ').',
|
|
942
|
+
help: 'Export it smaller and add it again.',
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return null
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
function queueFile(file, group) {
|
|
949
|
+
const key = ++uploadKey
|
|
950
|
+
files.set(key, file)
|
|
951
|
+
const entry = {
|
|
952
|
+
key,
|
|
953
|
+
group: group || '',
|
|
954
|
+
name: file.name,
|
|
955
|
+
preview: URL.createObjectURL(file),
|
|
956
|
+
sizeLabel: megabytes(file.size),
|
|
957
|
+
status: 'waiting',
|
|
958
|
+
pct: 0,
|
|
959
|
+
message: '',
|
|
960
|
+
help: '',
|
|
961
|
+
retryable: false,
|
|
962
|
+
id: '',
|
|
963
|
+
note: '',
|
|
964
|
+
exact: false,
|
|
965
|
+
expanded: false,
|
|
966
|
+
matchId: '',
|
|
967
|
+
matchName: '',
|
|
968
|
+
matchMeta: '',
|
|
969
|
+
matchThumb: '',
|
|
970
|
+
token: '',
|
|
971
|
+
}
|
|
972
|
+
const refused = refusal(file)
|
|
973
|
+
if (refused) Object.assign(entry, { status: 'failed', ...refused })
|
|
974
|
+
state.uploads = state.uploads.concat([entry])
|
|
975
|
+
refreshQueue()
|
|
976
|
+
if (!refused) measure(key, entry.preview, entry.sizeLabel)
|
|
977
|
+
return entry
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
function patchUpload(key, patch) {
|
|
981
|
+
state.uploads = state.uploads.map((one) => (one.key === key ? { ...one, ...patch } : one))
|
|
982
|
+
refreshQueue()
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
const ORDER = { question: 0, waiting: 1, uploading: 1, processing: 1, failed: 2, done: 3, pending: 3, skipped: 3 }
|
|
986
|
+
|
|
987
|
+
function refreshQueue() {
|
|
988
|
+
const uploads = state.uploads
|
|
989
|
+
const count = (...statuses) => uploads.filter((one) => statuses.includes(one.status)).length
|
|
990
|
+
const added = count('done', 'pending')
|
|
991
|
+
const active = count('waiting', 'uploading', 'processing')
|
|
992
|
+
const questions = count('question')
|
|
993
|
+
const failed = count('failed')
|
|
994
|
+
state.counts = {
|
|
995
|
+
added,
|
|
996
|
+
active,
|
|
997
|
+
questions,
|
|
998
|
+
failed,
|
|
999
|
+
addedLabel: added + ' added',
|
|
1000
|
+
activeLabel: active + ' uploading',
|
|
1001
|
+
questionsLabel: plural(questions, 'question', 'questions'),
|
|
1002
|
+
failedLabel: failed + " couldn't upload",
|
|
1003
|
+
}
|
|
1004
|
+
state.finished = uploads.length > 0 && active === 0 && questions === 0
|
|
1005
|
+
state.newIds = uploads.filter((one) => one.status === 'done' && one.id).map((one) => one.id)
|
|
1006
|
+
state.describeLabel = 'Describe the ' + plural(state.newIds.length, 'new picture', 'new pictures')
|
|
1007
|
+
const groups = [...new Set(uploads.map((one) => one.group).filter(Boolean))]
|
|
1008
|
+
const into = groups.length === 1 ? ' to ' + groups[0] : ''
|
|
1009
|
+
state.queueTitle = (state.finished ? 'Uploaded ' : 'Uploading ') + plural(uploads.length, 'file', 'files') + into
|
|
1010
|
+
|
|
1011
|
+
state.queue = uploads
|
|
1012
|
+
.map((one) => ({
|
|
1013
|
+
...one,
|
|
1014
|
+
question: one.status === 'question',
|
|
1015
|
+
active: ['waiting', 'uploading', 'processing'].includes(one.status),
|
|
1016
|
+
failed: one.status === 'failed',
|
|
1017
|
+
skipped: one.status === 'skipped',
|
|
1018
|
+
needsAlt: one.status === 'done',
|
|
1019
|
+
questionText: one.exact ? 'is already in the library, exactly.' : 'looks like one already in the library.',
|
|
1020
|
+
barStyle: 'width: ' + one.pct + '%',
|
|
1021
|
+
pctLabel: one.status === 'waiting' ? 'Waiting' : one.status === 'processing' ? 'Processing…' : one.pct + '%',
|
|
1022
|
+
}))
|
|
1023
|
+
.sort((a, b) => ORDER[a.status] - ORDER[b.status])
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// One at a time. The store converts and hashes each picture as it arrives,
|
|
1027
|
+
// and several large files at once would race each other for the same
|
|
1028
|
+
// minutes; a queue finishes sooner and reports in order.
|
|
1029
|
+
let uploading = Promise.resolve()
|
|
1030
|
+
|
|
1031
|
+
function send(entry) {
|
|
1032
|
+
const port = getLibrary()
|
|
1033
|
+
const file = files.get(entry.key)
|
|
1034
|
+
if (!file || typeof port.upload !== 'function') return
|
|
1035
|
+
uploading = uploading.then(async () => {
|
|
1036
|
+
patchUpload(entry.key, { status: 'uploading', pct: 0 })
|
|
1037
|
+
try {
|
|
1038
|
+
const outcome = await port.upload(file, {
|
|
1039
|
+
...(entry.group ? { group: entry.group } : {}),
|
|
1040
|
+
onProgress: (fraction) => {
|
|
1041
|
+
const pct = Math.round(fraction * 100)
|
|
1042
|
+
patchUpload(entry.key, { pct, status: pct < 100 ? 'uploading' : 'processing' })
|
|
1043
|
+
},
|
|
1044
|
+
})
|
|
1045
|
+
settle(entry.key, outcome)
|
|
1046
|
+
} catch (err) {
|
|
1047
|
+
patchUpload(entry.key, {
|
|
1048
|
+
status: 'failed',
|
|
1049
|
+
message: err && err.message ? err.message + '.' : "didn't reach the library.",
|
|
1050
|
+
help: 'Try again, or come back to it later.',
|
|
1051
|
+
retryable: true,
|
|
1052
|
+
})
|
|
1053
|
+
}
|
|
1054
|
+
})
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function sendFiles(list) {
|
|
1058
|
+
if (!state.canUpload || !list.length) return
|
|
1059
|
+
if (state.manyGroups) return hold(list)
|
|
1060
|
+
queueAll(list, state.writeGroups[0] || '')
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function queueAll(list, group) {
|
|
1064
|
+
for (const file of list) {
|
|
1065
|
+
const entry = queueFile(file, group)
|
|
1066
|
+
if (entry.status === 'waiting') send(entry)
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// Files waiting for a group, when there is more than one to choose from.
|
|
1071
|
+
let heldFiles = []
|
|
1072
|
+
|
|
1073
|
+
/** The group being browsed if it can be uploaded to, else the last one
|
|
1074
|
+
* chosen, else this side's own. */
|
|
1075
|
+
function likelyGroup() {
|
|
1076
|
+
if (state.writeGroups.includes(state.group)) return state.group
|
|
1077
|
+
let last = ''
|
|
1078
|
+
try {
|
|
1079
|
+
last = localStorage.getItem(UPLOAD_GROUP_KEY) || ''
|
|
1080
|
+
} catch {}
|
|
1081
|
+
return state.writeGroups.includes(last) ? last : state.writeGroups[0]
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function hold(list) {
|
|
1085
|
+
if (!heldFiles.length) state.heldGroup = likelyGroup()
|
|
1086
|
+
heldFiles = heldFiles.concat(list)
|
|
1087
|
+
state.held = heldFiles.map((file, index) => ({ key: index, name: file.name }))
|
|
1088
|
+
const files = plural(heldFiles.length, 'file', 'files')
|
|
1089
|
+
state.heldTitle = 'Upload ' + files
|
|
1090
|
+
state.heldAction = 'Upload ' + files
|
|
1091
|
+
const names = heldFiles.slice(0, 4).map((file) => file.name)
|
|
1092
|
+
state.heldNames = names.join(' · ') + (heldFiles.length > 4 ? ' and ' + (heldFiles.length - 4) + ' more' : '')
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function sendHeld() {
|
|
1096
|
+
const group = state.heldGroup
|
|
1097
|
+
if (!state.writeGroups.includes(group)) return
|
|
1098
|
+
try {
|
|
1099
|
+
localStorage.setItem(UPLOAD_GROUP_KEY, group)
|
|
1100
|
+
} catch {}
|
|
1101
|
+
const list = heldFiles
|
|
1102
|
+
cancelHeld()
|
|
1103
|
+
queueAll(list, group)
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function cancelHeld() {
|
|
1107
|
+
heldFiles = []
|
|
1108
|
+
state.held = []
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// What the store said, as the row's state. A likely duplicate is a question,
|
|
1112
|
+
// not a result: the row names what it matched and waits for an answer.
|
|
1113
|
+
function settle(key, outcome) {
|
|
1114
|
+
if (outcome && outcome.token) {
|
|
1115
|
+
const exact = Boolean(outcome.duplicateOf && outcome.duplicateOf.length)
|
|
1116
|
+
const match = exact ? outcome.duplicateOf[0] : outcome.similar && outcome.similar[0] && outcome.similar[0].id
|
|
1117
|
+
patchUpload(key, {
|
|
1118
|
+
status: 'question',
|
|
1119
|
+
pct: 100,
|
|
1120
|
+
exact,
|
|
1121
|
+
expanded: exact,
|
|
1122
|
+
token: outcome.token,
|
|
1123
|
+
matchId: match || '',
|
|
1124
|
+
matchName: match || 'A picture',
|
|
1125
|
+
matchThumb: match ? thumbnailUrl(match) : '',
|
|
1126
|
+
})
|
|
1127
|
+
if (match) describeMatch(key, match)
|
|
1128
|
+
return
|
|
1129
|
+
}
|
|
1130
|
+
if (outcome && outcome.pending) {
|
|
1131
|
+
patchUpload(key, { status: 'pending', pct: 100, note: 'Still processing; it will appear shortly.' })
|
|
1132
|
+
const entry = state.uploads.find((one) => one.key === key)
|
|
1133
|
+
state.processing = state.processing.concat([{ key, name: entry ? entry.name : '' }])
|
|
1134
|
+
refresh()
|
|
1135
|
+
setTimeout(() => {
|
|
1136
|
+
state.processing = state.processing.filter((one) => one.key !== key)
|
|
1137
|
+
changed.value = (changed.value || 0) + 1
|
|
1138
|
+
}, 20000)
|
|
1139
|
+
return
|
|
1140
|
+
}
|
|
1141
|
+
patchUpload(key, { status: 'done', pct: 100, id: outcome.id, token: '' })
|
|
1142
|
+
changed.value = (changed.value || 0) + 1
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/** Enough about the picture already there to decide by: its name, where it
|
|
1146
|
+
* lives, and how many pages would notice. */
|
|
1147
|
+
async function describeMatch(key, id) {
|
|
1148
|
+
const port = getLibrary()
|
|
1149
|
+
try {
|
|
1150
|
+
const [detail, usage] = await Promise.all([
|
|
1151
|
+
port.detail(id),
|
|
1152
|
+
typeof port.usage === 'function' ? port.usage(id).catch(() => null) : Promise.resolve(null),
|
|
1153
|
+
])
|
|
1154
|
+
const pages = usage ? new Set(usage.placements.map((one) => one.site + '|' + one.page)).size : -1
|
|
1155
|
+
const parts = [
|
|
1156
|
+
detail.width && detail.height ? detail.width + ' × ' + detail.height : '',
|
|
1157
|
+
(detail.tags || []).join(', '),
|
|
1158
|
+
pages > 0 ? 'used on ' + plural(pages, 'page', 'pages') : pages === 0 ? 'not used on any page' : '',
|
|
1159
|
+
].filter(Boolean)
|
|
1160
|
+
patchUpload(key, {
|
|
1161
|
+
matchName: detail.filename || id,
|
|
1162
|
+
matchMeta: parts.length ? ' · ' + parts.join(' · ') : '',
|
|
1163
|
+
})
|
|
1164
|
+
} catch {
|
|
1165
|
+
// The question still stands with the identifier alone.
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
function toggleCompare(one) {
|
|
1170
|
+
patchUpload(one.key, { expanded: !one.expanded })
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
async function uploadAnyway(one) {
|
|
1174
|
+
const port = getLibrary()
|
|
1175
|
+
if (!one.token || typeof port.confirmUpload !== 'function') return
|
|
1176
|
+
patchUpload(one.key, { status: 'processing', token: '' })
|
|
1177
|
+
try {
|
|
1178
|
+
settle(one.key, await port.confirmUpload(one.token))
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
patchUpload(one.key, {
|
|
1181
|
+
status: 'failed',
|
|
1182
|
+
message: err && err.message ? err.message + '.' : "didn't reach the library.",
|
|
1183
|
+
help: 'Drop it again to start over.',
|
|
1184
|
+
retryable: false,
|
|
1185
|
+
})
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function skipUpload(one) {
|
|
1190
|
+
patchUpload(one.key, { status: 'skipped', token: '', note: 'Skipped. The existing one stays.' })
|
|
1191
|
+
state.announce = 'Skipped ' + one.name + '. The existing one stays.'
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
async function openExisting(one) {
|
|
1195
|
+
if (!one.matchId) return
|
|
1196
|
+
try {
|
|
1197
|
+
const detail = await getLibrary().detail(one.matchId)
|
|
1198
|
+
selected.value = { ...detail, label: detail.filename || detail.id, thumbnail: thumbnailUrl(detail.id) }
|
|
1199
|
+
} catch {
|
|
1200
|
+
state.announce = "Couldn't open " + one.matchName + '.'
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function retryUpload(one) {
|
|
1205
|
+
const entry = state.uploads.find((each) => each.key === one.key)
|
|
1206
|
+
if (!entry) return
|
|
1207
|
+
patchUpload(one.key, { status: 'waiting', pct: 0, message: '', help: '', retryable: false })
|
|
1208
|
+
send(entry)
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
function forget(one) {
|
|
1212
|
+
if (one.preview) URL.revokeObjectURL(one.preview)
|
|
1213
|
+
files.delete(one.key)
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function dismissUpload(one) {
|
|
1217
|
+
forget(one)
|
|
1218
|
+
state.uploads = state.uploads.filter((each) => each.key !== one.key)
|
|
1219
|
+
refreshQueue()
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
function closeQueue() {
|
|
1223
|
+
state.uploads.forEach(forget)
|
|
1224
|
+
state.uploads = []
|
|
1225
|
+
refreshQueue()
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/** The new pictures, as a list to describe: just them, with the cursor in the
|
|
1229
|
+
* first one that still has no words. */
|
|
1230
|
+
function describeNew() {
|
|
1231
|
+
const ids = state.newIds.slice()
|
|
1232
|
+
if (!ids.length) return
|
|
1233
|
+
state.text = ''
|
|
1234
|
+
state.format = ''
|
|
1235
|
+
state.group = ''
|
|
1236
|
+
state.missingAlt = false
|
|
1237
|
+
state.shape = ''
|
|
1238
|
+
state.thisMonth = false
|
|
1239
|
+
state.kept = []
|
|
1240
|
+
state.onlyIds = ids
|
|
1241
|
+
if (!state.binMode) state.deleted = false
|
|
1242
|
+
setLayout('list')
|
|
1243
|
+
focusAltPending = true
|
|
1244
|
+
reload()
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
function chooseFiles() {
|
|
1248
|
+
if (refs.fileInput) refs.fileInput.click()
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
function filesChosen(event) {
|
|
1252
|
+
const input = event && event.target
|
|
1253
|
+
if (!input || !input.files) return
|
|
1254
|
+
sendFiles(Array.from(input.files))
|
|
1255
|
+
input.value = ''
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
function carriesFiles(event) {
|
|
1259
|
+
return event.dataTransfer && Array.from(event.dataTransfer.types || []).includes('Files')
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
function onDragOver(event) {
|
|
1263
|
+
if (!state.canUpload || state.deleted || !carriesFiles(event)) return
|
|
1264
|
+
event.preventDefault()
|
|
1265
|
+
const n = event.dataTransfer.items ? event.dataTransfer.items.length : 0
|
|
1266
|
+
const what = n ? plural(n, 'file', 'files') : 'files'
|
|
1267
|
+
state.dropLabel = state.writeGroups.length === 1
|
|
1268
|
+
? 'Drop ' + what + ' into ' + state.writeGroups[0]
|
|
1269
|
+
: state.manyGroups
|
|
1270
|
+
? 'Drop ' + what + ', then choose the group'
|
|
1271
|
+
: 'Drop ' + what + ' to add them'
|
|
1272
|
+
state.dragging = true
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function onDragLeave(event) {
|
|
1276
|
+
if (event.relatedTarget && document.body.contains(event.relatedTarget)) return
|
|
1277
|
+
state.dragging = false
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function onDrop(event) {
|
|
1281
|
+
state.dragging = false
|
|
1282
|
+
if (!state.canUpload || state.deleted) return
|
|
1283
|
+
if (!event.dataTransfer || !event.dataTransfer.files || !event.dataTransfer.files.length) return
|
|
1284
|
+
event.preventDefault()
|
|
1285
|
+
// Everything dropped gets a row, pictures or not: a file that is silently
|
|
1286
|
+
// left out is a file somebody thinks is in the library.
|
|
1287
|
+
sendFiles(Array.from(event.dataTransfer.files))
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
// An asset binned or restored from the panel belongs on the other list now.
|
|
1291
|
+
// Reloading is simpler than working out which row moved where, and the grid
|
|
1292
|
+
// is small.
|
|
1293
|
+
let lastChange = changed.value
|
|
1294
|
+
changed.subscribe((value) => {
|
|
1295
|
+
if (value === lastChange) return
|
|
1296
|
+
lastChange = value
|
|
1297
|
+
reload(true)
|
|
1298
|
+
})
|
|
1299
|
+
|
|
1300
|
+
let lastMode = ''
|
|
1301
|
+
function followMode() {
|
|
1302
|
+
const mode = props.mode === 'bin' ? 'bin' : 'library'
|
|
1303
|
+
if (mode === lastMode) return false
|
|
1304
|
+
lastMode = mode
|
|
1305
|
+
state.binMode = mode === 'bin'
|
|
1306
|
+
state.deleted = state.binMode
|
|
1307
|
+
if (state.binMode) state.missingAlt = false
|
|
1308
|
+
return true
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
onUpdate(() => {
|
|
1312
|
+
if (followMode()) filtersChanged()
|
|
1313
|
+
})
|
|
1314
|
+
|
|
1315
|
+
onMounted(() => {
|
|
1316
|
+
document.addEventListener('error', thumbnailFailed, true)
|
|
1317
|
+
document.addEventListener('click', openFromClick)
|
|
1318
|
+
document.addEventListener('dragover', onDragOver)
|
|
1319
|
+
document.addEventListener('dragleave', onDragLeave)
|
|
1320
|
+
document.addEventListener('drop', onDrop)
|
|
1321
|
+
restoreLayout()
|
|
1322
|
+
followMode()
|
|
1323
|
+
// Looked at as the host's own group until somebody chooses another.
|
|
1324
|
+
view.value = activeView() || null
|
|
1325
|
+
fetchPage(false)
|
|
1326
|
+
})
|
|
1327
|
+
|
|
1328
|
+
onUnmounted(() => {
|
|
1329
|
+
document.removeEventListener('error', thumbnailFailed, true)
|
|
1330
|
+
document.removeEventListener('click', openFromClick)
|
|
1331
|
+
document.removeEventListener('dragover', onDragOver)
|
|
1332
|
+
document.removeEventListener('dragleave', onDragLeave)
|
|
1333
|
+
document.removeEventListener('drop', onDrop)
|
|
1334
|
+
if (typingTimer) clearTimeout(typingTimer)
|
|
1335
|
+
if (inFlight) inFlight.abort()
|
|
1336
|
+
state.uploads.forEach(forget)
|
|
1337
|
+
})
|
|
1338
|
+
</logic>
|
|
1339
|
+
|
|
1340
|
+
<style>
|
|
1341
|
+
.library {
|
|
1342
|
+
position: relative;
|
|
1343
|
+
display: flex;
|
|
1344
|
+
flex-direction: column;
|
|
1345
|
+
gap: 14px;
|
|
1346
|
+
min-width: 0;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
.search {
|
|
1350
|
+
flex: 1 1 320px;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
/* The ring goes round the whole field, not the bare input inside it. */
|
|
1354
|
+
.search:focus-within {
|
|
1355
|
+
outline: 3px solid var(--px-focus);
|
|
1356
|
+
outline-offset: 2px;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
.search input:focus-visible {
|
|
1360
|
+
outline: none;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
.group {
|
|
1364
|
+
flex: 0 1 220px;
|
|
1365
|
+
width: auto;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
.file-input {
|
|
1369
|
+
display: none;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.filters {
|
|
1373
|
+
flex: 1 1 auto;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
.chip {
|
|
1377
|
+
position: relative;
|
|
1378
|
+
padding-right: 10px;
|
|
1379
|
+
font: inherit;
|
|
1380
|
+
font-size: var(--px-fs-s);
|
|
1381
|
+
font-weight: 500;
|
|
1382
|
+
color: var(--px-text);
|
|
1383
|
+
cursor: pointer;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/* The chip is drawn at 32px; the hit area reaches the full target. */
|
|
1387
|
+
.chip::after {
|
|
1388
|
+
content: "";
|
|
1389
|
+
position: absolute;
|
|
1390
|
+
inset: calc((32px - var(--px-target)) / 2) 0;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
.chip:hover {
|
|
1394
|
+
border-color: var(--px-border-strong);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
.chip[aria-pressed="true"],
|
|
1398
|
+
.chip.is-on {
|
|
1399
|
+
background: var(--px-accent-soft);
|
|
1400
|
+
border-color: var(--px-accent);
|
|
1401
|
+
color: var(--px-accent-text);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
.chip.is-on {
|
|
1405
|
+
padding-right: 4px;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
.compact {
|
|
1409
|
+
width: auto;
|
|
1410
|
+
min-height: 36px;
|
|
1411
|
+
padding: 4px 10px;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
.count {
|
|
1415
|
+
margin-left: auto;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/* Upload queue */
|
|
1419
|
+
.frame {
|
|
1420
|
+
border: 1px solid var(--px-border);
|
|
1421
|
+
border-radius: var(--px-r-l);
|
|
1422
|
+
background: var(--px-surface);
|
|
1423
|
+
overflow: hidden;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
.queue-head {
|
|
1427
|
+
display: flex;
|
|
1428
|
+
flex-wrap: wrap;
|
|
1429
|
+
align-items: center;
|
|
1430
|
+
gap: 10px;
|
|
1431
|
+
padding: 12px 16px;
|
|
1432
|
+
border-bottom: 1px solid var(--px-border);
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
.queue-title {
|
|
1436
|
+
flex: 1 1 auto;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
.counts {
|
|
1440
|
+
gap: 6px;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
.queue-item > .px-queue-row {
|
|
1444
|
+
padding: 10px 16px;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
.question {
|
|
1448
|
+
display: flex;
|
|
1449
|
+
flex-direction: column;
|
|
1450
|
+
gap: 12px;
|
|
1451
|
+
padding: 14px 16px;
|
|
1452
|
+
border-bottom: 1px solid var(--px-border);
|
|
1453
|
+
background: var(--px-warn-soft);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
.question-head {
|
|
1457
|
+
display: flex;
|
|
1458
|
+
align-items: center;
|
|
1459
|
+
gap: 12px;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
.question-title {
|
|
1463
|
+
flex: 1;
|
|
1464
|
+
min-width: 0;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
.cmp {
|
|
1468
|
+
max-width: 720px;
|
|
1469
|
+
display: grid;
|
|
1470
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1471
|
+
gap: 12px;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
.cmp > div {
|
|
1475
|
+
display: flex;
|
|
1476
|
+
flex-direction: column;
|
|
1477
|
+
gap: 6px;
|
|
1478
|
+
min-width: 0;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
.cmp-pic {
|
|
1482
|
+
display: block;
|
|
1483
|
+
aspect-ratio: 3 / 2;
|
|
1484
|
+
border-radius: var(--px-r-m);
|
|
1485
|
+
background: var(--px-surface-2);
|
|
1486
|
+
overflow: hidden;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
.cmp-pic img,
|
|
1490
|
+
.q-thumb img,
|
|
1491
|
+
.list-pic img,
|
|
1492
|
+
.pic img {
|
|
1493
|
+
display: block;
|
|
1494
|
+
width: 100%;
|
|
1495
|
+
height: 100%;
|
|
1496
|
+
object-fit: cover;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
.cmp-note {
|
|
1500
|
+
font-size: var(--px-fs-s);
|
|
1501
|
+
overflow-wrap: anywhere;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
.q-thumb {
|
|
1505
|
+
flex: none;
|
|
1506
|
+
width: 48px;
|
|
1507
|
+
height: 32px;
|
|
1508
|
+
border-radius: 4px;
|
|
1509
|
+
background: var(--px-surface-2);
|
|
1510
|
+
overflow: hidden;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
.q-name {
|
|
1514
|
+
flex: 1;
|
|
1515
|
+
min-width: 0;
|
|
1516
|
+
overflow: hidden;
|
|
1517
|
+
text-overflow: ellipsis;
|
|
1518
|
+
white-space: nowrap;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
.q-text {
|
|
1522
|
+
flex: 1;
|
|
1523
|
+
min-width: 0;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
.q-bar {
|
|
1527
|
+
flex: 0 1 160px;
|
|
1528
|
+
width: 160px;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
.q-pct {
|
|
1532
|
+
flex: none;
|
|
1533
|
+
width: 72px;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
.icon-ok { flex: none; color: var(--px-ok); }
|
|
1537
|
+
.icon-warn { flex: none; color: var(--px-warn); }
|
|
1538
|
+
.icon-danger { flex: none; color: var(--px-danger); }
|
|
1539
|
+
.icon-muted { flex: none; color: var(--px-text-3); }
|
|
1540
|
+
.text-danger { color: var(--px-danger); }
|
|
1541
|
+
|
|
1542
|
+
.hold {
|
|
1543
|
+
display: flex;
|
|
1544
|
+
flex-wrap: wrap;
|
|
1545
|
+
align-items: center;
|
|
1546
|
+
gap: 8px 16px;
|
|
1547
|
+
padding: 14px 16px;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
.hold-into {
|
|
1551
|
+
display: inline-flex;
|
|
1552
|
+
align-items: center;
|
|
1553
|
+
gap: 8px;
|
|
1554
|
+
font-weight: 600;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
.hold-names {
|
|
1558
|
+
flex: 1 1 240px;
|
|
1559
|
+
min-width: 0;
|
|
1560
|
+
overflow-wrap: anywhere;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
.queue-foot {
|
|
1564
|
+
display: flex;
|
|
1565
|
+
flex-wrap: wrap;
|
|
1566
|
+
align-items: center;
|
|
1567
|
+
gap: 10px;
|
|
1568
|
+
padding: 12px 16px;
|
|
1569
|
+
background: var(--px-surface-2);
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
.queue-foot .px-subtle {
|
|
1573
|
+
flex: 1 1 16rem;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/* Bin */
|
|
1577
|
+
.bin-head {
|
|
1578
|
+
display: flex;
|
|
1579
|
+
flex-wrap: wrap;
|
|
1580
|
+
align-items: baseline;
|
|
1581
|
+
gap: 4px 12px;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
/* States */
|
|
1585
|
+
.skel-tile {
|
|
1586
|
+
aspect-ratio: 4 / 3;
|
|
1587
|
+
border-radius: var(--px-r-l);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
.skel-thumb { width: 64px; height: 44px; }
|
|
1591
|
+
.skel-line { height: 14px; width: 70%; }
|
|
1592
|
+
.skel-input { height: 38px; }
|
|
1593
|
+
|
|
1594
|
+
.empty {
|
|
1595
|
+
min-height: 260px;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
.empty-body {
|
|
1599
|
+
max-width: 34rem;
|
|
1600
|
+
font-size: 14px;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
.empty-actions {
|
|
1604
|
+
justify-content: center;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
.error-mark {
|
|
1608
|
+
width: 52px;
|
|
1609
|
+
height: 52px;
|
|
1610
|
+
border-radius: 50%;
|
|
1611
|
+
background: var(--px-danger-soft);
|
|
1612
|
+
color: var(--px-danger);
|
|
1613
|
+
display: grid;
|
|
1614
|
+
place-items: center;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/* Tiles */
|
|
1618
|
+
.pic {
|
|
1619
|
+
display: block;
|
|
1620
|
+
aspect-ratio: 4 / 3;
|
|
1621
|
+
background: var(--px-surface-2);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
.tile:hover {
|
|
1625
|
+
border-color: var(--px-border-strong);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
.tile.is-selected:hover {
|
|
1629
|
+
border-color: var(--px-accent);
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
.broken img {
|
|
1633
|
+
visibility: hidden;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.broken-note {
|
|
1637
|
+
position: absolute;
|
|
1638
|
+
inset: 0;
|
|
1639
|
+
display: grid;
|
|
1640
|
+
place-items: center;
|
|
1641
|
+
padding: 8px;
|
|
1642
|
+
text-align: center;
|
|
1643
|
+
font-size: var(--px-fs-xs);
|
|
1644
|
+
color: var(--px-text-3);
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/* List */
|
|
1648
|
+
.list {
|
|
1649
|
+
overflow-x: auto;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
.list-row {
|
|
1653
|
+
grid-template-columns: 64px minmax(0, 1.3fr) minmax(0, 2fr) minmax(0, 160px);
|
|
1654
|
+
min-width: 560px;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
.list-row:last-child {
|
|
1658
|
+
border-bottom: 0;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.list-row.is-current {
|
|
1662
|
+
background: var(--px-accent-soft);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
.list-pic {
|
|
1666
|
+
display: block;
|
|
1667
|
+
width: 64px;
|
|
1668
|
+
height: 44px;
|
|
1669
|
+
border-radius: var(--px-r-s);
|
|
1670
|
+
background: var(--px-surface-2);
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
.list-row.is-binned .list-pic {
|
|
1674
|
+
filter: grayscale(1);
|
|
1675
|
+
opacity: 0.55;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
.name-cell {
|
|
1679
|
+
min-width: 0;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
.open-row {
|
|
1683
|
+
display: block;
|
|
1684
|
+
max-width: 100%;
|
|
1685
|
+
min-height: var(--px-target);
|
|
1686
|
+
padding: 0;
|
|
1687
|
+
border: 0;
|
|
1688
|
+
background: none;
|
|
1689
|
+
font: inherit;
|
|
1690
|
+
font-size: 14px;
|
|
1691
|
+
font-weight: 600;
|
|
1692
|
+
color: var(--px-text);
|
|
1693
|
+
text-align: left;
|
|
1694
|
+
overflow: hidden;
|
|
1695
|
+
text-overflow: ellipsis;
|
|
1696
|
+
white-space: nowrap;
|
|
1697
|
+
cursor: pointer;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
.open-row:hover {
|
|
1701
|
+
color: var(--px-accent-text);
|
|
1702
|
+
text-decoration: underline;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
.alt-cell {
|
|
1706
|
+
display: flex;
|
|
1707
|
+
flex-direction: column;
|
|
1708
|
+
gap: 4px;
|
|
1709
|
+
min-width: 0;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
.alt {
|
|
1713
|
+
min-height: 38px;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
.alt.is-missing:not(:focus) {
|
|
1717
|
+
border-color: var(--px-warn);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
.read-only {
|
|
1721
|
+
display: flex;
|
|
1722
|
+
flex-wrap: wrap;
|
|
1723
|
+
align-items: center;
|
|
1724
|
+
gap: 6px;
|
|
1725
|
+
font-size: 14px;
|
|
1726
|
+
color: var(--px-text-2);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
.save-note {
|
|
1730
|
+
font-size: var(--px-fs-xs);
|
|
1731
|
+
color: var(--px-text-3);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
.more {
|
|
1735
|
+
display: flex;
|
|
1736
|
+
flex-direction: column;
|
|
1737
|
+
align-items: center;
|
|
1738
|
+
gap: 6px;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/* Dropping */
|
|
1742
|
+
.drop {
|
|
1743
|
+
position: absolute;
|
|
1744
|
+
inset: 0;
|
|
1745
|
+
z-index: 5;
|
|
1746
|
+
min-height: 220px;
|
|
1747
|
+
padding: 16px;
|
|
1748
|
+
border: 2px dashed var(--px-accent);
|
|
1749
|
+
border-radius: var(--px-r-l);
|
|
1750
|
+
background: var(--px-accent-soft);
|
|
1751
|
+
color: var(--px-accent-text);
|
|
1752
|
+
pointer-events: none;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
.drop-target {
|
|
1756
|
+
position: sticky;
|
|
1757
|
+
top: 30vh;
|
|
1758
|
+
display: flex;
|
|
1759
|
+
flex-direction: column;
|
|
1760
|
+
align-items: center;
|
|
1761
|
+
gap: 8px;
|
|
1762
|
+
text-align: center;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
.drop-hint {
|
|
1766
|
+
font-size: var(--px-fs-s);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
.sr-only {
|
|
1770
|
+
position: absolute;
|
|
1771
|
+
width: 1px;
|
|
1772
|
+
height: 1px;
|
|
1773
|
+
overflow: hidden;
|
|
1774
|
+
clip: rect(0 0 0 0);
|
|
1775
|
+
white-space: nowrap;
|
|
1776
|
+
}
|
|
1777
|
+
</style>
|