@stella-source/stellasource-dsl 0.2.3 → 0.2.7
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/cjs/index.js +180 -87
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Table/Table.d.ts +1 -1
- package/dist/cjs/types/components/Table/TableComponents/EmptyTableState.d.ts +13 -0
- package/dist/cjs/types/components/Table/styles.d.ts +9 -2
- package/dist/cjs/types/components/Table/types.d.ts +6 -0
- package/dist/cjs/types/components/TableUnitsAndTotals/types.d.ts +2 -2
- package/dist/cjs/types/shared/tokens/whiteLabel/TransformValuesForOverridesUtil.d.ts +4 -0
- package/dist/cjs/types/shared/tokens/whiteLabel/WhiteLabelCSSOverrides.d.ts +9 -0
- package/dist/cjs/types/shared/utils/numberHelpers.d.ts +0 -1
- package/dist/esm/index.esm.js +180 -87
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/types/components/Table/Table.d.ts +1 -1
- package/dist/esm/types/components/Table/TableComponents/EmptyTableState.d.ts +13 -0
- package/dist/esm/types/components/Table/styles.d.ts +9 -2
- package/dist/esm/types/components/Table/types.d.ts +6 -0
- package/dist/esm/types/components/TableUnitsAndTotals/types.d.ts +2 -2
- package/dist/esm/types/shared/tokens/whiteLabel/TransformValuesForOverridesUtil.d.ts +4 -0
- package/dist/esm/types/shared/tokens/whiteLabel/WhiteLabelCSSOverrides.d.ts +9 -0
- package/dist/esm/types/shared/utils/numberHelpers.d.ts +0 -1
- package/dist/index.d.ts +9 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -3434,7 +3434,7 @@ var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
|
|
|
3434
3434
|
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
|
|
3435
3435
|
* exposing only those methods and properties that are defined in the spec.
|
|
3436
3436
|
*/
|
|
3437
|
-
var ResizeObserver$
|
|
3437
|
+
var ResizeObserver$2 = /** @class */ (function () {
|
|
3438
3438
|
/**
|
|
3439
3439
|
* Creates a new instance of ResizeObserver.
|
|
3440
3440
|
*
|
|
@@ -3460,7 +3460,7 @@ var ResizeObserver$1 = /** @class */ (function () {
|
|
|
3460
3460
|
'unobserve',
|
|
3461
3461
|
'disconnect'
|
|
3462
3462
|
].forEach(function (method) {
|
|
3463
|
-
ResizeObserver$
|
|
3463
|
+
ResizeObserver$2.prototype[method] = function () {
|
|
3464
3464
|
var _a;
|
|
3465
3465
|
return (_a = observers.get(this))[method].apply(_a, arguments);
|
|
3466
3466
|
};
|
|
@@ -3471,7 +3471,7 @@ var index = (function () {
|
|
|
3471
3471
|
if (typeof global$1.ResizeObserver !== 'undefined') {
|
|
3472
3472
|
return global$1.ResizeObserver;
|
|
3473
3473
|
}
|
|
3474
|
-
return ResizeObserver$
|
|
3474
|
+
return ResizeObserver$2;
|
|
3475
3475
|
})();
|
|
3476
3476
|
|
|
3477
3477
|
// =============================== Const ===============================
|
|
@@ -3711,7 +3711,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3711
3711
|
}
|
|
3712
3712
|
|
|
3713
3713
|
var INTERNAL_PREFIX_KEY = 'rc-observer-key';
|
|
3714
|
-
function ResizeObserver(props, ref) {
|
|
3714
|
+
function ResizeObserver$1(props, ref) {
|
|
3715
3715
|
var children = props.children;
|
|
3716
3716
|
var childNodes = typeof children === 'function' ? [children] : toArray$2(children);
|
|
3717
3717
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -3729,7 +3729,7 @@ function ResizeObserver(props, ref) {
|
|
|
3729
3729
|
}), child);
|
|
3730
3730
|
});
|
|
3731
3731
|
}
|
|
3732
|
-
var RefResizeObserver = /*#__PURE__*/a__namespace.forwardRef(ResizeObserver);
|
|
3732
|
+
var RefResizeObserver = /*#__PURE__*/a__namespace.forwardRef(ResizeObserver$1);
|
|
3733
3733
|
if (process.env.NODE_ENV !== 'production') {
|
|
3734
3734
|
RefResizeObserver.displayName = 'ResizeObserver';
|
|
3735
3735
|
}
|
|
@@ -16799,7 +16799,6 @@ const variantSelector = (variant) => {
|
|
|
16799
16799
|
}
|
|
16800
16800
|
|
|
16801
16801
|
&:disabled {
|
|
16802
|
-
background-color: var(--DSL-button-st-background-disabled);
|
|
16803
16802
|
border: 1px solid var(--DSL-button-disabled);
|
|
16804
16803
|
color: var(--DSL-button-disabled);
|
|
16805
16804
|
& svg {
|
|
@@ -16833,7 +16832,6 @@ const variantSelector = (variant) => {
|
|
|
16833
16832
|
}
|
|
16834
16833
|
|
|
16835
16834
|
&:disabled {
|
|
16836
|
-
background-color: var(--DSL-button-st-background-disabled);
|
|
16837
16835
|
color: var(--DSL-button-disabled);
|
|
16838
16836
|
& svg {
|
|
16839
16837
|
fill: var(--DSL-button-disabled);
|
|
@@ -16873,6 +16871,7 @@ const ButtonComponent = styled.button.attrs({
|
|
|
16873
16871
|
}
|
|
16874
16872
|
|
|
16875
16873
|
/* Button CSS Variables */
|
|
16874
|
+
/* p = primary, st = secondary, tertiary */
|
|
16876
16875
|
--DSL-button-branding: ${Styles.color.core.primary};
|
|
16877
16876
|
--DSL-button-hover: ${Styles.color.blue.darkNavy};
|
|
16878
16877
|
--DSL-button-active: ${Styles.color.blue.darkNavy};
|
|
@@ -17037,7 +17036,7 @@ const IconContainer = styled.div `
|
|
|
17037
17036
|
`;
|
|
17038
17037
|
|
|
17039
17038
|
const TextFieldContainer = ({ id, label, children, tooltipText, endIcon, className, rightCategory, leftCategory, helperText, dataTestId, helperTextAffectLayout = true, disabled = false, hideLabel = false, isLoading = false, hasError = false, isRequired = false, }) => {
|
|
17040
|
-
return (a$j.createElement(Wrapper, { "data-
|
|
17039
|
+
return (a$j.createElement(Wrapper, { "data-testid": dataTestId, className: className },
|
|
17041
17040
|
a$j.createElement(Label, { tooltipText: tooltipText, required: isRequired, labelValue: label, hideLabel: hideLabel, id: `${id}-label`, htmlFor: `${id}-text-field` }),
|
|
17042
17041
|
a$j.createElement(TextFieldWrapper, { id: id, "$hasError": hasError, "$isDisabled": disabled, "$isLoading": isLoading, "data-testid": "text-input-wrapper" },
|
|
17043
17042
|
leftCategory && a$j.createElement(Category, null, leftCategory),
|
|
@@ -17127,19 +17126,6 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
|
|
|
17127
17126
|
})}${decimalEnding ? "." : ""}${decimalZero ? "0" : ""}`
|
|
17128
17127
|
: "";
|
|
17129
17128
|
};
|
|
17130
|
-
const formatNumberWithDecimals = (num, decimalPlaces = 2, isCurrency = false) => {
|
|
17131
|
-
if (num === null || num === undefined || num === "")
|
|
17132
|
-
return "";
|
|
17133
|
-
const parsed = Number(num);
|
|
17134
|
-
if (isNaN(parsed))
|
|
17135
|
-
return "";
|
|
17136
|
-
return parsed.toLocaleString("en-US", {
|
|
17137
|
-
style: isCurrency ? "currency" : "decimal",
|
|
17138
|
-
currency: isCurrency ? "USD" : undefined,
|
|
17139
|
-
minimumFractionDigits: decimalPlaces,
|
|
17140
|
-
maximumFractionDigits: decimalPlaces,
|
|
17141
|
-
});
|
|
17142
|
-
};
|
|
17143
17129
|
|
|
17144
17130
|
const NumberInput = ({ id, className, htmlProps, leftCategory, rightCategory, label, onChange, onBlur, onFocus, value, isRequired, maxLength, tooltipText, helperText, endIcon, placeholder = "0", textAlign = "left", isTruncated = false, helperTextAffectLayout = true, hideLabel = false, disabled = false, isLoading = false, hasError = false, thousandSeparator = true, decimalPlaces = 0, allowNegativeNumbers = false, ariaDescribedBy, }) => {
|
|
17145
17131
|
const containerProps = {
|
|
@@ -20643,8 +20629,8 @@ const SelectCaret = styled(StellaIcon) `
|
|
|
20643
20629
|
position: absolute;
|
|
20644
20630
|
right: 0;
|
|
20645
20631
|
pointer-events: none;
|
|
20646
|
-
color: ${Styles.color.
|
|
20647
|
-
fill: ${Styles.color.
|
|
20632
|
+
color: ${Styles.color.core.primary};
|
|
20633
|
+
fill: ${Styles.color.core.primary};
|
|
20648
20634
|
transform: rotate(180deg);
|
|
20649
20635
|
`;
|
|
20650
20636
|
const RowInfo = styled.div `
|
|
@@ -20762,11 +20748,11 @@ const HeaderCell = styled.th `
|
|
|
20762
20748
|
: "unset"};
|
|
20763
20749
|
z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 2 : 1};
|
|
20764
20750
|
text-align: inherit;
|
|
20765
|
-
padding:
|
|
20751
|
+
padding: 0px 12px;
|
|
20766
20752
|
font-weight: 400;
|
|
20767
20753
|
font-size: 14px;
|
|
20768
20754
|
color: ${Styles.color.grey.charcoal};
|
|
20769
|
-
border-bottom: 1px solid ${Styles.color.grey.
|
|
20755
|
+
border-bottom: 1px solid ${Styles.color.grey.light};
|
|
20770
20756
|
background-color: ${Styles.color.grey.pale};
|
|
20771
20757
|
transition: box-shadow 0.3s ease-out;
|
|
20772
20758
|
& button {
|
|
@@ -20793,6 +20779,7 @@ const HeaderCellPosition = styled.div `
|
|
|
20793
20779
|
`;
|
|
20794
20780
|
const TableWrapper = styled.div `
|
|
20795
20781
|
width: 100%;
|
|
20782
|
+
position: relative;
|
|
20796
20783
|
overflow-x: hidden;
|
|
20797
20784
|
border: 1px solid ${Styles.color.grey.light};
|
|
20798
20785
|
border-radius: 5px;
|
|
@@ -20801,7 +20788,8 @@ const TableWrapper = styled.div `
|
|
|
20801
20788
|
`;
|
|
20802
20789
|
const TableWrapperScroll = styled.div `
|
|
20803
20790
|
width: 100%;
|
|
20804
|
-
overflow-x: ${({ $
|
|
20791
|
+
overflow-x: ${({ $stopScroll }) => ($stopScroll ? "hidden" : "auto")};
|
|
20792
|
+
overflow-y: hidden;
|
|
20805
20793
|
`;
|
|
20806
20794
|
const StyledTable = styled.table `
|
|
20807
20795
|
width: 100%;
|
|
@@ -20840,6 +20828,11 @@ const HeaderRow = styled.tr `
|
|
|
20840
20828
|
const CellRow = styled.tr `
|
|
20841
20829
|
min-height: 50px;
|
|
20842
20830
|
height: 50px;
|
|
20831
|
+
&:hover {
|
|
20832
|
+
& > td {
|
|
20833
|
+
background-color: ${Styles.color.blue.pale};
|
|
20834
|
+
}
|
|
20835
|
+
}
|
|
20843
20836
|
`;
|
|
20844
20837
|
const FilterMenu = styled.div `
|
|
20845
20838
|
position: absolute;
|
|
@@ -20880,10 +20873,10 @@ const BodyCell = styled.td `
|
|
|
20880
20873
|
: "unset"};
|
|
20881
20874
|
z-index: ${({ $isPinnedLeft, $isPinnedRight }) => $isPinnedLeft || $isPinnedRight ? 1 : 0};
|
|
20882
20875
|
background: white;
|
|
20883
|
-
padding:
|
|
20876
|
+
padding: 0px 12px;
|
|
20884
20877
|
font-size: 12px;
|
|
20885
20878
|
color: ${Styles.color.grey.charcoal};
|
|
20886
|
-
border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.
|
|
20879
|
+
border-bottom: ${({ $isLastRow }) => $isLastRow ? "none" : `1px solid ${Styles.color.grey.light}`};
|
|
20887
20880
|
transition: box-shadow 0.3s ease-out;
|
|
20888
20881
|
`;
|
|
20889
20882
|
const MenuButton = styled.button `
|
|
@@ -21031,12 +21024,57 @@ const LoadingShimmer = styled.div `
|
|
|
21031
21024
|
}
|
|
21032
21025
|
`;
|
|
21033
21026
|
const CustomPagination = styled(Pagination) `
|
|
21034
|
-
border-top: 1px solid ${Styles.color.grey.
|
|
21027
|
+
border-top: 1px solid ${Styles.color.grey.light};
|
|
21035
21028
|
`;
|
|
21036
21029
|
const KebabAlign = styled.div `
|
|
21037
21030
|
display: flex;
|
|
21038
21031
|
justify-content: end;
|
|
21039
21032
|
`;
|
|
21033
|
+
// EmptyTableState
|
|
21034
|
+
const EmptyTableCell = styled.td `
|
|
21035
|
+
padding: 10rem;
|
|
21036
|
+
background-color: white;
|
|
21037
|
+
`;
|
|
21038
|
+
const EmptyTableSection = styled.section `
|
|
21039
|
+
width: ${({ $size }) => ($size === "small" ? "360px" : "450px")};
|
|
21040
|
+
display: flex;
|
|
21041
|
+
flex-direction: column;
|
|
21042
|
+
justify-content: center;
|
|
21043
|
+
align-items: center;
|
|
21044
|
+
position: absolute;
|
|
21045
|
+
gap: 20px;
|
|
21046
|
+
top: 50px;
|
|
21047
|
+
left: 0;
|
|
21048
|
+
right: 0;
|
|
21049
|
+
margin: 80px auto 0;
|
|
21050
|
+
`;
|
|
21051
|
+
const EmptyTableHeader = styled.p `
|
|
21052
|
+
display: flex;
|
|
21053
|
+
justify-content: center;
|
|
21054
|
+
align-items: center;
|
|
21055
|
+
color: ${Styles.color.grey.smoke};
|
|
21056
|
+
font-size: 22px;
|
|
21057
|
+
font-weight: 400;
|
|
21058
|
+
text-align: center;
|
|
21059
|
+
line-height: 22px;
|
|
21060
|
+
margin-bottom: 0px;
|
|
21061
|
+
`;
|
|
21062
|
+
const EmptyTableSubHeader = styled.p `
|
|
21063
|
+
display: flex;
|
|
21064
|
+
justify-content: center;
|
|
21065
|
+
align-items: center;
|
|
21066
|
+
color: ${Styles.color.grey.shadow};
|
|
21067
|
+
font-size: 18px;
|
|
21068
|
+
text-align: center;
|
|
21069
|
+
font-weight: 400;
|
|
21070
|
+
margin-top: 0px;
|
|
21071
|
+
`;
|
|
21072
|
+
const ClearFilterButtonRow = styled.div `
|
|
21073
|
+
display: "flex";
|
|
21074
|
+
justify-content: "center";
|
|
21075
|
+
align-items: "center";
|
|
21076
|
+
text-align: "center";
|
|
21077
|
+
`;
|
|
21040
21078
|
|
|
21041
21079
|
const IndeterminateCheckbox = ({ isIndeterminate, isChecked, onChange, }) => {
|
|
21042
21080
|
const ref = a$j.useRef(null);
|
|
@@ -21058,7 +21096,11 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21058
21096
|
const [coords, setCoords] = a$j.useState({ top: 0, left: 0 });
|
|
21059
21097
|
const [tempFilters, setTempFilters] = a$j.useState([]);
|
|
21060
21098
|
const [currentAppliedFilters, setCurrentAppliedFilters] = a$j.useState([]);
|
|
21099
|
+
const [filterOptions, setFilterOptions] = a$j.useState([]);
|
|
21061
21100
|
const [textAlign, setTextAlign] = a$j.useState("left");
|
|
21101
|
+
a$j.useEffect(() => {
|
|
21102
|
+
setFilterOptions(meta?.filterOptions || []);
|
|
21103
|
+
}, [meta]);
|
|
21062
21104
|
const toggleMenu = (e) => {
|
|
21063
21105
|
e.stopPropagation();
|
|
21064
21106
|
if (buttonRef.current) {
|
|
@@ -21083,7 +21125,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21083
21125
|
const insideButton = !!buttonRef.current?.contains(target);
|
|
21084
21126
|
const insideMenu = !!menuRef.current?.contains(target);
|
|
21085
21127
|
if (!insideButton && !insideMenu) {
|
|
21086
|
-
setTempFilters(currentAppliedFilters);
|
|
21128
|
+
setTempFilters(filters?.[header.id] || currentAppliedFilters);
|
|
21087
21129
|
showFilterMenu(false);
|
|
21088
21130
|
}
|
|
21089
21131
|
};
|
|
@@ -21115,7 +21157,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21115
21157
|
a$j.createElement(HeaderCellPosition, { style: {
|
|
21116
21158
|
justifyContent: textAlign === "left" ? "start" : "end",
|
|
21117
21159
|
} },
|
|
21118
|
-
textAlign === "left" && (a$j.createElement("span",
|
|
21160
|
+
textAlign === "left" && (a$j.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))),
|
|
21119
21161
|
header.column.getCanFilter() && (a$j.createElement("div", { style: {
|
|
21120
21162
|
display: "flex",
|
|
21121
21163
|
alignItems: "center",
|
|
@@ -21142,7 +21184,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21142
21184
|
} }),
|
|
21143
21185
|
a$j.createElement(FilterBoxLabel, { htmlFor: "all-checkbox" }, "Select All"))),
|
|
21144
21186
|
(serverSide
|
|
21145
|
-
?
|
|
21187
|
+
? filterOptions
|
|
21146
21188
|
: Array.from(header.column.getFacetedUniqueValues().keys()))?.map((item) => {
|
|
21147
21189
|
if (meta?.singleSelect) {
|
|
21148
21190
|
return (a$j.createElement(MenuItemOption, { key: item, id: `${item}-button`, onClick: () => {
|
|
@@ -21177,7 +21219,7 @@ const TableHeaderCell = ({ header, serverSide, filters, sorting, scrollPosition,
|
|
|
21177
21219
|
setCurrentAppliedFilters([]);
|
|
21178
21220
|
} }, "Clear Filter"))), document.body))),
|
|
21179
21221
|
header.column.getCanSort() && (a$j.createElement(SortButton, { className: "icon", iconName: "sort", ariaLabel: "Sort Button", variant: "tertiary", "$active": sorting.some((s) => s.id === header.column.id), "$sort": column.getIsSorted(), onClick: (e) => header.column.getToggleSortingHandler()?.(e) })),
|
|
21180
|
-
textAlign === "right" && (a$j.createElement("span",
|
|
21222
|
+
textAlign === "right" && (a$j.createElement("span", { style: { fontWeight: 600 } }, flexRender(columnDef.header, header.getContext()))))));
|
|
21181
21223
|
};
|
|
21182
21224
|
|
|
21183
21225
|
const RowOptions = ({ row, selectionMenuItems }) => {
|
|
@@ -21222,12 +21264,21 @@ const RowOptions = ({ row, selectionMenuItems }) => {
|
|
|
21222
21264
|
})), document.body)));
|
|
21223
21265
|
};
|
|
21224
21266
|
|
|
21267
|
+
const EmptyTableState = ({ id, className, header, subHeader, showClearFilterButton, colSpan, size = "large", onClearFilters, }) => {
|
|
21268
|
+
return (a$j.createElement("tr", null,
|
|
21269
|
+
a$j.createElement(EmptyTableCell, { colSpan: colSpan },
|
|
21270
|
+
a$j.createElement(EmptyTableSection, { "$size": size, id: id, className: className },
|
|
21271
|
+
a$j.createElement(EmptyTableHeader, null, header),
|
|
21272
|
+
a$j.createElement(EmptyTableSubHeader, null, subHeader),
|
|
21273
|
+
a$j.createElement(ClearFilterButtonRow, null, showClearFilterButton && (a$j.createElement(StellaButton, { label: "Clear Filters", onClick: () => onClearFilters?.(), variant: "secondary" })))))));
|
|
21274
|
+
};
|
|
21275
|
+
|
|
21225
21276
|
// DataTable.tsx
|
|
21226
21277
|
function Table({ columns, data, isLoading, serverSide = false, onPageChange, onSortChange, onFilterChange, onRowSelect, rowStatuses, showSelection = false, showRowOptions = false, showPagination = true, variant, paginationDetails = {
|
|
21227
21278
|
startingPage: 1,
|
|
21228
21279
|
rowsPerPage: 10,
|
|
21229
21280
|
totalRows: data.length,
|
|
21230
|
-
}, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, }) {
|
|
21281
|
+
}, selectionMenuItems, dataAuto, dataTestId, id, className, htmlProps, resetTrigger, emptyTableState, }) {
|
|
21231
21282
|
const [rowSelection, setRowSelection] = a$j.useState({});
|
|
21232
21283
|
const [selectedRows] = a$j.useState({});
|
|
21233
21284
|
const [pageIndex, setPageIndex] = a$j.useState(paginationDetails?.startingPage);
|
|
@@ -21235,6 +21286,8 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21235
21286
|
pageIndex: paginationDetails?.startingPage - 1,
|
|
21236
21287
|
pageSize: paginationDetails?.rowsPerPage || 10,
|
|
21237
21288
|
});
|
|
21289
|
+
const [localData, setLocalData] = a$j.useState(data);
|
|
21290
|
+
const [localColumns, setLocalColumns] = a$j.useState(columns);
|
|
21238
21291
|
const [totalData, setTotalData] = a$j.useState(paginationDetails?.totalRows);
|
|
21239
21292
|
const [sorting, setSorting] = a$j.useState([]);
|
|
21240
21293
|
const [filters, setFilters] = a$j.useState({});
|
|
@@ -21253,20 +21306,51 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21253
21306
|
}, [rowStatuses]);
|
|
21254
21307
|
a$j.useEffect(() => {
|
|
21255
21308
|
setTotalData(paginationDetails?.totalRows);
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
|
|
21309
|
+
setPagination({
|
|
21310
|
+
pageIndex: paginationDetails?.startingPage - 1,
|
|
21311
|
+
pageSize: paginationDetails?.rowsPerPage || 10,
|
|
21312
|
+
});
|
|
21313
|
+
setLocalColumns(columns);
|
|
21314
|
+
setLocalData(data);
|
|
21315
|
+
}, [paginationDetails, data, columns]);
|
|
21316
|
+
a$j.useLayoutEffect(() => {
|
|
21317
|
+
const el = scrollRef.current;
|
|
21259
21318
|
if (!el)
|
|
21260
21319
|
return;
|
|
21261
|
-
|
|
21262
|
-
|
|
21263
|
-
const
|
|
21320
|
+
let raf = 0;
|
|
21321
|
+
const update = () => {
|
|
21322
|
+
const maxScrollLeft = Math.max(0, el.scrollWidth - el.clientWidth);
|
|
21323
|
+
const hasOverflow = maxScrollLeft > 1; // tolerance for rounding
|
|
21324
|
+
let atLeft = el.scrollLeft <= 0;
|
|
21325
|
+
let atRight = el.scrollLeft >= maxScrollLeft - 1;
|
|
21326
|
+
if (!hasOverflow) {
|
|
21327
|
+
atLeft = true;
|
|
21328
|
+
atRight = true;
|
|
21329
|
+
}
|
|
21264
21330
|
setScrollState({ atLeft, atRight });
|
|
21265
21331
|
};
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21269
|
-
|
|
21332
|
+
const schedule = () => {
|
|
21333
|
+
cancelAnimationFrame(raf);
|
|
21334
|
+
raf = requestAnimationFrame(update);
|
|
21335
|
+
};
|
|
21336
|
+
// Listen to scroll
|
|
21337
|
+
el.addEventListener("scroll", schedule);
|
|
21338
|
+
// Recalculate when sizes change
|
|
21339
|
+
const ro = new ResizeObserver(schedule);
|
|
21340
|
+
ro.observe(el);
|
|
21341
|
+
const tableEl = el.querySelector("table");
|
|
21342
|
+
if (tableEl)
|
|
21343
|
+
ro.observe(tableEl);
|
|
21344
|
+
window.addEventListener("resize", schedule);
|
|
21345
|
+
// Initial measurement after layout
|
|
21346
|
+
schedule();
|
|
21347
|
+
return () => {
|
|
21348
|
+
el.removeEventListener("scroll", schedule);
|
|
21349
|
+
window.removeEventListener("resize", schedule);
|
|
21350
|
+
ro.disconnect();
|
|
21351
|
+
cancelAnimationFrame(raf);
|
|
21352
|
+
};
|
|
21353
|
+
}, []);
|
|
21270
21354
|
const handleInputChange = (rowId, field, value) => {
|
|
21271
21355
|
setRowState((prev) => ({
|
|
21272
21356
|
...prev,
|
|
@@ -21287,7 +21371,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21287
21371
|
size: 20,
|
|
21288
21372
|
});
|
|
21289
21373
|
}
|
|
21290
|
-
cols.push(...
|
|
21374
|
+
cols.push(...localColumns);
|
|
21291
21375
|
if (showRowOptions) {
|
|
21292
21376
|
cols.push({
|
|
21293
21377
|
id: "options",
|
|
@@ -21299,9 +21383,16 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21299
21383
|
});
|
|
21300
21384
|
}
|
|
21301
21385
|
return cols;
|
|
21302
|
-
}, [
|
|
21386
|
+
}, [
|
|
21387
|
+
localColumns,
|
|
21388
|
+
selectedRows,
|
|
21389
|
+
localData,
|
|
21390
|
+
onRowSelect,
|
|
21391
|
+
showSelection,
|
|
21392
|
+
showRowOptions,
|
|
21393
|
+
]);
|
|
21303
21394
|
const table = useReactTable({
|
|
21304
|
-
data,
|
|
21395
|
+
data: localData,
|
|
21305
21396
|
columns: enhancedColumns,
|
|
21306
21397
|
state: {
|
|
21307
21398
|
pagination,
|
|
@@ -21374,7 +21465,7 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21374
21465
|
});
|
|
21375
21466
|
};
|
|
21376
21467
|
return (a$j.createElement(TableWrapper, { className: className, id: id, "data-testid": dataTestId, "data-auto": dataAuto },
|
|
21377
|
-
a$j.createElement(TableWrapperScroll, { "$
|
|
21468
|
+
a$j.createElement(TableWrapperScroll, { "$stopScroll": Object.values(filterMenuOpen).some((value) => value), ref: scrollRef }, isLoading ? (a$j.createElement("div", null,
|
|
21378
21469
|
a$j.createElement("div", { style: {
|
|
21379
21470
|
width: "100%",
|
|
21380
21471
|
maxWidth: "100%",
|
|
@@ -21409,39 +21500,45 @@ function Table({ columns, data, isLoading, serverSide = false, onPageChange, onS
|
|
|
21409
21500
|
}));
|
|
21410
21501
|
} }));
|
|
21411
21502
|
}))))),
|
|
21412
|
-
a$j.createElement("tbody", null,
|
|
21413
|
-
|
|
21414
|
-
|
|
21415
|
-
|
|
21416
|
-
|
|
21417
|
-
|
|
21418
|
-
|
|
21419
|
-
|
|
21420
|
-
|
|
21421
|
-
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
|
|
21426
|
-
|
|
21427
|
-
|
|
21428
|
-
|
|
21429
|
-
|
|
21430
|
-
cell.column.getIsPinned() === "right"
|
|
21503
|
+
a$j.createElement("tbody", null,
|
|
21504
|
+
table.getRowModel().rows.length === 0 && (a$j.createElement(EmptyTableState, { header: emptyTableState.header, subHeader: emptyTableState.subHeader, showClearFilterButton: emptyTableState.showClearFilterButton, onClearFilters: resetTable, colSpan: table.getVisibleLeafColumns().length, size: "large" })),
|
|
21505
|
+
table.getRowModel().rows.map((row) => (a$j.createElement(CellRow, { key: row.id }, row.getVisibleCells().map((cell) => {
|
|
21506
|
+
const value = flexRender(cell.column.columnDef.cell, {
|
|
21507
|
+
...cell.getContext(),
|
|
21508
|
+
localValue: rowState[row.id]?.[cell.column.id],
|
|
21509
|
+
onLocalChange: (val) => handleInputChange(row.id, cell.column.id, val),
|
|
21510
|
+
});
|
|
21511
|
+
const meta = cell.column.columnDef.meta;
|
|
21512
|
+
return (a$j.createElement(BodyCell, { key: cell.id, style: {
|
|
21513
|
+
width: cell.column.getSize(),
|
|
21514
|
+
textAlign: meta?.cellAlign ||
|
|
21515
|
+
(typeof cell.getValue() === "number" ||
|
|
21516
|
+
meta?.dataType === "number"
|
|
21517
|
+
? "right"
|
|
21518
|
+
: "left"),
|
|
21519
|
+
boxShadow: scrollState.atLeft &&
|
|
21520
|
+
cell.column.getIsPinned() === "left"
|
|
21431
21521
|
? "none"
|
|
21432
|
-
:
|
|
21433
|
-
|
|
21434
|
-
|
|
21435
|
-
|
|
21436
|
-
|
|
21437
|
-
|
|
21438
|
-
|
|
21439
|
-
|
|
21440
|
-
|
|
21441
|
-
|
|
21442
|
-
|
|
21443
|
-
|
|
21444
|
-
|
|
21522
|
+
: scrollState.atRight &&
|
|
21523
|
+
cell.column.getIsPinned() === "right"
|
|
21524
|
+
? "none"
|
|
21525
|
+
: undefined,
|
|
21526
|
+
backgroundColor: table
|
|
21527
|
+
.getSelectedRowModel()
|
|
21528
|
+
.rows.find((r) => r.id === row.id)
|
|
21529
|
+
? "#EBF0FA"
|
|
21530
|
+
: rowStatusesState?.[row.id] === "action-pending"
|
|
21531
|
+
? "#FFFDEB"
|
|
21532
|
+
: rowStatusesState?.[row.id] === "completed"
|
|
21533
|
+
? "#F5F5F5"
|
|
21534
|
+
: "",
|
|
21535
|
+
}, "$isPinnedLeft": cell.column.getIsPinned() === "left", "$isPinnedRight": cell.column.getIsPinned() === "right", "$columnInfo": cell.column, "$isLastRow": serverSide
|
|
21536
|
+
? row.index === table.getRowModel().rows.length - 1
|
|
21537
|
+
: row.index -
|
|
21538
|
+
pagination.pageSize * pagination.pageIndex ===
|
|
21539
|
+
table.getRowModel().rows.length - 1 }, value));
|
|
21540
|
+
})))))))),
|
|
21541
|
+
showPagination && paginationDetails?.totalRows > 0 && (a$j.createElement(CustomPagination, { totalRows: serverSide ? totalData : table.getFilteredRowModel().rows.length, isLoading: isLoading, rowsPerPage: paginationDetails?.rowsPerPage, startingPage: pageIndex, onPageChange: (page, pageSize) => {
|
|
21445
21542
|
setPageIndex(page);
|
|
21446
21543
|
setPagination((prev) => ({
|
|
21447
21544
|
...prev,
|
|
@@ -21566,13 +21663,9 @@ const SubHeaderText = styled.span `
|
|
|
21566
21663
|
const TableUnitsAndTotals = ({ id, className, value, subValue, variant, leftCategory = exports.TableUnitsAndTotalsLeftCategory.US_CURRENCY, rightCategory, }) => {
|
|
21567
21664
|
const isWeight = variant === exports.QuoteVariants.TOTAL_WEIGHT;
|
|
21568
21665
|
const leftCategoryValue = isWeight ? "" : leftCategory;
|
|
21569
|
-
const header =
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
const subHeader = subValue !== undefined
|
|
21573
|
-
? (leftCategoryValue ?? "") +
|
|
21574
|
-
formatNumberWithDecimals(subValue, 3, false) +
|
|
21575
|
-
(rightCategory ? ` ${rightCategory}` : "")
|
|
21666
|
+
const header = `${leftCategoryValue ?? ""}${value} ${rightCategory && isWeight ? ` ${rightCategory}` : ""}`;
|
|
21667
|
+
const subHeader = subValue
|
|
21668
|
+
? `${leftCategoryValue ?? ""}${subValue} ${rightCategory ? ` ${rightCategory}` : ""}`
|
|
21576
21669
|
: undefined;
|
|
21577
21670
|
return (a$j.createElement(Container, { id: id, className: className },
|
|
21578
21671
|
a$j.createElement(Column, { "$align": "right" },
|