jmapcloud-ng-core-types 2.0.13-qa.6 → 2.0.13-qa.7

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/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export type {
25
25
  JUIState,
26
26
  JUserState
27
27
  } from "./public/state.d.ts"
28
- export type { JAppConfirmMessage, JAppMessage, JAppMessageOptions, JAppMessageService, JAppMessageState, JAppOverlayMessage } from "./public/jmap/message.d.ts"
28
+ export type { JAppConfirmMessage, JAppMessage, JAppMessageOptions, JAppMessageService, JAppMessageState, JAppOverlayMessage, JAppRenderableMessage } from "./public/jmap/message.d.ts"
29
29
  export type { JAppUserAction } from "./public/jmap/user.d.ts"
30
30
 
31
31
  export interface JCoreService extends JCoreMainService {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "jmapcloud-ng-core-types",
3
- "version": "2.0.13-qa.6",
3
+ "version": "2.0.13-qa.7",
4
4
  "description": "JMap Cloud specific version of JMap Cloud NG Core types and interfaces",
5
5
  "main": "index.js",
6
6
  "types": "ambient.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "update-types-bridge": "node build/codemod-export-globals.js && node build/auto-add-imports.js && node build/generate-ambient.js && npx prettier --write public/global-aliases.d.ts ambient.d.ts",
9
+ "update-types-bridge": "node build/codemod-export-globals.js && node build/auto-add-imports.js && node build/generate-ambient.js && node ../../../node_modules/prettier/bin/prettier.cjs --write public/global-aliases.d.ts ambient.d.ts",
10
10
  "pub-github": "npm run update-types-bridge && node build/buildfile.js publish-github;",
11
11
  "doc-test": "npm run update-types-bridge && node build/buildfile.js doc-test;"
12
12
  },
@@ -364,6 +364,7 @@ declare global {
364
364
  /** @internal */ const MESSAGE_ACTION_TYPES: typeof message.MESSAGE_ACTION_TYPES
365
365
  /** @internal */ type JAppMessage = message.JAppMessage
366
366
  /** @internal */ type JAppOverlayMessage = message.JAppOverlayMessage
367
+ /** @internal */ type JAppRenderableMessage = message.JAppRenderableMessage
367
368
  /** @internal */ type JAppConfirmMessage = message.JAppConfirmMessage
368
369
  /** @internal */ type JAppMessageOptions = message.JAppMessageOptions
369
370
  /** @internal */ type JAppMessageState = message.JAppMessageState
@@ -1,4 +1,5 @@
1
1
  import type { JLOCALES } from "./language.d.ts"
2
+ import type { ReactNode } from "react"
2
3
  export {}
3
4
 
4
5
  // ALL_APP_MESSAGE_SEVERITIES in all-enums.ts
@@ -33,8 +34,59 @@ export interface JAppOverlayMessage {
33
34
  text: string
34
35
  }
35
36
 
37
+ /**
38
+ * Explicit message content modes for NG.
39
+ *
40
+ * Three explicit content modes are supported:
41
+ *
42
+ * 1. Plain text
43
+ * `{ kind: "text", value: "Delete project foo?" }`
44
+ * Render as inert text with no HTML interpretation.
45
+ *
46
+ * 2. Sanitized HTML
47
+ * `{ kind: "html", value: "Delete <b>foo</b>?<br>Please confirm.", policy: "dialog" }`
48
+ * Use only when intentionally rendering an HTML string. The renderer must
49
+ * sanitize the string before display. This is especially useful for
50
+ * translated rich messages, for example:
51
+ * `{ kind: "html", value: JMap.Language.translate("project.delete.message", { projectName: "<b>My project</b>" }), policy: "dialog" }`
52
+ *
53
+ * 3. React node / JSX
54
+ * `{ kind: "node", value: <>Delete <strong>{project.name}</strong>?</> }`
55
+ * Preferred when formatting is needed, because React escapes interpolated
56
+ * values automatically and avoids raw HTML string construction.
57
+ */
58
+ export type JAppRenderableMessage =
59
+ | {
60
+ kind: "html"
61
+ policy?: "dialog" | "presentation"
62
+ value: string
63
+ }
64
+ | {
65
+ kind: "node"
66
+ value: ReactNode
67
+ }
68
+ | {
69
+ kind: "text"
70
+ value: string
71
+ }
72
+
36
73
  export interface JAppConfirmMessage {
37
- message: string
74
+ /**
75
+ * Bare `string` means plain text by default.
76
+ *
77
+ * Explicit rich-content forms are:
78
+ * - `{ kind: "text", value }` for plain text
79
+ * - `{ kind: "html", value, policy }` for intentionally rich HTML that must
80
+ * be sanitized by the renderer, for example a rich message produced by
81
+ * `JMap.Language.translate(...)`
82
+ * - `{ kind: "node", value }` for JSX / ReactNode content
83
+ *
84
+ * Guidance:
85
+ * - default to plain text
86
+ * - prefer `node` when formatting is needed
87
+ * - use `html` only for legacy / translated HTML-string flows
88
+ */
89
+ message: JAppRenderableMessage | string
38
90
  title: string
39
91
  isInputMessage?: boolean
40
92
  isInputOptional?: boolean
@@ -58,6 +110,20 @@ export interface JAppMessageState {
58
110
  }
59
111
 
60
112
  export interface JAppMessageService {
113
+ /**
114
+ * Confirm message content supports three intended modes:
115
+ *
116
+ * - plain text:
117
+ * `message: "Delete project foo?"`
118
+ *
119
+ * - sanitized HTML string:
120
+ * `message: { kind: "html", value: "Delete <b>foo</b>?", policy: "dialog" }`
121
+ *
122
+ * - JSX / ReactNode:
123
+ * `message: { kind: "node", value: <>Delete <strong>{project.name}</strong>?</> }`
124
+ *
125
+ * Plain text is the default.
126
+ */
61
127
  error(message: string, options?: JAppMessageOptions): void
62
128
  warning(message: string, options?: JAppMessageOptions): void
63
129
  info(message: string, options?: JAppMessageOptions): void