@mgamadeus/ddd-admin-ui 0.1.0-rc.4 → 0.1.0-rc.6
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/.claude/skills/ddd-admin-ui-specialist/SKILL.md +39 -4
- package/CHANGELOG.md +111 -0
- package/README.md +34 -10
- package/STANDARDS.md +118 -22
- package/dist/components.css +2 -2
- package/dist/form/DrawerFooter.d.ts +9 -1
- package/dist/form/DrawerFooter.d.ts.map +1 -1
- package/dist/form/DrawerFooter.js +33 -32
- package/dist/form/DrawerFooter.js.map +1 -1
- package/dist/form/FormActions.d.ts +18 -13
- package/dist/form/FormActions.d.ts.map +1 -1
- package/dist/form/FormActions.js +110 -33
- package/dist/form/FormActions.js.map +1 -1
- package/dist/form/FormDialog.d.ts +51 -0
- package/dist/form/FormDialog.d.ts.map +1 -0
- package/dist/form/FormDialog.js +75 -0
- package/dist/form/FormDialog.js.map +1 -0
- package/dist/form/FormHeader.d.ts +6 -1
- package/dist/form/FormHeader.d.ts.map +1 -1
- package/dist/form/FormHeader.js +1 -1
- package/dist/form/FormHeader.js.map +1 -1
- package/dist/form/FormSubmitButton.d.ts +6 -1
- package/dist/form/FormSubmitButton.d.ts.map +1 -1
- package/dist/form/FormSubmitButton.js +5 -2
- package/dist/form/FormSubmitButton.js.map +1 -1
- package/dist/form/index.d.ts +2 -0
- package/dist/form/index.d.ts.map +1 -1
- package/dist/form/index.js +1 -0
- package/dist/form/index.js.map +1 -1
- package/dist/form/linkSubmitButtons.d.ts +7 -0
- package/dist/form/linkSubmitButtons.d.ts.map +1 -0
- package/dist/form/linkSubmitButtons.js +27 -0
- package/dist/form/linkSubmitButtons.js.map +1 -0
- package/dist/form/saveShortcut.d.ts +25 -0
- package/dist/form/saveShortcut.d.ts.map +1 -0
- package/dist/form/saveShortcut.js +59 -0
- package/dist/form/saveShortcut.js.map +1 -0
- package/dist/form/useConfirmDialog.d.ts +3 -2
- package/dist/form/useConfirmDialog.d.ts.map +1 -1
- package/dist/form/useConfirmDialog.js +21 -18
- package/dist/form/useConfirmDialog.js.map +1 -1
- package/dist/i18n/hints.json +13 -7
- package/dist/i18n-keys.json +64 -10
- package/dist/list/Combobox.d.ts +33 -3
- package/dist/list/Combobox.d.ts.map +1 -1
- package/dist/list/Combobox.js +71 -13
- package/dist/list/Combobox.js.map +1 -1
- package/dist/list/CopyButton.d.ts +23 -0
- package/dist/list/CopyButton.d.ts.map +1 -0
- package/dist/list/CopyButton.js +28 -0
- package/dist/list/CopyButton.js.map +1 -0
- package/dist/list/EntityListBody.d.ts +2 -2
- package/dist/list/EntityListBody.d.ts.map +1 -1
- package/dist/list/EntityListBody.js +2 -2
- package/dist/list/EntityListBody.js.map +1 -1
- package/dist/list/EntityListBulkBar.d.ts +7 -1
- package/dist/list/EntityListBulkBar.d.ts.map +1 -1
- package/dist/list/EntityListBulkBar.js +5 -1
- package/dist/list/EntityListBulkBar.js.map +1 -1
- package/dist/list/EntityListEmpty.d.ts +6 -1
- package/dist/list/EntityListEmpty.d.ts.map +1 -1
- package/dist/list/EntityListEmpty.js +4 -1
- package/dist/list/EntityListEmpty.js.map +1 -1
- package/dist/list/EntityListTable.d.ts +3 -1
- package/dist/list/EntityListTable.d.ts.map +1 -1
- package/dist/list/EntityListTable.js +4 -4
- package/dist/list/EntityListTable.js.map +1 -1
- package/dist/list/filters.d.ts +8 -1
- package/dist/list/filters.d.ts.map +1 -1
- package/dist/list/filters.js +5 -2
- package/dist/list/filters.js.map +1 -1
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.d.ts.map +1 -1
- package/dist/list/index.js +1 -0
- package/dist/list/index.js.map +1 -1
- package/dist/logic/browser/storage.d.ts +17 -0
- package/dist/logic/browser/storage.d.ts.map +1 -0
- package/dist/logic/browser/storage.js +40 -0
- package/dist/logic/browser/storage.js.map +1 -0
- package/dist/logic/index.d.ts +14 -0
- package/dist/logic/index.d.ts.map +1 -1
- package/dist/logic/index.js +8 -0
- package/dist/logic/index.js.map +1 -1
- package/dist/logic/pure/confirm.d.ts +16 -0
- package/dist/logic/pure/confirm.d.ts.map +1 -1
- package/dist/logic/pure/confirm.js +12 -0
- package/dist/logic/pure/confirm.js.map +1 -1
- package/dist/logic/pure/confirmQueue.d.ts +27 -0
- package/dist/logic/pure/confirmQueue.d.ts.map +1 -0
- package/dist/logic/pure/confirmQueue.js +52 -0
- package/dist/logic/pure/confirmQueue.js.map +1 -0
- package/dist/logic/pure/dateInput.d.ts +21 -0
- package/dist/logic/pure/dateInput.d.ts.map +1 -0
- package/dist/logic/pure/dateInput.js +79 -0
- package/dist/logic/pure/dateInput.js.map +1 -0
- package/dist/logic/pure/stickyParams.d.ts +10 -0
- package/dist/logic/pure/stickyParams.d.ts.map +1 -0
- package/dist/logic/pure/stickyParams.js +31 -0
- package/dist/logic/pure/stickyParams.js.map +1 -0
- package/dist/logic/pure/writeAccess.d.ts +18 -0
- package/dist/logic/pure/writeAccess.d.ts.map +1 -0
- package/dist/logic/pure/writeAccess.js +14 -0
- package/dist/logic/pure/writeAccess.js.map +1 -0
- package/dist/logic/react/useConfirm.d.ts +14 -0
- package/dist/logic/react/useConfirm.d.ts.map +1 -0
- package/dist/logic/react/useConfirm.js +16 -0
- package/dist/logic/react/useConfirm.js.map +1 -0
- package/dist/logic/react/useLatestSearch.d.ts +18 -0
- package/dist/logic/react/useLatestSearch.d.ts.map +1 -0
- package/dist/logic/react/useLatestSearch.js +37 -0
- package/dist/logic/react/useLatestSearch.js.map +1 -0
- package/dist/logic/react/useRowSelection.d.ts +12 -2
- package/dist/logic/react/useRowSelection.d.ts.map +1 -1
- package/dist/logic/react/useRowSelection.js +16 -8
- package/dist/logic/react/useRowSelection.js.map +1 -1
- package/dist/logic/react/writeAccess.d.ts +18 -0
- package/dist/logic/react/writeAccess.d.ts.map +1 -0
- package/dist/logic/react/writeAccess.js +18 -0
- package/dist/logic/react/writeAccess.js.map +1 -0
- package/dist/next/storage.d.ts +2 -10
- package/dist/next/storage.d.ts.map +1 -1
- package/dist/next/storage.js +2 -33
- package/dist/next/storage.js.map +1 -1
- package/dist/page/DefinitionList.d.ts +7 -2
- package/dist/page/DefinitionList.d.ts.map +1 -1
- package/dist/page/DefinitionList.js +4 -1
- package/dist/page/DefinitionList.js.map +1 -1
- package/dist/page/DetailHeader.d.ts +6 -1
- package/dist/page/DetailHeader.d.ts.map +1 -1
- package/dist/page/DetailHeader.js +3 -3
- package/dist/page/DetailHeader.js.map +1 -1
- package/dist/page/EntityDetailShell.d.ts +8 -2
- package/dist/page/EntityDetailShell.d.ts.map +1 -1
- package/dist/page/EntityDetailShell.js +6 -4
- package/dist/page/EntityDetailShell.js.map +1 -1
- package/dist/page/EntityListPage.d.ts +3 -1
- package/dist/page/EntityListPage.d.ts.map +1 -1
- package/dist/page/EntityListPage.js +1 -1
- package/dist/page/EntityListPage.js.map +1 -1
- package/dist/page/EntityTabs.d.ts +2 -2
- package/dist/page/EntityTabs.d.ts.map +1 -1
- package/dist/page/EntityTabs.js +3 -2
- package/dist/page/EntityTabs.js.map +1 -1
- package/dist/page/PageFrame.d.ts +6 -1
- package/dist/page/PageFrame.d.ts.map +1 -1
- package/dist/page/PageFrame.js +1 -1
- package/dist/page/PageFrame.js.map +1 -1
- package/dist/page/PageToolbar.d.ts +4 -3
- package/dist/page/PageToolbar.d.ts.map +1 -1
- package/dist/page/PageToolbar.js +9 -4
- package/dist/page/PageToolbar.js.map +1 -1
- package/dist/page/SectionHeader.d.ts +1 -1
- package/dist/page/SectionHeader.d.ts.map +1 -1
- package/dist/page/links.d.ts +2 -17
- package/dist/page/links.d.ts.map +1 -1
- package/dist/page/links.js +3 -3
- package/dist/page/links.js.map +1 -1
- package/dist/primitives/alert.d.ts +1 -1
- package/dist/primitives/badge.d.ts +1 -1
- package/dist/primitives/breadcrumb.d.ts.map +1 -1
- package/dist/primitives/breadcrumb.js +7 -0
- package/dist/primitives/breadcrumb.js.map +1 -1
- package/dist/primitives/command.js +1 -1
- package/dist/primitives/command.js.map +1 -1
- package/dist/primitives/confirmDialogView.d.ts +29 -0
- package/dist/primitives/confirmDialogView.d.ts.map +1 -0
- package/dist/primitives/confirmDialogView.js +63 -0
- package/dist/primitives/confirmDialogView.js.map +1 -0
- package/dist/primitives/formActionsSlot.d.ts +24 -0
- package/dist/primitives/formActionsSlot.d.ts.map +1 -0
- package/dist/primitives/formActionsSlot.js +51 -0
- package/dist/primitives/formActionsSlot.js.map +1 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/link.d.ts +28 -0
- package/dist/primitives/link.d.ts.map +1 -0
- package/dist/primitives/link.js +15 -0
- package/dist/primitives/link.js.map +1 -0
- package/dist/primitives/segmented-control.d.ts +8 -0
- package/dist/primitives/segmented-control.d.ts.map +1 -1
- package/dist/primitives/segmented-control.js +24 -6
- package/dist/primitives/segmented-control.js.map +1 -1
- package/dist/provider/AdminUiProvider.d.ts +4 -3
- package/dist/provider/AdminUiProvider.d.ts.map +1 -1
- package/dist/provider/AdminUiProvider.js +12 -5
- package/dist/provider/AdminUiProvider.js.map +1 -1
- package/dist/provider/ConfirmHost.d.ts +10 -0
- package/dist/provider/ConfirmHost.d.ts.map +1 -0
- package/dist/provider/ConfirmHost.js +19 -0
- package/dist/provider/ConfirmHost.js.map +1 -0
- package/dist/provider/types.d.ts +12 -0
- package/dist/provider/types.d.ts.map +1 -1
- package/dist/showcase/coverage.d.ts.map +1 -1
- package/dist/showcase/coverage.js +6 -3
- package/dist/showcase/coverage.js.map +1 -1
- package/dist/showcase/sections/FormShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/FormShowcase.js +41 -5
- package/dist/showcase/sections/FormShowcase.js.map +1 -1
- package/dist/showcase/sections/ListShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/ListShowcase.js +36 -6
- package/dist/showcase/sections/ListShowcase.js.map +1 -1
- package/dist/showcase/sections/PageShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/PageShowcase.js +5 -1
- package/dist/showcase/sections/PageShowcase.js.map +1 -1
- package/dist/showcase/sections/PrimitivesShowcase.d.ts.map +1 -1
- package/dist/showcase/sections/PrimitivesShowcase.js +2 -2
- package/dist/showcase/sections/PrimitivesShowcase.js.map +1 -1
- package/dist/translations/TranslationControls.d.ts.map +1 -1
- package/dist/translations/TranslationControls.js +8 -6
- package/dist/translations/TranslationControls.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the screen may write, as a presentation aid: write controls of the blocks (`FormSubmitButton`, the actions of
|
|
3
|
+
* `EntityListBulkBar`, `AddEntityButton` as a button) are disabled while it is `false`. It replaces no handler guard and
|
|
4
|
+
* no server check.
|
|
5
|
+
*/
|
|
6
|
+
export interface WriteAccess {
|
|
7
|
+
allowed: boolean;
|
|
8
|
+
/** Why writes are off (shown as the disabled control's title). */
|
|
9
|
+
reason?: string;
|
|
10
|
+
}
|
|
11
|
+
/** No provider: writes allowed. */
|
|
12
|
+
export declare const WRITE_ACCESS_ALLOWED: WriteAccess;
|
|
13
|
+
/**
|
|
14
|
+
* The access of a nested provider: a subtree can only narrow. An outer `allowed: false` stays, with its reason; an
|
|
15
|
+
* inner `allowed: false` below an allowed parent applies with the inner reason.
|
|
16
|
+
*/
|
|
17
|
+
export declare const narrowWriteAccess: (parent: WriteAccess, own: WriteAccess) => WriteAccess;
|
|
18
|
+
//# sourceMappingURL=writeAccess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeAccess.d.ts","sourceRoot":"","sources":["../../../src/logic/pure/writeAccess.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,mCAAmC;AACnC,eAAO,MAAM,oBAAoB,EAAE,WAA8C,CAAC;AAElF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,WAAW,EAAE,KAAK,WAAW,KAAG,WAIzE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** No provider: writes allowed. */
|
|
2
|
+
export const WRITE_ACCESS_ALLOWED = Object.freeze({ allowed: true });
|
|
3
|
+
/**
|
|
4
|
+
* The access of a nested provider: a subtree can only narrow. An outer `allowed: false` stays, with its reason; an
|
|
5
|
+
* inner `allowed: false` below an allowed parent applies with the inner reason.
|
|
6
|
+
*/
|
|
7
|
+
export const narrowWriteAccess = (parent, own) => {
|
|
8
|
+
if (!parent.allowed)
|
|
9
|
+
return parent;
|
|
10
|
+
if (own.allowed)
|
|
11
|
+
return parent === WRITE_ACCESS_ALLOWED && own.reason === undefined ? WRITE_ACCESS_ALLOWED : { allowed: true };
|
|
12
|
+
return own.reason === undefined ? { allowed: false } : { allowed: false, reason: own.reason };
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=writeAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeAccess.js","sourceRoot":"","sources":["../../../src/logic/pure/writeAccess.ts"],"names":[],"mappings":"AAWA,mCAAmC;AACnC,MAAM,CAAC,MAAM,oBAAoB,GAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAmB,EAAE,GAAgB,EAAe,EAAE;IACtF,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,GAAG,CAAC,OAAO;QAAE,OAAO,MAAM,KAAK,oBAAoB,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC/H,OAAO,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;AAChG,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConfirmFn } from './useUnsavedChangesGuard.js';
|
|
2
|
+
/**
|
|
3
|
+
* The confirmation of the nearest `AdminUiProvider`: the package dialog (calls queue), or the host's own `confirm`
|
|
4
|
+
* passed to the provider. `null` outside a provider.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ConfirmContext: import("react").Context<ConfirmFn | null>;
|
|
7
|
+
/**
|
|
8
|
+
* `confirm(options)` of the nearest `AdminUiProvider`, resolving `true` on confirm and `false` on cancel, Escape or the
|
|
9
|
+
* backdrop; the screen renders nothing. Calls queue and each settles exactly once (an unmounted provider settles its
|
|
10
|
+
* pending calls with `false`). Without a provider every call answers `false` (one warning outside production). The
|
|
11
|
+
* function is stable while the provider is.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useConfirm: () => ConfirmFn;
|
|
14
|
+
//# sourceMappingURL=useConfirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfirm.d.ts","sourceRoot":"","sources":["../../../src/logic/react/useConfirm.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,cAAc,2CAAwC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,SAAiE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { confirmWithoutProvider } from "../pure/confirm.js";
|
|
4
|
+
/**
|
|
5
|
+
* The confirmation of the nearest `AdminUiProvider`: the package dialog (calls queue), or the host's own `confirm`
|
|
6
|
+
* passed to the provider. `null` outside a provider.
|
|
7
|
+
*/
|
|
8
|
+
export const ConfirmContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* `confirm(options)` of the nearest `AdminUiProvider`, resolving `true` on confirm and `false` on cancel, Escape or the
|
|
11
|
+
* backdrop; the screen renders nothing. Calls queue and each settles exactly once (an unmounted provider settles its
|
|
12
|
+
* pending calls with `false`). Without a provider every call answers `false` (one warning outside production). The
|
|
13
|
+
* function is stable while the provider is.
|
|
14
|
+
*/
|
|
15
|
+
export const useConfirm = () => useContext(ConfirmContext) ?? confirmWithoutProvider;
|
|
16
|
+
//# sourceMappingURL=useConfirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfirm.js","sourceRoot":"","sources":["../../../src/logic/react/useConfirm.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAmB,IAAI,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAc,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LatestSearch<TResult> {
|
|
2
|
+
/** The answer to the last term asked for; an older answer arriving later is dropped. */
|
|
3
|
+
results: TResult[];
|
|
4
|
+
/** A request for the last term is in flight. */
|
|
5
|
+
isSearching: boolean;
|
|
6
|
+
/** Asks for `term` (pass it as `Combobox.onSearch`); the previous request is aborted. */
|
|
7
|
+
onSearch: (term: string) => void;
|
|
8
|
+
/** The last term asked for. */
|
|
9
|
+
term: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Server search for a picker (`Combobox.onSearch` / `isSearching`): only the answer to the last term is ever shown.
|
|
13
|
+
* Each call aborts the previous request through its `AbortSignal`, and an answer that arrives after a newer term was
|
|
14
|
+
* asked for (out of order, or ignoring the abort) is dropped. `search` may stay a new function on every render; the
|
|
15
|
+
* latest one is used. A failed request gives no results.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useLatestSearch: <TResult>(search: (term: string, signal: AbortSignal) => Promise<readonly TResult[]>, initialResults?: readonly TResult[]) => LatestSearch<TResult>;
|
|
18
|
+
//# sourceMappingURL=useLatestSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLatestSearch.d.ts","sourceRoot":"","sources":["../../../src/logic/react/useLatestSearch.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY,CAAC,OAAO;IACnC,wFAAwF;IACxF,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,gDAAgD;IAChD,WAAW,EAAE,OAAO,CAAC;IACrB,yFAAyF;IACzF,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,EACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,EAC1E,iBAAgB,SAAS,OAAO,EAAO,KACtC,YAAY,CAAC,OAAO,CA+BtB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Server search for a picker (`Combobox.onSearch` / `isSearching`): only the answer to the last term is ever shown.
|
|
5
|
+
* Each call aborts the previous request through its `AbortSignal`, and an answer that arrives after a newer term was
|
|
6
|
+
* asked for (out of order, or ignoring the abort) is dropped. `search` may stay a new function on every render; the
|
|
7
|
+
* latest one is used. A failed request gives no results.
|
|
8
|
+
*/
|
|
9
|
+
export const useLatestSearch = (search, initialResults = []) => {
|
|
10
|
+
const searchRef = useRef(search);
|
|
11
|
+
searchRef.current = search;
|
|
12
|
+
const requestRef = useRef(0);
|
|
13
|
+
const controllerRef = useRef(null);
|
|
14
|
+
const [state, setState] = useState(() => ({
|
|
15
|
+
results: [...initialResults],
|
|
16
|
+
isSearching: false,
|
|
17
|
+
term: '',
|
|
18
|
+
}));
|
|
19
|
+
useEffect(() => () => controllerRef.current?.abort(), []);
|
|
20
|
+
const onSearch = useCallback((term) => {
|
|
21
|
+
controllerRef.current?.abort();
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
controllerRef.current = controller;
|
|
24
|
+
requestRef.current += 1;
|
|
25
|
+
const request = requestRef.current;
|
|
26
|
+
setState(previous => ({ ...previous, isSearching: true, term }));
|
|
27
|
+
searchRef.current(term, controller.signal).then(results => {
|
|
28
|
+
if (request === requestRef.current)
|
|
29
|
+
setState({ results: [...results], isSearching: false, term });
|
|
30
|
+
}, () => {
|
|
31
|
+
if (request === requestRef.current)
|
|
32
|
+
setState({ results: [], isSearching: false, term });
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
return { ...state, onSearch };
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=useLatestSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLatestSearch.js","sourceRoot":"","sources":["../../../src/logic/react/useLatestSearch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAajE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAA0E,EAC1E,iBAAqC,EAAE,EAChB,EAAE;IACzB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,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;gBAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1F,CAAC,CACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/** What `EntityListTable` needs to draw the checkbox column (the `selection` prop). */
|
|
2
2
|
export interface EntityListSelection<TItem> {
|
|
3
3
|
isItemSelected: (item: TItem) => boolean;
|
|
4
|
-
/** False for a row without a usable key (it gets no checkbox). */
|
|
4
|
+
/** False for a row without a usable key (it gets no checkbox) or one `isSelectable` refuses. */
|
|
5
5
|
isItemSelectable: (item: TItem) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* True for a row with a key that `isSelectable` refuses: the table draws its checkbox disabled (a row without a key
|
|
8
|
+
* still gets none). Absent: no such rows.
|
|
9
|
+
*/
|
|
10
|
+
isItemSelectionDisabled?: (item: TItem) => boolean;
|
|
6
11
|
setItemSelected: (item: TItem, selected: boolean) => void;
|
|
7
12
|
/** The header checkbox: every loaded row, some of them, or none. */
|
|
8
13
|
allLoadedState: boolean | 'indeterminate';
|
|
@@ -21,6 +26,11 @@ export interface UseRowSelectionOptions<TItem, TKey extends string | number> {
|
|
|
21
26
|
resetKey?: string;
|
|
22
27
|
disabled?: boolean;
|
|
23
28
|
rowLabel?: (item: TItem) => string;
|
|
29
|
+
/**
|
|
30
|
+
* False for a row that cannot be selected now (e.g. one without the right to delete): its checkbox is disabled, and
|
|
31
|
+
* "Select all loaded", the header state and the count take only selectable rows. Keep it stable (`useCallback`).
|
|
32
|
+
*/
|
|
33
|
+
isSelectable?: (item: TItem) => boolean;
|
|
24
34
|
}
|
|
25
35
|
export interface RowSelection<TItem, TKey extends string | number> extends EntityListSelection<TItem> {
|
|
26
36
|
/** Selected keys among the loaded rows, in list order — what a bulk action runs on. */
|
|
@@ -36,5 +46,5 @@ export interface RowSelection<TItem, TKey extends string | number> extends Entit
|
|
|
36
46
|
* `EntityListTable.selection`, "Select all loaded" in the header, count + bulk actions in `EntityListBulkBar`. Keys
|
|
37
47
|
* outside the loaded rows never count; a new `resetKey` starts empty (derived, no effect).
|
|
38
48
|
*/
|
|
39
|
-
export declare const useRowSelection: <TItem, TKey extends string | number>({ items, getKey, resetKey, disabled, rowLabel, }: UseRowSelectionOptions<TItem, TKey>) => RowSelection<TItem, TKey>;
|
|
49
|
+
export declare const useRowSelection: <TItem, TKey extends string | number>({ items, getKey, resetKey, disabled, rowLabel, isSelectable, }: UseRowSelectionOptions<TItem, TKey>) => RowSelection<TItem, TKey>;
|
|
40
50
|
//# sourceMappingURL=useRowSelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../src/logic/react/useRowSelection.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,MAAM,WAAW,mBAAmB,CAAC,KAAK;IACxC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IACzC,
|
|
1
|
+
{"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../src/logic/react/useRowSelection.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,MAAM,WAAW,mBAAmB,CAAC,KAAK;IACxC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IACzC,gGAAgG;IAChG,gBAAgB,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IAC3C;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC;IACnD,eAAe,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,oEAAoE;IACpE,cAAc,EAAE,OAAO,GAAG,eA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AAC,KAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAqFhE,CAAC"}
|
|
@@ -6,7 +6,7 @@ const EMPTY = new Set();
|
|
|
6
6
|
* `EntityListTable.selection`, "Select all loaded" in the header, count + bulk actions in `EntityListBulkBar`. Keys
|
|
7
7
|
* outside the loaded rows never count; a new `resetKey` starts empty (derived, no effect).
|
|
8
8
|
*/
|
|
9
|
-
export const useRowSelection = ({ items, getKey, resetKey = '', disabled, rowLabel, }) => {
|
|
9
|
+
export const useRowSelection = ({ items, getKey, resetKey = '', disabled, rowLabel, isSelectable, }) => {
|
|
10
10
|
const [state, setState] = useState({ resetKey, keys: EMPTY });
|
|
11
11
|
const keys = state.resetKey === resetKey ? state.keys : EMPTY;
|
|
12
12
|
const update = useCallback((change) => setState(previous => ({
|
|
@@ -17,16 +17,16 @@ export const useRowSelection = ({ items, getKey, resetKey = '', disabled, rowLab
|
|
|
17
17
|
const list = [];
|
|
18
18
|
for (const item of items) {
|
|
19
19
|
const key = getKey(item);
|
|
20
|
-
if (key !== null && key !== undefined && key !== '')
|
|
20
|
+
if (key !== null && key !== undefined && key !== '' && (isSelectable?.(item) ?? true))
|
|
21
21
|
list.push(key);
|
|
22
22
|
}
|
|
23
23
|
return list;
|
|
24
|
-
}, [items, getKey]);
|
|
24
|
+
}, [items, getKey, isSelectable]);
|
|
25
25
|
const selectedKeys = useMemo(() => loadedKeys.filter(key => keys.has(key)), [loadedKeys, keys]);
|
|
26
26
|
const selectedItems = useMemo(() => items.filter(item => {
|
|
27
27
|
const key = getKey(item);
|
|
28
|
-
return key !== null && key !== undefined && keys.has(key);
|
|
29
|
-
}), [items, getKey, keys]);
|
|
28
|
+
return key !== null && key !== undefined && keys.has(key) && (isSelectable?.(item) ?? true);
|
|
29
|
+
}), [items, getKey, keys, isSelectable]);
|
|
30
30
|
const setSelected = useCallback((key, selected) => update(previous => {
|
|
31
31
|
if (previous.has(key) === selected)
|
|
32
32
|
return previous;
|
|
@@ -50,15 +50,23 @@ export const useRowSelection = ({ items, getKey, resetKey = '', disabled, rowLab
|
|
|
50
50
|
clear,
|
|
51
51
|
isItemSelected: item => {
|
|
52
52
|
const key = getKey(item);
|
|
53
|
-
return key !== null && key !== undefined && keys.has(key);
|
|
53
|
+
return key !== null && key !== undefined && keys.has(key) && (isSelectable?.(item) ?? true);
|
|
54
54
|
},
|
|
55
55
|
isItemSelectable: item => {
|
|
56
56
|
const key = getKey(item);
|
|
57
|
-
return key !== null && key !== undefined && key !== '';
|
|
57
|
+
return key !== null && key !== undefined && key !== '' && (isSelectable?.(item) ?? true);
|
|
58
58
|
},
|
|
59
|
+
...(isSelectable
|
|
60
|
+
? {
|
|
61
|
+
isItemSelectionDisabled: (item) => {
|
|
62
|
+
const key = getKey(item);
|
|
63
|
+
return key !== null && key !== undefined && key !== '' && !isSelectable(item);
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: {}),
|
|
59
67
|
setItemSelected: (item, selected) => {
|
|
60
68
|
const key = getKey(item);
|
|
61
|
-
if (key !== null && key !== undefined && key !== '')
|
|
69
|
+
if (key !== null && key !== undefined && key !== '' && (isSelectable?.(item) ?? true))
|
|
62
70
|
setSelected(key, selected);
|
|
63
71
|
},
|
|
64
72
|
allLoadedState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowSelection.js","sourceRoot":"","sources":["../../../src/logic/react/useRowSelection.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useRowSelection.js","sourceRoot":"","sources":["../../../src/logic/react/useRowSelection.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAgDvD,MAAM,KAAK,GAAuB,IAAI,GAAG,EAAE,CAAC;AAE5C;;;;GAIG;AACH,M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EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAChF,CAAC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,eAAe,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;YAClC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;gBAAE,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACpH,CAAC;QACD,cAAc;QACd,oBAAoB;QACpB,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type WriteAccess } from '../pure/writeAccess.js';
|
|
3
|
+
/** The write access of the subtree (`WriteAccessProvider`); no provider = allowed. */
|
|
4
|
+
export declare const WriteAccessContext: import("react").Context<WriteAccess>;
|
|
5
|
+
export interface WriteAccessProviderProps {
|
|
6
|
+
/** `{ allowed, reason? }`; nested providers can only narrow (an outer `allowed: false` stays). */
|
|
7
|
+
value: WriteAccess;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets whether the controls below may write, as a presentation aid: `FormSubmitButton`, the actions of
|
|
12
|
+
* `EntityListBulkBar` and `AddEntityButton` as a button are disabled while it is `false` (a link never). The handlers
|
|
13
|
+
* keep their own guard and the server its check.
|
|
14
|
+
*/
|
|
15
|
+
export declare const WriteAccessProvider: ({ value, children }: WriteAccessProviderProps) => import("react").FunctionComponentElement<import("react").ProviderProps<WriteAccess>>;
|
|
16
|
+
/** The write access of the nearest `WriteAccessProvider` (`{ allowed: true }` without one). */
|
|
17
|
+
export declare const useWriteAccess: () => WriteAccess;
|
|
18
|
+
//# sourceMappingURL=writeAccess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeAccess.d.ts","sourceRoot":"","sources":["../../../src/logic/react/writeAccess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAE1F,OAAO,EAA2C,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEnG,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,sCAAmD,CAAC;AAEnF,MAAM,WAAW,wBAAwB;IACvC,kGAAkG;IAClG,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,qBAAqB,wBAAwB,yFAIhF,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,cAAc,QAAO,WAA6C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, createElement, useContext, useMemo } from 'react';
|
|
3
|
+
import { narrowWriteAccess, WRITE_ACCESS_ALLOWED } from "../pure/writeAccess.js";
|
|
4
|
+
/** The write access of the subtree (`WriteAccessProvider`); no provider = allowed. */
|
|
5
|
+
export const WriteAccessContext = createContext(WRITE_ACCESS_ALLOWED);
|
|
6
|
+
/**
|
|
7
|
+
* Sets whether the controls below may write, as a presentation aid: `FormSubmitButton`, the actions of
|
|
8
|
+
* `EntityListBulkBar` and `AddEntityButton` as a button are disabled while it is `false` (a link never). The handlers
|
|
9
|
+
* keep their own guard and the server its check.
|
|
10
|
+
*/
|
|
11
|
+
export const WriteAccessProvider = ({ value, children }) => {
|
|
12
|
+
const parent = useContext(WriteAccessContext);
|
|
13
|
+
const merged = useMemo(() => narrowWriteAccess(parent, value), [parent, value.allowed, value.reason]);
|
|
14
|
+
return createElement(WriteAccessContext.Provider, { value: merged }, children);
|
|
15
|
+
};
|
|
16
|
+
/** The write access of the nearest `WriteAccessProvider` (`{ allowed: true }` without one). */
|
|
17
|
+
export const useWriteAccess = () => useContext(WriteAccessContext);
|
|
18
|
+
//# sourceMappingURL=writeAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeAccess.js","sourceRoot":"","sources":["../../../src/logic/react/writeAccess.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,aAAa,EAAkB,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAoB,MAAM,wBAAwB,CAAC;AAEnG,sFAAsF;AACtF,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAc,oBAAoB,CAAC,CAAC;AAQnF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAA4B,EAAE,EAAE;IACnF,MAAM,MAAM,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACtG,OAAO,aAAa,CAAC,kBAAkB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF,+FAA+F;AAC/F,MAAM,CAAC,MAAM,cAAc,GAAG,GAAgB,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC"}
|
package/dist/next/storage.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* private mode, blocked site data, quota): a failed read is "nothing stored", a failed write is skipped — the URL and
|
|
4
|
-
* the component state still hold the value for this visit. Keys come from the provider's `storageKey`.
|
|
5
|
-
*/
|
|
6
|
-
/** `local`: survives the tab (views). `session`: this tab only, across reloads and navigation (list filters). */
|
|
7
|
-
export type StorageArea = 'local' | 'session';
|
|
8
|
-
export declare const readStored: (area: StorageArea, key: string) => string | null;
|
|
9
|
-
/** `null` or `''` removes the key. */
|
|
10
|
-
export declare const writeStored: (area: StorageArea, key: string, value: string | null) => void;
|
|
1
|
+
export { readStored, writeStored } from '../logic/browser/storage.js';
|
|
2
|
+
export type { StorageArea } from '../logic/browser/storage.js';
|
|
11
3
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/next/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/next/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/next/storage.js
CHANGED
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* private mode, blocked site data, quota): a failed read is "nothing stored", a failed write is skipped — the URL and
|
|
4
|
-
* the component state still hold the value for this visit. Keys come from the provider's `storageKey`.
|
|
5
|
-
*/
|
|
6
|
-
const storageOf = (area) => {
|
|
7
|
-
if (typeof window === 'undefined')
|
|
8
|
-
return null;
|
|
9
|
-
return area === 'local' ? window.localStorage : window.sessionStorage;
|
|
10
|
-
};
|
|
11
|
-
export const readStored = (area, key) => {
|
|
12
|
-
try {
|
|
13
|
-
return storageOf(area)?.getItem(key) ?? null;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/** `null` or `''` removes the key. */
|
|
20
|
-
export const writeStored = (area, key, value) => {
|
|
21
|
-
try {
|
|
22
|
-
const storage = storageOf(area);
|
|
23
|
-
if (!storage)
|
|
24
|
-
return;
|
|
25
|
-
if (value)
|
|
26
|
-
storage.setItem(key, value);
|
|
27
|
-
else
|
|
28
|
-
storage.removeItem(key);
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
// storage unavailable or full: the value stays in the URL / component state for this visit
|
|
32
|
-
}
|
|
33
|
-
};
|
|
1
|
+
// The guarded storage helpers live in ./logic (peer-free); the Next adapters use them from there.
|
|
2
|
+
export { readStored, writeStored } from "../logic/browser/storage.js";
|
|
34
3
|
//# sourceMappingURL=storage.js.map
|
package/dist/next/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/next/storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/next/storage.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -12,13 +12,18 @@ export interface DefinitionItem {
|
|
|
12
12
|
}
|
|
13
13
|
export interface DefinitionListProps {
|
|
14
14
|
items: readonly DefinitionItem[];
|
|
15
|
-
/** Columns from `sm` (1 on a phone). */
|
|
15
|
+
/** Columns from `sm` (1 on a phone); the `grid` layout only. */
|
|
16
16
|
columns?: 1 | 2 | 3 | 4;
|
|
17
|
+
/**
|
|
18
|
+
* `grid` (default): label above value, in columns. `rows`: one divided row per item, label left, value right (a
|
|
19
|
+
* summary card, a side panel).
|
|
20
|
+
*/
|
|
21
|
+
layout?: 'grid' | 'rows';
|
|
17
22
|
className?: string;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Read-only facts of an entity (replaces the local `Row` / `InfoRow` / `Detail` helpers): small uppercase label, value
|
|
21
26
|
* below, `—` when empty, in a responsive grid. Put it inside a `Card`.
|
|
22
27
|
*/
|
|
23
|
-
export declare const DefinitionList: ({ items, columns, className }: DefinitionListProps) => import("react").JSX.Element;
|
|
28
|
+
export declare const DefinitionList: ({ items, columns, layout, className }: DefinitionListProps) => import("react").JSX.Element;
|
|
24
29
|
//# sourceMappingURL=DefinitionList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefinitionList.d.ts","sourceRoot":"","sources":["../../src/page/DefinitionList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,yHAAyH;IACzH,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,
|
|
1
|
+
{"version":3,"file":"DefinitionList.d.ts","sourceRoot":"","sources":["../../src/page/DefinitionList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,yHAAyH;IACzH,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,gEAAgE;IAChE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,uCAAoD,mBAAmB,gCAgCrG,CAAC"}
|
|
@@ -13,8 +13,11 @@ const COLUMNS_CLASS = {
|
|
|
13
13
|
* Read-only facts of an entity (replaces the local `Row` / `InfoRow` / `Detail` helpers): small uppercase label, value
|
|
14
14
|
* below, `—` when empty, in a responsive grid. Put it inside a `Card`.
|
|
15
15
|
*/
|
|
16
|
-
export const DefinitionList = ({ items, columns = 2, className }) => {
|
|
16
|
+
export const DefinitionList = ({ items, columns = 2, layout = 'grid', className }) => {
|
|
17
17
|
const { t } = useTranslate();
|
|
18
|
+
if (layout === 'rows') {
|
|
19
|
+
return (_jsx("dl", { className: cn('divide-y', className), children: items.map(item => (_jsxs("div", { className: "flex min-w-0 items-baseline justify-between gap-4 py-2.5 first:pt-0 last:pb-0", children: [_jsx("dt", { className: "shrink-0 text-sm text-muted-foreground", children: t(item.label) }), _jsxs("dd", { className: "min-w-0 text-right text-sm break-words", children: [orEmpty(item.value), item.hint && (_jsx("span", { className: "block text-xs text-muted-foreground", children: typeof item.hint === 'string' ? t(item.hint) : item.hint }))] })] }, item.id ?? item.label))) }));
|
|
20
|
+
}
|
|
18
21
|
return (_jsx("dl", { className: cn('grid grid-cols-1 gap-x-6 gap-y-4', COLUMNS_CLASS[columns], className), children: items.map(item => (_jsxs("div", { className: cn('min-w-0', item.wide && 'col-span-full'), children: [_jsx("dt", { className: "text-xs font-medium tracking-wide text-muted-foreground uppercase", children: t(item.label) }), _jsx("dd", { className: "mt-1 text-sm break-words", children: orEmpty(item.value) }), item.hint && (_jsx("dd", { className: "mt-0.5 text-xs text-muted-foreground", children: typeof item.hint === 'string' ? t(item.hint) : item.hint }))] }, item.id ?? item.label))) }));
|
|
19
22
|
};
|
|
20
23
|
//# sourceMappingURL=DefinitionList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefinitionList.js","sourceRoot":"","sources":["../../src/page/DefinitionList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DefinitionList.js","sourceRoot":"","sources":["../../src/page/DefinitionList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAwB,CAAC;AA0BjD,MAAM,aAAa,GAAG;IACpB,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,+BAA+B;IAClC,CAAC,EAAE,+BAA+B;CAC1B,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAuB,EAAE,EAAE;IACxG,MAAM,EAAE,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC;IAC7B,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,CACL,aAAI,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,YACrC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,eAAiC,SAAS,EAAC,+EAA+E,aACxH,aAAI,SAAS,EAAC,wCAAwC,YAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAM,EAC3E,cAAI,SAAS,EAAC,wCAAwC,aACnD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EACnB,IAAI,CAAC,IAAI,IAAI,CACZ,eAAM,SAAS,EAAC,qCAAqC,YAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAQ,CACxH,IACE,KAPG,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAQzB,CACP,CAAC,GACC,CACN,CAAC;IACJ,CAAC;IACD,OAAO,CACP,aAAI,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,YACrF,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,eAAiC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,IAAI,eAAe,CAAC,aACrF,aAAI,SAAS,EAAC,mEAAmE,YAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAM,EACtG,aAAI,SAAS,EAAC,0BAA0B,YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAM,EAClE,IAAI,CAAC,IAAI,IAAI,CACZ,aAAI,SAAS,EAAC,sCAAsC,YAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAM,CACrH,KALO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAMzB,CACP,CAAC,GACC,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -14,6 +14,11 @@ export interface DetailHeaderProps {
|
|
|
14
14
|
* title is an `h2` in the section size — the page keeps one `h1` and the outer header stays the dominant one.
|
|
15
15
|
*/
|
|
16
16
|
nested?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A `FormActionsSlot` at the end of the right column: the actions of the form below move up into the header (needs
|
|
19
|
+
* a `FormActionsSlotProvider` around header and form; `EntityDetailShell formActionsSlot` brings one).
|
|
20
|
+
*/
|
|
21
|
+
formActionsSlot?: boolean;
|
|
17
22
|
className?: string;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
@@ -22,5 +27,5 @@ export interface DetailHeaderProps {
|
|
|
22
27
|
* stacked (back, title, aside) below `md`. `EntityDetailShell` and `FormHeader` both draw it, so a create page and the
|
|
23
28
|
* entity's detail page have the same header.
|
|
24
29
|
*/
|
|
25
|
-
export declare const DetailHeader: ({ back, title, description, aside, isLoading, nested, className, }: DetailHeaderProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const DetailHeader: ({ back, title, description, aside, isLoading, nested, formActionsSlot, className, }: DetailHeaderProps) => import("react").JSX.Element;
|
|
26
31
|
//# sourceMappingURL=DetailHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailHeader.d.ts","sourceRoot":"","sources":["../../src/page/DetailHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,sCAAsC;IACtC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,
|
|
1
|
+
{"version":3,"file":"DetailHeader.d.ts","sourceRoot":"","sources":["../../src/page/DetailHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,sCAAsC;IACtC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,qFAS1B,iBAAiB,gCA2BnB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Skeleton } from "../primitives/index.js";
|
|
2
|
+
import { FormActionsSlot, Skeleton } from "../primitives/index.js";
|
|
3
3
|
import { cn } from "../primitives/cn.js";
|
|
4
4
|
/**
|
|
5
5
|
* The header of every entity detail and form page: back left, the title centred, metadata
|
|
@@ -7,8 +7,8 @@ import { cn } from "../primitives/cn.js";
|
|
|
7
7
|
* stacked (back, title, aside) below `md`. `EntityDetailShell` and `FormHeader` both draw it, so a create page and the
|
|
8
8
|
* entity's detail page have the same header.
|
|
9
9
|
*/
|
|
10
|
-
export const DetailHeader = ({ back, title, description, aside, isLoading = false, nested = false, className, }) => {
|
|
10
|
+
export const DetailHeader = ({ back, title, description, aside, isLoading = false, nested = false, formActionsSlot = false, className, }) => {
|
|
11
11
|
const Heading = nested ? 'h2' : 'h1';
|
|
12
|
-
return (_jsxs("header", { className: cn('mb-6 flex flex-col gap-3 md:flex-row md:items-center md:gap-4', className), children: [_jsx("div", { className: "flex items-center md:flex-1 md:basis-0", children: back }), isLoading ? (_jsxs("div", { className: "flex min-w-0 flex-col items-center gap-2 md:max-w-[60%]", "aria-busy": true, children: [_jsx(Skeleton, { className: cn('w-64 max-w-full', nested ? 'h-7' : 'h-9') }), _jsx(Skeleton, { className: "h-4 w-40 max-w-full" }), _jsx("span", { className: "sr-only", children: "Loading\u2026" })] })) : (_jsxs("div", { className: "min-w-0 text-center md:max-w-[60%]", children: [_jsx(Heading, { className: cn('truncate font-semibold tracking-tight', nested ? 'text-title-section' : 'text-title-page'), children: title }), description && _jsx("p", { className: "mt-1.5 truncate text-sm text-muted-foreground", children: description })] })),
|
|
12
|
+
return (_jsxs("header", { className: cn('mb-6 flex flex-col gap-3 md:flex-row md:items-center md:gap-4', className), children: [_jsx("div", { className: "flex items-center md:flex-1 md:basis-0", children: back }), isLoading ? (_jsxs("div", { className: "flex min-w-0 flex-col items-center gap-2 md:max-w-[60%]", "aria-busy": true, children: [_jsx(Skeleton, { className: cn('w-64 max-w-full', nested ? 'h-7' : 'h-9') }), _jsx(Skeleton, { className: "h-4 w-40 max-w-full" }), _jsx("span", { className: "sr-only", children: "Loading\u2026" })] })) : (_jsxs("div", { className: "min-w-0 text-center md:max-w-[60%]", children: [_jsx(Heading, { className: cn('truncate font-semibold tracking-tight', nested ? 'text-title-section' : 'text-title-page'), children: title }), description && _jsx("p", { className: "mt-1.5 truncate text-sm text-muted-foreground", children: description })] })), _jsxs("div", { className: "flex flex-wrap items-center justify-center gap-3 md:flex-1 md:basis-0 md:justify-end", children: [!isLoading && aside, formActionsSlot && _jsx(FormActionsSlot, {})] })] }));
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=DetailHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailHeader.js","sourceRoot":"","sources":["../../src/page/DetailHeader.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DetailHeader.js","sourceRoot":"","sources":["../../src/page/DetailHeader.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE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|
1
1
|
import type { ChangeHistory } from '@mgamadeus/ddd-web/contract';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { type EntityTab } from './EntityTabs.js';
|
|
4
|
-
import { type PageLinkComponent } from '
|
|
4
|
+
import { type PageLinkComponent } from '../primitives/link.js';
|
|
5
5
|
export interface EntityDetailBack {
|
|
6
6
|
/** The list route (`/worlds`). */
|
|
7
7
|
href: string;
|
|
@@ -36,6 +36,12 @@ export interface EntityDetailShellProps {
|
|
|
36
36
|
nested?: boolean;
|
|
37
37
|
/** Load failed or the entity does not exist: one error block with the back button instead of the page. */
|
|
38
38
|
error?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* The actions of a form in the page (`FormActions`) sit in the header, after `actions`, as a pill that floats under
|
|
41
|
+
* the top bar once the header scrolls away. The shell brings the `FormActionsSlotProvider`; a nested shell with its
|
|
42
|
+
* own slot takes the actions of its forms.
|
|
43
|
+
*/
|
|
44
|
+
formActionsSlot?: boolean;
|
|
39
45
|
children: ReactNode;
|
|
40
46
|
className?: string;
|
|
41
47
|
}
|
|
@@ -44,5 +50,5 @@ export interface EntityDetailShellProps {
|
|
|
44
50
|
* tabs, then the active tab. Clouds layout: title centred above the centred segmented tabs, fluid page-title size; full
|
|
45
51
|
* content width on every tab (host CSS `[data-page-shell]`). The breadcrumb trail lives in the top bar, not here.
|
|
46
52
|
*/
|
|
47
|
-
export declare const EntityDetailShell: ({ title, fallbackTitle, description, back, linkComponent
|
|
53
|
+
export declare const EntityDetailShell: ({ title, fallbackTitle, description, back, linkComponent, actions, metadata, tabs, currentPath, tabsLabel, isLoading, nested, error, formActionsSlot, children, className, }: EntityDetailShellProps) => import("react").JSX.Element;
|
|
48
54
|
//# sourceMappingURL=EntityDetailShell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDetailShell.d.ts","sourceRoot":"","sources":["../../src/page/EntityDetailShell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,E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AAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gHAAgH;IAChH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,8KAiB/B,sBAAsB,gCA6DxB,CAAC"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ArrowLeft } from 'lucide-react';
|
|
4
|
-
import { Button } from "../primitives/index.js";
|
|
4
|
+
import { Button, FormActionsSlotProvider } from "../primitives/index.js";
|
|
5
5
|
import { useTranslate } from "../i18n/index.js";
|
|
6
6
|
import { cn } from "../primitives/cn.js";
|
|
7
7
|
import { EntityListEmpty } from "../list/EntityListEmpty.js";
|
|
8
8
|
import { DetailHeader } from "./DetailHeader.js";
|
|
9
9
|
import { EntityMetadata } from "./EntityMetadata.js";
|
|
10
10
|
import { EntityTabs } from "./EntityTabs.js";
|
|
11
|
-
import {
|
|
11
|
+
import { useLinkComponent } from "../primitives/link.js";
|
|
12
12
|
/**
|
|
13
13
|
* The frame of every entity detail screen: back button + title + description + actions, the `EntityMetadata` strip (ID, Created, Updated), the route
|
|
14
14
|
* tabs, then the active tab. Clouds layout: title centred above the centred segmented tabs, fluid page-title size; full
|
|
15
15
|
* content width on every tab (host CSS `[data-page-shell]`). The breadcrumb trail lives in the top bar, not here.
|
|
16
16
|
*/
|
|
17
|
-
export const EntityDetailShell = ({ title, fallbackTitle, description, back, linkComponent
|
|
17
|
+
export const EntityDetailShell = ({ title, fallbackTitle, description, back, linkComponent, actions, metadata, tabs, currentPath, tabsLabel, isLoading = false, nested = false, error, formActionsSlot = false, children, className, }) => {
|
|
18
18
|
const { t } = useTranslate();
|
|
19
|
+
const Link = useLinkComponent(linkComponent);
|
|
19
20
|
if (error) {
|
|
20
21
|
return (_jsx("div", { className: cn('w-full', className), children: _jsx(EntityListEmpty, { tone: "error", message: error, action: back && (_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: back.href, children: back.label }) })) }) }));
|
|
21
22
|
}
|
|
22
23
|
const backButton = back && (_jsx(Button, { asChild: true, variant: "ghost", size: "icon-sm", className: "shrink-0", children: _jsx(Link, { href: back.href, "aria-label": back.label, children: _jsx(ArrowLeft, {}) }) }));
|
|
23
|
-
|
|
24
|
+
const page = (_jsxs("div", { className: cn('w-full', className), children: [_jsx(DetailHeader, { back: backButton, title: title || fallbackTitle, description: description, isLoading: isLoading, nested: nested, formActionsSlot: formActionsSlot, className: tabs && tabs.length > 0 ? 'mb-5' : undefined, aside: _jsxs(_Fragment, { children: [metadata && _jsx(EntityMetadata, { id: metadata.id, changeHistory: metadata.changeHistory, variant: "stacked" }), actions] }) }), tabs && tabs.length > 0 && (_jsx(EntityTabs, { tabs: tabs, currentPath: currentPath, linkComponent: Link, "aria-label": tabsLabel ?? t('Sections', { context: 'tab-navigation' }), align: "center", className: "mb-6" })), children] }));
|
|
25
|
+
return formActionsSlot ? _jsx(FormActionsSlotProvider, { children: page }) : page;
|
|
24
26
|
};
|
|
25
27
|
//# sourceMappingURL=EntityDetailShell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDetailShell.js","sourceRoot":"","sources":["../../src/page/EntityDetailShell.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"EntityDetailShell.js","sourceRoot":"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