viur-ui 0.0.3 → 0.0.4

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/index.d.ts CHANGED
@@ -28,9 +28,13 @@ export interface ListFetchOptions {
28
28
  group?: string | null
29
29
  url?: string | null
30
30
  renderer?: string
31
+ /** pin the wire format, e.g. `2`/`"v2"` (default: unversioned endpoint) */
32
+ version?: string | number | null
31
33
  immediate?: boolean
32
34
  cached?: boolean
33
35
  ttl?: number
36
+ /** push failures to the message store (when one exists), default `true` */
37
+ messages?: boolean
34
38
  /** Extra headers for the LIST requests (not the structure) — object or
35
39
  * function, evaluated per request (e.g. X-VIUR-BONELIST). */
36
40
  headers?: Record<string, string> | (() => Record<string, string> | null) | null
@@ -295,7 +299,8 @@ export declare const BRAND_LIGHTNESS: [string, number][]
295
299
  export interface UploadFileOptions {
296
300
  target?: string
297
301
  publicUpload?: boolean
298
- renderer?: string
302
+ renderer?: string | null
303
+ version?: string | number | null
299
304
  }
300
305
 
301
306
  export declare function uploadFile(file: File, options?: UploadFileOptions): Promise<Record<string, any>>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viur-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/viur-framework/viur-ui"
@@ -258,7 +258,9 @@ function createControllerListFetch({ all = false, secure = false } = {}) {
258
258
  },
259
259
  })
260
260
 
261
- const { isFetching, isFinished, error, execute: _execute, abort } = useViurFetch(listUrl, { immediate }).json()
261
+ // all=true starts through our own execute() below, which loads every page
262
+ const fetchOptions = { immediate: immediate && !all }
263
+ const { isFetching, isFinished, error, execute: _execute, abort } = useViurFetch(listUrl, fetchOptions).json()
262
264
 
263
265
  /** Everything loaded: last response is in and no cursor left open. From here
264
266
  * on, sorting/filtering may run locally on the dataset. */
@@ -281,22 +283,16 @@ function createControllerListFetch({ all = false, secure = false } = {}) {
281
283
  reset,
282
284
  }
283
285
 
284
- // when all=true: automatically fetch next pages until cursor is empty
285
- watch(isFinished, async (finished) => {
286
- if (finished && all && cursor.value) {
287
- params.value = { ...params.value, cursor: cursor.value }
288
- _isNext = true
289
- listUrl.value = _buildUrl()
290
- try {
291
- await executeAndThrow(fetchResult, _execute)
292
- } catch {
293
- // already in `error`; rethrowing here would only be an unhandled rejection
294
- }
295
- }
296
- })
286
+ if (all && immediate) {
287
+ execute().catch(() => {
288
+ // already in `error`; rethrowing here would only be an unhandled rejection
289
+ })
290
+ }
297
291
 
298
- function execute() {
292
+ /** First page; with all=true it only resolves once every page is in. */
293
+ async function execute() {
299
294
  _generation++
295
+ const generation = _generation
300
296
  _isNext = false
301
297
  abort()
302
298
  data.value = []
@@ -306,7 +302,14 @@ function createControllerListFetch({ all = false, secure = false } = {}) {
306
302
  const { cursor: _, ...rest } = params.value
307
303
  params.value = rest
308
304
  listUrl.value = _buildUrl()
309
- return executeAndThrow(fetchResult, _execute)
305
+ try {
306
+ const result = await executeAndThrow(fetchResult, _execute)
307
+ // a newer execute()/reset() took over meanwhile — that one loads the rest
308
+ if (all && generation === _generation) await nextAll()
309
+ return result
310
+ } catch (error) {
311
+ throw error
312
+ }
310
313
  }
311
314
 
312
315
  /** Load one more page; detects the ViUR end (empty page with the same
@@ -346,8 +349,10 @@ function createControllerListFetch({ all = false, secure = false } = {}) {
346
349
 
347
350
  /** Load all remaining pages ("load everything"). */
348
351
  async function nextAll() {
352
+ const generation = _generation
349
353
  try {
350
- while (await _advance()) {
354
+ // stops when execute()/filter()/reset() restarts the list meanwhile
355
+ while (generation === _generation && (await _advance())) {
351
356
  /* until the end */
352
357
  }
353
358
  } catch (error) {
@@ -16,7 +16,8 @@ import { useConfigStore } from "../request/configStore.js"
16
16
  // and dark) as it does for any built-in brand color.
17
17
 
18
18
  /** Lightness (HSL, %) per brand step: the old admin's table (50 → 83 %, …,
19
- * 950 → 3 %), step by step on WebAwesome's steps (95 … 05). */
19
+ * 950 → 3 %), step by step on WebAwesome's steps (95 … 05) — except the
20
+ * lightest step, which is brighter (95 % instead of 83 %). */
20
21
  export const BRAND_LIGHTNESS = [
21
22
  ["95", 95],
22
23
  ["90", 78],