@nebula.js/sn-table 1.5.0 → 1.7.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.
@@ -3,7 +3,7 @@
3
3
  "info": {
4
4
  "name": "@nebula.js/sn-table:properties",
5
5
  "description": "Table generic object definition",
6
- "version": "1.5.0",
6
+ "version": "1.7.1",
7
7
  "license": "MIT",
8
8
  "stability": "experimental",
9
9
  "x-qlik-visibility": "public"
package/core/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/sn-table v1.5.0
2
+ * @nebula.js/sn-table v1.7.1
3
3
  * Copyright (c) 2022 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -502,7 +502,7 @@ const properties$1 = {
502
502
  * @type {string}
503
503
  * @default
504
504
  */
505
- version: "1.5.0",
505
+ version: "1.7.1",
506
506
 
507
507
  /**
508
508
  * Extends HyperCubeDef, see Engine API: HyperCubeDef
@@ -7751,7 +7751,11 @@ function createStyled(input = {}) {
7751
7751
 
7752
7752
  transformedStyleArg = [...styleArg, ...placeholders];
7753
7753
  transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
7754
- } else if (typeof styleArg === 'function') {
7754
+ } else if (typeof styleArg === 'function' && // On the server emotion doesn't use React.forwardRef for creating components, so the created
7755
+ // component stays as a function. This condition makes sure that we do not interpolate functions
7756
+ // which are basically components used as a selectors.
7757
+ // eslint-disable-next-line no-underscore-dangle
7758
+ styleArg.__emotion_real !== styleArg) {
7755
7759
  // If the type is function, we need to define the default theme.
7756
7760
  transformedStyleArg = _ref2 => {
7757
7761
  let {
@@ -8356,7 +8360,7 @@ function getContainer$1(container) {
8356
8360
  */
8357
8361
 
8358
8362
 
8359
- const Portal = /*#__PURE__*/React.forwardRef(function Portal(props, ref) {
8363
+ const Portal$1 = /*#__PURE__*/React.forwardRef(function Portal(props, ref) {
8360
8364
  const {
8361
8365
  children,
8362
8366
  container,
@@ -8392,7 +8396,7 @@ const Portal = /*#__PURE__*/React.forwardRef(function Portal(props, ref) {
8392
8396
 
8393
8397
  return mountNode ? /*#__PURE__*/ReactDOM.createPortal(children, mountNode) : mountNode;
8394
8398
  });
8395
- Portal.propTypes
8399
+ Portal$1.propTypes
8396
8400
  /* remove-proptypes */
8397
8401
  = {
8398
8402
  // ----------------------------- Warning --------------------------------
@@ -8425,10 +8429,10 @@ Portal.propTypes
8425
8429
 
8426
8430
  {
8427
8431
  // eslint-disable-next-line
8428
- Portal['propTypes' + ''] = exactProp(Portal.propTypes);
8432
+ Portal$1['propTypes' + ''] = exactProp(Portal$1.propTypes);
8429
8433
  }
8430
8434
 
8431
- var Portal$1 = Portal;
8435
+ var Portal$2 = Portal$1;
8432
8436
 
8433
8437
  function isOverflowing(container) {
8434
8438
  const doc = ownerDocument(container);
@@ -9245,7 +9249,7 @@ const ModalUnstyled = /*#__PURE__*/React.forwardRef(function ModalUnstyled(props
9245
9249
 
9246
9250
  const Root = components.Root || component;
9247
9251
  const rootProps = componentsProps.root || {};
9248
- return /*#__PURE__*/jsxRuntime.exports.jsx(Portal$1, {
9252
+ return /*#__PURE__*/jsxRuntime.exports.jsx(Portal$2, {
9249
9253
  ref: handlePortalRef,
9250
9254
  container: container,
9251
9255
  disablePortal: disablePortal,
@@ -17494,6 +17498,7 @@ const SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(inProps, ref) {
17494
17498
  color,
17495
17499
  component,
17496
17500
  fontSize,
17501
+ instanceFontSize: inProps.fontSize,
17497
17502
  inheritViewBox,
17498
17503
  viewBox
17499
17504
  });
@@ -17636,7 +17641,9 @@ var ArrowDropDownIcon = createSvgIcon$1( /*#__PURE__*/jsxRuntime.exports.jsx("pa
17636
17641
  function getInputUtilityClass(slot) {
17637
17642
  return generateUtilityClass('MuiInput', slot);
17638
17643
  }
17639
- const inputClasses = generateUtilityClasses('MuiInput', ['root', 'formControl', 'focused', 'disabled', 'colorSecondary', 'underline', 'error', 'sizeSmall', 'multiline', 'fullWidth', 'input', 'inputSizeSmall', 'inputMultiline', 'inputTypeSearch']);
17644
+
17645
+ const inputClasses = _extends$6({}, inputBaseClasses$1, generateUtilityClasses('MuiInput', ['root', 'underline', 'input']));
17646
+
17640
17647
  var inputClasses$1 = inputClasses;
17641
17648
 
17642
17649
  const _excluded$g = ["disableUnderline", "components", "componentsProps", "fullWidth", "inputComponent", "multiline", "type"];
@@ -17967,7 +17974,9 @@ var Input$1 = Input;
17967
17974
  function getFilledInputUtilityClass(slot) {
17968
17975
  return generateUtilityClass('MuiFilledInput', slot);
17969
17976
  }
17970
- const filledInputClasses = generateUtilityClasses('MuiFilledInput', ['root', 'colorSecondary', 'underline', 'focused', 'disabled', 'adornedStart', 'adornedEnd', 'error', 'sizeSmall', 'multiline', 'hiddenLabel', 'input', 'inputSizeSmall', 'inputHiddenLabel', 'inputMultiline', 'inputAdornedStart', 'inputAdornedEnd']);
17977
+
17978
+ const filledInputClasses = _extends$6({}, inputBaseClasses$1, generateUtilityClasses('MuiFilledInput', ['root', 'underline', 'input']));
17979
+
17971
17980
  var filledInputClasses$1 = filledInputClasses;
17972
17981
 
17973
17982
  const _excluded$f = ["disableUnderline", "components", "componentsProps", "fullWidth", "hiddenLabel", "inputComponent", "multiline", "type"];
@@ -18391,7 +18400,9 @@ const NotchedOutlineLegend = styled$1('legend')(({
18391
18400
  ownerState,
18392
18401
  theme
18393
18402
  }) => _extends$6({
18394
- float: 'unset'
18403
+ float: 'unset',
18404
+ // Fix conflict with bootstrap
18405
+ overflow: 'hidden'
18395
18406
  }, !ownerState.withLabel && {
18396
18407
  padding: 0,
18397
18408
  lineHeight: '11px',
@@ -18501,7 +18512,9 @@ NotchedOutline.propTypes = {
18501
18512
  function getOutlinedInputUtilityClass(slot) {
18502
18513
  return generateUtilityClass('MuiOutlinedInput', slot);
18503
18514
  }
18504
- const outlinedInputClasses = generateUtilityClasses('MuiOutlinedInput', ['root', 'colorSecondary', 'focused', 'disabled', 'adornedStart', 'adornedEnd', 'error', 'sizeSmall', 'multiline', 'notchedOutline', 'input', 'inputSizeSmall', 'inputMultiline', 'inputAdornedStart', 'inputAdornedEnd']);
18515
+
18516
+ const outlinedInputClasses = _extends$6({}, inputBaseClasses$1, generateUtilityClasses('MuiOutlinedInput', ['root', 'notchedOutline', 'input']));
18517
+
18505
18518
  var outlinedInputClasses$1 = outlinedInputClasses;
18506
18519
 
18507
18520
  const _excluded$d = ["components", "fullWidth", "inputComponent", "label", "multiline", "notched", "type"];
@@ -21515,6 +21528,19 @@ const SELECTION_STYLING = {
21515
21528
  background: STYLING_DEFAULTS.WHITE
21516
21529
  }
21517
21530
  };
21531
+ function getPadding(styleObj, defaultPadding) {
21532
+ let padding = defaultPadding;
21533
+
21534
+ if (styleObj.padding) {
21535
+ ({
21536
+ padding
21537
+ } = styleObj);
21538
+ } else if (styleObj.fontSize) {
21539
+ padding = `${styleObj.fontSize / 2}px ${styleObj.fontSize}px`;
21540
+ }
21541
+
21542
+ return padding;
21543
+ }
21518
21544
  function getColor(color = {}, defaultColor, theme) {
21519
21545
  const resolvedColor = theme.getColorPickerColor(color);
21520
21546
  return !resolvedColor || resolvedColor === 'none' ? defaultColor : resolvedColor;
@@ -21523,7 +21549,7 @@ const getAutoFontColor = backgroundColor => isDarkColor(backgroundColor) ? STYLI
21523
21549
  const getBaseStyling = (styleObj, theme) => ({
21524
21550
  color: getColor(styleObj.fontColor, STYLING_DEFAULTS.FONT_COLOR, theme),
21525
21551
  fontSize: styleObj.fontSize || STYLING_DEFAULTS.FONT_SIZE,
21526
- padding: styleObj.fontSize ? `${styleObj.fontSize / 2}px ${styleObj.fontSize}px` : STYLING_DEFAULTS.PADDING
21552
+ padding: getPadding(styleObj, STYLING_DEFAULTS.PADDING)
21527
21553
  }); // Both index === -1 and color === null must be true for the property to be unset
21528
21554
 
21529
21555
  const isUnset = prop => !prop || JSON.stringify(prop) === JSON.stringify({
@@ -23207,8 +23233,18 @@ var interopRequireDefault = {exports: {}};
23207
23233
 
23208
23234
  var createSvgIcon = {};
23209
23235
 
23236
+ // eslint-disable-next-line @typescript-eslint/naming-convention
23237
+
23238
+ const unstable_ClassNameGenerator = {
23239
+ configure: generator => {
23240
+ console.warn(['MUI: `ClassNameGenerator` import from `@mui/material/utils` is outdated and might cause unexpected issues.', '', "You should use `import { unstable_ClassNameGenerator } from '@mui/material/className'` instead", '', 'The detail of the issue: https://github.com/mui/material-ui/issues/30011#issuecomment-1024993401', '', 'The updated documentation: https://mui.com/guides/classname-generator/'].join('\n'));
23241
+ ClassNameGenerator$1.configure(generator);
23242
+ }
23243
+ };
23244
+
23210
23245
  var utils = /*#__PURE__*/Object.freeze({
23211
23246
  __proto__: null,
23247
+ unstable_ClassNameGenerator: unstable_ClassNameGenerator,
23212
23248
  capitalize: capitalize,
23213
23249
  createChainedFunction: createChainedFunction,
23214
23250
  createSvgIcon: createSvgIcon$1,
@@ -23225,8 +23261,7 @@ var utils = /*#__PURE__*/Object.freeze({
23225
23261
  useControlled: useControlled,
23226
23262
  useEventCallback: useEventCallback,
23227
23263
  useForkRef: useForkRef,
23228
- useIsFocusVisible: useIsFocusVisible,
23229
- unstable_ClassNameGenerator: ClassNameGenerator$1
23264
+ useIsFocusVisible: useIsFocusVisible
23230
23265
  });
23231
23266
 
23232
23267
  var require$$0 = /*@__PURE__*/getAugmentedNamespace(utils);
@@ -23409,29 +23444,24 @@ function useDidUpdateEffect(fn, inputs) {
23409
23444
  const handleHorizontalScroll = (evt, isRTL, memoedContainer) => {
23410
23445
  evt.stopPropagation(); // scrollWidth is the width of an element's content, including content not visible on the screen due to overflow.
23411
23446
  // offsetWidth is the element's CSS width, including any borders, padding, and vertical scrollbars
23412
- // scrollLeft is the number of pixels scrolled from its left edge
23447
+
23448
+ const maxScrollableWidth = memoedContainer.scrollWidth - memoedContainer.offsetWidth; // scrollLeft is the number of pixels scrolled from its left edge
23449
+ // scrollLeft is 0 when the scrollbar is at its leftmost position
23450
+ // (at the start of the scrolled content),
23451
+ // and then increasingly negative as it is scrolled towards left.
23413
23452
 
23414
23453
  let {
23415
23454
  scrollLeft
23416
- } = memoedContainer;
23417
- const ScrollLeftWidth = scrollLeft + evt.deltaX;
23418
- const maxScrollableWidth = memoedContainer.scrollWidth - memoedContainer.offsetWidth;
23419
-
23420
- if (isRTL) {
23421
- // scrollLeft is 0 when the scrollbar is at its rightmost position
23422
- // (at the start of the scrolled content),
23423
- // and then increasingly negative as you scroll towards (left) the end of the content .
23424
- // evt.deltaX increasingly negative as you scroll towards left,
23425
- // increasingly positive as you scroll towards right
23426
- const scrollRight = maxScrollableWidth + ScrollLeftWidth;
23427
-
23428
- if (maxScrollableWidth > 0 && (scrollRight <= 0 || scrollRight > maxScrollableWidth)) {
23429
- evt.preventDefault();
23430
- scrollLeft = Math.min(0, Math.min(maxScrollableWidth, scrollRight));
23431
- }
23432
- } else if (maxScrollableWidth > 0 && (ScrollLeftWidth < 0 || ScrollLeftWidth > maxScrollableWidth)) {
23455
+ } = memoedContainer; // evt.deltaX is the horizontal scroll amount
23456
+ // evt.deltaX increasingly negative as you scroll towards left,
23457
+ // increasingly positive as you scroll towards right
23458
+
23459
+ let scrolledDistance = scrollLeft + evt.deltaX;
23460
+ if (isRTL) scrolledDistance = maxScrollableWidth + scrolledDistance;
23461
+
23462
+ if (maxScrollableWidth > 0 && (scrolledDistance < 0 || scrolledDistance > maxScrollableWidth + 1)) {
23433
23463
  evt.preventDefault();
23434
- scrollLeft = Math.max(0, Math.min(maxScrollableWidth, ScrollLeftWidth));
23464
+ scrollLeft = isRTL ? Math.min(0, Math.min(maxScrollableWidth, scrolledDistance)) : Math.max(0, Math.min(maxScrollableWidth, scrolledDistance));
23435
23465
  }
23436
23466
  };
23437
23467
  const handleNavigateTop = ({
@@ -23529,6 +23559,13 @@ function announcementFactory(rootElement, translator, prevAnnounceEl) {
23529
23559
  };
23530
23560
  }
23531
23561
 
23562
+ function Portal({
23563
+ children,
23564
+ target
23565
+ }) {
23566
+ return ReactDOM__default.createPortal(children, target);
23567
+ }
23568
+
23532
23569
  function TableWrapper(props) {
23533
23570
  const {
23534
23571
  rootElement,
@@ -23541,6 +23578,7 @@ function TableWrapper(props) {
23541
23578
  keyboard,
23542
23579
  rect,
23543
23580
  direction,
23581
+ footerContainer,
23544
23582
  announcer // this is only for testing purposes
23545
23583
 
23546
23584
  } = props;
@@ -23558,7 +23596,6 @@ function TableWrapper(props) {
23558
23596
  const shouldRefocus = useRef(false);
23559
23597
  const tableContainerRef = useRef();
23560
23598
  const tableWrapperRef = useRef();
23561
- const fixedRowsPerPage = selectionsAPI.isModal() || rect.width < 550 || size.qcx > 100;
23562
23599
  /* eslint-disable react-hooks/rules-of-hooks */
23563
23600
 
23564
23601
  const announce = announcer || useMemo(() => announcementFactory(rootElement, translator), [translator.language]);
@@ -23643,12 +23680,9 @@ function TableWrapper(props) {
23643
23680
  backgroundColor: 'rgb(255, 255, 255)',
23644
23681
  boxShadow: 'none'
23645
23682
  };
23646
- const tableContainerStyle = constraints.active ? {
23647
- height: '100%',
23648
- overflow: 'hidden'
23649
- } : {
23650
- height: 'calc(100% - 52px)',
23651
- overflow: 'auto'
23683
+ const tableContainerStyle = {
23684
+ height: constraints.active || footerContainer ? '100%' : 'calc(100% - 52px)',
23685
+ overflow: constraints.active ? 'hidden' : 'auto'
23652
23686
  };
23653
23687
  const paperTablePaginationStyle = {
23654
23688
  display: 'flex',
@@ -23660,6 +23694,62 @@ function TableWrapper(props) {
23660
23694
  boxShadow: 'none',
23661
23695
  alignItems: 'center'
23662
23696
  };
23697
+
23698
+ const paginationContent = width => {
23699
+ const fixedRowsPerPage = selectionsAPI.isModal() || width < 550 || size.qcx > 100;
23700
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TablePagination$1, {
23701
+ sx: constraints.active && {
23702
+ display: 'none'
23703
+ },
23704
+ rowsPerPageOptions: fixedRowsPerPage ? [rowsPerPage] : rowsPerPageOptions,
23705
+ component: "div",
23706
+ count: size.qcy,
23707
+ rowsPerPage: rowsPerPage,
23708
+ labelRowsPerPage: `${translator.get('SNTable.Pagination.RowsPerPage')}:`,
23709
+ page: page,
23710
+ SelectProps: {
23711
+ inputProps: {
23712
+ 'aria-label': translator.get('SNTable.Pagination.RowsPerPage'),
23713
+ 'data-testid': 'select',
23714
+ style: {
23715
+ color: '#404040'
23716
+ },
23717
+ tabIndex: !keyboard.enabled || keyboard.active ? 0 : -1
23718
+ },
23719
+ native: true
23720
+ },
23721
+ labelDisplayedRows: ({
23722
+ from,
23723
+ to,
23724
+ count
23725
+ }) => width > 250 && translator.get('SNTable.Pagination.DisplayedRowsLabel', [`${from} - ${to}`, count]),
23726
+ onRowsPerPageChange: handleChangeRowsPerPage,
23727
+ ActionsComponent: () => /*#__PURE__*/React__default.createElement("div", null, null),
23728
+ onPageChange: () => {}
23729
+ }), /*#__PURE__*/React__default.createElement(TablePaginationActions, {
23730
+ direction: direction,
23731
+ page: page,
23732
+ onPageChange: handleChangePage,
23733
+ lastPageIdx: Math.ceil(size.qcy / rowsPerPage) - 1,
23734
+ keyboard: keyboard,
23735
+ isInSelectionMode: selectionsAPI.isModal(),
23736
+ tableWidth: width,
23737
+ translator: translator
23738
+ }));
23739
+ };
23740
+
23741
+ let paginationBar;
23742
+
23743
+ if (footerContainer) {
23744
+ paginationBar = /*#__PURE__*/React__default.createElement(Portal, {
23745
+ target: footerContainer
23746
+ }, paginationContent(footerContainer.getBoundingClientRect().width));
23747
+ } else {
23748
+ paginationBar = /*#__PURE__*/React__default.createElement(Paper$1, {
23749
+ sx: paperTablePaginationStyle
23750
+ }, paginationContent(rect.width));
23751
+ }
23752
+
23663
23753
  return /*#__PURE__*/React__default.createElement(Paper$1, {
23664
23754
  dir: direction,
23665
23755
  sx: paperStyle,
@@ -23692,51 +23782,12 @@ function TableWrapper(props) {
23692
23782
  setFocusedCellCoord: setFocusedCellCoord,
23693
23783
  setShouldRefocus: setShouldRefocus,
23694
23784
  tableWrapperRef: tableWrapperRef
23695
- })))), /*#__PURE__*/React__default.createElement(Paper$1, {
23696
- sx: paperTablePaginationStyle
23697
- }, /*#__PURE__*/React__default.createElement(TablePagination$1, {
23698
- sx: constraints.active && {
23699
- display: 'none'
23700
- },
23701
- rowsPerPageOptions: fixedRowsPerPage ? [rowsPerPage] : rowsPerPageOptions,
23702
- component: "div",
23703
- count: size.qcy,
23704
- rowsPerPage: rowsPerPage,
23705
- labelRowsPerPage: `${translator.get('SNTable.Pagination.RowsPerPage')}:`,
23706
- page: page,
23707
- SelectProps: {
23708
- inputProps: {
23709
- 'aria-label': translator.get('SNTable.Pagination.RowsPerPage'),
23710
- 'data-testid': 'select',
23711
- style: {
23712
- color: '#404040'
23713
- },
23714
- tabIndex: !keyboard.enabled || keyboard.active ? 0 : -1
23715
- },
23716
- native: true
23717
- },
23718
- labelDisplayedRows: ({
23719
- from,
23720
- to,
23721
- count
23722
- }) => rect.width > 250 && translator.get('SNTable.Pagination.DisplayedRowsLabel', [`${from} - ${to}`, count]),
23723
- onRowsPerPageChange: handleChangeRowsPerPage,
23724
- ActionsComponent: () => /*#__PURE__*/React__default.createElement("div", null, null),
23725
- onPageChange: () => {}
23726
- }), /*#__PURE__*/React__default.createElement(TablePaginationActions, {
23727
- direction: direction,
23728
- page: page,
23729
- onPageChange: handleChangePage,
23730
- lastPageIdx: Math.ceil(size.qcy / rowsPerPage) - 1,
23731
- keyboard: keyboard,
23732
- isInSelectionMode: selectionsAPI.isModal(),
23733
- tableWidth: rect.width,
23734
- translator: translator
23735
- })));
23785
+ })))), paginationBar);
23736
23786
  }
23737
23787
  TableWrapper.defaultProps = {
23738
23788
  announcer: null,
23739
- direction: null
23789
+ direction: null,
23790
+ footerContainer: null
23740
23791
  };
23741
23792
  TableWrapper.propTypes = {
23742
23793
  rootElement: PropTypes.object.isRequired,
@@ -23748,6 +23799,7 @@ TableWrapper.propTypes = {
23748
23799
  selectionsAPI: PropTypes.object.isRequired,
23749
23800
  keyboard: PropTypes.object.isRequired,
23750
23801
  rect: PropTypes.object.isRequired,
23802
+ footerContainer: PropTypes.object,
23751
23803
  direction: PropTypes.string,
23752
23804
  announcer: PropTypes.func
23753
23805
  };
@@ -24465,7 +24517,8 @@ function supernova(env) {
24465
24517
  const rootElement = useElement();
24466
24518
  const layout = useStaleLayout();
24467
24519
  const {
24468
- direction
24520
+ direction,
24521
+ footerContainer
24469
24522
  } = useOptions();
24470
24523
  const model = useModel();
24471
24524
  const constraints = useConstraints();
@@ -24499,7 +24552,8 @@ function supernova(env) {
24499
24552
  theme,
24500
24553
  changeSortOrder,
24501
24554
  keyboard,
24502
- rect
24555
+ rect,
24556
+ footerContainer
24503
24557
  });
24504
24558
  }
24505
24559
  }, [tableData, constraints, direction, selectionsAPI.isModal(), theme.name(), keyboard.active, translator.language(), rect.width]);