@eworkbase/sdk 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Workbase SDK
2
+
3
+ 用于开发 Workbase 插件的 TypeScript SDK,提供宿主接口和共享界面组件。
4
+
5
+ TypeScript SDK for building Workbase plugins with host APIs and shared UI components.
package/dist/style.css CHANGED
@@ -2127,7 +2127,7 @@
2127
2127
  margin: 8px 0 0;
2128
2128
  }
2129
2129
 
2130
- .markdown-document-heading button, .markdown-link-error button {
2130
+ .markdown-document-heading button {
2131
2131
  border: 1px solid var(--color-border-strong);
2132
2132
  background: var(--color-surface);
2133
2133
  color: var(--color-foreground);
@@ -2138,7 +2138,7 @@
2138
2138
  padding: 6px 10px;
2139
2139
  }
2140
2140
 
2141
- .markdown-document-heading button:hover, .markdown-link-error button:hover {
2141
+ .markdown-document-heading button:hover {
2142
2142
  background: var(--color-surface-muted);
2143
2143
  }
2144
2144
 
@@ -2147,16 +2147,6 @@
2147
2147
  outline-offset: 2px;
2148
2148
  }
2149
2149
 
2150
- .markdown-link-error {
2151
- color: var(--color-danger);
2152
- overflow-wrap: anywhere;
2153
- line-height: 1.6;
2154
- }
2155
-
2156
- .markdown-link-error button {
2157
- margin-inline-start: 8px;
2158
- }
2159
-
2160
2150
  .workbase-markdown-links .markdown-document-body {
2161
2151
  max-width: 75ch;
2162
2152
  max-height: 65vh;
@@ -1,8 +1,8 @@
1
1
  import { errorSummary } from "./model.js";
2
2
  import { memo, useId, useState } from "react";
3
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/ui/PluginErrorPanel.tsx
5
- /** 宿主与插件共用的错误展示,保留可见原因并折叠技术详情,不执行业务恢复。 */
5
+ /** 宿主与插件共用的就地错误提示,优先展示原因和恢复操作。 */
6
6
  const PluginErrorPanel = memo(function PluginErrorPanel(props) {
7
7
  return /* @__PURE__ */ jsx(ErrorDetails, { ...props }, JSON.stringify([
8
8
  props.title,
@@ -12,7 +12,13 @@ const PluginErrorPanel = memo(function PluginErrorPanel(props) {
12
12
  });
13
13
  function ErrorDetails({ title, error, scope, recovery, technicalDetails = error, isDismissible = false, children, className, ...attributes }) {
14
14
  const headingId = useId();
15
+ const detailsId = useId();
15
16
  const [closed, setClosed] = useState(false);
17
+ const [showDetails, setShowDetails] = useState(false);
18
+ function handleClose() {
19
+ setShowDetails(false);
20
+ setClosed(!closed);
21
+ }
16
22
  if (closed && isDismissible) return null;
17
23
  return /* @__PURE__ */ jsxs("section", {
18
24
  tabIndex: 0,
@@ -28,34 +34,54 @@ function ErrorDetails({ title, error, scope, recovery, technicalDetails = error,
28
34
  children: title
29
35
  }), /* @__PURE__ */ jsx("button", {
30
36
  type: "button",
31
- className: "workbase-error-toggle",
37
+ className: closed ? "workbase-error-toggle" : "workbase-error-toggle workbase-error-close",
32
38
  "aria-label": closed ? "查看错误详情" : "关闭错误提示",
39
+ title: closed ? void 0 : "关闭错误提示",
33
40
  "aria-expanded": isDismissible ? void 0 : !closed,
34
- onClick: () => setClosed(!closed),
35
- children: closed ? "查看错误详情" : "关闭"
41
+ onClick: handleClose,
42
+ children: closed ? "查看错误详情" : null
36
43
  })]
37
- }), !closed && /* @__PURE__ */ jsxs(Fragment, { children: [
38
- /* @__PURE__ */ jsx("p", {
39
- className: "workbase-error-cause",
40
- children: errorSummary(error)
41
- }),
42
- /* @__PURE__ */ jsxs("p", {
43
- className: "workbase-error-context",
44
- children: [/* @__PURE__ */ jsx("strong", { children: "影响范围" }), scope]
45
- }),
46
- /* @__PURE__ */ jsxs("p", {
47
- className: "workbase-error-context",
48
- children: [/* @__PURE__ */ jsx("strong", { children: "处理建议" }), recovery]
49
- }),
50
- /* @__PURE__ */ jsxs("details", {
51
- className: "workbase-error-details",
52
- children: [/* @__PURE__ */ jsx("summary", { children: "技术详情" }), /* @__PURE__ */ jsx("pre", { children: technicalDetails })]
53
- }),
54
- children ? /* @__PURE__ */ jsx("div", {
55
- className: "workbase-error-actions",
56
- children
57
- }) : null
58
- ] })]
44
+ }), !closed && /* @__PURE__ */ jsxs("div", {
45
+ className: "workbase-error-body",
46
+ children: [
47
+ /* @__PURE__ */ jsx("p", {
48
+ className: "workbase-error-cause",
49
+ children: errorSummary(error)
50
+ }),
51
+ /* @__PURE__ */ jsxs("div", {
52
+ className: "workbase-error-actions",
53
+ children: [children, /* @__PURE__ */ jsxs("button", {
54
+ type: "button",
55
+ className: "workbase-error-disclosure",
56
+ "aria-expanded": showDetails,
57
+ "aria-controls": detailsId,
58
+ onClick: () => setShowDetails(!showDetails),
59
+ children: [showDetails ? "收起详情" : "查看详情", /* @__PURE__ */ jsx("svg", {
60
+ "aria-hidden": "true",
61
+ width: "14",
62
+ height: "14",
63
+ viewBox: "0 0 24 24",
64
+ fill: "none",
65
+ stroke: "currentColor",
66
+ strokeWidth: "1.8",
67
+ strokeLinecap: "round",
68
+ strokeLinejoin: "round",
69
+ children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
70
+ })]
71
+ })]
72
+ }),
73
+ /* @__PURE__ */ jsxs("dl", {
74
+ className: "workbase-error-details",
75
+ id: detailsId,
76
+ hidden: !showDetails,
77
+ children: [
78
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "影响范围" }), /* @__PURE__ */ jsx("dd", { children: scope })] }),
79
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "处理建议" }), /* @__PURE__ */ jsx("dd", { children: recovery })] }),
80
+ /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "技术详情" }), /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx("pre", { children: technicalDetails }) })] })
81
+ ]
82
+ })
83
+ ]
84
+ })]
59
85
  });
60
86
  }
61
87
  //#endregion
@@ -130,13 +130,13 @@ function MarkdownLinkBoundary({ host, children }) {
130
130
  }, [hasPreview]);
131
131
  return /* @__PURE__ */ jsxs("div", {
132
132
  ref: container,
133
- className: "workbase-markdown-links",
133
+ className: "workbase-markdown-links workbase-feedback-page",
134
134
  children: [
135
- error ? /* @__PURE__ */ jsxs("p", {
135
+ error ? /* @__PURE__ */ jsxs("div", {
136
136
  role: "alert",
137
- className: "markdown-link-error",
137
+ className: "workbase-inline-error",
138
138
  children: [
139
- error,
139
+ /* @__PURE__ */ jsx("span", { children: error }),
140
140
  request ? /* @__PURE__ */ jsx("button", {
141
141
  type: "button",
142
142
  onClick: handleRetry,
@@ -144,9 +144,9 @@ function MarkdownLinkBoundary({ host, children }) {
144
144
  }) : null,
145
145
  /* @__PURE__ */ jsx("button", {
146
146
  type: "button",
147
+ className: "workbase-error-close",
147
148
  "aria-label": "关闭错误提示",
148
- onClick: () => setError(""),
149
- children: "关闭"
149
+ onClick: () => setError("")
150
150
  })
151
151
  ]
152
152
  }) : null,
package/dist/ui/theme.css CHANGED
@@ -225,37 +225,68 @@
225
225
 
226
226
  .mantine-Alert-root { padding: 12px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
227
227
  .mantine-Alert-message { color: inherit; font-size: 14px; line-height: 1.5; }
228
- .workbase-plugin-error {
228
+ .workbase-plugin-error, .workbase-inline-error, .workbase-error-alert {
229
+ --workbase-notice-accent: var(--color-danger);
230
+ --workbase-error-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5m0 3h.01'/%3E%3C/svg%3E");
229
231
  min-width: 0;
230
- max-height: 100%;
231
232
  flex-shrink: 0;
232
- overflow-y: auto;
233
- padding: 16px 20px;
234
- border: 1px solid color-mix(in srgb, var(--color-danger) 24%, var(--color-border));
235
- border-radius: 8px;
233
+ padding: 12px 16px;
234
+ border: 1px solid color-mix(in srgb, var(--workbase-notice-accent) 16%, var(--color-border));
235
+ border-radius: var(--workbase-panel-radius);
236
236
  color: var(--color-foreground);
237
- background: color-mix(in srgb, var(--color-danger) 5%, var(--color-surface));
238
- text-align: left;
237
+ background: color-mix(in srgb, var(--workbase-notice-accent) 2%, var(--color-surface));
238
+ text-align: start;
239
239
  overflow-wrap: anywhere;
240
- scrollbar-color: var(--color-border-strong) transparent;
241
- scrollbar-width: thin;
242
240
  }
241
+ .workbase-feedback-page > :is(.workbase-plugin-error, .workbase-inline-error, .mantine-Alert-root, .workbase-error-reopen, .workbase-page-notice) {
242
+ margin: 0 var(--workbase-page-inset) var(--workbase-panel-gap);
243
+ }
244
+ .workbase-feedback-page > :is(.workbase-plugin-error, .workbase-inline-error, .mantine-Alert-root, .workbase-error-reopen, .workbase-page-notice):first-child {
245
+ margin-block-start: var(--workbase-panel-gap);
246
+ }
247
+ .workbase-error-header::before, .workbase-inline-error::before, .workbase-error-alert > .mantine-Alert-wrapper:not(:has(> .mantine-Alert-icon))::before {
248
+ content: "";
249
+ flex: 0 0 18px;
250
+ height: 18px;
251
+ background: var(--workbase-notice-accent);
252
+ mask: var(--workbase-error-icon) center / contain no-repeat;
253
+ }
254
+ .workbase-plugin-error { max-height: 100%; overflow: auto; scrollbar-color: var(--color-border-strong) transparent; scrollbar-width: thin; }
243
255
  .workbase-plugin-error:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
244
- .workbase-error-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
245
- .workbase-plugin-error .workbase-error-title { margin: 0; color: var(--color-danger); font-size: 14px; font-weight: 600; line-height: 1.5; }
246
- .workbase-error-toggle { flex: none; min-height: 24px; padding: 0 4px; color: var(--color-muted); font: inherit; font-size: 12px; background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
247
- .workbase-error-toggle:hover { color: var(--color-foreground); text-decoration: underline; }
248
- .workbase-error-toggle:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
249
- .workbase-error-header + .workbase-error-cause { margin-top: 8px; }
250
- .workbase-plugin-error .workbase-error-cause { margin: 0; color: var(--color-foreground); font-size: 14px; font-weight: 500; line-height: 1.65; white-space: pre-wrap; }
251
- .workbase-plugin-error .workbase-error-context { margin: 8px 0 0; color: var(--color-foreground); font-size: 12px; font-weight: 400; line-height: 1.65; }
252
- .workbase-error-context strong { margin-right: 8px; font-weight: 600; }
253
- .workbase-error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
254
- .workbase-error-details { margin-top: 12px; color: var(--color-foreground); font-size: 12px; font-weight: 400; }
255
- .workbase-error-details summary { width: fit-content; cursor: pointer; text-underline-offset: 3px; }
256
- .workbase-error-details summary:hover { text-decoration: underline; }
257
- .workbase-error-details summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 4px; }
258
- .workbase-error-details pre { max-width: 100%; max-height: 240px; margin: 8px 0 0; padding: 12px; overflow: auto; border-radius: 4px; color: var(--color-foreground); background: var(--color-surface); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; scrollbar-color: var(--color-border-strong) transparent; scrollbar-width: thin; }
256
+ .workbase-error-header { display: flex; align-items: center; gap: 10px; }
257
+ .workbase-plugin-error .workbase-error-title { flex: 1; min-width: 0; margin: 0; color: var(--color-foreground); font-size: var(--workbase-type-body); font-weight: 650; line-height: 1.45; }
258
+ .workbase-error-body { margin-inline-start: 28px; }
259
+ .workbase-plugin-error .workbase-error-cause { max-width: 75ch; margin: 0; color: var(--color-foreground); font-size: var(--workbase-type-body); font-weight: 400; line-height: 1.55; white-space: pre-wrap; }
260
+ .workbase-error-actions, .workbase-inline-error { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
261
+ .workbase-error-actions { margin-block-start: 10px; }
262
+ .workbase-error-toggle, .workbase-error-disclosure, .workbase-inline-error > button {
263
+ display: inline-flex; justify-content: center; align-items: center; gap: 5px; min-height: 28px;
264
+ padding: 3px 7px; border: 0; border-radius: 6px; background: transparent; color: var(--color-muted); font: inherit; font-size: var(--workbase-type-meta); line-height: 1.4; cursor: pointer;
265
+ }
266
+ .workbase-error-toggle { flex: none; min-width: 28px; }
267
+ .workbase-error-close { min-width: 28px; }
268
+ .workbase-error-close::before {
269
+ content: ""; width: 16px; height: 16px; background: currentColor;
270
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='m6 6 12 12M6 18 18 6'/%3E%3C/svg%3E") center / contain no-repeat;
271
+ }
272
+ .workbase-inline-error > button:not(.workbase-error-close) { border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-foreground); }
273
+ .workbase-error-disclosure:only-child { margin-inline-start: -7px; }
274
+ .workbase-error-disclosure[aria-expanded="true"] svg { transform: rotate(180deg); }
275
+ :is(.workbase-error-toggle, .workbase-error-disclosure, .workbase-inline-error > button, .mantine-Alert-closeButton):hover { background: var(--color-surface-muted); color: var(--color-foreground); }
276
+ :is(.workbase-error-toggle, .workbase-error-disclosure, .workbase-inline-error > button, .mantine-Alert-closeButton):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
277
+ .workbase-error-details:not([hidden]) { display: grid; gap: 8px; }
278
+ .workbase-error-details { margin: 12px 0 0; padding-block-start: 12px; border-top: 1px solid var(--color-border); font-size: var(--workbase-type-body); line-height: 1.6; }
279
+ .workbase-error-details > div { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px; }
280
+ .workbase-error-details dt { color: var(--color-muted); font-weight: 500; }
281
+ .workbase-error-details dd { min-width: 0; margin: 0; }
282
+ .workbase-error-details pre { max-height: 15rem; margin: 0; padding: 8px 10px; overflow: auto; border-radius: 6px; background: var(--color-surface-muted); color: var(--color-foreground); font-size: var(--workbase-type-meta); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
283
+ .workbase-inline-error > span { flex: 1 1 12ch; min-width: 0; white-space: pre-wrap; }
284
+ .workbase-inline-error { font-size: var(--workbase-type-body); line-height: 1.55; }
285
+ .workbase-error-alert .mantine-Alert-wrapper { align-items: flex-start; gap: 10px; }
286
+ .workbase-error-alert .mantine-Alert-wrapper::before { margin-block-start: 2px; }
287
+ .workbase-error-alert .mantine-Alert-body { min-width: 0; }
288
+ .workbase-error-alert .mantine-Alert-message { color: var(--color-foreground); }
289
+ .workbase-error-alert .mantine-Alert-closeButton { min-width: 28px; min-height: 28px; margin: -3px -3px -3px 0; color: var(--color-muted); }
259
290
  .mantine-Notification-root { border: 1px solid var(--color-border); }
260
291
  .mantine-Notification-title { color: var(--color-brand-deep); font-weight: 600; }
261
292
  .mantine-Notification-description { color: var(--color-muted); }
@@ -44,6 +44,9 @@ export declare const workbaseUiTheme: {
44
44
  readonly autoCapitalize: "none";
45
45
  };
46
46
  };
47
+ readonly Alert: {
48
+ readonly classNames: typeof alertClassNames;
49
+ };
47
50
  readonly Badge: {
48
51
  readonly defaultProps: {
49
52
  readonly radius: "sm";
@@ -80,6 +83,11 @@ declare function brandClassNames(_theme: unknown, { color }: {
80
83
  }): {
81
84
  root: string | undefined;
82
85
  };
86
+ declare function alertClassNames(_theme: unknown, { color }: {
87
+ readonly color?: string;
88
+ }): {
89
+ root: string | undefined;
90
+ };
83
91
  declare function badgeClassNames(theme: unknown, props: {
84
92
  readonly color?: string;
85
93
  readonly variant?: string;
package/dist/ui/theme.js CHANGED
@@ -107,6 +107,7 @@ const workbaseUiTheme = {
107
107
  components: {
108
108
  Input: { defaultProps: { autoCapitalize: "none" } },
109
109
  Textarea: { defaultProps: { autoCapitalize: "none" } },
110
+ Alert: { classNames: alertClassNames },
110
111
  Badge: {
111
112
  defaultProps: { radius: "sm" },
112
113
  classNames: badgeClassNames
@@ -125,6 +126,9 @@ const workbaseUiTheme = {
125
126
  function brandClassNames(_theme, { color }) {
126
127
  return { root: !color || color === "workbase" ? "workbase-brand-control" : void 0 };
127
128
  }
129
+ function alertClassNames(_theme, { color }) {
130
+ return { root: color === "red" ? "workbase-error-alert" : void 0 };
131
+ }
128
132
  function badgeClassNames(theme, props) {
129
133
  const { color, variant } = props;
130
134
  if (variant === "light" && color && [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eworkbase/sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./markdown": {