@skygraph/react 0.5.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{chunk-P4J4PFBG.js → chunk-7AA2JPZB.js} +95 -55
- package/dist/chunk-7AA2JPZB.js.map +1 -0
- package/dist/{chunk-YTPUWPWA.js → chunk-Y6XZ5TLD.js} +43 -2
- package/dist/chunk-Y6XZ5TLD.js.map +1 -0
- package/dist/form.cjs +41 -0
- package/dist/form.cjs.map +1 -1
- package/dist/form.d.cts +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.js +1 -1
- package/dist/index.cjs +261 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +230 -141
- package/dist/index.js.map +1 -1
- package/dist/table.cjs +94 -54
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-P4J4PFBG.js.map +0 -1
- package/dist/chunk-YTPUWPWA.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1985,6 +1985,7 @@ function Field({
|
|
|
1985
1985
|
noStyle,
|
|
1986
1986
|
normalize,
|
|
1987
1987
|
getValueFromEvent: _getValueFromEvent,
|
|
1988
|
+
valuePropName,
|
|
1988
1989
|
validateFirst,
|
|
1989
1990
|
validateStatus: manualStatus,
|
|
1990
1991
|
hasFeedback,
|
|
@@ -2025,6 +2026,18 @@ function Field({
|
|
|
2025
2026
|
prevValueRef.current = normalized;
|
|
2026
2027
|
field.onChange(normalized);
|
|
2027
2028
|
} : field.onChange;
|
|
2029
|
+
const valueProp = valuePropName ?? "value";
|
|
2030
|
+
const extractValue = (...args) => {
|
|
2031
|
+
if (_getValueFromEvent) return _getValueFromEvent(...args);
|
|
2032
|
+
const first = args[0];
|
|
2033
|
+
if (first !== null && typeof first === "object" && "target" in first) {
|
|
2034
|
+
const target = first.target;
|
|
2035
|
+
if (target && typeof target === "object" && "value" in target) {
|
|
2036
|
+
return valueProp === "checked" ? target.checked : target.value;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
return first;
|
|
2040
|
+
};
|
|
2028
2041
|
const effectiveStatus = manualStatus ?? field.status;
|
|
2029
2042
|
const hasErrors = field.errors.length > 0;
|
|
2030
2043
|
const hasWarnings = field.warnings.length > 0;
|
|
@@ -2060,6 +2073,34 @@ function Field({
|
|
|
2060
2073
|
] });
|
|
2061
2074
|
}
|
|
2062
2075
|
if (children) {
|
|
2076
|
+
if ((0, import_react13.isValidElement)(children)) {
|
|
2077
|
+
const childProps = children.props;
|
|
2078
|
+
const childOnChange = childProps.onChange;
|
|
2079
|
+
const childOnBlur = childProps.onBlur;
|
|
2080
|
+
const injected = {
|
|
2081
|
+
[valueProp]: field.value,
|
|
2082
|
+
onChange: (...args) => {
|
|
2083
|
+
wrappedOnChange(extractValue(...args));
|
|
2084
|
+
childOnChange?.(...args);
|
|
2085
|
+
},
|
|
2086
|
+
onBlur: (...args) => {
|
|
2087
|
+
field.onBlur();
|
|
2088
|
+
childOnBlur?.(...args);
|
|
2089
|
+
}
|
|
2090
|
+
};
|
|
2091
|
+
if (childProps.id === void 0) injected.id = fieldId;
|
|
2092
|
+
if (childProps.disabled === void 0 && disabled) injected.disabled = true;
|
|
2093
|
+
if (childProps["aria-describedby"] === void 0 && describedBy) {
|
|
2094
|
+
injected["aria-describedby"] = describedBy;
|
|
2095
|
+
}
|
|
2096
|
+
if (childProps["aria-invalid"] === void 0 && hasErrors) {
|
|
2097
|
+
injected["aria-invalid"] = true;
|
|
2098
|
+
}
|
|
2099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2100
|
+
(0, import_react13.cloneElement)(children, injected),
|
|
2101
|
+
feedbackIcon
|
|
2102
|
+
] });
|
|
2103
|
+
}
|
|
2063
2104
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2064
2105
|
children,
|
|
2065
2106
|
feedbackIcon
|
|
@@ -3741,14 +3782,11 @@ function TableBody(props) {
|
|
|
3741
3782
|
onContextMenu({ x: e.clientX, y: e.clientY, items: items2 });
|
|
3742
3783
|
}
|
|
3743
3784
|
};
|
|
3744
|
-
const handleCellCopy = (0, import_react20.useCallback)(
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
},
|
|
3750
|
-
[]
|
|
3751
|
-
);
|
|
3785
|
+
const handleCellCopy = (0, import_react20.useCallback)(async (rowId, colKey, value) => {
|
|
3786
|
+
await copyToClipboard(String(value ?? ""));
|
|
3787
|
+
setCopiedCell(`${rowId}:${colKey}`);
|
|
3788
|
+
setTimeout(() => setCopiedCell(null), 1500);
|
|
3789
|
+
}, []);
|
|
3752
3790
|
if (flatRows.length === 0) {
|
|
3753
3791
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3754
3792
|
"div",
|
|
@@ -3813,7 +3851,13 @@ function TableBody(props) {
|
|
|
3813
3851
|
{
|
|
3814
3852
|
className: "sg-table-td sg-table-cell-drag-handle",
|
|
3815
3853
|
role: "cell",
|
|
3816
|
-
style: {
|
|
3854
|
+
style: {
|
|
3855
|
+
cursor: "grab",
|
|
3856
|
+
userSelect: "none",
|
|
3857
|
+
display: "flex",
|
|
3858
|
+
alignItems: "center",
|
|
3859
|
+
justifyContent: "center"
|
|
3860
|
+
},
|
|
3817
3861
|
children: "\u283F"
|
|
3818
3862
|
}
|
|
3819
3863
|
),
|
|
@@ -3825,10 +3869,24 @@ function TableBody(props) {
|
|
|
3825
3869
|
role: "cell",
|
|
3826
3870
|
onClick: (e) => {
|
|
3827
3871
|
e.stopPropagation();
|
|
3828
|
-
|
|
3872
|
+
if (e.target === e.currentTarget) {
|
|
3873
|
+
onSelectRow(row.id, row.data);
|
|
3874
|
+
}
|
|
3829
3875
|
},
|
|
3830
|
-
children: rowSelection.type === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3831
|
-
|
|
3876
|
+
children: rowSelection.type === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3877
|
+
"input",
|
|
3878
|
+
{
|
|
3879
|
+
type: "radio",
|
|
3880
|
+
checked: !!isSelected,
|
|
3881
|
+
onChange: () => onSelectRow(row.id, row.data)
|
|
3882
|
+
}
|
|
3883
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3884
|
+
Checkbox,
|
|
3885
|
+
{
|
|
3886
|
+
checked: !!isSelected,
|
|
3887
|
+
onChange: () => onSelectRow(row.id, row.data)
|
|
3888
|
+
}
|
|
3889
|
+
)
|
|
3832
3890
|
}
|
|
3833
3891
|
),
|
|
3834
3892
|
expandable && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "sg-table-td sg-table-cell-expand", role: "cell", children: canExpand && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -3851,10 +3909,8 @@ function TableBody(props) {
|
|
|
3851
3909
|
const isFocused = keyboardNavigation && focusedCell?.row === rowIdx && focusedCell?.col === colIndex;
|
|
3852
3910
|
const isCopied = copiedCell === cellKey;
|
|
3853
3911
|
const cellStyle = { ...fixedStyle(col) };
|
|
3854
|
-
if (span?.colSpan && span.colSpan > 1)
|
|
3855
|
-
|
|
3856
|
-
if (span?.rowSpan && span.rowSpan > 1)
|
|
3857
|
-
cellStyle.gridRow = `span ${span.rowSpan}`;
|
|
3912
|
+
if (span?.colSpan && span.colSpan > 1) cellStyle.gridColumn = `span ${span.colSpan}`;
|
|
3913
|
+
if (span?.rowSpan && span.rowSpan > 1) cellStyle.gridRow = `span ${span.rowSpan}`;
|
|
3858
3914
|
const isFirstCol = colIndex === 0;
|
|
3859
3915
|
const treeIndent = isTreeMode && isFirstCol ? row.depth * indentSize : 0;
|
|
3860
3916
|
const cellClsExtra = typeof col.cellClassName === "function" ? col.cellClassName(val, row.data, row.id) : col.cellClassName ?? "";
|
|
@@ -4868,6 +4924,13 @@ function useTableState(props) {
|
|
|
4868
4924
|
[table, refresh]
|
|
4869
4925
|
);
|
|
4870
4926
|
const resizeRef = (0, import_react24.useRef)(null);
|
|
4927
|
+
const resizeCleanupRef = (0, import_react24.useRef)(null);
|
|
4928
|
+
(0, import_react24.useEffect)(
|
|
4929
|
+
() => () => {
|
|
4930
|
+
resizeCleanupRef.current?.();
|
|
4931
|
+
},
|
|
4932
|
+
[]
|
|
4933
|
+
);
|
|
4871
4934
|
const [contextMenu, setContextMenu] = (0, import_react24.useState)(null);
|
|
4872
4935
|
const columns = (0, import_react24.useMemo)(() => {
|
|
4873
4936
|
const base = hasColumnGroups ? leafColumns : (() => {
|
|
@@ -4993,9 +5056,8 @@ function useTableState(props) {
|
|
|
4993
5056
|
);
|
|
4994
5057
|
const handleToggleExpand = (id) => {
|
|
4995
5058
|
const open = expandedKeys.has(id);
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
} else {
|
|
5059
|
+
expandable?.onExpand?.(!open, id);
|
|
5060
|
+
if (expandable?.expandedKeys == null) {
|
|
4999
5061
|
setInternalExpanded((prev) => {
|
|
5000
5062
|
const next = new Set(prev);
|
|
5001
5063
|
if (open) {
|
|
@@ -5071,28 +5133,34 @@ function useTableState(props) {
|
|
|
5071
5133
|
const handleResizeStart = (e, colKey) => {
|
|
5072
5134
|
e.preventDefault();
|
|
5073
5135
|
e.stopPropagation();
|
|
5136
|
+
resizeCleanupRef.current?.();
|
|
5074
5137
|
resizeRef.current = {
|
|
5075
5138
|
col: colKey,
|
|
5076
5139
|
startX: e.clientX,
|
|
5077
5140
|
startW: colWidths[colKey] ?? DEFAULT_COL_WIDTH
|
|
5078
5141
|
};
|
|
5079
5142
|
const onMove = (ev) => {
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
const
|
|
5143
|
+
const ref = resizeRef.current;
|
|
5144
|
+
if (!ref) return;
|
|
5145
|
+
const diff = ev.clientX - ref.startX;
|
|
5146
|
+
const min = leafColumns.find((c) => c.key === ref.col)?.minWidth ?? MIN_COL_WIDTH;
|
|
5147
|
+
const nextWidth = Math.max(min, ref.startW + diff);
|
|
5148
|
+
const col = ref.col;
|
|
5083
5149
|
setColWidths((prev) => ({
|
|
5084
5150
|
...prev,
|
|
5085
|
-
[
|
|
5151
|
+
[col]: nextWidth
|
|
5086
5152
|
}));
|
|
5087
|
-
setUserResizedCols(
|
|
5088
|
-
(prev) => prev.has(resizeRef.current.col) ? prev : new Set(prev).add(resizeRef.current.col)
|
|
5089
|
-
);
|
|
5153
|
+
setUserResizedCols((prev) => prev.has(col) ? prev : new Set(prev).add(col));
|
|
5090
5154
|
};
|
|
5091
|
-
const
|
|
5092
|
-
const ref = resizeRef.current;
|
|
5155
|
+
const cleanup = () => {
|
|
5093
5156
|
resizeRef.current = null;
|
|
5094
5157
|
document.removeEventListener("mousemove", onMove);
|
|
5095
5158
|
document.removeEventListener("mouseup", onUp);
|
|
5159
|
+
resizeCleanupRef.current = null;
|
|
5160
|
+
};
|
|
5161
|
+
const onUp = () => {
|
|
5162
|
+
const ref = resizeRef.current;
|
|
5163
|
+
cleanup();
|
|
5096
5164
|
if (!ref) return;
|
|
5097
5165
|
setColWidths((prev) => {
|
|
5098
5166
|
const w = prev[ref.col];
|
|
@@ -5100,6 +5168,7 @@ function useTableState(props) {
|
|
|
5100
5168
|
return prev;
|
|
5101
5169
|
});
|
|
5102
5170
|
};
|
|
5171
|
+
resizeCleanupRef.current = cleanup;
|
|
5103
5172
|
document.addEventListener("mousemove", onMove);
|
|
5104
5173
|
document.addEventListener("mouseup", onUp);
|
|
5105
5174
|
};
|
|
@@ -5120,13 +5189,11 @@ function useTableState(props) {
|
|
|
5120
5189
|
setDragOver(null);
|
|
5121
5190
|
return;
|
|
5122
5191
|
}
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
return next;
|
|
5129
|
-
});
|
|
5192
|
+
const next = colOrder.filter((k) => k !== dragCol);
|
|
5193
|
+
const idx = next.indexOf(targetKey);
|
|
5194
|
+
next.splice(idx, 0, dragCol);
|
|
5195
|
+
setColOrder(next);
|
|
5196
|
+
onColumnOrderChange?.(next);
|
|
5130
5197
|
setDragCol(null);
|
|
5131
5198
|
setDragOver(null);
|
|
5132
5199
|
};
|
|
@@ -5157,31 +5224,24 @@ function useTableState(props) {
|
|
|
5157
5224
|
}));
|
|
5158
5225
|
table.groupBy(groupBy, aggregates2);
|
|
5159
5226
|
}, [groupBy, leafColumns, table]);
|
|
5160
|
-
const [expandedGroups, setExpandedGroups] = (0, import_react24.useState)(() =>
|
|
5161
|
-
|
|
5162
|
-
|
|
5227
|
+
const [expandedGroups, setExpandedGroups] = (0, import_react24.useState)(() => /* @__PURE__ */ new Set());
|
|
5228
|
+
const allGroupKeysRef = (0, import_react24.useRef)([]);
|
|
5229
|
+
const groupsSeededRef = (0, import_react24.useRef)(false);
|
|
5163
5230
|
const toggleGroupExpand = (0, import_react24.useCallback)(
|
|
5164
5231
|
(groupKey) => {
|
|
5232
|
+
const willExpand = !expandedGroups.has(groupKey);
|
|
5165
5233
|
setExpandedGroups((prev) => {
|
|
5166
5234
|
const next = new Set(prev);
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
next.delete(groupKey);
|
|
5170
|
-
} else {
|
|
5171
|
-
next.add(groupKey);
|
|
5172
|
-
}
|
|
5173
|
-
onGroupExpandChange?.(groupKey, !wasExpanded);
|
|
5235
|
+
if (next.has(groupKey)) next.delete(groupKey);
|
|
5236
|
+
else next.add(groupKey);
|
|
5174
5237
|
return next;
|
|
5175
5238
|
});
|
|
5239
|
+
onGroupExpandChange?.(groupKey, willExpand);
|
|
5176
5240
|
},
|
|
5177
|
-
[onGroupExpandChange]
|
|
5241
|
+
[onGroupExpandChange, expandedGroups]
|
|
5178
5242
|
);
|
|
5179
5243
|
const expandAllGroups = (0, import_react24.useCallback)(() => {
|
|
5180
|
-
setExpandedGroups((
|
|
5181
|
-
const next = new Set(prev);
|
|
5182
|
-
next.add("__all__");
|
|
5183
|
-
return next;
|
|
5184
|
-
});
|
|
5244
|
+
setExpandedGroups(new Set(allGroupKeysRef.current));
|
|
5185
5245
|
}, []);
|
|
5186
5246
|
const collapseAllGroups = (0, import_react24.useCallback)(() => {
|
|
5187
5247
|
setExpandedGroups(/* @__PURE__ */ new Set());
|
|
@@ -5274,11 +5334,32 @@ function useTableState(props) {
|
|
|
5274
5334
|
}
|
|
5275
5335
|
return flattenTreeRows(visibleRows, childrenKey, treeExpanded);
|
|
5276
5336
|
}, [visibleRows, isTreeMode, childrenKey, treeExpanded]);
|
|
5337
|
+
const allGroupKeys = (0, import_react24.useMemo)(() => {
|
|
5338
|
+
if (!groupBy) return [];
|
|
5339
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5340
|
+
const keys = [];
|
|
5341
|
+
for (const r of baseFlatRows) {
|
|
5342
|
+
const k = String(r.data[groupBy] ?? "Other");
|
|
5343
|
+
if (!seen.has(k)) {
|
|
5344
|
+
seen.add(k);
|
|
5345
|
+
keys.push(k);
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
return keys;
|
|
5349
|
+
}, [baseFlatRows, groupBy]);
|
|
5350
|
+
allGroupKeysRef.current = allGroupKeys;
|
|
5351
|
+
(0, import_react24.useEffect)(() => {
|
|
5352
|
+
groupsSeededRef.current = false;
|
|
5353
|
+
}, [groupBy]);
|
|
5354
|
+
(0, import_react24.useEffect)(() => {
|
|
5355
|
+
if (!groupBy || !defaultGroupExpanded) return;
|
|
5356
|
+
if (groupsSeededRef.current || allGroupKeys.length === 0) return;
|
|
5357
|
+
groupsSeededRef.current = true;
|
|
5358
|
+
setExpandedGroups(new Set(allGroupKeys));
|
|
5359
|
+
}, [groupBy, defaultGroupExpanded, allGroupKeys]);
|
|
5277
5360
|
const groupedRows = (0, import_react24.useMemo)(() => {
|
|
5278
5361
|
if (!groupBy) return baseFlatRows;
|
|
5279
|
-
|
|
5280
|
-
const effectiveExpanded = allExpanded ? /* @__PURE__ */ new Set([...expandedGroups, ...baseFlatRows.map((r) => String(r.data[groupBy] ?? "Other"))]) : expandedGroups;
|
|
5281
|
-
return groupByColumn(baseFlatRows, groupBy, columns, effectiveExpanded);
|
|
5362
|
+
return groupByColumn(baseFlatRows, groupBy, columns, expandedGroups);
|
|
5282
5363
|
}, [baseFlatRows, groupBy, columns, expandedGroups]);
|
|
5283
5364
|
const {
|
|
5284
5365
|
top: pinnedTop,
|
|
@@ -9458,6 +9539,21 @@ function startOfDay(d) {
|
|
|
9458
9539
|
function cloneDate(d) {
|
|
9459
9540
|
return new Date(d.getTime());
|
|
9460
9541
|
}
|
|
9542
|
+
function startOfWeek(d) {
|
|
9543
|
+
const s = startOfDay(d);
|
|
9544
|
+
s.setDate(s.getDate() - s.getDay());
|
|
9545
|
+
return s;
|
|
9546
|
+
}
|
|
9547
|
+
function endOfWeek(d) {
|
|
9548
|
+
const e = startOfWeek(d);
|
|
9549
|
+
e.setDate(e.getDate() + 6);
|
|
9550
|
+
return e;
|
|
9551
|
+
}
|
|
9552
|
+
function getWeekOfYear(d) {
|
|
9553
|
+
const oneJan = new Date(d.getFullYear(), 0, 1);
|
|
9554
|
+
const dayOfYear = Math.floor((startOfDay(d).getTime() - startOfDay(oneJan).getTime()) / 864e5) + 1;
|
|
9555
|
+
return Math.ceil((dayOfYear + oneJan.getDay()) / 7);
|
|
9556
|
+
}
|
|
9461
9557
|
function toValidDate(input) {
|
|
9462
9558
|
if (input == null || input === "") return null;
|
|
9463
9559
|
if (input instanceof Date) return isNaN(input.getTime()) ? null : input;
|
|
@@ -9859,6 +9955,7 @@ function DatePicker({
|
|
|
9859
9955
|
const okBtnLabel = config.locale?.modal?.okText ?? "OK";
|
|
9860
9956
|
const timeConfig = typeof showTime === "object" ? showTime : {};
|
|
9861
9957
|
const hasTime = !!showTime;
|
|
9958
|
+
const isWeek = picker === "week";
|
|
9862
9959
|
const fmt = formatProp ?? (hasTime ? "YYYY-MM-DD HH:mm:ss" : picker === "month" ? "YYYY-MM" : picker === "year" ? "YYYY" : "YYYY-MM-DD");
|
|
9863
9960
|
const normalizedValue = toValidDate(value);
|
|
9864
9961
|
const normalizedDefault = toValidDate(defaultValue);
|
|
@@ -10008,7 +10105,8 @@ function DatePicker({
|
|
|
10008
10105
|
}
|
|
10009
10106
|
if (e.key === "Escape") closeDropdown();
|
|
10010
10107
|
};
|
|
10011
|
-
const
|
|
10108
|
+
const formatValue2 = (d) => isWeek ? `${d.getFullYear()}-W${String(getWeekOfYear(d)).padStart(2, "0")}` : formatDate(d, fmt);
|
|
10109
|
+
const displayText = isInputting ? inputText : currentValue ? formatValue2(currentValue) : "";
|
|
10012
10110
|
const wrapperCls = unstyled ? className ?? "" : [
|
|
10013
10111
|
"sg-datepicker",
|
|
10014
10112
|
`sg-datepicker-${size}`,
|
|
@@ -10073,7 +10171,9 @@ function DatePicker({
|
|
|
10073
10171
|
{
|
|
10074
10172
|
viewYear,
|
|
10075
10173
|
viewMonth,
|
|
10076
|
-
selectedDate: currentValue,
|
|
10174
|
+
selectedDate: isWeek ? null : currentValue,
|
|
10175
|
+
rangeStart: isWeek && currentValue ? startOfWeek(currentValue) : void 0,
|
|
10176
|
+
rangeEnd: isWeek && currentValue ? endOfWeek(currentValue) : void 0,
|
|
10077
10177
|
disabledDate,
|
|
10078
10178
|
onSelect: handleDateSelect,
|
|
10079
10179
|
onMonthChange: (d) => {
|
|
@@ -10189,7 +10289,8 @@ function RangePicker({
|
|
|
10189
10289
|
const [internalOpen, setInternalOpen] = (0, import_react38.useState)(false);
|
|
10190
10290
|
const [activeIndex, setActiveIndex] = (0, import_react38.useState)(0);
|
|
10191
10291
|
const [hoverDate, setHoverDate] = (0, import_react38.useState)(null);
|
|
10192
|
-
const
|
|
10292
|
+
const [draft, setDraft] = (0, import_react38.useState)(null);
|
|
10293
|
+
const currentValue = draft ?? normalizedValue ?? internalValue;
|
|
10193
10294
|
const isOpen = openProp ?? internalOpen;
|
|
10194
10295
|
const now = /* @__PURE__ */ new Date();
|
|
10195
10296
|
const [leftYear, setLeftYear] = (0, import_react38.useState)(() => (currentValue[0] ?? now).getFullYear());
|
|
@@ -10206,6 +10307,8 @@ function RangePicker({
|
|
|
10206
10307
|
if (ref.current && !ref.current.contains(e.target)) {
|
|
10207
10308
|
setInternalOpen(false);
|
|
10208
10309
|
onOpenChange?.(false);
|
|
10310
|
+
setDraft(null);
|
|
10311
|
+
setActiveIndex(0);
|
|
10209
10312
|
}
|
|
10210
10313
|
};
|
|
10211
10314
|
document.addEventListener("mousedown", handle);
|
|
@@ -10228,7 +10331,7 @@ function RangePicker({
|
|
|
10228
10331
|
};
|
|
10229
10332
|
const handleDateSelect = (date) => {
|
|
10230
10333
|
if (activeIndex === 0) {
|
|
10231
|
-
|
|
10334
|
+
setDraft([date, null]);
|
|
10232
10335
|
setActiveIndex(1);
|
|
10233
10336
|
} else {
|
|
10234
10337
|
let start = currentValue[0];
|
|
@@ -10242,9 +10345,10 @@ function RangePicker({
|
|
|
10242
10345
|
s.setHours(tempTimes[0].getHours(), tempTimes[0].getMinutes(), tempTimes[0].getSeconds());
|
|
10243
10346
|
const e = cloneDate(end);
|
|
10244
10347
|
e.setHours(tempTimes[1].getHours(), tempTimes[1].getMinutes(), tempTimes[1].getSeconds());
|
|
10245
|
-
|
|
10348
|
+
setDraft([s, e]);
|
|
10246
10349
|
} else {
|
|
10247
10350
|
commitRange([start, end]);
|
|
10351
|
+
setDraft(null);
|
|
10248
10352
|
setInternalOpen(false);
|
|
10249
10353
|
onOpenChange?.(false);
|
|
10250
10354
|
setActiveIndex(0);
|
|
@@ -10253,6 +10357,7 @@ function RangePicker({
|
|
|
10253
10357
|
};
|
|
10254
10358
|
const handleTimeOk = () => {
|
|
10255
10359
|
commitRange(currentValue);
|
|
10360
|
+
setDraft(null);
|
|
10256
10361
|
setInternalOpen(false);
|
|
10257
10362
|
onOpenChange?.(false);
|
|
10258
10363
|
setActiveIndex(0);
|
|
@@ -10260,6 +10365,7 @@ function RangePicker({
|
|
|
10260
10365
|
const handleClear = (e) => {
|
|
10261
10366
|
e.stopPropagation();
|
|
10262
10367
|
commitRange([null, null]);
|
|
10368
|
+
setDraft(null);
|
|
10263
10369
|
setActiveIndex(0);
|
|
10264
10370
|
};
|
|
10265
10371
|
const handlePresetSelect = (val) => {
|
|
@@ -10268,6 +10374,8 @@ function RangePicker({
|
|
|
10268
10374
|
} else {
|
|
10269
10375
|
commitRange([val, val]);
|
|
10270
10376
|
}
|
|
10377
|
+
setDraft(null);
|
|
10378
|
+
setActiveIndex(0);
|
|
10271
10379
|
setInternalOpen(false);
|
|
10272
10380
|
onOpenChange?.(false);
|
|
10273
10381
|
};
|
|
@@ -10561,12 +10669,18 @@ function TimePicker({
|
|
|
10561
10669
|
}, [secondStep]);
|
|
10562
10670
|
const disHours = (0, import_react39.useMemo)(() => new Set(disabledHours?.() ?? []), [disabledHours]);
|
|
10563
10671
|
const disMinutes = (0, import_react39.useMemo)(() => new Set(disabledMinutes?.(hour) ?? []), [disabledMinutes, hour]);
|
|
10564
|
-
const disSecs = (0, import_react39.useMemo)(
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10672
|
+
const disSecs = (0, import_react39.useMemo)(
|
|
10673
|
+
() => new Set(disabledSeconds?.(hour, minute) ?? []),
|
|
10674
|
+
[disabledSeconds, hour, minute]
|
|
10675
|
+
);
|
|
10676
|
+
const commitTime = (0, import_react39.useCallback)(
|
|
10677
|
+
(h, m, s) => {
|
|
10678
|
+
const str = formatTime(h, m, s, fmt, use12Hours);
|
|
10679
|
+
setInternalValue(str);
|
|
10680
|
+
onChange?.(str);
|
|
10681
|
+
},
|
|
10682
|
+
[fmt, use12Hours, onChange]
|
|
10683
|
+
);
|
|
10570
10684
|
const handleHourChange = (h) => {
|
|
10571
10685
|
const realH = use12Hours ? h === 12 ? hour >= 12 ? 12 : 0 : hour >= 12 ? h + 12 : h : h;
|
|
10572
10686
|
setHour(realH);
|
|
@@ -10621,10 +10735,26 @@ function TimePicker({
|
|
|
10621
10735
|
"aria-label": ariaLabel,
|
|
10622
10736
|
"aria-labelledby": ariaLabelledBy,
|
|
10623
10737
|
children: [
|
|
10624
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
10738
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
10739
|
+
"span",
|
|
10740
|
+
{
|
|
10741
|
+
className: unstyled ? "" : currentValue ? "sg-timepicker-value" : "sg-timepicker-placeholder",
|
|
10742
|
+
children: currentValue || placeholder
|
|
10743
|
+
}
|
|
10744
|
+
),
|
|
10625
10745
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: unstyled ? "" : "sg-timepicker-suffix", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spin, { size: "small", unstyled }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
10626
10746
|
allowClear && currentValue && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: unstyled ? "" : "sg-timepicker-clear", onClick: handleClear, children: "\xD7" }),
|
|
10627
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
10747
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
10748
|
+
"svg",
|
|
10749
|
+
{
|
|
10750
|
+
className: unstyled ? "" : "sg-timepicker-icon-svg",
|
|
10751
|
+
viewBox: "0 0 16 16",
|
|
10752
|
+
width: "14",
|
|
10753
|
+
height: "14",
|
|
10754
|
+
fill: "currentColor",
|
|
10755
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M8 0a8 8 0 110 16A8 8 0 018 0zm0 1a7 7 0 100 14A7 7 0 008 1zm.5 3v4.5l3 1.5-.5 1-3.5-1.75V4h1z" })
|
|
10756
|
+
}
|
|
10757
|
+
)
|
|
10628
10758
|
] }) })
|
|
10629
10759
|
]
|
|
10630
10760
|
}
|
|
@@ -10722,7 +10852,9 @@ function TimeRangePicker({
|
|
|
10722
10852
|
const size = sizeProp ?? config.size ?? "middle";
|
|
10723
10853
|
const disabled = disabledProp ?? config.disabled ?? false;
|
|
10724
10854
|
const fmt = formatProp ?? (use12Hours ? "hh:mm:ss A" : showSecond ? "HH:mm:ss" : "HH:mm");
|
|
10725
|
-
const [internalValue, setInternalValue] = (0, import_react39.useState)(
|
|
10855
|
+
const [internalValue, setInternalValue] = (0, import_react39.useState)(
|
|
10856
|
+
value ?? defaultValue ?? ["", ""]
|
|
10857
|
+
);
|
|
10726
10858
|
const [internalOpen, setInternalOpen] = (0, import_react39.useState)(false);
|
|
10727
10859
|
const currentValue = value ?? internalValue;
|
|
10728
10860
|
const isOpen = openProp ?? internalOpen;
|
|
@@ -10767,12 +10899,19 @@ function TimeRangePicker({
|
|
|
10767
10899
|
className
|
|
10768
10900
|
].filter(Boolean).join(" ");
|
|
10769
10901
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: wrapperCls, ref, style, children: [
|
|
10770
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10902
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
10903
|
+
"div",
|
|
10904
|
+
{
|
|
10905
|
+
className: unstyled ? "" : "sg-timepicker-input sg-timepicker-range-input",
|
|
10906
|
+
onClick: openDropdown,
|
|
10907
|
+
children: [
|
|
10908
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: currentValue[0] || placeholder[0] }),
|
|
10909
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: unstyled ? "" : "sg-timepicker-separator", children: separator }),
|
|
10910
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: currentValue[1] || placeholder[1] }),
|
|
10911
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: unstyled ? "" : "sg-timepicker-suffix", children: allowClear && (currentValue[0] || currentValue[1]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: unstyled ? "" : "sg-timepicker-clear", onClick: handleClear, children: "\xD7" }) })
|
|
10912
|
+
]
|
|
10913
|
+
}
|
|
10914
|
+
),
|
|
10776
10915
|
isOpen && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: unstyled ? "" : "sg-tp-dropdown sg-tp-dropdown-range", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: unstyled ? "" : "sg-tp-range-panels", children: [
|
|
10777
10916
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
10778
10917
|
TimePicker,
|
|
@@ -10837,9 +10976,7 @@ function AutoComplete({
|
|
|
10837
10976
|
const [open, setOpen] = (0, import_react40.useState)(false);
|
|
10838
10977
|
const ref = (0, import_react40.useRef)(null);
|
|
10839
10978
|
const currentValue = value ?? internalValue;
|
|
10840
|
-
const filtered = options.filter(
|
|
10841
|
-
(o) => o.label.toLowerCase().includes(currentValue.toLowerCase())
|
|
10842
|
-
);
|
|
10979
|
+
const filtered = options.filter((o) => o.label.toLowerCase().includes(currentValue.toLowerCase()));
|
|
10843
10980
|
(0, import_react40.useEffect)(() => {
|
|
10844
10981
|
const handleClickOutside = (e) => {
|
|
10845
10982
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
@@ -10860,7 +10997,12 @@ function AutoComplete({
|
|
|
10860
10997
|
onSelect?.(opt.value, opt);
|
|
10861
10998
|
setOpen(false);
|
|
10862
10999
|
};
|
|
10863
|
-
const wrapperClass = unstyled ? className ?? "" : [
|
|
11000
|
+
const wrapperClass = unstyled ? className ?? "" : [
|
|
11001
|
+
"sg-autocomplete",
|
|
11002
|
+
`sg-autocomplete-${size}`,
|
|
11003
|
+
loading ? "sg-autocomplete-loading" : "",
|
|
11004
|
+
className
|
|
11005
|
+
].filter(Boolean).join(" ");
|
|
10864
11006
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: wrapperClass, ref, style, children: [
|
|
10865
11007
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: unstyled ? "" : "sg-input-wrapper", children: [
|
|
10866
11008
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -10873,7 +11015,8 @@ function AutoComplete({
|
|
|
10873
11015
|
className: unstyled ? "" : `sg-input sg-input-${size}`,
|
|
10874
11016
|
value: currentValue,
|
|
10875
11017
|
placeholder,
|
|
10876
|
-
disabled
|
|
11018
|
+
disabled,
|
|
11019
|
+
"aria-busy": loading || void 0,
|
|
10877
11020
|
onChange: handleChange,
|
|
10878
11021
|
onFocus: () => setOpen(true),
|
|
10879
11022
|
onBlur
|
|
@@ -11341,25 +11484,34 @@ function NotificationCard({
|
|
|
11341
11484
|
const type = item.type ?? "info";
|
|
11342
11485
|
const closeAriaLabel = useConfig().locale?.notification?.closeAriaLabel ?? "Close";
|
|
11343
11486
|
if (unstyled) {
|
|
11344
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { role: "alert", children: [
|
|
11487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { role: "alert", className: item.className, style: item.style, children: [
|
|
11345
11488
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: typeIcons[type] }),
|
|
11346
11489
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: item.message }),
|
|
11347
11490
|
item.description && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { children: item.description }),
|
|
11348
11491
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("button", { onClick: onClose, "aria-label": closeAriaLabel, children: "\xD7" })
|
|
11349
11492
|
] });
|
|
11350
11493
|
}
|
|
11351
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
11495
|
+
"div",
|
|
11496
|
+
{
|
|
11497
|
+
className: ["sg-notification", `sg-notification-${type}`, item.className].filter(Boolean).join(" "),
|
|
11498
|
+
style: item.style,
|
|
11499
|
+
role: "alert",
|
|
11500
|
+
children: [
|
|
11501
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "sg-notification-icon", children: typeIcons[type] }),
|
|
11502
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "sg-notification-content", children: [
|
|
11503
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "sg-notification-message", children: item.message }),
|
|
11504
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "sg-notification-description", children: item.description })
|
|
11505
|
+
] }),
|
|
11506
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("button", { className: "sg-notification-close", onClick: onClose, "aria-label": closeAriaLabel, children: "\xD7" })
|
|
11507
|
+
]
|
|
11508
|
+
}
|
|
11509
|
+
);
|
|
11359
11510
|
}
|
|
11360
11511
|
|
|
11361
11512
|
// src/components/ui/Drawer.tsx
|
|
11362
11513
|
var import_react45 = require("react");
|
|
11514
|
+
var import_react_dom2 = require("react-dom");
|
|
11363
11515
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
11364
11516
|
var PLACEMENT_TRANSITION = {
|
|
11365
11517
|
left: "sg-slide-left",
|
|
@@ -11367,6 +11519,18 @@ var PLACEMENT_TRANSITION = {
|
|
|
11367
11519
|
top: "sg-slide-down",
|
|
11368
11520
|
bottom: "sg-slide-up"
|
|
11369
11521
|
};
|
|
11522
|
+
function getScopedCssVars(scope) {
|
|
11523
|
+
if (!scope || typeof window === "undefined") return {};
|
|
11524
|
+
const computed = window.getComputedStyle(scope);
|
|
11525
|
+
const vars = {};
|
|
11526
|
+
for (let i = 0; i < computed.length; i += 1) {
|
|
11527
|
+
const name = computed.item(i);
|
|
11528
|
+
if (name.startsWith("--sg-")) {
|
|
11529
|
+
vars[name] = computed.getPropertyValue(name);
|
|
11530
|
+
}
|
|
11531
|
+
}
|
|
11532
|
+
return vars;
|
|
11533
|
+
}
|
|
11370
11534
|
function Drawer({
|
|
11371
11535
|
open,
|
|
11372
11536
|
onClose,
|
|
@@ -11387,6 +11551,7 @@ function Drawer({
|
|
|
11387
11551
|
const titleId = `${uid}-title`;
|
|
11388
11552
|
const bodyId = `${uid}-body`;
|
|
11389
11553
|
const trapRef = useFocusTrap(open);
|
|
11554
|
+
const scopeRef = (0, import_react45.useRef)(null);
|
|
11390
11555
|
const { locale } = useConfig();
|
|
11391
11556
|
const closeAriaLabel = locale?.drawer?.closeAriaLabel ?? "Close";
|
|
11392
11557
|
const handleKeyDown = (0, import_react45.useCallback)(
|
|
@@ -11424,7 +11589,8 @@ function Drawer({
|
|
|
11424
11589
|
);
|
|
11425
11590
|
}
|
|
11426
11591
|
const transitionName = PLACEMENT_TRANSITION[placement] ?? "sg-slide-right";
|
|
11427
|
-
|
|
11592
|
+
const portalTarget = typeof document !== "undefined" ? document.body : null;
|
|
11593
|
+
const drawer = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Transition, { visible: open, name: "sg-fade", unmountOnExit: true, duration: 300, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "sg-drawer-root", style: getScopedCssVars(scopeRef.current), children: [
|
|
11428
11594
|
mask && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "sg-drawer-mask", onClick: maskClosable ? onClose : void 0 }),
|
|
11429
11595
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Transition, { visible: open, name: transitionName, unmountOnExit: true, duration: 300, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
11430
11596
|
"div",
|
|
@@ -11456,6 +11622,10 @@ function Drawer({
|
|
|
11456
11622
|
}
|
|
11457
11623
|
) })
|
|
11458
11624
|
] }) });
|
|
11625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
11626
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { ref: scopeRef, hidden: true }),
|
|
11627
|
+
portalTarget ? (0, import_react_dom2.createPortal)(drawer, portalTarget) : drawer
|
|
11628
|
+
] });
|
|
11459
11629
|
}
|
|
11460
11630
|
|
|
11461
11631
|
// src/components/ui/Popconfirm.tsx
|
|
@@ -21200,7 +21370,8 @@ function ListInner({
|
|
|
21200
21370
|
(e, index) => {
|
|
21201
21371
|
if (!draggable || dragIndex === null) return;
|
|
21202
21372
|
e.preventDefault();
|
|
21203
|
-
|
|
21373
|
+
e.dataTransfer.dropEffect = "move";
|
|
21374
|
+
setDropIndex((prev) => prev === index ? prev : index);
|
|
21204
21375
|
},
|
|
21205
21376
|
[draggable, dragIndex]
|
|
21206
21377
|
);
|
|
@@ -21282,7 +21453,6 @@ function ListInner({
|
|
|
21282
21453
|
onDragOver: (e) => handleDragOver(e, index),
|
|
21283
21454
|
onDrop: (e) => handleDrop(e, index),
|
|
21284
21455
|
onDragEnd: handleDragEnd,
|
|
21285
|
-
onDragLeave: () => setDropIndex(null),
|
|
21286
21456
|
children: [
|
|
21287
21457
|
draggable && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "sg-list-drag-handle", children: "\u283F" }),
|
|
21288
21458
|
renderItem(item, index)
|