@antelopejs/interface-dms 0.4.0 → 0.4.2
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/CHANGELOG.md +33 -0
- package/dist/base/banner.d.ts +15 -9
- package/dist/base/banner.js +8 -3
- package/dist/base/banner.js.map +1 -1
- package/dist/base/card.d.ts +2 -2
- package/dist/base/chart-card.d.ts +6 -2
- package/dist/base/chart-card.js.map +1 -1
- package/dist/base/chart.d.ts +4 -0
- package/dist/base/chart.js.map +1 -1
- package/dist/base/display.d.ts +30 -0
- package/dist/base/display.js +16 -1
- package/dist/base/display.js.map +1 -1
- package/dist/base/internal/composed-text.d.ts +14 -0
- package/dist/base/internal/composed-text.js +51 -0
- package/dist/base/internal/composed-text.js.map +1 -0
- package/dist/base/key-value-list.d.ts +31 -25
- package/dist/base/key-value-list.js +5 -3
- package/dist/base/key-value-list.js.map +1 -1
- package/dist/base/kpi-card.d.ts +6 -2
- package/dist/base/kpi-card.js.map +1 -1
- package/dist/base/meter.d.ts +2 -1
- package/dist/base/meter.js.map +1 -1
- package/dist/base/stat-group.d.ts +30 -21
- package/dist/base/stat-group.js +7 -3
- package/dist/base/stat-group.js.map +1 -1
- package/dist/base/tab.d.ts +7 -1
- package/dist/base/tab.js.map +1 -1
- package/dist/base/table-view/column-display.d.ts +80 -3
- package/dist/base/table-view/column-display.js +12 -1
- package/dist/base/table-view/column-display.js.map +1 -1
- package/dist/base/table-view/schema.d.ts +2 -2
- package/dist/base/top-list-card.d.ts +6 -2
- package/dist/base/top-list-card.js.map +1 -1
- package/dist/base/types/composed-text.d.ts +120 -0
- package/dist/base/types/composed-text.js +17 -0
- package/dist/base/types/composed-text.js.map +1 -0
- package/dist/base/types/index.d.ts +1 -0
- package/dist/base/types/index.js +1 -0
- package/dist/base/types/index.js.map +1 -1
- package/dist/layout-banners.d.ts +74 -11
- package/dist/layout-banners.js +3 -3
- package/dist/layout-banners.js.map +1 -1
- package/package.json +1 -1
package/dist/layout-banners.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RegisteringProxy } from "@antelopejs/interface-core";
|
|
2
2
|
import type { User } from "./auth/db";
|
|
3
|
+
import type { BlockLinkAction } from "./base/display";
|
|
4
|
+
import type { BlockText } from "./base/types/composed-text";
|
|
3
5
|
import type { MaybePromise } from "./types";
|
|
4
6
|
/**
|
|
5
7
|
* Semantic look of a layout banner. It also picks the banner's ARIA role:
|
|
@@ -13,8 +15,8 @@ export declare const LayoutBannerVariant: {
|
|
|
13
15
|
};
|
|
14
16
|
export type LayoutBannerVariant = (typeof LayoutBannerVariant)[keyof typeof LayoutBannerVariant];
|
|
15
17
|
/**
|
|
16
|
-
* What a banner's `visible` resolver decides on: the request the
|
|
17
|
-
* is being built for.
|
|
18
|
+
* What a banner's `visible` or `resolve` resolver decides on: the request the
|
|
19
|
+
* site layout is being built for.
|
|
18
20
|
*/
|
|
19
21
|
export interface LayoutBannerContext {
|
|
20
22
|
/** Undefined for an unauthenticated request. */
|
|
@@ -41,6 +43,31 @@ export interface LayoutBannerContext {
|
|
|
41
43
|
* does not answer within two seconds, hides its banner for that request.
|
|
42
44
|
*/
|
|
43
45
|
export type LayoutBannerVisibility = (context: LayoutBannerContext) => MaybePromise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* What a text banner shows: its message and, after it, link buttons.
|
|
48
|
+
*/
|
|
49
|
+
export interface LayoutBannerContent {
|
|
50
|
+
/**
|
|
51
|
+
* The message: a `$`-prefixed value resolves as an i18n key, and a
|
|
52
|
+
* `ComposedText` is composed in the reader's language from the raw values
|
|
53
|
+
* it carries — an amount, a date, a count.
|
|
54
|
+
*/
|
|
55
|
+
text: BlockText;
|
|
56
|
+
/**
|
|
57
|
+
* Link buttons after the message; the last one is the main action. Their
|
|
58
|
+
* labels follow the `$` convention.
|
|
59
|
+
*/
|
|
60
|
+
actions?: BlockLinkAction[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Builds a banner's content per request, or answers `undefined` to hide it:
|
|
64
|
+
* the visibility and the message in one read, for a banner whose message
|
|
65
|
+
* names the state that makes it show (an invoice number, the amount due, the
|
|
66
|
+
* date the workspace is suspended). Runs where and when a
|
|
67
|
+
* {@link LayoutBannerVisibility} does, under the same two-second budget: a
|
|
68
|
+
* resolver that throws or does not answer hides its banner for that request.
|
|
69
|
+
*/
|
|
70
|
+
export type LayoutBannerResolver = (context: LayoutBannerContext) => MaybePromise<LayoutBannerContent | undefined>;
|
|
44
71
|
interface LayoutBannerBase {
|
|
45
72
|
/**
|
|
46
73
|
* Unique key of the banner across the deployment: re-registering a key
|
|
@@ -62,18 +89,19 @@ interface LayoutBannerBase {
|
|
|
62
89
|
* leaves the banner out. Defaults to `false`.
|
|
63
90
|
*/
|
|
64
91
|
dismissible?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface LayoutBannerStaticBase extends LayoutBannerBase {
|
|
65
94
|
/** Absent means the banner shows on every request. */
|
|
66
95
|
visible?: LayoutBannerVisibility;
|
|
96
|
+
resolve?: never;
|
|
67
97
|
}
|
|
68
|
-
/** A banner showing a
|
|
69
|
-
export interface LayoutBannerTextInfo extends
|
|
70
|
-
/** The message. A `$`-prefixed value resolves as an i18n key. */
|
|
71
|
-
text: string;
|
|
98
|
+
/** A banner showing a fixed message, and optionally link buttons. */
|
|
99
|
+
export interface LayoutBannerTextInfo extends LayoutBannerStaticBase, LayoutBannerContent {
|
|
72
100
|
component?: never;
|
|
73
101
|
props?: never;
|
|
74
102
|
}
|
|
75
103
|
/** A banner mounting a component of a frontend layer as its content. */
|
|
76
|
-
export interface LayoutBannerComponentInfo extends
|
|
104
|
+
export interface LayoutBannerComponentInfo extends LayoutBannerStaticBase {
|
|
77
105
|
/**
|
|
78
106
|
* Name of a global component, provided by a frontend layer, rendered as the
|
|
79
107
|
* banner's content. The DMS still draws the chrome: color, icon, dismiss
|
|
@@ -83,21 +111,56 @@ export interface LayoutBannerComponentInfo extends LayoutBannerBase {
|
|
|
83
111
|
/** Props passed to the component. Must be serializable. */
|
|
84
112
|
props?: Record<string, unknown>;
|
|
85
113
|
text?: never;
|
|
114
|
+
actions?: never;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A banner whose message and buttons are built per request by `resolve`,
|
|
118
|
+
* which also decides whether it shows.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* RegisterLayoutBanner({
|
|
123
|
+
* key: "saas:past-due",
|
|
124
|
+
* variant: LayoutBannerVariant.ERROR,
|
|
125
|
+
* resolve: async ({ tenantId }) => {
|
|
126
|
+
* const invoice = await openInvoice(tenantId);
|
|
127
|
+
* if (!invoice) return undefined;
|
|
128
|
+
* return {
|
|
129
|
+
* text: {
|
|
130
|
+
* key: "saas.banner.past_due",
|
|
131
|
+
* params: {
|
|
132
|
+
* amount: { type: "money", value: invoice.due, currency: invoice.currency },
|
|
133
|
+
* date: { type: "date", value: invoice.retryAt, format: "day" },
|
|
134
|
+
* },
|
|
135
|
+
* },
|
|
136
|
+
* actions: [{ label: "$saas.banner.pay", to: "/settings/workspace/billing" }],
|
|
137
|
+
* };
|
|
138
|
+
* },
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export interface LayoutBannerResolvedInfo extends LayoutBannerBase {
|
|
143
|
+
resolve: LayoutBannerResolver;
|
|
144
|
+
visible?: never;
|
|
145
|
+
text?: never;
|
|
146
|
+
actions?: never;
|
|
147
|
+
component?: never;
|
|
148
|
+
props?: never;
|
|
86
149
|
}
|
|
87
150
|
/**
|
|
88
151
|
* A global banner rendered under the header of the dashboard layout, on every
|
|
89
152
|
* page — tenant pages and module back-office pages alike.
|
|
90
153
|
*/
|
|
91
|
-
export type LayoutBannerInfo = LayoutBannerTextInfo | LayoutBannerComponentInfo;
|
|
154
|
+
export type LayoutBannerInfo = LayoutBannerTextInfo | LayoutBannerComponentInfo | LayoutBannerResolvedInfo;
|
|
92
155
|
/** @internal */
|
|
93
156
|
export declare namespace internal {
|
|
94
157
|
const RegisterLayoutBanner: RegisteringProxy<(info: LayoutBannerInfo) => void>;
|
|
95
158
|
}
|
|
96
159
|
/**
|
|
97
160
|
* Register a global banner under the dashboard header. Banners stack by
|
|
98
|
-
* `order`, and each one's `visible` resolver is evaluated
|
|
99
|
-
* site layout request, so the banner is in the
|
|
100
|
-
* state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
161
|
+
* `order`, and each one's `visible` or `resolve` resolver is evaluated
|
|
162
|
+
* server-side for every site layout request, so the banner is in the
|
|
163
|
+
* server-rendered page. When the state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
101
164
|
* connected clients re-fetch their site layout.
|
|
102
165
|
*
|
|
103
166
|
* The registration is dropped automatically when the registering module stops.
|
package/dist/layout-banners.js
CHANGED
|
@@ -20,9 +20,9 @@ var internal;
|
|
|
20
20
|
})(internal || (exports.internal = internal = {}));
|
|
21
21
|
/**
|
|
22
22
|
* Register a global banner under the dashboard header. Banners stack by
|
|
23
|
-
* `order`, and each one's `visible` resolver is evaluated
|
|
24
|
-
* site layout request, so the banner is in the
|
|
25
|
-
* state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
23
|
+
* `order`, and each one's `visible` or `resolve` resolver is evaluated
|
|
24
|
+
* server-side for every site layout request, so the banner is in the
|
|
25
|
+
* server-rendered page. When the state a resolver reads changes, call `NotifyMenuChanged(tenantId)` so the
|
|
26
26
|
* connected clients re-fetch their site layout.
|
|
27
27
|
*
|
|
28
28
|
* The registration is dropped automatically when the registering module stops.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-banners.js","sourceRoot":"","sources":["../src/layout-banners.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"layout-banners.js","sourceRoot":"","sources":["../src/layout-banners.ts"],"names":[],"mappings":";;;AAmMA,oDAGC;AAtMD,+DAA8D;AAM9D;;;;GAIG;AACU,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AAiKX,gBAAgB;AAChB,IAAiB,QAAQ,CAIxB;AAJD,WAAiB,QAAQ;IACV,6BAAoB,GAAG,IAAI,iCAAgB,EAErD,CAAC;AACN,CAAC,EAJgB,QAAQ,wBAAR,QAAQ,QAIxB;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,IAAsB;IACzD,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED