@nebula.js/stardust 2.1.0 → 2.2.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 v2.1.0
2
+ * @nebula.js/stardust v2.2.0
3
3
  * Copyright (c) 2021 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -11479,7 +11479,7 @@
11479
11479
  return [appSelections, navState];
11480
11480
  }
11481
11481
 
11482
- var NEBULA_VERSION_HASH = "5337" ;
11482
+ var NEBULA_VERSION_HASH = "34e9" ;
11483
11483
  var counter = 0;
11484
11484
  var NebulaApp = react.exports.forwardRef(function (_ref, ref) {
11485
11485
  var initialContext = _ref.initialContext,
@@ -11555,7 +11555,7 @@
11555
11555
  var appRef = React.createRef();
11556
11556
  var element = document.createElement('div');
11557
11557
  element.style.display = 'none';
11558
- element.setAttribute('data-nebulajs-version', "2.1.0" );
11558
+ element.setAttribute('data-nebulajs-version', "2.2.0" );
11559
11559
  element.setAttribute('data-app-id', app.id);
11560
11560
  document.body.appendChild(element);
11561
11561
  ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
@@ -19536,6 +19536,9 @@
19536
19536
  ref: !addAnchor ? ref : null,
19537
19537
  title: item.label,
19538
19538
  onClick: item.action,
19539
+ onKeyDown: function onKeyDown(e) {
19540
+ return ['Enter', ' ', 'Spacebar'].includes(e.key) && item.keyboardAction();
19541
+ },
19539
19542
  disabled: disabled,
19540
19543
  style: style,
19541
19544
  className: ActionElement.className
@@ -19582,7 +19585,9 @@
19582
19585
  _ref$onConfirm = _ref.onConfirm,
19583
19586
  onConfirm = _ref$onConfirm === void 0 ? function () {} : _ref$onConfirm,
19584
19587
  _ref$onCancel = _ref.onCancel,
19585
- onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
19588
+ onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
19589
+ _ref$onKeyDeactivate = _ref.onKeyDeactivate,
19590
+ onKeyDeactivate = _ref$onKeyDeactivate === void 0 ? function () {} : _ref$onKeyDeactivate;
19586
19591
 
19587
19592
  var _useContext = react.exports.useContext(InstanceContext),
19588
19593
  translator = _useContext.translator;
@@ -19606,8 +19611,13 @@
19606
19611
  return api.canCancel();
19607
19612
  },
19608
19613
  action: function action() {
19614
+ onCancel();
19609
19615
  api.cancel();
19616
+ },
19617
+ keyboardAction: function keyboardAction(e) {
19618
+ onKeyDeactivate(e);
19610
19619
  onCancel();
19620
+ api.cancel();
19611
19621
  },
19612
19622
  getSvgIconShape: close
19613
19623
  }, {
@@ -19618,8 +19628,13 @@
19618
19628
  return api.canConfirm();
19619
19629
  },
19620
19630
  action: function action() {
19631
+ onConfirm();
19621
19632
  api.confirm();
19633
+ },
19634
+ keyboardAction: function keyboardAction(e) {
19635
+ onKeyDeactivate(e);
19622
19636
  onConfirm();
19637
+ api.confirm();
19623
19638
  },
19624
19639
  getSvgIconShape: tick
19625
19640
  }];
@@ -19826,14 +19841,19 @@
19826
19841
  popover = _ref2$popover === void 0 ? {
19827
19842
  show: false,
19828
19843
  anchorEl: null
19829
- } : _ref2$popover;
19844
+ } : _ref2$popover,
19845
+ _ref2$focusHandler = _ref2.focusHandler,
19846
+ focusHandler = _ref2$focusHandler === void 0 ? null : _ref2$focusHandler,
19847
+ _ref2$actionsRefMock = _ref2.actionsRefMock,
19848
+ actionsRefMock = _ref2$actionsRefMock === void 0 ? null : _ref2$actionsRefMock;
19830
19849
  var defaultSelectionActions = useDefaultSelectionActions(selections);
19831
19850
 
19832
19851
  var _useStyles2 = useStyles$8(),
19833
19852
  itemSpacing = _useStyles2.itemSpacing;
19834
19853
 
19835
19854
  var _useContext = react.exports.useContext(InstanceContext),
19836
- translator = _useContext.translator;
19855
+ translator = _useContext.translator,
19856
+ keyboardNavigation = _useContext.keyboardNavigation;
19837
19857
 
19838
19858
  var _useState = react.exports.useState(false),
19839
19859
  _useState2 = _slicedToArray$2(_useState, 2),
@@ -19856,12 +19876,21 @@
19856
19876
  setMoreAlignTo = _useState8[1];
19857
19877
 
19858
19878
  var moreRef = react.exports.useRef();
19879
+ var actionsRef = react.exports.useRef();
19859
19880
  var theme = useTheme$2();
19860
19881
  var dividerStyle = react.exports.useMemo(function () {
19861
19882
  return {
19862
19883
  margin: theme.spacing(0.5, 0)
19863
19884
  };
19864
19885
  });
19886
+
19887
+ var getEnabledButton = function getEnabledButton(last) {
19888
+ var actionsElement = actionsRef.current || actionsRefMock;
19889
+ if (!actionsElement) return null;
19890
+ var buttons = actionsElement.querySelectorAll('button:not(.Mui-disabled)');
19891
+ return buttons[last ? buttons.length - 1 : 0];
19892
+ };
19893
+
19865
19894
  react.exports.useEffect(function () {
19866
19895
  return function () {
19867
19896
  return setShowMoreItems(false);
@@ -19870,6 +19899,22 @@
19870
19899
  react.exports.useEffect(function () {
19871
19900
  setMoreEnabled(more$1.enabled);
19872
19901
  }, [more$1.enabled]);
19902
+ react.exports.useEffect(function () {
19903
+ if (!focusHandler) return;
19904
+
19905
+ var focusFirst = function focusFirst() {
19906
+ var enabledButton = getEnabledButton(false);
19907
+ enabledButton && enabledButton.focus();
19908
+ };
19909
+
19910
+ var focusLast = function focusLast() {
19911
+ var enabledButton = getEnabledButton(true);
19912
+ enabledButton && enabledButton.focus();
19913
+ };
19914
+
19915
+ focusHandler.on('focus_toolbar_first', focusFirst);
19916
+ focusHandler.on('focus_toolbar_last', focusLast);
19917
+ }, []);
19873
19918
  var newActions = react.exports.useMemo(function () {
19874
19919
  return actions.filter(function (a) {
19875
19920
  return !a.hidden;
@@ -19902,10 +19947,23 @@
19902
19947
  setMoreAlignTo(moreRef);
19903
19948
  }
19904
19949
 
19950
+ var tabCallback = // if keyboardNavigation is true, create a callback to handle tabbing from the first/last button in the toolbar that resets focus on the content
19951
+ keyboardNavigation && focusHandler && focusHandler.refocusContent ? function (evt) {
19952
+ if (evt.key !== 'Tab') return;
19953
+ var isTabbingOut = evt.shiftKey && getEnabledButton(false) === evt.target || !evt.shiftKey && getEnabledButton(true) === evt.target;
19954
+
19955
+ if (isTabbingOut) {
19956
+ evt.preventDefault();
19957
+ evt.stopPropagation();
19958
+ focusHandler.refocusContent();
19959
+ }
19960
+ } : null;
19905
19961
  var showActions = newActions.length > 0;
19906
19962
  var showMore = moreActions.length > 0;
19907
19963
  var showDivider = showActions && selections.show || showMore && selections.show;
19908
19964
  var Actions = /*#__PURE__*/React.createElement(Grid$1, {
19965
+ ref: actionsRef,
19966
+ onKeyDown: tabCallback,
19909
19967
  container: true,
19910
19968
  spacing: 0,
19911
19969
  wrap: "nowrap"
@@ -22124,7 +22182,9 @@
22124
22182
 
22125
22183
  function fieldType(f) {
22126
22184
  if ( // a string starting with '=' is just a convention we use
22127
- typeof f === 'string' && f[0] === '=' || _typeof$3(f) === 'object' && f.qDef && f.qDef.qDef || _typeof$3(f) === 'object' && f.qLibraryId && f.type === 'measure') {
22185
+ typeof f === 'string' && f[0] === '=' || // based on NxMeasure and NxInlineMeasureDef
22186
+ _typeof$3(f) === 'object' && f.qDef && f.qDef.qDef || // use 'type' instead of 'qType' since this is not a real property
22187
+ _typeof$3(f) === 'object' && f.qLibraryId && f.type === 'measure') {
22128
22188
  return 'measure';
22129
22189
  }
22130
22190
 
@@ -23513,7 +23573,8 @@
23513
23573
  var layout = _ref.layout,
23514
23574
  sn = _ref.sn,
23515
23575
  anchorEl = _ref.anchorEl,
23516
- hovering = _ref.hovering;
23576
+ hovering = _ref.hovering,
23577
+ focusHandler = _ref.focusHandler;
23517
23578
  var showTitle = layout.showTitles && !!layout.title;
23518
23579
  var showSubtitle = layout.showTitles && !!layout.subtitle;
23519
23580
  var showInSelectionActions = layout.qSelectionInfo && layout.qSelectionInfo.qInSelections;
@@ -23559,13 +23620,15 @@
23559
23620
  show: showToolbar,
23560
23621
  selections: {
23561
23622
  show: showInSelectionActions,
23562
- api: sn.component.selections
23623
+ api: sn.component.selections,
23624
+ onKeyDeactivate: focusHandler.refocusContent
23563
23625
  },
23564
23626
  actions: actions,
23565
23627
  popover: {
23566
23628
  show: showPopoverToolbar,
23567
23629
  anchorEl: anchorEl
23568
- }
23630
+ },
23631
+ focusHandler: focusHandler
23569
23632
  });
23570
23633
  return /*#__PURE__*/React.createElement(Grid$1, {
23571
23634
  ref: containerRef,
@@ -23970,7 +24033,7 @@
23970
24033
  return clearTimeout(handle);
23971
24034
  };
23972
24035
  }, []);
23973
- return showLoading && /*#__PURE__*/React.createElement(Loading, null);
24036
+ return showLoading ? /*#__PURE__*/React.createElement(Loading, null) : null;
23974
24037
  };
23975
24038
 
23976
24039
  var handleModal = function handleModal(_ref2) {
@@ -24211,12 +24274,12 @@
24211
24274
 
24212
24275
  var loadType = /*#__PURE__*/function () {
24213
24276
  var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref7) {
24214
- var dispatch, types, visualization, version, model, app, selections, blurCallback, nebbie, snType, sn;
24277
+ var dispatch, types, visualization, version, model, app, selections, nebbie, focusHandler, snType, sn;
24215
24278
  return regeneratorRuntime.wrap(function _callee3$(_context3) {
24216
24279
  while (1) {
24217
24280
  switch (_context3.prev = _context3.next) {
24218
24281
  case 0:
24219
- dispatch = _ref7.dispatch, types = _ref7.types, visualization = _ref7.visualization, version = _ref7.version, model = _ref7.model, app = _ref7.app, selections = _ref7.selections, blurCallback = _ref7.blurCallback, nebbie = _ref7.nebbie;
24282
+ dispatch = _ref7.dispatch, types = _ref7.types, visualization = _ref7.visualization, version = _ref7.version, model = _ref7.model, app = _ref7.app, selections = _ref7.selections, nebbie = _ref7.nebbie, focusHandler = _ref7.focusHandler;
24220
24283
  _context3.prev = 1;
24221
24284
  _context3.next = 4;
24222
24285
  return getType({
@@ -24232,7 +24295,7 @@
24232
24295
  app: app,
24233
24296
  selections: selections,
24234
24297
  nebbie: nebbie,
24235
- blurCallback: blurCallback
24298
+ focusHandler: focusHandler
24236
24299
  });
24237
24300
  return _context3.abrupt("return", sn);
24238
24301
 
@@ -24306,9 +24369,10 @@
24306
24369
  appLayout = _useAppLayout2[0];
24307
24370
 
24308
24371
  var _useRect3 = useRect$1(),
24309
- _useRect4 = _slicedToArray$2(_useRect3, 2),
24372
+ _useRect4 = _slicedToArray$2(_useRect3, 3),
24310
24373
  contentRef = _useRect4[0],
24311
- contentRect = _useRect4[1];
24374
+ contentRect = _useRect4[1],
24375
+ contentNode = _useRect4[2];
24312
24376
 
24313
24377
  var _useState3 = react.exports.useState(initialSnOptions),
24314
24378
  _useState4 = _slicedToArray$2(_useState3, 2),
@@ -24333,6 +24397,27 @@
24333
24397
  enter: null,
24334
24398
  leave: null
24335
24399
  });
24400
+ var focusHandler = react.exports.useRef({
24401
+ focusToolbarButton: function focusToolbarButton(last) {
24402
+ // eslint-disable-next-line react/no-this-in-sfc
24403
+ this.emit(last ? 'focus_toolbar_last' : 'focus_toolbar_first');
24404
+ }
24405
+ });
24406
+ react.exports.useEffect(function () {
24407
+ eventmixin(focusHandler.current);
24408
+ }, []);
24409
+
24410
+ focusHandler.current.blurCallback = function (resetFocus) {
24411
+ halo.root.toggleFocusOfCells();
24412
+
24413
+ if (resetFocus && contentNode) {
24414
+ contentNode.focus();
24415
+ }
24416
+ };
24417
+
24418
+ focusHandler.current.refocusContent = function () {
24419
+ state.sn.component && typeof state.sn.component.focus === 'function' && state.sn.component.focus();
24420
+ };
24336
24421
 
24337
24422
  var handleOnMouseEnter = function handleOnMouseEnter() {
24338
24423
  if (hoveringDebouncer.current.leave) {
@@ -24365,14 +24450,6 @@
24365
24450
  }
24366
24451
  };
24367
24452
 
24368
- var relinquishFocus = function relinquishFocus(resetFocus) {
24369
- halo.root.toggleFocusOfCells();
24370
-
24371
- if (resetFocus && cellNode) {
24372
- cellNode.focus();
24373
- }
24374
- };
24375
-
24376
24453
  react.exports.useEffect(function () {
24377
24454
  if (initialError || !appLayout || !layout) {
24378
24455
  return undefined;
@@ -24445,7 +24522,7 @@
24445
24522
  app: app,
24446
24523
  selections: selections,
24447
24524
  nebbie: nebbie,
24448
- blurCallback: relinquishFocus
24525
+ focusHandler: focusHandler.current
24449
24526
  });
24450
24527
 
24451
24528
  case 3:
@@ -24646,14 +24723,12 @@
24646
24723
  height: '100%',
24647
24724
  overflow: 'hidden'
24648
24725
  },
24649
- tabIndex: keyboardNavigation ? 0 : -1,
24650
24726
  elevation: 0,
24651
24727
  square: true,
24652
24728
  className: CellElement.className,
24653
24729
  ref: cellRef,
24654
24730
  onMouseEnter: handleOnMouseEnter,
24655
- onMouseLeave: handleOnMouseLeave,
24656
- onKeyDown: keyboardNavigation ? handleKeyDown : null
24731
+ onMouseLeave: handleOnMouseLeave
24657
24732
  }, /*#__PURE__*/React.createElement(Grid$1, {
24658
24733
  container: true,
24659
24734
  direction: "column",
@@ -24670,8 +24745,11 @@
24670
24745
  layout: layout,
24671
24746
  sn: state.sn,
24672
24747
  anchorEl: cellNode,
24673
- hovering: hovering
24748
+ hovering: hovering,
24749
+ focusHandler: focusHandler.current
24674
24750
  }, "\xA0"), /*#__PURE__*/React.createElement(Grid$1, {
24751
+ tabIndex: keyboardNavigation ? 0 : -1,
24752
+ onKeyDown: keyboardNavigation ? handleKeyDown : null,
24675
24753
  item: true,
24676
24754
  xs: true,
24677
24755
  style: {
@@ -26956,6 +27034,7 @@
26956
27034
  * @property {boolean} active Set to true when the chart is activated, ie a user tabs to the chart and presses Enter or Space.
26957
27035
  * @property {function=} blur Function used by the visualization to tell Nebula to it wants to relinquish focus
26958
27036
  * @property {function=} focus Function used by the visualization to tell Nebula to it wants focus
27037
+ * @property {function=} focusSelection Function used by the visualization to tell Nebula to focus the selection toolbar
26959
27038
  */
26960
27039
 
26961
27040
  /**
@@ -26989,7 +27068,7 @@
26989
27068
 
26990
27069
  function useKeyboard() {
26991
27070
  var keyboardNavigation = useInternalContext('keyboardNavigation');
26992
- var blurCallback = useInternalContext('blurCallback');
27071
+ var focusHandler = useInternalContext('focusHandler');
26993
27072
 
26994
27073
  if (!currentComponent.__hooks.accessibility.exitFunction) {
26995
27074
  var exitFunction = function (resetFocus) {
@@ -26997,7 +27076,7 @@
26997
27076
 
26998
27077
  if (acc.enabled && acc.active) {
26999
27078
  blur(this);
27000
- blurCallback && blurCallback(resetFocus);
27079
+ focusHandler && focusHandler.blurCallback && focusHandler.blurCallback(resetFocus);
27001
27080
  }
27002
27081
  }.bind(currentComponent);
27003
27082
 
@@ -27007,22 +27086,34 @@
27007
27086
  var acc = this.__hooks.accessibility;
27008
27087
 
27009
27088
  if (acc.enabled && !acc.active) {
27010
- blurCallback && blurCallback(false);
27089
+ focusHandler && focusHandler.blurCallback && focusHandler.blurCallback(false);
27011
27090
  focus(this);
27012
27091
  }
27013
27092
  }.bind(currentComponent);
27014
27093
 
27015
27094
  currentComponent.__hooks.accessibility.focusFunction = focusFunction;
27095
+
27096
+ var focusSelectionFunction = function (focusLast) {
27097
+ var acc = this.__hooks.accessibility;
27098
+
27099
+ if (acc.enabled) {
27100
+ focusHandler && focusHandler.focusToolbarButton && focusHandler.focusToolbarButton(focusLast);
27101
+ }
27102
+ }.bind(currentComponent);
27103
+
27104
+ currentComponent.__hooks.accessibility.focusSelectionFunction = focusSelectionFunction;
27016
27105
  }
27017
27106
 
27018
27107
  var focusFunc = currentComponent.__hooks.accessibility.focusFunction;
27019
27108
  var exitFunc = currentComponent.__hooks.accessibility.exitFunction;
27109
+ var focusSelectionFunc = currentComponent.__hooks.accessibility.focusSelectionFunction;
27020
27110
 
27021
27111
  var _useState9 = useState({
27022
27112
  active: false,
27023
27113
  enabled: keyboardNavigation,
27024
27114
  blur: exitFunc,
27025
- focus: focusFunc
27115
+ focus: focusFunc,
27116
+ focusSelection: focusSelectionFunc
27026
27117
  }),
27027
27118
  _useState10 = _slicedToArray$2(_useState9, 2),
27028
27119
  acc = _useState10[0],
@@ -27035,7 +27126,8 @@
27035
27126
  active: false,
27036
27127
  enabled: keyboardNavigation,
27037
27128
  blur: exitFunc,
27038
- focus: focusFunc
27129
+ focus: focusFunc,
27130
+ focusSelection: focusSelectionFunc
27039
27131
  });
27040
27132
  }, [keyboardNavigation]);
27041
27133
  return acc;
@@ -27054,7 +27146,8 @@
27054
27146
  active: true,
27055
27147
  enabled: acc.enabled,
27056
27148
  blur: acc.exitFunction,
27057
- focus: acc.focusFunction
27149
+ focus: acc.focusFunction,
27150
+ focusSelection: acc.focusSelectionFunction
27058
27151
  });
27059
27152
  }
27060
27153
  }
@@ -27072,7 +27165,8 @@
27072
27165
  active: false,
27073
27166
  enabled: acc.enabled,
27074
27167
  blur: acc.exitFunction,
27075
- focus: acc.focusFunction
27168
+ focus: acc.focusFunction,
27169
+ focusSelection: acc.focusSelectionFunction
27076
27170
  });
27077
27171
  }
27078
27172
  }
@@ -27148,7 +27242,7 @@
27148
27242
  layout: {},
27149
27243
  appLayout: {},
27150
27244
  keyboardNavigation: opts.keyboardNavigation,
27151
- blurCallback: opts.blurCallback,
27245
+ focusHandler: opts.focusHandler,
27152
27246
  constraints: forcedConstraints,
27153
27247
  options: {},
27154
27248
  plugins: []
@@ -27183,9 +27277,9 @@
27183
27277
  changed = true;
27184
27278
  }
27185
27279
 
27186
- if (r.context && r.context.blurCallback) {
27280
+ if (r.context && r.context.focusHandler) {
27187
27281
  // Needs to be added here due to how the client renders
27188
- this.context.blurCallback = r.context.blurCallback;
27282
+ this.context.focusHandler = r.context.focusHandler;
27189
27283
  }
27190
27284
 
27191
27285
  if (r.options) {