@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/esm/dev.js CHANGED
@@ -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
  */
@@ -5670,7 +5670,7 @@ function StyledEngineProvider(props) {
5670
5670
  }
5671
5671
 
5672
5672
  /**
5673
- * @mui/styled-engine v5.14.16
5673
+ * @mui/styled-engine v5.14.17
5674
5674
  *
5675
5675
  * @license MIT
5676
5676
  * This source code is licensed under the MIT license found in the
@@ -8551,7 +8551,7 @@ function create$3(definition) {
8551
8551
  return cache[key];
8552
8552
  }
8553
8553
 
8554
- const NEBULA_VERSION_HASH = "ca95" ;
8554
+ const NEBULA_VERSION_HASH = "d794" ;
8555
8555
  ClassNameGenerator$1.configure(componentName => {
8556
8556
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
8557
8557
  });
@@ -8812,7 +8812,7 @@ function boot(_ref2) {
8812
8812
  const appRef = React__default.createRef();
8813
8813
  const element = document.createElement('div');
8814
8814
  element.style.display = 'none';
8815
- element.setAttribute('data-nebulajs-version', "4.6.2" );
8815
+ element.setAttribute('data-nebulajs-version', "4.7.0" );
8816
8816
  element.setAttribute('data-app-id', app.id);
8817
8817
  document.body.appendChild(element);
8818
8818
  if (context) {
@@ -10315,7 +10315,6 @@ const StyledCheckbox = styled$1(Checkbox, {
10315
10315
  shouldForwardProp: p => p !== 'styles'
10316
10316
  })(_ref => {
10317
10317
  let {
10318
- theme,
10319
10318
  styles
10320
10319
  } = _ref;
10321
10320
  return {
@@ -10346,13 +10345,13 @@ const StyledCheckbox = styled$1(Checkbox, {
10346
10345
  borderRadius: borderRadius - 1,
10347
10346
  width: 12,
10348
10347
  height: 12,
10349
- backgroundColor: theme.palette.selected.excluded
10348
+ backgroundColor: styles.selections.excluded
10350
10349
  },
10351
10350
  ["& .".concat(classes$b.cbIconAlternative)]: {
10352
10351
  borderRadius: borderRadius - 1,
10353
10352
  width: 12,
10354
10353
  height: 12,
10355
- backgroundColor: theme.palette.selected.alternative
10354
+ backgroundColor: styles.selections.alternative
10356
10355
  },
10357
10356
  ["&.".concat(classes$b.checkbox)]: {
10358
10357
  margin: 0,
@@ -14911,7 +14910,7 @@ const StyledInputAdornment = styled$1(InputAdornment, {
14911
14910
  styles
14912
14911
  } = _ref;
14913
14912
  return {
14914
- color: styles.content.color
14913
+ color: styles.search.color
14915
14914
  };
14916
14915
  });
14917
14916
  const StyledOutlinedInput = styled$1(OutlinedInput, {
@@ -14921,8 +14920,10 @@ const StyledOutlinedInput = styled$1(OutlinedInput, {
14921
14920
  styles
14922
14921
  } = _ref2;
14923
14922
  return {
14924
- color: styles.content.color,
14925
- display: 'flex'
14923
+ display: 'flex',
14924
+ '& .MuiInputBase-root': {
14925
+ color: styles.search.color
14926
+ }
14926
14927
  };
14927
14928
  });
14928
14929
  function ListBoxSearch(_ref3) {
@@ -17165,11 +17166,17 @@ function getOverridesAsObject() {
17165
17166
  });
17166
17167
  return overrides;
17167
17168
  }
17168
- function getSelectionColors(theme, getListboxStyle, overrides) {
17169
+ function getSelectionColors(_ref) {
17169
17170
  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;
17171
+ let {
17172
+ theme,
17173
+ getListboxStyle,
17174
+ overrides,
17175
+ checkboxes
17176
+ } = _ref;
17170
17177
  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;
17171
17178
  const desiredTextColor = componentContentTextColor || getListboxStyle('content', 'color') || ((_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.text.primary);
17172
- 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;
17179
+ 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);
17173
17180
 
17174
17181
  // Background colors
17175
17182
  const selectionColors = ((_overrides$selections = overrides.selections) === null || _overrides$selections === void 0 ? void 0 : _overrides$selections.colors) || {};
@@ -17206,17 +17213,22 @@ function getSelectionColors(theme, getListboxStyle, overrides) {
17206
17213
  possibleContrast
17207
17214
  };
17208
17215
  }
17209
- function getStyles(_ref) {
17216
+ function getStyles(_ref2) {
17210
17217
  var _themeOverrides$heade, _themeOverrides$heade2, _themeOverrides$conte;
17211
17218
  let {
17212
17219
  themeApi,
17213
17220
  theme,
17214
17221
  components = [],
17215
17222
  checkboxes = false
17216
- } = _ref;
17223
+ } = _ref2;
17217
17224
  const overrides = getOverridesAsObject(components);
17218
17225
  const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
17219
- const selections = getSelectionColors(theme, getListboxStyle, overrides);
17226
+ const selections = getSelectionColors({
17227
+ theme,
17228
+ getListboxStyle,
17229
+ overrides,
17230
+ checkboxes
17231
+ });
17220
17232
  const themeOverrides = overrides.theme || {};
17221
17233
  return {
17222
17234
  backgroundColor: getListboxStyle('', 'backgroundColor') || theme.palette.background.default,
@@ -17232,6 +17244,9 @@ function getStyles(_ref) {
17232
17244
  fontSize: ((_themeOverrides$conte = themeOverrides.content) === null || _themeOverrides$conte === void 0 ? void 0 : _themeOverrides$conte.fontSize) || getListboxStyle('content', 'fontSize'),
17233
17245
  fontFamily: getListboxStyle('content', 'fontFamily')
17234
17246
  },
17247
+ search: {
17248
+ color: getListboxStyle('content', 'color')
17249
+ },
17235
17250
  selections
17236
17251
  };
17237
17252
  }
@@ -21777,6 +21792,85 @@ function Supernova(_ref) {
21777
21792
  }));
21778
21793
  }
21779
21794
 
21795
+ const MULTI_REG = /,(?![^(]*\))/;
21796
+ const SINGLE_REG = /\s(?![^(]*\))/;
21797
+ const LENGTH_REG = /^[0-9]+[a-zA-Z%]+?$/;
21798
+ const PREDEFINED_STRINGS = ['none', 'inset', 'initial', 'inherit'];
21799
+ const isLength = v => v === '0' || LENGTH_REG.test(v);
21800
+ const getColor = singleShadowString => {
21801
+ if (!singleShadowString) return undefined;
21802
+ const parts = singleShadowString.split(SINGLE_REG).filter(part => !PREDEFINED_STRINGS.includes(part.toLowerCase()));
21803
+ const last = parts.at(-1);
21804
+ const color = last && !isLength(last) && !PREDEFINED_STRINGS.includes(last.toLowerCase()) ? last : undefined;
21805
+ return color;
21806
+ };
21807
+ const getShadows = shadowString => {
21808
+ if (!shadowString) return [];
21809
+ return shadowString.split(MULTI_REG).map(s => s.trim());
21810
+ };
21811
+
21812
+ /**
21813
+ * Combine box shadow with box shadow color.
21814
+ * @param {string} boxShadow - Box shadow which may include color
21815
+ * @param {string} themeBoxShadow - Box shadow from theme which may include color
21816
+ * @param {string | undefined} boxShadowColor - Box shadow color
21817
+ * @returns {string} Returns the combined box shadow and box shadow color
21818
+ *
21819
+ * If boxShadow is a single shadow and has a color then this color will be replaced by boxShadowColor and then
21820
+ * returned as the result,otherwise boxShadowColor will be added to boxShadow and then returned as the result.
21821
+ * If boxShadow is multiple shadows or an empty string then it will be returned as the result.
21822
+ *
21823
+ * @example getFullBoxShadow('none', '', 'red') returns 'none'
21824
+ *
21825
+ * @example getFullBoxShadow('initial', '', 'red') returns 'initial'
21826
+ *
21827
+ * @example getFullBoxShadow('inherit', '', 'red') returns 'inherit'
21828
+ *
21829
+ * @example getFullBoxShadow('', '', 'red') returns ''
21830
+ *
21831
+ * @example getFullBoxShadow('1px 2px blue, 3px 6px green', '', 'red') returns '1px 2px blue, 3px 6px green'
21832
+ *
21833
+ * @example getFullBoxShadow('1px 2px blue', '', 'red') returns '1px 2px red'
21834
+ *
21835
+ * @example getFullBoxShadow('1px 2px', '', 'red') returns '1px 2px red'
21836
+ *
21837
+ * @example getFullBoxShadow('1px 2px', '2px 5px green', undefined) returns '1px 2px green'
21838
+ *
21839
+ * @example getFullBoxShadow('1px 2px', '2px 5px', undefined) returns '1px 2px'
21840
+ */
21841
+ const getFullBoxShadow = (boxShadow, themeBoxShadow, boxShadowColor) => {
21842
+ if (boxShadow && PREDEFINED_STRINGS.includes(boxShadow.toLowerCase())) return boxShadow.toLowerCase();
21843
+ const shadowArray = getShadows(boxShadow);
21844
+ if (shadowArray.length !== 1) return boxShadow;
21845
+ let shadowColor = boxShadowColor;
21846
+ if (!shadowColor) {
21847
+ const themeShadowArray = getShadows(themeBoxShadow);
21848
+ if (themeShadowArray.length !== 1) return boxShadow;
21849
+ shadowColor = getColor(themeShadowArray[0]);
21850
+ }
21851
+ if (!shadowColor) return boxShadow;
21852
+ const color = getColor(shadowArray[0]);
21853
+ if (color) return boxShadow.replace(color, shadowColor);
21854
+ return "".concat(boxShadow, " ").concat(shadowColor);
21855
+ };
21856
+
21857
+ function resolveProperty(path, attribute, theme, objectType) {
21858
+ if (theme && objectType) {
21859
+ return theme.getStyle("object.".concat(objectType), path, attribute);
21860
+ }
21861
+ if (theme) {
21862
+ return theme.getStyle('', path, attribute);
21863
+ }
21864
+ return undefined;
21865
+ }
21866
+
21867
+ function resolveColor(colorObj, path, attribute, theme, objectType) {
21868
+ if (colorObj && theme) {
21869
+ return colorObj.color !== 'none' ? theme.getColorPickerColor(colorObj, true) : undefined;
21870
+ }
21871
+ return resolveProperty(path, attribute, theme, objectType);
21872
+ }
21873
+
21780
21874
  const imageSizingToCssProperty = {
21781
21875
  originalSize: 'auto auto',
21782
21876
  alwaysFit: 'contain',
@@ -21854,21 +21948,29 @@ function resolveBgImage(bgComp, app) {
21854
21948
  }
21855
21949
  return undefined;
21856
21950
  }
21857
- function resolveBgColor(bgComp, theme, objectType) {
21858
- const bgColor = bgComp === null || bgComp === void 0 ? void 0 : bgComp.bgColor;
21951
+ function resolveBgColor(comp, theme, objectType) {
21952
+ const bgColor = comp === null || comp === void 0 ? void 0 : comp.bgColor;
21859
21953
  if (bgColor && theme) {
21860
21954
  if (bgColor.useExpression) {
21861
21955
  return theme.validateColor(bgColor.colorExpression);
21862
21956
  }
21863
- return bgColor.color && bgColor.color.color !== 'none' ? theme.getColorPickerColor(bgColor.color, true) : undefined;
21864
21957
  }
21865
- if (theme && objectType) {
21866
- return theme.getStyle("object.".concat(objectType), '', 'backgroundColor');
21867
- }
21868
- if (theme) {
21869
- return theme.getStyle('', '', 'backgroundColor');
21870
- }
21871
- return undefined;
21958
+ return resolveColor(bgColor === null || bgColor === void 0 ? void 0 : bgColor.color, '', 'backgroundColor', theme, objectType);
21959
+ }
21960
+ function resolveBorder(comp, theme, objectType) {
21961
+ const borderColor = resolveColor(comp === null || comp === void 0 ? void 0 : comp.borderColor, '', 'borderColor', theme, objectType);
21962
+ const borderWidth = (comp === null || comp === void 0 ? void 0 : comp.borderWidth) || resolveProperty('', 'borderWidth', theme, objectType);
21963
+ return borderWidth && borderColor ? "".concat(borderWidth, " solid ").concat(borderColor) : undefined;
21964
+ }
21965
+ function resolveBorderRadius(comp, theme, objectType) {
21966
+ return (comp === null || comp === void 0 ? void 0 : comp.borderRadius) || resolveProperty('', 'borderRadius', theme, objectType);
21967
+ }
21968
+ function resolveBoxShadow(comp, theme, objectType) {
21969
+ var _comp$shadow, _comp$shadow2;
21970
+ const themeBoxShadow = resolveProperty('shadow', 'boxShadow', theme, objectType);
21971
+ const boxShadow = (comp === null || comp === void 0 || (_comp$shadow = comp.shadow) === null || _comp$shadow === void 0 ? void 0 : _comp$shadow.boxShadow) || themeBoxShadow;
21972
+ 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);
21973
+ return getFullBoxShadow(boxShadow, themeBoxShadow, boxShadowColor);
21872
21974
  }
21873
21975
  function unfurlFontStyle(fontStyle, target) {
21874
21976
  if (fontStyle && Array.isArray(fontStyle)) {
@@ -21889,6 +21991,34 @@ function resolveTextStyle(textComp, target, theme, objectType) {
21889
21991
  };
21890
21992
  }
21891
21993
 
21994
+ const useStyling = (layout, theme, app, themeName) => {
21995
+ const styling = useMemo$1(() => {
21996
+ if (layout && theme) {
21997
+ const generalComp = layout.components ? layout.components.find(comp => comp.key === 'general') : null;
21998
+ const titleStyles = {
21999
+ main: resolveTextStyle(generalComp, 'main', theme, layout.visualization),
22000
+ footer: resolveTextStyle(generalComp, 'footer', theme, layout.visualization),
22001
+ subTitle: resolveTextStyle(generalComp, 'subTitle', theme, layout.visualization)
22002
+ };
22003
+ const bgColor = resolveBgColor(generalComp, theme, layout.visualization);
22004
+ const bgImage = resolveBgImage(generalComp, app);
22005
+ const border = resolveBorder(generalComp, theme, layout.visualization);
22006
+ const borderRadius = resolveBorderRadius(generalComp, theme, layout.visualization);
22007
+ const boxShadow = resolveBoxShadow(generalComp, theme, layout.visualization);
22008
+ return {
22009
+ titleStyles,
22010
+ bgColor,
22011
+ bgImage,
22012
+ border,
22013
+ borderRadius,
22014
+ boxShadow
22015
+ };
22016
+ }
22017
+ return {};
22018
+ }, [layout, theme, app, themeName]);
22019
+ return styling;
22020
+ };
22021
+
21892
22022
  /**
21893
22023
  * @interface
21894
22024
  * @extends HTMLElement
@@ -22218,9 +22348,14 @@ const Cell = forwardRef((_ref6, ref) => {
22218
22348
  enter: null,
22219
22349
  leave: null
22220
22350
  });
22221
- const [bgColor, setBgColor] = useState$1(undefined);
22222
- const [bgImage, setBgImage] = useState$1(undefined); // {url: "", size: "", pos: ""}
22223
- const [titleStyles, setTitleStyles] = useState$1(undefined);
22351
+ const {
22352
+ titleStyles,
22353
+ bgColor,
22354
+ bgImage,
22355
+ border,
22356
+ borderRadius,
22357
+ boxShadow
22358
+ } = useStyling(layout, halo.public.theme, halo.app, themeName);
22224
22359
  const focusHandler = useRef({
22225
22360
  focusToolbarButton(last) {
22226
22361
  // eslint-disable-next-line react/no-this-in-sfc
@@ -22230,18 +22365,6 @@ const Cell = forwardRef((_ref6, ref) => {
22230
22365
  useEffect$1(() => {
22231
22366
  eventmixin(focusHandler.current);
22232
22367
  }, []);
22233
- useEffect$1(() => {
22234
- if (layout && halo.public.theme) {
22235
- const bgComp = layout.components ? layout.components.find(comp => comp.key === 'general') : null;
22236
- setTitleStyles({
22237
- main: resolveTextStyle(bgComp, 'main', halo.public.theme, layout.visualization),
22238
- footer: resolveTextStyle(bgComp, 'footer', halo.public.theme, layout.visualization),
22239
- subTitle: resolveTextStyle(bgComp, 'subTitle', halo.public.theme, layout.visualization)
22240
- });
22241
- setBgColor(resolveBgColor(bgComp, halo.public.theme, layout.visualization));
22242
- setBgImage(resolveBgImage(bgComp, halo.app));
22243
- }
22244
- }, [layout, halo.public.theme, halo.app, themeName]);
22245
22368
  focusHandler.current.blurCallback = resetFocus => {
22246
22369
  halo.root.toggleFocusOfCells();
22247
22370
  if (resetFocus && contentNode) {
@@ -22432,7 +22555,11 @@ const Cell = forwardRef((_ref6, ref) => {
22432
22555
  backgroundImage: bgImage && bgImage.url ? "url(".concat(bgImage.url, ")") : undefined,
22433
22556
  backgroundRepeat: 'no-repeat',
22434
22557
  backgroundSize: bgImage && bgImage.size,
22435
- backgroundPosition: bgImage && bgImage.pos
22558
+ backgroundPosition: bgImage && bgImage.pos,
22559
+ border,
22560
+ borderRadius,
22561
+ boxShadow,
22562
+ boxSizing: 'border-box'
22436
22563
  },
22437
22564
  elevation: 0,
22438
22565
  square: true,