@nebula.js/stardust 2.5.0 → 2.6.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/core/esm/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v2.5.0
2
+ * @nebula.js/stardust v2.6.1
3
3
  * Copyright (c) 2022 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -7,7 +7,7 @@
7
7
  import React, { useState as useState$1, useEffect as useEffect$1, useReducer, forwardRef, useMemo as useMemo$1, useImperativeHandle as useImperativeHandle$1, useCallback, useLayoutEffect as useLayoutEffect$1, createElement, PureComponent, useRef, useContext } from 'react';
8
8
  import ReactDOM from 'react-dom';
9
9
  import { createGenerateClassName, StylesProvider, ThemeProvider, makeStyles, useTheme as useTheme$1 } from '@material-ui/styles';
10
- import { Grid, Typography, IconButton, makeStyles as makeStyles$1, Popover, MenuList, MenuItem, ListItemIcon, Divider, OutlinedInput, InputAdornment, Badge, List, ListItem, Button, Box, Icon, CircularProgress, Paper } from '@material-ui/core';
10
+ import { Checkbox, Grid, FormControlLabel, Typography, IconButton, makeStyles as makeStyles$1, Popover, MenuList, MenuItem, ListItemIcon, Divider, OutlinedInput, InputAdornment, Badge, List, ListItem, Button, Box, Icon, CircularProgress, Paper } from '@material-ui/core';
11
11
 
12
12
  var runtime = {exports: {}};
13
13
 
@@ -5234,7 +5234,7 @@ function useAppSelections(app) {
5234
5234
  return [appSelections, navState];
5235
5235
  }
5236
5236
 
5237
- const NEBULA_VERSION_HASH = "daf8" ;
5237
+ const NEBULA_VERSION_HASH = "375a" ;
5238
5238
  let counter = 0;
5239
5239
  const NebulaApp = forwardRef((_ref, ref) => {
5240
5240
  let {
@@ -5294,7 +5294,7 @@ function boot(_ref2) {
5294
5294
  const appRef = React.createRef();
5295
5295
  const element = document.createElement('div');
5296
5296
  element.style.display = 'none';
5297
- element.setAttribute('data-nebulajs-version', "2.5.0" );
5297
+ element.setAttribute('data-nebulajs-version', "2.6.1" );
5298
5298
  element.setAttribute('data-app-id', app.id);
5299
5299
  document.body.appendChild(element);
5300
5300
  ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
@@ -6566,6 +6566,7 @@ function useSelectionsInteractions(_ref) {
6566
6566
  selections,
6567
6567
  pages = [],
6568
6568
  rangeSelect = true,
6569
+ checkboxes = false,
6569
6570
  doc = document
6570
6571
  } = _ref;
6571
6572
  const [instantPages, setInstantPages] = useState$1(pages);
@@ -6604,6 +6605,14 @@ function useSelectionsInteractions(_ref) {
6604
6605
  });
6605
6606
  };
6606
6607
 
6608
+ const onClick = useCallback(event => {
6609
+ if (selectingValues) {
6610
+ return;
6611
+ }
6612
+
6613
+ const elemNumber = +event.currentTarget.getAttribute('data-n');
6614
+ setPreSelected([elemNumber]);
6615
+ }, [selectingValues]);
6607
6616
  const onMouseDown = useCallback(event => {
6608
6617
  if (selectingValues) {
6609
6618
  return;
@@ -6665,7 +6674,7 @@ function useSelectionsInteractions(_ref) {
6665
6674
  setSelected(alreadySelected);
6666
6675
  }, [pages]);
6667
6676
  useEffect$1(() => {
6668
- if (selectingValues || !pages || !mouseDown) {
6677
+ if (selectingValues || !pages || !checkboxes && !mouseDown) {
6669
6678
  return;
6670
6679
  } // Render pre-selections before they have been selected in Engine.
6671
6680
 
@@ -6673,15 +6682,28 @@ function useSelectionsInteractions(_ref) {
6673
6682
  const newPages = applySelectionsOnPages(pages, preSelected);
6674
6683
  setInstantPages(newPages);
6675
6684
  }, [preSelected]);
6676
- const rangeSelectEvents = rangeSelect ? {
6677
- onMouseUp,
6678
- onMouseEnter
6679
- } : {};
6685
+ const interactionEvents = {};
6686
+
6687
+ if (checkboxes) {
6688
+ Object.assign(interactionEvents, {
6689
+ onClick
6690
+ });
6691
+ } else if (rangeSelect) {
6692
+ Object.assign(interactionEvents, {
6693
+ onMouseUp,
6694
+ onMouseDown,
6695
+ onMouseEnter
6696
+ });
6697
+ } else {
6698
+ Object.assign(interactionEvents, {
6699
+ onMouseUp,
6700
+ onMouseDown
6701
+ });
6702
+ }
6703
+
6680
6704
  return {
6681
6705
  instantPages,
6682
- interactionEvents: _objectSpread2({
6683
- onMouseDown
6684
- }, rangeSelectEvents)
6706
+ interactionEvents
6685
6707
  };
6686
6708
  }
6687
6709
 
@@ -6696,187 +6718,196 @@ const tick = props => _objectSpread2(_objectSpread2({}, props), {}, {
6696
6718
 
6697
6719
  var Tick = (props => SvgIcon(tick(props)));
6698
6720
 
6721
+ const CheckboxChecked = "url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath" + " fill-rule='evenodd' clip-rule='evenodd' d='M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 " + "1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z' fill='%23fff'/%3E%3C/svg%3E\")";
6722
+
6699
6723
  const useStyles$b = makeStyles(theme => ({
6700
- row: {
6701
- flexWrap: 'nowrap',
6702
- borderBottom: "1px solid ".concat(theme.palette.divider),
6703
- '&:focus': {
6704
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
6705
- outline: 'none'
6706
- }
6724
+ cbIcon: {
6725
+ borderRadius: 3,
6726
+ width: 16,
6727
+ height: 16,
6728
+ boxShadow: 'inset 0 0 0 1px rgba(16,22,26,.2), inset 0 -1px 0 rgba(16,22,26,.1)',
6729
+ backgroundColor: '#f5f8fa',
6730
+ backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))'
6707
6731
  },
6708
- cell: {
6709
- padding: '8px',
6710
- '& span': {
6711
- whiteSpace: 'nowrap',
6712
- fontSize: '12px',
6713
- lineHeight: '16px',
6714
- userSelect: 'none'
6715
- },
6716
- overflow: 'hidden',
6717
- textOverflow: 'ellipsis'
6718
- },
6719
- icon: {
6720
- padding: theme.spacing(1)
6721
- },
6722
- S: {
6723
- background: theme.palette.selected.main,
6724
- color: theme.palette.selected.mainContrastText,
6725
- '&:focus': {
6726
- boxShadow: "inset 0 0 0 2px rgba(0, 0, 0, 0.3)",
6727
- outline: 'none'
6732
+ cbIconChecked: {
6733
+ borderRadius: 3,
6734
+ backgroundColor: theme.palette.selected.main,
6735
+ backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
6736
+ '&:before': {
6737
+ display: 'block',
6738
+ width: 16,
6739
+ height: 16,
6740
+ backgroundImage: CheckboxChecked,
6741
+ content: '""'
6728
6742
  }
6729
6743
  },
6730
- A: {
6731
- background: theme.palette.selected.alternative,
6732
- color: theme.palette.selected.alternativeContrastText
6733
- },
6734
- X: {
6735
- background: theme.palette.selected.excluded,
6736
- color: theme.palette.selected.excludedContrastText
6744
+ checkbox: {
6745
+ margin: 0,
6746
+ '&:hover': {
6747
+ backgroundColor: 'inherit !important'
6748
+ }
6737
6749
  },
6738
- highlighted: {
6739
- backgroundColor: '#FFC72A'
6750
+ dense: {
6751
+ padding: '4px 8px'
6740
6752
  }
6741
6753
  }));
6742
- function Row(_ref) {
6754
+ function ListboxCheckbox(_ref) {
6743
6755
  let {
6744
- index,
6745
- style,
6746
- data
6756
+ checked,
6757
+ label,
6758
+ dense
6747
6759
  } = _ref;
6748
- const classes = useStyles$b();
6749
- const classArr = [classes.row];
6750
- let label = '';
6751
- const {
6752
- onMouseDown,
6753
- onMouseUp,
6754
- onMouseEnter,
6755
- pages
6756
- } = data;
6757
- let cell;
6758
-
6759
- if (pages) {
6760
- const page = pages.filter(p => p.qArea.qTop <= index && index < p.qArea.qTop + p.qArea.qHeight)[0];
6761
-
6762
- if (page) {
6763
- const area = page.qArea;
6764
-
6765
- if (index >= area.qTop && index < area.qTop + area.qHeight) {
6766
- [cell] = page.qMatrix[index - area.qTop];
6767
- }
6768
- }
6769
- }
6760
+ const styles = useStyles$b();
6761
+ return /*#__PURE__*/React.createElement(Checkbox, {
6762
+ edge: "start",
6763
+ checked: checked,
6764
+ tabIndex: -1,
6765
+ disableRipple: true,
6766
+ className: [styles.checkbox, dense && styles.dense].filter(Boolean).join(' '),
6767
+ inputProps: {
6768
+ 'aria-labelledby': label
6769
+ },
6770
+ name: label,
6771
+ icon: /*#__PURE__*/React.createElement("span", {
6772
+ className: styles.cbIcon
6773
+ }),
6774
+ checkedIcon: /*#__PURE__*/React.createElement("span", {
6775
+ className: styles.cbIconChecked
6776
+ })
6777
+ });
6778
+ }
6770
6779
 
6771
- let locked = false;
6772
- let selected = false;
6780
+ /**
6781
+ * @typedef {object} Range
6782
+ * @property {number} qCharPos The (absolute) index where the highlighted range starts.
6783
+ * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
6784
+ */
6773
6785
 
6774
- if (cell) {
6775
- label = cell.qText;
6776
- locked = cell.qState === 'L' || cell.qState === 'XL';
6777
- selected = cell.qState === 'S' || cell.qState === 'XS';
6786
+ /**
6787
+ * @typedef {object} Segment
6788
+ * @property {string} segment The sub-string/segment cut out from the original label.
6789
+ * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
6790
+ */
6778
6791
 
6779
- if (cell.qState === 'S' || cell.qState === 'L') {
6780
- classArr.push(classes.S);
6781
- } else if (cell.qState === 'A') {
6782
- classArr.push(classes.A);
6783
- } else if (cell.qState === 'X' || cell.qState === 'XS' || cell.qState === 'XL') {
6784
- classArr.push(classes.X);
6785
- }
6786
- } // Handle search highlights
6792
+ /**
6793
+ * @param {string} label The label we want to create segments out of.
6794
+ * @param {Range} range The indexes which define how to create the segments.
6795
+ * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
6796
+ * (only relevant for creating the first unhighlighted segment of a string/sub-string).
6797
+ * @returns {Segment[]} An array of segments.
6798
+ */
6799
+ function getSegmentsFromRange(label, range) {
6800
+ let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
6801
+ const {
6802
+ qCharPos,
6803
+ qCharCount
6804
+ } = range;
6805
+ const segments = [];
6787
6806
 
6807
+ if (qCharPos > startIndex) {
6808
+ // Create a non-highlighted section before the highighted section.
6809
+ segments.push([label.slice(startIndex, qCharPos), false]);
6810
+ } // Highlighted segment.
6788
6811
 
6789
- const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
6790
- const labels = ranges.reduce((acc, curr, ix) => {
6791
- // First non highlighted segment
6792
- if (curr.qCharPos > 0 && ix === 0) {
6793
- acc.push([label.slice(0, curr.qCharPos)]);
6794
- } // Previous non highlighted segment
6795
6812
 
6813
+ segments.push([label.slice(qCharPos, qCharPos + qCharCount), true]);
6814
+ return segments;
6815
+ }
6816
+ /**
6817
+ * @param {string} label The label we want to create segments out of.
6818
+ * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
6819
+ * @returns {Segment[]} An array of segments, covering the entire string label.
6820
+ */
6796
6821
 
6797
- const prev = ranges[ix - 1];
6798
6822
 
6799
- if (prev) {
6800
- acc.push([label.slice(prev.qCharPos + prev.qCharPos + 1, curr.qCharPos)]);
6801
- } // Highlighted segment
6823
+ function getSegmentsFromRanges(label, ranges) {
6824
+ if (!ranges.length) {
6825
+ return [];
6826
+ }
6802
6827
 
6828
+ const labels = ranges.reduce((acc, curr, ix) => {
6829
+ const startIndex = ix === 0 ? 0 : ranges[ix - 1].qCharPos + ranges[ix - 1].qCharCount;
6830
+ acc.push(...getSegmentsFromRange(label, curr, startIndex)); // Last non highlighted segment
6803
6831
 
6804
- acc.push([label.slice(curr.qCharPos, curr.qCharPos + curr.qCharCount), classes.highlighted]); // Last non highlighted segment
6832
+ const isLastRange = ix === ranges.length - 1;
6833
+ const endIndex = ranges[ix].qCharPos + ranges[ix].qCharCount;
6805
6834
 
6806
- if (ix === ranges.length - 1 && curr.qCharPos + curr.qCharCount < label.length) {
6807
- acc.push([label.slice(curr.qCharPos + curr.qCharCount)]);
6835
+ if (isLastRange && endIndex < label.length) {
6836
+ acc.push([label.slice(endIndex), false]);
6808
6837
  }
6809
6838
 
6810
6839
  return acc;
6811
6840
  }, []);
6812
- return /*#__PURE__*/React.createElement(Grid, {
6813
- container: true,
6814
- spacing: 0,
6815
- className: classArr.join(' ').trim(),
6816
- style: style,
6817
- onMouseDown: onMouseDown,
6818
- onMouseUp: onMouseUp,
6819
- onMouseEnter: onMouseEnter,
6820
- role: "row",
6821
- tabIndex: 0,
6822
- "data-n": cell && cell.qElemNumber
6823
- }, /*#__PURE__*/React.createElement(Grid, {
6824
- item: true,
6825
- style: {
6826
- minWidth: 0,
6827
- flexGrow: 1
6828
- },
6829
- className: classes.cell,
6830
- title: "".concat(label)
6831
- }, ranges.length === 0 ? /*#__PURE__*/React.createElement(Typography, {
6832
- component: "span",
6833
- noWrap: true,
6834
- color: "inherit"
6835
- }, "".concat(label)) : labels.map((_ref2, ix) => {
6836
- let [l, highlighted] = _ref2;
6837
- return (
6838
- /*#__PURE__*/
6839
- // eslint-disable-next-line react/no-array-index-key
6840
- React.createElement(Typography, {
6841
- component: "span",
6842
- key: ix,
6843
- className: highlighted,
6844
- noWrap: true
6845
- }, l)
6846
- );
6847
- })), /*#__PURE__*/React.createElement(Grid, {
6848
- item: true,
6849
- className: classes.icon
6850
- }, locked && /*#__PURE__*/React.createElement(Lock, {
6851
- size: "small"
6852
- }), selected && /*#__PURE__*/React.createElement(Tick, {
6853
- size: "small"
6854
- })));
6841
+ return labels;
6855
6842
  }
6856
6843
 
6844
+ const ellipsis = {
6845
+ width: '100%',
6846
+ overflow: 'hidden',
6847
+ textOverflow: 'ellipsis'
6848
+ };
6857
6849
  const useStyles$a = makeStyles(theme => ({
6850
+ row: {
6851
+ flexWrap: 'nowrap',
6852
+ borderBottom: "1px solid ".concat(theme.palette.divider),
6853
+ color: theme.palette.text.primary,
6854
+ '&:focus': {
6855
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
6856
+ outline: 'none'
6857
+ }
6858
+ },
6858
6859
  column: {
6859
6860
  flexWrap: 'nowrap',
6860
6861
  borderRight: "1px solid ".concat(theme.palette.divider),
6862
+ color: theme.palette.text.primary,
6861
6863
  '&:focus': {
6862
6864
  boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
6863
6865
  outline: 'none'
6864
6866
  }
6865
6867
  },
6868
+ // The interior wrapper for all field content.
6866
6869
  cell: {
6867
- padding: '8px',
6868
- '& span': {
6869
- whiteSpace: 'nowrap',
6870
- fontSize: '12px',
6871
- lineHeight: '16px',
6872
- userSelect: 'none'
6873
- },
6874
- overflow: 'hidden',
6875
- textOverflow: 'ellipsis'
6870
+ display: 'flex',
6871
+ alignItems: 'center',
6872
+ minWidth: 0,
6873
+ flexGrow: 1,
6874
+ // Note that this padding is overridden when using checkboxes.
6875
+ paddingLeft: '12px',
6876
+ paddingRight: '12px'
6877
+ },
6878
+ // The leaf node, containing the label text.
6879
+ labelText: _objectSpread2({
6880
+ flexBasis: 'max-content',
6881
+ lineHeight: '16px',
6882
+ userSelect: 'none',
6883
+ whiteSpace: 'pre'
6884
+ }, ellipsis),
6885
+ labelDense: {
6886
+ fontSize: 12
6876
6887
  },
6888
+ // Highlight is added to labelText spans, which are created as siblings to original labelText,
6889
+ // when a search string is matched.
6890
+ highlighted: {
6891
+ overflow: 'visible',
6892
+ width: '100%',
6893
+ '& > span': {
6894
+ width: '100%',
6895
+ backgroundColor: '#FFC72A'
6896
+ }
6897
+ },
6898
+ // Checkbox and label container.
6899
+ checkboxLabel: {
6900
+ margin: 0,
6901
+ width: '100%',
6902
+ // For checkboxes the first child is the checkbox container, second is the label container.
6903
+ '& > span:nth-child(2)': _objectSpread2({}, ellipsis)
6904
+ },
6905
+ // The icons container holding tick and lock, shown inside fields.
6877
6906
  icon: {
6907
+ display: 'flex',
6878
6908
  padding: theme.spacing(1)
6879
6909
  },
6910
+ // Selection styles (S=Selected, A=Available, X=Excluded).
6880
6911
  S: {
6881
6912
  background: theme.palette.selected.main,
6882
6913
  color: theme.palette.selected.mainContrastText,
@@ -6892,128 +6923,206 @@ const useStyles$a = makeStyles(theme => ({
6892
6923
  X: {
6893
6924
  background: theme.palette.selected.excluded,
6894
6925
  color: theme.palette.selected.excludedContrastText
6895
- },
6896
- highlighted: {
6897
- backgroundColor: '#FFC72A'
6898
6926
  }
6899
6927
  }));
6900
- function Column(_ref) {
6928
+ function RowColumn(_ref) {
6901
6929
  let {
6902
6930
  index,
6903
6931
  style,
6904
- data
6932
+ data,
6933
+ column = false
6905
6934
  } = _ref;
6906
- const classes = useStyles$a();
6907
- const classArr = [classes.column];
6908
- let label = '';
6909
6935
  const {
6936
+ onClick,
6910
6937
  onMouseDown,
6911
6938
  onMouseUp,
6912
6939
  onMouseEnter,
6913
- pages
6940
+ pages,
6941
+ isLocked,
6942
+ checkboxes = false,
6943
+ dense = false
6914
6944
  } = data;
6915
- let cell;
6945
+ const [isSelected, setSelected] = useState$1(false);
6946
+ const [cell, setCell] = useState$1();
6947
+ const classes = useStyles$a();
6948
+ const [classArr, setClassArr] = useState$1([]);
6949
+ useEffect$1(() => {
6950
+ if (!pages) {
6951
+ return;
6952
+ }
6916
6953
 
6917
- if (pages) {
6954
+ let c;
6918
6955
  const page = pages.filter(p => p.qArea.qTop <= index && index < p.qArea.qTop + p.qArea.qHeight)[0];
6919
6956
 
6920
6957
  if (page) {
6921
6958
  const area = page.qArea;
6922
6959
 
6923
6960
  if (index >= area.qTop && index < area.qTop + area.qHeight) {
6924
- [cell] = page.qMatrix[index - area.qTop];
6961
+ [c] = page.qMatrix[index - area.qTop];
6925
6962
  }
6926
6963
  }
6927
- }
6928
6964
 
6929
- let locked = false;
6930
- let selected = false;
6931
-
6932
- if (cell) {
6933
- label = cell.qText;
6934
- locked = cell.qState === 'L' || cell.qState === 'XL';
6935
- selected = cell.qState === 'S' || cell.qState === 'XS';
6936
-
6937
- if (cell.qState === 'S' || cell.qState === 'L') {
6938
- classArr.push(classes.S);
6939
- } else if (cell.qState === 'A') {
6940
- classArr.push(classes.A);
6941
- } else if (cell.qState === 'X' || cell.qState === 'XS' || cell.qState === 'XL') {
6942
- classArr.push(classes.X);
6965
+ setCell(c);
6966
+ }, [pages]);
6967
+ useEffect$1(() => {
6968
+ if (!cell) {
6969
+ return;
6943
6970
  }
6944
- } // Handle search highlights
6945
6971
 
6972
+ const selected = cell.qState === 'S' || cell.qState === 'XS' || cell.qState === 'L';
6973
+ setSelected(selected);
6974
+ const clazzArr = [column ? classes.column : classes.row];
6946
6975
 
6947
- const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
6948
- const labels = ranges.reduce((acc, curr, ix) => {
6949
- // First non highlighted segment
6950
- if (curr.qCharPos > 0 && ix === 0) {
6951
- acc.push([label.slice(0, curr.qCharPos)]);
6952
- } // Previous non highlighted segment
6976
+ if (!checkboxes) {
6977
+ if (cell.qState === 'S' || cell.qState === 'L') {
6978
+ clazzArr.push(classes.S);
6979
+ } else if (cell.qState === 'A') {
6980
+ clazzArr.push(classes.A);
6981
+ } else if (cell.qState === 'X' || cell.qState === 'XS' || cell.qState === 'XL') {
6982
+ clazzArr.push(classes.X);
6983
+ }
6984
+ }
6953
6985
 
6986
+ setClassArr(clazzArr);
6987
+ }, [cell && cell.qState]);
6954
6988
 
6955
- const prev = ranges[ix - 1];
6989
+ const getValueField = _ref2 => {
6990
+ let {
6991
+ lbl,
6992
+ ix,
6993
+ color,
6994
+ highlighted = false
6995
+ } = _ref2;
6996
+ return /*#__PURE__*/React.createElement(Typography, {
6997
+ component: "span",
6998
+ variant: "body2",
6999
+ key: ix,
7000
+ className: [classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense].filter(c => !!c).join(' ').trim(),
7001
+ color: color
7002
+ }, /*#__PURE__*/React.createElement("span", {
7003
+ style: {
7004
+ whiteSpace: 'pre'
7005
+ }
7006
+ }, lbl));
7007
+ };
6956
7008
 
6957
- if (prev) {
6958
- acc.push([label.slice(prev.qCharPos + prev.qCharPos + 1, curr.qCharPos)]);
6959
- } // Highlighted segment
7009
+ const getCheckboxField = _ref3 => {
7010
+ let {
7011
+ lbl,
7012
+ color,
7013
+ qElemNumber
7014
+ } = _ref3;
7015
+ const cb = /*#__PURE__*/React.createElement(ListboxCheckbox, {
7016
+ label: lbl,
7017
+ checked: isSelected,
7018
+ dense: dense
7019
+ });
7020
+ const labelTag = typeof lbl === 'string' ? getValueField({
7021
+ lbl,
7022
+ color,
7023
+ highlighted: false
7024
+ }) : lbl;
7025
+ return /*#__PURE__*/React.createElement(FormControlLabel, {
7026
+ color: color,
7027
+ control: cb,
7028
+ className: classes.checkboxLabel,
7029
+ label: labelTag,
7030
+ key: qElemNumber
7031
+ });
7032
+ };
6960
7033
 
7034
+ const label = cell ? cell.qText : ''; // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
6961
7035
 
6962
- acc.push([label.slice(curr.qCharPos, curr.qCharPos + curr.qCharCount), classes.highlighted]); // Last non highlighted segment
7036
+ const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
7037
+ const labels = getSegmentsFromRanges(label, ranges);
7038
+ const getField = checkboxes ? getCheckboxField : getValueField;
6963
7039
 
6964
- if (ix === ranges.length - 1 && curr.qCharPos + curr.qCharCount < label.length) {
6965
- acc.push([label.slice(curr.qCharPos + curr.qCharCount)]);
6966
- }
7040
+ const getFieldWithRanges = _ref4 => {
7041
+ let {
7042
+ lbls
7043
+ } = _ref4;
7044
+ const labelsWithRanges = lbls.map((_ref5, ix) => {
7045
+ let [lbl, highlighted] = _ref5;
7046
+ return getValueField({
7047
+ ix,
7048
+ highlighted,
7049
+ lbl
7050
+ });
7051
+ });
7052
+ return checkboxes ? getCheckboxField({
7053
+ lbl: labelsWithRanges
7054
+ }) : labelsWithRanges;
7055
+ };
6967
7056
 
6968
- return acc;
6969
- }, []);
7057
+ const iconStyles = {
7058
+ alignItems: 'center',
7059
+ display: 'flex'
7060
+ };
7061
+ const showLock = isSelected && isLocked;
7062
+ const showTick = !checkboxes && isSelected && !isLocked;
7063
+ const cellStyle = {
7064
+ display: 'flex',
7065
+ alignItems: 'center',
7066
+ minWidth: 0,
7067
+ flexGrow: 1,
7068
+ padding: checkboxes ? 0 : undefined
7069
+ };
6970
7070
  return /*#__PURE__*/React.createElement(Grid, {
6971
7071
  container: true,
6972
7072
  spacing: 0,
6973
- className: classArr.join(' ').trim(),
7073
+ className: ['value', ...classArr].join(' ').trim(),
6974
7074
  style: style,
6975
- alignItems: "center",
7075
+ onClick: onClick,
6976
7076
  onMouseDown: onMouseDown,
6977
7077
  onMouseUp: onMouseUp,
6978
7078
  onMouseEnter: onMouseEnter,
6979
- role: "row",
7079
+ role: column ? 'column' : 'row',
6980
7080
  tabIndex: 0,
6981
7081
  "data-n": cell && cell.qElemNumber
6982
7082
  }, /*#__PURE__*/React.createElement(Grid, {
6983
7083
  item: true,
6984
- style: {
6985
- minWidth: 0,
6986
- flexGrow: 1
6987
- },
7084
+ style: cellStyle,
6988
7085
  className: classes.cell,
6989
7086
  title: "".concat(label)
6990
- }, ranges.length === 0 ? /*#__PURE__*/React.createElement(Typography, {
6991
- component: "span",
6992
- noWrap: true,
6993
- color: "inherit"
6994
- }, "".concat(label)) : labels.map((_ref2, ix) => {
6995
- let [l, highlighted] = _ref2;
6996
- return (
6997
- /*#__PURE__*/
6998
- // eslint-disable-next-line react/no-array-index-key
6999
- React.createElement(Typography, {
7000
- component: "span",
7001
- key: ix,
7002
- className: highlighted,
7003
- noWrap: true
7004
- }, l)
7005
- );
7006
- })), /*#__PURE__*/React.createElement(Grid, {
7087
+ }, ranges.length === 0 ? getField({
7088
+ lbl: label,
7089
+ color: 'inherit'
7090
+ }) : getFieldWithRanges({
7091
+ lbls: labels
7092
+ })), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid, {
7007
7093
  item: true,
7008
7094
  className: classes.icon
7009
- }, locked && /*#__PURE__*/React.createElement(Lock, {
7095
+ }, showLock && /*#__PURE__*/React.createElement(Lock, {
7096
+ style: iconStyles,
7010
7097
  size: "small"
7011
- }), selected && /*#__PURE__*/React.createElement(Tick, {
7098
+ }), showTick && /*#__PURE__*/React.createElement(Tick, {
7099
+ style: iconStyles,
7012
7100
  size: "small"
7013
7101
  })));
7014
7102
  }
7015
7103
 
7016
- function ListBox(_ref) {
7104
+ function getSizeInfo(_ref) {
7105
+ let {
7106
+ isVertical,
7107
+ checkboxes,
7108
+ dense,
7109
+ height
7110
+ } = _ref;
7111
+ let sizeVertical = checkboxes ? 40 : 33;
7112
+
7113
+ if (dense) {
7114
+ sizeVertical = 24;
7115
+ }
7116
+
7117
+ const itemSize = isVertical ? sizeVertical : 200;
7118
+ const listHeight = height || 8 * itemSize;
7119
+ return {
7120
+ itemSize,
7121
+ listHeight
7122
+ };
7123
+ }
7124
+
7125
+ function ListBox(_ref2) {
7017
7126
  let {
7018
7127
  model,
7019
7128
  selections,
@@ -7022,8 +7131,10 @@ function ListBox(_ref) {
7022
7131
  width,
7023
7132
  listLayout = 'vertical',
7024
7133
  rangeSelect = true,
7025
- update = undefined
7026
- } = _ref;
7134
+ checkboxes = false,
7135
+ update = undefined,
7136
+ dense = false
7137
+ } = _ref2;
7027
7138
  const [layout] = useLayout$1(model);
7028
7139
  const [pages, setPages] = useState$1(null);
7029
7140
  const [isLoadingData, setIsLoadingData] = useState$1(false);
@@ -7035,6 +7146,7 @@ function ListBox(_ref) {
7035
7146
  selections,
7036
7147
  pages,
7037
7148
  rangeSelect,
7149
+ checkboxes,
7038
7150
  doc: document
7039
7151
  });
7040
7152
  const loaderRef = useRef(null);
@@ -7126,8 +7238,16 @@ function ListBox(_ref) {
7126
7238
 
7127
7239
  const isVertical = listLayout !== 'horizontal';
7128
7240
  const count = layout.qListObject.qSize.qcy;
7129
- const ITEM_SIZE = isVertical ? 33 : 200;
7130
- const listHeight = height || 8 * ITEM_SIZE;
7241
+ const {
7242
+ itemSize,
7243
+ listHeight
7244
+ } = getSizeInfo({
7245
+ isVertical,
7246
+ checkboxes,
7247
+ dense,
7248
+ height
7249
+ });
7250
+ const isLocked = layout && layout.qListObject.qDimensionInfo.qLocked;
7131
7251
  return /*#__PURE__*/React.createElement(InfiniteLoader, {
7132
7252
  isItemLoaded: isItemLoaded,
7133
7253
  itemCount: count,
@@ -7135,11 +7255,11 @@ function ListBox(_ref) {
7135
7255
  threshold: 0,
7136
7256
  minimumBatchSize: 100,
7137
7257
  ref: loaderRef
7138
- }, _ref2 => {
7258
+ }, _ref3 => {
7139
7259
  let {
7140
7260
  onItemsRendered,
7141
7261
  ref
7142
- } = _ref2;
7262
+ } = _ref3;
7143
7263
  local.current.listRef = ref;
7144
7264
  return /*#__PURE__*/React.createElement(FixedSizeList, {
7145
7265
  direction: direction,
@@ -7150,13 +7270,18 @@ function ListBox(_ref) {
7150
7270
  width: width,
7151
7271
  itemCount: count,
7152
7272
  layout: listLayout,
7153
- itemData: _objectSpread2(_objectSpread2({}, interactionEvents), {}, {
7273
+ itemData: _objectSpread2(_objectSpread2({
7274
+ isLocked,
7275
+ column: !isVertical,
7154
7276
  pages
7277
+ }, isLocked ? {} : interactionEvents), {}, {
7278
+ checkboxes,
7279
+ dense
7155
7280
  }),
7156
- itemSize: ITEM_SIZE,
7281
+ itemSize: itemSize,
7157
7282
  onItemsRendered: onItemsRendered,
7158
7283
  ref: ref
7159
- }, isVertical ? Row : Column);
7284
+ }, RowColumn);
7160
7285
  });
7161
7286
  }
7162
7287
 
@@ -7731,13 +7856,22 @@ const useStyles$7 = makeStyles(theme => ({
7731
7856
  borderRadius: 0,
7732
7857
  borderColor: "".concat(theme.palette.divider, " transparent")
7733
7858
  }
7859
+ },
7860
+ dense: {
7861
+ fontSize: 12,
7862
+ paddingLeft: theme.spacing(1),
7863
+ '& input': {
7864
+ paddingTop: '5px',
7865
+ paddingBottom: '5px'
7866
+ }
7734
7867
  }
7735
7868
  }));
7736
7869
  const TREE_PATH = '/qListObjectDef';
7737
7870
  function ListBoxSearch(_ref) {
7738
7871
  let {
7739
7872
  model,
7740
- autoFocus = true
7873
+ autoFocus = true,
7874
+ dense = false
7741
7875
  } = _ref;
7742
7876
  const {
7743
7877
  translator
@@ -7766,8 +7900,10 @@ function ListBoxSearch(_ref) {
7766
7900
  return /*#__PURE__*/React.createElement(OutlinedInput, {
7767
7901
  startAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
7768
7902
  position: "start"
7769
- }, /*#__PURE__*/React.createElement(Search, null)),
7770
- className: [classes.root].join(' '),
7903
+ }, /*#__PURE__*/React.createElement(Search, {
7904
+ size: dense ? 'small' : 'normal'
7905
+ })),
7906
+ className: ['search', classes.root, dense && classes.dense].filter(Boolean).join(' '),
7771
7907
  autoFocus: autoFocus,
7772
7908
  margin: "dense",
7773
7909
  fullWidth: true,
@@ -9380,10 +9516,12 @@ function ListBoxInline(_ref2) {
9380
9516
  search = true,
9381
9517
  toolbar = true,
9382
9518
  rangeSelect = true,
9519
+ checkboxes = false,
9383
9520
  properties = {},
9384
9521
  sessionModel = undefined,
9385
9522
  selectionsApi = undefined,
9386
- update = undefined
9523
+ update = undefined,
9524
+ dense = false
9387
9525
  } = options;
9388
9526
 
9389
9527
  const listdef = _objectSpread2({
@@ -9534,7 +9672,8 @@ function ListBoxInline(_ref2) {
9534
9672
  item: true
9535
9673
  }, /*#__PURE__*/React.createElement(ListBoxSearch, {
9536
9674
  model: model,
9537
- autoFocus: false
9675
+ autoFocus: false,
9676
+ dense: dense
9538
9677
  })) : '', /*#__PURE__*/React.createElement(Grid, {
9539
9678
  item: true,
9540
9679
  xs: true
@@ -9551,9 +9690,11 @@ function ListBoxInline(_ref2) {
9551
9690
  direction: direction,
9552
9691
  listLayout: listLayout,
9553
9692
  rangeSelect: rangeSelect,
9693
+ checkboxes: checkboxes,
9554
9694
  height: height,
9555
9695
  width: width,
9556
- update: update
9696
+ update: update,
9697
+ dense: dense
9557
9698
  });
9558
9699
  })));
9559
9700
  }
@@ -13787,9 +13928,11 @@ function useAction(fn, deps) {
13787
13928
  * @example
13788
13929
  * // configure embed to disallow active interactions when rendering
13789
13930
  * embed(app, {
13790
- * constraints: {
13791
- * active: true, // do not allow interactions
13792
- * }
13931
+ * context: {
13932
+ * constraints: {
13933
+ * active: true, // do not allow interactions
13934
+ * }
13935
+ * }
13793
13936
  * }).render({ element, id: 'sdfsdf' });
13794
13937
  *
13795
13938
  * @example
@@ -16851,8 +16994,11 @@ function nuked() {
16851
16994
  * @param {string=} options.title Custom title, defaults to fieldname
16852
16995
  * @param {string=} [options.direction=ltr] Direction setting ltr|rtl.
16853
16996
  * @param {string=} [options.listLayout=vertical] Layout direction vertical|horizontal
16854
- * @param {boolean=} [options.search=true] To show the search bar
16855
- * @param {boolean=} [options.toolbar=true] To show the toolbar
16997
+ * @param {boolean=} [options.search=true] Show the search bar
16998
+ * @param {boolean=} [options.toolbar=true] Show the toolbar
16999
+ * @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields
17000
+ * @param {boolean=} [options.rangeSelect=true] Enable range selection
17001
+ * @param {boolean=} [options.dense=false] Reduces padding and text size
16856
17002
  * @param {boolean=} [options.stateName="$"] Sets the state to make selections in
16857
17003
  * @param {object=} [options.properties={}] Properties object to extend default properties with
16858
17004
  * @param {object} [options.sessionModel] Use a custom sessionModel.
@@ -16946,7 +17092,9 @@ function nuked() {
16946
17092
  * // create an alternate config with dark theme
16947
17093
  * // and inherit the config from the previous
16948
17094
  * const d = m.createConfiguration({
16949
- * theme: 'dark'
17095
+ * context: {
17096
+ * theme: 'dark'
17097
+ * }
16950
17098
  * });
16951
17099
  *
16952
17100
  * m(app).render({ type: 'mekko' }); // will render the object with default theme