@sia.soul/sia-react-ui 0.1.150 → 0.1.152

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.
@@ -305,9 +305,10 @@ function Floating({
305
305
  const leaveTimer = useRef3();
306
306
  const contentId = useId2();
307
307
  const triggers = Array.isArray(trigger) ? trigger : [trigger];
308
+ const hasContent = content !== null && content !== void 0 && typeof content !== "boolean" && !(typeof content === "string" && content.trim() === "");
308
309
  const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
309
310
  const [position, setPosition] = useState();
310
- const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
311
+ const motion = useOverlayMotion(!!visible && hasContent, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
311
312
  const [portalContainer, setPortalContainer] = useState(null);
312
313
  useLayoutEffect(() => {
313
314
  if (!motion.present) return;
@@ -319,6 +320,7 @@ function Floating({
319
320
  if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
320
321
  const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
321
322
  function openNow() {
323
+ if (!hasContent) return;
322
324
  if (exclusiveTooltip && activeTooltipClose !== closeSelfRef.current) {
323
325
  activeTooltipClose?.();
324
326
  activeTooltipClose = closeSelfRef.current;
@@ -431,7 +433,7 @@ function Floating({
431
433
  } } : {},
432
434
  "aria-describedby": visible ? contentId : void 0
433
435
  });
434
- const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? createPortal(
436
+ const overlay = motion.present && hasContent && typeof document !== "undefined" ? createPortal(
435
437
  /* @__PURE__ */ jsxs2(
436
438
  "span",
437
439
  {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Popover,
3
3
  Tooltip
4
- } from "./chunk-HRC6TQTZ.js";
4
+ } from "./chunk-5P274RXG.js";
5
5
  import {
6
6
  Dropdown
7
7
  } from "./chunk-J4R734AI.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Select
3
- } from "./chunk-HRC6TQTZ.js";
3
+ } from "./chunk-5P274RXG.js";
4
4
  import {
5
5
  Icon
6
6
  } from "./chunk-SCVUD2IJ.js";
package/dist/core.cjs CHANGED
@@ -4006,9 +4006,10 @@ function Floating({
4006
4006
  const leaveTimer = (0, import_react21.useRef)();
4007
4007
  const contentId = (0, import_react21.useId)();
4008
4008
  const triggers = Array.isArray(trigger) ? trigger : [trigger];
4009
+ const hasContent = content !== null && content !== void 0 && typeof content !== "boolean" && !(typeof content === "string" && content.trim() === "");
4009
4010
  const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
4010
4011
  const [position, setPosition] = (0, import_react21.useState)();
4011
- const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
4012
+ const motion = useOverlayMotion(!!visible && hasContent, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
4012
4013
  const [portalContainer, setPortalContainer] = (0, import_react21.useState)(null);
4013
4014
  (0, import_react21.useLayoutEffect)(() => {
4014
4015
  if (!motion.present) return;
@@ -4020,6 +4021,7 @@ function Floating({
4020
4021
  if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
4021
4022
  const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
4022
4023
  function openNow() {
4024
+ if (!hasContent) return;
4023
4025
  if (exclusiveTooltip && activeTooltipClose !== closeSelfRef.current) {
4024
4026
  activeTooltipClose?.();
4025
4027
  activeTooltipClose = closeSelfRef.current;
@@ -4132,7 +4134,7 @@ function Floating({
4132
4134
  } } : {},
4133
4135
  "aria-describedby": visible ? contentId : void 0
4134
4136
  });
4135
- const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(
4137
+ const overlay = motion.present && hasContent && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(
4136
4138
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
4137
4139
  "span",
4138
4140
  {
package/dist/core.css CHANGED
@@ -3914,14 +3914,14 @@ fieldset:disabled .sia-input-number__floating-placeholder {
3914
3914
  text-overflow: ellipsis;
3915
3915
  white-space: nowrap;
3916
3916
  }
3917
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3917
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3918
3918
  display: inline-flex;
3919
3919
  width: max-content;
3920
3920
  flex-wrap: nowrap !important;
3921
3921
  flex-direction: row !important;
3922
3922
  vertical-align: middle;
3923
3923
  }
3924
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3924
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3925
3925
  flex-shrink: 0;
3926
3926
  width: auto;
3927
3927
  flex-direction: row;
@@ -4368,6 +4368,9 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4368
4368
  inset: 0;
4369
4369
  overflow: visible;
4370
4370
  }
4371
+ .sia-table__cell:has(> .sia-table__cell-content > .sia-table__editor) {
4372
+ isolation: isolate;
4373
+ }
4371
4374
  .sia-table__editor {
4372
4375
  display: flex;
4373
4376
  width: 100%;
@@ -4397,6 +4400,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4397
4400
  .sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
4398
4401
  outline: none;
4399
4402
  }
4403
+ .sia-table__editor--custom {
4404
+ min-width: 0;
4405
+ overflow: auto;
4406
+ box-sizing: border-box;
4407
+ }
4408
+ .sia-table__editor--custom:has(> .sia-flex) {
4409
+ padding: 4px 8px;
4410
+ }
4411
+ .sia-table__editor--custom > .sia-flex {
4412
+ min-width: 0;
4413
+ min-height: min-content;
4414
+ height: auto;
4415
+ flex: 1;
4416
+ white-space: normal;
4417
+ }
4418
+ .sia-table__editor--custom .sia-flex {
4419
+ min-width: 0;
4420
+ }
4421
+ .sia-table__editor--custom .sia-flex > .sia-select {
4422
+ width: 100%;
4423
+ min-width: 0;
4424
+ flex-shrink: 0;
4425
+ }
4426
+ .sia-table__editor--custom .sia-flex .sia-select__trigger {
4427
+ height: var(--sia-control-height);
4428
+ border-radius: var(--sia-radius);
4429
+ }
4430
+ .sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
4431
+ height: var(--sia-control-height-small);
4432
+ }
4433
+ .sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
4434
+ height: var(--sia-control-height-large);
4435
+ }
4400
4436
  .sia-table__tree-cell {
4401
4437
  display: flex;
4402
4438
  align-items: center;
package/dist/core.js CHANGED
@@ -11,11 +11,11 @@ import {
11
11
  Typography,
12
12
  Upload,
13
13
  message
14
- } from "./chunk-G5YXOCSY.js";
14
+ } from "./chunk-GA5HA2A4.js";
15
15
  import "./chunk-RX242MUO.js";
16
16
  import {
17
17
  Select
18
- } from "./chunk-HRC6TQTZ.js";
18
+ } from "./chunk-5P274RXG.js";
19
19
  import {
20
20
  Input,
21
21
  Segmented
package/dist/game.css CHANGED
@@ -3965,14 +3965,14 @@ fieldset:disabled .sia-input-number__floating-placeholder {
3965
3965
  text-overflow: ellipsis;
3966
3966
  white-space: nowrap;
3967
3967
  }
3968
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3968
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3969
3969
  display: inline-flex;
3970
3970
  width: max-content;
3971
3971
  flex-wrap: nowrap !important;
3972
3972
  flex-direction: row !important;
3973
3973
  vertical-align: middle;
3974
3974
  }
3975
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3975
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3976
3976
  flex-shrink: 0;
3977
3977
  width: auto;
3978
3978
  flex-direction: row;
@@ -4419,6 +4419,9 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4419
4419
  inset: 0;
4420
4420
  overflow: visible;
4421
4421
  }
4422
+ .sia-table__cell:has(> .sia-table__cell-content > .sia-table__editor) {
4423
+ isolation: isolate;
4424
+ }
4422
4425
  .sia-table__editor {
4423
4426
  display: flex;
4424
4427
  width: 100%;
@@ -4448,6 +4451,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4448
4451
  .sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
4449
4452
  outline: none;
4450
4453
  }
4454
+ .sia-table__editor--custom {
4455
+ min-width: 0;
4456
+ overflow: auto;
4457
+ box-sizing: border-box;
4458
+ }
4459
+ .sia-table__editor--custom:has(> .sia-flex) {
4460
+ padding: 4px 8px;
4461
+ }
4462
+ .sia-table__editor--custom > .sia-flex {
4463
+ min-width: 0;
4464
+ min-height: min-content;
4465
+ height: auto;
4466
+ flex: 1;
4467
+ white-space: normal;
4468
+ }
4469
+ .sia-table__editor--custom .sia-flex {
4470
+ min-width: 0;
4471
+ }
4472
+ .sia-table__editor--custom .sia-flex > .sia-select {
4473
+ width: 100%;
4474
+ min-width: 0;
4475
+ flex-shrink: 0;
4476
+ }
4477
+ .sia-table__editor--custom .sia-flex .sia-select__trigger {
4478
+ height: var(--sia-control-height);
4479
+ border-radius: var(--sia-radius);
4480
+ }
4481
+ .sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
4482
+ height: var(--sia-control-height-small);
4483
+ }
4484
+ .sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
4485
+ height: var(--sia-control-height-large);
4486
+ }
4451
4487
  .sia-table__tree-cell {
4452
4488
  display: flex;
4453
4489
  align-items: center;
package/dist/index.cjs CHANGED
@@ -5277,9 +5277,10 @@ function Floating({
5277
5277
  const leaveTimer = (0, import_react26.useRef)();
5278
5278
  const contentId = (0, import_react26.useId)();
5279
5279
  const triggers = Array.isArray(trigger) ? trigger : [trigger];
5280
+ const hasContent = content !== null && content !== void 0 && typeof content !== "boolean" && !(typeof content === "string" && content.trim() === "");
5280
5281
  const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
5281
5282
  const [position, setPosition] = (0, import_react26.useState)();
5282
- const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
5283
+ const motion = useOverlayMotion(!!visible && hasContent, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
5283
5284
  const [portalContainer, setPortalContainer] = (0, import_react26.useState)(null);
5284
5285
  (0, import_react26.useLayoutEffect)(() => {
5285
5286
  if (!motion.present) return;
@@ -5291,6 +5292,7 @@ function Floating({
5291
5292
  if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
5292
5293
  const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
5293
5294
  function openNow() {
5295
+ if (!hasContent) return;
5294
5296
  if (exclusiveTooltip && activeTooltipClose !== closeSelfRef.current) {
5295
5297
  activeTooltipClose?.();
5296
5298
  activeTooltipClose = closeSelfRef.current;
@@ -5403,7 +5405,7 @@ function Floating({
5403
5405
  } } : {},
5404
5406
  "aria-describedby": visible ? contentId : void 0
5405
5407
  });
5406
- const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? (0, import_react_dom5.createPortal)(
5408
+ const overlay = motion.present && hasContent && typeof document !== "undefined" ? (0, import_react_dom5.createPortal)(
5407
5409
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
5408
5410
  "span",
5409
5411
  {
@@ -17225,10 +17227,8 @@ function EditableTableCell({
17225
17227
  value,
17226
17228
  record,
17227
17229
  content,
17228
- onStart,
17229
17230
  onSave,
17230
17231
  onCancel,
17231
- trigger,
17232
17232
  showEditIcon
17233
17233
  }) {
17234
17234
  const config = typeof editable === "object" ? editable : { type: "input" };
@@ -17236,6 +17236,7 @@ function EditableTableCell({
17236
17236
  const [saving, setSaving] = (0, import_react66.useState)(false);
17237
17237
  const inputRef = (0, import_react66.useRef)(null);
17238
17238
  const editorRef = (0, import_react66.useRef)(null);
17239
+ const ownedEvents = (0, import_react66.useRef)(/* @__PURE__ */ new WeakSet());
17239
17240
  const editValueRef = (0, import_react66.useRef)(value);
17240
17241
  const savingRef = (0, import_react66.useRef)(false);
17241
17242
  const saveRef = (0, import_react66.useRef)(
@@ -17274,27 +17275,25 @@ function EditableTableCell({
17274
17275
  }
17275
17276
  saveRef.current = save;
17276
17277
  (0, import_react66.useEffect)(() => {
17277
- if (!active || config.type === "select" || config.type === "custom") return;
17278
+ if (!active) return;
17278
17279
  const handleOutsidePointerDown = (event) => {
17279
17280
  const target = event.target;
17280
- if (!(target instanceof Node) || editorRef.current?.contains(target))
17281
+ if (!(target instanceof Node) || ownedEvents.current.has(event) || editorRef.current?.contains(target))
17281
17282
  return;
17282
- void saveRef.current();
17283
+ if (config.type === "custom" || config.type === "select") onCancel();
17284
+ else void saveRef.current();
17283
17285
  };
17284
- document.addEventListener("pointerdown", handleOutsidePointerDown, true);
17286
+ document.addEventListener("pointerdown", handleOutsidePointerDown);
17285
17287
  return () => document.removeEventListener(
17286
17288
  "pointerdown",
17287
- handleOutsidePointerDown,
17288
- true
17289
+ handleOutsidePointerDown
17289
17290
  );
17290
- }, [active, config.type]);
17291
+ }, [active, config.type, onCancel]);
17291
17292
  if (!active)
17292
17293
  return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
17293
17294
  "div",
17294
17295
  {
17295
17296
  className: "sia-table__editable-display",
17296
- onClick: trigger === "click" ? onStart : void 0,
17297
- onDoubleClick: trigger === "doubleClick" ? onStart : void 0,
17298
17297
  children: [
17299
17298
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: content }),
17300
17299
  showEditIcon && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(Icon, { name: "edit", size: 13 })
@@ -17357,14 +17356,31 @@ function EditableTableCell({
17357
17356
  }
17358
17357
  );
17359
17358
  }
17360
- return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { ref: editorRef, className: "sia-table__editor", children: editor });
17359
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
17360
+ "div",
17361
+ {
17362
+ ref: editorRef,
17363
+ className: `sia-table__editor${config.type === "custom" ? " sia-table__editor--custom" : ""}`,
17364
+ onPointerDownCapture: (event) => ownedEvents.current.add(event.nativeEvent),
17365
+ children: editor
17366
+ }
17367
+ );
17361
17368
  }
17362
17369
  function createEditablePlugin(options = {}) {
17363
17370
  const trigger = options.trigger ?? "click";
17371
+ const startCellEdit = (row, column, event, context) => {
17372
+ const config = typeof column.editable === "object" ? column.editable : void 0;
17373
+ if (!column.editable || config?.canEdit?.(row.record) === false) return;
17374
+ if (event.target instanceof Element && event.target.closest("td") !== event.currentTarget) return;
17375
+ if (event.target instanceof Element && event.target.closest('button,a,input,textarea,select,[role="button"],[role="combobox"],.sia-table__editor,.sia-table__worksheet-handle,.sia-table__row-resize-handle')) return;
17376
+ context.setState({ editing: { rowKey: row.key, columnKey: column.key } });
17377
+ };
17364
17378
  return {
17365
17379
  id: "editable",
17366
17380
  order: 70,
17367
17381
  initialState: { editing: null },
17382
+ onCellClick: trigger === "click" ? startCellEdit : void 0,
17383
+ onCellDoubleClick: trigger === "doubleClick" ? startCellEdit : void 0,
17368
17384
  transformColumns(columns, context) {
17369
17385
  return mapTableLeafColumns(columns, (column) => {
17370
17386
  if (!column.editable) return column;
@@ -17385,11 +17401,7 @@ function createEditablePlugin(options = {}) {
17385
17401
  value,
17386
17402
  record,
17387
17403
  content,
17388
- trigger,
17389
17404
  showEditIcon: options.showEditIcon ?? true,
17390
- onStart: () => context.setState({
17391
- editing: { rowKey: info.row.key, columnKey: column.key }
17392
- }),
17393
17405
  onCancel: () => context.setState(
17394
17406
  (state) => state.editing?.rowKey === info.row.key && state.editing.columnKey === column.key ? { editing: null } : state
17395
17407
  ),
@@ -18322,6 +18334,7 @@ var TableBodyRow = (0, import_react67.memo)(function TableBodyRow2({
18322
18334
  onCellMouseEnter,
18323
18335
  onCellMouseLeave,
18324
18336
  onCellClick,
18337
+ onCellDoubleClick,
18325
18338
  onCellContextMenu,
18326
18339
  onCellPointerDown,
18327
18340
  onCellPointerMove
@@ -18368,6 +18381,7 @@ var TableBodyRow = (0, import_react67.memo)(function TableBodyRow2({
18368
18381
  onMouseEnter: () => onCellMouseEnter(column),
18369
18382
  onMouseLeave: () => onCellMouseLeave(column),
18370
18383
  onClick: (event) => onCellClick(column, event),
18384
+ onDoubleClick: (event) => onCellDoubleClick(column, event),
18371
18385
  onContextMenu: (event) => onCellContextMenu(column, event),
18372
18386
  onPointerDown: (event) => onCellPointerDown(column, event),
18373
18387
  onPointerMove: (event) => onCellPointerMove(column, event),
@@ -19114,6 +19128,9 @@ function TableInner(props, ref) {
19114
19128
  onCellClick: (column, event) => {
19115
19129
  for (const plugin of sortedPlugins) plugin.onCellClick?.(row, column, event, getContext(plugin));
19116
19130
  },
19131
+ onCellDoubleClick: (column, event) => {
19132
+ for (const plugin of sortedPlugins) plugin.onCellDoubleClick?.(row, column, event, getContext(plugin));
19133
+ },
19117
19134
  onCellContextMenu: (column, event) => {
19118
19135
  onCellContextMenu?.(row.record, column, row.sourceIndex, event);
19119
19136
  },
@@ -19619,6 +19636,17 @@ function createWorksheetPlugin(options) {
19619
19636
  id: "worksheet",
19620
19637
  order: 71,
19621
19638
  initialState: { editing: null, revision: 0 },
19639
+ // 工作表复用编辑插件的整格双击命中规则,同时解除撤销/替换数据后的编辑抑制。
19640
+ onCellDoubleClick(row, column, event, current) {
19641
+ remember(current);
19642
+ createEditablePlugin({ trigger: "doubleClick" }).onCellDoubleClick?.(row, column, event, {
19643
+ ...current,
19644
+ setState: (next) => {
19645
+ suppressEditing = false;
19646
+ current.setState((previous) => ({ ...previous, ...typeof next === "function" ? next(previous) : next }));
19647
+ }
19648
+ });
19649
+ },
19622
19650
  transformColumns(input, current) {
19623
19651
  remember(current);
19624
19652
  const epoch = editEpoch;
package/dist/index.css CHANGED
@@ -3914,14 +3914,14 @@ fieldset:disabled .sia-input-number__floating-placeholder {
3914
3914
  text-overflow: ellipsis;
3915
3915
  white-space: nowrap;
3916
3916
  }
3917
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3917
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) {
3918
3918
  display: inline-flex;
3919
3919
  width: max-content;
3920
3920
  flex-wrap: nowrap !important;
3921
3921
  flex-direction: row !important;
3922
3922
  vertical-align: middle;
3923
3923
  }
3924
- .sia-table__cell--ellipsis > .sia-table__cell-content :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3924
+ .sia-table__cell--ellipsis > .sia-table__cell-content:not(:has(> .sia-table__editor)) :is(.sia-space, .sia-flex, [data-table-inline-layout]) > * {
3925
3925
  flex-shrink: 0;
3926
3926
  width: auto;
3927
3927
  flex-direction: row;
@@ -4368,6 +4368,9 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4368
4368
  inset: 0;
4369
4369
  overflow: visible;
4370
4370
  }
4371
+ .sia-table__cell:has(> .sia-table__cell-content > .sia-table__editor) {
4372
+ isolation: isolate;
4373
+ }
4371
4374
  .sia-table__editor {
4372
4375
  display: flex;
4373
4376
  width: 100%;
@@ -4397,6 +4400,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
4397
4400
  .sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
4398
4401
  outline: none;
4399
4402
  }
4403
+ .sia-table__editor--custom {
4404
+ min-width: 0;
4405
+ overflow: auto;
4406
+ box-sizing: border-box;
4407
+ }
4408
+ .sia-table__editor--custom:has(> .sia-flex) {
4409
+ padding: 4px 8px;
4410
+ }
4411
+ .sia-table__editor--custom > .sia-flex {
4412
+ min-width: 0;
4413
+ min-height: min-content;
4414
+ height: auto;
4415
+ flex: 1;
4416
+ white-space: normal;
4417
+ }
4418
+ .sia-table__editor--custom .sia-flex {
4419
+ min-width: 0;
4420
+ }
4421
+ .sia-table__editor--custom .sia-flex > .sia-select {
4422
+ width: 100%;
4423
+ min-width: 0;
4424
+ flex-shrink: 0;
4425
+ }
4426
+ .sia-table__editor--custom .sia-flex .sia-select__trigger {
4427
+ height: var(--sia-control-height);
4428
+ border-radius: var(--sia-radius);
4429
+ }
4430
+ .sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
4431
+ height: var(--sia-control-height-small);
4432
+ }
4433
+ .sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
4434
+ height: var(--sia-control-height-large);
4435
+ }
4400
4436
  .sia-table__tree-cell {
4401
4437
  display: flex;
4402
4438
  align-items: center;
@@ -11693,6 +11729,7 @@ body > .sia-title-tooltip[data-sia-popup-layer] {
11693
11729
  background: var(--sia-color-primary);
11694
11730
  cursor: crosshair;
11695
11731
  z-index: 2;
11732
+ pointer-events: auto;
11696
11733
  }
11697
11734
  .sia-table__worksheet-fill-preview {
11698
11735
  box-shadow: inset 0 0 0 1px var(--sia-color-primary);
package/dist/index.d.cts CHANGED
@@ -2242,7 +2242,7 @@ interface TableEditableCellConfig<T> {
2242
2242
  /** 该项目对应的数据值,用于标识、选择或计算。 */
2243
2243
  value: string | number;
2244
2244
  }[];
2245
- /** 自定义单元格编辑控件。 */
2245
+ /** 自定义单元格编辑控件。save 写回并结束编辑,cancel 只结束编辑;点击编辑器及其 React Portal 之外会结束编辑,不自动写回未提交草稿。持续编辑可由工作表 editCell 即时写回。 */
2246
2246
  editRender?: (record: T, save: (value: unknown) => void, cancel: () => void) => ReactNode;
2247
2247
  /** 判断当前单元格是否允许编辑。 */
2248
2248
  canEdit?: (record: T) => boolean;
@@ -2347,6 +2347,8 @@ interface TablePlugin<T, S = unknown, Api = unknown> {
2347
2347
  onCellMouseLeave?: (row: TableRow<T>, column: TableColumn<T>, context: TablePluginContext<T, S>) => void;
2348
2348
  /** 点击单元格时调用。 */
2349
2349
  onCellClick?: (row: TableRow<T>, column: TableColumn<T>, event: MouseEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2350
+ /** 双击整个单元格时调用,包含文本以外的留白区域。 */
2351
+ onCellDoubleClick?: (row: TableRow<T>, column: TableColumn<T>, event: MouseEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2350
2352
  /** 指针在单元格按下时调用。 */
2351
2353
  onCellPointerDown?: (row: TableRow<T>, column: TableColumn<T>, event: PointerEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2352
2354
  /** 指针在单元格移动时调用。 */
package/dist/index.d.ts CHANGED
@@ -2242,7 +2242,7 @@ interface TableEditableCellConfig<T> {
2242
2242
  /** 该项目对应的数据值,用于标识、选择或计算。 */
2243
2243
  value: string | number;
2244
2244
  }[];
2245
- /** 自定义单元格编辑控件。 */
2245
+ /** 自定义单元格编辑控件。save 写回并结束编辑,cancel 只结束编辑;点击编辑器及其 React Portal 之外会结束编辑,不自动写回未提交草稿。持续编辑可由工作表 editCell 即时写回。 */
2246
2246
  editRender?: (record: T, save: (value: unknown) => void, cancel: () => void) => ReactNode;
2247
2247
  /** 判断当前单元格是否允许编辑。 */
2248
2248
  canEdit?: (record: T) => boolean;
@@ -2347,6 +2347,8 @@ interface TablePlugin<T, S = unknown, Api = unknown> {
2347
2347
  onCellMouseLeave?: (row: TableRow<T>, column: TableColumn<T>, context: TablePluginContext<T, S>) => void;
2348
2348
  /** 点击单元格时调用。 */
2349
2349
  onCellClick?: (row: TableRow<T>, column: TableColumn<T>, event: MouseEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2350
+ /** 双击整个单元格时调用,包含文本以外的留白区域。 */
2351
+ onCellDoubleClick?: (row: TableRow<T>, column: TableColumn<T>, event: MouseEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2350
2352
  /** 指针在单元格按下时调用。 */
2351
2353
  onCellPointerDown?: (row: TableRow<T>, column: TableColumn<T>, event: PointerEvent<HTMLTableCellElement>, context: TablePluginContext<T, S>) => void;
2352
2354
  /** 指针在单元格移动时调用。 */
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ import {
82
82
  Watermark,
83
83
  message,
84
84
  notification
85
- } from "./chunk-G5YXOCSY.js";
85
+ } from "./chunk-GA5HA2A4.js";
86
86
  import "./chunk-RX242MUO.js";
87
87
  import {
88
88
  MarkdownEditor
@@ -95,7 +95,7 @@ import {
95
95
  DatePicker,
96
96
  SelectDateRange,
97
97
  TimePanel
98
- } from "./chunk-TKRCHZB7.js";
98
+ } from "./chunk-PDYEIHUO.js";
99
99
  import {
100
100
  Checkbox,
101
101
  OverflowTags,
@@ -107,7 +107,7 @@ import {
107
107
  Tree,
108
108
  normalizeSelectionValues,
109
109
  usePressFeedback
110
- } from "./chunk-HRC6TQTZ.js";
110
+ } from "./chunk-5P274RXG.js";
111
111
  import {
112
112
  Dropdown,
113
113
  Input,
@@ -8278,10 +8278,8 @@ function EditableTableCell({
8278
8278
  value,
8279
8279
  record,
8280
8280
  content,
8281
- onStart,
8282
8281
  onSave,
8283
8282
  onCancel,
8284
- trigger,
8285
8283
  showEditIcon
8286
8284
  }) {
8287
8285
  const config = typeof editable === "object" ? editable : { type: "input" };
@@ -8289,6 +8287,7 @@ function EditableTableCell({
8289
8287
  const [saving, setSaving] = useState23(false);
8290
8288
  const inputRef = useRef23(null);
8291
8289
  const editorRef = useRef23(null);
8290
+ const ownedEvents = useRef23(/* @__PURE__ */ new WeakSet());
8292
8291
  const editValueRef = useRef23(value);
8293
8292
  const savingRef = useRef23(false);
8294
8293
  const saveRef = useRef23(
@@ -8327,27 +8326,25 @@ function EditableTableCell({
8327
8326
  }
8328
8327
  saveRef.current = save;
8329
8328
  useEffect16(() => {
8330
- if (!active || config.type === "select" || config.type === "custom") return;
8329
+ if (!active) return;
8331
8330
  const handleOutsidePointerDown = (event) => {
8332
8331
  const target = event.target;
8333
- if (!(target instanceof Node) || editorRef.current?.contains(target))
8332
+ if (!(target instanceof Node) || ownedEvents.current.has(event) || editorRef.current?.contains(target))
8334
8333
  return;
8335
- void saveRef.current();
8334
+ if (config.type === "custom" || config.type === "select") onCancel();
8335
+ else void saveRef.current();
8336
8336
  };
8337
- document.addEventListener("pointerdown", handleOutsidePointerDown, true);
8337
+ document.addEventListener("pointerdown", handleOutsidePointerDown);
8338
8338
  return () => document.removeEventListener(
8339
8339
  "pointerdown",
8340
- handleOutsidePointerDown,
8341
- true
8340
+ handleOutsidePointerDown
8342
8341
  );
8343
- }, [active, config.type]);
8342
+ }, [active, config.type, onCancel]);
8344
8343
  if (!active)
8345
8344
  return /* @__PURE__ */ jsxs24(
8346
8345
  "div",
8347
8346
  {
8348
8347
  className: "sia-table__editable-display",
8349
- onClick: trigger === "click" ? onStart : void 0,
8350
- onDoubleClick: trigger === "doubleClick" ? onStart : void 0,
8351
8348
  children: [
8352
8349
  /* @__PURE__ */ jsx28("span", { children: content }),
8353
8350
  showEditIcon && /* @__PURE__ */ jsx28(Icon, { name: "edit", size: 13 })
@@ -8410,14 +8407,31 @@ function EditableTableCell({
8410
8407
  }
8411
8408
  );
8412
8409
  }
8413
- return /* @__PURE__ */ jsx28("div", { ref: editorRef, className: "sia-table__editor", children: editor });
8410
+ return /* @__PURE__ */ jsx28(
8411
+ "div",
8412
+ {
8413
+ ref: editorRef,
8414
+ className: `sia-table__editor${config.type === "custom" ? " sia-table__editor--custom" : ""}`,
8415
+ onPointerDownCapture: (event) => ownedEvents.current.add(event.nativeEvent),
8416
+ children: editor
8417
+ }
8418
+ );
8414
8419
  }
8415
8420
  function createEditablePlugin(options = {}) {
8416
8421
  const trigger = options.trigger ?? "click";
8422
+ const startCellEdit = (row, column, event, context) => {
8423
+ const config = typeof column.editable === "object" ? column.editable : void 0;
8424
+ if (!column.editable || config?.canEdit?.(row.record) === false) return;
8425
+ if (event.target instanceof Element && event.target.closest("td") !== event.currentTarget) return;
8426
+ if (event.target instanceof Element && event.target.closest('button,a,input,textarea,select,[role="button"],[role="combobox"],.sia-table__editor,.sia-table__worksheet-handle,.sia-table__row-resize-handle')) return;
8427
+ context.setState({ editing: { rowKey: row.key, columnKey: column.key } });
8428
+ };
8417
8429
  return {
8418
8430
  id: "editable",
8419
8431
  order: 70,
8420
8432
  initialState: { editing: null },
8433
+ onCellClick: trigger === "click" ? startCellEdit : void 0,
8434
+ onCellDoubleClick: trigger === "doubleClick" ? startCellEdit : void 0,
8421
8435
  transformColumns(columns, context) {
8422
8436
  return mapTableLeafColumns(columns, (column) => {
8423
8437
  if (!column.editable) return column;
@@ -8438,11 +8452,7 @@ function createEditablePlugin(options = {}) {
8438
8452
  value,
8439
8453
  record,
8440
8454
  content,
8441
- trigger,
8442
8455
  showEditIcon: options.showEditIcon ?? true,
8443
- onStart: () => context.setState({
8444
- editing: { rowKey: info.row.key, columnKey: column.key }
8445
- }),
8446
8456
  onCancel: () => context.setState(
8447
8457
  (state) => state.editing?.rowKey === info.row.key && state.editing.columnKey === column.key ? { editing: null } : state
8448
8458
  ),
@@ -9375,6 +9385,7 @@ var TableBodyRow = memo(function TableBodyRow2({
9375
9385
  onCellMouseEnter,
9376
9386
  onCellMouseLeave,
9377
9387
  onCellClick,
9388
+ onCellDoubleClick,
9378
9389
  onCellContextMenu,
9379
9390
  onCellPointerDown,
9380
9391
  onCellPointerMove
@@ -9421,6 +9432,7 @@ var TableBodyRow = memo(function TableBodyRow2({
9421
9432
  onMouseEnter: () => onCellMouseEnter(column),
9422
9433
  onMouseLeave: () => onCellMouseLeave(column),
9423
9434
  onClick: (event) => onCellClick(column, event),
9435
+ onDoubleClick: (event) => onCellDoubleClick(column, event),
9424
9436
  onContextMenu: (event) => onCellContextMenu(column, event),
9425
9437
  onPointerDown: (event) => onCellPointerDown(column, event),
9426
9438
  onPointerMove: (event) => onCellPointerMove(column, event),
@@ -10167,6 +10179,9 @@ function TableInner(props, ref) {
10167
10179
  onCellClick: (column, event) => {
10168
10180
  for (const plugin of sortedPlugins) plugin.onCellClick?.(row, column, event, getContext(plugin));
10169
10181
  },
10182
+ onCellDoubleClick: (column, event) => {
10183
+ for (const plugin of sortedPlugins) plugin.onCellDoubleClick?.(row, column, event, getContext(plugin));
10184
+ },
10170
10185
  onCellContextMenu: (column, event) => {
10171
10186
  onCellContextMenu?.(row.record, column, row.sourceIndex, event);
10172
10187
  },
@@ -10672,6 +10687,17 @@ function createWorksheetPlugin(options) {
10672
10687
  id: "worksheet",
10673
10688
  order: 71,
10674
10689
  initialState: { editing: null, revision: 0 },
10690
+ // 工作表复用编辑插件的整格双击命中规则,同时解除撤销/替换数据后的编辑抑制。
10691
+ onCellDoubleClick(row, column, event, current) {
10692
+ remember(current);
10693
+ createEditablePlugin({ trigger: "doubleClick" }).onCellDoubleClick?.(row, column, event, {
10694
+ ...current,
10695
+ setState: (next) => {
10696
+ suppressEditing = false;
10697
+ current.setState((previous) => ({ ...previous, ...typeof next === "function" ? next(previous) : next }));
10698
+ }
10699
+ });
10700
+ },
10675
10701
  transformColumns(input, current) {
10676
10702
  remember(current);
10677
10703
  const epoch = editEpoch;
@@ -4053,9 +4053,10 @@ function Floating({
4053
4053
  const leaveTimer = (0, import_react18.useRef)();
4054
4054
  const contentId = (0, import_react18.useId)();
4055
4055
  const triggers = Array.isArray(trigger) ? trigger : [trigger];
4056
+ const hasContent = content !== null && content !== void 0 && typeof content !== "boolean" && !(typeof content === "string" && content.trim() === "");
4056
4057
  const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
4057
4058
  const [position, setPosition] = (0, import_react18.useState)();
4058
- const motion = useOverlayMotion(!!visible, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
4059
+ const motion = useOverlayMotion(!!visible && hasContent, overlayRef, "tooltip", "bottom", !!position, void 0, !overlayClassName.includes("sia-form-item__error-popover"));
4059
4060
  const [portalContainer, setPortalContainer] = (0, import_react18.useState)(null);
4060
4061
  (0, import_react18.useLayoutEffect)(() => {
4061
4062
  if (!motion.present) return;
@@ -4067,6 +4068,7 @@ function Floating({
4067
4068
  if (!closeSelfRef.current) closeSelfRef.current = () => setVisibleRef.current(false);
4068
4069
  const exclusiveTooltip = role === "tooltip" && triggers.includes("hover");
4069
4070
  function openNow() {
4071
+ if (!hasContent) return;
4070
4072
  if (exclusiveTooltip && activeTooltipClose !== closeSelfRef.current) {
4071
4073
  activeTooltipClose?.();
4072
4074
  activeTooltipClose = closeSelfRef.current;
@@ -4179,7 +4181,7 @@ function Floating({
4179
4181
  } } : {},
4180
4182
  "aria-describedby": visible ? contentId : void 0
4181
4183
  });
4182
- const overlay = motion.present && content !== null && content !== void 0 && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(
4184
+ const overlay = motion.present && hasContent && typeof document !== "undefined" ? (0, import_react_dom3.createPortal)(
4183
4185
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
4184
4186
  "span",
4185
4187
  {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SelectDateRange
3
- } from "./chunk-TKRCHZB7.js";
4
- import "./chunk-HRC6TQTZ.js";
3
+ } from "./chunk-PDYEIHUO.js";
4
+ import "./chunk-5P274RXG.js";
5
5
  import "./chunk-J4R734AI.js";
6
6
  import "./chunk-NRLIOMXY.js";
7
7
  import "./chunk-SCVUD2IJ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.150",
3
+ "version": "0.1.152",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",