@ceed/cds 1.26.0 → 1.27.1
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/components/DataTable/styled.d.ts +2 -1
- package/dist/components/DataTable/types.d.ts +4 -0
- package/dist/components/data-display/DataTable.md +163 -10
- package/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +2 -2
- package/dist/index.cjs +39 -6
- package/dist/index.js +42 -9
- package/framer/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2321,7 +2321,8 @@ var StyledTd = (0, import_joy25.styled)("td")(({ theme }) => ({
|
|
|
2321
2321
|
}));
|
|
2322
2322
|
var MotionSortIcon = (0, import_framer_motion17.motion)(import_ArrowUpwardRounded.default);
|
|
2323
2323
|
var DefaultLoadingOverlay = () => /* @__PURE__ */ import_react19.default.createElement(import_joy25.LinearProgress, { value: 8, variant: "plain" });
|
|
2324
|
-
var
|
|
2324
|
+
var DefaultNoRowsOverlay = () => /* @__PURE__ */ import_react19.default.createElement(import_joy25.Typography, { level: "body-sm", textColor: "text.tertiary" }, "No rows");
|
|
2325
|
+
var Resizer = (ref, targetRef = ref, onResizeStateChange) => /* @__PURE__ */ import_react19.default.createElement(
|
|
2325
2326
|
Box_default,
|
|
2326
2327
|
{
|
|
2327
2328
|
sx: {
|
|
@@ -2336,6 +2337,7 @@ var Resizer = (ref, targetRef = ref) => /* @__PURE__ */ import_react19.default.c
|
|
|
2336
2337
|
onMouseDown: (e) => {
|
|
2337
2338
|
const initialX = e.clientX;
|
|
2338
2339
|
const initialWidth = ref.current?.getBoundingClientRect().width;
|
|
2340
|
+
onResizeStateChange?.(true);
|
|
2339
2341
|
const onMouseMove = (e2) => {
|
|
2340
2342
|
if (initialWidth && initialX) {
|
|
2341
2343
|
ref.current.style.width = `${initialWidth + (e2.clientX - initialX)}px`;
|
|
@@ -2345,6 +2347,7 @@ var Resizer = (ref, targetRef = ref) => /* @__PURE__ */ import_react19.default.c
|
|
|
2345
2347
|
const onMouseUp = () => {
|
|
2346
2348
|
document.removeEventListener("mousemove", onMouseMove);
|
|
2347
2349
|
document.removeEventListener("mouseup", onMouseUp);
|
|
2350
|
+
requestAnimationFrame(() => onResizeStateChange?.(false));
|
|
2348
2351
|
};
|
|
2349
2352
|
document.addEventListener("mousemove", onMouseMove);
|
|
2350
2353
|
document.addEventListener("mouseup", onMouseUp);
|
|
@@ -2932,7 +2935,7 @@ var TextEllipsis = ({ children, lineClamp }) => {
|
|
|
2932
2935
|
ro.observe(element);
|
|
2933
2936
|
return () => ro.disconnect();
|
|
2934
2937
|
}, [children, lineClamp]);
|
|
2935
|
-
return /* @__PURE__ */ import_react24.default.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top"
|
|
2938
|
+
return /* @__PURE__ */ import_react24.default.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top" }, /* @__PURE__ */ import_react24.default.createElement(EllipsisDiv, { ref: textRef, lineClamp }, children));
|
|
2936
2939
|
};
|
|
2937
2940
|
var CellTextEllipsis = ({ children }) => {
|
|
2938
2941
|
const textRef = (0, import_react24.useRef)(null);
|
|
@@ -2995,7 +2998,13 @@ var HeadCell = (props) => {
|
|
|
2995
2998
|
() => `${tableId}_header_${headerName ?? field}`.trim(),
|
|
2996
2999
|
[tableId, headerName, field]
|
|
2997
3000
|
);
|
|
2998
|
-
const
|
|
3001
|
+
const isResizingRef = (0, import_react24.useRef)(false);
|
|
3002
|
+
const resizer = (0, import_react24.useMemo)(
|
|
3003
|
+
() => resizable ?? true ? Resizer(ref, colRef, (isResizing) => {
|
|
3004
|
+
isResizingRef.current = isResizing;
|
|
3005
|
+
}) : null,
|
|
3006
|
+
[resizable, ref, colRef]
|
|
3007
|
+
);
|
|
2999
3008
|
const style = (0, import_react24.useMemo)(
|
|
3000
3009
|
() => ({
|
|
3001
3010
|
width,
|
|
@@ -3069,7 +3078,11 @@ var HeadCell = (props) => {
|
|
|
3069
3078
|
key: field,
|
|
3070
3079
|
style,
|
|
3071
3080
|
onClick: (0, import_react24.useCallback)(
|
|
3072
|
-
(e) =>
|
|
3081
|
+
(e) => {
|
|
3082
|
+
if (isResizingRef.current) return;
|
|
3083
|
+
if (!(e.target instanceof Element) || !e.currentTarget.contains(e.target)) return;
|
|
3084
|
+
sortable && onSortChange?.({ field, currentSort: sort, multiple: e.shiftKey });
|
|
3085
|
+
},
|
|
3073
3086
|
[field, onSortChange, sort, sortable]
|
|
3074
3087
|
),
|
|
3075
3088
|
onMouseEnter: () => setIsHovered(true),
|
|
@@ -4035,9 +4048,15 @@ function Component(props, apiRef) {
|
|
|
4035
4048
|
checkbox: RenderCheckbox = Checkbox_default,
|
|
4036
4049
|
toolbar: Toolbar,
|
|
4037
4050
|
footer: Footer,
|
|
4038
|
-
loadingOverlay: LoadingOverlay = DefaultLoadingOverlay
|
|
4051
|
+
loadingOverlay: LoadingOverlay = DefaultLoadingOverlay,
|
|
4052
|
+
noRowsOverlay: NoRowsOverlay = DefaultNoRowsOverlay
|
|
4053
|
+
} = {},
|
|
4054
|
+
slotProps: {
|
|
4055
|
+
checkbox: checkboxProps = {},
|
|
4056
|
+
toolbar: toolbarProps,
|
|
4057
|
+
background: backgroundProps = {},
|
|
4058
|
+
noRowsOverlay: noRowsOverlayProps = {}
|
|
4039
4059
|
} = {},
|
|
4040
|
-
slotProps: { checkbox: checkboxProps = {}, toolbar: toolbarProps, background: backgroundProps = {} } = {},
|
|
4041
4060
|
stripe,
|
|
4042
4061
|
isTotalSelected: ___________,
|
|
4043
4062
|
...innerProps
|
|
@@ -4081,6 +4100,8 @@ function Component(props, apiRef) {
|
|
|
4081
4100
|
const paginationModel = (0, import_react28.useMemo)(() => ({ page, pageSize }), [page, pageSize]);
|
|
4082
4101
|
const totalSize = virtualizer.getTotalSize();
|
|
4083
4102
|
const virtualizedItems = virtualizer.getVirtualItems();
|
|
4103
|
+
const showNoRowsOverlay = !loading && rowCount === 0;
|
|
4104
|
+
const totalColCount = Math.max(1, columns.length + (checkboxSelection ? 1 : 0));
|
|
4084
4105
|
const getRowClickHandler = (0, import_react28.useCallback)(
|
|
4085
4106
|
(row, rowId) => (e) => {
|
|
4086
4107
|
onRowClick?.({ row, rowId }, e);
|
|
@@ -4372,6 +4393,18 @@ function Component(props, apiRef) {
|
|
|
4372
4393
|
/* @__PURE__ */ import_react28.default.createElement(LoadingOverlay, null)
|
|
4373
4394
|
)
|
|
4374
4395
|
)),
|
|
4396
|
+
showNoRowsOverlay && /* @__PURE__ */ import_react28.default.createElement("tr", null, /* @__PURE__ */ import_react28.default.createElement("td", { colSpan: totalColCount, style: { border: "none" } }, /* @__PURE__ */ import_react28.default.createElement(
|
|
4397
|
+
Box_default,
|
|
4398
|
+
{
|
|
4399
|
+
sx: {
|
|
4400
|
+
display: "flex",
|
|
4401
|
+
alignItems: "center",
|
|
4402
|
+
justifyContent: "center",
|
|
4403
|
+
minHeight: "150px"
|
|
4404
|
+
}
|
|
4405
|
+
},
|
|
4406
|
+
/* @__PURE__ */ import_react28.default.createElement(NoRowsOverlay, { ...noRowsOverlayProps })
|
|
4407
|
+
))),
|
|
4375
4408
|
virtualizedItems.map((virtualizedRow, index) => {
|
|
4376
4409
|
const rowIndex = virtualizedRow.index;
|
|
4377
4410
|
const row = dataInPage[rowIndex];
|
package/dist/index.js
CHANGED
|
@@ -2089,7 +2089,7 @@ var numberFormatter = (value) => "Intl" in window ? new Intl.NumberFormat().form
|
|
|
2089
2089
|
|
|
2090
2090
|
// src/components/DataTable/styled.tsx
|
|
2091
2091
|
import React17 from "react";
|
|
2092
|
-
import { styled as styled8, LinearProgress, buttonClasses, iconButtonClasses } from "@mui/joy";
|
|
2092
|
+
import { styled as styled8, LinearProgress, buttonClasses, iconButtonClasses, Typography as Typography3 } from "@mui/joy";
|
|
2093
2093
|
import { motion as motion17 } from "framer-motion";
|
|
2094
2094
|
import SortIcon from "@mui/icons-material/ArrowUpwardRounded";
|
|
2095
2095
|
var EllipsisDiv = styled8("div", {
|
|
@@ -2195,7 +2195,8 @@ var StyledTd = styled8("td")(({ theme }) => ({
|
|
|
2195
2195
|
}));
|
|
2196
2196
|
var MotionSortIcon = motion17(SortIcon);
|
|
2197
2197
|
var DefaultLoadingOverlay = () => /* @__PURE__ */ React17.createElement(LinearProgress, { value: 8, variant: "plain" });
|
|
2198
|
-
var
|
|
2198
|
+
var DefaultNoRowsOverlay = () => /* @__PURE__ */ React17.createElement(Typography3, { level: "body-sm", textColor: "text.tertiary" }, "No rows");
|
|
2199
|
+
var Resizer = (ref, targetRef = ref, onResizeStateChange) => /* @__PURE__ */ React17.createElement(
|
|
2199
2200
|
Box_default,
|
|
2200
2201
|
{
|
|
2201
2202
|
sx: {
|
|
@@ -2210,6 +2211,7 @@ var Resizer = (ref, targetRef = ref) => /* @__PURE__ */ React17.createElement(
|
|
|
2210
2211
|
onMouseDown: (e) => {
|
|
2211
2212
|
const initialX = e.clientX;
|
|
2212
2213
|
const initialWidth = ref.current?.getBoundingClientRect().width;
|
|
2214
|
+
onResizeStateChange?.(true);
|
|
2213
2215
|
const onMouseMove = (e2) => {
|
|
2214
2216
|
if (initialWidth && initialX) {
|
|
2215
2217
|
ref.current.style.width = `${initialWidth + (e2.clientX - initialX)}px`;
|
|
@@ -2219,6 +2221,7 @@ var Resizer = (ref, targetRef = ref) => /* @__PURE__ */ React17.createElement(
|
|
|
2219
2221
|
const onMouseUp = () => {
|
|
2220
2222
|
document.removeEventListener("mousemove", onMouseMove);
|
|
2221
2223
|
document.removeEventListener("mouseup", onMouseUp);
|
|
2224
|
+
requestAnimationFrame(() => onResizeStateChange?.(false));
|
|
2222
2225
|
};
|
|
2223
2226
|
document.addEventListener("mousemove", onMouseMove);
|
|
2224
2227
|
document.addEventListener("mouseup", onMouseUp);
|
|
@@ -2666,7 +2669,7 @@ var Textarea_default = Textarea;
|
|
|
2666
2669
|
|
|
2667
2670
|
// src/components/Select/Select.tsx
|
|
2668
2671
|
import React20, { useMemo as useMemo7 } from "react";
|
|
2669
|
-
import { Select as JoySelect, Option as JoyOption, ListItemContent as ListItemContent2, Typography as
|
|
2672
|
+
import { Select as JoySelect, Option as JoyOption, ListItemContent as ListItemContent2, Typography as Typography4 } from "@mui/joy";
|
|
2670
2673
|
import { motion as motion20 } from "framer-motion";
|
|
2671
2674
|
var MotionOption = motion20(JoyOption);
|
|
2672
2675
|
var Option = MotionOption;
|
|
@@ -2740,7 +2743,7 @@ function Select(props) {
|
|
|
2740
2743
|
return optionMap.get(selected.value)?.label;
|
|
2741
2744
|
}
|
|
2742
2745
|
},
|
|
2743
|
-
options.map((option) => /* @__PURE__ */ React20.createElement(Option, { key: option.value, value: option.value, disabled: option.disabled }, option.secondaryText ? /* @__PURE__ */ React20.createElement(ListItemContent2, { sx: { gap: 0.5 } }, /* @__PURE__ */ React20.createElement(
|
|
2746
|
+
options.map((option) => /* @__PURE__ */ React20.createElement(Option, { key: option.value, value: option.value, disabled: option.disabled }, option.secondaryText ? /* @__PURE__ */ React20.createElement(ListItemContent2, { sx: { gap: 0.5 } }, /* @__PURE__ */ React20.createElement(Typography4, { level: "inherit" }, option.label), /* @__PURE__ */ React20.createElement(Typography4, { level: secondaryTextLevelMap2[size ?? "md"], textColor: "text.tertiary" }, option.secondaryText)) : option.label))
|
|
2744
2747
|
);
|
|
2745
2748
|
return /* @__PURE__ */ React20.createElement(
|
|
2746
2749
|
FormControl_default,
|
|
@@ -2815,7 +2818,7 @@ var TextEllipsis = ({ children, lineClamp }) => {
|
|
|
2815
2818
|
ro.observe(element);
|
|
2816
2819
|
return () => ro.disconnect();
|
|
2817
2820
|
}, [children, lineClamp]);
|
|
2818
|
-
return /* @__PURE__ */ React22.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top"
|
|
2821
|
+
return /* @__PURE__ */ React22.createElement(Tooltip_default, { title: showTooltip ? children : "", placement: "top" }, /* @__PURE__ */ React22.createElement(EllipsisDiv, { ref: textRef, lineClamp }, children));
|
|
2819
2822
|
};
|
|
2820
2823
|
var CellTextEllipsis = ({ children }) => {
|
|
2821
2824
|
const textRef = useRef5(null);
|
|
@@ -2878,7 +2881,13 @@ var HeadCell = (props) => {
|
|
|
2878
2881
|
() => `${tableId}_header_${headerName ?? field}`.trim(),
|
|
2879
2882
|
[tableId, headerName, field]
|
|
2880
2883
|
);
|
|
2881
|
-
const
|
|
2884
|
+
const isResizingRef = useRef5(false);
|
|
2885
|
+
const resizer = useMemo8(
|
|
2886
|
+
() => resizable ?? true ? Resizer(ref, colRef, (isResizing) => {
|
|
2887
|
+
isResizingRef.current = isResizing;
|
|
2888
|
+
}) : null,
|
|
2889
|
+
[resizable, ref, colRef]
|
|
2890
|
+
);
|
|
2882
2891
|
const style = useMemo8(
|
|
2883
2892
|
() => ({
|
|
2884
2893
|
width,
|
|
@@ -2952,7 +2961,11 @@ var HeadCell = (props) => {
|
|
|
2952
2961
|
key: field,
|
|
2953
2962
|
style,
|
|
2954
2963
|
onClick: useCallback9(
|
|
2955
|
-
(e) =>
|
|
2964
|
+
(e) => {
|
|
2965
|
+
if (isResizingRef.current) return;
|
|
2966
|
+
if (!(e.target instanceof Element) || !e.currentTarget.contains(e.target)) return;
|
|
2967
|
+
sortable && onSortChange?.({ field, currentSort: sort, multiple: e.shiftKey });
|
|
2968
|
+
},
|
|
2956
2969
|
[field, onSortChange, sort, sortable]
|
|
2957
2970
|
),
|
|
2958
2971
|
onMouseEnter: () => setIsHovered(true),
|
|
@@ -3918,9 +3931,15 @@ function Component(props, apiRef) {
|
|
|
3918
3931
|
checkbox: RenderCheckbox = Checkbox_default,
|
|
3919
3932
|
toolbar: Toolbar,
|
|
3920
3933
|
footer: Footer,
|
|
3921
|
-
loadingOverlay: LoadingOverlay = DefaultLoadingOverlay
|
|
3934
|
+
loadingOverlay: LoadingOverlay = DefaultLoadingOverlay,
|
|
3935
|
+
noRowsOverlay: NoRowsOverlay = DefaultNoRowsOverlay
|
|
3936
|
+
} = {},
|
|
3937
|
+
slotProps: {
|
|
3938
|
+
checkbox: checkboxProps = {},
|
|
3939
|
+
toolbar: toolbarProps,
|
|
3940
|
+
background: backgroundProps = {},
|
|
3941
|
+
noRowsOverlay: noRowsOverlayProps = {}
|
|
3922
3942
|
} = {},
|
|
3923
|
-
slotProps: { checkbox: checkboxProps = {}, toolbar: toolbarProps, background: backgroundProps = {} } = {},
|
|
3924
3943
|
stripe,
|
|
3925
3944
|
isTotalSelected: ___________,
|
|
3926
3945
|
...innerProps
|
|
@@ -3964,6 +3983,8 @@ function Component(props, apiRef) {
|
|
|
3964
3983
|
const paginationModel = useMemo10(() => ({ page, pageSize }), [page, pageSize]);
|
|
3965
3984
|
const totalSize = virtualizer.getTotalSize();
|
|
3966
3985
|
const virtualizedItems = virtualizer.getVirtualItems();
|
|
3986
|
+
const showNoRowsOverlay = !loading && rowCount === 0;
|
|
3987
|
+
const totalColCount = Math.max(1, columns.length + (checkboxSelection ? 1 : 0));
|
|
3967
3988
|
const getRowClickHandler = useCallback12(
|
|
3968
3989
|
(row, rowId) => (e) => {
|
|
3969
3990
|
onRowClick?.({ row, rowId }, e);
|
|
@@ -4255,6 +4276,18 @@ function Component(props, apiRef) {
|
|
|
4255
4276
|
/* @__PURE__ */ React25.createElement(LoadingOverlay, null)
|
|
4256
4277
|
)
|
|
4257
4278
|
)),
|
|
4279
|
+
showNoRowsOverlay && /* @__PURE__ */ React25.createElement("tr", null, /* @__PURE__ */ React25.createElement("td", { colSpan: totalColCount, style: { border: "none" } }, /* @__PURE__ */ React25.createElement(
|
|
4280
|
+
Box_default,
|
|
4281
|
+
{
|
|
4282
|
+
sx: {
|
|
4283
|
+
display: "flex",
|
|
4284
|
+
alignItems: "center",
|
|
4285
|
+
justifyContent: "center",
|
|
4286
|
+
minHeight: "150px"
|
|
4287
|
+
}
|
|
4288
|
+
},
|
|
4289
|
+
/* @__PURE__ */ React25.createElement(NoRowsOverlay, { ...noRowsOverlayProps })
|
|
4290
|
+
))),
|
|
4258
4291
|
virtualizedItems.map((virtualizedRow, index) => {
|
|
4259
4292
|
const rowIndex = virtualizedRow.index;
|
|
4260
4293
|
const row = dataInPage[rowIndex];
|