@nebula.js/stardust 4.6.2 → 4.7.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.
package/core/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "module": "esm/index.js",
3
3
  "peerDependencies": {
4
- "@mui/material": "^5.14.16",
4
+ "@mui/material": "^5.14.17",
5
5
  "@mui/icons-material": "^5.14.16",
6
6
  "@emotion/react": "^11.11.1",
7
7
  "@emotion/styled": "^11.11.0",
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.6.2
2
+ * @nebula.js/stardust v4.7.0
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -6952,7 +6952,7 @@
6952
6952
  }
6953
6953
 
6954
6954
  /**
6955
- * @mui/styled-engine v5.14.16
6955
+ * @mui/styled-engine v5.14.17
6956
6956
  *
6957
6957
  * @license MIT
6958
6958
  * This source code is licensed under the MIT license found in the
@@ -11820,7 +11820,7 @@
11820
11820
  return cache[key];
11821
11821
  }
11822
11822
 
11823
- const NEBULA_VERSION_HASH = "ca95" ;
11823
+ const NEBULA_VERSION_HASH = "d794" ;
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.6.2" );
12084
+ element.setAttribute('data-nebulajs-version', "4.7.0" );
12085
12085
  element.setAttribute('data-app-id', app.id);
12086
12086
  document.body.appendChild(element);
12087
12087
  if (context) {
@@ -15575,7 +15575,9 @@
15575
15575
  // clicking a checkbox to check it, hitting a button to submit a form,
15576
15576
  // and hitting left arrow to move the cursor in a text input etc.
15577
15577
  // Only special HTML elements have these default behaviors.
15578
- if (event.key !== 'Escape' || !isTopModal()) {
15578
+ if (event.key !== 'Escape' || event.which === 229 ||
15579
+ // Wait until IME is settled.
15580
+ !isTopModal()) {
15579
15581
  return;
15580
15582
  }
15581
15583
  if (!disableEscapeKeyDown) {
@@ -22283,7 +22285,6 @@
22283
22285
  shouldForwardProp: p => p !== 'styles'
22284
22286
  })(_ref => {
22285
22287
  let {
22286
- theme,
22287
22288
  styles
22288
22289
  } = _ref;
22289
22290
  return {
@@ -22314,13 +22315,13 @@
22314
22315
  borderRadius: borderRadius - 1,
22315
22316
  width: 12,
22316
22317
  height: 12,
22317
- backgroundColor: theme.palette.selected.excluded
22318
+ backgroundColor: styles.selections.excluded
22318
22319
  },
22319
22320
  ["& .".concat(classes$b.cbIconAlternative)]: {
22320
22321
  borderRadius: borderRadius - 1,
22321
22322
  width: 12,
22322
22323
  height: 12,
22323
- backgroundColor: theme.palette.selected.alternative
22324
+ backgroundColor: styles.selections.alternative
22324
22325
  },
22325
22326
  ["&.".concat(classes$b.checkbox)]: {
22326
22327
  margin: 0,
@@ -26729,7 +26730,7 @@
26729
26730
  styles
26730
26731
  } = _ref;
26731
26732
  return {
26732
- color: styles.content.color
26733
+ color: styles.search.color
26733
26734
  };
26734
26735
  });
26735
26736
  const StyledOutlinedInput = styled$1(OutlinedInput$1, {
@@ -26739,8 +26740,10 @@
26739
26740
  styles
26740
26741
  } = _ref2;
26741
26742
  return {
26742
- color: styles.content.color,
26743
- display: 'flex'
26743
+ display: 'flex',
26744
+ '& .MuiInputBase-root': {
26745
+ color: styles.search.color
26746
+ }
26744
26747
  };
26745
26748
  });
26746
26749
  function ListBoxSearch(_ref3) {
@@ -28983,11 +28986,17 @@
28983
28986
  });
28984
28987
  return overrides;
28985
28988
  }
28986
- function getSelectionColors(theme, getListboxStyle, overrides) {
28989
+ function getSelectionColors(_ref) {
28987
28990
  var _overrides$theme, _theme$palette, _overrides$theme$cont, _overrides$theme2, _overrides$selections, _selectionColors$sele, _theme$palette2, _selectionColors$alte, _theme$palette3, _selectionColors$excl, _theme$palette4, _selectionColors$sele2, _theme$palette5, _selectionColors$poss, _theme$palette6, _theme$palette7, _theme$palette8, _theme$palette9, _theme$palette10, _theme$palette11;
28991
+ let {
28992
+ theme,
28993
+ getListboxStyle,
28994
+ overrides,
28995
+ checkboxes
28996
+ } = _ref;
28988
28997
  const componentContentTextColor = (_overrides$theme = overrides.theme) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.content) === null || _overrides$theme === void 0 || (_overrides$theme = _overrides$theme.fontColor) === null || _overrides$theme === void 0 ? void 0 : _overrides$theme.color;
28989
28998
  const desiredTextColor = componentContentTextColor || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
28990
- const useContrastTextColor = (_overrides$theme$cont = (_overrides$theme2 = overrides.theme) === null || _overrides$theme2 === void 0 || (_overrides$theme2 = _overrides$theme2.content) === null || _overrides$theme2 === void 0 ? void 0 : _overrides$theme2.useContrastColor) !== null && _overrides$theme$cont !== void 0 ? _overrides$theme$cont : true;
28999
+ const useContrastTextColor = !checkboxes && ((_overrides$theme$cont = (_overrides$theme2 = overrides.theme) === null || _overrides$theme2 === void 0 || (_overrides$theme2 = _overrides$theme2.content) === null || _overrides$theme2 === void 0 ? void 0 : _overrides$theme2.useContrastColor) !== null && _overrides$theme$cont !== void 0 ? _overrides$theme$cont : true);
28991
29000
 
28992
29001
  // Background colors
28993
29002
  const selectionColors = ((_overrides$selections = overrides.selections) === null || _overrides$selections === void 0 ? void 0 : _overrides$selections.colors) || {};
@@ -29024,17 +29033,22 @@
29024
29033
  possibleContrast
29025
29034
  };
29026
29035
  }
29027
- function getStyles(_ref) {
29036
+ function getStyles(_ref2) {
29028
29037
  var _themeOverrides$heade, _themeOverrides$heade2, _themeOverrides$conte;
29029
29038
  let {
29030
29039
  themeApi,
29031
29040
  theme,
29032
29041
  components = [],
29033
29042
  checkboxes = false
29034
- } = _ref;
29043
+ } = _ref2;
29035
29044
  const overrides = getOverridesAsObject(components);
29036
29045
  const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
29037
- const selections = getSelectionColors(theme, getListboxStyle, overrides);
29046
+ const selections = getSelectionColors({
29047
+ theme,
29048
+ getListboxStyle,
29049
+ overrides,
29050
+ checkboxes
29051
+ });
29038
29052
  const themeOverrides = overrides.theme || {};
29039
29053
  return {
29040
29054
  backgroundColor: getListboxStyle('', 'backgroundColor') || theme.palette.background.default,
@@ -29050,6 +29064,9 @@
29050
29064
  fontSize: ((_themeOverrides$conte = themeOverrides.content) === null || _themeOverrides$conte === void 0 ? void 0 : _themeOverrides$conte.fontSize) || getListboxStyle('content', 'fontSize'),
29051
29065
  fontFamily: getListboxStyle('content', 'fontFamily')
29052
29066
  },
29067
+ search: {
29068
+ color: getListboxStyle('content', 'color')
29069
+ },
29053
29070
  selections
29054
29071
  };
29055
29072
  }
@@ -33595,6 +33612,85 @@
33595
33612
  }));
33596
33613
  }
33597
33614
 
33615
+ const MULTI_REG = /,(?![^(]*\))/;
33616
+ const SINGLE_REG = /\s(?![^(]*\))/;
33617
+ const LENGTH_REG = /^[0-9]+[a-zA-Z%]+?$/;
33618
+ const PREDEFINED_STRINGS = ['none', 'inset', 'initial', 'inherit'];
33619
+ const isLength = v => v === '0' || LENGTH_REG.test(v);
33620
+ const getColor = singleShadowString => {
33621
+ if (!singleShadowString) return undefined;
33622
+ const parts = singleShadowString.split(SINGLE_REG).filter(part => !PREDEFINED_STRINGS.includes(part.toLowerCase()));
33623
+ const last = parts.at(-1);
33624
+ const color = last && !isLength(last) && !PREDEFINED_STRINGS.includes(last.toLowerCase()) ? last : undefined;
33625
+ return color;
33626
+ };
33627
+ const getShadows = shadowString => {
33628
+ if (!shadowString) return [];
33629
+ return shadowString.split(MULTI_REG).map(s => s.trim());
33630
+ };
33631
+
33632
+ /**
33633
+ * Combine box shadow with box shadow color.
33634
+ * @param {string} boxShadow - Box shadow which may include color
33635
+ * @param {string} themeBoxShadow - Box shadow from theme which may include color
33636
+ * @param {string | undefined} boxShadowColor - Box shadow color
33637
+ * @returns {string} Returns the combined box shadow and box shadow color
33638
+ *
33639
+ * If boxShadow is a single shadow and has a color then this color will be replaced by boxShadowColor and then
33640
+ * returned as the result,otherwise boxShadowColor will be added to boxShadow and then returned as the result.
33641
+ * If boxShadow is multiple shadows or an empty string then it will be returned as the result.
33642
+ *
33643
+ * @example getFullBoxShadow('none', '', 'red') returns 'none'
33644
+ *
33645
+ * @example getFullBoxShadow('initial', '', 'red') returns 'initial'
33646
+ *
33647
+ * @example getFullBoxShadow('inherit', '', 'red') returns 'inherit'
33648
+ *
33649
+ * @example getFullBoxShadow('', '', 'red') returns ''
33650
+ *
33651
+ * @example getFullBoxShadow('1px 2px blue, 3px 6px green', '', 'red') returns '1px 2px blue, 3px 6px green'
33652
+ *
33653
+ * @example getFullBoxShadow('1px 2px blue', '', 'red') returns '1px 2px red'
33654
+ *
33655
+ * @example getFullBoxShadow('1px 2px', '', 'red') returns '1px 2px red'
33656
+ *
33657
+ * @example getFullBoxShadow('1px 2px', '2px 5px green', undefined) returns '1px 2px green'
33658
+ *
33659
+ * @example getFullBoxShadow('1px 2px', '2px 5px', undefined) returns '1px 2px'
33660
+ */
33661
+ const getFullBoxShadow = (boxShadow, themeBoxShadow, boxShadowColor) => {
33662
+ if (boxShadow && PREDEFINED_STRINGS.includes(boxShadow.toLowerCase())) return boxShadow.toLowerCase();
33663
+ const shadowArray = getShadows(boxShadow);
33664
+ if (shadowArray.length !== 1) return boxShadow;
33665
+ let shadowColor = boxShadowColor;
33666
+ if (!shadowColor) {
33667
+ const themeShadowArray = getShadows(themeBoxShadow);
33668
+ if (themeShadowArray.length !== 1) return boxShadow;
33669
+ shadowColor = getColor(themeShadowArray[0]);
33670
+ }
33671
+ if (!shadowColor) return boxShadow;
33672
+ const color = getColor(shadowArray[0]);
33673
+ if (color) return boxShadow.replace(color, shadowColor);
33674
+ return "".concat(boxShadow, " ").concat(shadowColor);
33675
+ };
33676
+
33677
+ function resolveProperty(path, attribute, theme, objectType) {
33678
+ if (theme && objectType) {
33679
+ return theme.getStyle("object.".concat(objectType), path, attribute);
33680
+ }
33681
+ if (theme) {
33682
+ return theme.getStyle('', path, attribute);
33683
+ }
33684
+ return undefined;
33685
+ }
33686
+
33687
+ function resolveColor(colorObj, path, attribute, theme, objectType) {
33688
+ if (colorObj && theme) {
33689
+ return colorObj.color !== 'none' ? theme.getColorPickerColor(colorObj, true) : undefined;
33690
+ }
33691
+ return resolveProperty(path, attribute, theme, objectType);
33692
+ }
33693
+
33598
33694
  const imageSizingToCssProperty = {
33599
33695
  originalSize: 'auto auto',
33600
33696
  alwaysFit: 'contain',
@@ -33672,21 +33768,29 @@
33672
33768
  }
33673
33769
  return undefined;
33674
33770
  }
33675
- function resolveBgColor(bgComp, theme, objectType) {
33676
- const bgColor = bgComp === null || bgComp === void 0 ? void 0 : bgComp.bgColor;
33771
+ function resolveBgColor(comp, theme, objectType) {
33772
+ const bgColor = comp === null || comp === void 0 ? void 0 : comp.bgColor;
33677
33773
  if (bgColor && theme) {
33678
33774
  if (bgColor.useExpression) {
33679
33775
  return theme.validateColor(bgColor.colorExpression);
33680
33776
  }
33681
- return bgColor.color && bgColor.color.color !== 'none' ? theme.getColorPickerColor(bgColor.color, true) : undefined;
33682
33777
  }
33683
- if (theme && objectType) {
33684
- return theme.getStyle("object.".concat(objectType), '', 'backgroundColor');
33685
- }
33686
- if (theme) {
33687
- return theme.getStyle('', '', 'backgroundColor');
33688
- }
33689
- return undefined;
33778
+ return resolveColor(bgColor === null || bgColor === void 0 ? void 0 : bgColor.color, '', 'backgroundColor', theme, objectType);
33779
+ }
33780
+ function resolveBorder(comp, theme, objectType) {
33781
+ const borderColor = resolveColor(comp === null || comp === void 0 ? void 0 : comp.borderColor, '', 'borderColor', theme, objectType);
33782
+ const borderWidth = (comp === null || comp === void 0 ? void 0 : comp.borderWidth) || resolveProperty('', 'borderWidth', theme, objectType);
33783
+ return borderWidth && borderColor ? "".concat(borderWidth, " solid ").concat(borderColor) : undefined;
33784
+ }
33785
+ function resolveBorderRadius(comp, theme, objectType) {
33786
+ return (comp === null || comp === void 0 ? void 0 : comp.borderRadius) || resolveProperty('', 'borderRadius', theme, objectType);
33787
+ }
33788
+ function resolveBoxShadow(comp, theme, objectType) {
33789
+ var _comp$shadow, _comp$shadow2;
33790
+ const themeBoxShadow = resolveProperty('shadow', 'boxShadow', theme, objectType);
33791
+ const boxShadow = (comp === null || comp === void 0 || (_comp$shadow = comp.shadow) === null || _comp$shadow === void 0 ? void 0 : _comp$shadow.boxShadow) || themeBoxShadow;
33792
+ const boxShadowColor = resolveColor(comp === null || comp === void 0 || (_comp$shadow2 = comp.shadow) === null || _comp$shadow2 === void 0 ? void 0 : _comp$shadow2.boxShadowColor, 'shadow', 'boxShadowColor', theme, objectType);
33793
+ return getFullBoxShadow(boxShadow, themeBoxShadow, boxShadowColor);
33690
33794
  }
33691
33795
  function unfurlFontStyle(fontStyle, target) {
33692
33796
  if (fontStyle && Array.isArray(fontStyle)) {
@@ -33707,6 +33811,34 @@
33707
33811
  };
33708
33812
  }
33709
33813
 
33814
+ const useStyling = (layout, theme, app, themeName) => {
33815
+ const styling = reactExports.useMemo(() => {
33816
+ if (layout && theme) {
33817
+ const generalComp = layout.components ? layout.components.find(comp => comp.key === 'general') : null;
33818
+ const titleStyles = {
33819
+ main: resolveTextStyle(generalComp, 'main', theme, layout.visualization),
33820
+ footer: resolveTextStyle(generalComp, 'footer', theme, layout.visualization),
33821
+ subTitle: resolveTextStyle(generalComp, 'subTitle', theme, layout.visualization)
33822
+ };
33823
+ const bgColor = resolveBgColor(generalComp, theme, layout.visualization);
33824
+ const bgImage = resolveBgImage(generalComp, app);
33825
+ const border = resolveBorder(generalComp, theme, layout.visualization);
33826
+ const borderRadius = resolveBorderRadius(generalComp, theme, layout.visualization);
33827
+ const boxShadow = resolveBoxShadow(generalComp, theme, layout.visualization);
33828
+ return {
33829
+ titleStyles,
33830
+ bgColor,
33831
+ bgImage,
33832
+ border,
33833
+ borderRadius,
33834
+ boxShadow
33835
+ };
33836
+ }
33837
+ return {};
33838
+ }, [layout, theme, app, themeName]);
33839
+ return styling;
33840
+ };
33841
+
33710
33842
  /**
33711
33843
  * @interface
33712
33844
  * @extends HTMLElement
@@ -34036,9 +34168,14 @@
34036
34168
  enter: null,
34037
34169
  leave: null
34038
34170
  });
34039
- const [bgColor, setBgColor] = reactExports.useState(undefined);
34040
- const [bgImage, setBgImage] = reactExports.useState(undefined); // {url: "", size: "", pos: ""}
34041
- const [titleStyles, setTitleStyles] = reactExports.useState(undefined);
34171
+ const {
34172
+ titleStyles,
34173
+ bgColor,
34174
+ bgImage,
34175
+ border,
34176
+ borderRadius,
34177
+ boxShadow
34178
+ } = useStyling(layout, halo.public.theme, halo.app, themeName);
34042
34179
  const focusHandler = reactExports.useRef({
34043
34180
  focusToolbarButton(last) {
34044
34181
  // eslint-disable-next-line react/no-this-in-sfc
@@ -34048,18 +34185,6 @@
34048
34185
  reactExports.useEffect(() => {
34049
34186
  eventmixin(focusHandler.current);
34050
34187
  }, []);
34051
- reactExports.useEffect(() => {
34052
- if (layout && halo.public.theme) {
34053
- const bgComp = layout.components ? layout.components.find(comp => comp.key === 'general') : null;
34054
- setTitleStyles({
34055
- main: resolveTextStyle(bgComp, 'main', halo.public.theme, layout.visualization),
34056
- footer: resolveTextStyle(bgComp, 'footer', halo.public.theme, layout.visualization),
34057
- subTitle: resolveTextStyle(bgComp, 'subTitle', halo.public.theme, layout.visualization)
34058
- });
34059
- setBgColor(resolveBgColor(bgComp, halo.public.theme, layout.visualization));
34060
- setBgImage(resolveBgImage(bgComp, halo.app));
34061
- }
34062
- }, [layout, halo.public.theme, halo.app, themeName]);
34063
34188
  focusHandler.current.blurCallback = resetFocus => {
34064
34189
  halo.root.toggleFocusOfCells();
34065
34190
  if (resetFocus && contentNode) {
@@ -34250,7 +34375,11 @@
34250
34375
  backgroundImage: bgImage && bgImage.url ? "url(".concat(bgImage.url, ")") : undefined,
34251
34376
  backgroundRepeat: 'no-repeat',
34252
34377
  backgroundSize: bgImage && bgImage.size,
34253
- backgroundPosition: bgImage && bgImage.pos
34378
+ backgroundPosition: bgImage && bgImage.pos,
34379
+ border,
34380
+ borderRadius,
34381
+ boxShadow,
34382
+ boxSizing: 'border-box'
34254
34383
  },
34255
34384
  elevation: 0,
34256
34385
  square: true,