@nebula.js/stardust 4.8.1 → 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.1
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 = "cca9" ;
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.1" );
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) {
@@ -33188,7 +33188,8 @@
33188
33188
  model,
33189
33189
  cellRef,
33190
33190
  newType,
33191
- properties
33191
+ properties,
33192
+ viewDataMode = false
33192
33193
  } = _ref2;
33193
33194
  const propertyTree = properties ? {
33194
33195
  qProperty: properties
@@ -33209,7 +33210,8 @@
33209
33210
  }
33210
33211
  const exportFormat = exportProperties({
33211
33212
  propertyTree,
33212
- hypercubePath: helpers.getHypercubePath(sourceQae)
33213
+ hypercubePath: helpers.getHypercubePath(sourceQae),
33214
+ viewDataMode
33213
33215
  });
33214
33216
  const initial = utils.getValue(targetQae, 'properties.initial', {});
33215
33217
  const initialProperties = _objectSpread2({
@@ -33222,7 +33224,8 @@
33222
33224
  exportFormat,
33223
33225
  initialProperties,
33224
33226
  dataDefinition: utils.getValue(targetQae, 'data.targets.0.', {}),
33225
- hypercubePath: helpers.getHypercubePath(targetQae)
33227
+ hypercubePath: helpers.getHypercubePath(targetQae),
33228
+ viewDataMode
33226
33229
  });
33227
33230
  return newPropertyTree;
33228
33231
  };
@@ -34241,7 +34244,7 @@
34241
34244
  const Cell = reactExports.forwardRef((_ref6, ref) => {
34242
34245
  let {
34243
34246
  halo,
34244
- model,
34247
+ model: inputModel,
34245
34248
  initialSnOptions,
34246
34249
  initialSnPlugins,
34247
34250
  initialError,
@@ -34266,6 +34269,7 @@
34266
34269
  const theme = useTheme$1();
34267
34270
  const [cellRef, cellRect, cellNode] = useRect$1();
34268
34271
  const [state, dispatch] = reactExports.useReducer(contentReducer, initialState(initialError));
34272
+ const [model, setModel] = reactExports.useState(inputModel);
34269
34273
  const [layout, {
34270
34274
  validating,
34271
34275
  canCancel,
@@ -34419,6 +34423,7 @@
34419
34423
  },
34420
34424
  setSnOptions,
34421
34425
  setSnPlugins,
34426
+ setModel,
34422
34427
  getImperativeHandle() {
34423
34428
  var _state$sn;
34424
34429
  if ((_state$sn = state.sn) !== null && _state$sn !== void 0 && _state$sn.component && typeof state.sn.component.getImperativeHandle === 'function') {
@@ -36904,6 +36909,7 @@
36904
36909
  let mountedReference = null;
36905
36910
  let onMount = null;
36906
36911
  let onRender = null;
36912
+ let viewDataObjectId;
36907
36913
  const mounted = new Promise(resolve => {
36908
36914
  onMount = resolve;
36909
36915
  });
@@ -37041,6 +37047,49 @@
37041
37047
  });
37042
37048
  return propertyTree;
37043
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
+ },
37044
37093
  /**
37045
37094
  * Listens to custom events from inside the visualization. See useEmitter
37046
37095
  * @experimental
@@ -37175,7 +37224,6 @@
37175
37224
  // setOptions() {}, // applied soft patch
37176
37225
  // resize() {},
37177
37226
  // show() {},
37178
- // toggleDataView() {},
37179
37227
  };
37180
37228
 
37181
37229
  return api;
@@ -39987,7 +40035,13 @@
39987
40035
  /** @type {boolean=} */
39988
40036
  keyboardNavigation: false,
39989
40037
  /** @type {boolean=} */
39990
- 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'
39991
40045
  };
39992
40046
  DEFAULT_CONFIG.context = DEFAULT_CONTEXT;
39993
40047