@marktiderman/genesis-core 2.4.1 → 2.5.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 +42 -0
- package/dist/chunk-227N654S.js +497 -0
- package/dist/chunk-227N654S.js.map +1 -0
- package/dist/{chunk-ZIMQUFXD.js → chunk-37RWGNIO.js} +9 -4
- package/dist/chunk-37RWGNIO.js.map +1 -0
- package/dist/{chunk-5NEOX2N7.js → chunk-H2RGMX6L.js} +4 -4
- package/dist/{chunk-5NEOX2N7.js.map → chunk-H2RGMX6L.js.map} +1 -1
- package/dist/dates.d.ts +173 -1
- package/dist/dates.js +1 -1
- package/dist/errors.d.ts +8 -1
- package/dist/errors.js +1 -1
- package/dist/hooks/index.js +3 -3
- package/dist/index.js +3 -3
- package/dist/resource-view/index.d.ts +34 -1
- package/dist/resource-view/index.js +28 -3
- package/dist/resource-view/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3B4IFDMK.js +0 -117
- package/dist/chunk-3B4IFDMK.js.map +0 -1
- package/dist/chunk-ZIMQUFXD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabas
|
|
|
2
2
|
export { defineResource } from './chunk-7FVTGKTX.js';
|
|
3
3
|
export { decodeRecordKey, encodeRecordKey, keyFields } from './chunk-KV2HW4G4.js';
|
|
4
4
|
import './chunk-XCX2TRBL.js';
|
|
5
|
-
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-
|
|
5
|
+
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-H2RGMX6L.js';
|
|
6
6
|
export { useWizard } from './chunk-7KOLYF27.js';
|
|
7
7
|
export { WRITE_FAILED, useWrite } from './chunk-52T2EYXH.js';
|
|
8
8
|
export { NO_VIEWER } from './chunk-OZYF55E3.js';
|
|
@@ -23,8 +23,8 @@ import './chunk-7NUL32W7.js';
|
|
|
23
23
|
export { useCapabilities } from './chunk-LGTXQTHA.js';
|
|
24
24
|
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-VDEW4AOS.js';
|
|
25
25
|
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './chunk-ZYJUEJ4Z.js';
|
|
26
|
-
import './chunk-
|
|
27
|
-
export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './chunk-
|
|
26
|
+
import './chunk-227N654S.js';
|
|
27
|
+
export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './chunk-37RWGNIO.js';
|
|
28
28
|
export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from './chunk-PA6WJE5E.js';
|
|
29
29
|
export { DataReadError, isDataReadError, readFailureMessage } from './chunk-HUNGCTRA.js';
|
|
30
30
|
export { titleCase } from './chunk-RYEXWQFD.js';
|
|
@@ -195,6 +195,29 @@ interface ViewCopy {
|
|
|
195
195
|
filtered?: string;
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
+
/** How a calendar lays out its window: a month grid, 1–4 weeks, a day-by-day agenda, or a row per lane. */
|
|
199
|
+
type ViewCalendarLayout = "month" | "weeks" | "agenda" | "lanes";
|
|
200
|
+
/**
|
|
201
|
+
* How the view's rows show as a calendar: ResourceView's `mode="calendar"` on the web,
|
|
202
|
+
* NativeResourceView's later. Plain values only, so every platform reads the same block; a screen
|
|
203
|
+
* overrides the layout, weeks and anchor, and adds functions (dot colours, `onSelect`).
|
|
204
|
+
*/
|
|
205
|
+
interface ViewCalendar<Name extends string = string> {
|
|
206
|
+
/** The date or timestamp field that places each row. */
|
|
207
|
+
field: Name;
|
|
208
|
+
/** Where a row ends: its last day for a date field, its end instant for a timestamp. */
|
|
209
|
+
endField?: Name;
|
|
210
|
+
/** A yes/no field: the row is all day, its timestamp shown without a time. */
|
|
211
|
+
allDayField?: Name;
|
|
212
|
+
/** The field whose value (or list of values) names a row's lanes: a dot each, a lane each. */
|
|
213
|
+
laneBy?: Name;
|
|
214
|
+
/** Default `month`. */
|
|
215
|
+
layout?: ViewCalendarLayout;
|
|
216
|
+
/** For `weeks`, `agenda` and `lanes`: 1 to 4. Default 2. */
|
|
217
|
+
weeks?: 1 | 2 | 3 | 4;
|
|
218
|
+
/** 0 Sunday or 1 Monday (default). */
|
|
219
|
+
weekStartsOn?: 0 | 1;
|
|
220
|
+
}
|
|
198
221
|
/** What `defineView` accepts. */
|
|
199
222
|
interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {
|
|
200
223
|
copy?: ViewCopy;
|
|
@@ -220,6 +243,8 @@ interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf
|
|
|
220
243
|
summary?: (row: Row) => RowSummary;
|
|
221
244
|
/** The scope keys this view needs above it (`["org_id"]`). They stay out of forms. */
|
|
222
245
|
scope?: readonly FieldNameOf<C>[];
|
|
246
|
+
/** How the rows show as a calendar (`mode="calendar"`). */
|
|
247
|
+
calendar?: ViewCalendar<FieldNameOf<C>>;
|
|
223
248
|
/** Group rows under headers by this field. */
|
|
224
249
|
groupBy?: FieldNameOf<C>;
|
|
225
250
|
/** Default order; `manual: true` turns on drag to reorder, writing this field. */
|
|
@@ -341,6 +366,14 @@ declare function valueText(labels: Readonly<Record<string, string>> | undefined,
|
|
|
341
366
|
* Throws {@link ViewDefinitionError} when it names something the contract doesn't have, so a
|
|
342
367
|
* renamed column fails at start-up, not as a blank cell.
|
|
343
368
|
*/
|
|
369
|
+
/**
|
|
370
|
+
* What's wrong with a calendar block for these fields, one sentence each (empty when it's fine).
|
|
371
|
+
* `defineView` checks the view's own block with it; a renderer checks a screen's overrides merged
|
|
372
|
+
* over that block with it too, so neither can name a field that isn't there or isn't a date.
|
|
373
|
+
*
|
|
374
|
+
* @stability Beta
|
|
375
|
+
*/
|
|
376
|
+
declare function calendarProblems(fields: readonly Pick<FieldSchema, "name" | "type" | "array">[], calendar: Partial<ViewCalendar>): string[];
|
|
344
377
|
declare function defineView<C extends ResourceContract, Row extends DataRow = RowOf<C>>(contract: C, definition?: ViewDefinition<C, Row>): ResourceView<C, Row>;
|
|
345
378
|
|
|
346
379
|
/**
|
|
@@ -649,4 +682,4 @@ type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = strin
|
|
|
649
682
|
/** @deprecated Renamed `RecordViewHeaderAction`. */
|
|
650
683
|
type WorkspaceHeaderAction = RecordViewHeaderAction;
|
|
651
684
|
|
|
652
|
-
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
685
|
+
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
@@ -2,7 +2,7 @@ import { readinessOf } from '../chunk-PP3XFFQM.js';
|
|
|
2
2
|
import { keyFields, encodeRecordKey } from '../chunk-KV2HW4G4.js';
|
|
3
3
|
import { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
4
4
|
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
5
|
-
import { isTimeZone } from '../chunk-
|
|
5
|
+
import { isTimeZone } from '../chunk-227N654S.js';
|
|
6
6
|
import { titleCase } from '../chunk-RYEXWQFD.js';
|
|
7
7
|
import { isSafeUrl } from '../chunk-YDDPFSQ6.js';
|
|
8
8
|
|
|
@@ -83,6 +83,28 @@ function valueText(labels, value) {
|
|
|
83
83
|
const key = String(value);
|
|
84
84
|
return own(labels, key) ?? titleCase(key);
|
|
85
85
|
}
|
|
86
|
+
function calendarProblems(fields, calendar) {
|
|
87
|
+
const problems = [];
|
|
88
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
89
|
+
const typed = (name, where, type) => {
|
|
90
|
+
if (name === void 0) return;
|
|
91
|
+
const f = byName.get(name);
|
|
92
|
+
if (!f) problems.push(`${where} names "${name}", which isn't a field`);
|
|
93
|
+
else if (f.type !== type || f.array) problems.push(`${where} "${name}" isn't a ${type === "datetime" ? "date or timestamp" : "yes/no"} field`);
|
|
94
|
+
};
|
|
95
|
+
typed(calendar.field, "calendar.field", "datetime");
|
|
96
|
+
typed(calendar.endField, "calendar.endField", "datetime");
|
|
97
|
+
typed(calendar.allDayField, "calendar.allDayField", "boolean");
|
|
98
|
+
if (calendar.laneBy !== void 0 && !byName.has(calendar.laneBy)) problems.push(`calendar.laneBy names "${calendar.laneBy}", which isn't a field`);
|
|
99
|
+
if (calendar.layout !== void 0 && !["month", "weeks", "agenda", "lanes"].includes(calendar.layout)) {
|
|
100
|
+
problems.push(`calendar.layout "${String(calendar.layout)}" isn't month, weeks, agenda or lanes`);
|
|
101
|
+
}
|
|
102
|
+
if (calendar.weeks !== void 0 && ![1, 2, 3, 4].includes(calendar.weeks)) problems.push(`calendar.weeks is 1 to 4, not ${String(calendar.weeks)}`);
|
|
103
|
+
if (calendar.weekStartsOn !== void 0 && calendar.weekStartsOn !== 0 && calendar.weekStartsOn !== 1) {
|
|
104
|
+
problems.push(`calendar.weekStartsOn is 0 (Sunday) or 1 (Monday), not ${String(calendar.weekStartsOn)}`);
|
|
105
|
+
}
|
|
106
|
+
return problems;
|
|
107
|
+
}
|
|
86
108
|
function defineView(contract, definition = {}) {
|
|
87
109
|
const facts = contract;
|
|
88
110
|
const fields = contract.fields;
|
|
@@ -183,6 +205,8 @@ function defineView(contract, definition = {}) {
|
|
|
183
205
|
}
|
|
184
206
|
for (const name of scope) known(name, "scope");
|
|
185
207
|
if (definition.groupBy) known(definition.groupBy, "groupBy");
|
|
208
|
+
const calendar = definition.calendar ? Object.freeze({ ...definition.calendar }) : void 0;
|
|
209
|
+
if (calendar) problems.push(...calendarProblems(fields, calendar));
|
|
186
210
|
if (definition.orderBy) known(definition.orderBy.field, "orderBy");
|
|
187
211
|
for (const [name, preset] of Object.entries(presets)) {
|
|
188
212
|
if (preset.columns && preset.columns !== "default" && !own(columnLists, preset.columns)) {
|
|
@@ -335,7 +359,8 @@ function defineView(contract, definition = {}) {
|
|
|
335
359
|
presets,
|
|
336
360
|
...definition.form ? { form: formItems } : {},
|
|
337
361
|
...definition.scope ? { scope: Object.freeze([...definition.scope]) } : {},
|
|
338
|
-
...definition.actions ? { actions: actionList } : {}
|
|
362
|
+
...definition.actions ? { actions: actionList } : {},
|
|
363
|
+
...calendar ? { calendar } : {}
|
|
339
364
|
}),
|
|
340
365
|
resource: contract.name,
|
|
341
366
|
noun,
|
|
@@ -738,6 +763,6 @@ function defineRecordView(view, definition) {
|
|
|
738
763
|
var defineWorkspace = defineRecordView;
|
|
739
764
|
var isWorkspace = isRecordView;
|
|
740
765
|
|
|
741
|
-
export { ViewDefinitionError, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
766
|
+
export { ViewDefinitionError, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
742
767
|
//# sourceMappingURL=index.js.map
|
|
743
768
|
//# sourceMappingURL=index.js.map
|