@nebula.js/stardust 4.0.0-alpha.2 → 4.0.0-alpha.4

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.0.0-alpha.2
2
+ * @nebula.js/stardust v4.0.0-alpha.4
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -1560,6 +1560,26 @@
1560
1560
  "zh-TW": "選取可能值"
1561
1561
  }
1562
1562
  };
1563
+ var SelectionToolbar_ClickToUnlock = {
1564
+ id: "SelectionToolbar.ClickToUnlock",
1565
+ locale: {
1566
+ "de-DE": "Klicken zum Freigeben",
1567
+ "en-US": "Click to unlock",
1568
+ "es-ES": "Haga clic para desbloquearla",
1569
+ "fr-FR": "Cliquez pour déverrouiller",
1570
+ "it-IT": "Fare clic per sbloccare",
1571
+ "ja-JP": "クリックしてロック解除",
1572
+ "ko-KR": "잠금을 해제하려면 클릭하십시오.",
1573
+ "nl-NL": "Klik om te ontgrendelen",
1574
+ "pl-PL": "Aby odblokować, kliknij",
1575
+ "pt-BR": "Clique para destravar",
1576
+ "ru-RU": "Щелкните, чтобы разблокировать",
1577
+ "sv-SE": "Klicka för att låsa upp",
1578
+ "tr-TR": "Kilidi kaldırmak için tıklayın",
1579
+ "zh-CN": "单击以解锁",
1580
+ "zh-TW": "按一下以解除鎖定"
1581
+ }
1582
+ };
1563
1583
  var Visualization_Incomplete = {
1564
1584
  id: "Visualization.Incomplete",
1565
1585
  locale: {
@@ -1731,6 +1751,7 @@
1731
1751
  Selection_SelectAlternative: Selection_SelectAlternative,
1732
1752
  Selection_SelectExcluded: Selection_SelectExcluded,
1733
1753
  Selection_SelectPossible: Selection_SelectPossible,
1754
+ SelectionToolbar_ClickToUnlock: SelectionToolbar_ClickToUnlock,
1734
1755
  Visualization_Incomplete: Visualization_Incomplete,
1735
1756
  Visualization_Incomplete_Dimensions: Visualization_Incomplete_Dimensions,
1736
1757
  Visualization_Incomplete_Measures: Visualization_Incomplete_Measures,
@@ -15399,7 +15420,7 @@
15399
15420
  return cache[key];
15400
15421
  }
15401
15422
 
15402
- const NEBULA_VERSION_HASH = "9a45" ;
15423
+ const NEBULA_VERSION_HASH = "0bc0" ;
15403
15424
  ClassNameGenerator$1.configure(componentName => {
15404
15425
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
15405
15426
  });
@@ -15607,7 +15628,7 @@
15607
15628
  const appRef = React.createRef();
15608
15629
  const element = document.createElement('div');
15609
15630
  element.style.display = 'none';
15610
- element.setAttribute('data-nebulajs-version', "4.0.0-alpha.2" );
15631
+ element.setAttribute('data-nebulajs-version', "4.0.0-alpha.4" );
15611
15632
  element.setAttribute('data-app-id', app.id);
15612
15633
  document.body.appendChild(element);
15613
15634
  const root = client.createRoot(element);
@@ -21956,6 +21977,8 @@
21956
21977
  function getFieldKeyboardNavigation(_ref) {
21957
21978
  let {
21958
21979
  select,
21980
+ selectAll,
21981
+ onCtrlF,
21959
21982
  confirm,
21960
21983
  cancel,
21961
21984
  setScrollPosition,
@@ -21975,7 +21998,8 @@
21975
21998
  const {
21976
21999
  keyCode,
21977
22000
  shiftKey = false,
21978
- ctrlKey = false
22001
+ ctrlKey = false,
22002
+ metaKey = false
21979
22003
  } = event.nativeEvent;
21980
22004
  switch (keyCode) {
21981
22005
  case KEYS.SHIFT:
@@ -22030,6 +22054,18 @@
22030
22054
  }
22031
22055
  setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('end');
22032
22056
  break;
22057
+ case KEYS.A:
22058
+ if (ctrlKey || metaKey) {
22059
+ selectAll();
22060
+ break;
22061
+ }
22062
+ return;
22063
+ case KEYS.F:
22064
+ if (ctrlKey || metaKey) {
22065
+ onCtrlF();
22066
+ break;
22067
+ }
22068
+ return;
22033
22069
  default:
22034
22070
  return;
22035
22071
  // don't stop propagation since we want to outsource keydown to other handlers.
@@ -22413,7 +22449,7 @@
22413
22449
  ["& .".concat(rowColClasses.frequencyCount)]: _objectSpread2(_objectSpread2({
22414
22450
  justifyContent: 'flex-end'
22415
22451
  }, ellipsis), {}, {
22416
- flex: "0 1 ".concat(frequencyWidth, "px"),
22452
+ flex: "0 1 ".concat(frequencyWidth + (showIcon || checkboxes ? 0 : iconWidth), "px"),
22417
22453
  textAlign: 'right',
22418
22454
  paddingLeft: '2px'
22419
22455
  }),
@@ -24716,6 +24752,8 @@
24716
24752
  histogram,
24717
24753
  isSingleSelect,
24718
24754
  select,
24755
+ selectAll,
24756
+ onCtrlF,
24719
24757
  textAlign,
24720
24758
  selections,
24721
24759
  keyboard,
@@ -24773,7 +24811,9 @@
24773
24811
  select,
24774
24812
  confirm: () => selections === null || selections === void 0 ? void 0 : selections.confirm.call(selections),
24775
24813
  cancel: () => selections === null || selections === void 0 ? void 0 : selections.cancel.call(selections),
24776
- setScrollPosition
24814
+ setScrollPosition,
24815
+ selectAll,
24816
+ onCtrlF
24777
24817
  },
24778
24818
  frequencyMax,
24779
24819
  histogram,
@@ -25425,7 +25465,10 @@
25425
25465
  if (!field) {
25426
25466
  return field;
25427
25467
  }
25428
- return "".concat(field.replace(/\]/g, ']]'));
25468
+ if (/^[A-Za-z][A-Za-z0-9_]*$/.test(field)) {
25469
+ return field;
25470
+ }
25471
+ return "[".concat(field.replace(/\]/g, ']]'), "]");
25429
25472
  };
25430
25473
  const needToFetchFrequencyMax = layout => (layout === null || layout === void 0 ? void 0 : layout.frequencyMax) === 'fetch';
25431
25474
  const getFrequencyMaxExpression = field => {
@@ -25441,8 +25484,9 @@
25441
25484
  };
25442
25485
 
25443
25486
  const useFrequencyMax = (app, layout) => {
25444
- const [frequencyMax, setFrequencyMax] = reactExports.useState();
25445
25487
  const needFetch = needToFetchFrequencyMax(layout);
25488
+ const [frequencyMax, setFrequencyMax] = reactExports.useState();
25489
+ const [awaitingFrequencyMax, setAwaitingFrequencyMax] = reactExports.useState(needFetch);
25446
25490
  reactExports.useEffect(() => {
25447
25491
  if (!needFetch) {
25448
25492
  return;
@@ -25450,10 +25494,14 @@
25450
25494
  const fetch = async () => {
25451
25495
  const newValue = await getFrequencyMax(layout, app);
25452
25496
  setFrequencyMax(newValue);
25497
+ setAwaitingFrequencyMax(false);
25453
25498
  };
25454
25499
  fetch();
25455
25500
  }, [needFetch && layout]);
25456
- return needFetch ? frequencyMax : layout === null || layout === void 0 ? void 0 : layout.frequencyMax;
25501
+ return {
25502
+ frequencyMax: needFetch ? frequencyMax : layout === null || layout === void 0 ? void 0 : layout.frequencyMax,
25503
+ awaitingFrequencyMax
25504
+ };
25457
25505
  };
25458
25506
 
25459
25507
  const _excluded$4 = ["isLoadingData"];
@@ -25486,7 +25534,9 @@
25486
25534
  },
25487
25535
  currentScrollIndex = {
25488
25536
  set: () => {}
25489
- }
25537
+ },
25538
+ renderedCallback,
25539
+ onCtrlF
25490
25540
  } = _ref;
25491
25541
  const [initScrollPosIsSet, setInitScrollPosIsSet] = reactExports.useState(false);
25492
25542
  const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
@@ -25506,6 +25556,10 @@
25506
25556
 
25507
25557
  // The time from scroll end until new data is being fetched, may be exposed in API later on.
25508
25558
  const scrollTimeout = 0;
25559
+ const {
25560
+ frequencyMax,
25561
+ awaitingFrequencyMax
25562
+ } = useFrequencyMax(app, layout);
25509
25563
  const _useItemsLoader = useItemsLoader({
25510
25564
  local,
25511
25565
  loaderRef,
@@ -25531,11 +25585,15 @@
25531
25585
  if (itemsLoader !== null && itemsLoader !== void 0 && itemsLoader.pages) {
25532
25586
  selectionState.update({
25533
25587
  setPages,
25534
- pages: itemsLoader === null || itemsLoader === void 0 ? void 0 : itemsLoader.pages,
25588
+ pages: itemsLoader.pages,
25535
25589
  isSingleSelect,
25536
25590
  selectDisabled,
25537
25591
  layout
25538
25592
  });
25593
+ if (itemsLoader.pages.length && !awaitingFrequencyMax) {
25594
+ // All necessary data fetching done - signal rendering done!
25595
+ renderedCallback();
25596
+ }
25539
25597
  }
25540
25598
  const isItemLoaded = reactExports.useCallback(index => {
25541
25599
  if (!(pages !== null && pages !== void 0 && pages.length) || !local.current.validPages) {
@@ -25694,7 +25752,10 @@
25694
25752
  last
25695
25753
  }))
25696
25754
  });
25697
- const frequencyMax = useFrequencyMax(app, layout);
25755
+ const selectAll = () => {
25756
+ selectionState.clearItemStates(false);
25757
+ model.selectListObjectAll('/qListObjectDef');
25758
+ };
25698
25759
  const {
25699
25760
  List,
25700
25761
  Grid
@@ -25710,6 +25771,8 @@
25710
25771
  showGray,
25711
25772
  interactionEvents,
25712
25773
  select,
25774
+ selectAll,
25775
+ onCtrlF,
25713
25776
  textAlign,
25714
25777
  isVertical,
25715
25778
  pages,
@@ -26175,15 +26238,12 @@
26175
26238
  const popoverStyle = {
26176
26239
  pointerEvents: 'none'
26177
26240
  };
26178
- const popoverAnchorOrigin = {
26179
- vertical: 'top',
26180
- horizontal: 'right'
26181
- };
26182
26241
  const popoverTransformOrigin = {
26183
26242
  vertical: 'bottom',
26184
26243
  horizontal: 'right'
26185
26244
  };
26186
26245
  function ActionsToolbar(_ref3) {
26246
+ var _popover$anchorEl$cli, _popover$anchorEl;
26187
26247
  let {
26188
26248
  show = true,
26189
26249
  actions = [],
@@ -26222,6 +26282,10 @@
26222
26282
  const dividerStyle = reactExports.useMemo(() => ({
26223
26283
  margin: theme.spacing(0.5, 0)
26224
26284
  }));
26285
+ const popoverAnchorOrigin = {
26286
+ vertical: 15,
26287
+ horizontal: ((_popover$anchorEl$cli = (_popover$anchorEl = popover.anchorEl) === null || _popover$anchorEl === void 0 ? void 0 : _popover$anchorEl.clientWidth) !== null && _popover$anchorEl$cli !== void 0 ? _popover$anchorEl$cli : 0) - 7
26288
+ };
26225
26289
  const getEnabledButton = last => {
26226
26290
  const actionsElement = actionsRef.current || actionsRefMock;
26227
26291
  if (!actionsElement) return null;
@@ -26383,7 +26447,8 @@
26383
26447
  autoFocus = true,
26384
26448
  wildCardSearch = false,
26385
26449
  searchEnabled,
26386
- direction
26450
+ direction,
26451
+ hide
26387
26452
  } = _ref3;
26388
26453
  const {
26389
26454
  translator
@@ -26469,6 +26534,16 @@
26469
26534
  e.preventDefault();
26470
26535
  e.stopPropagation();
26471
26536
  break;
26537
+ case 'f':
26538
+ case 'F':
26539
+ if (e.ctrlKey || e.metaKey) {
26540
+ if (hide) {
26541
+ hide();
26542
+ }
26543
+ e.preventDefault();
26544
+ e.stopPropagation();
26545
+ }
26546
+ break;
26472
26547
  }
26473
26548
  return response;
26474
26549
  };
@@ -26926,6 +27001,7 @@
26926
27001
  const open = show && Boolean(alignTo.current);
26927
27002
  const [listCount, setListCount] = reactExports.useState(0);
26928
27003
  const theme = useTheme$1();
27004
+ const searchContainerRef = reactExports.useRef();
26929
27005
  const [model] = useSessionModel({
26930
27006
  qInfo: {
26931
27007
  qType: 'njsListbox'
@@ -26987,6 +27063,10 @@
26987
27063
  translator,
26988
27064
  selectionState: selectionState$1
26989
27065
  });
27066
+ const onCtrlF = () => {
27067
+ const input = searchContainerRef.current.querySelector('input');
27068
+ input === null || input === void 0 ? void 0 : input.focus();
27069
+ };
26990
27070
  const hasSelections$1 = hasSelections(layout);
26991
27071
  return /*#__PURE__*/React.createElement(Popover$1, {
26992
27072
  open: open,
@@ -27053,7 +27133,10 @@
27053
27133
  xs: true
27054
27134
  }, /*#__PURE__*/React.createElement("div", {
27055
27135
  ref: moreAlignTo
27056
- }), /*#__PURE__*/React.createElement(ListBoxSearch, {
27136
+ }), /*#__PURE__*/React.createElement(Grid$1, {
27137
+ item: true,
27138
+ ref: searchContainerRef
27139
+ }, /*#__PURE__*/React.createElement(ListBoxSearch, {
27057
27140
  visible: true,
27058
27141
  model: model,
27059
27142
  listCount: listCount,
@@ -27063,14 +27146,15 @@
27063
27146
  enabled: false
27064
27147
  },
27065
27148
  autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : true
27066
- }), /*#__PURE__*/React.createElement(ListBox, {
27149
+ })), /*#__PURE__*/React.createElement(ListBox, {
27067
27150
  model: model,
27068
27151
  app: app,
27069
27152
  layout: layout,
27070
27153
  selections: selections,
27071
27154
  selectionState: selectionState$1,
27072
27155
  direction: "ltr",
27073
- onSetListCount: c => setListCount(c)
27156
+ onSetListCount: c => setListCount(c),
27157
+ onCtrlF: onCtrlF
27074
27158
  }))));
27075
27159
  }
27076
27160
 
@@ -28416,19 +28500,20 @@
28416
28500
  listboxWrapper: "".concat(PREFIX$4, "-listboxWrapper")
28417
28501
  };
28418
28502
  const StyledGrid$3 = styled$1(Grid$1, {
28419
- shouldForwardProp: p => !['containerPadding'].includes(p)
28503
+ shouldForwardProp: p => !['containerPadding', 'hasIcon'].includes(p)
28420
28504
  })(_ref => {
28421
28505
  var _theme$listBox$backgr, _theme$listBox;
28422
28506
  let {
28423
28507
  theme,
28424
- containerPadding
28508
+ containerPadding,
28509
+ hasIcon
28425
28510
  } = _ref;
28426
28511
  return {
28427
28512
  backgroundColor: (_theme$listBox$backgr = (_theme$listBox = theme.listBox) === null || _theme$listBox === void 0 ? void 0 : _theme$listBox.backgroundColor) !== null && _theme$listBox$backgr !== void 0 ? _theme$listBox$backgr : theme.palette.background.default,
28428
28513
  ["& .".concat(classes$4.listBoxHeader)]: {
28429
28514
  alignSelf: 'center',
28430
28515
  display: 'flex',
28431
- width: "calc(100% - ".concat(BUTTON_ICON_WIDTH, "px)")
28516
+ width: "calc(100% - ".concat(hasIcon ? BUTTON_ICON_WIDTH : 0, "px)")
28432
28517
  },
28433
28518
  ["& .".concat(classes$4.screenReaderOnly)]: {
28434
28519
  position: 'absolute',
@@ -28439,7 +28524,7 @@
28439
28524
  ["& .".concat(classes$4.listboxWrapper)]: {
28440
28525
  padding: containerPadding
28441
28526
  },
28442
- '&:focus': {
28527
+ '&:focus:not(:hover)': {
28443
28528
  boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
28444
28529
  },
28445
28530
  '&:focus-visible': {
@@ -28481,7 +28566,8 @@
28481
28566
  postProcessPages = undefined,
28482
28567
  calculatePagesHeight,
28483
28568
  showGray = true,
28484
- scrollState = undefined
28569
+ scrollState = undefined,
28570
+ renderedCallback
28485
28571
  } = options;
28486
28572
  let {
28487
28573
  toolbar = true
@@ -28558,9 +28644,6 @@
28558
28644
  reactExports.useEffect(() => {
28559
28645
  const show = () => {
28560
28646
  setShowToolbar(true);
28561
- if (search === 'toggle' && toolbar === false) {
28562
- setShowSearch(true);
28563
- }
28564
28647
  };
28565
28648
  const hide = () => {
28566
28649
  setShowToolbar(false);
@@ -28621,6 +28704,14 @@
28621
28704
  const newValue = !showSearch;
28622
28705
  setShowSearch(newValue);
28623
28706
  };
28707
+ const onCtrlF = () => {
28708
+ if (search === 'toggle') {
28709
+ onShowSearch();
28710
+ } else {
28711
+ const input = searchContainer.current.querySelector('input');
28712
+ input === null || input === void 0 ? void 0 : input.focus();
28713
+ }
28714
+ };
28624
28715
  const getActionToolbarProps = isPopover => getListboxActionProps({
28625
28716
  isPopover,
28626
28717
  showToolbar,
@@ -28660,7 +28751,8 @@
28660
28751
  onKeyDown: handleKeyDown,
28661
28752
  onMouseEnter: handleOnMouseEnter,
28662
28753
  onMouseLeave: handleOnMouseLeave,
28663
- ref: containerRef
28754
+ ref: containerRef,
28755
+ hasIcon: showIcons
28664
28756
  }, toolbar && /*#__PURE__*/React.createElement(Grid$1, {
28665
28757
  item: true,
28666
28758
  container: true,
@@ -28763,10 +28855,10 @@
28763
28855
  visible: searchVisible,
28764
28856
  search: search,
28765
28857
  autoFocus: shouldAutoFocus,
28766
- searchContainerRef: searchContainerRef,
28767
28858
  wildCardSearch: wildCardSearch,
28768
28859
  searchEnabled: searchEnabled,
28769
- direction: direction
28860
+ direction: direction,
28861
+ hide: showSearchIcon && onShowSearch
28770
28862
  })), /*#__PURE__*/React.createElement(Grid$1, {
28771
28863
  item: true,
28772
28864
  xs: true,
@@ -28810,7 +28902,9 @@
28810
28902
  currentScrollIndex: {
28811
28903
  state: currentScrollIndex,
28812
28904
  set: setCurrentScrollIndex
28813
- }
28905
+ },
28906
+ renderedCallback: renderedCallback,
28907
+ onCtrlF: onCtrlF
28814
28908
  });
28815
28909
  })))));
28816
28910
  }
@@ -29090,7 +29184,8 @@
29090
29184
  qId,
29091
29185
  stateName,
29092
29186
  element,
29093
- options
29187
+ options,
29188
+ renderedCallback
29094
29189
  } = _ref;
29095
29190
  const {
29096
29191
  isExistingObject,
@@ -29121,7 +29216,8 @@
29121
29216
  const opts = reactExports.useMemo(() => _objectSpread2(_objectSpread2({}, options), {}, {
29122
29217
  selections,
29123
29218
  model,
29124
- app
29219
+ app,
29220
+ renderedCallback
29125
29221
  }), [options, selections, model, app]);
29126
29222
  if (!selections || !model) {
29127
29223
  return null;
@@ -29137,7 +29233,8 @@
29137
29233
  fieldIdentifier,
29138
29234
  qId,
29139
29235
  stateName = '$',
29140
- options = {}
29236
+ options = {},
29237
+ renderedCallback
29141
29238
  } = _ref2;
29142
29239
  return ReactDOM.createPortal( /*#__PURE__*/React.createElement(ListBoxWrapper, {
29143
29240
  app: app,
@@ -29145,7 +29242,8 @@
29145
29242
  fieldIdentifier: fieldIdentifier,
29146
29243
  qId: qId,
29147
29244
  stateName: stateName,
29148
- options: options
29245
+ options: options,
29246
+ renderedCallback: renderedCallback
29149
29247
  }), element, uid());
29150
29248
  }
29151
29249
 
@@ -36670,13 +36768,14 @@
36670
36768
  * @param {boolean=} [options.dense=false] Reduces padding and text size (not applicable for existing objects)
36671
36769
  * @param {string=} [options.stateName="$"] Sets the state to make selections in (not applicable for existing objects)
36672
36770
  * @param {object=} [options.properties={}] Properties object to extend default properties with
36771
+ * @returns {Promise<void>} A promise that resolves when the data is fetched.
36673
36772
  *
36674
36773
  * @since 1.1.0
36675
36774
  * @instance
36676
36775
  * @example
36677
36776
  * fieldInstance.mount(element);
36678
36777
  */
36679
- mount(element) {
36778
+ async mount(element) {
36680
36779
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
36681
36780
  if (!element) {
36682
36781
  throw new Error("Element for ".concat(fieldName || qId, " not provided"));
@@ -36686,18 +36785,21 @@
36686
36785
  }
36687
36786
  const onSelectionActivated = () => fieldSels.emit('selectionActivated');
36688
36787
  const onSelectionDeactivated = () => fieldSels.emit('selectionDeactivated');
36689
- this._instance = ListBoxPortal({
36690
- element,
36691
- app,
36692
- fieldIdentifier,
36693
- qId,
36694
- options: getOptions$1(_objectSpread2({
36695
- onSelectionActivated,
36696
- onSelectionDeactivated
36697
- }, options)),
36698
- stateName: options.stateName || '$'
36788
+ return new Promise(resolve => {
36789
+ this._instance = ListBoxPortal({
36790
+ element,
36791
+ app,
36792
+ fieldIdentifier,
36793
+ qId,
36794
+ options: getOptions$1(_objectSpread2({
36795
+ onSelectionActivated,
36796
+ onSelectionDeactivated
36797
+ }, options)),
36798
+ stateName: options.stateName || '$',
36799
+ renderedCallback: resolve
36800
+ });
36801
+ root.add(this._instance);
36699
36802
  });
36700
- root.add(this._instance);
36701
36803
  },
36702
36804
  /**
36703
36805
  * Unmounts the field listbox from the DOM.