@antelopejs/interface-dms 0.4.1 → 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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.4.2
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/interface-v0.4.1...v0.4.2)
6
+
7
+ ### 🚀 Enhancements
8
+
9
+ - **dms:** Compose block texts client-side with typed params and resolve layout banners per request ([#173](https://github.com/AntelopeJS/dms/pull/173))
10
+ - **dms:** Compose table cell sub-lines and add the two_line display and empty identities ([#175](https://github.com/AntelopeJS/dms/pull/175))
11
+
12
+ ### 🏡 Chore
13
+
14
+ - **release:** @antelopejs/dms v0.6.1 ([3c2fb0a](https://github.com/AntelopeJS/dms/commit/3c2fb0a))
15
+
16
+ ### ❤️ Contributors
17
+
18
+ - Antony Rizzitelli <rizzitelli.antony@pm.me>
19
+
3
20
  ## v0.4.1
4
21
 
5
22
  [compare changes](https://github.com/AntelopeJS/dms/compare/interface-v0.4.0...v0.4.1)
@@ -2,6 +2,7 @@ import { ComponentBuilder } from "../component";
2
2
  import { z } from "zod";
3
3
  import { type BlockLinkAction } from "./display";
4
4
  import type { BaseComponentProps } from "./types";
5
+ import type { BlockText } from "./types/composed-text";
5
6
  import type { Tone } from "./types/tone";
6
7
  /** The tones a banner washes with. */
7
8
  export declare const BANNER_TONES: readonly ["info", "success", "warning", "error", "primary"];
@@ -12,9 +13,14 @@ export declare const BANNER_SIZES: readonly ["md", "sm"];
12
13
  export type BannerSize = (typeof BANNER_SIZES)[number];
13
14
  /** The options `Banner` takes. */
14
15
  export interface BannerProps extends BaseComponentProps {
15
- /** `$`-prefixed for an i18n key, like every text of the block. */
16
- title?: string;
17
- description?: string;
16
+ /**
17
+ * `$`-prefixed for an i18n key, like every text of the block, or a
18
+ * `ComposedText` composed in the reader's language ("Payment failed, retry
19
+ * {date}").
20
+ */
21
+ title?: BlockText;
22
+ /** A string or a `ComposedText`, like `title`. */
23
+ description?: BlockText;
18
24
  tone?: BannerTone;
19
25
  /** Overrides the tone's icon. */
20
26
  icon?: string;
@@ -52,8 +58,8 @@ export interface BannerProps extends BaseComponentProps {
52
58
  export declare function Banner(options?: BannerProps): ComponentBuilder<BannerProps>;
53
59
  /** The options `Banner` accepts. */
54
60
  export declare const BannerSchema: z.ZodObject<{
55
- title: z.ZodOptional<z.ZodString>;
56
- description: z.ZodOptional<z.ZodString>;
61
+ title: z.ZodOptional<z.ZodType<BlockText, z.ZodTypeDef, BlockText>>;
62
+ description: z.ZodOptional<z.ZodType<BlockText, z.ZodTypeDef, BlockText>>;
57
63
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
64
  label: z.ZodString;
59
65
  to: z.ZodString;
@@ -81,8 +87,8 @@ export declare const BannerSchema: z.ZodObject<{
81
87
  }, "strip", z.ZodTypeAny, {
82
88
  size: "sm" | "md";
83
89
  tone: "primary" | "success" | "info" | "warning" | "error";
84
- description?: string | undefined;
85
- title?: string | undefined;
90
+ description?: BlockText | undefined;
91
+ title?: BlockText | undefined;
86
92
  icon?: string | undefined;
87
93
  actions?: {
88
94
  label: string;
@@ -94,9 +100,9 @@ export declare const BannerSchema: z.ZodObject<{
94
100
  dismissible?: boolean | undefined;
95
101
  dismissKey?: string | undefined;
96
102
  }, {
97
- description?: string | undefined;
103
+ description?: BlockText | undefined;
98
104
  size?: "sm" | "md" | undefined;
99
- title?: string | undefined;
105
+ title?: BlockText | undefined;
100
106
  icon?: string | undefined;
101
107
  actions?: {
102
108
  label: string;
@@ -7,6 +7,7 @@ const zod_1 = require("zod");
7
7
  const block_registry_1 = require("./block-registry");
8
8
  const display_1 = require("./display");
9
9
  const display_2 = require("./internal/display");
10
+ const composed_text_1 = require("./internal/composed-text");
10
11
  /** The tones a banner washes with. */
11
12
  exports.BANNER_TONES = [
12
13
  "info",
@@ -43,14 +44,18 @@ function Banner(options) {
43
44
  return new component_1.ComponentBuilder(BANNER_COMPONENT_NAME)
44
45
  .options({ ...BANNER_DEFAULTS, ...options })
45
46
  .meta({
46
- name: options?.title || "Banner",
47
+ name: (typeof options?.title === "string" && options.title) || "Banner",
47
48
  icon: options?.icon || BANNER_ICON,
48
49
  });
49
50
  }
50
51
  /** The options `Banner` accepts. */
51
52
  exports.BannerSchema = zod_1.z.object({
52
- title: (0, block_registry_1.ui)(zod_1.z.string().optional(), { label: "Title", group: "content" }),
53
- description: (0, block_registry_1.ui)(zod_1.z.string().optional(), {
53
+ title: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)().optional(), {
54
+ label: "Title",
55
+ group: "content",
56
+ widget: "text",
57
+ }),
58
+ description: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)().optional(), {
54
59
  label: "Description",
55
60
  group: "content",
56
61
  widget: "textarea",
@@ -1 +1 @@
1
- {"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/base/banner.ts"],"names":[],"mappings":";;;AAqEA,wBAOC;AA5ED,4CAAgD;AAChD,6BAAwB;AACxB,qDAA+E;AAC/E,uCAAqE;AACrE,gDAA8C;AAI9C,sCAAsC;AACzB,QAAA,YAAY,GAAG;IAC1B,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,SAAS;CACyB,CAAC;AAIrC,6BAA6B;AAChB,QAAA,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AA0BlD,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AACjD,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAW,CAAC;AAE9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,OAAqB;IAC1C,OAAO,IAAI,4BAAgB,CAAc,qBAAqB,CAAC;SAC5D,OAAO,CAAC,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC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EAAE;QACrE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,MAAM;KACf,CAAC;IACF,IAAI,EAAE,IAAA,mBAAE,EACN,OAAC;SACE,IAAI,CAAC,oBAAY,CAAC;SAClB,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC;SAC7B,QAAQ,CAAC,sCAAsC,CAAC,EACnD;QACE,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE;KAC9C,CACF;IACD,WAAW,EAAE,IAAA,mBAAE,EACb,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EACnE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,CAC9D;IACD,UAAU,EAAE,IAAA,mBAAE,EACZ,OAAC;SACE,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,4DAA4D,CAAC,EACzE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAC5D;CACF,CAAwC,CAAC;AAE1C,IAAA,kCAAiB,EAAC;IAChB,IAAI,EAAE,QAAQ;IACd,aAAa,EAAE,qBAAqB;IACpC,MAAM,EAAE,oBAAY;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,4DAA4D;QACzE,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC"}
@@ -74,8 +74,8 @@ export declare const CardSchema: z.ZodObject<{
74
74
  padded: boolean;
75
75
  description?: string | undefined;
76
76
  title?: string | undefined;
77
- footer?: string | undefined;
78
77
  count?: string | number | undefined;
78
+ footer?: string | undefined;
79
79
  actions?: {
80
80
  label: string;
81
81
  to: string;
@@ -86,9 +86,9 @@ export declare const CardSchema: z.ZodObject<{
86
86
  }, {
87
87
  description?: string | undefined;
88
88
  title?: string | undefined;
89
+ count?: string | number | undefined;
89
90
  variant?: "default" | "elevated" | undefined;
90
91
  footer?: string | undefined;
91
- count?: string | number | undefined;
92
92
  actions?: {
93
93
  label: string;
94
94
  to: string;
@@ -57,7 +57,7 @@ export declare const ChartCardSchema: z.ZodObject<{
57
57
  fetchUrl?: string | undefined;
58
58
  fetchUrlMethod?: HttpMethod | undefined;
59
59
  periodScope?: string | undefined;
60
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
60
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
61
61
  currencyCode?: string | undefined;
62
62
  primaryLabel?: string | undefined;
63
63
  comparisonLabel?: string | undefined;
@@ -70,7 +70,7 @@ export declare const ChartCardSchema: z.ZodObject<{
70
70
  fetchUrlMethod?: HttpMethod | undefined;
71
71
  showLegend?: boolean | undefined;
72
72
  periodScope?: string | undefined;
73
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
73
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
74
74
  currencyCode?: string | undefined;
75
75
  showDelta?: boolean | undefined;
76
76
  primaryLabel?: string | undefined;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { type BlockText, type ComposedText } from "../types/composed-text";
3
+ /**
4
+ * The zod schema of a {@link ComposedText}.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare const ComposedTextSchema: z.ZodType<ComposedText>;
9
+ /**
10
+ * The schema of a block text option: a plain string or a composed text.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare const blockTextSchema: () => z.ZodType<BlockText>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blockTextSchema = exports.ComposedTextSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const composed_text_1 = require("../types/composed-text");
6
+ const DateValueSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number()]);
7
+ const TypedParamSchema = zod_1.z.discriminatedUnion("type", [
8
+ zod_1.z.object({
9
+ type: zod_1.z.literal("money"),
10
+ value: zod_1.z.number(),
11
+ currency: zod_1.z.string(),
12
+ }),
13
+ zod_1.z.object({
14
+ type: zod_1.z.literal("date"),
15
+ value: DateValueSchema,
16
+ format: zod_1.z.enum(composed_text_1.COMPOSED_TEXT_DATE_FORMATS).optional(),
17
+ }),
18
+ zod_1.z.object({
19
+ type: zod_1.z.literal("datetime"),
20
+ value: DateValueSchema,
21
+ format: zod_1.z.enum(composed_text_1.COMPOSED_TEXT_DATE_FORMATS).optional(),
22
+ }),
23
+ zod_1.z.object({ type: zod_1.z.literal("relative"), value: DateValueSchema }),
24
+ zod_1.z.object({
25
+ type: zod_1.z.literal("number"),
26
+ value: zod_1.z.number(),
27
+ format: zod_1.z.enum(composed_text_1.COMPOSED_TEXT_NUMBER_FORMATS).optional(),
28
+ }),
29
+ zod_1.z.object({ type: zod_1.z.literal("count"), value: zod_1.z.number() }),
30
+ ]);
31
+ // A parameter may itself be a composed text, so the two schemas name each
32
+ // other through `z.lazy`.
33
+ const ComposedTextParamSchema = zod_1.z.lazy(() => zod_1.z.union([zod_1.z.string(), zod_1.z.number(), TypedParamSchema, exports.ComposedTextSchema]));
34
+ /**
35
+ * The zod schema of a {@link ComposedText}.
36
+ *
37
+ * @internal
38
+ */
39
+ exports.ComposedTextSchema = zod_1.z.object({
40
+ key: zod_1.z.string().min(1),
41
+ params: zod_1.z.record(ComposedTextParamSchema).optional(),
42
+ plural: zod_1.z.string().optional(),
43
+ });
44
+ /**
45
+ * The schema of a block text option: a plain string or a composed text.
46
+ *
47
+ * @internal
48
+ */
49
+ const blockTextSchema = () => zod_1.z.union([zod_1.z.string(), exports.ComposedTextSchema]);
50
+ exports.blockTextSchema = blockTextSchema;
51
+ //# sourceMappingURL=composed-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,0EAA0E;AAC1E,0BAA0B;AAC1B,MAAM,uBAAuB,GAAiC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACxE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,0BAAkB,CAAC,CAAC,CACxE,CAAC;AAEF;;;;GAIG;AACU,QAAA,kBAAkB,GAA4B,OAAC,CAAC,MAAM,CAAC;IAClE,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH;;;;GAIG;AACI,MAAM,eAAe,GAAG,GAAyB,EAAE,CACxD,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,0BAAkB,CAAC,CAAC,CAAC;AAD/B,QAAA,eAAe,mBACgB"}
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  import { type BlockItemsSource } from "./display";
4
4
  import { type Tone } from "./types/tone";
5
5
  import type { BaseComponentProps } from "./types";
6
+ import type { BlockText } from "./types/composed-text";
6
7
  /**
7
8
  * How a value is drawn: `text` plain, `status` a tinted pill, `money` a
8
9
  * currency amount, `date` a localized date, `link` an accent link, `mono` an
@@ -14,17 +15,22 @@ export type KeyValueType = (typeof KEY_VALUE_TYPES)[number];
14
15
  export interface KeyValueListItem {
15
16
  /** Stable key; the position is used without one. */
16
17
  id?: string;
17
- /** `$`-prefixed for an i18n key. */
18
- label: string;
19
- /** Raw value: an ISO date for `date`, a number for `money`. */
20
- value?: string | number | null;
18
+ /** `$`-prefixed for an i18n key, or a `ComposedText`. */
19
+ label: BlockText;
20
+ /**
21
+ * Raw value: an ISO date for `date`, a number for `money`. A
22
+ * `ComposedText` is composed in the reader's language and drawn as text,
23
+ * whatever the `type` — its parameters already say how each value is
24
+ * written.
25
+ */
26
+ value?: BlockText | number | null;
21
27
  type?: KeyValueType;
22
28
  /** Route, `#anchor` or URL the value links to. */
23
29
  to?: string;
24
30
  /** Text colour, or the pill tone of a `status` value. */
25
31
  tone?: Tone;
26
- /** Dim note after the value. */
27
- detail?: string;
32
+ /** Dim note after the value: a string or a `ComposedText`. */
33
+ detail?: BlockText;
28
34
  /** ISO 4217 code of a `money` value; overrides the list's `currency`. */
29
35
  currency?: string;
30
36
  }
@@ -81,29 +87,29 @@ export declare const KeyValueListSchema: z.ZodObject<{
81
87
  title: z.ZodOptional<z.ZodString>;
82
88
  items: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
89
  id: z.ZodOptional<z.ZodString>;
84
- label: z.ZodString;
85
- value: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
90
+ label: z.ZodType<BlockText, z.ZodTypeDef, BlockText>;
91
+ value: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodType<BlockText, z.ZodTypeDef, BlockText>, z.ZodNumber]>>>;
86
92
  type: z.ZodOptional<z.ZodEnum<["text", "status", "money", "date", "link", "mono"]>>;
87
93
  to: z.ZodOptional<z.ZodString>;
88
94
  tone: z.ZodOptional<z.ZodEnum<["primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral", ...("primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral")[]]>>;
89
- detail: z.ZodOptional<z.ZodString>;
95
+ detail: z.ZodOptional<z.ZodType<BlockText, z.ZodTypeDef, BlockText>>;
90
96
  currency: z.ZodOptional<z.ZodString>;
91
97
  }, "strip", z.ZodTypeAny, {
92
- label: string;
93
- type?: "link" | "date" | "status" | "text" | "mono" | "money" | undefined;
94
- value?: string | number | null | undefined;
98
+ label: BlockText;
99
+ type?: "link" | "date" | "status" | "money" | "text" | "mono" | undefined;
100
+ value?: number | BlockText | null | undefined;
95
101
  id?: string | undefined;
96
102
  to?: string | undefined;
97
- detail?: string | undefined;
103
+ detail?: BlockText | undefined;
98
104
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
99
105
  currency?: string | undefined;
100
106
  }, {
101
- label: string;
102
- type?: "link" | "date" | "status" | "text" | "mono" | "money" | undefined;
103
- value?: string | number | null | undefined;
107
+ label: BlockText;
108
+ type?: "link" | "date" | "status" | "money" | "text" | "mono" | undefined;
109
+ value?: number | BlockText | null | undefined;
104
110
  id?: string | undefined;
105
111
  to?: string | undefined;
106
- detail?: string | undefined;
112
+ detail?: BlockText | undefined;
107
113
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
108
114
  currency?: string | undefined;
109
115
  }>, "many">>;
@@ -115,12 +121,12 @@ export declare const KeyValueListSchema: z.ZodObject<{
115
121
  card: boolean;
116
122
  columns: number;
117
123
  items?: {
118
- label: string;
119
- type?: "link" | "date" | "status" | "text" | "mono" | "money" | undefined;
120
- value?: string | number | null | undefined;
124
+ label: BlockText;
125
+ type?: "link" | "date" | "status" | "money" | "text" | "mono" | undefined;
126
+ value?: number | BlockText | null | undefined;
121
127
  id?: string | undefined;
122
128
  to?: string | undefined;
123
- detail?: string | undefined;
129
+ detail?: BlockText | undefined;
124
130
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
125
131
  currency?: string | undefined;
126
132
  }[] | undefined;
@@ -136,12 +142,12 @@ export declare const KeyValueListSchema: z.ZodObject<{
136
142
  dense?: boolean | undefined;
137
143
  }, {
138
144
  items?: {
139
- label: string;
140
- type?: "link" | "date" | "status" | "text" | "mono" | "money" | undefined;
141
- value?: string | number | null | undefined;
145
+ label: BlockText;
146
+ type?: "link" | "date" | "status" | "money" | "text" | "mono" | undefined;
147
+ value?: number | BlockText | null | undefined;
142
148
  id?: string | undefined;
143
149
  to?: string | undefined;
144
- detail?: string | undefined;
150
+ detail?: BlockText | undefined;
145
151
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
146
152
  currency?: string | undefined;
147
153
  }[] | undefined;
@@ -8,6 +8,7 @@ const block_registry_1 = require("./block-registry");
8
8
  const display_1 = require("./display");
9
9
  const display_2 = require("./internal/display");
10
10
  const tone_1 = require("./types/tone");
11
+ const composed_text_1 = require("./internal/composed-text");
11
12
  /**
12
13
  * How a value is drawn: `text` plain, `status` a tinted pill, `money` a
13
14
  * currency amount, `date` a localized date, `link` an accent link, `mono` an
@@ -54,9 +55,10 @@ function KeyValueList(options) {
54
55
  }
55
56
  const KeyValueListItemSchema = zod_1.z.object({
56
57
  id: (0, block_registry_1.ui)(zod_1.z.string().optional(), { label: "Key", advanced: true }),
57
- label: (0, block_registry_1.ui)(zod_1.z.string(), { label: "Label" }),
58
- value: (0, block_registry_1.ui)(zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).nullable().optional(), {
58
+ label: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)(), { label: "Label", widget: "text" }),
59
+ value: (0, block_registry_1.ui)(zod_1.z.union([(0, composed_text_1.blockTextSchema)(), zod_1.z.number()]).nullable().optional(), {
59
60
  label: "Value",
61
+ widget: "text",
60
62
  }),
61
63
  type: (0, block_registry_1.ui)(zod_1.z.enum(exports.KEY_VALUE_TYPES).optional(), {
62
64
  label: "Type",
@@ -67,7 +69,7 @@ const KeyValueListItemSchema = zod_1.z.object({
67
69
  label: "Tone",
68
70
  widget: "select",
69
71
  }),
70
- detail: (0, block_registry_1.ui)(zod_1.z.string().optional(), { label: "Detail" }),
72
+ detail: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)().optional(), { label: "Detail", widget: "text" }),
71
73
  currency: (0, block_registry_1.ui)(zod_1.z.string().optional(), { label: "Currency", advanced: true }),
72
74
  });
73
75
  /** The options `KeyValueList` accepts. */
@@ -1 +1 @@
1
- {"version":3,"file":"key-value-list.js","sourceRoot":"","sources":["../../src/base/key-value-list.ts"],"names":[],"mappings":";;;AAuFA,oCASC;AAhGD,4CAAgD;AAChD,6BAAwB;AACxB,qDAA+E;AAC/E,uCAImB;AACnB,gDAA8C;AAC9C,uCAAgD;AAGhD;;;;GAIG;AACU,QAAA,eAAe,GAAG;IAC7B,MAAM;IACN,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAC;AAuCX,MAAM,6BAA6B,GAAG,0BAA0B,CAAC;AACjE,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAW,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,YAAY,CAC1B,OAA2B;IAE3B,OAAO,IAAI,4BAAgB,CAAoB,6BAA6B,CAAC;SAC1E,OAAO,CAAC,EAAE,GAAG,uBAAuB,EAAE,GAAG,OAAO,EAAE,CAAC;SACnD,IAAI,CAAC;QACJ,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,kBAAkB;QAC1C,IAAI,EAAE,mBAAmB;KAC1B,CAAC,CAAC;AACP,CAAC;AAED,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,IAAA,mBAAE,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/D,KAAK,EAAE,IAAA,mBAAE,EAAC,OAAC,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACzC,KAAK,EAAE,IAAA,mBAAE,EAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,E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
63
63
  fetchUrlMethod?: HttpMethod | undefined;
64
64
  periodScope?: string | undefined;
65
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
65
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
66
66
  currencyCode?: string | undefined;
67
67
  showDelta?: boolean | undefined;
68
68
  showSparkline?: boolean | undefined;
@@ -80,7 +80,7 @@ export declare const KpiCardSchema: z.ZodObject<{
80
80
  fetchUrl?: string | undefined;
81
81
  fetchUrlMethod?: HttpMethod | undefined;
82
82
  periodScope?: string | undefined;
83
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
83
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
84
84
  currencyCode?: string | undefined;
85
85
  showDelta?: boolean | undefined;
86
86
  showSparkline?: boolean | undefined;
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  import { type BlockItemsSource } from "./display";
4
4
  import { type Tone, type IconTone } from "./types/tone";
5
5
  import type { BaseComponentProps } from "./types";
6
+ import type { BlockText } from "./types/composed-text";
6
7
  /** One cell of a stat group. */
7
8
  export interface StatGroupItem {
8
9
  /** Stable key; the position is used without one. */
@@ -14,12 +15,20 @@ export interface StatGroupItem {
14
15
  * cards layout.
15
16
  */
16
17
  tone?: IconTone;
17
- /** Mono label above the value; `$`-prefixed for an i18n key. */
18
- eyebrow: string;
19
- /** The figure or the short state; a number is formatted for the locale. */
20
- value: string | number;
21
- /** One line under the value. */
22
- detail?: string;
18
+ /**
19
+ * Mono label above the value; `$`-prefixed for an i18n key, or a
20
+ * `ComposedText`.
21
+ */
22
+ eyebrow: BlockText;
23
+ /**
24
+ * The figure or the short state; a number is formatted for the locale, and
25
+ * a `ComposedText` composes an amount, a date or a count in the
26
+ * reader's language (`{ key: "saas.stats.mrr", params: { amount: { type:
27
+ * "money", value: 92200, currency: "EUR" } } }`).
28
+ */
29
+ value: BlockText | number;
30
+ /** One line under the value: a string or a `ComposedText`. */
31
+ detail?: BlockText;
23
32
  /** Tone of the detail line (`neutral` = muted). */
24
33
  detailTone?: Tone;
25
34
  /** Route, `#anchor` or URL the whole cell links to. */
@@ -80,27 +89,27 @@ export declare const StatGroupSchema: z.ZodObject<{
80
89
  id: z.ZodOptional<z.ZodString>;
81
90
  icon: z.ZodOptional<z.ZodString>;
82
91
  tone: z.ZodOptional<z.ZodEnum<["primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted", ...("primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted")[]]>>;
83
- eyebrow: z.ZodString;
84
- value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
85
- detail: z.ZodOptional<z.ZodString>;
92
+ eyebrow: z.ZodType<BlockText, z.ZodTypeDef, BlockText>;
93
+ value: z.ZodUnion<[z.ZodType<BlockText, z.ZodTypeDef, BlockText>, z.ZodNumber]>;
94
+ detail: z.ZodOptional<z.ZodType<BlockText, z.ZodTypeDef, BlockText>>;
86
95
  detailTone: z.ZodOptional<z.ZodEnum<["primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral", ...("primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral")[]]>>;
87
96
  to: z.ZodOptional<z.ZodString>;
88
97
  }, "strip", z.ZodTypeAny, {
89
- value: string | number;
90
- eyebrow: string;
98
+ value: number | BlockText;
99
+ eyebrow: BlockText;
91
100
  id?: string | undefined;
92
101
  icon?: string | undefined;
93
102
  to?: string | undefined;
94
- detail?: string | undefined;
103
+ detail?: BlockText | undefined;
95
104
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted" | undefined;
96
105
  detailTone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
97
106
  }, {
98
- value: string | number;
99
- eyebrow: string;
107
+ value: number | BlockText;
108
+ eyebrow: BlockText;
100
109
  id?: string | undefined;
101
110
  icon?: string | undefined;
102
111
  to?: string | undefined;
103
- detail?: string | undefined;
112
+ detail?: BlockText | undefined;
104
113
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted" | undefined;
105
114
  detailTone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
106
115
  }>, "many">>;
@@ -110,12 +119,12 @@ export declare const StatGroupSchema: z.ZodObject<{
110
119
  }, "strip", z.ZodTypeAny, {
111
120
  layout: "cards" | "joined";
112
121
  items?: {
113
- value: string | number;
114
- eyebrow: string;
122
+ value: number | BlockText;
123
+ eyebrow: BlockText;
115
124
  id?: string | undefined;
116
125
  icon?: string | undefined;
117
126
  to?: string | undefined;
118
- detail?: string | undefined;
127
+ detail?: BlockText | undefined;
119
128
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted" | undefined;
120
129
  detailTone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
121
130
  }[] | undefined;
@@ -130,12 +139,12 @@ export declare const StatGroupSchema: z.ZodObject<{
130
139
  skeletonCount?: number | undefined;
131
140
  }, {
132
141
  items?: {
133
- value: string | number;
134
- eyebrow: string;
142
+ value: number | BlockText;
143
+ eyebrow: BlockText;
135
144
  id?: string | undefined;
136
145
  icon?: string | undefined;
137
146
  to?: string | undefined;
138
- detail?: string | undefined;
147
+ detail?: BlockText | undefined;
139
148
  tone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | "muted" | undefined;
140
149
  detailTone?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
141
150
  }[] | undefined;
@@ -8,6 +8,7 @@ const block_registry_1 = require("./block-registry");
8
8
  const display_1 = require("./display");
9
9
  const display_2 = require("./internal/display");
10
10
  const tone_1 = require("./types/tone");
11
+ const composed_text_1 = require("./internal/composed-text");
11
12
  /** How a stat group lays its cells out: see `StatGroupProps.layout`. */
12
13
  exports.STAT_GROUP_LAYOUTS = ["joined", "cards"];
13
14
  const STAT_GROUP_COMPONENT_NAME = "dms-stat-group-block";
@@ -44,11 +45,14 @@ const StatGroupItemSchema = zod_1.z.object({
44
45
  label: "Tone",
45
46
  widget: "select",
46
47
  }),
47
- eyebrow: (0, block_registry_1.ui)(zod_1.z.string().describe("Mono label above the value."), {
48
+ eyebrow: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)().describe("Mono label above the value."), {
48
49
  label: "Label",
50
+ widget: "text",
49
51
  }),
50
- value: (0, block_registry_1.ui)(zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).describe("The figure or the state."), { label: "Value" }),
51
- detail: (0, block_registry_1.ui)(zod_1.z.string().optional(), { label: "Detail" }),
52
+ value: (0, block_registry_1.ui)(zod_1.z
53
+ .union([(0, composed_text_1.blockTextSchema)(), zod_1.z.number()])
54
+ .describe("The figure or the state."), { label: "Value", widget: "text" }),
55
+ detail: (0, block_registry_1.ui)((0, composed_text_1.blockTextSchema)().optional(), { label: "Detail", widget: "text" }),
52
56
  detailTone: (0, block_registry_1.ui)((0, display_2.toneEnum)(tone_1.TONES).optional(), {
53
57
  label: "Detail tone",
54
58
  widget: "select",
@@ -1 +1 @@
1
- {"version":3,"file":"stat-group.js","sourceRoot":"","sources":["../../src/base/stat-group.ts"],"names":[],"mappings":";;;AAyEA,8BAMC;AA/ED,4CAAgD;AAChD,6BAAwB;AACxB,qDAA+E;AAC/E,uCAA2E;AAC3E,gDAA8C;AAC9C,uCAA2E;AA0B3E,wEAAwE;AAC3D,QAAA,kBAAkB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC;AAkB/D,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AACzD,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,yBAAyB,GAAoB,QAAQ,CAAC;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CACvB,OAAwB;IAExB,OAAO,IAAI,4BAAgB,CAAiB,yBAAyB,CAAC;SACnE,OAAO,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,EAAE,CAAC;SAC1D,IAAI,CAAC,EAAE,I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,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type Class, type ClassDecorator } from "@antelopejs/interface-core/decorators";
2
+ import type { BlockText } from "../types/composed-text";
2
3
  import type { Tone } from "../types/tone";
3
4
  /**
4
5
  * How table cells (and expanded-row fields) draw a column's value, in place of
@@ -36,6 +37,39 @@ export interface ColumnDisplaySerialized {
36
37
  export declare const RegisterDisplay: (id: string) => ClassDecorator<Class<ColumnDisplay<object>>>;
37
38
  /** The tones of a cell's text. */
38
39
  export type CellTone = "default" | "muted" | "dimmed" | "highlighted" | "success" | "warning" | "error" | "info" | "primary";
40
+ /**
41
+ * A cell's secondary line as a row field holds it, with the tone that row
42
+ * gives it: "Payment failed · retry Oct 10" in `error`, "Due Oct 28" in
43
+ * `muted`. The server picks the text and the tone per row; the column only
44
+ * names the field.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * @Listable(["status", "attemptCount", "nextPaymentAttemptAt"])
49
+ * get statusDetail(): CellSubline | null {
50
+ * if (this.status !== "open" || !this.nextPaymentAttemptAt) return null;
51
+ * const date = this.nextPaymentAttemptAt.toISOString();
52
+ * return {
53
+ * text: {
54
+ * key: "$saas.invoice.sub_state.retry",
55
+ * params: { date: { type: "date", value: date, format: "day" } },
56
+ * },
57
+ * tone: "error",
58
+ * };
59
+ * }
60
+ * ```
61
+ */
62
+ export interface CellSubline {
63
+ /** The line: a string (`$`-prefixed for an i18n key) or a composed text. */
64
+ text: BlockText;
65
+ /** Tone of the line; the display's own tone when left out. */
66
+ tone?: CellTone;
67
+ }
68
+ /**
69
+ * What a row field drawn as a cell's secondary line holds: a text, or a text
70
+ * and its tone. Nothing (`null`, `""`) draws no line.
71
+ */
72
+ export type CellSublineValue = BlockText | CellSubline;
39
73
  export declare namespace DefaultDisplays {
40
74
  /** A badge an identity cell shows when a field of the row matches. */
41
75
  interface IdentityBadge {
@@ -55,8 +89,14 @@ export declare namespace DefaultDisplays {
55
89
  avatarField?: string;
56
90
  /** Icon drawn in a tile instead of an avatar. */
57
91
  icon?: string;
58
- /** Row field drawn as the secondary line. */
92
+ /**
93
+ * Row field drawn as the secondary line: a string, drawn as written (an
94
+ * address, an id), or a `ComposedText` or {@link CellSubline}
95
+ * composed in the reader's language.
96
+ */
59
97
  subtitleField?: string;
98
+ /** Tone of the secondary line when the row gives none. Defaults to `dimmed`. */
99
+ subtitleTone?: CellTone;
60
100
  /** Row field holding the user id that marks the signed-in user's row. */
61
101
  selfField?: string;
62
102
  /** Tag of the signed-in user's row ("You"). `$`-prefixed: an i18n key. */
@@ -64,10 +104,18 @@ export declare namespace DefaultDisplays {
64
104
  badges?: IdentityBadge[];
65
105
  /** File storage the avatar is read from. */
66
106
  storage?: string;
107
+ /**
108
+ * Name drawn, muted, for a row without a value ("Automatic" for a credit
109
+ * note no operator issued). `$`-prefixed: an i18n key.
110
+ */
111
+ emptyLabel?: string;
112
+ /** Icon drawn in a tile for a row without a value (`i-ph-robot`). */
113
+ emptyIcon?: string;
67
114
  }
68
115
  /**
69
116
  * Avatar or icon tile, the value as the name, a "You" tag on the signed-in
70
- * user's row, badges and a secondary line, all read off the row.
117
+ * user's row, badges and a secondary line, all read off the row; an empty
118
+ * label and icon for a row without a value.
71
119
  */
72
120
  class IdentityDisplay extends ColumnDisplay<IdentityDisplayOptions> {
73
121
  }
@@ -142,14 +190,43 @@ export declare namespace DefaultDisplays {
142
190
  * @example { healthy: "success", degraded: "warning", failing: "error" }
143
191
  */
144
192
  tones: Record<string, Tone>;
145
- /** Row field drawn under the pill, in its tone (the failure's cause). */
193
+ /**
194
+ * Row field drawn under the pill (the failure's cause): a string
195
+ * (`$`-prefixed for an i18n key), a `ComposedText` or a
196
+ * {@link CellSubline} carrying its own tone.
197
+ */
146
198
  subField?: string;
199
+ /** Tone of the line under the pill when the row gives none; the pill's by default. */
200
+ subTone?: CellTone;
147
201
  /** A pulsing dot for these values (a run in progress). */
148
202
  liveValues?: string[];
149
203
  }
150
204
  /** A status as a tinted pill led by a dot, with an optional line under it. */
151
205
  class StatusPillDisplay extends ColumnDisplay<StatusPillDisplayOptions> {
152
206
  }
207
+ interface TwoLineDisplayOptions {
208
+ /**
209
+ * Row field holding the primary line, a string (`$`-prefixed for an i18n
210
+ * key) or a `ComposedText`, drawn in place of the column's value
211
+ * ("Renews in 3 days" over a `renewsAt` date column). Without it the
212
+ * primary line is the column's value, written by the column's own data
213
+ * type (an amount, a date, a select's label) or composed when the value
214
+ * is a `ComposedText`.
215
+ */
216
+ primaryField?: string;
217
+ /** Row field holding the secondary line: a {@link CellSublineValue}. */
218
+ subField?: string;
219
+ /** Tone of the secondary line when the row gives none. Defaults to `muted`. */
220
+ subTone?: CellTone;
221
+ /** Text drawn for an empty primary line. `$`-prefixed: an i18n key. Defaults to "—". */
222
+ emptyLabel?: string;
223
+ }
224
+ /**
225
+ * A primary line over a secondary one, without an avatar: a plan over its
226
+ * price per seat, an amount over what it means, a reason over its memo.
227
+ */
228
+ class TwoLineDisplay extends ColumnDisplay<TwoLineDisplayOptions> {
229
+ }
153
230
  interface ProgressDisplayOptions {
154
231
  /** Row field holding the number of items done. */
155
232
  doneField: string;
@@ -47,7 +47,8 @@ var DefaultDisplays;
47
47
  (function (DefaultDisplays) {
48
48
  /**
49
49
  * Avatar or icon tile, the value as the name, a "You" tag on the signed-in
50
- * user's row, badges and a secondary line, all read off the row.
50
+ * user's row, badges and a secondary line, all read off the row; an empty
51
+ * label and icon for a row without a value.
51
52
  */
52
53
  let IdentityDisplay = class IdentityDisplay extends ColumnDisplay {
53
54
  };
@@ -89,6 +90,16 @@ var DefaultDisplays;
89
90
  (0, exports.RegisterDisplay)("status_pill")
90
91
  ], StatusPillDisplay);
91
92
  DefaultDisplays.StatusPillDisplay = StatusPillDisplay;
93
+ /**
94
+ * A primary line over a secondary one, without an avatar: a plan over its
95
+ * price per seat, an amount over what it means, a reason over its memo.
96
+ */
97
+ let TwoLineDisplay = class TwoLineDisplay extends ColumnDisplay {
98
+ };
99
+ TwoLineDisplay = __decorate([
100
+ (0, exports.RegisterDisplay)("two_line")
101
+ ], TwoLineDisplay);
102
+ DefaultDisplays.TwoLineDisplay = TwoLineDisplay;
92
103
  /**
93
104
  * A bar filled with the share of items done ("31 / 44"), failed items in
94
105
  * red at its end; green once every item is done.
@@ -1 +1 @@
1
- {"version":3,"file":"column-display.js","sourceRoot":"","sources":["../../../src/base/table-view/column-display.ts"],"names":[],"mappings":";;;;;;;;;AAAA,sEAI+C;AAE/C,8DAAuD;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,MAAsB,aAAa;IAML;IAH5B,qEAAqE;IAClD,eAAe,GAAG,IAAI,CAAC;IAE1C,YAA4B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;CAClD;AAPD,sCAOC;AASD;;;;;GAKG;AACU,QAAA,eAAe,GAEwB,IAAA,+BAAkB,EACpE,CAAC,MAAM,EAAE,EAAU,EAAE,EAAE;IACrB,2BAAU,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC,CACF,CAAC;AAcF,IAAiB,eAAe,CAkL/B;AAlLD,WAAiB,eAAe;IA+B9B;;;OAGG;IAEH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,aAAqC;KAAG,CAAA;IAAhE,eAAe;QAD3B,IAAA,uBAAe,EAAC,UAAU,CAAC;OACf,eAAe,CAAiD;IAAhE,+BAAe,kBAAiD,CAAA;IAoB7E;;;OAGG;IAEH,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,aAAkC;KAAG,CAAA;IAA1D,YAAY;QADxB,IAAA,uBAAe,EAAC,OAAO,CAAC;OACZ,YAAY,CAA8C;IAA1D,4BAAY,eAA8C,CAAA;IA2BvE;;;OAGG;IAEH,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,aAAyC;KAAG,CAAA;IAAxE,mBAAmB;QAD/B,IAAA,uBAAe,EAAC,eAAe,CAAC;OACpB,mBAAmB,CAAqD;IAAxE,mCAAmB,s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4BAAY,eAAgD,CAAA;IAOzE,wDAAwD;IAExD,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,aAAiC;KAAG,CAAA;IAAxD,WAAW;QADvB,IAAA,uBAAe,EAAC,MAAM,CAAC;OACX,WAAW,CAA6C;IAAxD,2BAAW,cAA6C,CAAA;AACvE,CAAC,EA/NgB,eAAe,+BAAf,eAAe,QA+N/B"}
@@ -897,7 +897,7 @@ export declare const TableViewSchema: z.ZodObject<{
897
897
  countLabel?: string | undefined;
898
898
  } | undefined;
899
899
  labelKey?: string | undefined;
900
- layout?: "full" | "compact" | undefined;
900
+ layout?: "compact" | "full" | undefined;
901
901
  card?: {
902
902
  component?: import("../..").Component<unknown> | undefined;
903
903
  fields?: string[] | undefined;
@@ -1093,7 +1093,7 @@ export declare const TableViewSchema: z.ZodObject<{
1093
1093
  countLabel?: string | undefined;
1094
1094
  } | undefined;
1095
1095
  labelKey?: string | undefined;
1096
- layout?: "full" | "compact" | undefined;
1096
+ layout?: "compact" | "full" | undefined;
1097
1097
  card?: {
1098
1098
  component?: import("../..").Component<unknown> | undefined;
1099
1099
  fields?: string[] | undefined;
@@ -135,7 +135,7 @@ export declare const TopListCardSchema: z.ZodObject<{
135
135
  maxHeight?: string | undefined;
136
136
  skeletonCount?: number | undefined;
137
137
  periodScope?: string | undefined;
138
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
138
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
139
139
  currencyCode?: string | undefined;
140
140
  showDelta?: boolean | undefined;
141
141
  showSparkline?: boolean | undefined;
@@ -169,7 +169,7 @@ export declare const TopListCardSchema: z.ZodObject<{
169
169
  maxHeight?: string | undefined;
170
170
  skeletonCount?: number | undefined;
171
171
  periodScope?: string | undefined;
172
- valueFormat?: "number" | "compact" | "percent" | "currency" | undefined;
172
+ valueFormat?: "number" | "percent" | "compact" | "currency" | undefined;
173
173
  currencyCode?: string | undefined;
174
174
  showDelta?: boolean | undefined;
175
175
  showSparkline?: boolean | undefined;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * A text the dashboard composes in the reader's language: an i18n key and the
3
+ * raw values its message names, each formatted for the reader's locale, time
4
+ * zone and clock when the text is drawn. The server sends the values, never a
5
+ * finished sentence, so a route answers the same JSON whatever the language of
6
+ * the person reading it.
7
+ *
8
+ * The key is looked up like any `$`-prefixed text, with or without its `$`:
9
+ * `"saas.billing.retry"` and `"$saas.billing.retry"` are the same message.
10
+ * A key the active language lacks falls back to the fallback language, then to
11
+ * the bare key.
12
+ *
13
+ * Plurals follow vue-i18n: the message lists its forms split by `|`
14
+ * (`"no seat | {count} seat | {count} seats"`) and the number named by
15
+ * `plural` picks one — by default the first `count` parameter.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // "saas.banner.past_due": "Invoice {invoice} of {amount} failed, retry {date}"
20
+ * const text: ComposedText = {
21
+ * key: "saas.banner.past_due",
22
+ * params: {
23
+ * invoice: "INV-0042",
24
+ * amount: { type: "money", value: 2900, currency: "EUR" },
25
+ * date: { type: "date", value: "2026-10-10", format: "day" },
26
+ * },
27
+ * };
28
+ * ```
29
+ */
30
+ export interface ComposedText {
31
+ /** The i18n key of the message; the leading `$` is optional. */
32
+ key: string;
33
+ /** The values the message names, by the name it gives them. */
34
+ params?: Record<string, ComposedTextParam>;
35
+ /**
36
+ * The parameter whose number picks the plural form. Defaults to the first
37
+ * `count` parameter; without one the message is not pluralised.
38
+ */
39
+ plural?: string;
40
+ }
41
+ /**
42
+ * An amount in the minor unit of its currency (cents for `EUR`, yen for
43
+ * `JPY`), written with the currency's symbol in the reader's locale:
44
+ * `{ type: "money", value: 92200, currency: "EUR" }` reads "€922.00" in
45
+ * English, "922,00 €" in French.
46
+ */
47
+ export interface ComposedTextMoneyParam {
48
+ type: "money";
49
+ /** The amount in minor units: an integer, the way payment providers store it. */
50
+ value: number;
51
+ /** ISO 4217 code. An unknown code writes the amount as a plain number. */
52
+ currency: string;
53
+ }
54
+ /** How much of a date a `date` or `datetime` parameter writes. */
55
+ export declare const COMPOSED_TEXT_DATE_FORMATS: readonly ["day", "short", "medium", "long"];
56
+ /**
57
+ * `day`: day and month ("Oct 10"); `short`: numeric ("10/10/2026");
58
+ * `medium`: the month abbreviated ("Oct 10, 2026"); `long`: the month in
59
+ * full ("October 10, 2026").
60
+ */
61
+ export type ComposedTextDateFormat = (typeof COMPOSED_TEXT_DATE_FORMATS)[number];
62
+ /**
63
+ * A date (`date`), or a date and its time (`datetime`), in the reader's
64
+ * language, time zone and date format preference.
65
+ */
66
+ export interface ComposedTextDateParam {
67
+ type: "date" | "datetime";
68
+ /** An ISO 8601 string or a timestamp in milliseconds. */
69
+ value: string | number;
70
+ /** Defaults to `medium`. */
71
+ format?: ComposedTextDateFormat;
72
+ }
73
+ /**
74
+ * The distance from now, past or future, in the largest whole unit: "in 3
75
+ * days", "tomorrow", "2 hours ago". It is computed when the text is drawn.
76
+ */
77
+ export interface ComposedTextRelativeDateParam {
78
+ type: "relative";
79
+ /** An ISO 8601 string or a timestamp in milliseconds. */
80
+ value: string | number;
81
+ }
82
+ /** How a `number` parameter is written. */
83
+ export declare const COMPOSED_TEXT_NUMBER_FORMATS: readonly ["decimal", "percent", "compact"];
84
+ /**
85
+ * `decimal`: grouped digits ("1,284.5"); `percent`: a ratio as a percentage
86
+ * (`0.25` → "25%"); `compact`: a short form ("1.3K").
87
+ */
88
+ export type ComposedTextNumberFormat = (typeof COMPOSED_TEXT_NUMBER_FORMATS)[number];
89
+ /** A number written for the reader's locale. */
90
+ export interface ComposedTextNumberParam {
91
+ type: "number";
92
+ value: number;
93
+ /** Defaults to `decimal`. */
94
+ format?: ComposedTextNumberFormat;
95
+ }
96
+ /**
97
+ * A count: written like a number, and the parameter that picks the plural
98
+ * form of the message unless `ComposedText.plural` names another one.
99
+ */
100
+ export interface ComposedTextCountParam {
101
+ type: "count";
102
+ value: number;
103
+ }
104
+ /** A parameter that says how its value is written. */
105
+ export type ComposedTextTypedParam = ComposedTextMoneyParam | ComposedTextDateParam | ComposedTextRelativeDateParam | ComposedTextNumberParam | ComposedTextCountParam;
106
+ /** The `type` of a typed parameter. */
107
+ export type ComposedTextParamType = ComposedTextTypedParam["type"];
108
+ /**
109
+ * A value a composed text names. A string is inserted as written — it is
110
+ * data (an invoice number, a plan name), not a key; a bare number is written
111
+ * for the locale; a typed parameter is formatted by its `type`; a nested
112
+ * `ComposedText` is composed first ("Business · {seats}" inside a sentence).
113
+ */
114
+ export type ComposedTextParam = string | number | ComposedTextTypedParam | ComposedText;
115
+ /**
116
+ * Any text a block draws: a plain string, `$`-prefixed for an i18n key, or a
117
+ * {@link ComposedText}. Every option and fetched field typed `BlockText`
118
+ * accepts both, so a route can answer either.
119
+ */
120
+ export type BlockText = string | ComposedText;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMPOSED_TEXT_NUMBER_FORMATS = exports.COMPOSED_TEXT_DATE_FORMATS = void 0;
4
+ /** How much of a date a `date` or `datetime` parameter writes. */
5
+ exports.COMPOSED_TEXT_DATE_FORMATS = [
6
+ "day",
7
+ "short",
8
+ "medium",
9
+ "long",
10
+ ];
11
+ /** How a `number` parameter is written. */
12
+ exports.COMPOSED_TEXT_NUMBER_FORMATS = [
13
+ "decimal",
14
+ "percent",
15
+ "compact",
16
+ ];
17
+ //# sourceMappingURL=composed-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composed-text.js","sourceRoot":"","sources":["../../../src/base/types/composed-text.ts"],"names":[],"mappings":";;;AAuDA,kEAAkE;AACrD,QAAA,0BAA0B,GAAG;IACxC,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;CACE,CAAC;AAgCX,2CAA2C;AAC9B,QAAA,4BAA4B,GAAG;IAC1C,SAAS;IACT,SAAS;IACT,SAAS;CACD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export * from "./base-component-props";
2
2
  export * from "./button";
3
3
  export * from "./color";
4
+ export * from "./composed-text";
4
5
  export * from "./component-input";
5
6
  export * from "./confirm-dialog";
6
7
  export * from "./custom-button";
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-component-props"), exports);
18
18
  __exportStar(require("./button"), exports);
19
19
  __exportStar(require("./color"), exports);
20
+ __exportStar(require("./composed-text"), exports);
20
21
  __exportStar(require("./component-input"), exports);
21
22
  __exportStar(require("./confirm-dialog"), exports);
22
23
  __exportStar(require("./custom-button"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,mDAAiC;AACjC,kDAAgC;AAChC,gDAA8B;AAC9B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,8CAA4B;AAC5B,gDAA8B;AAC9B,yCAAuB;AACvB,yCAAuB;AACvB,gDAA8B;AAC9B,sDAAoC;AACpC,yCAAuB;AACvB,yCAAuB;AACvB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,2CAAyB;AACzB,0CAAwB;AACxB,kDAAgC;AAChC,oDAAkC;AAClC,mDAAiC;AACjC,kDAAgC;AAChC,gDAA8B;AAC9B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,8CAA4B;AAC5B,gDAA8B;AAC9B,yCAAuB;AACvB,yCAAuB;AACvB,gDAA8B;AAC9B,sDAAoC;AACpC,yCAAuB;AACvB,yCAAuB;AACvB,0CAAwB"}
@@ -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 site layout
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 line of text. */
69
- export interface LayoutBannerTextInfo extends LayoutBannerBase {
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 LayoutBannerBase {
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 server-side for every
99
- * site layout request, so the banner is in the server-rendered page. When 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.
@@ -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 server-side for every
24
- * site layout request, so the banner is in the server-rendered page. When 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":";;;AA0HA,oDAGC;AA7HD,+DAA8D;AAI9D;;;;GAIG;AACU,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AA0FX,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"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/interface-dms",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
5
5
  "keywords": [
6
6
  "antelopejs",