@ssa-ui-kit/core 2.2.1 → 2.2.2
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NestedTableRowContextType } from './types';
|
|
2
2
|
export declare const NestedTableRowContext: import("react").Context<NestedTableRowContextType>;
|
|
3
|
-
export declare const NestedTableRowProvider: ({ children, isCollapsed
|
|
3
|
+
export declare const NestedTableRowProvider: ({ children, isCollapsed, isSubHeader: isSubHeaderInput, childRowsCount: childRowsCountInput, setIsCollapsed, }: React.PropsWithChildren<NestedTableRowContextType>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -12277,20 +12277,20 @@ const LinksTabBar = ({
|
|
|
12277
12277
|
const NestedTableRowContext = /*#__PURE__*/(0,external_react_namespaceObject.createContext)({
|
|
12278
12278
|
childRowsCount: 0,
|
|
12279
12279
|
isCollapsed: false,
|
|
12280
|
-
isSubHeader: false
|
|
12280
|
+
isSubHeader: false,
|
|
12281
|
+
setIsCollapsed: () => {
|
|
12282
|
+
// no-op
|
|
12283
|
+
}
|
|
12281
12284
|
});
|
|
12282
12285
|
const NestedTableRowProvider = ({
|
|
12283
12286
|
children,
|
|
12284
|
-
isCollapsed
|
|
12287
|
+
isCollapsed,
|
|
12285
12288
|
isSubHeader: isSubHeaderInput,
|
|
12286
|
-
childRowsCount: childRowsCountInput
|
|
12289
|
+
childRowsCount: childRowsCountInput,
|
|
12290
|
+
setIsCollapsed
|
|
12287
12291
|
}) => {
|
|
12288
|
-
const [isCollapsed, setIsCollapsed] = (0,external_react_namespaceObject.useState)(isCollapsedInput);
|
|
12289
12292
|
const [isSubHeader, setIsSubHeader] = (0,external_react_namespaceObject.useState)(isSubHeaderInput);
|
|
12290
12293
|
const [childRowsCount, setChildRowsCount] = (0,external_react_namespaceObject.useState)(childRowsCountInput);
|
|
12291
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
12292
|
-
setIsCollapsed(isCollapsedInput);
|
|
12293
|
-
}, [isCollapsedInput]);
|
|
12294
12294
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
12295
12295
|
setIsSubHeader(isSubHeaderInput);
|
|
12296
12296
|
}, [isSubHeaderInput]);
|
|
@@ -12300,6 +12300,7 @@ const NestedTableRowProvider = ({
|
|
|
12300
12300
|
return (0,jsx_runtime_namespaceObject.jsx)(NestedTableRowContext.Provider, {
|
|
12301
12301
|
value: {
|
|
12302
12302
|
isCollapsed,
|
|
12303
|
+
setIsCollapsed,
|
|
12303
12304
|
isSubHeader,
|
|
12304
12305
|
childRowsCount
|
|
12305
12306
|
},
|
|
@@ -12405,11 +12406,20 @@ const NestedTableRow = ({
|
|
|
12405
12406
|
const theme = (0,react_namespaceObject.useTheme)();
|
|
12406
12407
|
const {
|
|
12407
12408
|
isCollapsed,
|
|
12408
|
-
isSubHeader
|
|
12409
|
+
isSubHeader,
|
|
12410
|
+
childRowsCount,
|
|
12411
|
+
setIsCollapsed
|
|
12409
12412
|
} = useNestedTableRowContext();
|
|
12410
12413
|
const headerCSS = isSubHeader ? {
|
|
12411
12414
|
background: theme.colors.greyLighter60
|
|
12412
12415
|
} : {};
|
|
12416
|
+
const classNames = [];
|
|
12417
|
+
if (isSubHeader) {
|
|
12418
|
+
classNames.push('first-row');
|
|
12419
|
+
}
|
|
12420
|
+
if (isCollapsed) {
|
|
12421
|
+
classNames.push('collapsed');
|
|
12422
|
+
}
|
|
12413
12423
|
const notSubHeaderCSS = !isSubHeader && isCollapsed ? {
|
|
12414
12424
|
maxHeight: 0,
|
|
12415
12425
|
padding: 0,
|
|
@@ -12418,11 +12428,18 @@ const NestedTableRow = ({
|
|
|
12418
12428
|
padding: 0
|
|
12419
12429
|
}
|
|
12420
12430
|
} : {};
|
|
12431
|
+
const handleClick = () => {
|
|
12432
|
+
if (childRowsCount > 1 && isSubHeader) {
|
|
12433
|
+
setIsCollapsed(currentState => !currentState);
|
|
12434
|
+
}
|
|
12435
|
+
};
|
|
12421
12436
|
return (0,jsx_runtime_namespaceObject.jsxs)(TableRow_TableRow, {
|
|
12422
12437
|
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
12423
12438
|
...headerCSS,
|
|
12424
12439
|
...notSubHeaderCSS
|
|
12425
12440
|
}, true ? "" : 0, true ? "" : 0),
|
|
12441
|
+
onClick: handleClick,
|
|
12442
|
+
className: classNames.join(' '),
|
|
12426
12443
|
...props,
|
|
12427
12444
|
children: [(0,jsx_runtime_namespaceObject.jsx)(NestedTableCellSubHeader, {
|
|
12428
12445
|
isHeader: isHeader,
|
|
@@ -12448,25 +12465,12 @@ const WithNestedTableRow = ({
|
|
|
12448
12465
|
return external_react_namespaceObject.Children.map(children, (child, index) => {
|
|
12449
12466
|
if (/*#__PURE__*/(0,external_react_namespaceObject.isValidElement)(child)) {
|
|
12450
12467
|
const isSubHeader = index === 0;
|
|
12451
|
-
const classNames = [];
|
|
12452
|
-
if (isSubHeader) {
|
|
12453
|
-
classNames.push('first-row');
|
|
12454
|
-
}
|
|
12455
|
-
if (isCollapsed) {
|
|
12456
|
-
classNames.push('collapsed');
|
|
12457
|
-
}
|
|
12458
12468
|
return (0,jsx_runtime_namespaceObject.jsx)(NestedTableRowProvider, {
|
|
12459
12469
|
isCollapsed: isCollapsed,
|
|
12470
|
+
setIsCollapsed: setIsCollapsed,
|
|
12460
12471
|
isSubHeader: isSubHeader,
|
|
12461
12472
|
childRowsCount: childRowsCount,
|
|
12462
|
-
children: /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(child
|
|
12463
|
-
className: classNames.length > 0 ? classNames.join(' ') : undefined,
|
|
12464
|
-
isCollapsed,
|
|
12465
|
-
childRowsCount,
|
|
12466
|
-
onClick: childRowsCount > 1 ? () => {
|
|
12467
|
-
setIsCollapsed(currentState => !currentState);
|
|
12468
|
-
} : undefined
|
|
12469
|
-
})
|
|
12473
|
+
children: /*#__PURE__*/(0,external_react_namespaceObject.cloneElement)(child)
|
|
12470
12474
|
});
|
|
12471
12475
|
}
|
|
12472
12476
|
});
|