@nebula.js/stardust 4.8.0 → 4.9.0

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,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.8.0
2
+ * @nebula.js/stardust v4.9.0
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -722,26 +722,26 @@
722
722
  }
723
723
  })(runtime);
724
724
 
725
- function ownKeys(object, enumerableOnly) {
726
- var keys = Object.keys(object);
725
+ function ownKeys(e, r) {
726
+ var t = Object.keys(e);
727
727
  if (Object.getOwnPropertySymbols) {
728
- var symbols = Object.getOwnPropertySymbols(object);
729
- enumerableOnly && (symbols = symbols.filter(function (sym) {
730
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
731
- })), keys.push.apply(keys, symbols);
732
- }
733
- return keys;
734
- }
735
- function _objectSpread2(target) {
736
- for (var i = 1; i < arguments.length; i++) {
737
- var source = null != arguments[i] ? arguments[i] : {};
738
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
739
- _defineProperty(target, key, source[key]);
740
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
741
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
728
+ var o = Object.getOwnPropertySymbols(e);
729
+ r && (o = o.filter(function (r) {
730
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
731
+ })), t.push.apply(t, o);
732
+ }
733
+ return t;
734
+ }
735
+ function _objectSpread2(e) {
736
+ for (var r = 1; r < arguments.length; r++) {
737
+ var t = null != arguments[r] ? arguments[r] : {};
738
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
739
+ _defineProperty(e, r, t[r]);
740
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
741
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
742
742
  });
743
743
  }
744
- return target;
744
+ return e;
745
745
  }
746
746
  function _defineProperty(obj, key, value) {
747
747
  key = _toPropertyKey(key);
@@ -11820,7 +11820,7 @@
11820
11820
  return cache[key];
11821
11821
  }
11822
11822
 
11823
- const NEBULA_VERSION_HASH = "f910" ;
11823
+ const NEBULA_VERSION_HASH = "8934" ;
11824
11824
  ClassNameGenerator$1.configure(componentName => {
11825
11825
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
11826
11826
  });
@@ -12081,7 +12081,7 @@
12081
12081
  const appRef = React.createRef();
12082
12082
  const element = document.createElement('div');
12083
12083
  element.style.display = 'none';
12084
- element.setAttribute('data-nebulajs-version', "4.8.0" );
12084
+ element.setAttribute('data-nebulajs-version', "4.9.0" );
12085
12085
  element.setAttribute('data-app-id', app.id);
12086
12086
  document.body.appendChild(element);
12087
12087
  if (context) {
@@ -21984,6 +21984,7 @@
21984
21984
  const GRID_ROW_HEIGHT = 32;
21985
21985
  const LIST_ROW_HEIGHT = 29;
21986
21986
  const DENSE_ROW_HEIGHT = 20; // same for both list and grid in dense mode
21987
+ const GRID_ITEM_PADDING = 4;
21987
21988
 
21988
21989
  const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
21989
21990
  const getBarWidth = _ref => {
@@ -22658,7 +22659,8 @@
22658
22659
  let {
22659
22660
  dataLayout,
22660
22661
  layoutOrder,
22661
- itemPadding
22662
+ itemPadding,
22663
+ fillHeight
22662
22664
  } = _ref;
22663
22665
  // Simulate margin/padding by making the item smaller than its container.
22664
22666
  if (dataLayout === 'singleColumn') {
@@ -22670,14 +22672,14 @@
22670
22672
  switch (layoutOrder) {
22671
22673
  case 'row':
22672
22674
  return {
22673
- height: "calc(100% - ".concat(itemPadding, "px)"),
22675
+ height: fillHeight ? '100%' : "calc(100% - ".concat(itemPadding, "px)"),
22674
22676
  width: "calc(100% - ".concat(2 * itemPadding, "px)"),
22675
22677
  position: 'absolute',
22676
22678
  left: 4
22677
22679
  };
22678
22680
  case 'column':
22679
22681
  return {
22680
- height: "calc(100% - ".concat(itemPadding, "px)"),
22682
+ height: fillHeight ? '100%' : "calc(100% - ".concat(itemPadding, "px)"),
22681
22683
  width: "calc(100% - ".concat(2 * itemPadding, "px)"),
22682
22684
  position: 'absolute',
22683
22685
  left: 4
@@ -22688,21 +22690,23 @@
22688
22690
  }
22689
22691
 
22690
22692
  const ItemGrid = styled$1(Grid$1, {
22691
- shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding', 'cellPaddingRight', 'direction'].includes(prop)
22693
+ shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding', 'cellPaddingRight', 'direction', 'fillHeight'].includes(prop)
22692
22694
  })(_ref => {
22693
22695
  let {
22694
22696
  dataLayout,
22695
22697
  layoutOrder,
22696
22698
  itemPadding,
22697
22699
  cellPaddingRight,
22698
- direction
22700
+ direction,
22701
+ fillHeight
22699
22702
  } = _ref;
22700
22703
  const att = "padding".concat(direction === 'rtl' ? 'Left' : 'Right');
22701
22704
  return {
22702
22705
  ["&.".concat(rowColClasses.fieldRoot)]: _objectSpread2(_objectSpread2({}, getGridItemSizes({
22703
22706
  dataLayout,
22704
22707
  layoutOrder,
22705
- itemPadding
22708
+ itemPadding,
22709
+ fillHeight
22706
22710
  })), {}, {
22707
22711
  [att]: cellPaddingRight ? '8px' : undefined
22708
22712
  })
@@ -23143,7 +23147,8 @@
23143
23147
  showSearch,
23144
23148
  isModal,
23145
23149
  contentFontStyle,
23146
- styles
23150
+ styles,
23151
+ fillHeight
23147
23152
  } = data;
23148
23153
  const {
23149
23154
  dense = false,
@@ -23171,6 +23176,7 @@
23171
23176
  }
23172
23177
  const padding = 0;
23173
23178
  styleOverrides = _objectSpread2(_objectSpread2({}, style), {}, {
23179
+ height: fillHeight ? '100%' : style.height,
23174
23180
  left: padding + (columnIndex === 0 ? style.left : Number(style.left) + columnIndex * padding),
23175
23181
  // right: columnIndex === columnCount ? style.right : Number(style.right) + columnIndex * padding,
23176
23182
  top: rowIndex === 0 ? style.top : Number(style.top) + rowIndex * padding
@@ -23307,7 +23313,8 @@
23307
23313
  onContextMenu: preventContextMenu,
23308
23314
  tabIndex: isFirstElement && keyboard.innerTabStops ? 0 : -1,
23309
23315
  "data-n": cell === null || cell === void 0 ? void 0 : cell.qElemNumber,
23310
- direction: direction
23316
+ direction: direction,
23317
+ fillHeight: fillHeight
23311
23318
  }, (cell === null || cell === void 0 ? void 0 : cell.qFrequency) && /*#__PURE__*/React.createElement(Histogram, {
23312
23319
  qFrequency: cell === null || cell === void 0 ? void 0 : cell.qFrequency,
23313
23320
  histogram: histogram,
@@ -24205,7 +24212,7 @@
24205
24212
  scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
24206
24213
  return {
24207
24214
  isScrolling: true,
24208
- scrollDirection: prevState.scrollOffset < scrollLeft ? 'forward' : 'backward',
24215
+ scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
24209
24216
  scrollOffset: scrollOffset,
24210
24217
  scrollUpdateWasRequested: false
24211
24218
  };
@@ -24947,6 +24954,7 @@
24947
24954
  className: classes$9.styledScrollbars
24948
24955
  };
24949
24956
  const isLocked = layout === null || layout === void 0 ? void 0 : layout.qListObject.qDimensionInfo.qLocked;
24957
+ const fillHeight = listHeight <= itemHeight;
24950
24958
 
24951
24959
  // Item data common for List and Grid.
24952
24960
  const commonItemData = _objectSpread2(_objectSpread2({
@@ -24980,7 +24988,8 @@
24980
24988
  translator,
24981
24989
  showSearch,
24982
24990
  isModal,
24983
- styles
24991
+ styles,
24992
+ fillHeight
24984
24993
  });
24985
24994
  const List = _ref2 => {
24986
24995
  let {
@@ -25177,6 +25186,21 @@
25177
25186
  return measureString;
25178
25187
  }
25179
25188
 
25189
+ function getItemHeight(_ref) {
25190
+ let {
25191
+ isGridMode,
25192
+ dense
25193
+ } = _ref;
25194
+ const normalItemHeight = isGridMode ? GRID_ROW_HEIGHT : LIST_ROW_HEIGHT;
25195
+ let itemHeight = dense ? DENSE_ROW_HEIGHT : normalItemHeight;
25196
+ if (isGridMode) {
25197
+ // Emulate a margin between items using padding, since the list library
25198
+ // needs an explicit row height and cannot handle margins.
25199
+ itemHeight += GRID_ITEM_PADDING;
25200
+ }
25201
+ return itemHeight;
25202
+ }
25203
+
25180
25204
  function useListSizes(_ref) {
25181
25205
  let {
25182
25206
  layout,
@@ -25232,14 +25256,10 @@
25232
25256
  let columnWidth;
25233
25257
  let rowCount;
25234
25258
  const isGridMode = dataLayout === 'grid';
25235
- const itemPadding = 4;
25236
- const normalItemHeight = isGridMode ? GRID_ROW_HEIGHT : LIST_ROW_HEIGHT;
25237
- let itemHeight = dense ? DENSE_ROW_HEIGHT : normalItemHeight;
25238
- if (isGridMode) {
25239
- // Emulate a margin between items using padding, since the list library
25240
- // needs an explicit row height and cannot handle margins.
25241
- itemHeight += itemPadding;
25242
- }
25259
+ const itemHeight = getItemHeight({
25260
+ isGridMode,
25261
+ dense
25262
+ });
25243
25263
  const listHeight = height !== null && height !== void 0 ? height : 8 * itemHeight;
25244
25264
  if (layoutOrder) {
25245
25265
  // Modify container width to achieve the exact design with 8px margins on each side (left and right).
@@ -25248,7 +25268,7 @@
25248
25268
  overflowStyling = {
25249
25269
  overflowX: 'hidden'
25250
25270
  };
25251
- containerWidth += itemPadding * 2;
25271
+ containerWidth += GRID_ITEM_PADDING * 2;
25252
25272
  ({
25253
25273
  rowCount,
25254
25274
  columnWidth,
@@ -25303,7 +25323,7 @@
25303
25323
  row: maxRowCount,
25304
25324
  column: maxColumnCount
25305
25325
  },
25306
- itemPadding,
25326
+ itemPadding: GRID_ITEM_PADDING,
25307
25327
  textWidth,
25308
25328
  freqMinWidth,
25309
25329
  freqMaxWidth
@@ -30972,6 +30992,33 @@
30972
30992
  return isDQ;
30973
30993
  }
30974
30994
 
30995
+ function getContainerPadding(_ref) {
30996
+ let {
30997
+ isGridMode,
30998
+ dense,
30999
+ height,
31000
+ layoutOrder
31001
+ } = _ref;
31002
+ let containerPadding;
31003
+ if (isGridMode) {
31004
+ const itemHeight = getItemHeight({
31005
+ isGridMode,
31006
+ dense
31007
+ });
31008
+ let paddingY;
31009
+ if (itemHeight > height) {
31010
+ paddingY = '0px';
31011
+ } else {
31012
+ paddingY = '2px';
31013
+ }
31014
+ containerPadding = layoutOrder === 'row' ? "".concat(paddingY, " 4px") : "".concat(paddingY, " 6px ").concat(paddingY, " 4px");
31015
+ } else {
31016
+ containerPadding = undefined; // to prevent overriding any default padding
31017
+ }
31018
+
31019
+ return containerPadding;
31020
+ }
31021
+
30975
31022
  const PREFIX$4 = 'ListBoxInline';
30976
31023
  const classes$4 = {
30977
31024
  listBoxHeader: "".concat(PREFIX$4, "-listBoxHeader"),
@@ -31050,7 +31097,7 @@
31050
31097
  return (_app$isInModalSelecti = (_app$isInModalSelecti2 = app.isInModalSelection) === null || _app$isInModalSelecti2 === void 0 ? void 0 : _app$isInModalSelecti2.call(app)) !== null && _app$isInModalSelecti !== void 0 ? _app$isInModalSelecti : appSelections.isInModal();
31051
31098
  };
31052
31099
  function ListBoxInline(_ref5) {
31053
- var _layout$qListObject, _layout$qListObject2, _layoutOptions$dense;
31100
+ var _layout$qListObject, _layout$qListObject2, _layoutOptions$dense, _containerRef$current;
31054
31101
  let {
31055
31102
  options,
31056
31103
  layout
@@ -31276,10 +31323,12 @@
31276
31323
 
31277
31324
  // Add a container padding for grid mode to harmonize with the grid item margins (should sum to 8px).
31278
31325
  const isGridMode = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.dataLayout) === 'grid';
31279
- let containerPadding;
31280
- if (isGridMode) {
31281
- containerPadding = layoutOptions.layoutOrder === 'row' ? '2px 4px' : '2px 6px 2px 4px';
31282
- }
31326
+ const containerPadding = getContainerPadding({
31327
+ isGridMode,
31328
+ dense,
31329
+ height: (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.clientHeight,
31330
+ layoutOrder: layoutOptions.layoutOrder
31331
+ });
31283
31332
  const searchIconComp = constraints !== null && constraints !== void 0 && constraints.active ? /*#__PURE__*/React.createElement(SearchIcon, {
31284
31333
  title: translator.get('Listbox.Search'),
31285
31334
  size: "large",
@@ -31319,6 +31368,7 @@
31319
31368
  if (isInvalid) {
31320
31369
  renderedCallback === null || renderedCallback === void 0 || renderedCallback();
31321
31370
  }
31371
+ const listBoxMinHeight = showToolbarWithTitle ? DENSE_ROW_HEIGHT + SCROLL_BAR_WIDTH : 0;
31322
31372
  return /*#__PURE__*/React.createElement(React.Fragment, null, showDetachedToolbarOnly && /*#__PURE__*/React.createElement(ActionsToolbar, _extends$7({
31323
31373
  direction: direction
31324
31374
  }, getActionToolbarProps(true))), /*#__PURE__*/React.createElement(StyledGrid$3, {
@@ -31384,10 +31434,8 @@
31384
31434
  item: true,
31385
31435
  container: true,
31386
31436
  direction: "column",
31387
- style: {
31388
- height: '100%',
31389
- minHeight: DENSE_ROW_HEIGHT + SCROLL_BAR_WIDTH
31390
- },
31437
+ height: "100%",
31438
+ minHeight: listBoxMinHeight,
31391
31439
  role: "region",
31392
31440
  "aria-label": translator.get('Listbox.ResultFilterLabel')
31393
31441
  }, /*#__PURE__*/React.createElement(Grid$1, {
@@ -33140,7 +33188,8 @@
33140
33188
  model,
33141
33189
  cellRef,
33142
33190
  newType,
33143
- properties
33191
+ properties,
33192
+ viewDataMode = false
33144
33193
  } = _ref2;
33145
33194
  const propertyTree = properties ? {
33146
33195
  qProperty: properties
@@ -33161,7 +33210,8 @@
33161
33210
  }
33162
33211
  const exportFormat = exportProperties({
33163
33212
  propertyTree,
33164
- hypercubePath: helpers.getHypercubePath(sourceQae)
33213
+ hypercubePath: helpers.getHypercubePath(sourceQae),
33214
+ viewDataMode
33165
33215
  });
33166
33216
  const initial = utils.getValue(targetQae, 'properties.initial', {});
33167
33217
  const initialProperties = _objectSpread2({
@@ -33174,7 +33224,8 @@
33174
33224
  exportFormat,
33175
33225
  initialProperties,
33176
33226
  dataDefinition: utils.getValue(targetQae, 'data.targets.0.', {}),
33177
- hypercubePath: helpers.getHypercubePath(targetQae)
33227
+ hypercubePath: helpers.getHypercubePath(targetQae),
33228
+ viewDataMode
33178
33229
  });
33179
33230
  return newPropertyTree;
33180
33231
  };
@@ -34193,7 +34244,7 @@
34193
34244
  const Cell = reactExports.forwardRef((_ref6, ref) => {
34194
34245
  let {
34195
34246
  halo,
34196
- model,
34247
+ model: inputModel,
34197
34248
  initialSnOptions,
34198
34249
  initialSnPlugins,
34199
34250
  initialError,
@@ -34218,6 +34269,7 @@
34218
34269
  const theme = useTheme$1();
34219
34270
  const [cellRef, cellRect, cellNode] = useRect$1();
34220
34271
  const [state, dispatch] = reactExports.useReducer(contentReducer, initialState(initialError));
34272
+ const [model, setModel] = reactExports.useState(inputModel);
34221
34273
  const [layout, {
34222
34274
  validating,
34223
34275
  canCancel,
@@ -34371,6 +34423,7 @@
34371
34423
  },
34372
34424
  setSnOptions,
34373
34425
  setSnPlugins,
34426
+ setModel,
34374
34427
  getImperativeHandle() {
34375
34428
  var _state$sn;
34376
34429
  if ((_state$sn = state.sn) !== null && _state$sn !== void 0 && _state$sn.component && typeof state.sn.component.getImperativeHandle === 'function') {
@@ -36856,6 +36909,7 @@
36856
36909
  let mountedReference = null;
36857
36910
  let onMount = null;
36858
36911
  let onRender = null;
36912
+ let viewDataObjectId;
36859
36913
  const mounted = new Promise(resolve => {
36860
36914
  onMount = resolve;
36861
36915
  });
@@ -36993,6 +37047,49 @@
36993
37047
  });
36994
37048
  return propertyTree;
36995
37049
  },
37050
+ /**
37051
+ * Toggles the chart to a data view of the chart.
37052
+ *
37053
+ * The chart will be toggled to the type defined in the nebula context (dataViewType).
37054
+ *
37055
+ * The default dataViewType for nebula is sn-table. The specified chart type needs to be registered as well, in order to make it possible to render the data view.
37056
+ *
37057
+ * @experimental
37058
+ * @since 4.9.0
37059
+ * @param {boolean=} showDataView - If included, forces the chart into a specific state. True will show data view, and false will show the original chart. If not included it will always toggle between the two views.
37060
+ */
37061
+ async toggleDataView(showDataView) {
37062
+ let newModel;
37063
+ if (!viewDataObjectId && showDataView !== false) {
37064
+ let newType = halo.config.context.dataViewType;
37065
+ const oldProperties = await model.getEffectiveProperties();
37066
+ // Check if dataViewType is registered. Otherwise potentially fallback to table
37067
+ if (!halo.types.getSupportedVersion(newType)) {
37068
+ if (halo.types.getSupportedVersion('table')) {
37069
+ newType = 'table';
37070
+ } else {
37071
+ throw new Error('No data view type registered');
37072
+ }
37073
+ }
37074
+ const propertyTree = await convertTo({
37075
+ halo,
37076
+ model,
37077
+ cellRef,
37078
+ newType,
37079
+ properties: oldProperties,
37080
+ viewDataMode: true
37081
+ });
37082
+ newModel = await halo.app.createSessionObject(propertyTree.qProperty);
37083
+ viewDataObjectId = newModel.id;
37084
+ } else if (viewDataObjectId && showDataView !== true) {
37085
+ newModel = model;
37086
+ await halo.app.destroySessionObject(viewDataObjectId);
37087
+ viewDataObjectId = undefined;
37088
+ }
37089
+ if (newModel) {
37090
+ cellRef.current.setModel(newModel);
37091
+ }
37092
+ },
36996
37093
  /**
36997
37094
  * Listens to custom events from inside the visualization. See useEmitter
36998
37095
  * @experimental
@@ -37127,7 +37224,6 @@
37127
37224
  // setOptions() {}, // applied soft patch
37128
37225
  // resize() {},
37129
37226
  // show() {},
37130
- // toggleDataView() {},
37131
37227
  };
37132
37228
 
37133
37229
  return api;
@@ -39939,7 +40035,13 @@
39939
40035
  /** @type {boolean=} */
39940
40036
  keyboardNavigation: false,
39941
40037
  /** @type {boolean=} */
39942
- disableCellPadding: false
40038
+ disableCellPadding: false,
40039
+ /**
40040
+ * Type used for toggling to the data view (toggleDataView)
40041
+ * This type need to be registered as well
40042
+ * @type {string=}
40043
+ * */
40044
+ dataViewType: 'sn-table'
39943
40045
  };
39944
40046
  DEFAULT_CONFIG.context = DEFAULT_CONTEXT;
39945
40047