@nebula.js/stardust 4.0.0-alpha.0 → 4.0.0-alpha.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.0.0-alpha.0
2
+ * @nebula.js/stardust v4.0.0-alpha.1
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -15112,7 +15112,7 @@
15112
15112
  disabled: 'rgba(0, 0, 0, 0.3)'
15113
15113
  },
15114
15114
  action: {
15115
- active: colors.grey25,
15115
+ active: '#545454',
15116
15116
  // color for actionable things like icon buttons
15117
15117
  hover: 'rgba(0, 0, 0, 0.03)',
15118
15118
  // color for hoverable things like list items
@@ -15252,10 +15252,21 @@
15252
15252
  padding: 7,
15253
15253
  borderRadius: 2,
15254
15254
  border: '1px solid transparent',
15255
- // should ideally use $focusVisible, but that messes up focus in all other places where Iconbutton is used (Checkbox, Switch etc)
15256
- '&:focus': {
15255
+ '&:hover': {
15256
+ backgroundColor: theme.palette.btn.hover
15257
+ },
15258
+ '&:focus-visible': {
15257
15259
  borderColor: theme.palette.custom.focusBorder,
15258
15260
  boxShadow: "0 0 0 2px ".concat(theme.palette.custom.focusOutline)
15261
+ },
15262
+ '&:active': {
15263
+ borderColor: 'transparent',
15264
+ boxShadow: 'none',
15265
+ backgroundColor: theme.palette.btn.active
15266
+ },
15267
+ '&:not(:active):not(:focus-visible)': {
15268
+ borderColor: 'transparent',
15269
+ boxShadow: 'none'
15259
15270
  }
15260
15271
  }
15261
15272
  },
@@ -15343,7 +15354,7 @@
15343
15354
  return cache[key];
15344
15355
  }
15345
15356
 
15346
- const NEBULA_VERSION_HASH = "b1a6" ;
15357
+ const NEBULA_VERSION_HASH = "f871" ;
15347
15358
  ClassNameGenerator$1.configure(componentName => {
15348
15359
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
15349
15360
  });
@@ -15551,7 +15562,7 @@
15551
15562
  const appRef = React.createRef();
15552
15563
  const element = document.createElement('div');
15553
15564
  element.style.display = 'none';
15554
- element.setAttribute('data-nebulajs-version', "4.0.0-alpha.0" );
15565
+ element.setAttribute('data-nebulajs-version', "4.0.0-alpha.1" );
15555
15566
  element.setAttribute('data-app-id', app.id);
15556
15567
  document.body.appendChild(element);
15557
15568
  const root = client.createRoot(element);
@@ -21698,7 +21709,7 @@
21698
21709
  doSelect();
21699
21710
  }, []);
21700
21711
  const onMouseDown = reactExports.useCallback(event => {
21701
- if (selectionState.selectDisabled()) {
21712
+ if (event.button !== 0 || selectionState.selectDisabled()) {
21702
21713
  return;
21703
21714
  }
21704
21715
  const elemNumber = +event.currentTarget.getAttribute('data-n');
@@ -21719,7 +21730,7 @@
21719
21730
  handleSingleSelectKey(event, event.currentTarget);
21720
21731
  }, []);
21721
21732
  const onMouseUp = reactExports.useCallback(event => {
21722
- if (!currentSelect.current.active) {
21733
+ if (event.button !== 0 || !currentSelect.current.active) {
21723
21734
  return;
21724
21735
  }
21725
21736
  currentSelect.current.active = false;
@@ -21729,9 +21740,9 @@
21729
21740
  }
21730
21741
  doSelect();
21731
21742
  }, []);
21732
- const onMouseUpDoc = reactExports.useCallback(() => {
21743
+ const onMouseUpDoc = reactExports.useCallback(event => {
21733
21744
  // Ensure we end interactions when mouseup happens outside the Listbox.
21734
- if (!currentSelect.current.active) {
21745
+ if (event.button !== 0 || !currentSelect.current.active) {
21735
21746
  return;
21736
21747
  }
21737
21748
  currentSelect.current.active = false;
@@ -21758,17 +21769,19 @@
21758
21769
  };
21759
21770
  }, [onMouseUpDoc]);
21760
21771
  reactExports.useEffect(() => {
21761
- const onDeactivated = () => {
21772
+ const clearItemStates = () => {
21762
21773
  selectionState.clearItemStates(false);
21763
21774
  };
21764
21775
  const onCleared = () => {
21765
21776
  selectionState.clearItemStates(true);
21766
21777
  selectionState.triggerStateChanged();
21767
21778
  };
21768
- selections.on('deactivated', onDeactivated);
21779
+ selections.on('clearItemStates', clearItemStates);
21780
+ selections.on('deactivated', clearItemStates);
21769
21781
  selections.on('cleared', onCleared);
21770
21782
  return () => {
21771
- selections.removeListener('activated', onDeactivated);
21783
+ selections.removeListener('clearItemStates', clearItemStates);
21784
+ selections.removeListener('deactivated', clearItemStates);
21772
21785
  selections.removeListener('cleared', onCleared);
21773
21786
  };
21774
21787
  }, [selections]);
@@ -22189,8 +22202,10 @@
22189
22202
  return '';
22190
22203
  };
22191
22204
 
22192
- const ICON_PADDING = 7;
22193
22205
  const CELL_PADDING_LEFT = 9;
22206
+ const ICON_WIDTH = 12;
22207
+ const ICON_PADDING = 7;
22208
+ const BUTTON_ICON_WIDTH = ICON_WIDTH + (ICON_PADDING + 1) * 2; // 1 is border width
22194
22209
 
22195
22210
  const getSelectedStyle = _ref => {
22196
22211
  let {
@@ -22317,7 +22332,7 @@
22317
22332
  theme
22318
22333
  })), {}, {
22319
22334
  background: theme.palette.selected.excluded,
22320
- color: theme.palette.selected.mainContrastText,
22335
+ color: theme.palette.selected.excludedContrastText,
22321
22336
  border: isGridMode ? 'none' : undefined
22322
22337
  }),
22323
22338
  ["& .".concat(rowColClasses.A)]: {
@@ -22936,7 +22951,7 @@
22936
22951
  pages,
22937
22952
  cellIndex
22938
22953
  }), [pages, cellIndex]);
22939
- const isSelected = (cell === null || cell === void 0 ? void 0 : cell.qState) === 'S' || (cell === null || cell === void 0 ? void 0 : cell.qState) === 'XS' || (cell === null || cell === void 0 ? void 0 : cell.qState) === 'L';
22954
+ const isSelected = (cell === null || cell === void 0 ? void 0 : cell.qState) === 'S' || (cell === null || cell === void 0 ? void 0 : cell.qState) === 'XS' || (cell === null || cell === void 0 ? void 0 : cell.qState) === 'L' || (cell === null || cell === void 0 ? void 0 : cell.qState) === 'XL';
22940
22955
  const classArr = reactExports.useMemo(() => getValueStateClasses({
22941
22956
  column,
22942
22957
  histogram,
@@ -22945,10 +22960,6 @@
22945
22960
  showGray
22946
22961
  }), [cell === null || cell === void 0 ? void 0 : cell.qState, histogram, dense, checkboxes]);
22947
22962
  const preventContextMenu = reactExports.useCallback(event => {
22948
- if (checkboxes) {
22949
- // Event will not propagate in the checkbox/radiobutton case
22950
- onClick(event);
22951
- }
22952
22963
  event.preventDefault();
22953
22964
  }, [checkboxes]);
22954
22965
  if (!cell) {
@@ -25718,6 +25729,7 @@
25718
25729
  style: style,
25719
25730
  className: ActionElement.className,
25720
25731
  size: "large",
25732
+ disableRipple: true,
25721
25733
  "aria-expanded": ariaExpanded,
25722
25734
  "aria-controls": "moreMenuList"
25723
25735
  }, hasSvgIconShape && SvgIcon(item.getSvgIconShape()), addAnchor && /*#__PURE__*/React.createElement("div", {
@@ -26125,7 +26137,7 @@
26125
26137
  className: ActionToolbarElement.className,
26126
26138
  style: {
26127
26139
  pointerEvents: 'auto',
26128
- padding: theme.spacing(1, 1)
26140
+ padding: theme.spacing(0.8)
26129
26141
  }
26130
26142
  }
26131
26143
  }, Actions) : show && Actions;
@@ -28136,9 +28148,58 @@
28136
28148
  };
28137
28149
  };
28138
28150
 
28151
+ function showToolbarDetached(_ref) {
28152
+ var _containerRef$current, _containerRef$current2, _titleRef$current$cli, _titleRef$current, _titleRef$current2, _titleRef$current3;
28153
+ let {
28154
+ containerRef,
28155
+ titleRef,
28156
+ iconsWidth
28157
+ } = _ref;
28158
+ const containerWidth = (_containerRef$current = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.clientWidth) !== null && _containerRef$current !== void 0 ? _containerRef$current : 0;
28159
+ const padding = 16;
28160
+ const contentWidth = ((_titleRef$current$cli = titleRef === null || titleRef === void 0 ? void 0 : (_titleRef$current = titleRef.current) === null || _titleRef$current === void 0 ? void 0 : _titleRef$current.clientWidth) !== null && _titleRef$current$cli !== void 0 ? _titleRef$current$cli : 0) + iconsWidth + padding;
28161
+ const actionToolbarWidth = 128;
28162
+ const notSufficientSpace = containerWidth < contentWidth + actionToolbarWidth;
28163
+ const isTruncated = (titleRef === null || titleRef === void 0 ? void 0 : (_titleRef$current2 = titleRef.current) === null || _titleRef$current2 === void 0 ? void 0 : _titleRef$current2.scrollWidth) > (titleRef === null || titleRef === void 0 ? void 0 : (_titleRef$current3 = titleRef.current) === null || _titleRef$current3 === void 0 ? void 0 : _titleRef$current3.offsetWidth);
28164
+ return !!(notSufficientSpace | isTruncated);
28165
+ }
28166
+
28167
+ function getListboxActionProps(_ref) {
28168
+ let {
28169
+ isPopover,
28170
+ showToolbar,
28171
+ containerRef,
28172
+ isLocked,
28173
+ listboxSelectionToolbarItems,
28174
+ selections
28175
+ } = _ref;
28176
+ return {
28177
+ show: showToolbar && !isPopover,
28178
+ popover: {
28179
+ show: showToolbar && isPopover,
28180
+ anchorEl: containerRef.current
28181
+ },
28182
+ more: {
28183
+ enabled: !isLocked,
28184
+ actions: listboxSelectionToolbarItems,
28185
+ popoverProps: {
28186
+ elevation: 0
28187
+ },
28188
+ popoverPaperStyle: {
28189
+ boxShadow: '0 12px 8px -8px rgba(0, 0, 0, 0.2)',
28190
+ minWidth: '250px'
28191
+ }
28192
+ },
28193
+ selections: {
28194
+ show: showToolbar,
28195
+ api: selections,
28196
+ onConfirm: () => {},
28197
+ onCancel: () => {}
28198
+ }
28199
+ };
28200
+ }
28201
+
28139
28202
  const PREFIX$4 = 'ListBoxInline';
28140
- const searchIconWidth = 28;
28141
- const drillDownIconWidth = 24;
28142
28203
  const classes$4 = {
28143
28204
  listBoxHeader: "".concat(PREFIX$4, "-listBoxHeader"),
28144
28205
  screenReaderOnly: "".concat(PREFIX$4, "-screenReaderOnly"),
@@ -28157,7 +28218,7 @@
28157
28218
  ["& .".concat(classes$4.listBoxHeader)]: {
28158
28219
  alignSelf: 'center',
28159
28220
  display: 'inline-flex',
28160
- width: "calc(100% - ".concat(searchIconWidth, "px)")
28221
+ width: "calc(100% - ".concat(BUTTON_ICON_WIDTH, "px)")
28161
28222
  },
28162
28223
  ["& .".concat(classes$4.screenReaderOnly)]: {
28163
28224
  position: 'absolute',
@@ -28231,7 +28292,6 @@
28231
28292
  constraints
28232
28293
  } = reactExports.useContext(InstanceContext);
28233
28294
  theme.listBox = addListboxTheme(themeApi);
28234
- const moreAlignTo = reactExports.useRef();
28235
28295
  const containerRef = reactExports.useRef();
28236
28296
  const [searchContainer, searchContainerRef] = useRefWithCallback();
28237
28297
  const [showToolbar, setShowToolbar] = reactExports.useState(false);
@@ -28249,6 +28309,7 @@
28249
28309
  stop: 0
28250
28310
  });
28251
28311
  const [appSelections] = useAppSelections(app);
28312
+ const titleRef = reactExports.useRef(null);
28252
28313
  const [selectionState$1] = reactExports.useState(() => selectionState());
28253
28314
  const {
28254
28315
  handleKeyDown,
@@ -28275,6 +28336,7 @@
28275
28336
  if ((layout === null || layout === void 0 ? void 0 : layout.toolbar) !== undefined) {
28276
28337
  toolbar = layout.toolbar;
28277
28338
  }
28339
+ const toolbarDetachedOnly = toolbar && (layout === null || layout === void 0 ? void 0 : layout.title) === '';
28278
28340
  toolbar = toolbar && (layout === null || layout === void 0 ? void 0 : layout.title) !== '';
28279
28341
  reactExports.useEffect(() => {
28280
28342
  const show = () => {
@@ -28291,15 +28353,15 @@
28291
28353
  };
28292
28354
  if (selections) {
28293
28355
  if (!selections.isModal()) {
28294
- selections.on('deactivated', hide);
28295
28356
  selections.on('activated', show);
28357
+ selections.on('deactivated', hide);
28296
28358
  }
28297
28359
  setShowToolbar(selections.isActive());
28298
28360
  }
28299
28361
  return () => {
28300
28362
  if (selections && selections.removeListener) {
28301
- selections.removeListener('deactivated', show);
28302
- selections.removeListener('activated', hide);
28363
+ selections.removeListener('activated', show);
28364
+ selections.removeListener('deactivated', hide);
28303
28365
  }
28304
28366
  };
28305
28367
  }, [selections, toolbar]);
@@ -28318,12 +28380,12 @@
28318
28380
  }
28319
28381
  const isLocked = layout.qListObject.qDimensionInfo.qLocked === true;
28320
28382
  const isDrillDown = layout.qListObject.qDimensionInfo.qGrouping === 'H';
28321
- const listboxSelectionToolbarItems = toolbar ? createListboxSelectionToolbar({
28383
+ const listboxSelectionToolbarItems = createListboxSelectionToolbar({
28322
28384
  layout,
28323
28385
  model,
28324
28386
  translator,
28325
28387
  selectionState: selectionState$1
28326
- }) : [];
28388
+ });
28327
28389
  const showSearchToggle = search === 'toggle' && showSearch;
28328
28390
  const searchVisible = (search === true || showSearchToggle) && !selectDisabled();
28329
28391
  const {
@@ -28342,13 +28404,20 @@
28342
28404
  const newValue = !showSearch;
28343
28405
  setShowSearch(newValue);
28344
28406
  };
28407
+ const getActionToolbarProps = isPopover => getListboxActionProps({
28408
+ isPopover,
28409
+ showToolbar,
28410
+ containerRef,
28411
+ isLocked,
28412
+ listboxSelectionToolbarItems,
28413
+ selections
28414
+ });
28345
28415
  const shouldAutoFocus = searchVisible && search === 'toggle';
28346
28416
  const showSearchIcon = searchEnabled !== false && search === 'toggle' && !(constraints !== null && constraints !== void 0 && constraints.active);
28347
28417
  const showSearchOrLockIcon = isLocked || showSearchIcon;
28348
28418
  const showIcons = showSearchOrLockIcon || isDrillDown;
28349
- const iconsWidth = (showSearchOrLockIcon ? searchIconWidth : 0) + (isDrillDown ? drillDownIconWidth : 0);
28350
- const drillDownPaddingLeft = showSearchOrLockIcon ? 0 : ICON_PADDING;
28351
- const headerPaddingLeft = CELL_PADDING_LEFT - (showIcons ? ICON_PADDING : 0);
28419
+ const iconsWidth = (showSearchOrLockIcon ? BUTTON_ICON_WIDTH : 0) + (isDrillDown ? ICON_WIDTH + ICON_PADDING : 0); // Drill-down icon needs padding right so there is space between the icon and the title
28420
+ const headerPaddingLeft = CELL_PADDING_LEFT - (showSearchOrLockIcon ? ICON_PADDING : 0);
28352
28421
 
28353
28422
  // Add a container padding for grid mode to harmonize with the grid item margins (should sum to 8px).
28354
28423
  const isGridMode = (layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.dataLayout) === 'grid';
@@ -28356,7 +28425,7 @@
28356
28425
  if (isGridMode) {
28357
28426
  containerPadding = layoutOptions.layoutOrder === 'row' ? '2px 4px' : '2px 6px 2px 4px';
28358
28427
  }
28359
- return /*#__PURE__*/React.createElement(StyledGrid$3, {
28428
+ return /*#__PURE__*/React.createElement(React.Fragment, null, toolbarDetachedOnly && /*#__PURE__*/React.createElement(ActionsToolbar, getActionToolbarProps(true)), /*#__PURE__*/React.createElement(StyledGrid$3, {
28360
28429
  className: "listbox-container",
28361
28430
  container: true,
28362
28431
  tabIndex: keyboard.enabled && !keyboard.active ? 0 : -1,
@@ -28399,6 +28468,7 @@
28399
28468
  size: "large"
28400
28469
  }, /*#__PURE__*/React.createElement(Lock, {
28401
28470
  title: translator.get('Listbox.Unlock'),
28471
+ disableRipple: true,
28402
28472
  style: {
28403
28473
  fontSize: '12px'
28404
28474
  }
@@ -28407,54 +28477,37 @@
28407
28477
  tabIndex: -1,
28408
28478
  title: translator.get('Listbox.Search'),
28409
28479
  size: "large",
28480
+ disableRipple: true,
28410
28481
  "data-testid": "search-toggle-btn"
28411
28482
  }, /*#__PURE__*/React.createElement(SearchIcon, {
28412
28483
  style: {
28413
28484
  fontSize: '12px'
28414
28485
  }
28415
- })), isDrillDown && /*#__PURE__*/React.createElement(IconButton$1, {
28486
+ })), isDrillDown && /*#__PURE__*/React.createElement(DrillDownIcon, {
28416
28487
  tabIndex: -1,
28417
28488
  title: translator.get('Listbox.DrillDown'),
28418
28489
  size: "large",
28419
- sx: {
28420
- paddingLeft: "".concat(drillDownPaddingLeft, "px")
28421
- }
28422
- }, /*#__PURE__*/React.createElement(DrillDownIcon, {
28423
28490
  style: {
28424
28491
  fontSize: '12px'
28425
28492
  }
28426
- }))), /*#__PURE__*/React.createElement(Grid$1, {
28493
+ })), /*#__PURE__*/React.createElement(Grid$1, {
28427
28494
  item: true,
28428
28495
  className: classes$4.listBoxHeader
28429
28496
  }, /*#__PURE__*/React.createElement(Title, {
28430
28497
  variant: "h6",
28431
28498
  noWrap: true,
28499
+ ref: titleRef,
28432
28500
  title: layout.title
28433
28501
  }, layout.title))), /*#__PURE__*/React.createElement(Grid$1, {
28434
28502
  item: true,
28435
28503
  xs: true
28436
28504
  }), /*#__PURE__*/React.createElement(Grid$1, {
28437
28505
  item: true
28438
- }, /*#__PURE__*/React.createElement(ActionsToolbar, {
28439
- more: {
28440
- enabled: !isLocked,
28441
- actions: listboxSelectionToolbarItems,
28442
- alignTo: moreAlignTo,
28443
- popoverProps: {
28444
- elevation: 0
28445
- },
28446
- popoverPaperStyle: {
28447
- boxShadow: '0 12px 8px -8px rgba(0, 0, 0, 0.2)',
28448
- minWidth: '250px'
28449
- }
28450
- },
28451
- selections: {
28452
- show: showToolbar,
28453
- api: selections,
28454
- onConfirm: () => {},
28455
- onCancel: () => {}
28456
- }
28457
- }))), /*#__PURE__*/React.createElement(Grid$1, {
28506
+ }, /*#__PURE__*/React.createElement(ActionsToolbar, getActionToolbarProps(showToolbarDetached({
28507
+ containerRef,
28508
+ titleRef,
28509
+ iconsWidth
28510
+ }))))), /*#__PURE__*/React.createElement(Grid$1, {
28458
28511
  item: true,
28459
28512
  container: true,
28460
28513
  direction: "column",
@@ -28464,9 +28517,7 @@
28464
28517
  },
28465
28518
  role: "region",
28466
28519
  "aria-label": translator.get('Listbox.ResultFilterLabel')
28467
- }, /*#__PURE__*/React.createElement("div", {
28468
- ref: moreAlignTo
28469
- }), /*#__PURE__*/React.createElement(Grid$1, {
28520
+ }, /*#__PURE__*/React.createElement(Grid$1, {
28470
28521
  item: true,
28471
28522
  ref: searchContainerRef
28472
28523
  }, /*#__PURE__*/React.createElement("div", {
@@ -28527,7 +28578,7 @@
28527
28578
  set: setCurrentScrollIndex
28528
28579
  }
28529
28580
  });
28530
- }))));
28581
+ })))));
28531
28582
  }
28532
28583
  const ListBoxInlineMemoed = React.memo(ListBoxInline);
28533
28584
  function IsolateUseLayoutWrapper(_ref5) {
@@ -28821,7 +28872,7 @@
28821
28872
  options
28822
28873
  });
28823
28874
  const elementRef = reactExports.useRef(element);
28824
- const selections = hasExternalSelectionsApi ? options.selectionsApi : useObjectSelections(app, model, [elementRef, '.njs-action-toolbar-more'], options)[0];
28875
+ const selections = hasExternalSelectionsApi ? options.selectionsApi : useObjectSelections(app, model, [elementRef, '.njs-action-toolbar-more', '.njs-action-toolbar-popover'], options)[0];
28825
28876
  const opts = reactExports.useMemo(() => _objectSpread2(_objectSpread2({}, options), {}, {
28826
28877
  selections,
28827
28878
  model,