@marktiderman/genesis-core 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -1
- package/dist/{chunk-LGTXQTHA.js → chunk-2VJQVAJD.js} +3 -3
- package/dist/{chunk-LGTXQTHA.js.map → chunk-2VJQVAJD.js.map} +1 -1
- package/dist/chunk-2WS4LGYU.js +47 -0
- package/dist/chunk-2WS4LGYU.js.map +1 -0
- package/dist/{chunk-KXVDDDJY.js → chunk-3B5O36DU.js} +105 -13
- package/dist/chunk-3B5O36DU.js.map +1 -0
- package/dist/{chunk-EHFYSJJA.js → chunk-42QPCDQF.js} +3 -3
- package/dist/{chunk-EHFYSJJA.js.map → chunk-42QPCDQF.js.map} +1 -1
- package/dist/{chunk-RK365SO2.js → chunk-AKF2RAGX.js} +8 -5
- package/dist/chunk-AKF2RAGX.js.map +1 -0
- package/dist/{chunk-4ZR7472O.js → chunk-LOJGHR5O.js} +4 -4
- package/dist/{chunk-4ZR7472O.js.map → chunk-LOJGHR5O.js.map} +1 -1
- package/dist/{chunk-ON2V4RXX.js → chunk-OC4OGB2K.js} +19 -11
- package/dist/chunk-OC4OGB2K.js.map +1 -0
- package/dist/{chunk-HQAVDVIH.js → chunk-POMTRNAL.js} +4 -4
- package/dist/{chunk-HQAVDVIH.js.map → chunk-POMTRNAL.js.map} +1 -1
- package/dist/{chunk-VDEW4AOS.js → chunk-PSFKIG27.js} +55 -6
- package/dist/chunk-PSFKIG27.js.map +1 -0
- package/dist/{chunk-37RWGNIO.js → chunk-VFT6QKZW.js} +114 -5
- package/dist/chunk-VFT6QKZW.js.map +1 -0
- package/dist/{chunk-VDS6REM3.js → chunk-VJGU6E4U.js} +5 -5
- package/dist/{chunk-VDS6REM3.js.map → chunk-VJGU6E4U.js.map} +1 -1
- package/dist/{chunk-ZCE3CHPX.js → chunk-XVRIWP7B.js} +3 -3
- package/dist/{chunk-ZCE3CHPX.js.map → chunk-XVRIWP7B.js.map} +1 -1
- package/dist/{chunk-7FVTGKTX.js → chunk-YDMKMNDS.js} +2 -2
- package/dist/{chunk-7FVTGKTX.js.map → chunk-YDMKMNDS.js.map} +1 -1
- package/dist/{chunk-6WV6ST67.js → chunk-YNXLPOAB.js} +97 -10
- package/dist/chunk-YNXLPOAB.js.map +1 -0
- package/dist/{chunk-7GW3QR63.js → chunk-ZHC3MDCS.js} +101 -18
- package/dist/chunk-ZHC3MDCS.js.map +1 -0
- package/dist/conversation/index.d.ts +195 -0
- package/dist/conversation/index.js +110 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/csv.d.ts +1 -1
- package/dist/errors.js +1 -2
- package/dist/form-types.d.ts +1 -1
- package/dist/gallery/index.d.ts +79 -0
- package/dist/gallery/index.js +64 -0
- package/dist/gallery/index.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -4
- package/dist/hooks/index.js +18 -18
- package/dist/hooks/mutation-mode.d.ts +29 -2
- package/dist/hooks/mutation-mode.js +9 -4
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-capabilities.js +2 -2
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.js +4 -4
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-link-options.js +6 -6
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-live.js +3 -3
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-one.js +4 -4
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-relation-label.js +2 -2
- package/dist/hooks/use-resource-form.d.ts +14 -1
- package/dist/hooks/use-resource-form.js +12 -9
- package/dist/hooks/use-resource.d.ts +17 -3
- package/dist/hooks/use-resource.js +12 -8
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +21 -21
- package/dist/offline/index.d.ts +84 -0
- package/dist/offline/index.js +413 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/provider/index.d.ts +60 -7
- package/dist/provider/index.js +3 -3
- package/dist/resource-view/index.d.ts +79 -4
- package/dist/resource-view/index.js +141 -19
- package/dist/resource-view/index.js.map +1 -1
- package/dist/schema/index.d.ts +4 -3
- package/dist/schema/index.js +2 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-9WnGxZhj.d.ts → types-BzLv8yOm.d.ts} +8 -0
- package/dist/types-CsKSAKqs.d.ts +143 -0
- package/dist/{viewer-scope-bthEYSOB.d.ts → viewer-scope-Dx0N9AYk.d.ts} +3 -2
- package/dist/workspaces.d.ts +1 -1
- package/dist/{write-outcome-ZWlhhzRW.d.ts → write-outcome-DC5hORz-.d.ts} +1 -1
- package/dist/write-state-DVC4Yq9T.d.ts +58 -0
- package/package.json +15 -2
- package/dist/chunk-37RWGNIO.js.map +0 -1
- package/dist/chunk-6WV6ST67.js.map +0 -1
- package/dist/chunk-7GW3QR63.js.map +0 -1
- package/dist/chunk-KXVDDDJY.js.map +0 -1
- package/dist/chunk-ON2V4RXX.js.map +0 -1
- package/dist/chunk-PA6WJE5E.js +0 -115
- package/dist/chunk-PA6WJE5E.js.map +0 -1
- package/dist/chunk-RK365SO2.js.map +0 -1
- package/dist/chunk-VDEW4AOS.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/conversation/types.ts","../../src/conversation/format.ts","../../src/conversation/use-thread-jump.ts"],"names":[],"mappings":";;;AAmHO,IAAM,qBAAA,GAAgD,OAAO,MAAA,CAAO;AAAA,EACzE,GAAA,EAAK,KAAA;AAAA,EACL,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,iBAAA;AAAA,EACT,MAAA,EAAQ,iBAAA;AAAA,EACR,OAAA,EAAS,yBAAA;AAAA,EACT,QAAA,EAAU,4CAAA;AAAA,EACV,SAAA,EAAW,0BAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAA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A,EAAW,CAAA;AACnC,IAAA,MAAM,MAAA,GAAS,MAAM,UAAA,CAAW,CAAC,MAAO,CAAA,IAAK,CAAA,CAAE,EAAA,KAAO,EAAA,GAAK,EAAE,GAAG,CAAA,EAAG,KAAA,EAAO,QAAA,KAAa,CAAE,CAAA;AACzF,IAAA,KAAK,OAAO,OAAA,CAAQ,SAAA,CAAU,EAAE,CAAA,CAAE,IAAA,CAAK,QAAQ,MAAM,CAAA;AAAA,EACvD,GAAG,CAAC,OAAA,EAAS,OAAA,EAAS,GAAA,EAAK,EAAE,CAAC,CAAA;AAE9B,EAAA,OAAO,EAAE,aAAA,EAAe,OAAA,EAAS,OAAA,KAAY,IAAA,EAAK;AACpD","file":"index.js","sourcesContent":["/**\n * The conversation contract: what a thread, its messages, its composer and an\n * inbox row are, for web (genesis-ui) and native (genesis-ui-native) alike.\n * One description serves both: the same `ThreadMessage[]` renders in ui's\n * `ThreadPage` and ui-native's `ThreadPage`, and genesis-chat, the help desk\n * or an app's own thread feed either.\n *\n * Data, not behaviour: a row's send state (`status`) and its actions come in\n * from whatever owns the data (an outbox, the offline queue, the server), and\n * the layouts never fetch. Ids stay the same across refreshes (a cache, then\n * the server): pass `clientId ?? serverId` as `id`.\n *\n * @stability Beta\n */\nimport type { ReactNode } from \"react\";\n\nexport interface ThreadAttachment {\n id: string;\n /** An image URI (a signed URL, a file:// path). */\n uri: string;\n width?: number;\n height?: number;\n accessibilityLabel?: string;\n onPress?: () => void;\n}\n\n/**\n * Where a message is on its way. `sending` (in flight), `sent`, `pending`\n * (queued: offline), `paused` (the session expired: sign in to send),\n * `failed` and `conflict` (changed elsewhere) with `onRetry` / `onDiscard`.\n */\nexport type ThreadMessageStatus = \"sending\" | \"sent\" | \"pending\" | \"paused\" | \"failed\" | \"conflict\";\n\n/** How a message reads: `default`, or `internal` (a staff-only note, never mistaken for a reply). */\nexport type MessageTone = \"default\" | \"internal\";\n\nexport interface ThreadMessage {\n /** Stays the same across refreshes, or the list jumps. */\n id: string;\n /** `event`: a centred line between messages (\"Sam was assigned\"); `body` is its text. Default `message`. */\n kind?: \"message\" | \"event\";\n body: string;\n /** Sent by the person using the app: trailing side, tint. */\n mine: boolean;\n /** Shown over theirs (\"Support\"); never over mine. */\n authorName?: string;\n timestamp: string | Date;\n status?: ThreadMessageStatus;\n onRetry?: () => void;\n onDiscard?: () => void;\n /** `internal`: a staff-only note, tinted so it never reads like a reply. */\n tone?: MessageTone;\n attachments?: ThreadAttachment[];\n}\n\n/** How a composer mode reads. The same tones as a message. */\nexport type ComposerTone = MessageTone;\n\nexport interface ComposerMode {\n id: string;\n label: string;\n tone?: ComposerTone;\n}\n\nexport interface ThreadComposer {\n value: string;\n onChangeText: (text: string) => void;\n onSend: () => void;\n /** A send is in flight: the button spins and won't send twice. */\n sending?: boolean;\n placeholder?: string;\n sendLabel?: string;\n /** Turns the send button off (besides an empty or blank value). */\n disabled?: boolean;\n maxLength?: number;\n /** Said while sending. Default `labels.sending`. */\n sendingLabel?: string;\n /** Above the input: a reply preview, attachments waiting to send. */\n above?: ReactNode;\n /** Beside send: a mic. */\n trailing?: ReactNode;\n /** The input grows to this many lines, then scrolls. Default 6. */\n maxLines?: number;\n /** Ways to send (\"Reply\", \"Internal note\"); two or more show the picker. */\n modes?: readonly ComposerMode[];\n mode?: string;\n onModeChange?: (id: string) => void;\n}\n\n/** What the default parts of a thread say. */\nexport interface ThreadLabels {\n /** Who \"mine\" is, to a screen reader. */\n you: string;\n sending: string;\n /** Queued while offline. */\n pending: string;\n /** The session expired. */\n paused: string;\n notSent: string;\n /** Changed somewhere else before it was sent. */\n conflict: string;\n retryHint: string;\n discard: string;\n /** The first unread message's divider. */\n newMessages: string;\n /** The pill that goes back to the newest message. */\n jumpToLatest: string;\n /** While `updating`. */\n updating: string;\n /** Said with an internal note, so a screen reader never reads it as a reply. */\n internal: string;\n /** Said when a `jumpTo` message can't be found. */\n messageGone: string;\n}\n\nexport const DEFAULT_THREAD_LABELS: Readonly<ThreadLabels> = Object.freeze({\n you: \"You\",\n sending: \"Sending\",\n pending: \"Waiting to send\",\n paused: \"Sign in to send\",\n notSent: \"Not sent. Tap to retry.\",\n conflict: \"Not sent: changed elsewhere. Tap to retry.\",\n retryHint: \"Double tap to send again\",\n discard: \"Discard\",\n newMessages: \"New messages\",\n jumpToLatest: \"Jump to latest\",\n updating: \"Updating…\",\n internal: \"Internal note\",\n messageGone: \"That message isn't available.\",\n});\n\n/** An action on an inbox row: a swipe, a long press or context menu, an accessibility action. */\nexport interface InboxSwipeAction {\n id: string;\n label: string;\n onPress: () => void;\n /** Destructive tone (delete, leave). */\n destructive?: boolean;\n}\n\nexport interface InboxItem {\n /** Stable id for keying. */\n id: string;\n title: string;\n /** The latest message or a summary, at most two lines. */\n preview?: string;\n /** When it last changed. Shown as a short time or date. */\n timestamp?: string | Date;\n /** Something new the person hasn't read: a dot, and the title in bold. */\n unread?: boolean;\n /** How many unread messages; shown as a count instead of the dot when above 0. */\n unreadCount?: number;\n /** A short status shown under the preview (\"In progress\", \"12 votes\"). */\n meta?: string;\n /** Replaces the unread dot (an icon). For a picture of who it is, use `avatar`, which keeps the dot. */\n leading?: ReactNode;\n /**\n * A picture of who or what it is (an avatar, about 40px), between the\n * unread dot and the text. It is hidden from screen readers; when it shows\n * someone `title` doesn't name, say who in `avatarLabel`.\n */\n avatar?: ReactNode;\n /** Who the avatar shows, read before the title, when `title` doesn't name them. */\n avatarLabel?: string;\n /** Shown at the end of the row (a vote button, a badge). Replaces the chevron. */\n trailing?: ReactNode;\n /** Opens the conversation. */\n onPress?: () => void;\n /** Swipe actions on native; a row menu on web. Always reachable as accessibility actions. */\n swipeActions?: InboxSwipeAction[];\n /** The row is the conversation open beside the list (a 3-pane inbox). */\n selected?: boolean;\n /** testID override. Default `<page testID>-row-<id>`. */\n testID?: string;\n}\n","/**\n * The conversation contract's shared logic: which message shows the read\n * receipt, and how an inbox row's time reads. Platform-neutral.\n *\n * @stability Beta\n */\nimport type { ThreadMessage } from \"./types\";\n\nconst toDate = (value: string | Date) => (typeof value === \"string\" ? new Date(value) : value);\n\n/** Sent and delivered: a read receipt can mark it. */\nexport const isDelivered = (m: ThreadMessage): boolean => m.status === undefined || m.status === \"sent\";\n\n/** The newest of my messages the other side has read, or null. Events and undelivered messages never count. */\nexport function readReceiptFor(messages: readonly ThreadMessage[], readAt: string | Date | null | undefined): string | null {\n if (!readAt) return null;\n const read = toDate(readAt).getTime();\n for (let i = messages.length - 1; i >= 0; i--) {\n const m = messages[i]!;\n if (m.kind !== \"event\" && m.mine && isDelivered(m) && toDate(m.timestamp).getTime() <= read) return m.id;\n }\n return null;\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\n/** The default inbox row time: `9:41`, `Yesterday`, `Monday`, then a short date. */\nexport function formatInboxTime(date: Date, now: Date): string {\n const start = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();\n const days = Math.round((start(now) - start(date)) / DAY_MS);\n if (days <= 0) return date.toLocaleTimeString(undefined, { hour: \"numeric\", minute: \"2-digit\" });\n if (days === 1) return \"Yesterday\";\n if (days < 7) return date.toLocaleDateString(undefined, { weekday: \"long\" });\n return date.toLocaleDateString(undefined, { day: \"numeric\", month: \"short\", year: date.getFullYear() === now.getFullYear() ? undefined : \"numeric\" });\n}\n\n/** The default message time: \"Oct 24, 9:41 AM\". */\nexport function formatMessageTime(date: Date): string {\n return date.toLocaleString(undefined, { month: \"short\", day: \"numeric\", hour: \"numeric\", minute: \"2-digit\" });\n}\n","/**\n * useThreadJump — going to one row of a thread (a search result, a pinned\n * message, the first unread): load earlier pages until the row is held, then\n * scroll to it and highlight it for two seconds. A row that can't be found\n * says so.\n *\n * Promoted from genesis-chat's `useJumpToMessage` (G4), generalised from\n * chat's sequence numbers to row ids. It's a state machine driven by the\n * rows, not a one-shot: a target set before the first page has loaded waits\n * for `loading` to end, a row that arrives a render or two after `loadUntil`\n * resolves is still found, and going to the same id again (after `null`)\n * goes again.\n *\n * @stability Beta\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport interface UseThreadJumpOptions {\n /** The row to go to; `null` clears it, and a new id (or the same one after `null`) starts again. */\n target: string | null | undefined;\n /** Whether the row is held now. */\n has: (id: string) => boolean;\n /** The first page is still loading: don't start until it's in. */\n loading?: boolean | undefined;\n /** Load earlier pages until the row is held; resolve false when it can't be. Without it, a row not held is gone. */\n loadUntil?: ((id: string) => Promise<boolean>) | undefined;\n /** Scroll to the row. */\n scrollTo: (id: string) => void;\n /** Before loading or scrolling (stop following the bottom). */\n onStart?: (() => void) | undefined;\n /** Scrolled to it (say so to VoiceOver). */\n onLanded?: ((id: string) => void) | undefined;\n /** It isn't there (go back to where the thread was). */\n onGone?: ((id: string) => void) | undefined;\n}\n\ntype Pending = { id: string; phase: \"new\" | \"loading\" | \"loaded\" };\n\n/** After `loadUntil` resolves, how long the rows have to arrive before the row counts as gone. */\nexport const JUMP_SETTLE_MS = 400;\n\nexport function useThreadJump({ target, has, loading = false, loadUntil, scrollTo, onStart, onLanded, onGone }: UseThreadJumpOptions) {\n const [pending, setPending] = useState<Pending | null>(target ? { id: target, phase: \"new\" } : null);\n const [highlightedId, setHighlightedId] = useState<string | null>(null);\n const armed = useRef<Pending | null>(null);\n const goneTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => {\n if (target) setPending({ id: target, phase: \"new\" });\n else {\n // null cancels a jump in progress.\n if (goneTimerRef.current) clearTimeout(goneTimerRef.current);\n armed.current = null;\n setPending(null);\n }\n }, [target]);\n\n const latest = useRef({ scrollTo, onStart, onLanded, onGone, loadUntil });\n latest.current = { scrollTo, onStart, onLanded, onGone, loadUntil };\n const highlightTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const goneTimer = goneTimerRef;\n useEffect(\n () => () => {\n if (highlightTimer.current) clearTimeout(highlightTimer.current);\n if (goneTimer.current) clearTimeout(goneTimer.current);\n },\n [],\n );\n\n const go = useCallback((id: string) => {\n latest.current.onStart?.();\n latest.current.scrollTo(id);\n latest.current.onLanded?.(id);\n setHighlightedId(id);\n if (highlightTimer.current) clearTimeout(highlightTimer.current);\n highlightTimer.current = setTimeout(() => setHighlightedId((h) => (h === id ? null : h)), 2000);\n }, []);\n\n useEffect(() => {\n if (!pending || loading) return;\n const { id, phase } = pending;\n if (has(id)) {\n if (goneTimer.current) clearTimeout(goneTimer.current);\n setPending(null);\n go(id);\n return;\n }\n if (phase === \"loading\") return;\n if (phase === \"loaded\" || !latest.current.loadUntil) {\n // The rows may reach the list a render or two after the load resolved: give them a moment,\n // once per pending jump (new rows arriving in a busy thread don't restart it).\n if (armed.current === pending) return;\n armed.current = pending;\n if (goneTimer.current) clearTimeout(goneTimer.current);\n goneTimer.current = setTimeout(\n () => {\n setPending((p) => (p && p.id === id ? null : p));\n latest.current.onGone?.(id);\n },\n phase === \"loaded\" ? JUMP_SETTLE_MS : 0,\n );\n return;\n }\n latest.current.onStart?.();\n setPending({ id, phase: \"loading\" });\n const settle = () => setPending((p) => (p && p.id === id ? { ...p, phase: \"loaded\" } : p));\n void latest.current.loadUntil(id).then(settle, settle);\n }, [pending, loading, has, go]);\n\n return { highlightedId, jumping: pending !== null };\n}\n"]}
|
package/dist/csv.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, F as FieldSchema, S as SortParam, a as FilterParam } from './types-
|
|
1
|
+
import { D as DataProvider, F as FieldSchema, S as SortParam, a as FilterParam } from './types-BzLv8yOm.js';
|
|
2
2
|
|
|
3
3
|
/** RFC 4180 field: quoted when it holds a comma, quote or line break. */
|
|
4
4
|
declare function csvField(value: unknown): string;
|
package/dist/errors.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, isDevelopment, reportError, setErrorReporter } from './chunk-
|
|
2
|
-
import './chunk-PA6WJE5E.js';
|
|
1
|
+
export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, isDevelopment, reportError, setErrorReporter } from './chunk-VFT6QKZW.js';
|
|
3
2
|
import './chunk-HUNGCTRA.js';
|
|
4
3
|
import './chunk-RYEXWQFD.js';
|
|
5
4
|
import './chunk-LG6TUBVM.js';
|
package/dist/form-types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { m as FieldType, y as ResourceFormFieldDef, T as SelectOption } from './types-
|
|
1
|
+
export { m as FieldType, y as ResourceFormFieldDef, T as SelectOption } from './types-BzLv8yOm.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gallery's data and layout, the same on every platform: one image's shape, the defaults, and
|
|
3
|
+
* the justified-rows packing. genesis-ui's `GalleryGrid` and genesis-ui-native's
|
|
4
|
+
* `NativeGalleryGrid` both lay out with `justifyRows` from here, as does ResourceView's
|
|
5
|
+
* `mode="grid"` over a view's `gallery` block, so the same items pack into the same rows anywhere.
|
|
6
|
+
*
|
|
7
|
+
* Pure: no React, no DOM.
|
|
8
|
+
*
|
|
9
|
+
* @stability Beta
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* One image in a gallery. Shared by `GalleryGrid`, `Lightbox` and their native twins, so a
|
|
13
|
+
* consumer passes the same array to the grid and to the viewer it opens.
|
|
14
|
+
*
|
|
15
|
+
* `width`/`height` are the image's intrinsic pixel size when known; the justified layout uses
|
|
16
|
+
* their ratio to pack rows and falls back to 4:3 when they are absent.
|
|
17
|
+
*
|
|
18
|
+
* @stability Beta
|
|
19
|
+
*/
|
|
20
|
+
interface GalleryItem {
|
|
21
|
+
id: string;
|
|
22
|
+
src: string;
|
|
23
|
+
alt?: string;
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
caption?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The gallery's defaults, the same on web and native: a target row height and the space between
|
|
30
|
+
* tiles (px on web, points on native), and the columns of `layout="grid"`.
|
|
31
|
+
*
|
|
32
|
+
* @stability Beta
|
|
33
|
+
*/
|
|
34
|
+
declare const GALLERY_DEFAULTS: {
|
|
35
|
+
readonly rowHeight: 180;
|
|
36
|
+
readonly gap: 4;
|
|
37
|
+
readonly columns: 3;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A `layout="grid"` tile's shape: a ratio (width / height; 1 is square, the default), or `"item"`
|
|
41
|
+
* for each item's own (its `width`/`height`, 4:3 when unknown).
|
|
42
|
+
*
|
|
43
|
+
* @stability Beta
|
|
44
|
+
*/
|
|
45
|
+
type GalleryTileAspect = number | "item";
|
|
46
|
+
/** Used when an item has no `width`/`height` (or a degenerate one). */
|
|
47
|
+
declare const DEFAULT_GALLERY_RATIO: number;
|
|
48
|
+
interface JustifiedTile {
|
|
49
|
+
item: GalleryItem;
|
|
50
|
+
/** Index of `item` in the input array. */
|
|
51
|
+
index: number;
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
}
|
|
55
|
+
interface JustifiedRow {
|
|
56
|
+
tiles: JustifiedTile[];
|
|
57
|
+
/** The row's height after scaling to fill the container. */
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
/** Width ÷ height of an item, falling back to 4:3. */
|
|
61
|
+
declare function galleryItemRatio(item: GalleryItem): number;
|
|
62
|
+
/**
|
|
63
|
+
* Pack `items` into rows of a target `rowHeight`, then scale each row so its
|
|
64
|
+
* tiles exactly fill `containerWidth` (minus `gap` between tiles). Pure: same
|
|
65
|
+
* input, same rows.
|
|
66
|
+
*
|
|
67
|
+
* Greedy, as in the classic justified-gallery algorithm: tiles are added at
|
|
68
|
+
* the target height until the row would overflow; the row is then closed at
|
|
69
|
+
* whichever of "with" / "without" the overflowing tile is nearer the target
|
|
70
|
+
* width, and scaled to fit. The last row is scaled too, but never above the
|
|
71
|
+
* target height (a single landscape photo in the last row should not fill
|
|
72
|
+
* the width as a banner); it is left-aligned at the target height instead.
|
|
73
|
+
*
|
|
74
|
+
* `containerWidth <= 0` (not measured yet) yields no rows, so callers render
|
|
75
|
+
* nothing rather than divide by zero.
|
|
76
|
+
*/
|
|
77
|
+
declare function justifyRows(items: readonly GalleryItem[], containerWidth: number, rowHeight: number, gap: number): JustifiedRow[];
|
|
78
|
+
|
|
79
|
+
export { DEFAULT_GALLERY_RATIO, GALLERY_DEFAULTS, type GalleryItem, type GalleryTileAspect, type JustifiedRow, type JustifiedTile, galleryItemRatio, justifyRows };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/gallery/index.ts
|
|
2
|
+
var GALLERY_DEFAULTS = { rowHeight: 180, gap: 4, columns: 3 };
|
|
3
|
+
var DEFAULT_GALLERY_RATIO = 4 / 3;
|
|
4
|
+
function galleryItemRatio(item) {
|
|
5
|
+
const { width, height } = item;
|
|
6
|
+
if (typeof width === "number" && typeof height === "number" && Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) {
|
|
7
|
+
return width / height;
|
|
8
|
+
}
|
|
9
|
+
return DEFAULT_GALLERY_RATIO;
|
|
10
|
+
}
|
|
11
|
+
function justifyRows(items, containerWidth, rowHeight, gap) {
|
|
12
|
+
if (!(containerWidth > 0) || !(rowHeight > 0) || items.length === 0) return [];
|
|
13
|
+
const spacing = Math.max(0, gap);
|
|
14
|
+
const rows = [];
|
|
15
|
+
let pending = [];
|
|
16
|
+
let pendingWidth = 0;
|
|
17
|
+
const rowWidthWithGaps = (tiles, widthSum) => widthSum + spacing * Math.max(0, tiles.length - 1);
|
|
18
|
+
const close = (tiles, widthSum, capAtTarget) => {
|
|
19
|
+
if (tiles.length === 0) return;
|
|
20
|
+
const available = containerWidth - spacing * (tiles.length - 1);
|
|
21
|
+
let scale = available > 0 ? available / widthSum : 1;
|
|
22
|
+
if (capAtTarget && scale > 1) scale = 1;
|
|
23
|
+
rows.push({
|
|
24
|
+
height: rowHeight * scale,
|
|
25
|
+
tiles: tiles.map((t) => ({
|
|
26
|
+
...t,
|
|
27
|
+
width: t.width * scale,
|
|
28
|
+
height: t.height * scale
|
|
29
|
+
}))
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
items.forEach((item, index) => {
|
|
33
|
+
const tile = {
|
|
34
|
+
item,
|
|
35
|
+
index,
|
|
36
|
+
width: galleryItemRatio(item) * rowHeight,
|
|
37
|
+
height: rowHeight
|
|
38
|
+
};
|
|
39
|
+
const withTile = [...pending, tile];
|
|
40
|
+
const withTileWidth = rowWidthWithGaps(withTile, pendingWidth + tile.width);
|
|
41
|
+
if (withTileWidth < containerWidth) {
|
|
42
|
+
pending = withTile;
|
|
43
|
+
pendingWidth += tile.width;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const withoutWidth = rowWidthWithGaps(pending, pendingWidth);
|
|
47
|
+
const keep = pending.length === 0 || Math.abs(withTileWidth - containerWidth) <= Math.abs(containerWidth - withoutWidth);
|
|
48
|
+
if (keep) {
|
|
49
|
+
close(withTile, pendingWidth + tile.width, false);
|
|
50
|
+
pending = [];
|
|
51
|
+
pendingWidth = 0;
|
|
52
|
+
} else {
|
|
53
|
+
close(pending, pendingWidth, false);
|
|
54
|
+
pending = [tile];
|
|
55
|
+
pendingWidth = tile.width;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
close(pending, pendingWidth, true);
|
|
59
|
+
return rows;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { DEFAULT_GALLERY_RATIO, GALLERY_DEFAULTS, galleryItemRatio, justifyRows };
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/gallery/index.ts"],"names":[],"mappings":";AAmCO,IAAM,mBAAmB,EAAE,SAAA,EAAW,KAAK,GAAA,EAAK,CAAA,EAAG,SAAS,CAAA;AAW5D,IAAM,wBAAwB,CAAA,GAAI;AAiBlC,SAAS,iBAAiB,IAAA,EAA2B;AAC1D,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAO,GA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A,KAAA,CAAM,OAAA,EAAS,cAAc,KAAK,CAAA;AAClC,MAAA,OAAA,GAAU,CAAC,IAAI,CAAA;AACf,MAAA,YAAA,GAAe,IAAA,CAAK,KAAA;AAAA,IACtB;AAAA,EACF,CAAC,CAAA;AAED,EAAA,KAAA,CAAM,OAAA,EAAS,cAAc,IAAI,CAAA;AACjC,EAAA,OAAO,IAAA;AACT","file":"index.js","sourcesContent":["/**\n * The gallery's data and layout, the same on every platform: one image's shape, the defaults, and\n * the justified-rows packing. genesis-ui's `GalleryGrid` and genesis-ui-native's\n * `NativeGalleryGrid` both lay out with `justifyRows` from here, as does ResourceView's\n * `mode=\"grid\"` over a view's `gallery` block, so the same items pack into the same rows anywhere.\n *\n * Pure: no React, no DOM.\n *\n * @stability Beta\n */\n\n/**\n * One image in a gallery. Shared by `GalleryGrid`, `Lightbox` and their native twins, so a\n * consumer passes the same array to the grid and to the viewer it opens.\n *\n * `width`/`height` are the image's intrinsic pixel size when known; the justified layout uses\n * their ratio to pack rows and falls back to 4:3 when they are absent.\n *\n * @stability Beta\n */\nexport interface GalleryItem {\n id: string;\n src: string;\n alt?: string;\n width?: number;\n height?: number;\n caption?: string;\n}\n\n/**\n * The gallery's defaults, the same on web and native: a target row height and the space between\n * tiles (px on web, points on native), and the columns of `layout=\"grid\"`.\n *\n * @stability Beta\n */\nexport const GALLERY_DEFAULTS = { rowHeight: 180, gap: 4, columns: 3 } as const;\n\n/**\n * A `layout=\"grid\"` tile's shape: a ratio (width / height; 1 is square, the default), or `\"item\"`\n * for each item's own (its `width`/`height`, 4:3 when unknown).\n *\n * @stability Beta\n */\nexport type GalleryTileAspect = number | \"item\";\n\n/** Used when an item has no `width`/`height` (or a degenerate one). */\nexport const DEFAULT_GALLERY_RATIO = 4 / 3;\n\nexport interface JustifiedTile {\n item: GalleryItem;\n /** Index of `item` in the input array. */\n index: number;\n width: number;\n height: number;\n}\n\nexport interface JustifiedRow {\n tiles: JustifiedTile[];\n /** The row's height after scaling to fill the container. */\n height: number;\n}\n\n/** Width ÷ height of an item, falling back to 4:3. */\nexport function galleryItemRatio(item: GalleryItem): number {\n const { width, height } = item;\n if (\n typeof width === \"number\" &&\n typeof height === \"number\" &&\n Number.isFinite(width) &&\n Number.isFinite(height) &&\n width > 0 &&\n height > 0\n ) {\n return width / height;\n }\n return DEFAULT_GALLERY_RATIO;\n}\n\n/**\n * Pack `items` into rows of a target `rowHeight`, then scale each row so its\n * tiles exactly fill `containerWidth` (minus `gap` between tiles). Pure: same\n * input, same rows.\n *\n * Greedy, as in the classic justified-gallery algorithm: tiles are added at\n * the target height until the row would overflow; the row is then closed at\n * whichever of \"with\" / \"without\" the overflowing tile is nearer the target\n * width, and scaled to fit. The last row is scaled too, but never above the\n * target height (a single landscape photo in the last row should not fill\n * the width as a banner); it is left-aligned at the target height instead.\n *\n * `containerWidth <= 0` (not measured yet) yields no rows, so callers render\n * nothing rather than divide by zero.\n */\nexport function justifyRows(\n items: readonly GalleryItem[],\n containerWidth: number,\n rowHeight: number,\n gap: number,\n): JustifiedRow[] {\n if (!(containerWidth > 0) || !(rowHeight > 0) || items.length === 0) return [];\n const spacing = Math.max(0, gap);\n\n const rows: JustifiedRow[] = [];\n let pending: JustifiedTile[] = [];\n let pendingWidth = 0; // tile widths only, no gaps\n\n const rowWidthWithGaps = (tiles: JustifiedTile[], widthSum: number) =>\n widthSum + spacing * Math.max(0, tiles.length - 1);\n\n const close = (tiles: JustifiedTile[], widthSum: number, capAtTarget: boolean) => {\n if (tiles.length === 0) return;\n const available = containerWidth - spacing * (tiles.length - 1);\n let scale = available > 0 ? available / widthSum : 1;\n if (capAtTarget && scale > 1) scale = 1;\n rows.push({\n height: rowHeight * scale,\n tiles: tiles.map((t) => ({\n ...t,\n width: t.width * scale,\n height: t.height * scale,\n })),\n });\n };\n\n items.forEach((item, index) => {\n const tile: JustifiedTile = {\n item,\n index,\n width: galleryItemRatio(item) * rowHeight,\n height: rowHeight,\n };\n const withTile = [...pending, tile];\n const withTileWidth = rowWidthWithGaps(withTile, pendingWidth + tile.width);\n\n if (withTileWidth < containerWidth) {\n pending = withTile;\n pendingWidth += tile.width;\n return;\n }\n\n // Overflow. Close the row with or without this tile, whichever is closer\n // to the container width; a row must hold at least one tile.\n const withoutWidth = rowWidthWithGaps(pending, pendingWidth);\n const keep =\n pending.length === 0 ||\n Math.abs(withTileWidth - containerWidth) <= Math.abs(containerWidth - withoutWidth);\n\n if (keep) {\n close(withTile, pendingWidth + tile.width, false);\n pending = [];\n pendingWidth = 0;\n } else {\n close(pending, pendingWidth, false);\n pending = [tile];\n pendingWidth = tile.width;\n }\n });\n\n close(pending, pendingWidth, true);\n return rows;\n}\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { UseResourceOptions, UseResourceReturn, useResource } from './use-resource.js';
|
|
1
|
+
export { UpdateOptions, UseResourceOptions, UseResourceReturn, useResource } from './use-resource.js';
|
|
2
2
|
export { UseOneOptions, useOne } from './use-one.js';
|
|
3
3
|
export { UseRelationLabelOptions, loadRelationLabel, relationNamingField, useRelationLabel } from './use-relation-label.js';
|
|
4
4
|
export { LinkOption, LinkTarget, UseLinkOptionsOptions, UseLinkOptionsReturn, useLinkOptions } from './use-link-options.js';
|
|
@@ -7,8 +7,8 @@ export { useCapabilities } from './use-capabilities.js';
|
|
|
7
7
|
export { UseWriteOptions, UseWriteReturn, WRITE_FAILED, useWrite } from './use-write.js';
|
|
8
8
|
export { UseDraftReturn, useDraft } from './use-draft.js';
|
|
9
9
|
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftAdoption, DraftController, DraftOptions, DraftSeed, DraftState, DraftStatus, DraftValue, isNetworkFailure, stableJson } from './draft-controller.js';
|
|
10
|
-
import { c as ViewerScopeProps } from '../viewer-scope-
|
|
11
|
-
export { G as GenesisViewerRoles, N as NO_VIEWER, R as ResourceScope, V as Viewer, a as ViewerContext, b as ViewerScope, d as clearViewerCache, s as scopeClock, u as useOptionalViewerScope, e as useViewer, f as useViewerScope } from '../viewer-scope-
|
|
10
|
+
import { c as ViewerScopeProps } from '../viewer-scope-Dx0N9AYk.js';
|
|
11
|
+
export { G as GenesisViewerRoles, N as NO_VIEWER, R as ResourceScope, V as Viewer, a as ViewerContext, b as ViewerScope, d as clearViewerCache, s as scopeClock, u as useOptionalViewerScope, e as useViewer, f as useViewerScope } from '../viewer-scope-Dx0N9AYk.js';
|
|
12
12
|
import * as react from 'react';
|
|
13
13
|
import { Workspace, WorkspaceHrefOptions } from '../workspaces.js';
|
|
14
14
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, LiveOptions, useLiveInvalidation } from './use-live.js';
|
|
@@ -17,9 +17,10 @@ export { UseWizardReturn, WizardStep, useWizard } from './use-wizard.js';
|
|
|
17
17
|
export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './mutation-mode.js';
|
|
18
18
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './use-unsaved-changes-guard.js';
|
|
19
19
|
import '@tanstack/react-query';
|
|
20
|
-
import '../types-
|
|
20
|
+
import '../types-BzLv8yOm.js';
|
|
21
21
|
import '../dates.js';
|
|
22
22
|
import 'react-hook-form';
|
|
23
|
+
import '../write-state-DVC4Yq9T.js';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* The workspace the viewer is in, and where each of their others is from here.
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-
|
|
2
|
-
export {
|
|
1
|
+
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-AKF2RAGX.js';
|
|
2
|
+
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
3
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-3B5O36DU.js';
|
|
4
|
+
import '../chunk-2WS4LGYU.js';
|
|
5
|
+
export { useResource } from '../chunk-OC4OGB2K.js';
|
|
6
|
+
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from '../chunk-RVWKVD5Q.js';
|
|
3
7
|
export { useWizard } from '../chunk-7KOLYF27.js';
|
|
4
8
|
export { WRITE_FAILED, useWrite } from '../chunk-52T2EYXH.js';
|
|
5
|
-
|
|
9
|
+
import '../chunk-7NUL32W7.js';
|
|
6
10
|
export { useDraft } from '../chunk-YQBWXG2G.js';
|
|
7
|
-
export { useLinkOptions } from '../chunk-
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { useOne } from '../chunk-4ZR7472O.js';
|
|
13
|
-
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-ZCE3CHPX.js';
|
|
11
|
+
export { useLinkOptions } from '../chunk-VJGU6E4U.js';
|
|
12
|
+
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-42QPCDQF.js';
|
|
13
|
+
export { useInfiniteResource } from '../chunk-POMTRNAL.js';
|
|
14
|
+
export { useOne } from '../chunk-LOJGHR5O.js';
|
|
15
|
+
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-XVRIWP7B.js';
|
|
14
16
|
import '../chunk-UHOMTFBD.js';
|
|
15
17
|
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from '../chunk-HBAPYA5K.js';
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
|
|
18
|
+
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from '../chunk-YNXLPOAB.js';
|
|
19
|
+
export { useCapabilities } from '../chunk-2VJQVAJD.js';
|
|
20
|
+
import '../chunk-AJGVLF37.js';
|
|
19
21
|
import '../chunk-7PUFVNPB.js';
|
|
20
|
-
import '../chunk-
|
|
22
|
+
import '../chunk-PSFKIG27.js';
|
|
21
23
|
import '../chunk-ZYJUEJ4Z.js';
|
|
22
|
-
import '../chunk-
|
|
23
|
-
import '../chunk-7NUL32W7.js';
|
|
24
|
+
import '../chunk-AUVKRXRC.js';
|
|
24
25
|
import '../chunk-WXENWPWP.js';
|
|
25
|
-
import '../chunk-
|
|
26
|
-
import '../chunk-PA6WJE5E.js';
|
|
26
|
+
import '../chunk-VFT6QKZW.js';
|
|
27
27
|
import '../chunk-HUNGCTRA.js';
|
|
28
28
|
import '../chunk-RYEXWQFD.js';
|
|
29
29
|
import '../chunk-LG6TUBVM.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-
|
|
2
|
+
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
type MutationMode = "pessimistic" | "optimistic" | "undoable";
|
|
5
5
|
/** How long an `undoable` write waits for an undo before it is sent. */
|
|
@@ -73,6 +73,16 @@ interface SendContext {
|
|
|
73
73
|
data?: Record<string, unknown>;
|
|
74
74
|
/** The page is unloading: pass `keepalive: true` to the provider. */
|
|
75
75
|
keepalive: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The version of the row this write was made on (`base`, else the cached
|
|
78
|
+
* row when the write was made), or, for a write made behind another on the
|
|
79
|
+
* same record, the version that one committed at. The field is the one the
|
|
80
|
+
* provider's capabilities name (`version`). Pass it as `expectedVersion`, so
|
|
81
|
+
* a write made on a stale copy is refused as a `conflict`. Undefined when
|
|
82
|
+
* the resource has no version or the row isn't known: send the write
|
|
83
|
+
* unchecked, as before.
|
|
84
|
+
*/
|
|
85
|
+
expectedVersion?: string;
|
|
76
86
|
}
|
|
77
87
|
interface ExecuteWriteArgs<R extends BaseRecord | void> {
|
|
78
88
|
queryClient: QueryClient;
|
|
@@ -85,6 +95,18 @@ interface ExecuteWriteArgs<R extends BaseRecord | void> {
|
|
|
85
95
|
* nothing, e.g. when the values are form-shaped and the row is not.
|
|
86
96
|
*/
|
|
87
97
|
data?: Record<string, unknown>;
|
|
98
|
+
/**
|
|
99
|
+
* The row as the person saw it when they made this change (an edit form's
|
|
100
|
+
* loaded record). Its version is what the write is checked against.
|
|
101
|
+
* Defaults to the cached row at the moment `executeWrite` is called.
|
|
102
|
+
*/
|
|
103
|
+
base?: BaseRecord;
|
|
104
|
+
/**
|
|
105
|
+
* The version to check this write against, overriding `base` and the
|
|
106
|
+
* cache: "keep mine" after a conflict sends at the version the conflict
|
|
107
|
+
* reported (`WriteConflict.currentVersion`).
|
|
108
|
+
*/
|
|
109
|
+
expectedVersion?: string;
|
|
88
110
|
mode: MutationMode;
|
|
89
111
|
undoDelayMs?: number;
|
|
90
112
|
onUndoable?: (write: UndoableWrite) => void;
|
|
@@ -111,6 +133,11 @@ type ExecuteWriteResult<R> = {
|
|
|
111
133
|
* @internal Exported for tests.
|
|
112
134
|
*/
|
|
113
135
|
declare function providerServesUndo(queryClient: QueryClient, provider: DataProvider, resource: string): Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* The version `id`'s cached row is at, as a token for `expectedVersion`.
|
|
138
|
+
* @internal Exported for tests.
|
|
139
|
+
*/
|
|
140
|
+
declare function cachedVersion(queryClient: QueryClient, provider: DataProvider, resource: string, id: Identifier): string | undefined;
|
|
114
141
|
/** A later write that built on one that was taken back. */
|
|
115
142
|
declare const DROPPED_WRITE_MESSAGE = "This change was not saved: it was made on top of an earlier change that was undone or failed. Please make it again.";
|
|
116
143
|
/**
|
|
@@ -126,4 +153,4 @@ declare const DROPPED_WRITE_MESSAGE = "This change was not saved: it was made on
|
|
|
126
153
|
*/
|
|
127
154
|
declare function executeWrite<R extends BaseRecord | void>(args: ExecuteWriteArgs<R>): Promise<ExecuteWriteResult<R>>;
|
|
128
155
|
|
|
129
|
-
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, type ExecuteWriteArgs, type ExecuteWriteResult, type MutationMode, type MutationModeOptions, type SendContext, type UndoableWrite, cachedRecord, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue };
|
|
156
|
+
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, type ExecuteWriteArgs, type ExecuteWriteResult, type MutationMode, type MutationModeOptions, type SendContext, type UndoableWrite, cachedRecord, cachedVersion, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, cachedRecord, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { DEFAULT_UNDO_DELAY_MS, DROPPED_WRITE_MESSAGE, cachedRecord, cachedVersion, dropPendingWrites, executeWrite, flushPendingWrites, invalidateResource, pendingWriteCount, providerServesUndo, sameValue } from '../chunk-YNXLPOAB.js';
|
|
2
|
+
import '../chunk-2VJQVAJD.js';
|
|
3
|
+
import '../chunk-AJGVLF37.js';
|
|
3
4
|
import '../chunk-7PUFVNPB.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PSFKIG27.js';
|
|
5
6
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-AUVKRXRC.js';
|
|
8
|
+
import '../chunk-VFT6QKZW.js';
|
|
9
|
+
import '../chunk-HUNGCTRA.js';
|
|
10
|
+
import '../chunk-RYEXWQFD.js';
|
|
11
|
+
import '../chunk-LG6TUBVM.js';
|
|
7
12
|
//# sourceMappingURL=mutation-mode.js.map
|
|
8
13
|
//# sourceMappingURL=mutation-mode.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-
|
|
1
|
+
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-BzLv8yOm.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The cache keys a committed write makes stale beyond `[resource]`: the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { t as ProviderCapabilities } from '../types-
|
|
2
|
+
import { t as ProviderCapabilities } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The query key for `provider`'s capabilities for `resource`. It includes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { capabilitiesQueryKey, useCapabilities } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { capabilitiesQueryKey, useCapabilities } from '../chunk-2VJQVAJD.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
3
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
4
|
//# sourceMappingURL=use-capabilities.js.map
|
|
5
5
|
//# sourceMappingURL=use-capabilities.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseInfiniteQueryResult, InfiniteData } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseInfiniteResourceOptions {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { useInfiniteResource } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useInfiniteResource } from '../chunk-POMTRNAL.js';
|
|
2
|
+
import '../chunk-XVRIWP7B.js';
|
|
4
3
|
import '../chunk-7PUFVNPB.js';
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PSFKIG27.js';
|
|
6
5
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
+
import '../chunk-AUVKRXRC.js';
|
|
7
7
|
//# sourceMappingURL=use-infinite-resource.js.map
|
|
8
8
|
//# sourceMappingURL=use-infinite-resource.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { useLinkOptions } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useLinkOptions } from '../chunk-VJGU6E4U.js';
|
|
2
|
+
import '../chunk-42QPCDQF.js';
|
|
3
|
+
import '../chunk-POMTRNAL.js';
|
|
4
|
+
import '../chunk-XVRIWP7B.js';
|
|
6
5
|
import '../chunk-7PUFVNPB.js';
|
|
7
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-PSFKIG27.js';
|
|
8
7
|
import '../chunk-ZYJUEJ4Z.js';
|
|
8
|
+
import '../chunk-AUVKRXRC.js';
|
|
9
9
|
//# sourceMappingURL=use-link-options.js.map
|
|
10
10
|
//# sourceMappingURL=use-link-options.js.map
|
package/dist/hooks/use-live.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-
|
|
2
|
+
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-BzLv8yOm.js';
|
|
3
3
|
|
|
4
4
|
/** How long a burst of change events is gathered into one refetch. */
|
|
5
5
|
declare const DEFAULT_LIVE_DEBOUNCE_MS = 250;
|
package/dist/hooks/use-live.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-VDEW4AOS.js';
|
|
1
|
+
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-XVRIWP7B.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
4
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
|
+
import '../chunk-AUVKRXRC.js';
|
|
5
5
|
//# sourceMappingURL=use-live.js.map
|
|
6
6
|
//# sourceMappingURL=use-live.js.map
|
package/dist/hooks/use-one.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { B as BaseRecord, b as Identifier } from '../types-
|
|
2
|
+
import { B as BaseRecord, b as Identifier } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseOneOptions {
|
package/dist/hooks/use-one.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { useOne } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-AUVKRXRC.js';
|
|
1
|
+
export { useOne } from '../chunk-LOJGHR5O.js';
|
|
2
|
+
import '../chunk-XVRIWP7B.js';
|
|
4
3
|
import '../chunk-7PUFVNPB.js';
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PSFKIG27.js';
|
|
6
5
|
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
+
import '../chunk-AUVKRXRC.js';
|
|
7
7
|
//# sourceMappingURL=use-one.js.map
|
|
8
8
|
//# sourceMappingURL=use-one.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-
|
|
1
|
+
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-BzLv8yOm.js';
|
|
2
2
|
|
|
3
3
|
interface UseRelationLabelOptions {
|
|
4
4
|
/** The linked row's field that names it. Default: the linked resource's `labelField` (`describe`). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-42QPCDQF.js';
|
|
2
|
+
import '../chunk-PSFKIG27.js';
|
|
3
3
|
import '../chunk-ZYJUEJ4Z.js';
|
|
4
4
|
//# sourceMappingURL=use-relation-label.js.map
|
|
5
5
|
//# sourceMappingURL=use-relation-label.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-
|
|
2
|
+
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-BzLv8yOm.js';
|
|
3
|
+
import { W as WriteConflict } from '../write-state-DVC4Yq9T.js';
|
|
3
4
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
5
|
import '@tanstack/react-query';
|
|
5
6
|
|
|
@@ -100,6 +101,18 @@ interface UseResourceFormReturn {
|
|
|
100
101
|
* `window.confirm` otherwise.
|
|
101
102
|
*/
|
|
102
103
|
confirmLeave: () => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Set when a save met someone else's change (a versioned resource's
|
|
106
|
+
* `conflict`): their row beside what this form tried to save. Show it with
|
|
107
|
+
* ConflictSheet; null otherwise.
|
|
108
|
+
*/
|
|
109
|
+
conflict: WriteConflict | null;
|
|
110
|
+
/** Save this form's values over theirs, at the version the conflict reported. */
|
|
111
|
+
keepMine: () => Promise<void>;
|
|
112
|
+
/** Drop this form's changes and show their row. */
|
|
113
|
+
takeTheirs: () => void;
|
|
114
|
+
/** Close the conflict without choosing: the form keeps its unsaved values. */
|
|
115
|
+
dismissConflict: () => void;
|
|
103
116
|
}
|
|
104
117
|
/** Build default values for a single array item from its sub-field definitions */
|
|
105
118
|
declare function buildArrayItemDefaults(arrayFields: ResourceFormFieldDef[]): Record<string, unknown>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
1
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-3B5O36DU.js';
|
|
2
|
+
import '../chunk-2WS4LGYU.js';
|
|
2
3
|
import '../chunk-RVWKVD5Q.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-7NUL32W7.js';
|
|
5
|
+
import '../chunk-LOJGHR5O.js';
|
|
6
|
+
import '../chunk-XVRIWP7B.js';
|
|
7
|
+
import '../chunk-YNXLPOAB.js';
|
|
8
|
+
import '../chunk-2VJQVAJD.js';
|
|
9
|
+
import '../chunk-AJGVLF37.js';
|
|
8
10
|
import '../chunk-7PUFVNPB.js';
|
|
9
|
-
import '../chunk-
|
|
11
|
+
import '../chunk-PSFKIG27.js';
|
|
10
12
|
import '../chunk-ZYJUEJ4Z.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
+
import '../chunk-AUVKRXRC.js';
|
|
14
|
+
import '../chunk-VFT6QKZW.js';
|
|
15
|
+
import '../chunk-HUNGCTRA.js';
|
|
13
16
|
import '../chunk-RYEXWQFD.js';
|
|
14
17
|
import '../chunk-LG6TUBVM.js';
|
|
15
18
|
//# sourceMappingURL=use-resource-form.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-BzLv8yOm.js';
|
|
3
3
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
4
|
import { LiveOptions } from './use-live.js';
|
|
5
5
|
|
|
@@ -65,6 +65,19 @@ interface UseResourceOptions<T> extends MutationModeOptions {
|
|
|
65
65
|
*/
|
|
66
66
|
onError?: (error: Error) => void;
|
|
67
67
|
}
|
|
68
|
+
/** What `update` can take beside the change. */
|
|
69
|
+
interface UpdateOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Check the write against this version instead of the cached row's: "keep mine" after a
|
|
72
|
+
* conflict, at the version the conflict reported (`WriteConflict.currentVersion`). A version
|
|
73
|
+
* already chained for the row wins over it: a write sent while an earlier write of the same row
|
|
74
|
+
* is still in flight is checked against the version that one commits (as
|
|
75
|
+
* `ExecuteWriteArgs.expectedVersion`). The write
|
|
76
|
+
* still goes through the resource's write path (queued behind any other write of the row, its
|
|
77
|
+
* committed version recorded), so a move made right after it is checked against it.
|
|
78
|
+
*/
|
|
79
|
+
expectedVersion?: string;
|
|
80
|
+
}
|
|
68
81
|
interface UseResourceReturn<T> {
|
|
69
82
|
/** TanStack Query result for the list query. */
|
|
70
83
|
list: UseQueryResult<ListResult<T>>;
|
|
@@ -86,7 +99,7 @@ interface UseResourceReturn<T> {
|
|
|
86
99
|
* `optimistic` and `undoable` modes it resolves at once with the cached
|
|
87
100
|
* row merged with `data`.
|
|
88
101
|
*/
|
|
89
|
-
update: (id: Identifier, data: Partial<T
|
|
102
|
+
update: (id: Identifier, data: Partial<T>, options?: UpdateOptions) => Promise<T>;
|
|
90
103
|
/** Delete a record by id. Resolves at once in `optimistic` / `undoable` modes. */
|
|
91
104
|
remove: (id: Identifier) => Promise<void>;
|
|
92
105
|
/** True when any mutation is in-flight. */
|
|
@@ -95,9 +108,10 @@ interface UseResourceReturn<T> {
|
|
|
95
108
|
updateMutation: UseMutationResult<T, Error, {
|
|
96
109
|
id: Identifier;
|
|
97
110
|
data: Partial<T>;
|
|
111
|
+
options?: UpdateOptions;
|
|
98
112
|
}>;
|
|
99
113
|
deleteMutation: UseMutationResult<void, Error, Identifier>;
|
|
100
114
|
}
|
|
101
115
|
declare function useResource<T extends BaseRecord = BaseRecord>(resource: string, options?: UseResourceOptions<T>): UseResourceReturn<T>;
|
|
102
116
|
|
|
103
|
-
export { type UseResourceOptions, type UseResourceReturn, useResource };
|
|
117
|
+
export { type UpdateOptions, type UseResourceOptions, type UseResourceReturn, useResource };
|