@sia.soul/sia-react-ui 0.1.150 → 0.1.151
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/dist/{chunk-HRC6TQTZ.js → chunk-5P274RXG.js} +4 -2
- package/dist/{chunk-G5YXOCSY.js → chunk-GA5HA2A4.js} +1 -1
- package/dist/{chunk-TKRCHZB7.js → chunk-PDYEIHUO.js} +1 -1
- package/dist/core.cjs +4 -2
- package/dist/core.css +35 -2
- package/dist/core.js +2 -2
- package/dist/game.css +35 -2
- package/dist/index.cjs +46 -18
- package/dist/index.css +36 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +45 -19
- package/dist/select-date-range.cjs +4 -2
- package/dist/select-date-range.js +2 -2
- package/package.json +1 -1
|
@@ -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 &&
|
|
436
|
+
const overlay = motion.present && hasContent && typeof document !== "undefined" ? createPortal(
|
|
435
437
|
/* @__PURE__ */ jsxs2(
|
|
436
438
|
"span",
|
|
437
439
|
{
|
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 &&
|
|
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;
|
|
@@ -4397,6 +4397,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4397
4397
|
.sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
|
|
4398
4398
|
outline: none;
|
|
4399
4399
|
}
|
|
4400
|
+
.sia-table__editor--custom {
|
|
4401
|
+
min-width: 0;
|
|
4402
|
+
overflow: auto;
|
|
4403
|
+
box-sizing: border-box;
|
|
4404
|
+
}
|
|
4405
|
+
.sia-table__editor--custom:has(> .sia-flex) {
|
|
4406
|
+
padding: 4px 8px;
|
|
4407
|
+
}
|
|
4408
|
+
.sia-table__editor--custom > .sia-flex {
|
|
4409
|
+
min-width: 0;
|
|
4410
|
+
min-height: min-content;
|
|
4411
|
+
height: auto;
|
|
4412
|
+
flex: 1;
|
|
4413
|
+
white-space: normal;
|
|
4414
|
+
}
|
|
4415
|
+
.sia-table__editor--custom .sia-flex {
|
|
4416
|
+
min-width: 0;
|
|
4417
|
+
}
|
|
4418
|
+
.sia-table__editor--custom .sia-flex > .sia-select {
|
|
4419
|
+
width: 100%;
|
|
4420
|
+
min-width: 0;
|
|
4421
|
+
flex-shrink: 0;
|
|
4422
|
+
}
|
|
4423
|
+
.sia-table__editor--custom .sia-flex .sia-select__trigger {
|
|
4424
|
+
height: var(--sia-control-height);
|
|
4425
|
+
border-radius: var(--sia-radius);
|
|
4426
|
+
}
|
|
4427
|
+
.sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
|
|
4428
|
+
height: var(--sia-control-height-small);
|
|
4429
|
+
}
|
|
4430
|
+
.sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
|
|
4431
|
+
height: var(--sia-control-height-large);
|
|
4432
|
+
}
|
|
4400
4433
|
.sia-table__tree-cell {
|
|
4401
4434
|
display: flex;
|
|
4402
4435
|
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-
|
|
14
|
+
} from "./chunk-GA5HA2A4.js";
|
|
15
15
|
import "./chunk-RX242MUO.js";
|
|
16
16
|
import {
|
|
17
17
|
Select
|
|
18
|
-
} from "./chunk-
|
|
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;
|
|
@@ -4448,6 +4448,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4448
4448
|
.sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
|
|
4449
4449
|
outline: none;
|
|
4450
4450
|
}
|
|
4451
|
+
.sia-table__editor--custom {
|
|
4452
|
+
min-width: 0;
|
|
4453
|
+
overflow: auto;
|
|
4454
|
+
box-sizing: border-box;
|
|
4455
|
+
}
|
|
4456
|
+
.sia-table__editor--custom:has(> .sia-flex) {
|
|
4457
|
+
padding: 4px 8px;
|
|
4458
|
+
}
|
|
4459
|
+
.sia-table__editor--custom > .sia-flex {
|
|
4460
|
+
min-width: 0;
|
|
4461
|
+
min-height: min-content;
|
|
4462
|
+
height: auto;
|
|
4463
|
+
flex: 1;
|
|
4464
|
+
white-space: normal;
|
|
4465
|
+
}
|
|
4466
|
+
.sia-table__editor--custom .sia-flex {
|
|
4467
|
+
min-width: 0;
|
|
4468
|
+
}
|
|
4469
|
+
.sia-table__editor--custom .sia-flex > .sia-select {
|
|
4470
|
+
width: 100%;
|
|
4471
|
+
min-width: 0;
|
|
4472
|
+
flex-shrink: 0;
|
|
4473
|
+
}
|
|
4474
|
+
.sia-table__editor--custom .sia-flex .sia-select__trigger {
|
|
4475
|
+
height: var(--sia-control-height);
|
|
4476
|
+
border-radius: var(--sia-radius);
|
|
4477
|
+
}
|
|
4478
|
+
.sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
|
|
4479
|
+
height: var(--sia-control-height-small);
|
|
4480
|
+
}
|
|
4481
|
+
.sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
|
|
4482
|
+
height: var(--sia-control-height-large);
|
|
4483
|
+
}
|
|
4451
4484
|
.sia-table__tree-cell {
|
|
4452
4485
|
display: flex;
|
|
4453
4486
|
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 &&
|
|
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
|
|
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
|
-
|
|
17283
|
+
if (config.type === "custom" || config.type === "select") onCancel();
|
|
17284
|
+
else void saveRef.current();
|
|
17283
17285
|
};
|
|
17284
|
-
document.addEventListener("pointerdown", handleOutsidePointerDown
|
|
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)(
|
|
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;
|
|
@@ -4397,6 +4397,39 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4397
4397
|
.sia-table__editor > .sia-select > .sia-select__trigger:focus-visible {
|
|
4398
4398
|
outline: none;
|
|
4399
4399
|
}
|
|
4400
|
+
.sia-table__editor--custom {
|
|
4401
|
+
min-width: 0;
|
|
4402
|
+
overflow: auto;
|
|
4403
|
+
box-sizing: border-box;
|
|
4404
|
+
}
|
|
4405
|
+
.sia-table__editor--custom:has(> .sia-flex) {
|
|
4406
|
+
padding: 4px 8px;
|
|
4407
|
+
}
|
|
4408
|
+
.sia-table__editor--custom > .sia-flex {
|
|
4409
|
+
min-width: 0;
|
|
4410
|
+
min-height: min-content;
|
|
4411
|
+
height: auto;
|
|
4412
|
+
flex: 1;
|
|
4413
|
+
white-space: normal;
|
|
4414
|
+
}
|
|
4415
|
+
.sia-table__editor--custom .sia-flex {
|
|
4416
|
+
min-width: 0;
|
|
4417
|
+
}
|
|
4418
|
+
.sia-table__editor--custom .sia-flex > .sia-select {
|
|
4419
|
+
width: 100%;
|
|
4420
|
+
min-width: 0;
|
|
4421
|
+
flex-shrink: 0;
|
|
4422
|
+
}
|
|
4423
|
+
.sia-table__editor--custom .sia-flex .sia-select__trigger {
|
|
4424
|
+
height: var(--sia-control-height);
|
|
4425
|
+
border-radius: var(--sia-radius);
|
|
4426
|
+
}
|
|
4427
|
+
.sia-table__editor--custom .sia-flex .sia-select--small > .sia-select__trigger {
|
|
4428
|
+
height: var(--sia-control-height-small);
|
|
4429
|
+
}
|
|
4430
|
+
.sia-table__editor--custom .sia-flex .sia-select--large > .sia-select__trigger {
|
|
4431
|
+
height: var(--sia-control-height-large);
|
|
4432
|
+
}
|
|
4400
4433
|
.sia-table__tree-cell {
|
|
4401
4434
|
display: flex;
|
|
4402
4435
|
align-items: center;
|
|
@@ -11693,6 +11726,7 @@ body > .sia-title-tooltip[data-sia-popup-layer] {
|
|
|
11693
11726
|
background: var(--sia-color-primary);
|
|
11694
11727
|
cursor: crosshair;
|
|
11695
11728
|
z-index: 2;
|
|
11729
|
+
pointer-events: auto;
|
|
11696
11730
|
}
|
|
11697
11731
|
.sia-table__worksheet-fill-preview {
|
|
11698
11732
|
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-
|
|
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-
|
|
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-
|
|
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
|
|
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
|
-
|
|
8334
|
+
if (config.type === "custom" || config.type === "select") onCancel();
|
|
8335
|
+
else void saveRef.current();
|
|
8336
8336
|
};
|
|
8337
|
-
document.addEventListener("pointerdown", handleOutsidePointerDown
|
|
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(
|
|
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 &&
|
|
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
|
{
|