@marktiderman/genesis-core 2.15.0 → 2.16.1
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/dist/{aggregate-y-qqJioF.d.ts → aggregate-Y5IJ5aPn.d.ts} +1 -1
- package/dist/{chunk-TKK7D2ZT.js → chunk-ALLWIK62.js} +3 -3
- package/dist/{chunk-TKK7D2ZT.js.map → chunk-ALLWIK62.js.map} +1 -1
- package/dist/{chunk-JTRRAVR4.js → chunk-APFXV6FZ.js} +18 -12
- package/dist/chunk-APFXV6FZ.js.map +1 -0
- package/dist/chunk-BDPRWVFW.js +17 -0
- package/dist/chunk-BDPRWVFW.js.map +1 -0
- package/dist/{chunk-JFHRSG6G.js → chunk-FXPODKCK.js} +3 -3
- package/dist/{chunk-JFHRSG6G.js.map → chunk-FXPODKCK.js.map} +1 -1
- package/dist/{chunk-YZV3Z6ZA.js → chunk-SQLM5CIJ.js} +3 -3
- package/dist/{chunk-YZV3Z6ZA.js.map → chunk-SQLM5CIJ.js.map} +1 -1
- package/dist/{chunk-NZP7YQHS.js → chunk-ZYOJWU62.js} +4 -4
- package/dist/{chunk-NZP7YQHS.js.map → chunk-ZYOJWU62.js.map} +1 -1
- package/dist/csv.d.ts +1 -1
- package/dist/form-types.d.ts +1 -1
- package/dist/headless/index.d.ts +334 -0
- package/dist/headless/index.js +490 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +11 -10
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-aggregate.d.ts +2 -2
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-draft.js +2 -2
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-resource-form.d.ts +1 -1
- package/dist/hooks/use-resource-form.js +3 -3
- package/dist/hooks/use-resource.d.ts +1 -1
- package/dist/hooks/use-resource.js +3 -3
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.ts +5 -5
- package/dist/resource-view/index.d.ts +1 -1
- package/dist/schema/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-D4Bi_Iq8.d.ts → types-BriIV4e_.d.ts} +2 -0
- package/dist/{workspaces-BKhloJPK.d.ts → workspaces-CxpiFu2-.d.ts} +9 -1
- package/dist/workspaces.d.ts +1 -1
- package/dist/workspaces.js +2 -1
- package/dist/{write-outcome-CHPT7Slm.d.ts → write-outcome-CkQXgtJq.d.ts} +1 -1
- package/package.json +14 -4
- package/dist/chunk-JTRRAVR4.js.map +0 -1
package/dist/hooks/index.d.ts
CHANGED
|
@@ -12,15 +12,15 @@ export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftAdoption, DraftController
|
|
|
12
12
|
import { c as ViewerScopeProps } from '../viewer-scope-Dx0N9AYk.js';
|
|
13
13
|
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';
|
|
14
14
|
import * as react from 'react';
|
|
15
|
-
import { W as Workspace, g as WorkspaceHrefOptions } from '../workspaces-
|
|
15
|
+
import { W as Workspace, g as WorkspaceHrefOptions } from '../workspaces-CxpiFu2-.js';
|
|
16
16
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, LiveOptions, useLiveInvalidation } from './use-live.js';
|
|
17
17
|
export { UseResourceFormOptions, UseResourceFormReturn, blankValues, buildArrayItemDefaults, useResourceForm } from './use-resource-form.js';
|
|
18
18
|
export { UseWizardReturn, WizardStep, useWizard } from './use-wizard.js';
|
|
19
19
|
export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './mutation-mode.js';
|
|
20
20
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './use-unsaved-changes-guard.js';
|
|
21
21
|
import '@tanstack/react-query';
|
|
22
|
-
import '../types-
|
|
23
|
-
import '../aggregate-
|
|
22
|
+
import '../types-BriIV4e_.js';
|
|
23
|
+
import '../aggregate-Y5IJ5aPn.js';
|
|
24
24
|
import '../dates.js';
|
|
25
25
|
import 'react-hook-form';
|
|
26
26
|
import '../write-state-DVC4Yq9T.js';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-
|
|
1
|
+
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-ZYOJWU62.js';
|
|
2
|
+
export { WRITE_FAILED, useWrite } from '../chunk-NQFIAULD.js';
|
|
2
3
|
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
3
4
|
export { usePersistedUiState } from '../chunk-IYGVJFCV.js';
|
|
4
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
5
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-FXPODKCK.js';
|
|
5
6
|
import '../chunk-LKRJB632.js';
|
|
6
7
|
export { useOne } from '../chunk-QGWQ6LK3.js';
|
|
7
|
-
export { useResource } from '../chunk-
|
|
8
|
+
export { useResource } from '../chunk-ALLWIK62.js';
|
|
8
9
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from '../chunk-RVWKVD5Q.js';
|
|
9
10
|
export { useWizard } from '../chunk-7KOLYF27.js';
|
|
10
|
-
export {
|
|
11
|
+
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from '../chunk-SOO54YYY.js';
|
|
11
12
|
import '../chunk-7NUL32W7.js';
|
|
12
13
|
export { useAggregate } from '../chunk-XPBS5YE4.js';
|
|
13
|
-
export {
|
|
14
|
+
export { useCapabilities } from '../chunk-42NVJJTT.js';
|
|
15
|
+
export { useDraft } from '../chunk-SQLM5CIJ.js';
|
|
16
|
+
import '../chunk-AJGVLF37.js';
|
|
14
17
|
export { useLinkOptions } from '../chunk-POUI7GAI.js';
|
|
15
18
|
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-UDSTWXXZ.js';
|
|
16
19
|
export { useInfiniteResource } from '../chunk-M5IX7C6U.js';
|
|
17
20
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-E3K2A3PK.js';
|
|
18
|
-
import '../chunk-JTRRAVR4.js';
|
|
19
|
-
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from '../chunk-5ASUMG6K.js';
|
|
20
|
-
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from '../chunk-SOO54YYY.js';
|
|
21
|
-
export { useCapabilities } from '../chunk-42NVJJTT.js';
|
|
22
|
-
import '../chunk-AJGVLF37.js';
|
|
23
21
|
import '../chunk-2IGAUXYH.js';
|
|
24
22
|
import '../chunk-R3YXYVWF.js';
|
|
25
23
|
import '../chunk-J54XXKQD.js';
|
|
26
24
|
import '../chunk-4PTQYT5J.js';
|
|
25
|
+
import '../chunk-APFXV6FZ.js';
|
|
26
|
+
import '../chunk-BDPRWVFW.js';
|
|
27
|
+
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from '../chunk-5ASUMG6K.js';
|
|
27
28
|
import '../chunk-AUVKRXRC.js';
|
|
28
29
|
import '../chunk-WXENWPWP.js';
|
|
29
30
|
import '../chunk-NOPS5EIH.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { d as Identifier, B as BaseRecord, D as DataProvider, h as AuditEntry } from '../types-
|
|
2
|
+
import { d as Identifier, B as BaseRecord, D as DataProvider, h as AuditEntry } from '../types-BriIV4e_.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. */
|
|
@@ -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-BriIV4e_.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The cache keys a committed write makes stale beyond `[resource]`: the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { R as ResolveAggregateOptions } from '../aggregate-
|
|
3
|
-
import { A as AggregateParams, b as AggregateResult } from '../types-
|
|
2
|
+
import { R as ResolveAggregateOptions } from '../aggregate-Y5IJ5aPn.js';
|
|
3
|
+
import { A as AggregateParams, b as AggregateResult } from '../types-BriIV4e_.js';
|
|
4
4
|
import { LiveOptions } from './use-live.js';
|
|
5
5
|
|
|
6
6
|
interface UseAggregateOptions extends ResolveAggregateOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { P as ProviderCapabilities } from '../types-
|
|
2
|
+
import { P as ProviderCapabilities } from '../types-BriIV4e_.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The query key for `provider`'s capabilities for `resource`. It includes
|
package/dist/hooks/use-draft.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { useDraft } from '../chunk-
|
|
2
|
-
import '../chunk-5ASUMG6K.js';
|
|
1
|
+
export { useDraft } from '../chunk-SQLM5CIJ.js';
|
|
3
2
|
import '../chunk-AJGVLF37.js';
|
|
3
|
+
import '../chunk-5ASUMG6K.js';
|
|
4
4
|
import '../chunk-WLDSIQJ2.js';
|
|
5
5
|
//# sourceMappingURL=use-draft.js.map
|
|
6
6
|
//# sourceMappingURL=use-draft.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseInfiniteQueryResult, InfiniteData } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, L as ListResult, c as ListParams, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, L as ListResult, c as ListParams, B as BaseRecord } from '../types-BriIV4e_.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseInfiniteResourceOptions {
|
package/dist/hooks/use-live.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import { f as SubscribeParams, g as ResourceChangeEvent } from '../types-
|
|
2
|
+
import { f as SubscribeParams, g as ResourceChangeEvent } from '../types-BriIV4e_.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-one.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { B as BaseRecord, d as Identifier } from '../types-
|
|
2
|
+
import { B as BaseRecord, d as Identifier } from '../types-BriIV4e_.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseOneOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, e as FieldReference, d as Identifier } from '../types-
|
|
1
|
+
import { D as DataProvider, e as FieldReference, d as Identifier } from '../types-BriIV4e_.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
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import { R as ResourceFormFieldDef, I as InvalidationKey } from '../types-
|
|
2
|
+
import { R as ResourceFormFieldDef, I as InvalidationKey } from '../types-BriIV4e_.js';
|
|
3
3
|
import { W as WriteConflict } from '../write-state-DVC4Yq9T.js';
|
|
4
4
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
5
5
|
import '@tanstack/react-query';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
1
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-FXPODKCK.js';
|
|
2
2
|
import '../chunk-LKRJB632.js';
|
|
3
3
|
import '../chunk-QGWQ6LK3.js';
|
|
4
4
|
import '../chunk-RVWKVD5Q.js';
|
|
5
|
-
import '../chunk-7NUL32W7.js';
|
|
6
|
-
import '../chunk-E3K2A3PK.js';
|
|
7
5
|
import '../chunk-SOO54YYY.js';
|
|
6
|
+
import '../chunk-7NUL32W7.js';
|
|
8
7
|
import '../chunk-42NVJJTT.js';
|
|
9
8
|
import '../chunk-AJGVLF37.js';
|
|
9
|
+
import '../chunk-E3K2A3PK.js';
|
|
10
10
|
import '../chunk-2IGAUXYH.js';
|
|
11
11
|
import '../chunk-R3YXYVWF.js';
|
|
12
12
|
import '../chunk-J54XXKQD.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, I as InvalidationKey, L as ListResult, c as ListParams, d as Identifier, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, I as InvalidationKey, L as ListResult, c as ListParams, d as Identifier, B as BaseRecord } from '../types-BriIV4e_.js';
|
|
3
3
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
4
|
import { LiveOptions } from './use-live.js';
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { useResource } from '../chunk-
|
|
2
|
-
import '../chunk-7NUL32W7.js';
|
|
3
|
-
import '../chunk-E3K2A3PK.js';
|
|
1
|
+
export { useResource } from '../chunk-ALLWIK62.js';
|
|
4
2
|
import '../chunk-SOO54YYY.js';
|
|
3
|
+
import '../chunk-7NUL32W7.js';
|
|
5
4
|
import '../chunk-42NVJJTT.js';
|
|
6
5
|
import '../chunk-AJGVLF37.js';
|
|
6
|
+
import '../chunk-E3K2A3PK.js';
|
|
7
7
|
import '../chunk-2IGAUXYH.js';
|
|
8
8
|
import '../chunk-R3YXYVWF.js';
|
|
9
9
|
import '../chunk-J54XXKQD.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient, MutationOptions } from '@tanstack/react-query';
|
|
2
|
-
import { I as InvalidationKey } from '../types-
|
|
2
|
+
import { I as InvalidationKey } from '../types-BriIV4e_.js';
|
|
3
3
|
|
|
4
4
|
declare const WRITE_FAILED = "That didn't work. Try again.";
|
|
5
5
|
interface UseWriteOptions<A, R> {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as ListParams, d as Identifier } from './types-
|
|
2
|
-
export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, h as AuditEntry, B as BaseRecord, l as BulkChange, m as BulkResult, C as ControlHint, n as CountMode, o as CreateParams, p as CreateResult, D as DataProvider, j as DataRow, q as DeleteParams, r as DeleteResult, s as FieldPermissions, e as FieldReference, F as FieldSchema, t as FieldType, u as FilterOperator, a as FilterParam, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, I as InvalidationKey, L as ListResult, N as NullFilter, z as PaginationParam, P as ProviderCapabilities, E as RangeFilter, J as RecordComment, K as ResourceAccess, g as ResourceChangeEvent, M as ResourceContract, R as ResourceFormFieldDef, O as ResourceRelation, Q as ResourceSchema, T as ResourceSummary, U as RowAction, V as RowFailure, X as RowOf, Y as ScalarFilter, Z as SelectOption, S as SortParam, _ as StorageType, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult, a1 as VersionField, a2 as WidgetHint, W as WriteEvent, a3 as defineResource, a4 as fieldControl } from './types-
|
|
3
|
-
export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from './aggregate-
|
|
4
|
-
export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from './write-outcome-
|
|
1
|
+
import { c as ListParams, d as Identifier } from './types-BriIV4e_.js';
|
|
2
|
+
export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, h as AuditEntry, B as BaseRecord, l as BulkChange, m as BulkResult, C as ControlHint, n as CountMode, o as CreateParams, p as CreateResult, D as DataProvider, j as DataRow, q as DeleteParams, r as DeleteResult, s as FieldPermissions, e as FieldReference, F as FieldSchema, t as FieldType, u as FilterOperator, a as FilterParam, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, I as InvalidationKey, L as ListResult, N as NullFilter, z as PaginationParam, P as ProviderCapabilities, E as RangeFilter, J as RecordComment, K as ResourceAccess, g as ResourceChangeEvent, M as ResourceContract, R as ResourceFormFieldDef, O as ResourceRelation, Q as ResourceSchema, T as ResourceSummary, U as RowAction, V as RowFailure, X as RowOf, Y as ScalarFilter, Z as SelectOption, S as SortParam, _ as StorageType, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult, a1 as VersionField, a2 as WidgetHint, W as WriteEvent, a3 as defineResource, a4 as fieldControl } from './types-BriIV4e_.js';
|
|
3
|
+
export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from './aggregate-Y5IJ5aPn.js';
|
|
4
|
+
export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from './write-outcome-CkQXgtJq.js';
|
|
5
5
|
export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseUpdateContext, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
|
|
6
6
|
export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from './read-outcome-BnboMYOV.js';
|
|
7
7
|
export { S as StorageAdapter } from './types-DKcxHXxq.js';
|
|
@@ -30,8 +30,8 @@ import { Query } from '@tanstack/react-query';
|
|
|
30
30
|
export { isSafeUrl, normalizeLinkUrl } from './urls.js';
|
|
31
31
|
export { ClassifiedError, ClassifyErrorOptions, ErrorKind, ErrorMessages, ErrorReportContext, ErrorReporter, classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './errors.js';
|
|
32
32
|
export { titleCase } from './utils.js';
|
|
33
|
-
import { A as AppearancePreferenceValues, R as ResolvedAppearancePreferences, a as AppearancePreferenceLayers, b as Appearance, D as Density } from './workspaces-
|
|
34
|
-
export { c as APPEARANCES, d as AppearancePreferenceSource, e as DENSITIES, G as GENESIS_APPEARANCE_DEFAULTS, i as isAppearance, f as isDensity, r as resolveAppearancePreferences, t as toAppearancePreferenceValues } from './workspaces-
|
|
33
|
+
import { A as AppearancePreferenceValues, R as ResolvedAppearancePreferences, a as AppearancePreferenceLayers, b as Appearance, D as Density } from './workspaces-CxpiFu2-.js';
|
|
34
|
+
export { c as APPEARANCES, d as AppearancePreferenceSource, e as DENSITIES, G as GENESIS_APPEARANCE_DEFAULTS, i as isAppearance, f as isDensity, r as resolveAppearancePreferences, t as toAppearancePreferenceValues } from './workspaces-CxpiFu2-.js';
|
|
35
35
|
import * as react from 'react';
|
|
36
36
|
import { ReactNode } from 'react';
|
|
37
37
|
import './types-CsKSAKqs.js';
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-7EFTWOMA.js';
|
|
2
2
|
export { decodeRecordKey, defineResource, encodeRecordKey, fieldControl, keyFields } from './chunk-LB6FMQQM.js';
|
|
3
3
|
import './chunk-XCX2TRBL.js';
|
|
4
|
-
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-
|
|
4
|
+
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-ZYOJWU62.js';
|
|
5
|
+
export { WRITE_FAILED, useWrite } from './chunk-NQFIAULD.js';
|
|
5
6
|
export { NO_VIEWER } from './chunk-OZYF55E3.js';
|
|
6
7
|
import { usePersistedUiState } from './chunk-IYGVJFCV.js';
|
|
7
8
|
export { usePersistedUiState } from './chunk-IYGVJFCV.js';
|
|
8
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-
|
|
9
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-FXPODKCK.js';
|
|
9
10
|
export { writeConflict } from './chunk-LKRJB632.js';
|
|
10
11
|
export { useOne } from './chunk-QGWQ6LK3.js';
|
|
11
|
-
export { useResource } from './chunk-
|
|
12
|
+
export { useResource } from './chunk-ALLWIK62.js';
|
|
12
13
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-RVWKVD5Q.js';
|
|
13
14
|
export { useWizard } from './chunk-7KOLYF27.js';
|
|
14
|
-
export {
|
|
15
|
+
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './chunk-SOO54YYY.js';
|
|
15
16
|
import './chunk-7NUL32W7.js';
|
|
16
17
|
export { useAggregate } from './chunk-XPBS5YE4.js';
|
|
17
|
-
export {
|
|
18
|
+
export { useCapabilities } from './chunk-42NVJJTT.js';
|
|
19
|
+
export { useDraft } from './chunk-SQLM5CIJ.js';
|
|
20
|
+
import './chunk-AJGVLF37.js';
|
|
18
21
|
export { useLinkOptions } from './chunk-POUI7GAI.js';
|
|
19
22
|
export { loadRelationLabel, relationNamingField, useRelationLabel } from './chunk-UDSTWXXZ.js';
|
|
20
23
|
export { useInfiniteResource } from './chunk-M5IX7C6U.js';
|
|
21
24
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from './chunk-E3K2A3PK.js';
|
|
22
|
-
import { isAppearance, APPEARANCES, isDensity, DENSITIES, toAppearancePreferenceValues, resolveAppearancePreferences } from './chunk-JTRRAVR4.js';
|
|
23
|
-
export { APPEARANCES, DENSITIES, GENESIS_APPEARANCE_DEFAULTS, isAppearance, isDensity, resolveAppearancePreferences, toAppearancePreferenceValues } from './chunk-JTRRAVR4.js';
|
|
24
|
-
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from './chunk-5ASUMG6K.js';
|
|
25
|
-
export { DEFAULT_UNDO_DELAY_MS, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './chunk-SOO54YYY.js';
|
|
26
|
-
export { useCapabilities } from './chunk-42NVJJTT.js';
|
|
27
|
-
import './chunk-AJGVLF37.js';
|
|
28
25
|
export { defineQueryKeys, resourceKeys } from './chunk-2IGAUXYH.js';
|
|
29
26
|
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-R3YXYVWF.js';
|
|
30
27
|
export { aggregateProblems, resolveAggregate, toAggregateValues } from './chunk-J54XXKQD.js';
|
|
31
28
|
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './chunk-4PTQYT5J.js';
|
|
29
|
+
import { isAppearance, APPEARANCES, isDensity, DENSITIES, toAppearancePreferenceValues, resolveAppearancePreferences } from './chunk-APFXV6FZ.js';
|
|
30
|
+
export { APPEARANCES, DENSITIES, GENESIS_APPEARANCE_DEFAULTS, isAppearance, isDensity, resolveAppearancePreferences, toAppearancePreferenceValues } from './chunk-APFXV6FZ.js';
|
|
31
|
+
import './chunk-BDPRWVFW.js';
|
|
32
|
+
export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from './chunk-5ASUMG6K.js';
|
|
32
33
|
import './chunk-AUVKRXRC.js';
|
|
33
34
|
import './chunk-WXENWPWP.js';
|
|
34
35
|
import { reportError } from './chunk-NOPS5EIH.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/appearance.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFO,SAAS,2BAAA,CAA4B,UAAA,GAA8C,EAAC,EAA0B;AACnH,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,IAAA,IAAQ,EAAC;AACjC,EAAA,IAAI,IAAA,CAAK,UAAA,KAAe,MAAA,IAAa,CAAC,aAAa,IA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M,QAAA,GAAW,6BAA6B,MAAM,CAAA;AACpD,IAAA,MAAM,MAAA,GAAS,EAAE,UAAA,EAAY,IAAA,CAAK,eAAe,MAAA,EAAW,OAAA,EAAS,IAAA,CAAK,OAAA,KAAY,MAAA,EAAU;AAChG,IAAA,OAAO;AAAA,MACL,GAAG,QAAA;AAAA,MACH,MAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,KAAA;AAAA,MACA,aAAA,EAAe,CAAC,UAAA,KAAe;AAC7B,QAAA,IAAI,CAAC,MAAA,CAAO,UAAA,EAAY,IAAA,CAAK,EAAE,YAAY,CAAA;AAAA,MAC7C,CAAA;AAAA,MACA,UAAA,EAAY,CAAC,OAAA,KAAY;AACvB,QAAA,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,IAAA,CAAK,EAAE,SAAS,CAAA;AAAA,MACvC;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAA,EAAM,MAAA,EAAQ,cAAc,KAAA,EAAO,KAAA,EAAO,IAAI,CAAC,CAAA;AAEnD,EAAA,uBAAO,GAAA,CAAC,4BAAA,CAA6B,QAAA,EAA7B,EAAsC,OAAe,QAAA,EAAS,CAAA;AACxE;AASO,SAAS,wBAAA,GAA2D;AACzE,EAAA,MAAM,KAAA,GAAQ,WAAW,4BAA4B,CAAA;AACrD,EAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,MAAM,kFAAkF,CAAA;AAC9G,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,gCAAA,GAA0E;AACxF,EAAA,OAAO,WAAW,4BAA4B,CAAA;AAChD","file":"index.js","sourcesContent":["\"use client\";\n/**\n * Appearance preferences (ADR 0024): who sets a person's appearance (light, dark or system) and\n * density (compact, comfortable, spacious).\n *\n * Both are the person's. An app can lock either one; an organization can set a default for its\n * people; an app theme sets the default under that; Genesis's own default is last:\n *\n * app lock > person > organization default > theme default > Genesis default\n *\n * `resolveAppearancePreferences` is that order as a pure function. `defineAppearancePreferences`\n * declares an app's lock, defaults and where a person's choice is kept: a store (an adapter the\n * app backs with its own server table, so the choice follows the person to every device), with\n * the device's storage (`useStorage()`) as a copy and the fallback. `AppearancePreferencesProvider`\n * serves it to the tree: genesis-ui's `AppearanceProvider` (light and dark) and `AppShell`\n * (density) read it when it is there, and work as before when it isn't.\n *\n * Brand is not here: an organization sets its brand (`WorkspaceTheme.brand`), and the app sets\n * the theme per area.\n */\nimport { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { usePersistedUiState } from \"./hooks/use-persisted-ui-state\";\nimport { reportError } from \"./errors\";\nimport {\n APPEARANCES,\n DENSITIES,\n isAppearance,\n isDensity,\n resolveAppearancePreferences,\n toAppearancePreferenceValues,\n type Appearance,\n type AppearancePreferenceLayers,\n type AppearancePreferenceValues,\n type Density,\n type ResolvedAppearancePreferences,\n} from \"./appearance-values\";\n\n/**\n * Where a person's appearance preferences are kept: an adapter an app backs with its own server\n * table (a `profiles` row, say), so the choice follows the person. `read` may be async; return\n * null when the person has chosen nothing. `subscribe` (optional) reports a change made elsewhere.\n *\n * @stability Beta\n */\nexport interface AppearancePreferencesStore {\n read(): AppearancePreferenceValues | null | undefined | Promise<AppearancePreferenceValues | null | undefined>;\n write(values: AppearancePreferenceValues): void | Promise<void>;\n subscribe?(onChange: (values: AppearancePreferenceValues | null) => void): () => void;\n}\n\n/** What `defineAppearancePreferences` accepts. */\nexport interface AppearancePreferencesDefinition {\n /** Where the person's choice is kept beyond this device. Unset: the device only. */\n store?: AppearancePreferencesStore;\n /** The device copy's storage key (`useStorage()`). Default `genesis-appearance`. */\n storageKey?: string;\n /** Values the app fixes: nobody below can change them. */\n lock?: AppearancePreferenceValues;\n}\n\n/** A defined appearance-preferences setup. */\nexport interface AppearancePreferences {\n readonly store?: AppearancePreferencesStore;\n readonly storageKey: string;\n readonly lock: Readonly<AppearancePreferenceValues>;\n}\n\n/**\n * Declare where a person's appearance and density are kept and what the app locks. Checks the\n * lock and returns it frozen; throws on a value that isn't an appearance or a density.\n *\n * ```ts\n * export const appearance = defineAppearancePreferences({\n * store: {\n * read: () => api.myPreferences(), // { appearance: \"dark\", density: \"compact\" }\n * write: (values) => api.saveMyPreferences(values),\n * },\n * lock: { density: \"comfortable\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineAppearancePreferences(definition: AppearancePreferencesDefinition = {}): AppearancePreferences {\n const problems: string[] = [];\n const lock = definition.lock ?? {};\n if (lock.appearance !== undefined && !isAppearance(lock.appearance)) problems.push(`lock.appearance: one of ${APPEARANCES.join(\", \")}`);\n if (lock.density !== undefined && !isDensity(lock.density)) problems.push(`lock.density: one of ${DENSITIES.join(\", \")}`);\n if (definition.store && (typeof definition.store.read !== \"function\" || typeof definition.store.write !== \"function\"))\n problems.push(\"store: an object with read() and write()\");\n if (definition.storageKey !== undefined && (typeof definition.storageKey !== \"string\" || !definition.storageKey.trim()))\n problems.push(\"storageKey: a non-empty string\");\n if (problems.length) throw new Error(`defineAppearancePreferences: ${problems.join(\"; \")}`);\n return Object.freeze({\n ...(definition.store ? { store: definition.store } : {}),\n storageKey: definition.storageKey ?? \"genesis-appearance\",\n lock: Object.freeze(toAppearancePreferenceValues(lock)),\n });\n}\n\n/** What `useAppearancePreferences` returns. */\nexport interface UseAppearancePreferencesReturn extends ResolvedAppearancePreferences {\n /** The person's own choice (the store's, else this device's), before the order is applied. */\n person: AppearancePreferenceValues;\n /** Which values the app has locked. */\n locked: { appearance: boolean; density: boolean };\n /**\n * Every layer as given, for a component with a default of its own to put in the order\n * (`AppShell` puts its `options.density` under the theme's).\n */\n layers: AppearancePreferenceLayers;\n /** False until the store's first read has answered. */\n ready: boolean;\n /** Save the person's appearance (`undefined` clears it back to the defaults). Ignored when locked. */\n setAppearance(appearance: Appearance | undefined): void;\n /** Save the person's density (`undefined` clears it). Ignored when locked. */\n setDensity(density: Density | undefined): void;\n}\n\nconst AppearancePreferencesContext = createContext<UseAppearancePreferencesReturn | null>(null);\n\nconst FORMAT = {\n parse: (raw: string) => {\n try {\n return toAppearancePreferenceValues(JSON.parse(raw));\n } catch {\n return undefined;\n }\n },\n};\nconst NONE: AppearancePreferenceValues = {};\n\nexport interface AppearancePreferencesProviderProps {\n /** From `defineAppearancePreferences`. Default: this device only, nothing locked. */\n preferences?: AppearancePreferences;\n /** The active organization's defaults (`resolveWorkspaceAppearance(workspace)`). */\n organization?: AppearancePreferenceValues | undefined;\n /** The app theme's defaults. */\n theme?: AppearancePreferenceValues | undefined;\n children: ReactNode;\n}\n\nconst DEVICE_ONLY = defineAppearancePreferences();\n\n/**\n * Serves a person's appearance and density to the tree, resolved in the written order. Reads the\n * store once on mount (and on its `subscribe`), keeps a copy on the device, and writes both when\n * the person changes a value.\n *\n * @stability Beta\n */\nexport function AppearancePreferencesProvider({ preferences = DEVICE_ONLY, organization, theme, children }: AppearancePreferencesProviderProps) {\n const { store, storageKey, lock } = preferences;\n const [device, setDevice] = usePersistedUiState<AppearancePreferenceValues>(storageKey, NONE, FORMAT);\n const [stored, setStored] = useState<AppearancePreferenceValues | null | undefined>(undefined);\n const [ready, setReady] = useState(!store);\n const latestStore = useRef(store);\n latestStore.current = store;\n\n useEffect(() => {\n if (!store) return;\n let active = true;\n Promise.resolve()\n .then(() => store.read())\n .then(\n (values) => {\n if (!active) return;\n setStored(values ? toAppearancePreferenceValues(values) : null);\n setReady(true);\n },\n (error: unknown) => {\n // A store that can't be read leaves the device's copy in charge.\n reportError(error, \"core:appearance-preferences\");\n if (active) setReady(true);\n },\n );\n const unsubscribe = store.subscribe?.((values) => {\n if (active) setStored(values ? toAppearancePreferenceValues(values) : null);\n });\n return () => {\n active = false;\n unsubscribe?.();\n };\n }, [store]);\n\n // The store's answer is the person's choice; the device's copy fills in until it comes, and\n // when there is no store.\n const person = useMemo<AppearancePreferenceValues>(() => ({ ...device, ...(stored ?? {}) }), [device, stored]);\n\n const save = useCallback(\n (patch: AppearancePreferenceValues) => {\n // An undefined value in the patch clears that key: the spread sets it, and the check drops it.\n const next = toAppearancePreferenceValues({ ...person, ...patch });\n setDevice(Object.keys(next).length ? next : undefined);\n if (latestStore.current) {\n setStored(next);\n void Promise.resolve()\n .then(() => latestStore.current?.write(next))\n .catch((error: unknown) => {\n reportError(error, \"core:appearance-preferences\");\n });\n }\n },\n [person, setDevice],\n );\n\n const value = useMemo<UseAppearancePreferencesReturn>(() => {\n const layers: AppearancePreferenceLayers = { lock, person, organization, theme };\n const resolved = resolveAppearancePreferences(layers);\n const locked = { appearance: lock.appearance !== undefined, density: lock.density !== undefined };\n return {\n ...resolved,\n person,\n locked,\n layers,\n ready,\n setAppearance: (appearance) => {\n if (!locked.appearance) save({ appearance });\n },\n setDensity: (density) => {\n if (!locked.density) save({ density });\n },\n };\n }, [lock, person, organization, theme, ready, save]);\n\n return <AppearancePreferencesContext.Provider value={value}>{children}</AppearancePreferencesContext.Provider>;\n}\n\n/**\n * The person's appearance and density, resolved, with setters. Throws outside an\n * `AppearancePreferencesProvider`; a component that works with or without one reads\n * `useOptionalAppearancePreferences`.\n *\n * @stability Beta\n */\nexport function useAppearancePreferences(): UseAppearancePreferencesReturn {\n const value = useContext(AppearancePreferencesContext);\n if (!value) throw new Error(\"useAppearancePreferences: no AppearancePreferencesProvider above this component.\");\n return value;\n}\n\n/**\n * Like `useAppearancePreferences`, but null outside a provider: for a component (a shell, a\n * theme provider) that keeps its own behaviour when an app hasn't set preferences up.\n *\n * @stability Beta\n */\nexport function useOptionalAppearancePreferences(): UseAppearancePreferencesReturn | null {\n return useContext(AppearancePreferencesContext);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/appearance.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFO,SAAS,2BAAA,CAA4B,UAAA,GAA8C,EAAC,EAA0B;AACnH,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,IAAA,IAAQ,EAAC;AACjC,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E,IAAA,EAAM,MAAA,EAAQ,cAAc,KAAA,EAAM;AAC/E,IAAA,MAAM,QAAA,GAAW,6BAA6B,MAAM,CAAA;AACpD,IAAA,MAAM,MAAA,GAAS,EAAE,UAAA,EAAY,IAAA,CAAK,eAAe,MAAA,EAAW,OAAA,EAAS,IAAA,CAAK,OAAA,KAAY,MAAA,EAAU;AAChG,IAAA,OAAO;AAAA,MACL,GAAG,QAAA;AAAA,MACH,MAAA;AAAA,MACA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,KAAA;AAAA,MACA,aAAA,EAAe,CAAC,UAAA,KAAe;AAC7B,QAAA,IAAI,CAAC,MAAA,CAAO,UAAA,EAAY,IAAA,CAAK,EAAE,YAAY,CAAA;AAAA,MAC7C,CAAA;AAAA,MACA,UAAA,EAAY,CAAC,OAAA,KAAY;AACvB,QAAA,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,IAAA,CAAK,EAAE,SAAS,CAAA;AAAA,MACvC;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,IAAA,EAAM,MAAA,EAAQ,cAAc,KAAA,EAAO,KAAA,EAAO,IAAI,CAAC,CAAA;AAEnD,EAAA,uBAAO,GAAA,CAAC,4BAAA,CAA6B,QAAA,EAA7B,EAAsC,OAAe,QAAA,EAAS,CAAA;AACxE;AASO,SAAS,wBAAA,GAA2D;AACzE,EAAA,MAAM,KAAA,GAAQ,WAAW,4BAA4B,CAAA;AACrD,EAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,MAAM,kFAAkF,CAAA;AAC9G,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,gCAAA,GAA0E;AACxF,EAAA,OAAO,WAAW,4BAA4B,CAAA;AAChD","file":"index.js","sourcesContent":["\"use client\";\n/**\n * Appearance preferences (ADR 0024): who sets a person's appearance (light, dark or system) and\n * density (compact, comfortable, spacious).\n *\n * Both are the person's. An app can lock either one; an organization can set a default for its\n * people; an app theme sets the default under that; Genesis's own default is last:\n *\n * app lock > person > organization default > theme default > Genesis default\n *\n * `resolveAppearancePreferences` is that order as a pure function. `defineAppearancePreferences`\n * declares an app's lock, defaults and where a person's choice is kept: a store (an adapter the\n * app backs with its own server table, so the choice follows the person to every device), with\n * the device's storage (`useStorage()`) as a copy and the fallback. `AppearancePreferencesProvider`\n * serves it to the tree: genesis-ui's `AppearanceProvider` (light and dark) and `AppShell`\n * (density) read it when it is there, and work as before when it isn't.\n *\n * Brand is not here: an organization sets its brand (`WorkspaceTheme.brand`), and the app sets\n * the theme per area.\n */\nimport { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { usePersistedUiState } from \"./hooks/use-persisted-ui-state\";\nimport { reportError } from \"./errors\";\nimport {\n APPEARANCES,\n DENSITIES,\n isAppearance,\n isDensity,\n resolveAppearancePreferences,\n toAppearancePreferenceValues,\n type Appearance,\n type AppearancePreferenceLayers,\n type AppearancePreferenceValues,\n type Density,\n type ResolvedAppearancePreferences,\n} from \"./appearance-values\";\n\n/**\n * Where a person's appearance preferences are kept: an adapter an app backs with its own server\n * table (a `profiles` row, say), so the choice follows the person. `read` may be async; return\n * null when the person has chosen nothing. `subscribe` (optional) reports a change made elsewhere.\n *\n * @stability Beta\n */\nexport interface AppearancePreferencesStore {\n read(): AppearancePreferenceValues | null | undefined | Promise<AppearancePreferenceValues | null | undefined>;\n write(values: AppearancePreferenceValues): void | Promise<void>;\n subscribe?(onChange: (values: AppearancePreferenceValues | null) => void): () => void;\n}\n\n/** What `defineAppearancePreferences` accepts. */\nexport interface AppearancePreferencesDefinition {\n /** Where the person's choice is kept beyond this device. Unset: the device only. */\n store?: AppearancePreferencesStore;\n /** The device copy's storage key (`useStorage()`). Default `genesis-appearance`. */\n storageKey?: string;\n /** Values the app fixes: nobody below can change them. */\n lock?: AppearancePreferenceValues;\n}\n\n/** A defined appearance-preferences setup. */\nexport interface AppearancePreferences {\n readonly store?: AppearancePreferencesStore;\n readonly storageKey: string;\n readonly lock: Readonly<AppearancePreferenceValues>;\n}\n\n/**\n * Declare where a person's appearance and density are kept and what the app locks. Checks the\n * lock and returns it frozen; throws on a value that isn't an appearance or a density.\n *\n * ```ts\n * export const appearance = defineAppearancePreferences({\n * store: {\n * read: () => api.myPreferences(), // { appearance: \"dark\", density: \"compact\" }\n * write: (values) => api.saveMyPreferences(values),\n * },\n * lock: { density: \"comfortable\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineAppearancePreferences(definition: AppearancePreferencesDefinition = {}): AppearancePreferences {\n const problems: string[] = [];\n const lock = definition.lock ?? {};\n if (lock.appearance !== undefined && !isAppearance(lock.appearance)) problems.push(`lock.appearance: one of ${APPEARANCES.join(\", \")}`);\n if (lock.density !== undefined && !isDensity(lock.density)) problems.push(`lock.density: one of ${DENSITIES.join(\", \")}`);\n if (definition.store && (typeof definition.store.read !== \"function\" || typeof definition.store.write !== \"function\"))\n problems.push(\"store: an object with read() and write()\");\n if (definition.storageKey !== undefined && (typeof definition.storageKey !== \"string\" || !definition.storageKey.trim()))\n problems.push(\"storageKey: a non-empty string\");\n if (problems.length) throw new Error(`defineAppearancePreferences: ${problems.join(\"; \")}`);\n return Object.freeze({\n ...(definition.store ? { store: definition.store } : {}),\n storageKey: definition.storageKey ?? \"genesis-appearance\",\n lock: Object.freeze(toAppearancePreferenceValues(lock)),\n });\n}\n\n/** What `useAppearancePreferences` returns. */\nexport interface UseAppearancePreferencesReturn extends ResolvedAppearancePreferences {\n /** The person's own choice (the store's, else this device's), before the order is applied. */\n person: AppearancePreferenceValues;\n /** Which values the app has locked. */\n locked: { appearance: boolean; density: boolean };\n /**\n * Every layer as given, for a component with a default of its own to put in the order\n * (`AppShell` puts its `options.density` under the theme's).\n */\n layers: AppearancePreferenceLayers;\n /** False until the store's first read has answered. */\n ready: boolean;\n /** Save the person's appearance (`undefined` clears it back to the defaults). Ignored when locked. */\n setAppearance(appearance: Appearance | undefined): void;\n /** Save the person's density (`undefined` clears it). Ignored when locked. */\n setDensity(density: Density | undefined): void;\n}\n\nconst AppearancePreferencesContext = createContext<UseAppearancePreferencesReturn | null>(null);\n\nconst FORMAT = {\n parse: (raw: string) => {\n try {\n return toAppearancePreferenceValues(JSON.parse(raw));\n } catch {\n return undefined;\n }\n },\n};\nconst NONE: AppearancePreferenceValues = {};\n\nexport interface AppearancePreferencesProviderProps {\n /** From `defineAppearancePreferences`. Default: this device only, nothing locked. */\n preferences?: AppearancePreferences;\n /** The active organization's defaults (`resolveWorkspaceAppearance(workspace)`). */\n organization?: AppearancePreferenceValues | undefined;\n /** The app theme's defaults. */\n theme?: AppearancePreferenceValues | undefined;\n children: ReactNode;\n}\n\nconst DEVICE_ONLY = defineAppearancePreferences();\n\n/**\n * Serves a person's appearance and density to the tree, resolved in the written order. Reads the\n * store once on mount (and on its `subscribe`), keeps a copy on the device, and writes both when\n * the person changes a value.\n *\n * @stability Beta\n */\nexport function AppearancePreferencesProvider({ preferences = DEVICE_ONLY, organization, theme, children }: AppearancePreferencesProviderProps) {\n const { store, storageKey, lock } = preferences;\n const [device, setDevice] = usePersistedUiState<AppearancePreferenceValues>(storageKey, NONE, FORMAT);\n const [stored, setStored] = useState<AppearancePreferenceValues | null | undefined>(undefined);\n const [ready, setReady] = useState(!store);\n const latestStore = useRef(store);\n latestStore.current = store;\n\n useEffect(() => {\n if (!store) return;\n let active = true;\n Promise.resolve()\n .then(() => store.read())\n .then(\n (values) => {\n if (!active) return;\n setStored(values ? toAppearancePreferenceValues(values) : null);\n setReady(true);\n },\n (error: unknown) => {\n // A store that can't be read leaves the device's copy in charge.\n reportError(error, \"core:appearance-preferences\");\n if (active) setReady(true);\n },\n );\n const unsubscribe = store.subscribe?.((values) => {\n if (active) setStored(values ? toAppearancePreferenceValues(values) : null);\n });\n return () => {\n active = false;\n unsubscribe?.();\n };\n }, [store]);\n\n // The store's answer is the person's choice; the device's copy fills in until it comes, and\n // when there is no store.\n const person = useMemo<AppearancePreferenceValues>(() => ({ ...device, ...(stored ?? {}) }), [device, stored]);\n\n const save = useCallback(\n (patch: AppearancePreferenceValues) => {\n // An undefined value in the patch clears that key: the spread sets it, and the check drops it.\n const next = toAppearancePreferenceValues({ ...person, ...patch });\n setDevice(Object.keys(next).length ? next : undefined);\n if (latestStore.current) {\n setStored(next);\n void Promise.resolve()\n .then(() => latestStore.current?.write(next))\n .catch((error: unknown) => {\n reportError(error, \"core:appearance-preferences\");\n });\n }\n },\n [person, setDevice],\n );\n\n const value = useMemo<UseAppearancePreferencesReturn>(() => {\n const layers: AppearancePreferenceLayers = { lock, person, organization, theme };\n const resolved = resolveAppearancePreferences(layers);\n const locked = { appearance: lock.appearance !== undefined, density: lock.density !== undefined };\n return {\n ...resolved,\n person,\n locked,\n layers,\n ready,\n setAppearance: (appearance) => {\n if (!locked.appearance) save({ appearance });\n },\n setDensity: (density) => {\n if (!locked.density) save({ density });\n },\n };\n }, [lock, person, organization, theme, ready, save]);\n\n return <AppearancePreferencesContext.Provider value={value}>{children}</AppearancePreferencesContext.Provider>;\n}\n\n/**\n * The person's appearance and density, resolved, with setters. Throws outside an\n * `AppearancePreferencesProvider`; a component that works with or without one reads\n * `useOptionalAppearancePreferences`.\n *\n * @stability Beta\n */\nexport function useAppearancePreferences(): UseAppearancePreferencesReturn {\n const value = useContext(AppearancePreferencesContext);\n if (!value) throw new Error(\"useAppearancePreferences: no AppearancePreferencesProvider above this component.\");\n return value;\n}\n\n/**\n * Like `useAppearancePreferences`, but null outside a provider: for a component (a shell, a\n * theme provider) that keeps its own behaviour when an app hasn't set preferences up.\n *\n * @stability Beta\n */\nexport function useOptionalAppearancePreferences(): UseAppearancePreferencesReturn | null {\n return useContext(AppearancePreferencesContext);\n}\n"]}
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { D as DataProvider, d as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, n as CountMode, a as FilterParam } from '../types-
|
|
2
|
-
export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, l as BulkChange, m as BulkResult, o as CreateParams, p as CreateResult, q as DeleteParams, r as DeleteResult, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, c as ListParams, L as ListResult, N as NullFilter, z as PaginationParam, E as RangeFilter, g as ResourceChangeEvent, V as RowFailure, Y as ScalarFilter, S as SortParam, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult } from '../types-
|
|
3
|
-
export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-
|
|
4
|
-
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-
|
|
5
|
-
export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../write-outcome-
|
|
1
|
+
import { D as DataProvider, d as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, n as CountMode, a as FilterParam } from '../types-BriIV4e_.js';
|
|
2
|
+
export { i as AggregateMetric, A as AggregateParams, b as AggregateResult, k as ArrayFilter, l as BulkChange, m as BulkResult, o as CreateParams, p as CreateResult, q as DeleteParams, r as DeleteResult, G as GetManyParams, v as GetManyResult, w as GetOneParams, x as GetOneResult, H as HistoryParams, y as ImportParams, c as ListParams, L as ListResult, N as NullFilter, z as PaginationParam, E as RangeFilter, g as ResourceChangeEvent, V as RowFailure, Y as ScalarFilter, S as SortParam, f as SubscribeParams, $ as UpdateParams, a0 as UpdateResult } from '../types-BriIV4e_.js';
|
|
3
|
+
export { R as ResolveAggregateOptions, a as aggregateProblems, r as resolveAggregate, t as toAggregateValues } from '../aggregate-Y5IJ5aPn.js';
|
|
4
|
+
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-CkQXgtJq.js';
|
|
5
|
+
export { a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, i as isDataWriteError } from '../write-outcome-CkQXgtJq.js';
|
|
6
6
|
import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
|
|
7
7
|
export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
|
|
8
8
|
import * as react from 'react';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as ResourceContract, j as DataRow, X as RowOf, d as Identifier, U as RowAction, F as FieldSchema, a as FilterParam, i as AggregateMetric, S as SortParam, A as AggregateParams } from '../types-
|
|
1
|
+
import { M as ResourceContract, j as DataRow, X as RowOf, d as Identifier, U as RowAction, F as FieldSchema, a as FilterParam, i as AggregateMetric, S as SortParam, A as AggregateParams } from '../types-BriIV4e_.js';
|
|
2
2
|
import { R as Readiness, C as ChipTone } from '../status-BXRokZD9.js';
|
|
3
3
|
import { V as Viewer, R as ResourceScope } from '../viewer-scope-Dx0N9AYk.js';
|
|
4
4
|
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-Dx0N9AYk.js';
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as ResourceContract, d as Identifier, j as DataRow } from '../types-
|
|
2
|
-
export { h as AuditEntry, C as ControlHint, s as FieldPermissions, e as FieldReference, F as FieldSchema, u as FilterOperator, P as ProviderCapabilities, J as RecordComment, K as ResourceAccess, O as ResourceRelation, Q as ResourceSchema, T as ResourceSummary, U as RowAction, X as RowOf, _ as StorageType, a1 as VersionField, a2 as WidgetHint, a3 as defineResource, a4 as fieldControl } from '../types-
|
|
3
|
-
export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from '../write-outcome-
|
|
1
|
+
import { M as ResourceContract, d as Identifier, j as DataRow } from '../types-BriIV4e_.js';
|
|
2
|
+
export { h as AuditEntry, C as ControlHint, s as FieldPermissions, e as FieldReference, F as FieldSchema, u as FilterOperator, P as ProviderCapabilities, J as RecordComment, K as ResourceAccess, O as ResourceRelation, Q as ResourceSchema, T as ResourceSummary, U as RowAction, X as RowOf, _ as StorageType, a1 as VersionField, a2 as WidgetHint, a3 as defineResource, a4 as fieldControl } from '../types-BriIV4e_.js';
|
|
3
|
+
export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from '../write-outcome-CkQXgtJq.js';
|
|
4
4
|
export { W as WriteConflict, a as WriteConflictOptions, b as WriteState, w as writeConflict } from '../write-state-DVC4Yq9T.js';
|
|
5
5
|
export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
|
|
6
6
|
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DataProvider, d as Identifier } from '../types-
|
|
2
|
-
import { D as DataWriteError } from '../write-outcome-
|
|
1
|
+
import { D as DataProvider, d as Identifier } from '../types-BriIV4e_.js';
|
|
2
|
+
import { D as DataWriteError } from '../write-outcome-CkQXgtJq.js';
|
|
3
3
|
|
|
4
4
|
/** The shared fixture logins, the same ids `genesis_testing.user_id()` uses. */
|
|
5
5
|
declare const FIXTURE_USERS: {
|
|
@@ -110,6 +110,8 @@ interface ResourceFormFieldDef {
|
|
|
110
110
|
arrayMin?: number;
|
|
111
111
|
/** Maximum number of array items. */
|
|
112
112
|
arrayMax?: number;
|
|
113
|
+
/** One array item's name, for the add button ("Address" makes "Add Address"). Default: the label, made singular. */
|
|
114
|
+
arrayItemLabel?: string;
|
|
113
115
|
/** Group heading for field grouping in the form. */
|
|
114
116
|
group?: string;
|
|
115
117
|
/** Column span in 2-column layout. Default 1. */
|
|
@@ -251,5 +251,13 @@ declare function filterWorkspaces<W extends Workspace>(workspaces: readonly W[],
|
|
|
251
251
|
* @stability Beta
|
|
252
252
|
*/
|
|
253
253
|
declare function orderedWorkspaces<W extends Workspace>(workspaces: readonly W[], order?: readonly WorkspaceKind[]): W[];
|
|
254
|
+
/** With a switcher's `search="auto"`, past this many workspaces it opens with a search box. On the web and the phone. */
|
|
255
|
+
declare const WORKSPACE_SWITCHER_SEARCH_THRESHOLD = 7;
|
|
256
|
+
/** The default heading over each kind's group in a switcher, on the web and the phone. */
|
|
257
|
+
declare const DEFAULT_WORKSPACE_KIND_LABELS: Readonly<Partial<Record<WorkspaceKind, string>>>;
|
|
258
|
+
/** Whether a workspace's badge shows: `0`, an empty string, `null` and undefined show nothing. */
|
|
259
|
+
declare function hasWorkspaceBadge(value: Workspace["badge"]): value is string | number;
|
|
260
|
+
/** What a screen reader hears for a badge: "3 new" for a number, the text itself otherwise. */
|
|
261
|
+
declare function workspaceBadgeLabel(_workspace: Workspace, value: string | number): string;
|
|
254
262
|
|
|
255
|
-
export { type AppearancePreferenceValues as A, type Density as D, GENESIS_APPEARANCE_DEFAULTS as G, type ResolvedAppearancePreferences as R, type Workspace as W, type AppearancePreferenceLayers as a, type Appearance as b, APPEARANCES as c, type AppearancePreferenceSource as d, DENSITIES as e, isDensity as f, type WorkspaceHrefOptions as g,
|
|
263
|
+
export { type AppearancePreferenceValues as A, workspaceAt as B, workspaceBadgeLabel as C, type Density as D, workspaceHref as E, workspaceInitials as F, GENESIS_APPEARANCE_DEFAULTS as G, type ResolvedAppearancePreferences as R, type Workspace as W, type AppearancePreferenceLayers as a, type Appearance as b, APPEARANCES as c, type AppearancePreferenceSource as d, DENSITIES as e, isDensity as f, type WorkspaceHrefOptions as g, DEFAULT_WORKSPACE_KIND_LABELS as h, isAppearance as i, type GenesisWorkspaceKinds as j, WORKSPACE_KIND_ORDER as k, WORKSPACE_SWITCHER_SEARCH_THRESHOLD as l, type WorkspaceGroup as m, type WorkspaceKind as n, type WorkspaceTheme as o, defaultWorkspace as p, filterWorkspaces as q, resolveAppearancePreferences as r, groupWorkspaces as s, toAppearancePreferenceValues as t, hasWorkspaceBadge as u, keepSection as v, orderedWorkspaces as w, pathInWorkspace as x, resolveWorkspaceAppearance as y, resolveWorkspaceBrand as z };
|
package/dist/workspaces.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './viewer-scope-Dx0N9AYk.js';
|
|
2
|
-
export { h as
|
|
2
|
+
export { h as DEFAULT_WORKSPACE_KIND_LABELS, j as GenesisWorkspaceKinds, k as WORKSPACE_KIND_ORDER, l as WORKSPACE_SWITCHER_SEARCH_THRESHOLD, W as Workspace, m as WorkspaceGroup, g as WorkspaceHrefOptions, n as WorkspaceKind, o as WorkspaceTheme, p as defaultWorkspace, q as filterWorkspaces, s as groupWorkspaces, u as hasWorkspaceBadge, v as keepSection, w as orderedWorkspaces, x as pathInWorkspace, y as resolveWorkspaceAppearance, z as resolveWorkspaceBrand, B as workspaceAt, C as workspaceBadgeLabel, E as workspaceHref, F as workspaceInitials } from './workspaces-CxpiFu2-.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@tanstack/react-query';
|
|
5
5
|
import './dates.js';
|
package/dist/workspaces.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { WORKSPACE_KIND_ORDER, defaultWorkspace, filterWorkspaces, groupWorkspaces, keepSection, orderedWorkspaces, pathInWorkspace, resolveWorkspaceAppearance, resolveWorkspaceBrand, workspaceAt, workspaceHref, workspaceInitials } from './chunk-
|
|
1
|
+
export { DEFAULT_WORKSPACE_KIND_LABELS, WORKSPACE_KIND_ORDER, WORKSPACE_SWITCHER_SEARCH_THRESHOLD, defaultWorkspace, filterWorkspaces, groupWorkspaces, hasWorkspaceBadge, keepSection, orderedWorkspaces, pathInWorkspace, resolveWorkspaceAppearance, resolveWorkspaceBrand, workspaceAt, workspaceBadgeLabel, workspaceHref, workspaceInitials } from './chunk-APFXV6FZ.js';
|
|
2
|
+
import './chunk-BDPRWVFW.js';
|
|
2
3
|
//# sourceMappingURL=workspaces.js.map
|
|
3
4
|
//# sourceMappingURL=workspaces.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -104,6 +104,10 @@
|
|
|
104
104
|
"types": "./dist/csv.d.ts",
|
|
105
105
|
"import": "./dist/csv.js"
|
|
106
106
|
},
|
|
107
|
+
"./headless": {
|
|
108
|
+
"types": "./dist/headless/index.d.ts",
|
|
109
|
+
"import": "./dist/headless/index.js"
|
|
110
|
+
},
|
|
107
111
|
"./errors": {
|
|
108
112
|
"types": "./dist/errors.d.ts",
|
|
109
113
|
"import": "./dist/errors.js"
|
|
@@ -115,19 +119,19 @@
|
|
|
115
119
|
"README.md"
|
|
116
120
|
],
|
|
117
121
|
"peerDependencies": {
|
|
118
|
-
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
122
|
+
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
119
123
|
"@tanstack/react-query": "^5.0.0",
|
|
120
124
|
"react": "^19.0.0",
|
|
121
125
|
"react-hook-form": "^7.0.0",
|
|
122
126
|
"zod": "^3.0.0 || ^4.0.0"
|
|
123
127
|
},
|
|
124
128
|
"devDependencies": {
|
|
125
|
-
"@hookform/resolvers": "^
|
|
129
|
+
"@hookform/resolvers": "^7.0.1",
|
|
126
130
|
"@tanstack/react-query": "^5.105.0",
|
|
127
131
|
"@testing-library/react": "^16.3.2",
|
|
128
132
|
"@types/react": "^19.2.14",
|
|
129
133
|
"@types/react-dom": "^19.2.3",
|
|
130
|
-
"fake-indexeddb": "6.2.
|
|
134
|
+
"fake-indexeddb": "6.2.7",
|
|
131
135
|
"happy-dom": "^21.0.4",
|
|
132
136
|
"react": "^19.0.0",
|
|
133
137
|
"react-dom": "^19.0.0",
|
|
@@ -231,6 +235,12 @@
|
|
|
231
235
|
"need": "write errors and refusals",
|
|
232
236
|
"use": "DataWriteError and readFailureMessage",
|
|
233
237
|
"import": "@marktiderman/genesis-core/errors"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"need": "an organization's own brand and defaults inside the app",
|
|
241
|
+
"use": "WorkspaceTheme's brand and defaults, read with resolveWorkspaceBrand and resolveWorkspaceAppearance",
|
|
242
|
+
"import": "@marktiderman/genesis-core/workspaces",
|
|
243
|
+
"docs": "https://github.com/marktiderman/genesis/blob/main/docs/adr/0024-who-sets-what.md"
|
|
234
244
|
}
|
|
235
245
|
]
|
|
236
246
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/appearance-values.ts","../src/workspaces.ts"],"names":[],"mappings":";AAeO,IAAM,cAAqC,MAAA,CAAO,MAAA,CAAO,CAAC,QAAA,EAAU,OAAA,EAAS,MAAM,CAAC;AAEpF,IAAM,YAAgC,MAAA,CAAO,MAAA,CAAO,CAAC,SAAA,EAAW,aAAA,EAAe,UAAU,CAAC;AAS1F,IAAM,2BAAA,GAA8E,OAAO,MAAA,CAAO;AAAA,EACvG,UAAA,EAAY,QAAA;AAAA,EACZ,OAAA,EAAS;AACX,CAAC;AAyBM,IAAM,eAAe,CAAC,CAAA,KAAgC,MAAM,OAAA,IAAW,CAAA,KAAM,UAAU,CAAA,KAAM;AAE7F,IAAM,YAAY,CAAC,CAAA,KAA6B,MAAM,SAAA,IAAa,CAAA,KAAM,iBAAiB,CAAA,KAAM;AAGhG,SAAS,6BAA6B,KAAA,EAA4C;AACvF,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,SAAiB,EAAC;AACjD,EAAA,MAAM,EAAE,UAAA,EAAY,OAAA,EAAQ,GAAI,KAAA;AAChC,EAAA,OAAO,EAAE,GAAI,YAAA,CAAa,UAAU,CAAA,GAAI,EAAE,YAAW,GAAI,EAAC,EAAI,GAAI,UAAU,OAAO,CAAA,GAAI,EAAE,OAAA,EAAQ,GAAI,EAAC,EAAG;AAC3G;AASO,SAAS,6BAA6B,MAAA,EAAmE;AAC9G,EAAA,MAAM,KAAA,GAAg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A,CACd,UAAA,EACA,KAAA,GAAkC,oBAAA,EAC7B;AACL,EAAA,OAAO,eAAA,CAAgB,YAAY,KAAK,CAAA,CAAE,QAAQ,CAAC,CAAA,KAAM,EAAE,UAAU,CAAA;AACvE","file":"chunk-JTRRAVR4.js","sourcesContent":["/**\n * Appearance preferences, as data (ADR 0024): the values and the order that decides which one\n * applies. No React, so a server, a phone or `workspaces.ts` can use it; the provider is\n * `appearance.tsx`.\n *\n * app lock > person > organization default > theme default > Genesis default\n */\n\n/** Light, dark, or follow the device: the person's appearance. */\nexport type Appearance = \"light\" | \"dark\" | \"system\";\n\n/** How tightly rows and controls sit. */\nexport type Density = \"compact\" | \"comfortable\" | \"spacious\";\n\n/** The appearances, in a picker's order. */\nexport const APPEARANCES: readonly Appearance[] = Object.freeze([\"system\", \"light\", \"dark\"]);\n/** The densities, tightest first. */\nexport const DENSITIES: readonly Density[] = Object.freeze([\"compact\", \"comfortable\", \"spacious\"]);\n\n/** An appearance and a density, either of which may be unset. */\nexport interface AppearancePreferenceValues {\n appearance?: Appearance | undefined;\n density?: Density | undefined;\n}\n\n/** Genesis's own defaults, the last step of the order. */\nexport const GENESIS_APPEARANCE_DEFAULTS: Readonly<Required<AppearancePreferenceValues>> = Object.freeze({\n appearance: \"system\",\n density: \"comfortable\",\n});\n\n/** Where a resolved value came from. */\nexport type AppearancePreferenceSource = \"app\" | \"person\" | \"organization\" | \"theme\" | \"genesis\";\n\n/** Each layer of the order; any may be missing. */\nexport interface AppearancePreferenceLayers {\n /** The app's lock: a value set here can't be changed by anyone below it. */\n lock?: AppearancePreferenceValues | undefined;\n /** The person's own choice. */\n person?: AppearancePreferenceValues | undefined;\n /** The organization's default for its people (`WorkspaceTheme.defaults`). */\n organization?: AppearancePreferenceValues | undefined;\n /** The app theme's default (its layout's density, say). */\n theme?: AppearancePreferenceValues | undefined;\n}\n\n/** The values that apply, and where each came from. */\nexport interface ResolvedAppearancePreferences {\n appearance: Appearance;\n density: Density;\n source: { appearance: AppearancePreferenceSource; density: AppearancePreferenceSource };\n}\n\n/** Whether a value is an appearance. */\nexport const isAppearance = (v: unknown): v is Appearance => v === \"light\" || v === \"dark\" || v === \"system\";\n/** Whether a value is a density. */\nexport const isDensity = (v: unknown): v is Density => v === \"compact\" || v === \"comfortable\" || v === \"spacious\";\n\n/** Only the known values: a stored or typed-in value that isn't one is left out. */\nexport function toAppearancePreferenceValues(input: unknown): AppearancePreferenceValues {\n if (!input || typeof input !== \"object\") return {};\n const { appearance, density } = input as Record<string, unknown>;\n return { ...(isAppearance(appearance) ? { appearance } : {}), ...(isDensity(density) ? { density } : {}) };\n}\n\n/**\n * The appearance and density that apply: app lock, then the person, then the organization's\n * default, then the theme's, then Genesis's. Values that aren't known appearances or densities\n * are skipped, so a bad stored value falls through to the next layer.\n *\n * @stability Beta\n */\nexport function resolveAppearancePreferences(layers: AppearancePreferenceLayers): ResolvedAppearancePreferences {\n const order: [AppearancePreferenceSource, AppearancePreferenceValues | undefined][] = [\n [\"app\", layers.lock],\n [\"person\", layers.person],\n [\"organization\", layers.organization],\n [\"theme\", layers.theme],\n [\"genesis\", GENESIS_APPEARANCE_DEFAULTS],\n ];\n const pick = <K extends keyof AppearancePreferenceValues>(key: K, valid: (v: unknown) => boolean) => {\n for (const [source, values] of order) {\n const value = values?.[key];\n if (valid(value)) return { value: value as NonNullable<AppearancePreferenceValues[K]>, source };\n }\n return { value: GENESIS_APPEARANCE_DEFAULTS[key] as NonNullable<AppearancePreferenceValues[K]>, source: \"genesis\" as const };\n };\n const appearance = pick(\"appearance\", isAppearance);\n const density = pick(\"density\", isDensity);\n return {\n appearance: appearance.value as Appearance,\n density: density.value as Density,\n source: { appearance: appearance.source, density: density.source },\n };\n}\n\n","/**\n * Workspaces (docs/adr/0004-workspaces.md): where the viewer is working, chosen first and kept in\n * the URL. A workspace is one tenant (an organization), the roll-up across them, or the viewer's\n * own personal space. Everything inside it is scoped to it: its `scope` is the `ResourceScope`\n * every view reads, and its path prefixes every URL inside it.\n *\n * Router-free and DOM-free, like `navigation`: web and native shells share it.\n */\n\nimport type { ResourceScope } from \"./hooks/viewer-scope\";\nimport type { GenesisViewerRoles } from \"./viewer\";\nimport { toAppearancePreferenceValues, type AppearancePreferenceValues } from \"./appearance-values\";\n\n/**\n * The kinds of workspace. Genesis ships three; an app adds its own by module augmentation, and\n * the switcher groups and orders them like the built-in ones:\n *\n * ```ts\n * declare module \"@marktiderman/genesis-core/workspaces\" {\n * interface GenesisWorkspaceKinds {\n * location: true;\n * }\n * }\n * ```\n *\n * @stability Beta\n */\nexport interface GenesisWorkspaceKinds {\n /** One tenant: an organization the viewer is a member or staff of. */\n tenant: true;\n /** The roll-up across every tenant the viewer works in. */\n rollup: true;\n /** The viewer's own things, belonging to no tenant. */\n personal: true;\n}\n\n/** @stability Beta */\nexport type WorkspaceKind = keyof GenesisWorkspaceKinds;\n\n/**\n * One place the viewer can work in.\n *\n * @stability Beta\n */\nexport interface Workspace {\n /** Unique among the viewer's workspaces. For a tenant, usually its URL segment. */\n id: string;\n kind: WorkspaceKind;\n /** Its name: the organization's name, \"All organizations\", \"Personal\". */\n label: string;\n /** A second line in the switcher: the viewer's role there, a location. */\n description?: string;\n /**\n * Where it starts, and the prefix of every URL inside it: `/o/acme`, `/all`, `/me`. Matched at\n * segment boundaries, so `/o/acme` never matches `/o/acme-west`.\n */\n path: string;\n /** What views read inside it: `{ orgId }`, `{ orgId: [...] }`, `{ personId }`. */\n scope: ResourceScope;\n /** The viewer's roles here, for view guards (see `GenesisViewerRoles`). */\n roles?: GenesisViewerRoles;\n /** The workspace's IANA time zone, for columns read on the scope's clock. */\n timeZone?: string | null;\n /** Its picture: a logo URL, else initials made from `label`. */\n image?: string;\n /**\n * A count or short status beside it in the switcher: unread messages, tasks waiting. `0`, an\n * empty string, `null` and undefined show nothing.\n */\n badge?: string | number | null;\n /** Its brand, for the switcher's picture and anything the app themes inside it. */\n theme?: WorkspaceTheme;\n /** Anything else the app needs; Genesis never reads it. */\n meta?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * A workspace's brand. `accent` takes the same values as a public page's brand accent (`#rgb`,\n * `#rrggbb`, `rgb()`, `hsl()` or a bare token triplet like `\"160 84% 39%\"`); genesis-ui turns it\n * into the design system's `--primary` (`workspaceThemeStyle`), darkened when it is too light to\n * carry text.\n *\n * @stability Beta\n */\nexport interface WorkspaceTheme {\n accent?: string;\n /**\n * The app brand this organization wears, by id (`defineAppBrand`'s name, what\n * `data-app-brand` names): its colours and typefaces across the app while the workspace is\n * active. `resolveWorkspaceBrand` picks it, checked against the brands the app ships.\n */\n brand?: string;\n /**\n * The organization's defaults for its people's appearance and density. A person's own choice\n * wins over them, and the app's lock over that (`resolveAppearancePreferences`).\n */\n defaults?: AppearancePreferenceValues;\n}\n\n/**\n * The app brand that applies in a workspace: its `theme.brand` when the app ships a brand by\n * that id (`available`, ids or anything with an `id`), else `fallback`. Without `available`,\n * any brand id is taken as given.\n *\n * ```ts\n * const brand = resolveWorkspaceBrand(active, { available: STARTER_BRANDS, fallback: \"acme\" });\n * document.documentElement.dataset.appBrand = brand;\n * ```\n *\n * @stability Beta\n */\nexport function resolveWorkspaceBrand(\n workspace: Pick<Workspace, \"theme\"> | null | undefined,\n options: { available?: readonly (string | { readonly id: string })[]; fallback?: string } = {},\n): string | undefined {\n const wanted = workspace?.theme?.brand;\n if (wanted) {\n const ids = options.available?.map((b) => (typeof b === \"string\" ? b : b.id));\n if (!ids || ids.includes(wanted)) return wanted;\n if (process.env.NODE_ENV !== \"production\") {\n // genesis-allow-console: a development hint about the app's own data, not a caught error.\n console.warn(`[genesis-core] resolveWorkspaceBrand: the workspace asks for brand \"${wanted}\", which the app doesn't ship.`);\n }\n }\n return options.fallback;\n}\n\n/**\n * The organization's appearance and density defaults, for `AppearancePreferencesProvider`'s\n * `organization`: only known values, empty without a workspace.\n *\n * @stability Beta\n */\nexport function resolveWorkspaceAppearance(workspace: Pick<Workspace, \"theme\"> | null | undefined): AppearancePreferenceValues {\n return toAppearancePreferenceValues(workspace?.theme?.defaults);\n}\n\n/** The kinds in their default order: personal, roll-up, then each tenant. */\nexport const WORKSPACE_KIND_ORDER: readonly WorkspaceKind[] = [\"personal\", \"rollup\", \"tenant\"];\n\nfunction trimPath(path: string): string {\n const bare = path.split(/[?#]/)[0] ?? \"\";\n // Trailing slashes off, keeping \"/\" itself. A loop, not /\\/+$/, which is slow on many slashes.\n let end = bare.length;\n while (end > 1 && bare[end - 1] === \"/\") end--;\n return bare.slice(0, end);\n}\n\nfunction within(pathname: string, prefix: string): boolean {\n const p = trimPath(pathname);\n const w = trimPath(prefix);\n if (w === \"/\") return true;\n return p === w || p.startsWith(`${w}/`);\n}\n\n/**\n * The workspace a URL is in: the one whose `path` is the longest prefix of `pathname`, or\n * undefined when the URL is in none (a sign-in page, the app's front door).\n *\n * @stability Beta\n */\nexport function workspaceAt<W extends Workspace>(workspaces: readonly W[], pathname: string): W | undefined {\n let best: W | undefined;\n for (const w of workspaces) {\n if (within(pathname, w.path) && (!best || trimPath(w.path).length > trimPath(best.path).length)) best = w;\n }\n return best;\n}\n\n/**\n * The path inside a workspace: `/o/acme/clients/42` in `/o/acme` is `/clients/42`; the workspace's\n * own landing page is `/`.\n *\n * @stability Beta\n */\nexport function pathInWorkspace(workspace: Pick<Workspace, \"path\">, pathname: string): string {\n const w = trimPath(workspace.path);\n const p = trimPath(pathname);\n if (!within(p, w)) return \"/\";\n const rest = w === \"/\" ? p : p.slice(w.length);\n return rest || \"/\";\n}\n\n/** @stability Beta */\nexport interface WorkspaceHrefOptions {\n /**\n * Whether to keep the viewer's place when switching: given the path inside the current\n * workspace (`/clients`) and the two workspaces, return the path to open in the target, or\n * false for its landing page. By default the place is kept between workspaces of the same kind,\n * up to the first segment (a list, not one record that belongs to the old workspace):\n * `/o/acme/clients/42` switches to `/o/globex/clients`.\n */\n keep?: (rest: string, from: Workspace, to: Workspace) => string | false;\n}\n\n/** The default `keep`: the same kind keeps the section (the first segment), never a record. */\nexport function keepSection(rest: string, from: Workspace, to: Workspace): string | false {\n if (from.kind !== to.kind) return false;\n const section = rest.split(\"/\").filter(Boolean)[0];\n return section ? `/${section}` : false;\n}\n\n/**\n * Where switching to `to` goes from `pathname`. The URL moves with the viewer: it lands in the same\n * section of the new workspace when that makes sense (see `keep`), else on its landing page.\n *\n * @stability Beta\n */\nexport function workspaceHref(\n workspaces: readonly Workspace[],\n to: Workspace,\n pathname: string | undefined,\n options: WorkspaceHrefOptions = {},\n): string {\n const from = pathname === undefined ? undefined : workspaceAt(workspaces, pathname);\n if (!from || from.id === to.id || pathname === undefined) return to.path;\n const kept = (options.keep ?? keepSection)(pathInWorkspace(from, pathname), from, to);\n if (!kept || kept === \"/\") return to.path;\n const base = trimPath(to.path);\n return `${base === \"/\" ? \"\" : base}${kept.startsWith(\"/\") ? kept : `/${kept}`}`;\n}\n\n/** @stability Beta */\nexport interface WorkspaceGroup<W extends Workspace = Workspace> {\n kind: WorkspaceKind;\n workspaces: W[];\n}\n\n/**\n * The workspaces grouped by kind, in `order` (default {@link WORKSPACE_KIND_ORDER}, then any kind\n * an app added), each group in the order given. Empty groups are left out.\n *\n * @stability Beta\n */\nexport function groupWorkspaces<W extends Workspace>(\n workspaces: readonly W[],\n order: readonly WorkspaceKind[] = WORKSPACE_KIND_ORDER,\n): WorkspaceGroup<W>[] {\n const kinds = [...order];\n for (const w of workspaces) if (!kinds.includes(w.kind)) kinds.push(w.kind);\n return kinds\n .map((kind) => ({ kind, workspaces: workspaces.filter((w) => w.kind === kind) }))\n .filter((g) => g.workspaces.length > 0);\n}\n\n/**\n * The workspace to open when the URL names none (the app's front door): the remembered one if the\n * viewer still has it, else the first tenant, else the first workspace.\n *\n * @stability Beta\n */\nexport function defaultWorkspace<W extends Workspace>(workspaces: readonly W[], rememberedId?: string | null): W | undefined {\n return (\n (rememberedId ? workspaces.find((w) => w.id === rememberedId) : undefined) ??\n workspaces.find((w) => w.kind === \"tenant\") ??\n workspaces[0]\n );\n}\n\n/**\n * Initials for a workspace with no image: the first letters of its first two words.\n *\n * @stability Beta\n */\nexport function workspaceInitials(label: string): string {\n const words = label.trim().split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0]![0], words[1]![0]] : [...(words[0] ?? \"\")].slice(0, 2);\n return letters.join(\"\").toUpperCase();\n}\n\n/**\n * The workspaces whose label or second line contains every word of `query`, ignoring case and\n * accents, in the order given. An empty query keeps them all. For the switcher's search box, on\n * the web and on the phone.\n *\n * @stability Beta\n */\nexport function filterWorkspaces<W extends Workspace>(workspaces: readonly W[], query: string): W[] {\n const words = fold(query).split(/\\s+/).filter(Boolean);\n if (words.length === 0) return [...workspaces];\n return workspaces.filter((w) => {\n const text = fold(`${w.label} ${w.description ?? \"\"}`);\n return words.every((word) => text.includes(word));\n });\n}\n\nfunction fold(text: string): string {\n return text.normalize(\"NFD\").replace(/\\p{M}/gu, \"\").toLowerCase();\n}\n\n/**\n * The workspaces in the order the switcher lists them (grouped by kind, in `order`): the order its\n * keyboard jump numbers them, 1 to 9.\n *\n * @stability Beta\n */\nexport function orderedWorkspaces<W extends Workspace>(\n workspaces: readonly W[],\n order: readonly WorkspaceKind[] = WORKSPACE_KIND_ORDER,\n): W[] {\n return groupWorkspaces(workspaces, order).flatMap((g) => g.workspaces);\n}\n"]}
|