dsh-plugin-core-demo 0.21.0 → 0.22.0

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.
Files changed (2) hide show
  1. package/dist/client.js +218 -91
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -3893,6 +3893,15 @@ function Loader(props) {
3893
3893
 
3894
3894
  // dist/ui/Button.js
3895
3895
  var import_react9 = require("react");
3896
+
3897
+ // dist/ui/thenable.js
3898
+ function isThenable(value) {
3899
+ if (value === null || value === void 0)
3900
+ return false;
3901
+ return typeof value.then === "function";
3902
+ }
3903
+
3904
+ // dist/ui/Button.js
3896
3905
  var SOLID_VARIANTS = [
3897
3906
  "primary",
3898
3907
  "secondary",
@@ -3931,9 +3940,32 @@ function colorVars(variant, color) {
3931
3940
  function buttonClass(variant, size4, block2, hasIcon, extra) {
3932
3941
  return `dshpc-btn dshpc-btn--${variant} dshpc-btn--${size4}${block2 ? " dshpc-btn--block" : ""}${hasIcon ? " dshpc-btn--icon-start" : ""}${extra !== void 0 && extra !== "" ? ` ${extra}` : ""}`;
3933
3942
  }
3943
+ function useAsyncClick(onClick, onBusyChange) {
3944
+ const [busy, setBusy] = (0, import_react9.useState)(false);
3945
+ const click = (event) => {
3946
+ if (onClick === void 0)
3947
+ return;
3948
+ const out = onClick(event);
3949
+ if (!isThenable(out))
3950
+ return;
3951
+ setBusy(true);
3952
+ onBusyChange?.(true);
3953
+ const done = () => {
3954
+ setBusy(false);
3955
+ onBusyChange?.(false);
3956
+ };
3957
+ void out.then(done, (err) => {
3958
+ done();
3959
+ console.error("[dsh-plugin-core] Button \u5F02\u6B65\u70B9\u51FB\u5931\u8D25\uFF0C\u5DF2\u6062\u590D\u53EF\u70B9\uFF1A", err);
3960
+ });
3961
+ };
3962
+ return { busy, click };
3963
+ }
3934
3964
  function Button(props) {
3935
3965
  ensureComponentStyles("button", BUTTON_CSS);
3936
- const { variant = "outline", size: size4 = "lg", icon: icon2, iconRight, color, loading = false, block: block2 = false, width, minWidth, maxWidth, className: className2, style: style2, children, ...rest } = props;
3966
+ const { variant = "outline", size: size4 = "lg", icon: icon2, iconRight, color, loading: loadingProp = false, block: block2 = false, width, minWidth, maxWidth, className: className2, style: style2, children, onClick, onBusyChange, ...rest } = props;
3967
+ const asyncClick = useAsyncClick(onClick, onBusyChange);
3968
+ const loading = loadingProp || asyncClick.busy;
3937
3969
  const widthStyle = {};
3938
3970
  if (width !== void 0) {
3939
3971
  widthStyle.width = width;
@@ -3948,14 +3980,24 @@ function Button(props) {
3948
3980
  ...rest,
3949
3981
  type: rest.type ?? "button",
3950
3982
  disabled: rest.disabled === true || loading,
3983
+ onClick: asyncClick.click,
3951
3984
  className: buttonClass(variant, size4, block2, icon2 !== void 0 && icon2 !== null && !loading, className2),
3952
3985
  style: { ...colorVars(variant, color), ...widthStyle, ...style2 }
3953
3986
  };
3954
- return (0, import_react9.createElement)("button", attrs2, loading ? (0, import_react9.createElement)(Loader, { size: "xs" }) : icon2 !== void 0 && icon2 !== null ? (0, import_react9.createElement)("span", { className: "dshpc-btn__icon" }, icon2) : null, marqueeLabel ? (0, import_react9.createElement)(MarqueeText, { text: children, className: "dshpc-btn__label" }) : children, iconRight !== void 0 && iconRight !== null ? (0, import_react9.createElement)("span", { className: "dshpc-btn__icon-end" }, iconRight) : null);
3987
+ return (0, import_react9.createElement)(
3988
+ "button",
3989
+ attrs2,
3990
+ loading ? (0, import_react9.createElement)(Loader, { size: "xs" }) : icon2 !== void 0 && icon2 !== null ? (0, import_react9.createElement)("span", { className: "dshpc-btn__icon" }, icon2) : null,
3991
+ marqueeLabel ? (0, import_react9.createElement)(MarqueeText, { text: children, className: "dshpc-btn__label" }) : children,
3992
+ // 转圈期间所有图标位都让位:前置位被 Loader 顶替,后置位(展开 / 外链)留在禁用态里只会挤版面
3993
+ iconRight !== void 0 && iconRight !== null && !loading ? (0, import_react9.createElement)("span", { className: "dshpc-btn__icon-end" }, iconRight) : null
3994
+ );
3955
3995
  }
3956
3996
  function IconButton(props) {
3957
3997
  ensureComponentStyles("button", BUTTON_CSS);
3958
- const { variant = "plain", size: size4 = "lg", icon: icon2, label, color, background: background2, className: className2, style: style2, ...rest } = props;
3998
+ const { variant = "plain", size: size4 = "lg", icon: icon2, label, color, background: background2, loading: loadingProp = false, className: className2, style: style2, onClick, onBusyChange, ...rest } = props;
3999
+ const asyncClick = useAsyncClick(onClick, onBusyChange);
4000
+ const loading = loadingProp || asyncClick.busy;
3959
4001
  const accent = {};
3960
4002
  if (color !== void 0 && color !== "") {
3961
4003
  accent["--icb-fg"] = color;
@@ -3971,10 +4013,14 @@ function IconButton(props) {
3971
4013
  type: rest.type ?? "button",
3972
4014
  title: rest.title ?? label,
3973
4015
  "aria-label": rest["aria-label"] ?? label,
4016
+ // 无障碍名不变(仍是 label),只声明「正在忙」,读屏不会把圈读成内容
4017
+ "aria-busy": loading || void 0,
4018
+ disabled: rest.disabled === true || loading,
4019
+ onClick: asyncClick.click,
3974
4020
  className: `dshpc-iconbtn dshpc-iconbtn--${variant} dshpc-iconbtn--${size4}${className2 !== void 0 && className2 !== "" ? ` ${className2}` : ""}`,
3975
4021
  style: { ...accent, ...style2 }
3976
4022
  };
3977
- return (0, import_react9.createElement)("button", attrs2, icon2);
4023
+ return (0, import_react9.createElement)("button", attrs2, loading ? (0, import_react9.createElement)(Loader, { size: "xs" }) : icon2);
3978
4024
  }
3979
4025
 
3980
4026
  // dist/utils/date.js
@@ -4909,19 +4955,20 @@ function OverlayHead(props) {
4909
4955
  function Modal(props) {
4910
4956
  ensureComponentStyles("feedback", FEEDBACK_CSS);
4911
4957
  const tt = props.translate ?? t;
4912
- const closeOnMask = props.closeOnMask !== false;
4913
- useEscapeClose(props.escClose !== false, props.onClose);
4958
+ const busy = props.busy === true;
4959
+ const closeOnMask = !busy && props.closeOnMask !== false;
4960
+ useEscapeClose(!busy && props.escClose !== false, busy ? void 0 : props.onClose);
4914
4961
  const sizeStyle = {
4915
4962
  sm: { width: "360px", maxWidth: "calc(100% - 48px)" },
4916
4963
  md: { width: "min(720px, calc(100% - 32px))", maxHeight: "86vh" },
4917
4964
  lg: { width: "min(1120px, calc(100% - 32px))", height: "calc(100% - 80px)" }
4918
4965
  };
4919
4966
  const s = sizeStyle[props.size ?? "md"];
4920
- const showClose = props.closable !== false && props.onClose !== void 0;
4967
+ const showClose = props.closable !== false && props.onClose !== void 0 && !busy;
4921
4968
  const showHeader = props.hideHeader !== true && (props.icon !== void 0 || props.title !== void 0 || props.subtitle !== void 0 || props.headerExtra !== void 0 || props.headerActions !== void 0 || showClose);
4922
4969
  return (0, import_react17.createElement)(
4923
4970
  OverlayMask,
4924
- { kind: "center", closeOnMask, onClose: props.onClose },
4971
+ { kind: "center", closeOnMask, onClose: busy ? void 0 : props.onClose },
4925
4972
  // 表面(底色/描边/圆角/阴影)来自 panel.css 的 modal 档;`.dshpc-modal` 只剩家族布局,
4926
4973
  // 且继续作为既有类名别名存在(消费方写在它上面的覆盖不受影响)。
4927
4974
  (0, import_react17.createElement)(
@@ -5014,8 +5061,9 @@ function SideSheet(props) {
5014
5061
  ensureComponentStyles("side-sheet", SIDE_SHEET_CSS);
5015
5062
  const tt = props.translate ?? t;
5016
5063
  const side = props.side ?? "left";
5017
- const closeOnMask = props.closeOnMask !== false;
5018
- useEscapeClose(props.escClose !== false, props.onClose);
5064
+ const busy = props.busy === true;
5065
+ const closeOnMask = !busy && props.closeOnMask !== false;
5066
+ useEscapeClose(!busy && props.escClose !== false, busy ? void 0 : props.onClose);
5019
5067
  const [width, setWidth] = (0, import_react18.useState)(props.width ?? 460);
5020
5068
  const panelRef = (0, import_react18.useRef)(null);
5021
5069
  const leaving = props.open === false;
@@ -5026,7 +5074,7 @@ function SideSheet(props) {
5026
5074
  }, [leaving]);
5027
5075
  if (unmounted)
5028
5076
  return null;
5029
- const showClose = props.closable !== false && props.onClose !== void 0;
5077
+ const showClose = props.closable !== false && props.onClose !== void 0 && !busy;
5030
5078
  const hasHeader = props.header !== null;
5031
5079
  const beginResize = (event) => {
5032
5080
  const element = panelRef.current;
@@ -5069,7 +5117,7 @@ function SideSheet(props) {
5069
5117
  }
5070
5118
  return (0, import_react18.createElement)("div", { className: "dshpc-dock__head" }, props.icon === void 0 ? null : (0, import_react18.createElement)("div", { className: "dshpc-dock__lead" }, props.icon), (0, import_react18.createElement)("div", { className: "dshpc-dock__title" }, props.title), props.extra === void 0 ? null : (0, import_react18.createElement)("div", { className: "dshpc-dock__extra" }, props.extra));
5071
5119
  };
5072
- return (0, import_react18.createElement)(OverlayMask, { kind: "side", closeOnMask, onClose: props.onClose }, (0, import_react18.createElement)("section", {
5120
+ return (0, import_react18.createElement)(OverlayMask, { kind: "side", closeOnMask, onClose: busy ? void 0 : props.onClose }, (0, import_react18.createElement)("section", {
5073
5121
  ref: (element) => {
5074
5122
  panelRef.current = element;
5075
5123
  },
@@ -5106,16 +5154,18 @@ function AlertModal(props) {
5106
5154
  ensureComponentStyles("feedback", FEEDBACK_CSS);
5107
5155
  const tt = props.translate ?? t;
5108
5156
  const severity = props.severity ?? "info";
5157
+ const [running, setRunning] = (0, import_react19.useState)(false);
5158
+ const busy = running || props.confirmLoading === true;
5109
5159
  return (0, import_react19.createElement)(Modal, {
5110
5160
  icon: (0, import_react19.createElement)("span", { className: `dshpc-alert-sev dshpc-alert-sev--${severity}` }, SEVERITY_GLYPH[severity]),
5111
5161
  title: props.title,
5112
5162
  size: props.size ?? "sm",
5113
5163
  hideHeader: props.title === void 0,
5114
5164
  closable: false,
5115
- closeOnMask: props.confirmLoading === true ? false : props.closeOnMask,
5116
- // 加载中锁死关闭路径(遮罩 / Esc 都走 onClose)。
5117
- onClose: props.confirmLoading === true ? void 0 : props.onConfirm,
5118
- footer: (0, import_react19.createElement)(Button, { variant: "primary", loading: props.confirmLoading === true, onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("dialogOk"))
5165
+ closeOnMask: props.closeOnMask,
5166
+ busy,
5167
+ onClose: props.onConfirm,
5168
+ footer: (0, import_react19.createElement)(Button, { variant: "primary", loading: props.confirmLoading === true, onBusyChange: setRunning, onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("dialogOk"))
5119
5169
  }, props.message ?? null);
5120
5170
  }
5121
5171
 
@@ -5125,15 +5175,18 @@ function ConfirmModal(props) {
5125
5175
  const tt = props.translate ?? t;
5126
5176
  const tone = props.tone ?? "primary";
5127
5177
  const confirmVariant = tone === "danger" ? "danger" : tone === "warning" ? "warning" : "primary";
5128
- const busy = props.confirmLoading === true || props.cancelLoading === true;
5178
+ const [confirmBusy, setConfirmBusy] = (0, import_react20.useState)(false);
5179
+ const [cancelBusy, setCancelBusy] = (0, import_react20.useState)(false);
5180
+ const busy = confirmBusy || cancelBusy || props.confirmLoading === true || props.cancelLoading === true;
5129
5181
  return (0, import_react20.createElement)(Modal, {
5130
5182
  title: props.title,
5131
5183
  size: props.size ?? "sm",
5132
5184
  hideHeader: props.title === void 0,
5133
5185
  closable: false,
5134
- closeOnMask: busy ? false : props.closeOnMask,
5135
- onClose: busy ? void 0 : props.onCancel,
5136
- footer: (0, import_react20.createElement)("div", { style: { display: "flex", gap: "8px", justifyContent: "flex-end" } }, (0, import_react20.createElement)(Button, { variant: "outline", loading: props.cancelLoading === true, onClick: () => props.onCancel?.() }, props.cancelText ?? tt("cancel")), (0, import_react20.createElement)(Button, { variant: confirmVariant, loading: props.confirmLoading === true, onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("confirm")))
5186
+ closeOnMask: props.closeOnMask,
5187
+ busy,
5188
+ onClose: props.onCancel,
5189
+ footer: (0, import_react20.createElement)("div", { style: { display: "flex", gap: "8px", justifyContent: "flex-end" } }, (0, import_react20.createElement)(Button, { variant: "outline", loading: props.cancelLoading === true, onBusyChange: setCancelBusy, onClick: () => props.onCancel?.() }, props.cancelText ?? tt("cancel")), (0, import_react20.createElement)(Button, { variant: confirmVariant, loading: props.confirmLoading === true, onBusyChange: setConfirmBusy, onClick: () => props.onConfirm?.() }, props.confirmText ?? tt("confirm")))
5137
5190
  }, props.message ?? null);
5138
5191
  }
5139
5192
 
@@ -5177,11 +5230,6 @@ var hostHandlers = null;
5177
5230
  function registerHostDialog(handlers2) {
5178
5231
  hostHandlers = handlers2;
5179
5232
  }
5180
- function isThenable(value) {
5181
- if (value === null || value === void 0)
5182
- return false;
5183
- return typeof value.then === "function";
5184
- }
5185
5233
  function confirmModal(opts) {
5186
5234
  if (opts.skin === "host") {
5187
5235
  if (hostHandlers !== null) {
@@ -5199,47 +5247,31 @@ function confirmModal(opts) {
5199
5247
  void _skin;
5200
5248
  return new Promise((resolve) => {
5201
5249
  const id3 = ++idSeq;
5202
- const entry = { id: id3, node: null };
5203
- let busy = null;
5204
5250
  let closed = false;
5205
- const draw = () => {
5206
- entry.node = (0, import_react21.createElement)(ConfirmModal, {
5207
- ...core,
5208
- confirmLoading: busy === "confirm",
5209
- cancelLoading: busy === "cancel",
5210
- onConfirm: () => void run("confirm"),
5211
- onCancel: () => void run("cancel")
5212
- });
5213
- flush();
5214
- };
5215
5251
  const close = (result) => {
5252
+ if (closed)
5253
+ return;
5216
5254
  closed = true;
5217
5255
  dismiss(id3);
5218
5256
  resolve(result);
5219
5257
  };
5220
- const run = async (which) => {
5221
- if (closed || busy !== null)
5222
- return;
5258
+ const run = (which) => {
5259
+ if (closed)
5260
+ return void 0;
5223
5261
  const out = (which === "confirm" ? onConfirm : onCancel)?.();
5224
5262
  if (!isThenable(out)) {
5225
5263
  close(which === "confirm");
5226
- return;
5227
- }
5228
- busy = which;
5229
- draw();
5230
- try {
5231
- await out;
5232
- } catch (err) {
5233
- busy = null;
5234
- draw();
5235
- console.error("[dsh-plugin-core] confirmModal \u56DE\u8C03\u5931\u8D25\uFF0C\u5F39\u7A97\u5DF2\u6062\u590D\u53EF\u64CD\u4F5C\uFF1A", err);
5236
- return;
5264
+ return void 0;
5237
5265
  }
5238
- busy = null;
5239
- close(which === "confirm");
5266
+ void out.then(() => close(which === "confirm"), () => {
5267
+ });
5268
+ return out;
5240
5269
  };
5241
- entries.push(entry);
5242
- draw();
5270
+ entries.push({
5271
+ id: id3,
5272
+ node: (0, import_react21.createElement)(ConfirmModal, { ...core, onConfirm: () => run("confirm"), onCancel: () => run("cancel") })
5273
+ });
5274
+ flush();
5243
5275
  });
5244
5276
  }
5245
5277
  function alertModal(opts) {
@@ -5257,39 +5289,28 @@ function alertModal(opts) {
5257
5289
  void _skin;
5258
5290
  return new Promise((resolve) => {
5259
5291
  const id3 = ++idSeq;
5260
- const entry = { id: id3, node: null };
5261
- let busy = false;
5262
- const draw = () => {
5263
- entry.node = (0, import_react21.createElement)(AlertModal, { ...core, confirmLoading: busy, onConfirm: () => void run() });
5264
- flush();
5265
- };
5292
+ let closed = false;
5266
5293
  const close = () => {
5294
+ if (closed)
5295
+ return;
5296
+ closed = true;
5267
5297
  dismiss(id3);
5268
5298
  resolve();
5269
5299
  };
5270
- const run = async () => {
5271
- if (busy)
5272
- return;
5300
+ const run = () => {
5301
+ if (closed)
5302
+ return void 0;
5273
5303
  const out = onConfirm?.();
5274
5304
  if (!isThenable(out)) {
5275
5305
  close();
5276
- return;
5277
- }
5278
- busy = true;
5279
- draw();
5280
- try {
5281
- await out;
5282
- } catch (err) {
5283
- busy = false;
5284
- draw();
5285
- console.error("[dsh-plugin-core] alertModal \u56DE\u8C03\u5931\u8D25\uFF0C\u5F39\u7A97\u5DF2\u6062\u590D\u53EF\u64CD\u4F5C\uFF1A", err);
5286
- return;
5306
+ return void 0;
5287
5307
  }
5288
- busy = false;
5289
- close();
5308
+ void out.then(close, () => {
5309
+ });
5310
+ return out;
5290
5311
  };
5291
- entries.push(entry);
5292
- draw();
5312
+ entries.push({ id: id3, node: (0, import_react21.createElement)(AlertModal, { ...core, onConfirm: () => run() }) });
5313
+ flush();
5293
5314
  });
5294
5315
  }
5295
5316
 
@@ -60102,6 +60123,10 @@ var docData = {
60102
60123
  "zh": "IconButton\uFF1Avariant: plain|outline|danger\uFF08\u9ED8\u8BA4 plain\uFF0C**\u65E0\u5E95\u8272**\uFF09\u3001size\uFF08\u9ED8\u8BA4 lg\uFF09\u3001icon\uFF08\u5FC5\u586B\uFF09\u3001label\uFF08\u5FC5\u586B\uFF0C\u65E0\u969C\u788D\u540D\u517C title\uFF09\u3001color\uFF08\u56FE\u6807\u8272\uFF09\u3001background\uFF08\u5E95\u8272\uFF0C\u4E0D\u4F20\u5373\u65E0\u5E95\u8272\uFF09\u3002",
60103
60124
  "en": "IconButton: variant plain|outline|danger (default plain, **no background**), size (default lg), icon (required), label (required, doubles as a11y name and title), color (icon colour), background (fill; omitted = no fill)."
60104
60125
  },
60126
+ {
60127
+ "zh": "\u4E24\u8005\u7684 loading \u8BED\u4E49\u4E00\u81F4\uFF1A`onClick` \u8FD4\u56DE Promise \u5C31\u8F6C\u5708\uFF08\u7EAF\u56FE\u6807\u94AE\u628A\u56FE\u6807\u4F4D\u6362\u6210\u5C0F\u5708\uFF0C`aria-label` \u4E0D\u53D8\u3001\u8865 `aria-busy`\uFF09\uFF0C`onBusyChange` \u628A\u300C\u5728\u8DD1\u300D\u62A5\u51FA\u53BB\uFF1B\u53D7\u63A7 `loading` \u4E0E\u5B83\u53D6\u6216 \u2014\u2014 \u522B\u5904\u5237\u65B0\u4E5F\u80FD\u70B9\u4EAE\u540C\u4E00\u9897\u6309\u94AE\u3002\u8F6C\u5708\u671F\u95F4\u6309\u94AE\u81EA\u5DF1\u7684\u56FE\u6807\u4F4D\uFF08`icon` / `iconRight`\uFF09\u5168\u90E8\u8BA9\u4F4D\uFF0C\u53EA\u7559\u8F6C\u5708 + \u6587\u5B57\u3002",
60128
+ "en": 'Both share one loading semantics: a Promise-returning `onClick` spins (an icon button swaps its icon for the spinner, keeps `aria-label` and adds `aria-busy`), `onBusyChange` reports "running", and the controlled `loading` prop is OR-ed in \u2014 an external refresh lights the same button too. While spinning, the button\u2019s own icon slots (`icon` / `iconRight`) all step aside: spinner plus label only.'
60129
+ },
60105
60130
  {
60106
60131
  "zh": "Segmented\uFF1A`items`\uFF08\u5FC5\u586B\uFF09\u652F\u6301\u5355\u9009 / \u591A\u9009\uFF0C`size`\uFF08\u9ED8\u8BA4 lg\uFF1B\u4E09\u6863\u603B\u9AD8 24 / 28 / 32\uFF09\u3001`bordered`\uFF081px \u5916\u6846\uFF0C\u603B\u9AD8\u4E0D\u53D8\uFF09\u3001`multiple`\uFF08\u591A\u9009\uFF09\u3002\u5916\u89C2\u53EA\u6709\u4E00\u5957\uFF1A\u7070\u5E95\u8F68\u9053 + \u767D\u8272\u9009\u4E2D\u7247\uFF0C\u9009\u4E2D\u7247\u7684\u63CF\u8FB9\u73AF\u4E0E\u9634\u5F71\u7531\u5BBF\u4E3B elevation token \u63D0\u4F9B\uFF08\u79BB\u7EBF\u515C\u5E95\u503C\u6CA1\u6709\u90A3\u5708\u73AF\uFF09\u3002\u9009\u4E2D\u7247\u914D\u8272\u53EA\u7ECF `tone`\uFF1A\u4F20\u5185\u7F6E\u8272\u540D\uFF08\u4E0E Chip \u540C\u540D\u7684 business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate\uFF09\u65F6\u5E95\u4E0E\u5B57\u7531\u6838\u5FC3\u5B9A\u3001\u6DF1\u6D45\u4E24\u4E3B\u9898\u5404\u81EA\u6210\u7ACB\uFF1B\u4F20 `{ bg, fg }` \u65F6\u4E24\u4E2A\u4E3B\u9898\u90FD\u7528\u8C03\u7528\u65B9\u8FD9\u4E00\u5BF9\u989C\u8272\uFF08\u5BF9\u6BD4\u5EA6\u7531\u8C03\u7528\u65B9\u8D1F\u8D23\uFF09\u3002\u6BB5\u5185 `icon` \u662F\u524D\u7F6E\u56FE\u6807\u69FD\uFF08\u5B98\u65B9\u56FE\u6807\u7EC4\u4EF6 / \u6570\u7EC4 / \u81EA\u7ED8\u8282\u70B9\u5747\u53EF\uFF09\uFF0C`label` \u4E5F\u53EF\u4F20\u8282\u70B9\uFF1B\u987A\u5E8F\u56FA\u5B9A\u4E3A icon \u2192 label \u2192 count\u3002\u53EA\u6709\u56FE\u6807\uFF08\u65E0\u6587\u5B57 / \u8BA1\u6570 / \u89D2\u6807\uFF09\u65F6\u8BE5\u6BB5\u81EA\u52A8\u53D8\u6B63\u65B9\u5F62\uFF08\u5BBD = \u6BB5\u9AD8\uFF09\uFF0C\u8BFB\u5C4F\u540D\u7528 `ariaLabel`\uFF0C\u7F3A\u7701\u9000\u56DE `tooltip`\u3002\u6BB5\u5185 `count`\uFF08\u5F31\u5316\u7070\u5B57\uFF0C\u9009\u4E2D\u6BB5\u5185\u81EA\u52A8\u8DDF\u7740\u9009\u4E2D\u7247\u5B57\u8272\u63D0\u4EAE\uFF09/ `badge`\uFF08\u7EA2\u89D2\u6807\uFF09\u63A5\u53D7 `number | string`\uFF1A\u6570\u5B57 \u22640 \u4E0D\u663E\u793A\uFF0C\u5B57\u7B26\u4E32\u539F\u6837\u663E\u793A\uFF08\u5982 `1K` / `99+`\uFF09\u3002",
60107
60132
  "en": "Segmented: `items` (required) supports single or multiple selection; `size` (default lg; totals 24 / 28 / 32), `bordered` (1px outer frame, same total height), `multiple` (multi-select). One look only: grey track + white selected pill; its stroke ring and shadow come from the host elevation token (the offline fallback has no ring). The selected pill\u2019s colors go through `tone` only: a built-in color name (business / success / warning / danger / purple / pink / cyan / teal / orange / indigo / rose / slate, same names as Chip) lets the core pick background and text per theme; `{ bg, fg }` uses that pair verbatim in both themes (contrast is the caller\u2019s call). An item\u2019s leading `icon` takes any node (official icon component, array, or custom); `label` also accepts a node; order is always icon \u2192 label \u2192 count. With only an icon (no label / count / badge) the segment squares itself (width = segment height), and the accessible name comes from `ariaLabel`, falling back to `tooltip`. An item\u2019s `count` (muted text; auto-lightened to follow the selected pill\u2019s text color while selected) and `badge` (red pill) take `number | string`: numbers \u22640 render nothing, strings render as given (e.g. `'1K'` / `'99+'`)."
@@ -60161,8 +60186,26 @@ var docData = {
60161
60186
  "type": "boolean",
60162
60187
  "def": "'false'",
60163
60188
  "desc": {
60164
- "zh": "\u6587\u6848\u524D\u663E\u793A\u540C\u8272\u5C0F\u5708\uFF0C\u5E76\u81EA\u52A8 disabled",
60165
- "en": "Shows a same-color spinner before the label and auto-disables"
60189
+ "zh": "\u53D7\u63A7 loading\uFF1A\u6587\u6848\u524D\u663E\u793A\u540C\u8272\u5C0F\u5708\u5E76\u81EA\u52A8 disabled\uFF08\u522B\u5904\u5237\u65B0\u4E5F\u80FD\u70B9\u4EAE\u5B83\uFF09\uFF1B\u4E0E\u300C\u70B9\u51FB\u81EA\u52A8 loading\u300D\u53D6\u6216",
60190
+ "en": "Controlled loading: same-color spinner before the label plus auto-disable (an external refresh can light it up too); OR-ed with automatic click loading"
60191
+ }
60192
+ },
60193
+ {
60194
+ "name": "onClick",
60195
+ "type": "(...) => unknown",
60196
+ "def": "\u2014",
60197
+ "desc": {
60198
+ "zh": "**\u8FD4\u56DE Promise \u5373\u81EA\u52A8 loading**\uFF1A\u8F6C\u5708 + \u7981\u7528 + \u9632\u8FDE\u70B9\uFF0Csettle \u540E\u81EA\u5DF1\u6062\u590D\uFF1Breject \u4E5F\u6062\u590D\u5E76\u628A\u9519\u8BEF\u6253\u5230\u63A7\u5236\u53F0\u3002\u540C\u6B65\u8FD4\u56DE\u503C = \u8001\u884C\u4E3A",
60199
+ "en": "**Returning a Promise enables loading automatically**: spinner, disabled, no double-clicks, restored on settle; a rejection also restores and logs the error. Sync return values behave as before"
60200
+ }
60201
+ },
60202
+ {
60203
+ "name": "onBusyChange",
60204
+ "type": "(busy: boolean) => void",
60205
+ "def": "\u2014",
60206
+ "desc": {
60207
+ "zh": "\u628A\u300C\u8FD9\u4E2A\u6309\u94AE\u6B63\u5728\u8DD1\u300D\u62A5\u51FA\u53BB\uFF08\u914D\u5408 `Modal` / `SideSheet` \u7684 `busy` \u9501\u6B7B\u5173\u95ED\uFF09\uFF0C\u4E0D\u6539\u53D8\u6309\u94AE\u81EA\u8EAB\u884C\u4E3A",
60208
+ "en": 'Reports "this button is running" outward (pair with `busy` on `Modal` / `SideSheet` to lock closing); does not change the button itself'
60166
60209
  }
60167
60210
  },
60168
60211
  {
@@ -60215,8 +60258,8 @@ var docData = {
60215
60258
  "type": "\u539F\u751F button \u5C5E\u6027",
60216
60259
  "def": "\u2014",
60217
60260
  "desc": {
60218
- "zh": "type / disabled / title / aria-* / onClick \u539F\u6837\u900F\u4F20",
60219
- "en": "type / disabled / title / aria-* / onClick passed through"
60261
+ "zh": "type / disabled / title / aria-* \u7B49\u539F\u6837\u900F\u4F20\uFF08onClick \u89C1\u4E0A\u9762\u90A3\u884C\uFF09",
60262
+ "en": "type / disabled / title / aria-* and friends pass through (onClick is documented above)"
60220
60263
  }
60221
60264
  }
60222
60265
  ]
@@ -61788,6 +61831,15 @@ var docData = {
61788
61831
  "en": "Close on Esc"
61789
61832
  }
61790
61833
  },
61834
+ {
61835
+ "name": "busy",
61836
+ "type": "boolean",
61837
+ "def": "false",
61838
+ "desc": {
61839
+ "zh": "\u6709\u5F02\u6B65\u5728\u8DD1\uFF08footer \u91CC\u7684 `Button` \u6B63\u5728 loading\uFF09\uFF1A\u906E\u7F69 / Esc / \u2715 \u4E09\u6761\u5173\u95ED\u8DEF\u5F84\u4E00\u8D77\u5931\u6548\uFF0C\u5185\u5BB9\u7167\u5E38\u3002\u5426\u51B3\u9879\uFF0C\u4E0D\u66FF\u4EE3 closeOnMask / escClose",
61840
+ "en": "Async work in flight (a footer `Button` is loading): mask / Esc / \u2715 all stop closing while content keeps rendering. A veto, not a replacement for closeOnMask / escClose"
61841
+ }
61842
+ },
61791
61843
  {
61792
61844
  "name": "maxWidth",
61793
61845
  "type": "string",
@@ -61928,6 +61980,15 @@ var docData = {
61928
61980
  "en": "Close on mask click / on Esc"
61929
61981
  }
61930
61982
  },
61983
+ {
61984
+ "name": "busy",
61985
+ "type": "boolean",
61986
+ "def": "false",
61987
+ "desc": {
61988
+ "zh": "\u6709\u5F02\u6B65\u5728\u8DD1\uFF08footer \u91CC\u7684 `Button` \u6B63\u5728 loading\uFF09\uFF1A\u906E\u7F69 / Esc / \u2715 \u4E09\u6761\u5173\u95ED\u8DEF\u5F84\u4E00\u8D77\u5931\u6548\uFF0C\u5185\u5BB9\u7167\u5E38\u3002\u5426\u51B3\u9879\uFF0C\u4E0D\u66FF\u4EE3 closeOnMask / escClose",
61989
+ "en": "Async work in flight (a footer `Button` is loading): mask / Esc / \u2715 all stop closing while content keeps rendering. A veto, not a replacement for closeOnMask / escClose"
61990
+ }
61991
+ },
61931
61992
  {
61932
61993
  "name": "width / minWidth / maxWidth",
61933
61994
  "type": "number / number / number",
@@ -62816,7 +62877,16 @@ var CODE_BTN_STATE = `<Button variant="primary">\u9ED8\u8BA4</Button>
62816
62877
  <Button variant="primary" disabled>\u7981\u7528</Button>
62817
62878
  <Button variant="danger" disabled icon={<IconCloseOutlineRegular size={16} />}>\u7981\u7528</Button>
62818
62879
  <Button variant="outline" loading>\u52A0\u8F7D\u4E2D</Button>
62819
- <Button variant="primary" loading icon={<IconRefreshOutlineRegular size={16} />}>\u63D0\u4EA4\u4E2D</Button>`;
62880
+ <Button variant="primary" loading icon={<IconRefreshOutlineRegular size={16} />}>\u63D0\u4EA4\u4E2D</Button>
62881
+
62882
+ // \u5F02\u6B65\uFF1AonClick \u8FD4\u56DE Promise \u21D2 \u81EA\u5DF1\u8F6C\u5708 + \u7981\u7528\uFF0Csettle \u540E\u6062\u590D\uFF08reject \u4E5F\u6062\u590D\uFF09
62883
+ <Button variant="primary" onClick={async () => { await save() }}>\u4FDD\u5B58</Button>
62884
+
62885
+ // \u5916\u90E8\u4E5F\u80FD\u70B9\u4EAE\u540C\u4E00\u4E2A\u6309\u94AE\uFF08\u6BD4\u5982\u522B\u5904\u6B63\u5728\u5237\u65B0\uFF09
62886
+ <Button variant="outline" loading={refreshing}>\u4FDD\u5B58</Button>
62887
+
62888
+ // \u628A\u300C\u5728\u8DD1\u300D\u62A5\u51FA\u53BB\uFF0C\u9501\u6B7B\u6240\u5728\u5F39\u7A97\uFF08\u5F39\u7A97\u4F20 busy\uFF09
62889
+ <Button onBusyChange={setBusy} onClick={async () => { await save() }}>\u4FDD\u5B58</Button>`;
62820
62890
  var CODE_BTN_COLOR = `<Button variant="primary" color="#7c3aed">#7c3aed</Button>
62821
62891
  <Button variant="outline" color="#0ea5e9">#0ea5e9</Button>`;
62822
62892
  var CODE_BTN_WIDTH = `// \u56FA\u5B9A\u5BBD\uFF1A\u5199\u6B7B\u5BBD\u5EA6
@@ -62832,6 +62902,7 @@ var CODE_BTN_WIDTH = `// \u56FA\u5B9A\u5BBD\uFF1A\u5199\u6B7B\u5BBD\u5EA6
62832
62902
  // \u4E09\u8005\u540C\u8BBE \u21D2 \u56FA\u5B9A\u5BBD\u4F18\u5148\uFF0C\u6700\u5C0F\u5BBD / \u6700\u5927\u5BBD\u81EA\u52A8\u5931\u6548
62833
62903
  <Button variant="outline" width={120} minWidth={200} maxWidth={160}>\u56FA\u5B9A\u5BBD\u4F18\u5148</Button>`;
62834
62904
  function ButtonPage() {
62905
+ const [extLoading, setExtLoading] = (0, import_react80.useState)(false);
62835
62906
  return (0, import_react80.createElement)(
62836
62907
  "div",
62837
62908
  null,
@@ -62942,6 +63013,15 @@ function ButtonPage() {
62942
63013
  (0, import_react80.createElement)(IconButton, { icon: (0, import_react80.createElement)(BUTTON_ICONS[0].Icon, { size: 16 }), label: "\u9ED8\u8BA4\u65E0\u5E95\u8272" }),
62943
63014
  (0, import_react80.createElement)(IconButton, { icon: (0, import_react80.createElement)(BUTTON_ICONS[1].Icon, { size: 16 }), label: "\u81EA\u5B9A\u4E49\u56FE\u6807\u8272", color: "#7c3aed" }),
62944
63015
  (0, import_react80.createElement)(IconButton, { icon: (0, import_react80.createElement)(BUTTON_ICONS[2].Icon, { size: 16 }), label: "\u81EA\u5B9A\u4E49\u5E95\u8272", color: "#fff", background: "#7c3aed" })
63016
+ ),
63017
+ // 纯图标钮也吃同一套 loading:图标位换成小圈,文字本来就没有
63018
+ (0, import_react80.createElement)(
63019
+ Labeled,
63020
+ { label: "IconButton \xB7 loading" },
63021
+ (0, import_react80.createElement)(IconButton, { icon: (0, import_react80.createElement)(BUTTON_ICONS[0].Icon, { size: 16 }), label: "\u5237\u65B0", onClick: async () => {
63022
+ await demoWait();
63023
+ } }),
63024
+ (0, import_react80.createElement)(IconButton, { variant: "outline", icon: (0, import_react80.createElement)(BUTTON_ICONS[0].Icon, { size: 16 }), label: "\u52A0\u8F7D\u4E2D", loading: true })
62945
63025
  )
62946
63026
  )
62947
63027
  ),
@@ -62964,6 +63044,16 @@ function ButtonPage() {
62964
63044
  { label: "loading" },
62965
63045
  (0, import_react80.createElement)(Button, { variant: "outline", loading: true }, "\u52A0\u8F7D\u4E2D"),
62966
63046
  (0, import_react80.createElement)(Button, { variant: "primary", loading: true, icon: iconOf("refresh", ICON_SIZE.lg) }, "\u63D0\u4EA4\u4E2D")
63047
+ ),
63048
+ // 异步:onClick 返回 Promise 就自己转圈;外部 loading 与它取或(别处刷新也能点亮同一颗按钮)
63049
+ (0, import_react80.createElement)(
63050
+ Labeled,
63051
+ { label: "\u5F02\u6B65 / \u5916\u90E8 loading" },
63052
+ (0, import_react80.createElement)(Button, { variant: "primary", onClick: async () => {
63053
+ await demoWait();
63054
+ } }, "\u70B9\u4E86\u81EA\u5DF1\u8F6C\u5708\uFF081.4s\uFF09"),
63055
+ (0, import_react80.createElement)(Button, { variant: "outline", loading: extLoading, onClick: () => setExtLoading((v) => !v) }, extLoading ? "\u5916\u90E8\u5237\u65B0\u4E2D\u2026" : "\u70B9\u6211\u70B9\u4EAE\u53F3\u8FB9"),
63056
+ (0, import_react80.createElement)(Button, { variant: "outline", loading: extLoading }, "\u88AB\u522B\u5904\u5237\u65B0\u5E26\u6210 loading")
62967
63057
  )
62968
63058
  )
62969
63059
  ),
@@ -64372,8 +64462,11 @@ function FeedbackPage() {
64372
64462
  const [confirmResult, setConfirmResult] = (0, import_react80.useState)("");
64373
64463
  const [largeOpen, setLargeOpen] = (0, import_react80.useState)(false);
64374
64464
  const [largeOpenB, setLargeOpenB] = (0, import_react80.useState)(false);
64465
+ const [asyncOpen, setAsyncOpen] = (0, import_react80.useState)(false);
64466
+ const [saving, setSaving] = (0, import_react80.useState)(false);
64375
64467
  const [sheetCfg, setSheetCfg] = (0, import_react80.useState)({ side: "left", footer: false });
64376
64468
  const [sheetOpen, setSheetOpen] = (0, import_react80.useState)(false);
64469
+ const [sheetSaving, setSheetSaving] = (0, import_react80.useState)(false);
64377
64470
  const [nativeText, setNativeText] = (0, import_react80.useState)("");
64378
64471
  const flash = (opts) => {
64379
64472
  const handle = showLoading(opts);
@@ -64603,6 +64696,35 @@ function FeedbackPage() {
64603
64696
  (0, import_react80.createElement)(Surface, { border: "faint", padding: "md", style: { marginTop: "12px", fontSize: "13px" } }, "\u4EFB\u610F\u5185\u5BB9\uFF0C\u4F8B\u5982\u4E00\u6BB5\u8BF4\u660E\u6216\u4E00\u4E2A\u4E1A\u52A1\u5361\u7247\u3002")
64604
64697
  )
64605
64698
  ) : null
64699
+ ),
64700
+ // 异步按钮 + busy:按钮自己转圈,把「在跑」报给 Modal,三条关闭路径一起封死
64701
+ (0, import_react80.createElement)(
64702
+ "div",
64703
+ null,
64704
+ (0, import_react80.createElement)("div", { style: { fontSize: "12px", color: "var(--dshpc-fg-3)", marginBottom: "6px" } }, "footer \u5F02\u6B65\uFF08\u4FDD\u5B58\u65F6\u6574\u6846\u9501\u6B7B\uFF09"),
64705
+ (0, import_react80.createElement)(Button, { variant: "outline", onClick: () => setAsyncOpen(true) }, "\u6253\u5F00\u5927\u5F39\u7A97\uFF08\u5F02\u6B65\u4FDD\u5B58\uFF09"),
64706
+ asyncOpen ? (0, import_react80.createElement)(
64707
+ Modal,
64708
+ {
64709
+ title: "\u7F16\u8F91\u4EFB\u52A1",
64710
+ busy: saving,
64711
+ onClose: () => setAsyncOpen(false),
64712
+ footer: (0, import_react80.createElement)(
64713
+ "div",
64714
+ { style: { display: "flex", justifyContent: "flex-end", gap: "8px" } },
64715
+ (0, import_react80.createElement)(Button, { variant: "outline", disabled: saving, onClick: () => setAsyncOpen(false) }, "\u53D6\u6D88"),
64716
+ (0, import_react80.createElement)(Button, {
64717
+ variant: "primary",
64718
+ onBusyChange: setSaving,
64719
+ onClick: async () => {
64720
+ await demoWait();
64721
+ setAsyncOpen(false);
64722
+ }
64723
+ }, "\u4FDD\u5B58")
64724
+ )
64725
+ },
64726
+ (0, import_react80.createElement)("div", { style: { fontSize: "13px", lineHeight: "1.7" } }, "\u70B9\u300C\u4FDD\u5B58\u300D\uFF1A\u6309\u94AE\u81EA\u5DF1\u8F6C\u5708\uFF0C\u540C\u65F6\u628A busy \u62A5\u7ED9\u5F39\u7A97 \u2014\u2014 \u906E\u7F69 / Esc / \u2715 \u5168\u90E8\u5931\u6548\uFF0C1.4 \u79D2\u540E\u5173\u95ED\u3002footer \u90A3\u6761\u5206\u9694\u7EBF\u7167\u65E7\uFF0C\u4E0D\u56E0\u5F02\u6B65\u6539\u53D8\u3002")
64727
+ ) : null
64606
64728
  )
64607
64729
  )
64608
64730
  ),
@@ -64633,7 +64755,12 @@ function FeedbackPage() {
64633
64755
  title: "\u6587\u4EF6\u8BE6\u60C5",
64634
64756
  extra: (0, import_react80.createElement)(Chip, null, "\u53EA\u8BFB"),
64635
64757
  onClose: () => setSheetOpen(false),
64636
- footer: sheetCfg.footer ? (0, import_react80.createElement)(Button, { variant: "primary", onClick: () => setSheetOpen(false) }, "\u77E5\u9053\u4E86") : void 0
64758
+ // 底栏按钮异步:转圈期间抽屉也锁死(busy 由按钮报上来)
64759
+ busy: sheetSaving,
64760
+ footer: sheetCfg.footer ? (0, import_react80.createElement)(Button, { variant: "primary", onBusyChange: setSheetSaving, onClick: async () => {
64761
+ await demoWait(1e3);
64762
+ setSheetOpen(false);
64763
+ } }, "\u4FDD\u5B58\u5E76\u5173\u95ED") : void 0
64637
64764
  },
64638
64765
  (0, import_react80.createElement)(
64639
64766
  "div",
@@ -66005,9 +66132,9 @@ function ReferencePage() {
66005
66132
  "tbody",
66006
66133
  null,
66007
66134
  [
66008
- [t3("buildCore"), `v${"0.21.0"}`],
66009
- [t3("buildDemo"), `v${"0.21.0"}`],
66010
- [t3("buildStamp"), "261103-090039-142"]
66135
+ [t3("buildCore"), `v${"0.22.0"}`],
66136
+ [t3("buildDemo"), `v${"0.22.0"}`],
66137
+ [t3("buildStamp"), "261103-114124-136"]
66011
66138
  ].map(
66012
66139
  ([label, value]) => (0, import_react85.createElement)(
66013
66140
  "tr",
@@ -66329,9 +66456,9 @@ function DemoPage() {
66329
66456
  lineHeight: "14px"
66330
66457
  }
66331
66458
  },
66332
- (0, import_react87.createElement)("span", null, `core v${"0.21.0"}`),
66333
- (0, import_react87.createElement)("span", null, `demo v${"0.21.0"}`),
66334
- (0, import_react87.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261103-090039-142")
66459
+ (0, import_react87.createElement)("span", null, `core v${"0.22.0"}`),
66460
+ (0, import_react87.createElement)("span", null, `demo v${"0.22.0"}`),
66461
+ (0, import_react87.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261103-114124-136")
66335
66462
  )
66336
66463
  )
66337
66464
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "The shared UI foundation for DSH plugins, with a live component preview: design tokens, common controls, workspace browsing and notifications maintained in one place — install it to preview every component in a real host.",
5
5
  "icon": "./assets/icon-components.svg",
6
6
  "keywords": [