@rolster/react-components 18.12.7 → 18.12.8

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 CHANGED
@@ -1114,6 +1114,17 @@ const reactI18n = i18n.i18n({
1114
1114
  }
1115
1115
  });
1116
1116
 
1117
+ function useDatatable() {
1118
+ const [scrolleable, setScrolleable] = react.useState(false);
1119
+ const bodyRef = react.useRef(null);
1120
+ react.useEffect(() => {
1121
+ const scrollHeight = bodyRef?.current?.scrollHeight || 0;
1122
+ const clientHeight = bodyRef?.current?.clientHeight || 0;
1123
+ setScrolleable(scrollHeight > clientHeight);
1124
+ }, [bodyRef]);
1125
+ return { bodyRef, scrolleable };
1126
+ }
1127
+
1117
1128
  class ListCollection {
1118
1129
  constructor(value) {
1119
1130
  this.value = value;
@@ -1528,19 +1539,18 @@ function RlsDatatableHeader({ children }) {
1528
1539
  return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
1529
1540
  }
1530
1541
  function RlsDatatableTitle({ children, className, control }) {
1531
- return (jsxRuntime.jsx("th", { className: (renderClassStatus('rls-datatable__title', { control }) +
1532
- ` ${className || ''}`).trim(), children: children }));
1542
+ return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
1533
1543
  }
1534
1544
  function RlsDatatableData({ children, className, error }) {
1535
- return (jsxRuntime.jsx("tr", { className: (renderClassStatus('rls-datatable__data', { error }) +
1536
- ` ${className || ''}`).trim(), children: children }));
1545
+ return (jsxRuntime.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
1537
1546
  }
1538
1547
  function RlsDatatableCell({ children, className, control, overflow }) {
1539
- return (jsxRuntime.jsx("th", { className: (renderClassStatus('rls-datatable__cell', { control, overflow }) +
1540
- ` ${className || ''}`).trim(), children: children }));
1548
+ return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
1541
1549
  }
1542
- function RlsDatatable({ bodyRef, children, footer, header, rlsTheme }) {
1543
- return (jsxRuntime.jsxs("div", { className: "rls-datatable", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: bodyRef, className: "rls-datatable__tbody", children: children })] }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
1550
+ function RlsDatatable({ children, datatable, footer, header, rlsTheme }) {
1551
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
1552
+ scrolleable: datatable?.scrolleable
1553
+ }), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
1544
1554
  }
1545
1555
 
1546
1556
  const controlIsValid = (props) => {
@@ -2153,6 +2163,7 @@ exports.RlsToolbar = RlsToolbar;
2153
2163
  exports.RlsYearPicker = RlsYearPicker;
2154
2164
  exports.renderClassStatus = renderClassStatus;
2155
2165
  exports.useConfirmationService = useConfirmationService;
2166
+ exports.useDatatable = useDatatable;
2156
2167
  exports.useListControl = useListControl;
2157
2168
  exports.useSnackbarService = useSnackbarService;
2158
2169
  //# sourceMappingURL=index.js.map