@nebula.js/stardust 4.4.0 → 4.5.0-alpha.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 v4.4.0
2
+ * @nebula.js/stardust v4.5.0-alpha.0
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -4797,16 +4797,19 @@
4797
4797
  const ClassNameGenerator = createClassNameGenerator();
4798
4798
  var ClassNameGenerator$1 = ClassNameGenerator;
4799
4799
 
4800
+ // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
4801
+ // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
4800
4802
  const globalStateClassesMapping = {
4801
4803
  active: 'active',
4802
4804
  checked: 'checked',
4803
4805
  completed: 'completed',
4804
4806
  disabled: 'disabled',
4805
- readOnly: 'readOnly',
4806
4807
  error: 'error',
4807
4808
  expanded: 'expanded',
4808
4809
  focused: 'focused',
4809
4810
  focusVisible: 'focusVisible',
4811
+ open: 'open',
4812
+ readOnly: 'readOnly',
4810
4813
  required: 'required',
4811
4814
  selected: 'selected'
4812
4815
  };
@@ -6937,13 +6940,12 @@
6937
6940
  }
6938
6941
 
6939
6942
  /**
6940
- * @mui/styled-engine v5.13.2
6943
+ * @mui/styled-engine v5.14.6
6941
6944
  *
6942
6945
  * @license MIT
6943
6946
  * This source code is licensed under the MIT license found in the
6944
6947
  * LICENSE file in the root directory of this source tree.
6945
6948
  */
6946
- /* eslint-disable no-underscore-dangle */
6947
6949
  function styled$3(tag, options) {
6948
6950
  const stylesFactory = newStyled(tag, options);
6949
6951
  return stylesFactory;
@@ -6986,7 +6988,7 @@
6986
6988
  return target;
6987
6989
  }
6988
6990
 
6989
- const _excluded$S = ["values", "unit", "step"];
6991
+ const _excluded$R = ["values", "unit", "step"];
6990
6992
  const sortBreakpointsValues = values => {
6991
6993
  const breakpointsAsArray = Object.keys(values).map(key => ({
6992
6994
  key,
@@ -7021,7 +7023,7 @@
7021
7023
  unit = 'px',
7022
7024
  step = 5
7023
7025
  } = breakpoints,
7024
- other = _objectWithoutPropertiesLoose$2(breakpoints, _excluded$S);
7026
+ other = _objectWithoutPropertiesLoose$2(breakpoints, _excluded$R);
7025
7027
  const sortedValues = sortBreakpointsValues(values);
7026
7028
  const keys = Object.keys(sortedValues);
7027
7029
  function up(key) {
@@ -8064,7 +8066,7 @@
8064
8066
  styleFunctionSx.filterProps = ['sx'];
8065
8067
  var styleFunctionSx$1 = styleFunctionSx;
8066
8068
 
8067
- const _excluded$R = ["breakpoints", "palette", "spacing", "shape"];
8069
+ const _excluded$Q = ["breakpoints", "palette", "spacing", "shape"];
8068
8070
  function createTheme$1(options = {}, ...args) {
8069
8071
  const {
8070
8072
  breakpoints: breakpointsInput = {},
@@ -8072,7 +8074,7 @@
8072
8074
  spacing: spacingInput,
8073
8075
  shape: shapeInput = {}
8074
8076
  } = options,
8075
- other = _objectWithoutPropertiesLoose$2(options, _excluded$R);
8077
+ other = _objectWithoutPropertiesLoose$2(options, _excluded$Q);
8076
8078
  const breakpoints = createBreakpoints(breakpointsInput);
8077
8079
  const spacing = createSpacing(spacingInput);
8078
8080
  let muiTheme = deepmerge({
@@ -8122,7 +8124,7 @@
8122
8124
  });
8123
8125
  }
8124
8126
 
8125
- const _excluded$Q = ["sx"];
8127
+ const _excluded$P = ["sx"];
8126
8128
  const splitProps = props => {
8127
8129
  var _props$theme$unstable, _props$theme;
8128
8130
  const result = {
@@ -8143,7 +8145,7 @@
8143
8145
  const {
8144
8146
  sx: inSx
8145
8147
  } = props,
8146
- other = _objectWithoutPropertiesLoose$2(props, _excluded$Q);
8148
+ other = _objectWithoutPropertiesLoose$2(props, _excluded$P);
8147
8149
  const {
8148
8150
  systemProps,
8149
8151
  otherProps
@@ -8169,7 +8171,7 @@
8169
8171
 
8170
8172
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
8171
8173
 
8172
- const _excluded$P = ["className", "component"];
8174
+ const _excluded$O = ["className", "component"];
8173
8175
  function createBox(options = {}) {
8174
8176
  const {
8175
8177
  themeId,
@@ -8187,7 +8189,7 @@
8187
8189
  className,
8188
8190
  component = 'div'
8189
8191
  } = _extendSxProp,
8190
- other = _objectWithoutPropertiesLoose$2(_extendSxProp, _excluded$P);
8192
+ other = _objectWithoutPropertiesLoose$2(_extendSxProp, _excluded$O);
8191
8193
  return /*#__PURE__*/jsxRuntimeExports.jsx(BoxRoot, _extends$3({
8192
8194
  as: component,
8193
8195
  ref: ref,
@@ -8198,7 +8200,7 @@
8198
8200
  return Box;
8199
8201
  }
8200
8202
 
8201
- const _excluded$O = ["variant"];
8203
+ const _excluded$N = ["variant"];
8202
8204
  function isEmpty$3(string) {
8203
8205
  return string.length === 0;
8204
8206
  }
@@ -8212,7 +8214,7 @@
8212
8214
  const {
8213
8215
  variant
8214
8216
  } = props,
8215
- other = _objectWithoutPropertiesLoose$2(props, _excluded$O);
8217
+ other = _objectWithoutPropertiesLoose$2(props, _excluded$N);
8216
8218
  let classKey = variant || '';
8217
8219
  Object.keys(other).sort().forEach(key => {
8218
8220
  if (key === 'color') {
@@ -8224,7 +8226,7 @@
8224
8226
  return classKey;
8225
8227
  }
8226
8228
 
8227
- const _excluded$N = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
8229
+ const _excluded$M = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
8228
8230
  function isEmpty$2(obj) {
8229
8231
  return Object.keys(obj).length === 0;
8230
8232
  }
@@ -8330,7 +8332,7 @@
8330
8332
  // For more details: https://github.com/mui/material-ui/pull/37908
8331
8333
  overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot))
8332
8334
  } = inputOptions,
8333
- options = _objectWithoutPropertiesLoose$2(inputOptions, _excluded$N);
8335
+ options = _objectWithoutPropertiesLoose$2(inputOptions, _excluded$M);
8334
8336
 
8335
8337
  // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
8336
8338
  const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
@@ -8800,7 +8802,7 @@
8800
8802
  });
8801
8803
  }
8802
8804
 
8803
- const _excluded$M = ["component", "direction", "spacing", "divider", "children", "className", "useFlexGap"];
8805
+ const _excluded$L = ["component", "direction", "spacing", "divider", "children", "className", "useFlexGap"];
8804
8806
  const defaultTheme$3 = createTheme$1();
8805
8807
  // widening Theme to any so that the consumer can own the theme structure.
8806
8808
  const defaultCreateStyledComponent = systemStyled('div', {
@@ -8933,7 +8935,7 @@
8933
8935
  className,
8934
8936
  useFlexGap = false
8935
8937
  } = props,
8936
- other = _objectWithoutPropertiesLoose$2(props, _excluded$M);
8938
+ other = _objectWithoutPropertiesLoose$2(props, _excluded$L);
8937
8939
  const ownerState = {
8938
8940
  direction,
8939
8941
  spacing,
@@ -8952,7 +8954,7 @@
8952
8954
  return Stack;
8953
8955
  }
8954
8956
 
8955
- const _excluded$L = ["defaultProps", "mixins", "overrides", "palette", "props", "styleOverrides"],
8957
+ const _excluded$K = ["defaultProps", "mixins", "overrides", "palette", "props", "styleOverrides"],
8956
8958
  _excluded2$4 = ["type", "mode"];
8957
8959
  function adaptV4Theme(inputTheme) {
8958
8960
  const {
@@ -8963,7 +8965,7 @@
8963
8965
  props = {},
8964
8966
  styleOverrides = {}
8965
8967
  } = inputTheme,
8966
- other = _objectWithoutPropertiesLoose$3(inputTheme, _excluded$L);
8968
+ other = _objectWithoutPropertiesLoose$3(inputTheme, _excluded$K);
8967
8969
  const theme = _extends$5({}, other, {
8968
8970
  components: {}
8969
8971
  });
@@ -9176,7 +9178,7 @@
9176
9178
  };
9177
9179
  var green$1 = green;
9178
9180
 
9179
- const _excluded$K = ["mode", "contrastThreshold", "tonalOffset"];
9181
+ const _excluded$J = ["mode", "contrastThreshold", "tonalOffset"];
9180
9182
  const light$1 = {
9181
9183
  // The colors used to style the text.
9182
9184
  text: {
@@ -9345,7 +9347,7 @@
9345
9347
  contrastThreshold = 3,
9346
9348
  tonalOffset = 0.2
9347
9349
  } = palette,
9348
- other = _objectWithoutPropertiesLoose$3(palette, _excluded$K);
9350
+ other = _objectWithoutPropertiesLoose$3(palette, _excluded$J);
9349
9351
  const primary = palette.primary || getDefaultPrimary(mode);
9350
9352
  const secondary = palette.secondary || getDefaultSecondary(mode);
9351
9353
  const error = palette.error || getDefaultError(mode);
@@ -9444,7 +9446,7 @@
9444
9446
  return paletteOutput;
9445
9447
  }
9446
9448
 
9447
- const _excluded$J = ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"];
9449
+ const _excluded$I = ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"];
9448
9450
  function round$2(value) {
9449
9451
  return Math.round(value * 1e5) / 1e5;
9450
9452
  }
@@ -9475,7 +9477,7 @@
9475
9477
  allVariants,
9476
9478
  pxToRem: pxToRem2
9477
9479
  } = _ref,
9478
- other = _objectWithoutPropertiesLoose$3(_ref, _excluded$J);
9480
+ other = _objectWithoutPropertiesLoose$3(_ref, _excluded$I);
9479
9481
  const coef = fontSize / 14;
9480
9482
  const pxToRem = pxToRem2 || (size => `${size / htmlFontSize * coef}rem`);
9481
9483
  const buildVariant = (fontWeight, size, lineHeight, letterSpacing, casing) => _extends$5({
@@ -9535,7 +9537,7 @@
9535
9537
  const shadows = ['none', createShadow(0, 2, 1, -1, 0, 1, 1, 0, 0, 1, 3, 0), createShadow(0, 3, 1, -2, 0, 2, 2, 0, 0, 1, 5, 0), createShadow(0, 3, 3, -2, 0, 3, 4, 0, 0, 1, 8, 0), createShadow(0, 2, 4, -1, 0, 4, 5, 0, 0, 1, 10, 0), createShadow(0, 3, 5, -1, 0, 5, 8, 0, 0, 1, 14, 0), createShadow(0, 3, 5, -1, 0, 6, 10, 0, 0, 1, 18, 0), createShadow(0, 4, 5, -2, 0, 7, 10, 1, 0, 2, 16, 1), createShadow(0, 5, 5, -3, 0, 8, 10, 1, 0, 3, 14, 2), createShadow(0, 5, 6, -3, 0, 9, 12, 1, 0, 3, 16, 2), createShadow(0, 6, 6, -3, 0, 10, 14, 1, 0, 4, 18, 3), createShadow(0, 6, 7, -4, 0, 11, 15, 1, 0, 4, 20, 3), createShadow(0, 7, 8, -4, 0, 12, 17, 2, 0, 5, 22, 4), createShadow(0, 7, 8, -4, 0, 13, 19, 2, 0, 5, 24, 4), createShadow(0, 7, 9, -4, 0, 14, 21, 2, 0, 5, 26, 4), createShadow(0, 8, 9, -5, 0, 15, 22, 2, 0, 6, 28, 5), createShadow(0, 8, 10, -5, 0, 16, 24, 2, 0, 6, 30, 5), createShadow(0, 8, 11, -5, 0, 17, 26, 2, 0, 6, 32, 5), createShadow(0, 9, 11, -5, 0, 18, 28, 2, 0, 7, 34, 6), createShadow(0, 9, 12, -6, 0, 19, 29, 2, 0, 7, 36, 6), createShadow(0, 10, 13, -6, 0, 20, 31, 3, 0, 8, 38, 7), createShadow(0, 10, 13, -6, 0, 21, 33, 3, 0, 8, 40, 7), createShadow(0, 10, 14, -6, 0, 22, 35, 3, 0, 8, 42, 7), createShadow(0, 11, 14, -7, 0, 23, 36, 3, 0, 9, 44, 8), createShadow(0, 11, 15, -7, 0, 24, 38, 3, 0, 9, 46, 8)];
9536
9538
  var shadows$1 = shadows;
9537
9539
 
9538
- const _excluded$I = ["duration", "easing", "delay"];
9540
+ const _excluded$H = ["duration", "easing", "delay"];
9539
9541
  // Follow https://material.google.com/motion/duration-easing.html#duration-easing-natural-easing-curves
9540
9542
  // to learn the context in which each easing should be used.
9541
9543
  const easing = {
@@ -9586,7 +9588,7 @@
9586
9588
  easing: easingOption = mergedEasing.easeInOut,
9587
9589
  delay = 0
9588
9590
  } = options;
9589
- _objectWithoutPropertiesLoose$3(options, _excluded$I);
9591
+ _objectWithoutPropertiesLoose$3(options, _excluded$H);
9590
9592
  return (Array.isArray(props) ? props : [props]).map(animatedProp => `${animatedProp} ${typeof durationOption === 'string' ? durationOption : formatMs(durationOption)} ${easingOption} ${typeof delay === 'string' ? delay : formatMs(delay)}`).join(',');
9591
9593
  };
9592
9594
  return _extends$5({
@@ -9612,7 +9614,7 @@
9612
9614
  };
9613
9615
  var zIndex$1 = zIndex;
9614
9616
 
9615
- const _excluded$H = ["breakpoints", "mixins", "spacing", "palette", "transitions", "typography", "shape"];
9617
+ const _excluded$G = ["breakpoints", "mixins", "spacing", "palette", "transitions", "typography", "shape"];
9616
9618
  function createTheme(options = {}, ...args) {
9617
9619
  const {
9618
9620
  mixins: mixinsInput = {},
@@ -9620,7 +9622,7 @@
9620
9622
  transitions: transitionsInput = {},
9621
9623
  typography: typographyInput = {}
9622
9624
  } = options,
9623
- other = _objectWithoutPropertiesLoose$3(options, _excluded$H);
9625
+ other = _objectWithoutPropertiesLoose$3(options, _excluded$G);
9624
9626
  if (options.vars) {
9625
9627
  throw new Error(formatMuiErrorMessage(18));
9626
9628
  }
@@ -9675,12 +9677,12 @@
9675
9677
  });
9676
9678
  var styled$1 = styled;
9677
9679
 
9678
- const _excluded$G = ["theme"];
9680
+ const _excluded$F = ["theme"];
9679
9681
  function ThemeProvider(_ref) {
9680
9682
  let {
9681
9683
  theme: themeInput
9682
9684
  } = _ref,
9683
- props = _objectWithoutPropertiesLoose$3(_ref, _excluded$G);
9685
+ props = _objectWithoutPropertiesLoose$3(_ref, _excluded$F);
9684
9686
  const scopedTheme = themeInput[THEME_ID];
9685
9687
  return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$1, _extends$5({}, props, {
9686
9688
  themeId: scopedTheme ? THEME_ID : undefined,
@@ -10505,7 +10507,7 @@
10505
10507
  const touchRippleClasses = generateUtilityClasses('MuiTouchRipple', ['root', 'ripple', 'rippleVisible', 'ripplePulsate', 'child', 'childLeaving', 'childPulsate']);
10506
10508
  var touchRippleClasses$1 = touchRippleClasses;
10507
10509
 
10508
- const _excluded$F = ["center", "classes", "className"];
10510
+ const _excluded$E = ["center", "classes", "className"];
10509
10511
  let _$1 = t => t,
10510
10512
  _t$1,
10511
10513
  _t2$1,
@@ -10634,7 +10636,7 @@
10634
10636
  classes = {},
10635
10637
  className
10636
10638
  } = props,
10637
- other = _objectWithoutPropertiesLoose$3(props, _excluded$F);
10639
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$E);
10638
10640
  const [ripples, setRipples] = reactExports.useState([]);
10639
10641
  const nextKey = reactExports.useRef(0);
10640
10642
  const rippleCallback = reactExports.useRef(null);
@@ -10821,7 +10823,7 @@
10821
10823
  const buttonBaseClasses = generateUtilityClasses('MuiButtonBase', ['root', 'disabled', 'focusVisible']);
10822
10824
  var buttonBaseClasses$1 = buttonBaseClasses;
10823
10825
 
10824
- const _excluded$E = ["action", "centerRipple", "children", "className", "component", "disabled", "disableRipple", "disableTouchRipple", "focusRipple", "focusVisibleClassName", "LinkComponent", "onBlur", "onClick", "onContextMenu", "onDragLeave", "onFocus", "onFocusVisible", "onKeyDown", "onKeyUp", "onMouseDown", "onMouseLeave", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "tabIndex", "TouchRippleProps", "touchRippleRef", "type"];
10826
+ const _excluded$D = ["action", "centerRipple", "children", "className", "component", "disabled", "disableRipple", "disableTouchRipple", "focusRipple", "focusVisibleClassName", "LinkComponent", "onBlur", "onClick", "onContextMenu", "onDragLeave", "onFocus", "onFocusVisible", "onKeyDown", "onKeyUp", "onMouseDown", "onMouseLeave", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "tabIndex", "TouchRippleProps", "touchRippleRef", "type"];
10825
10827
  const useUtilityClasses$r = ownerState => {
10826
10828
  const {
10827
10829
  disabled,
@@ -10923,7 +10925,7 @@
10923
10925
  touchRippleRef,
10924
10926
  type
10925
10927
  } = props,
10926
- other = _objectWithoutPropertiesLoose$3(props, _excluded$E);
10928
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$D);
10927
10929
  const buttonRef = reactExports.useRef(null);
10928
10930
  const rippleRef = reactExports.useRef(null);
10929
10931
  const handleRippleRef = useForkRef(rippleRef, touchRippleRef);
@@ -11127,7 +11129,7 @@
11127
11129
  const ButtonGroupContext = /*#__PURE__*/reactExports.createContext({});
11128
11130
  var ButtonGroupContext$1 = ButtonGroupContext;
11129
11131
 
11130
- const _excluded$D = ["children", "color", "component", "className", "disabled", "disableElevation", "disableFocusRipple", "endIcon", "focusVisibleClassName", "fullWidth", "size", "startIcon", "type", "variant"];
11132
+ const _excluded$C = ["children", "color", "component", "className", "disabled", "disableElevation", "disableFocusRipple", "endIcon", "focusVisibleClassName", "fullWidth", "size", "startIcon", "type", "variant"];
11131
11133
  const useUtilityClasses$q = ownerState => {
11132
11134
  const {
11133
11135
  color,
@@ -11353,7 +11355,7 @@
11353
11355
  type,
11354
11356
  variant = 'text'
11355
11357
  } = props,
11356
- other = _objectWithoutPropertiesLoose$3(props, _excluded$D);
11358
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$C);
11357
11359
  const ownerState = _extends$5({}, props, {
11358
11360
  color,
11359
11361
  component,
@@ -11710,7 +11712,7 @@
11710
11712
  return cache[key];
11711
11713
  }
11712
11714
 
11713
- const NEBULA_VERSION_HASH = "9b4b" ;
11715
+ const NEBULA_VERSION_HASH = "d1ff" ;
11714
11716
  ClassNameGenerator$1.configure(componentName => {
11715
11717
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
11716
11718
  });
@@ -11971,7 +11973,7 @@
11971
11973
  const appRef = React.createRef();
11972
11974
  const element = document.createElement('div');
11973
11975
  element.style.display = 'none';
11974
- element.setAttribute('data-nebulajs-version', "4.4.0" );
11976
+ element.setAttribute('data-nebulajs-version', "4.5.0-alpha.0" );
11975
11977
  element.setAttribute('data-app-id', app.id);
11976
11978
  document.body.appendChild(element);
11977
11979
  if (context) {
@@ -12044,7 +12046,7 @@
12044
12046
  }
12045
12047
  generateUtilityClasses('MuiSvgIcon', ['root', 'colorPrimary', 'colorSecondary', 'colorAction', 'colorError', 'colorDisabled', 'fontSizeInherit', 'fontSizeSmall', 'fontSizeMedium', 'fontSizeLarge']);
12046
12048
 
12047
- const _excluded$C = ["children", "className", "color", "component", "fontSize", "htmlColor", "inheritViewBox", "titleAccess", "viewBox"];
12049
+ const _excluded$B = ["children", "className", "color", "component", "fontSize", "htmlColor", "inheritViewBox", "titleAccess", "viewBox"];
12048
12050
  const useUtilityClasses$p = ownerState => {
12049
12051
  const {
12050
12052
  color,
@@ -12112,7 +12114,7 @@
12112
12114
  titleAccess,
12113
12115
  viewBox = '0 0 24 24'
12114
12116
  } = props,
12115
- other = _objectWithoutPropertiesLoose$3(props, _excluded$C);
12117
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$B);
12116
12118
  const hasSvgAsChild = /*#__PURE__*/reactExports.isValidElement(children) && children.type === 'svg';
12117
12119
  const ownerState = _extends$5({}, props, {
12118
12120
  color,
@@ -12209,7 +12211,7 @@
12209
12211
  }
12210
12212
  generateUtilityClasses('MuiPaper', ['root', 'rounded', 'outlined', 'elevation', 'elevation0', 'elevation1', 'elevation2', 'elevation3', 'elevation4', 'elevation5', 'elevation6', 'elevation7', 'elevation8', 'elevation9', 'elevation10', 'elevation11', 'elevation12', 'elevation13', 'elevation14', 'elevation15', 'elevation16', 'elevation17', 'elevation18', 'elevation19', 'elevation20', 'elevation21', 'elevation22', 'elevation23', 'elevation24']);
12211
12213
 
12212
- const _excluded$B = ["className", "component", "elevation", "square", "variant"];
12214
+ const _excluded$A = ["className", "component", "elevation", "square", "variant"];
12213
12215
  const useUtilityClasses$o = ownerState => {
12214
12216
  const {
12215
12217
  square,
@@ -12264,7 +12266,7 @@
12264
12266
  square = false,
12265
12267
  variant = 'elevation'
12266
12268
  } = props,
12267
- other = _objectWithoutPropertiesLoose$3(props, _excluded$B);
12269
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$A);
12268
12270
  const ownerState = _extends$5({}, props, {
12269
12271
  component,
12270
12272
  elevation,
@@ -12287,7 +12289,7 @@
12287
12289
  const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge']);
12288
12290
  var iconButtonClasses$1 = iconButtonClasses;
12289
12291
 
12290
- const _excluded$A = ["edge", "children", "className", "color", "disabled", "disableFocusRipple", "size"];
12292
+ const _excluded$z = ["edge", "children", "className", "color", "disabled", "disableFocusRipple", "size"];
12291
12293
  const useUtilityClasses$n = ownerState => {
12292
12294
  const {
12293
12295
  classes,
@@ -12388,7 +12390,7 @@
12388
12390
  disableFocusRipple = false,
12389
12391
  size = 'medium'
12390
12392
  } = props,
12391
- other = _objectWithoutPropertiesLoose$3(props, _excluded$A);
12393
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$z);
12392
12394
  const ownerState = _extends$5({}, props, {
12393
12395
  edge,
12394
12396
  color,
@@ -12415,7 +12417,7 @@
12415
12417
  }
12416
12418
  generateUtilityClasses('MuiTypography', ['root', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'inherit', 'button', 'caption', 'overline', 'alignLeft', 'alignRight', 'alignCenter', 'alignJustify', 'noWrap', 'gutterBottom', 'paragraph']);
12417
12419
 
12418
- const _excluded$z = ["align", "className", "component", "gutterBottom", "noWrap", "paragraph", "variant", "variantMapping"];
12420
+ const _excluded$y = ["align", "className", "component", "gutterBottom", "noWrap", "paragraph", "variant", "variantMapping"];
12419
12421
  const useUtilityClasses$m = ownerState => {
12420
12422
  const {
12421
12423
  align,
@@ -12502,7 +12504,7 @@
12502
12504
  variant = 'body1',
12503
12505
  variantMapping = defaultVariantMapping
12504
12506
  } = props,
12505
- other = _objectWithoutPropertiesLoose$3(props, _excluded$z);
12507
+ other = _objectWithoutPropertiesLoose$3(props, _excluded$y);
12506
12508
  const ownerState = _extends$5({}, props, {
12507
12509
  align,
12508
12510
  color,
@@ -12719,7 +12721,7 @@
12719
12721
  };
12720
12722
  }
12721
12723
 
12722
- const _excluded$y = ["elementType", "externalSlotProps", "ownerState", "skipResolvingSlotProps"];
12724
+ const _excluded$x = ["elementType", "externalSlotProps", "ownerState", "skipResolvingSlotProps"];
12723
12725
  /**
12724
12726
  * @ignore - do not document.
12725
12727
  * Builds the props to be passed into the slot of an unstyled component.
@@ -12736,7 +12738,7 @@
12736
12738
  ownerState,
12737
12739
  skipResolvingSlotProps = false
12738
12740
  } = parameters,
12739
- rest = _objectWithoutPropertiesLoose(parameters, _excluded$y);
12741
+ rest = _objectWithoutPropertiesLoose(parameters, _excluded$x);
12740
12742
  const resolvedComponentsProps = skipResolvingSlotProps ? {} : resolveComponentProps(externalSlotProps, ownerState);
12741
12743
  const {
12742
12744
  props: mergedProps,
@@ -14900,7 +14902,7 @@
14900
14902
  }
14901
14903
  generateUtilityClasses('MuiPopper', ['root']);
14902
14904
 
14903
- const _excluded$x = ["anchorEl", "children", "direction", "disablePortal", "modifiers", "open", "placement", "popperOptions", "popperRef", "slotProps", "slots", "TransitionProps", "ownerState"],
14905
+ const _excluded$w = ["anchorEl", "children", "direction", "disablePortal", "modifiers", "open", "placement", "popperOptions", "popperRef", "slotProps", "slots", "TransitionProps", "ownerState"],
14904
14906
  _excluded2$3 = ["anchorEl", "children", "container", "direction", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "style", "transition", "slotProps", "slots"];
14905
14907
  function flipPlacement(placement, direction) {
14906
14908
  if (direction === 'ltr') {
@@ -14950,7 +14952,7 @@
14950
14952
  // @ts-ignore internal logic
14951
14953
  // prevent from spreading to DOM, it can come from the parent component e.g. Select.
14952
14954
  } = props,
14953
- other = _objectWithoutPropertiesLoose(props, _excluded$x);
14955
+ other = _objectWithoutPropertiesLoose(props, _excluded$w);
14954
14956
  const tooltipRef = reactExports.useRef(null);
14955
14957
  const ownRef = useForkRef(tooltipRef, forwardedRef);
14956
14958
  const popperRef = reactExports.useRef(null);
@@ -15210,7 +15212,7 @@
15210
15212
  if (container.parentNode instanceof DocumentFragment) {
15211
15213
  scrollContainer = ownerDocument(container).body;
15212
15214
  } else {
15213
- // Improve Gatsby support
15215
+ // Support html overflow-y: auto for scroll stability between pages
15214
15216
  // https://css-tricks.com/snippets/css/force-vertical-scrollbar/
15215
15217
  const parent = container.parentElement;
15216
15218
  const containerWindow = ownerWindow(container);
@@ -15345,23 +15347,6 @@
15345
15347
  }
15346
15348
  }
15347
15349
 
15348
- function getModalUtilityClass(slot) {
15349
- return generateUtilityClass('MuiModal', slot);
15350
- }
15351
- generateUtilityClasses('MuiModal', ['root', 'hidden', 'backdrop']);
15352
-
15353
- const _excluded$w = ["children", "closeAfterTransition", "container", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "manager", "onBackdropClick", "onClose", "onKeyDown", "open", "onTransitionEnter", "onTransitionExited", "slotProps", "slots"];
15354
- const useUtilityClasses$k = ownerState => {
15355
- const {
15356
- open,
15357
- exited
15358
- } = ownerState;
15359
- const slots = {
15360
- root: ['root', !open && exited && 'hidden'],
15361
- backdrop: ['backdrop']
15362
- };
15363
- return composeClasses(slots, useClassNamesOverride(getModalUtilityClass));
15364
- };
15365
15350
  function getContainer(container) {
15366
15351
  return typeof container === 'function' ? container() : container;
15367
15352
  }
@@ -15372,68 +15357,47 @@
15372
15357
  // A modal manager used to track and manage the state of open Modals.
15373
15358
  // Modals don't open on the server so this won't conflict with concurrent requests.
15374
15359
  const defaultManager = new ModalManager();
15375
-
15376
15360
  /**
15377
- * Modal is a lower-level construct that is leveraged by the following components:
15378
- *
15379
- * * [Dialog](https://mui.com/material-ui/api/dialog/)
15380
- * * [Drawer](https://mui.com/material-ui/api/drawer/)
15381
- * * [Menu](https://mui.com/material-ui/api/menu/)
15382
- * * [Popover](https://mui.com/material-ui/api/popover/)
15383
- *
15384
- * If you are creating a modal dialog, you probably want to use the [Dialog](https://mui.com/material-ui/api/dialog/) component
15385
- * rather than directly using Modal.
15386
- *
15387
- * This component shares many concepts with [react-overlays](https://react-bootstrap.github.io/react-overlays/#modals).
15388
15361
  *
15389
15362
  * Demos:
15390
15363
  *
15391
- * - [Modal](https://mui.com/base-ui/react-modal/)
15364
+ * - [Modal](https://mui.com/base-ui/react-modal/#hook)
15392
15365
  *
15393
15366
  * API:
15394
15367
  *
15395
- * - [Modal API](https://mui.com/base-ui/react-modal/components-api/#modal)
15368
+ * - [useModal API](https://mui.com/base-ui/react-modal/hooks-api/#use-modal)
15396
15369
  */
15397
- const Modal$2 = /*#__PURE__*/reactExports.forwardRef(function Modal(props, forwardedRef) {
15398
- var _props$ariaHidden, _slots$root;
15370
+ function useModal(parameters) {
15399
15371
  const {
15400
- children,
15401
- closeAfterTransition = false,
15402
- container,
15403
- disableAutoFocus = false,
15404
- disableEnforceFocus = false,
15405
- disableEscapeKeyDown = false,
15406
- disablePortal = false,
15407
- disableRestoreFocus = false,
15408
- disableScrollLock = false,
15409
- hideBackdrop = false,
15410
- keepMounted = false,
15411
- // private
15412
- manager: managerProp = defaultManager,
15413
- onBackdropClick,
15414
- onClose,
15415
- onKeyDown,
15416
- open,
15417
- onTransitionEnter,
15418
- onTransitionExited,
15419
- slotProps = {},
15420
- slots = {}
15421
- } = props,
15422
- other = _objectWithoutPropertiesLoose(props, _excluded$w);
15423
- // TODO: `modal`` must change its type in this file to match the type of methods
15424
- // provided by `ModalManager`
15425
- const manager = managerProp;
15426
- const [exited, setExited] = reactExports.useState(!open);
15372
+ container,
15373
+ disableEscapeKeyDown = false,
15374
+ disableScrollLock = false,
15375
+ // @ts-ignore internal logic - Base UI supports the manager as a prop too
15376
+ manager = defaultManager,
15377
+ closeAfterTransition = false,
15378
+ onTransitionEnter,
15379
+ onTransitionExited,
15380
+ children,
15381
+ onClose,
15382
+ open,
15383
+ rootRef
15384
+ } = parameters;
15385
+
15386
+ // @ts-ignore internal logic
15427
15387
  const modal = reactExports.useRef({});
15428
15388
  const mountNodeRef = reactExports.useRef(null);
15429
15389
  const modalRef = reactExports.useRef(null);
15430
- const handleRef = useForkRef(modalRef, forwardedRef);
15390
+ const handleRef = useForkRef(modalRef, rootRef);
15391
+ const [exited, setExited] = reactExports.useState(!open);
15431
15392
  const hasTransition = getHasTransition(children);
15432
- const ariaHiddenProp = (_props$ariaHidden = props['aria-hidden']) != null ? _props$ariaHidden : true;
15393
+ let ariaHiddenProp = true;
15394
+ if (parameters['aria-hidden'] === 'false' || parameters['aria-hidden'] === false) {
15395
+ ariaHiddenProp = false;
15396
+ }
15433
15397
  const getDoc = () => ownerDocument(mountNodeRef.current);
15434
15398
  const getModal = () => {
15435
15399
  modal.current.modalRef = modalRef.current;
15436
- modal.current.mountNode = mountNodeRef.current;
15400
+ modal.current.mount = mountNodeRef.current;
15437
15401
  return modal.current;
15438
15402
  };
15439
15403
  const handleMounted = () => {
@@ -15458,18 +15422,18 @@
15458
15422
  const isTopModal = reactExports.useCallback(() => manager.isTopModal(getModal()), [manager]);
15459
15423
  const handlePortalRef = useEventCallback(node => {
15460
15424
  mountNodeRef.current = node;
15461
- if (!node || !modalRef.current) {
15425
+ if (!node) {
15462
15426
  return;
15463
15427
  }
15464
15428
  if (open && isTopModal()) {
15465
15429
  handleMounted();
15466
- } else {
15430
+ } else if (modalRef.current) {
15467
15431
  ariaHidden(modalRef.current, ariaHiddenProp);
15468
15432
  }
15469
15433
  });
15470
15434
  const handleClose = reactExports.useCallback(() => {
15471
15435
  manager.remove(getModal(), ariaHiddenProp);
15472
- }, [manager, ariaHiddenProp]);
15436
+ }, [ariaHiddenProp, manager]);
15473
15437
  reactExports.useEffect(() => {
15474
15438
  return () => {
15475
15439
  handleClose();
@@ -15482,49 +15446,9 @@
15482
15446
  handleClose();
15483
15447
  }
15484
15448
  }, [open, handleClose, hasTransition, closeAfterTransition, handleOpen]);
15485
- const ownerState = _extends({}, props, {
15486
- closeAfterTransition,
15487
- disableAutoFocus,
15488
- disableEnforceFocus,
15489
- disableEscapeKeyDown,
15490
- disablePortal,
15491
- disableRestoreFocus,
15492
- disableScrollLock,
15493
- exited,
15494
- hideBackdrop,
15495
- keepMounted
15496
- });
15497
- const classes = useUtilityClasses$k(ownerState);
15498
- const handleEnter = () => {
15499
- setExited(false);
15500
- if (onTransitionEnter) {
15501
- onTransitionEnter();
15502
- }
15503
- };
15504
- const handleExited = () => {
15505
- setExited(true);
15506
- if (onTransitionExited) {
15507
- onTransitionExited();
15508
- }
15509
- if (closeAfterTransition) {
15510
- handleClose();
15511
- }
15512
- };
15513
- const handleBackdropClick = event => {
15514
- if (event.target !== event.currentTarget) {
15515
- return;
15516
- }
15517
- if (onBackdropClick) {
15518
- onBackdropClick(event);
15519
- }
15520
- if (onClose) {
15521
- onClose(event, 'backdropClick');
15522
- }
15523
- };
15524
- const handleKeyDown = event => {
15525
- if (onKeyDown) {
15526
- onKeyDown(event);
15527
- }
15449
+ const createHandleKeyDown = otherHandlers => event => {
15450
+ var _otherHandlers$onKeyD;
15451
+ (_otherHandlers$onKeyD = otherHandlers.onKeyDown) == null ? void 0 : _otherHandlers$onKeyD.call(otherHandlers, event);
15528
15452
 
15529
15453
  // The handler doesn't take event.defaultPrevented into account:
15530
15454
  //
@@ -15543,62 +15467,71 @@
15543
15467
  }
15544
15468
  }
15545
15469
  };
15546
- const childProps = {};
15547
- if (children.props.tabIndex === undefined) {
15548
- childProps.tabIndex = '-1';
15549
- }
15470
+ const createHandleBackdropClick = otherHandlers => event => {
15471
+ var _otherHandlers$onClic;
15472
+ (_otherHandlers$onClic = otherHandlers.onClick) == null ? void 0 : _otherHandlers$onClic.call(otherHandlers, event);
15473
+ if (event.target !== event.currentTarget) {
15474
+ return;
15475
+ }
15476
+ if (onClose) {
15477
+ onClose(event, 'backdropClick');
15478
+ }
15479
+ };
15480
+ const getRootProps = (otherHandlers = {}) => {
15481
+ const propsEventHandlers = extractEventHandlers(parameters);
15550
15482
 
15551
- // It's a Transition like component
15552
- if (hasTransition) {
15553
- childProps.onEnter = createChainedFunction(handleEnter, children.props.onEnter);
15554
- childProps.onExited = createChainedFunction(handleExited, children.props.onExited);
15555
- }
15556
- const Root = (_slots$root = slots.root) != null ? _slots$root : 'div';
15557
- const rootProps = useSlotProps({
15558
- elementType: Root,
15559
- externalSlotProps: slotProps.root,
15560
- externalForwardedProps: other,
15561
- additionalProps: {
15562
- ref: handleRef,
15563
- role: 'presentation',
15564
- onKeyDown: handleKeyDown
15565
- },
15566
- className: classes.root,
15567
- ownerState
15568
- });
15569
- const BackdropComponent = slots.backdrop;
15570
- const backdropProps = useSlotProps({
15571
- elementType: BackdropComponent,
15572
- externalSlotProps: slotProps.backdrop,
15573
- additionalProps: {
15574
- 'aria-hidden': true,
15575
- onClick: handleBackdropClick,
15483
+ // The custom event handlers shouldn't be spread on the root element
15484
+ delete propsEventHandlers.onTransitionEnter;
15485
+ delete propsEventHandlers.onTransitionExited;
15486
+ const externalEventHandlers = _extends({}, propsEventHandlers, otherHandlers);
15487
+ return _extends({
15488
+ role: 'presentation'
15489
+ }, externalEventHandlers, {
15490
+ onKeyDown: createHandleKeyDown(externalEventHandlers),
15491
+ ref: handleRef
15492
+ });
15493
+ };
15494
+ const getBackdropProps = (otherHandlers = {}) => {
15495
+ const externalEventHandlers = otherHandlers;
15496
+ return _extends({
15497
+ 'aria-hidden': true
15498
+ }, externalEventHandlers, {
15499
+ onClick: createHandleBackdropClick(externalEventHandlers),
15576
15500
  open
15577
- },
15578
- className: classes.backdrop,
15579
- ownerState
15580
- });
15581
- if (!keepMounted && !open && (!hasTransition || exited)) {
15582
- return null;
15583
- }
15584
- return /*#__PURE__*/jsxRuntimeExports.jsx(Portal
15585
- // @ts-expect-error TODO: include ref to Base UI Portal props
15586
- , {
15587
- ref: handlePortalRef,
15588
- container: container,
15589
- disablePortal: disablePortal,
15590
- children: /*#__PURE__*/jsxRuntimeExports.jsxs(Root, _extends({}, rootProps, {
15591
- children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/jsxRuntimeExports.jsx(BackdropComponent, _extends({}, backdropProps)) : null, /*#__PURE__*/jsxRuntimeExports.jsx(FocusTrap, {
15592
- disableEnforceFocus: disableEnforceFocus,
15593
- disableAutoFocus: disableAutoFocus,
15594
- disableRestoreFocus: disableRestoreFocus,
15595
- isEnabled: isTopModal,
15596
- open: open,
15597
- children: /*#__PURE__*/reactExports.cloneElement(children, childProps)
15598
- })]
15599
- }))
15600
- });
15601
- });
15501
+ });
15502
+ };
15503
+ const getTransitionProps = () => {
15504
+ const handleEnter = () => {
15505
+ setExited(false);
15506
+ if (onTransitionEnter) {
15507
+ onTransitionEnter();
15508
+ }
15509
+ };
15510
+ const handleExited = () => {
15511
+ setExited(true);
15512
+ if (onTransitionExited) {
15513
+ onTransitionExited();
15514
+ }
15515
+ if (closeAfterTransition) {
15516
+ handleClose();
15517
+ }
15518
+ };
15519
+ return {
15520
+ onEnter: createChainedFunction(handleEnter, children.props.onEnter),
15521
+ onExited: createChainedFunction(handleExited, children.props.onExited)
15522
+ };
15523
+ };
15524
+ return {
15525
+ getRootProps,
15526
+ getBackdropProps,
15527
+ getTransitionProps,
15528
+ rootRef: handleRef,
15529
+ portalRef: handlePortalRef,
15530
+ isTopModal,
15531
+ exited,
15532
+ hasTransition
15533
+ };
15534
+ }
15602
15535
 
15603
15536
  const _excluded$v = ["onChange", "maxRows", "minRows", "style", "value"];
15604
15537
  function getStyleValue(value) {
@@ -15956,7 +15889,7 @@
15956
15889
  } = props;
15957
15890
  return [styles.input, ownerState.size === 'small' && styles.inputSizeSmall, ownerState.multiline && styles.inputMultiline, ownerState.type === 'search' && styles.inputTypeSearch, ownerState.startAdornment && styles.inputAdornedStart, ownerState.endAdornment && styles.inputAdornedEnd, ownerState.hiddenLabel && styles.inputHiddenLabel];
15958
15891
  };
15959
- const useUtilityClasses$j = ownerState => {
15892
+ const useUtilityClasses$k = ownerState => {
15960
15893
  const {
15961
15894
  classes,
15962
15895
  color,
@@ -16282,7 +16215,7 @@
16282
16215
  if (inputRef.current && event.currentTarget === event.target) {
16283
16216
  inputRef.current.focus();
16284
16217
  }
16285
- if (onClick && !fcs.disabled) {
16218
+ if (onClick) {
16286
16219
  onClick(event);
16287
16220
  }
16288
16221
  };
@@ -16329,7 +16262,7 @@
16329
16262
  startAdornment,
16330
16263
  type
16331
16264
  });
16332
- const classes = useUtilityClasses$j(ownerState);
16265
+ const classes = useUtilityClasses$k(ownerState);
16333
16266
  const Root = slots.root || components.Root || InputBaseRoot;
16334
16267
  const rootProps = slotProps.root || componentsProps.root || {};
16335
16268
  const Input = slots.input || components.Input || InputBaseComponent;
@@ -16511,7 +16444,7 @@
16511
16444
  generateUtilityClasses('MuiBackdrop', ['root', 'invisible']);
16512
16445
 
16513
16446
  const _excluded$r = ["children", "className", "component", "components", "componentsProps", "invisible", "open", "slotProps", "slots", "TransitionComponent", "transitionDuration"];
16514
- const useUtilityClasses$i = ownerState => {
16447
+ const useUtilityClasses$j = ownerState => {
16515
16448
  const {
16516
16449
  classes,
16517
16450
  invisible
@@ -16570,7 +16503,7 @@
16570
16503
  component,
16571
16504
  invisible
16572
16505
  });
16573
- const classes = useUtilityClasses$i(ownerState);
16506
+ const classes = useUtilityClasses$j(ownerState);
16574
16507
  const rootSlotProps = (_slotProps$root = slotProps.root) != null ? _slotProps$root : componentsProps.root;
16575
16508
  return /*#__PURE__*/jsxRuntimeExports.jsx(TransitionComponent, _extends$5({
16576
16509
  in: open,
@@ -16601,7 +16534,7 @@
16601
16534
  const _excluded$q = ["anchorOrigin", "className", "classes", "component", "components", "componentsProps", "children", "overlap", "color", "invisible", "max", "badgeContent", "slots", "slotProps", "showZero", "variant"];
16602
16535
  const RADIUS_STANDARD = 10;
16603
16536
  const RADIUS_DOT = 4;
16604
- const useUtilityClasses$h = ownerState => {
16537
+ const useUtilityClasses$i = ownerState => {
16605
16538
  const {
16606
16539
  color,
16607
16540
  anchorOrigin,
@@ -16804,7 +16737,7 @@
16804
16737
  overlap,
16805
16738
  variant
16806
16739
  });
16807
- const classes = useUtilityClasses$h(ownerState);
16740
+ const classes = useUtilityClasses$i(ownerState);
16808
16741
 
16809
16742
  // support both `slots` and `components` for backward compatibility
16810
16743
  const RootSlot = (_ref = (_slots$root = slots == null ? void 0 : slots.root) != null ? _slots$root : components.Root) != null ? _ref : BadgeRoot;
@@ -16851,7 +16784,7 @@
16851
16784
  generateUtilityClasses('PrivateSwitchBase', ['root', 'checked', 'disabled', 'input', 'edgeStart', 'edgeEnd']);
16852
16785
 
16853
16786
  const _excluded$p = ["autoFocus", "checked", "checkedIcon", "className", "defaultChecked", "disabled", "disableFocusRipple", "edge", "icon", "id", "inputProps", "inputRef", "name", "onBlur", "onChange", "onFocus", "readOnly", "required", "tabIndex", "type", "value"];
16854
- const useUtilityClasses$g = ownerState => {
16787
+ const useUtilityClasses$h = ownerState => {
16855
16788
  const {
16856
16789
  classes,
16857
16790
  checked,
@@ -16963,7 +16896,7 @@
16963
16896
  disableFocusRipple,
16964
16897
  edge
16965
16898
  });
16966
- const classes = useUtilityClasses$g(ownerState);
16899
+ const classes = useUtilityClasses$h(ownerState);
16967
16900
  return /*#__PURE__*/jsxRuntimeExports.jsxs(SwitchBaseRoot, _extends$5({
16968
16901
  component: "span",
16969
16902
  className: clsx(classes.root, className),
@@ -17018,7 +16951,7 @@
17018
16951
  var checkboxClasses$1 = checkboxClasses;
17019
16952
 
17020
16953
  const _excluded$o = ["checkedIcon", "color", "icon", "indeterminate", "indeterminateIcon", "inputProps", "size", "className"];
17021
- const useUtilityClasses$f = ownerState => {
16954
+ const useUtilityClasses$g = ownerState => {
17022
16955
  const {
17023
16956
  classes,
17024
16957
  indeterminate,
@@ -17089,7 +17022,7 @@
17089
17022
  indeterminate,
17090
17023
  size
17091
17024
  });
17092
- const classes = useUtilityClasses$f(ownerState);
17025
+ const classes = useUtilityClasses$g(ownerState);
17093
17026
  return /*#__PURE__*/jsxRuntimeExports.jsx(CheckboxRoot, _extends$5({
17094
17027
  type: "checkbox",
17095
17028
  inputProps: _extends$5({
@@ -17147,7 +17080,7 @@
17147
17080
  stroke-dashoffset: -125px;
17148
17081
  }
17149
17082
  `));
17150
- const useUtilityClasses$e = ownerState => {
17083
+ const useUtilityClasses$f = ownerState => {
17151
17084
  const {
17152
17085
  classes,
17153
17086
  variant,
@@ -17249,7 +17182,7 @@
17249
17182
  value,
17250
17183
  variant
17251
17184
  });
17252
- const classes = useUtilityClasses$e(ownerState);
17185
+ const classes = useUtilityClasses$f(ownerState);
17253
17186
  const circleStyle = {};
17254
17187
  const rootStyle = {};
17255
17188
  const rootProps = {};
@@ -17289,7 +17222,24 @@
17289
17222
  });
17290
17223
  var CircularProgress$1 = CircularProgress;
17291
17224
 
17225
+ function getModalUtilityClass(slot) {
17226
+ return generateUtilityClass('MuiModal', slot);
17227
+ }
17228
+ generateUtilityClasses('MuiModal', ['root', 'hidden', 'backdrop']);
17229
+
17292
17230
  const _excluded$m = ["BackdropComponent", "BackdropProps", "classes", "className", "closeAfterTransition", "children", "container", "component", "components", "componentsProps", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "onBackdropClick", "onClose", "open", "slotProps", "slots", "theme"];
17231
+ const useUtilityClasses$e = ownerState => {
17232
+ const {
17233
+ open,
17234
+ exited,
17235
+ classes
17236
+ } = ownerState;
17237
+ const slots = {
17238
+ root: ['root', !open && exited && 'hidden'],
17239
+ backdrop: ['backdrop']
17240
+ };
17241
+ return composeClasses(slots, getModalUtilityClass, classes);
17242
+ };
17293
17243
  const ModalRoot = styled$1('div', {
17294
17244
  name: 'MuiModal',
17295
17245
  slot: 'Root',
@@ -17344,7 +17294,6 @@
17344
17294
  const {
17345
17295
  BackdropComponent = ModalBackdrop,
17346
17296
  BackdropProps,
17347
- classes,
17348
17297
  className,
17349
17298
  closeAfterTransition = false,
17350
17299
  children,
@@ -17361,17 +17310,13 @@
17361
17310
  hideBackdrop = false,
17362
17311
  keepMounted = false,
17363
17312
  onBackdropClick,
17364
- onClose,
17365
17313
  open,
17366
17314
  slotProps,
17367
- slots,
17315
+ slots
17368
17316
  // eslint-disable-next-line react/prop-types
17369
- theme
17370
17317
  } = props,
17371
17318
  other = _objectWithoutPropertiesLoose$3(props, _excluded$m);
17372
- const [exited, setExited] = reactExports.useState(true);
17373
- const commonProps = {
17374
- container,
17319
+ const propsWithDefaults = _extends$5({}, props, {
17375
17320
  closeAfterTransition,
17376
17321
  disableAutoFocus,
17377
17322
  disableEnforceFocus,
@@ -17380,40 +17325,90 @@
17380
17325
  disableRestoreFocus,
17381
17326
  disableScrollLock,
17382
17327
  hideBackdrop,
17383
- keepMounted,
17384
- onBackdropClick,
17385
- onClose,
17386
- open
17387
- };
17388
- const ownerState = _extends$5({}, props, commonProps, {
17328
+ keepMounted
17329
+ });
17330
+ const {
17331
+ getRootProps,
17332
+ getBackdropProps,
17333
+ getTransitionProps,
17334
+ portalRef,
17335
+ isTopModal,
17336
+ exited,
17337
+ hasTransition
17338
+ } = useModal(_extends$5({}, propsWithDefaults, {
17339
+ rootRef: ref
17340
+ }));
17341
+ const ownerState = _extends$5({}, propsWithDefaults, {
17389
17342
  exited
17390
17343
  });
17344
+ const classes = useUtilityClasses$e(ownerState);
17345
+ const childProps = {};
17346
+ if (children.props.tabIndex === undefined) {
17347
+ childProps.tabIndex = '-1';
17348
+ }
17349
+
17350
+ // It's a Transition like component
17351
+ if (hasTransition) {
17352
+ const {
17353
+ onEnter,
17354
+ onExited
17355
+ } = getTransitionProps();
17356
+ childProps.onEnter = onEnter;
17357
+ childProps.onExited = onExited;
17358
+ }
17391
17359
  const RootSlot = (_ref = (_slots$root = slots == null ? void 0 : slots.root) != null ? _slots$root : components.Root) != null ? _ref : ModalRoot;
17392
17360
  const BackdropSlot = (_ref2 = (_slots$backdrop = slots == null ? void 0 : slots.backdrop) != null ? _slots$backdrop : components.Backdrop) != null ? _ref2 : BackdropComponent;
17393
17361
  const rootSlotProps = (_slotProps$root = slotProps == null ? void 0 : slotProps.root) != null ? _slotProps$root : componentsProps.root;
17394
17362
  const backdropSlotProps = (_slotProps$backdrop = slotProps == null ? void 0 : slotProps.backdrop) != null ? _slotProps$backdrop : componentsProps.backdrop;
17395
- return /*#__PURE__*/jsxRuntimeExports.jsx(Modal$2, _extends$5({
17396
- slots: {
17397
- root: RootSlot,
17398
- backdrop: BackdropSlot
17363
+ const rootProps = useSlotProps({
17364
+ elementType: RootSlot,
17365
+ externalSlotProps: rootSlotProps,
17366
+ externalForwardedProps: other,
17367
+ getSlotProps: getRootProps,
17368
+ additionalProps: {
17369
+ ref,
17370
+ as: component
17399
17371
  },
17400
- slotProps: {
17401
- root: () => _extends$5({}, resolveComponentProps(rootSlotProps, ownerState), !isHostComponent(RootSlot) && {
17402
- as: component,
17403
- theme
17404
- }, {
17405
- className: clsx(className, rootSlotProps == null ? void 0 : rootSlotProps.className, classes == null ? void 0 : classes.root, !ownerState.open && ownerState.exited && (classes == null ? void 0 : classes.hidden))
17406
- }),
17407
- backdrop: () => _extends$5({}, BackdropProps, resolveComponentProps(backdropSlotProps, ownerState), {
17408
- className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop)
17409
- })
17372
+ ownerState,
17373
+ className: clsx(className, rootSlotProps == null ? void 0 : rootSlotProps.className, classes == null ? void 0 : classes.root, !ownerState.open && ownerState.exited && (classes == null ? void 0 : classes.hidden))
17374
+ });
17375
+ const backdropProps = useSlotProps({
17376
+ elementType: BackdropSlot,
17377
+ externalSlotProps: backdropSlotProps,
17378
+ additionalProps: BackdropProps,
17379
+ getSlotProps: otherHandlers => {
17380
+ return getBackdropProps(_extends$5({}, otherHandlers, {
17381
+ onClick: e => {
17382
+ if (onBackdropClick) {
17383
+ onBackdropClick(e);
17384
+ }
17385
+ if (otherHandlers != null && otherHandlers.onClick) {
17386
+ otherHandlers.onClick(e);
17387
+ }
17388
+ }
17389
+ }));
17410
17390
  },
17411
- onTransitionEnter: () => setExited(false),
17412
- onTransitionExited: () => setExited(true),
17413
- ref: ref
17414
- }, other, commonProps, {
17415
- children: children
17416
- }));
17391
+ className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop),
17392
+ ownerState
17393
+ });
17394
+ if (!keepMounted && !open && (!hasTransition || exited)) {
17395
+ return null;
17396
+ }
17397
+ return /*#__PURE__*/jsxRuntimeExports.jsx(Portal, {
17398
+ ref: portalRef,
17399
+ container: container,
17400
+ disablePortal: disablePortal,
17401
+ children: /*#__PURE__*/jsxRuntimeExports.jsxs(RootSlot, _extends$5({}, rootProps, {
17402
+ children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/jsxRuntimeExports.jsx(BackdropSlot, _extends$5({}, backdropProps)) : null, /*#__PURE__*/jsxRuntimeExports.jsx(FocusTrap, {
17403
+ disableEnforceFocus: disableEnforceFocus,
17404
+ disableAutoFocus: disableAutoFocus,
17405
+ disableRestoreFocus: disableRestoreFocus,
17406
+ isEnabled: isTopModal,
17407
+ open: open,
17408
+ children: /*#__PURE__*/reactExports.cloneElement(children, childProps)
17409
+ })]
17410
+ }))
17411
+ });
17417
17412
  });
17418
17413
  var Modal$1 = Modal;
17419
17414
 
@@ -31000,17 +30995,26 @@
31000
30995
  halo,
31001
30996
  model,
31002
30997
  cellRef,
31003
- newType
30998
+ newType,
30999
+ properties
31004
31000
  } = _ref2;
31005
- const propertyTree = await model.getFullPropertyTree();
31001
+ const propertyTree = properties ? {
31002
+ qProperty: properties
31003
+ } : await model.getFullPropertyTree();
31006
31004
  const sourceQae = cellRef.current.getQae();
31007
31005
  const exportProperties = getExportPropertiesFnc(sourceQae);
31006
+ if (!exportProperties) {
31007
+ throw new Error('Source chart does not support conversion');
31008
+ }
31008
31009
  const targetSnType = await getType$1({
31009
31010
  halo,
31010
31011
  name: newType
31011
31012
  });
31012
31013
  const targetQae = targetSnType.qae;
31013
31014
  const importProperties = getImportPropertiesFnc(targetQae);
31015
+ if (!importProperties) {
31016
+ throw new Error('Target chart does not support conversion');
31017
+ }
31014
31018
  const exportFormat = exportProperties({
31015
31019
  propertyTree,
31016
31020
  hypercubePath: helpers.getHypercubePath(sourceQae)
@@ -32082,7 +32086,8 @@
32082
32086
  selections,
32083
32087
  nebbie,
32084
32088
  focusHandler,
32085
- emitter
32089
+ emitter,
32090
+ onMount
32086
32091
  } = _ref5;
32087
32092
  try {
32088
32093
  const snType = await getType({
@@ -32098,7 +32103,14 @@
32098
32103
  focusHandler,
32099
32104
  emitter
32100
32105
  });
32101
- return sn;
32106
+ if (sn) {
32107
+ dispatch({
32108
+ type: 'LOADED',
32109
+ sn,
32110
+ visualization
32111
+ });
32112
+ onMount();
32113
+ }
32102
32114
  } catch (err) {
32103
32115
  if (!version) {
32104
32116
  dispatch({
@@ -32115,8 +32127,8 @@
32115
32127
  }
32116
32128
  });
32117
32129
  }
32130
+ onMount();
32118
32131
  }
32119
- return undefined;
32120
32132
  };
32121
32133
  const Cell = reactExports.forwardRef((_ref6, ref) => {
32122
32134
  let {
@@ -32222,7 +32234,12 @@
32222
32234
  }
32223
32235
  };
32224
32236
  reactExports.useEffect(() => {
32225
- if (initialError || !appLayout || !layout) {
32237
+ if (initialError) {
32238
+ // To resolve the Viz promise for missing types
32239
+ onMount();
32240
+ return undefined;
32241
+ }
32242
+ if (!appLayout || !layout) {
32226
32243
  return undefined;
32227
32244
  }
32228
32245
  const validate = async sn => {
@@ -32247,7 +32264,7 @@
32247
32264
  dispatch({
32248
32265
  type: 'LOADING'
32249
32266
  });
32250
- const sn = await loadType({
32267
+ await loadType({
32251
32268
  dispatch,
32252
32269
  types,
32253
32270
  visualization,
@@ -32257,17 +32274,9 @@
32257
32274
  selections,
32258
32275
  nebbie,
32259
32276
  focusHandler: focusHandler.current,
32260
- emitter
32277
+ emitter,
32278
+ onMount
32261
32279
  });
32262
- if (sn) {
32263
- dispatch({
32264
- type: 'LOADED',
32265
- sn,
32266
- visualization
32267
- });
32268
- onMount();
32269
- }
32270
- return undefined;
32271
32280
  };
32272
32281
 
32273
32282
  // Validate if it's still the same type
@@ -32535,796 +32544,18 @@
32535
32544
  });
32536
32545
  }
32537
32546
 
32538
- const noopi$1 = () => {};
32539
- function viz() {
32540
- let {
32541
- model,
32542
- halo,
32543
- initialError,
32544
- onDestroy = async () => {}
32545
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32546
- let unmountCell = noopi$1;
32547
- let cellRef = null;
32548
- let mountedReference = null;
32549
- let onMount = null;
32550
- let onRender = null;
32551
- const mounted = new Promise(resolve => {
32552
- onMount = resolve;
32553
- });
32554
- const rendered = new Promise(resolve => {
32555
- onRender = resolve;
32556
- });
32557
- const createOnInitialRender = override => () => {
32558
- override && override();
32559
- onRender();
32560
- };
32561
- let initialSnOptions = {};
32562
- let initialSnPlugins = [];
32563
- const emitter = new EventEmitter$1();
32564
- const setSnOptions = async opts => {
32565
- const override = opts.onInitialRender;
32566
- if (mountedReference) {
32567
- (async () => {
32568
- await mounted;
32569
- cellRef.current.setSnOptions(_objectSpread2(_objectSpread2(_objectSpread2({}, initialSnOptions), opts), {
32570
- onInitialRender: createOnInitialRender(override)
32571
- }));
32572
- })();
32573
- } else {
32574
- // Handle setting options before mount
32575
- initialSnOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, initialSnOptions), opts), {
32576
- onInitialRender: createOnInitialRender(override)
32577
- });
32578
- }
32579
- };
32580
- const setSnPlugins = async plugins => {
32581
- validatePlugins(plugins);
32582
- if (mountedReference) {
32583
- (async () => {
32584
- await mounted;
32585
- cellRef.current.setSnPlugins(plugins);
32586
- })();
32587
- } else {
32588
- // Handle setting plugins before mount
32589
- initialSnPlugins = plugins;
32590
- }
32591
- };
32592
-
32593
- /**
32594
- * @class
32595
- * @alias Viz
32596
- * @classdesc A controller to further modify a visualization after it has been rendered.
32597
- * @example
32598
- * const viz = await embed(app).render({
32599
- * element,
32600
- * type: 'barchart'
32601
- * });
32602
- * viz.destroy();
32603
- */
32604
- const api = /** @lends Viz# */{
32605
- /**
32606
- * The id of this visualization's generic object.
32607
- * @type {string}
32608
- */
32609
- id: model.id,
32610
- /**
32611
- * This visualizations Enigma model, a representation of the generic object.
32612
- * @type {EngineAPI.IGenericObject}
32613
- */
32614
- model,
32615
- /**
32616
- * Destroys the visualization and removes it from the the DOM.
32617
- * @example
32618
- * const viz = await embed(app).render({
32619
- * element,
32620
- * id: 'abc'
32621
- * });
32622
- * viz.destroy();
32623
- */
32624
- async destroy() {
32625
- await onDestroy();
32626
- unmountCell();
32627
- unmountCell = noopi$1;
32628
- },
32629
- /**
32630
- * Converts the visualization to a different registered type
32631
- * @since 1.1.0
32632
- * @param {string} newType - Which registered type to convert to.
32633
- * @param {boolean=} forceUpdate - Whether to run setProperties or not, defaults to true.
32634
- * @returns {Promise<object>} Promise object that resolves to the full property tree of the converted visualization.
32635
- * @example
32636
- * const viz = await embed(app).render({
32637
- * element,
32638
- * id: 'abc'
32639
- * });
32640
- * viz.convertTo('barChart');
32641
- */
32642
- async convertTo(newType) {
32643
- let forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
32644
- const propertyTree = await convertTo({
32645
- halo,
32646
- model,
32647
- cellRef,
32648
- newType
32649
- });
32650
- if (forceUpdate) {
32651
- if (model.__snInterceptor) {
32652
- await model.__snInterceptor.setProperties.call(model, propertyTree.qProperty);
32653
- } else {
32654
- await model.setProperties(propertyTree.qProperty);
32655
- }
32656
- }
32657
- return propertyTree;
32658
- },
32659
- /**
32660
- * Listens to custom events from inside the visualization. See useEmitter
32661
- * @experimental
32662
- * @param {string} eventName Event name to listen to
32663
- * @param {Function} listener Callback function to invoke
32664
- */
32665
- addListener(eventName, listener) {
32666
- emitter.addListener(eventName, listener);
32667
- },
32668
- /**
32669
- * Removes a listener
32670
- * @experimental
32671
- * @param {string} eventName Event name to remove from
32672
- * @param {Function} listener Callback function to remove
32673
- */
32674
- removeListener(eventName, listener) {
32675
- emitter.removeListener(eventName, listener);
32676
- },
32677
- /**
32678
- * Gets the specific api that a Viz exposes.
32679
- * @returns {Promise<object>} object that contains the internal Viz api.
32680
- */
32681
- async getImperativeHandle() {
32682
- await rendered;
32683
- return cellRef.current.getImperativeHandle();
32684
- },
32685
- // ===== unexposed experimental API - use at own risk ======
32686
- __DO_NOT_USE__: {
32687
- mount(element) {
32688
- if (mountedReference) {
32689
- throw new Error('Already mounted');
32690
- }
32691
- mountedReference = element;
32692
- [unmountCell, cellRef] = glue$1({
32693
- halo,
32694
- element,
32695
- model,
32696
- initialSnOptions,
32697
- initialSnPlugins,
32698
- initialError,
32699
- onMount,
32700
- emitter
32701
- });
32702
- return mounted;
32703
- },
32704
- async applyProperties(props) {
32705
- const current = await model.getEffectiveProperties();
32706
- const patches = getPatches('/', props, current);
32707
- if (patches.length) {
32708
- return model.applyPatches(patches, true);
32709
- }
32710
- return undefined;
32711
- },
32712
- options(opts) {
32713
- setSnOptions(opts);
32714
- },
32715
- plugins(plugins) {
32716
- setSnPlugins(plugins);
32717
- },
32718
- exportImage() {
32719
- return cellRef.current.exportImage();
32720
- },
32721
- takeSnapshot() {
32722
- return cellRef.current.takeSnapshot();
32723
- },
32724
- getModel() {
32725
- return model;
32726
- }
32727
- }
32728
-
32729
- // old QVisualization API
32730
- // close() {},
32731
- // exportData() {},
32732
- // exportImg() {},
32733
- // exportPdf() {},
32734
- // setOptions() {}, // applied soft patch
32735
- // resize() {},
32736
- // show() {},
32737
- // toggleDataView() {},
32738
- };
32739
-
32740
- return api;
32741
- }
32742
-
32743
- /* eslint no-underscore-dangle:0 */
32744
- async function init(model, optional, halo, initialError) {
32745
- let onDestroy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : async () => {};
32746
- const api = viz({
32747
- model,
32748
- halo,
32749
- initialError,
32750
- onDestroy
32751
- });
32752
- if (optional.options) {
32753
- api.__DO_NOT_USE__.options(optional.options);
32754
- }
32755
- if (optional.plugins) {
32756
- api.__DO_NOT_USE__.plugins(optional.plugins);
32757
- }
32758
- if (optional.element) {
32759
- await api.__DO_NOT_USE__.mount(optional.element);
32760
- }
32761
- return api;
32762
- }
32763
-
32764
- /**
32765
- * @typedef {string | EngineAPI.INxDimension | EngineAPI.INxMeasure | LibraryField} Field
32766
- */
32767
-
32768
- /**
32769
- * @interface RenderConfig
32770
- * @description Configuration for rendering a visualisation, either creating or fetching an existing object.
32771
- * @property {HTMLElement} element Target html element to render in to
32772
- * @property {object=} options Options passed into the visualisation
32773
- * @property {Plugin[]} [plugins] plugins passed into the visualisation
32774
- * @property {string=} id For existing objects: Engine identifier of object to render
32775
- * @property {string=} type For creating objects: Type of visualisation to render
32776
- * @property {string=} version For creating objects: Version of visualization to render
32777
- * @property {(Field[])=} fields For creating objects: Data fields to use
32778
- * @property {boolean=} [extendProperties=false] For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
32779
- * @property {EngineAPI.IGenericObjectProperties=} properties For creating objects: Explicit properties to set
32780
- * @example
32781
- * // A config for Creating objects:
32782
- * const createConfig = {
32783
- * type: 'bar',
32784
- * element: document.querySelector('.bar'),
32785
- * extendProperties: true,
32786
- * fields: ['[Country names]', '=Sum(Sales)'],
32787
- * properties: {
32788
- * legend: {
32789
- * show: false,
32790
- * },
32791
- * }
32792
- * };
32793
- * nebbie.render(createConfig);
32794
- * // A config for rendering an existing object:
32795
- * const createConfig = {
32796
- * id: 'jG5LP',
32797
- * element: document.querySelector('.line'),
32798
- * };
32799
- * nebbie.render(createConfig);
32800
- */
32801
- async function createSessionObject(_ref, halo) {
32802
- let {
32803
- type,
32804
- version,
32805
- fields,
32806
- properties,
32807
- options,
32808
- plugins,
32809
- element,
32810
- extendProperties
32811
- } = _ref;
32812
- let mergedProps = {};
32813
- const children = [];
32814
- let error;
32815
- try {
32816
- const t = halo.types.get({
32817
- name: type,
32818
- version
32819
- });
32820
- mergedProps = await t.initialProperties(properties, extendProperties);
32821
- const sn = await t.supernova();
32822
- if (fields) {
32823
- await populateData({
32824
- sn,
32825
- properties: mergedProps,
32826
- fields,
32827
- children
32828
- }, halo);
32829
- }
32830
- if (properties && sn && sn.qae.properties.onChange) {
32831
- sn.qae.properties.onChange.call({}, mergedProps);
32832
- }
32833
- } catch (e) {
32834
- error = e;
32835
- // minimal dummy object properties to allow it to be created
32836
- // and rendered with the error
32837
- mergedProps = {
32838
- qInfo: {
32839
- qType: type
32840
- },
32841
- visualization: type
32842
- };
32843
- // console.error(e); // eslint-disable-line
32844
- }
32845
-
32846
- const model = await halo.app.createSessionObject(mergedProps);
32847
- if (children.length > 0) {
32848
- await model.setFullPropertyTree({
32849
- qProperty: mergedProps,
32850
- qChildren: children
32851
- });
32852
- }
32853
- modelStore.set(model.id, model);
32854
- const unsubscribe = subscribe(model);
32855
- const onDestroy = async () => {
32856
- await halo.app.destroySessionObject(model.id);
32857
- unsubscribe();
32858
- };
32859
- return init(model, {
32860
- options,
32861
- plugins,
32862
- element
32863
- }, halo, error, onDestroy);
32864
- }
32865
-
32866
- /**
32867
- * @typedef {string | EngineAPI.INxDimension | EngineAPI.INxMeasure | LibraryField} Field
32868
- */
32869
-
32870
- /**
32871
- * @interface CreateConfig
32872
- * @description Rendering configuration for creating and rendering a new object
32873
- * @property {string} type
32874
- * @property {string=} version
32875
- * @property {(Field[])=} fields
32876
- * @property {EngineAPI.IGenericObjectProperties=} properties
32877
- */
32878
-
32879
- async function createObject(_ref, halo, generateOnly) {
32880
- let {
32881
- type,
32882
- version,
32883
- fields,
32884
- properties,
32885
- extendProperties /* , options, plugins, element */
32886
- } = _ref;
32887
- let mergedProps = {};
32888
- const children = [];
32889
- // let error;
32890
- try {
32891
- const t = halo.types.get({
32892
- name: type,
32893
- version
32894
- });
32895
- mergedProps = await t.initialProperties(properties, extendProperties);
32896
- const sn = await t.supernova();
32897
- if (fields) {
32898
- await populateData({
32899
- sn,
32900
- properties: mergedProps,
32901
- fields,
32902
- children
32903
- }, halo);
32904
- }
32905
- if (properties && sn && sn.qae.properties.onChange) {
32906
- sn.qae.properties.onChange.call({}, mergedProps);
32907
- }
32908
- } catch (e) {
32909
- // error = e;
32910
- // minimal dummy object properties to allow it to be created
32911
- // and rendered with the error
32912
- if (!generateOnly) {
32913
- mergedProps = {
32914
- qInfo: {
32915
- qType: type
32916
- },
32917
- visualization: type
32918
- };
32919
- } else {
32920
- mergedProps = null;
32921
- }
32922
- // console.error(e); // eslint-disable-line
32923
- }
32924
-
32925
- if (!generateOnly) {
32926
- const model = await halo.app.createObject(mergedProps);
32927
- if (children.length > 0) {
32928
- await model.setFullPropertyTree({
32929
- qProperty: mergedProps,
32930
- qChildren: children
32931
- });
32932
- }
32933
- modelStore.set(model.id, model);
32934
- return model;
32935
- }
32936
- return mergedProps;
32937
- }
32938
-
32939
- async function getObject$1(_ref, halo) {
32940
- let {
32941
- id,
32942
- options,
32943
- plugins,
32944
- element
32945
- } = _ref;
32946
- const key = "".concat(id);
32947
- let rpc = rpcRequestModelStore.get(key);
32948
- if (!rpc) {
32949
- rpc = halo.app.getObject(id);
32950
- rpcRequestModelStore.set(key, rpc);
32951
- }
32952
- const model = await rpc;
32953
- modelStore.set(key, model);
32954
- return init(model, {
32955
- options,
32956
- plugins,
32957
- element
32958
- }, halo);
32959
- }
32960
-
32961
- /**
32962
- * @interface
32963
- * @extends HTMLElement
32964
- * @experimental
32965
- * @since 3.1.0
32966
- */
32967
- const SheetElement = {
32968
- /** @type {'njs-sheet'} */
32969
- className: 'njs-sheet'
32547
+ const canSetProperties = layout => {
32548
+ var _layout$qMeta;
32549
+ return !!(layout && !layout.qHasSoftPatches && !layout.qExtendsId && (((_layout$qMeta = layout.qMeta) === null || _layout$qMeta === void 0 ? void 0 : _layout$qMeta.privileges) || []).indexOf('update') > -1);
32970
32550
  };
32971
- function getCellRenderer(cell, halo, initialSnOptions, initialSnPlugins, initialError, onMount) {
32972
- const {
32973
- x,
32974
- y,
32975
- width,
32976
- height
32977
- } = cell.bounds;
32978
- return /*#__PURE__*/React.createElement("div", {
32979
- style: {
32980
- left: "".concat(x, "%"),
32981
- top: "".concat(y, "%"),
32982
- width: "".concat(width, "%"),
32983
- height: "".concat(height, "%"),
32984
- position: 'absolute'
32985
- }
32986
- }, /*#__PURE__*/React.createElement(Cell, {
32987
- ref: cell.cellRef,
32988
- halo: halo,
32989
- model: cell.model,
32990
- currentId: cell.currentId,
32991
- initialSnOptions: initialSnOptions,
32992
- initialSnPlugins: initialSnPlugins,
32993
- initialError: initialError,
32994
- onMount: onMount
32995
- }));
32996
- }
32997
- function Sheet(_ref) {
32998
- let {
32999
- model,
33000
- halo,
33001
- initialSnOptions,
33002
- initialSnPlugins,
33003
- initialError,
33004
- onMount
33005
- } = _ref;
33006
- const {
33007
- root
33008
- } = halo;
33009
- const [layout] = useLayout$1(model);
33010
- const {
33011
- theme: themeName
33012
- } = reactExports.useContext(InstanceContext);
33013
- const [cells, setCells] = reactExports.useState([]);
33014
- const [bgColor, setBgColor] = reactExports.useState(undefined);
33015
- const [bgImage, setBgImage] = reactExports.useState(undefined);
33016
- const [deepHash, setDeepHash] = reactExports.useState('');
33017
32551
 
33018
- /// For each object
33019
- reactExports.useEffect(() => {
33020
- if (layout) {
33021
- const hash = JSON.stringify(layout.cells);
33022
- if (hash === deepHash) {
33023
- return;
33024
- }
33025
- setDeepHash(hash);
33026
- const fetchObjects = async () => {
33027
- /*
33028
- Need to always fetch and evaluate everything as the sheet need to support multiple instances of the same object?
33029
- No, there is no way to add the same chart twice, so the optimization should be worth it.
33030
- */
33031
-
33032
- // Clear the cell list
33033
- cells.forEach(c => {
33034
- root.removeCell(c.currentId);
33035
- });
33036
- const lCells = layout.cells;
33037
- // TODO - should try reuse existing objects on subsequent renders
33038
- // Non-id updates should only change the "css"
33039
- const cs = await Promise.all(lCells.map(async c => {
33040
- let mounted;
33041
- const mountedPromise = new Promise(resolve => {
33042
- mounted = resolve;
33043
- });
33044
- const cell = cells.find(ce => ce.id === c.name);
33045
- if (cell) {
33046
- cell.bounds = c.bounds;
33047
- delete cell.mountedPromise;
33048
- return cell;
33049
- }
33050
- const vs = await getObject$1({
33051
- id: c.name
33052
- }, halo);
33053
- return {
33054
- model: vs.model,
33055
- id: c.name,
33056
- bounds: c.bounds,
33057
- cellRef: React.createRef(),
33058
- currentId: uid(),
33059
- mounted,
33060
- mountedPromise
33061
- };
33062
- }));
33063
- cs.forEach(c => root.addCell(c.currentId, c.cellRef));
33064
- setCells(cs);
33065
- };
33066
- fetchObjects();
33067
- }
33068
- }, [layout]);
33069
- const cellRenderers = reactExports.useMemo(() => cells ? cells.map(c => getCellRenderer(c, halo, initialSnOptions, initialSnPlugins, initialError, c.mounted)) : [], [cells]);
33070
- reactExports.useEffect(() => {
33071
- const bgComp = layout !== null && layout !== void 0 && layout.components ? layout.components.find(comp => comp.key === 'general') : null;
33072
- setBgColor(resolveBgColor(bgComp, halo.public.theme));
33073
- setBgImage(resolveBgImage(bgComp, halo.app));
33074
- }, [layout, halo.public.theme, halo.app, themeName]);
33075
-
33076
- /* TODO
33077
- - sheet title + bg + logo etc + as option
33078
- - sheet exposed classnames for theming
33079
- */
33080
-
33081
- const height = !layout || Number.isNaN(layout.height) ? '100%' : "".concat(Number(layout.height), "%");
33082
- const promises = cells.map(c => c.mountedPromise);
33083
- const ps = promises.filter(p => !!p);
33084
- if (ps.length) {
33085
- Promise.all(promises).then(() => {
33086
- // TODO - correct? Currently called each time a new cell is mounted?
33087
- onMount();
33088
- });
33089
- }
33090
- return /*#__PURE__*/React.createElement("div", {
33091
- className: SheetElement.className,
33092
- style: {
33093
- width: "100%",
33094
- height,
33095
- position: 'relative',
33096
- backgroundColor: bgColor,
33097
- backgroundImage: bgImage && bgImage.url ? "url(".concat(bgImage.url, ")") : undefined,
33098
- backgroundRepeat: 'no-repeat',
33099
- backgroundSize: bgImage && bgImage.size,
33100
- backgroundPosition: bgImage && bgImage.pos
33101
- }
33102
- }, cellRenderers);
33103
- }
33104
-
33105
- function glue(_ref) {
33106
- let {
33107
- halo,
33108
- element,
33109
- model,
33110
- initialSnOptions,
33111
- initialSnPlugins,
33112
- onMount,
33113
- initialError
33114
- } = _ref;
33115
- const {
33116
- root
33117
- } = halo;
33118
- const sheetRef = React.createRef();
33119
- const portal = ReactDOM.createPortal( /*#__PURE__*/React.createElement(Sheet, {
33120
- ref: sheetRef,
33121
- halo: halo,
33122
- model: model,
33123
- initialSnOptions: initialSnOptions,
33124
- initialSnPlugins: initialSnPlugins,
33125
- initialError: initialError,
33126
- onMount: onMount
33127
- }), element, model.id);
33128
- const unmount = () => {
33129
- root.remove(portal);
33130
- model.removeListener('closed', unmount);
33131
- };
33132
- model.on('closed', unmount);
33133
- root.add(portal);
33134
- return [unmount, sheetRef];
33135
- }
33136
-
33137
- const noopi = () => {};
33138
- function sheet() {
33139
- let {
33140
- model,
33141
- halo,
33142
- initialError,
33143
- onDestroy = async () => {}
33144
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33145
- let unmountSheet = noopi;
33146
- let sheetRef = null;
33147
- let mountedReference = null;
33148
- let onMount = null;
33149
- const mounted = new Promise(resolve => {
33150
- onMount = resolve;
33151
- });
33152
- let initialSnOptions = {};
33153
- let initialSnPlugins = [];
33154
- const setSnOptions = async opts => {
33155
- if (mountedReference) {
33156
- (async () => {
33157
- await mounted;
33158
- sheetRef.current.setSnOptions(_objectSpread2(_objectSpread2({}, initialSnOptions), opts));
33159
- })();
33160
- } else {
33161
- // Handle setting options before mount
33162
- initialSnOptions = _objectSpread2(_objectSpread2({}, initialSnOptions), opts);
33163
- }
33164
- };
33165
- const setSnPlugins = async plugins => {
33166
- validatePlugins(plugins);
33167
- if (mountedReference) {
33168
- (async () => {
33169
- await mounted;
33170
- sheetRef.current.setSnPlugins(plugins);
33171
- })();
33172
- } else {
33173
- // Handle setting plugins before mount
33174
- initialSnPlugins = plugins;
33175
- }
33176
- };
33177
-
33178
- /**
33179
- * @class
33180
- * @alias Sheet
33181
- * @classdesc A controller to further modify a visualization after it has been rendered.
33182
- * @experimental
33183
- * @since 3.1.0
33184
- * @example
33185
- * const sheet = await embed(app).render({
33186
- * element,
33187
- * id: "jD5Gd"
33188
- * });
33189
- * sheet.destroy();
33190
- */
33191
- const api = /** @lends Sheet# */{
33192
- /**
33193
- * The id of this sheets's generic object.
33194
- * @type {string}
33195
- */
33196
- id: model.id,
33197
- /**
33198
- * This sheets Enigma model, a representation of the generic object.
33199
- * @type {string}
33200
- */
33201
- model,
33202
- /**
33203
- * Destroys the sheet and removes it from the the DOM.
33204
- * @example
33205
- * const sheet = await embed(app).render({
33206
- * element,
33207
- * id: "jD5Gd"
33208
- * });
33209
- * sheet.destroy();
33210
- */
33211
- async destroy() {
33212
- await onDestroy();
33213
- unmountSheet();
33214
- unmountSheet = noopi;
33215
- },
33216
- // ===== unexposed experimental API - use at own risk ======
33217
- __DO_NOT_USE__: {
33218
- mount(element) {
33219
- if (mountedReference) {
33220
- throw new Error('Already mounted');
33221
- }
33222
- mountedReference = element;
33223
- [unmountSheet, sheetRef] = glue({
33224
- halo,
33225
- element,
33226
- model,
33227
- initialSnOptions,
33228
- initialSnPlugins,
33229
- initialError,
33230
- onMount
33231
- });
33232
- return mounted;
33233
- },
33234
- async applyProperties(props) {
33235
- const current = await model.getEffectiveProperties();
33236
- const patches = getPatches('/', props, current);
33237
- if (patches.length) {
33238
- return model.applyPatches(patches, true);
33239
- }
33240
- return undefined;
33241
- },
33242
- options(opts) {
33243
- setSnOptions(opts);
33244
- },
33245
- plugins(plugins) {
33246
- setSnPlugins(plugins);
33247
- },
33248
- exportImage() {
33249
- throw new Error('Not implemented');
33250
- },
33251
- takeSnapshot() {
33252
- throw new Error('Not implemented');
33253
- },
33254
- getModel() {
33255
- return model;
33256
- }
33257
- }
33258
- };
33259
- return api;
33260
- }
33261
-
33262
- /* eslint no-underscore-dangle:0 */
33263
- async function initSheet(model, optional, halo, initialError) {
33264
- let onDestroy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : async () => {};
33265
- const api = sheet({
33266
- model,
33267
- halo,
33268
- initialError,
33269
- onDestroy
33270
- });
33271
- if (optional.options) {
33272
- api.__DO_NOT_USE__.options(optional.options);
33273
- }
33274
- if (optional.plugins) {
33275
- api.__DO_NOT_USE__.plugins(optional.plugins);
33276
- }
33277
- if (optional.element) {
33278
- await api.__DO_NOT_USE__.mount(optional.element);
33279
- }
33280
- return api;
33281
- }
33282
-
33283
- async function getObject(_ref, halo) {
33284
- let {
33285
- id,
33286
- options,
33287
- plugins,
33288
- element
33289
- } = _ref;
33290
- const key = "".concat(id);
33291
- let rpc = rpcRequestModelStore.get(key);
33292
- if (!rpc) {
33293
- rpc = halo.app.getObject(id);
33294
- rpcRequestModelStore.set(key, rpc);
33295
- }
33296
- const model = await rpc;
33297
- modelStore.set(key, model);
33298
- if (model.genericType === 'sheet') {
33299
- return initSheet(model, {
33300
- options,
33301
- plugins,
33302
- element
33303
- }, halo);
32552
+ /* eslint-disable no-underscore-dangle */
32553
+ const setProperties = (model, newProperties) => {
32554
+ if (model.__snInterceptor) {
32555
+ return model.__snInterceptor.setProperties.call(model, newProperties);
33304
32556
  }
33305
- return init(model, {
33306
- options,
33307
- plugins,
33308
- element
33309
- }, halo);
33310
- }
33311
-
33312
- function flagsFn () {
33313
- let flags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33314
- /**
33315
- * @interface Flags
33316
- */
33317
-
33318
- return (/** @lends Flags */{
33319
- /**
33320
- * Checks whether the specified flag is enabled.
33321
- * @param {string} flag - The value flag to check.
33322
- * @returns {boolean} True if the specified flag is enabled, false otherwise.
33323
- */
33324
- isEnabled: f => flags[f] === true
33325
- }
33326
- );
33327
- }
32557
+ return model.setProperties(newProperties);
32558
+ };
33328
32559
 
33329
32560
  /* eslint no-param-reassign: 0, no-restricted-globals: 0 */
33330
32561
  const extend = extend$2.bind(null, true);
@@ -35408,130 +34639,1030 @@
35408
34639
  if (steps[i] === '') {
35409
34640
  continue; // eslint-disable-line no-continue
35410
34641
  }
35411
-
35412
- if (typeof dataContainer[steps[i]] === 'undefined') {
35413
- return defaultValue;
34642
+
34643
+ if (typeof dataContainer[steps[i]] === 'undefined') {
34644
+ return defaultValue;
34645
+ }
34646
+ dataContainer = dataContainer[steps[i]];
34647
+ }
34648
+ return dataContainer;
34649
+ };
34650
+ function target(def) {
34651
+ const propertyPath = def.path || '/qHyperCubeDef';
34652
+ const layoutPath = propertyPath.slice(0, -3);
34653
+ if (/\/(qHyperCube|qListObject|qChildList)$/.test(layoutPath) === false) {
34654
+ const d = layoutPath.includes('/qHyperCube') ? 'qHyperCubeDef' : 'qListObjectDef';
34655
+ throw new Error("Incorrect definition for ".concat(d, " at ").concat(propertyPath, ". Valid paths include /qHyperCubeDef, /qListObjectDef, or /qChildListDef, e.g. data/qHyperCubeDef"));
34656
+ }
34657
+ return {
34658
+ propertyPath,
34659
+ layoutPath,
34660
+ resolveLayout: layout => resolveValue(layout, layoutPath, {}),
34661
+ dimensions: defFn(def.dimensions),
34662
+ measures: defFn(def.measures)
34663
+ };
34664
+ }
34665
+ function qae() {
34666
+ let def = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34667
+ let initial = def.properties || {};
34668
+ let onChange;
34669
+ if (def.properties && (def.properties.initial || def.properties.onChange)) {
34670
+ initial = def.properties.initial;
34671
+ onChange = def.properties.onChange;
34672
+ }
34673
+ const q = {
34674
+ properties: {
34675
+ initial,
34676
+ onChange
34677
+ },
34678
+ data: {
34679
+ targets: ((def.data || {}).targets || []).map(target)
34680
+ },
34681
+ exportProperties: def.exportProperties,
34682
+ importProperties: def.importProperties
34683
+ };
34684
+ return q;
34685
+ }
34686
+
34687
+ /**
34688
+ * The entry point for defining a visualization.
34689
+ * @interface Visualization
34690
+ * @param {Galaxy} galaxy
34691
+ * @returns {VisualizationDefinition}
34692
+ * @example
34693
+ * import { useElement, useLayout } from '@nebula.js/stardust';
34694
+ *
34695
+ * export default function() {
34696
+ * return {
34697
+ * qae: {
34698
+ * properties: {
34699
+ * dude: 'Heisenberg',
34700
+ * }
34701
+ * },
34702
+ * component() {
34703
+ * const el = useElement();
34704
+ * const layout = useLayout();
34705
+ * el.innerHTML = `What's my name? ${layout.dude}!!!`;
34706
+ * }
34707
+ * };
34708
+ * }
34709
+ */
34710
+
34711
+ /**
34712
+ * @interface VisualizationDefinition
34713
+ * @property {QAEDefinition} qae
34714
+ * @property {function():void} component
34715
+ */
34716
+
34717
+ /**
34718
+ * @interface snGenerator
34719
+ * @param {Visualization} Sn
34720
+ * @param {Galaxy} galaxy
34721
+ * @returns {generator}
34722
+ * @private
34723
+ */
34724
+ function generatorFn(UserSN, galaxy) {
34725
+ let sn;
34726
+
34727
+ // TODO validate galaxy API
34728
+
34729
+ if (typeof UserSN === 'function') {
34730
+ sn = UserSN(galaxy);
34731
+ } else {
34732
+ sn = UserSN;
34733
+ }
34734
+
34735
+ /**
34736
+ * @alias generator
34737
+ * @private
34738
+ */
34739
+ const generator = /** @lends generator */{
34740
+ /**
34741
+ * @type {QAE}
34742
+ */
34743
+ qae: qae(sn.qae),
34744
+ /**
34745
+ * @type {SnComponent}
34746
+ */
34747
+ component: sn.component || {},
34748
+ /**
34749
+ * @param {object} p
34750
+ * @param {EnigmaAppModel} p.app
34751
+ * @param {EnigmaObjectModel} p.model
34752
+ * @param {ObjectSelections} p.selections
34753
+ */
34754
+ create(params) {
34755
+ const ss = create$2(generator, params, galaxy);
34756
+ return ss;
34757
+ },
34758
+ definition: {}
34759
+ };
34760
+ Object.keys(sn).forEach(key => {
34761
+ if (!generator[key]) {
34762
+ generator.definition[key] = sn[key];
34763
+ }
34764
+ });
34765
+ return generator;
34766
+ }
34767
+
34768
+ /* eslint-disable no-underscore-dangle */
34769
+ const saveSoftProperties = (model, prevEffectiveProperties, effectiveProperties) => {
34770
+ if (!model) {
34771
+ return Promise.resolve();
34772
+ }
34773
+ let patches = JSONPatch.generate(prevEffectiveProperties, effectiveProperties);
34774
+ extend$2(true, prevEffectiveProperties, effectiveProperties);
34775
+ if (patches && patches.length) {
34776
+ patches = patches.map(p => ({
34777
+ qOp: p.op,
34778
+ qValue: JSON.stringify(p.value),
34779
+ qPath: p.path
34780
+ }));
34781
+ if (model.__snInterceptor) {
34782
+ return model.__snInterceptor.applyPatches.call(model, patches, true);
34783
+ }
34784
+ return model.applyPatches(patches, true);
34785
+ }
34786
+ return Promise.resolve();
34787
+ };
34788
+
34789
+ const noopi$1 = () => {};
34790
+ function viz() {
34791
+ let {
34792
+ model,
34793
+ halo,
34794
+ initialError,
34795
+ onDestroy = async () => {}
34796
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34797
+ let unmountCell = noopi$1;
34798
+ let cellRef = null;
34799
+ let mountedReference = null;
34800
+ let onMount = null;
34801
+ let onRender = null;
34802
+ const mounted = new Promise(resolve => {
34803
+ onMount = resolve;
34804
+ });
34805
+ const rendered = new Promise(resolve => {
34806
+ onRender = resolve;
34807
+ });
34808
+ const createOnInitialRender = override => () => {
34809
+ override && override();
34810
+ onRender();
34811
+ };
34812
+ let initialSnOptions = {};
34813
+ let initialSnPlugins = [];
34814
+ const emitter = new EventEmitter$1();
34815
+ const setSnOptions = async opts => {
34816
+ const override = opts.onInitialRender;
34817
+ if (mountedReference) {
34818
+ (async () => {
34819
+ await mounted;
34820
+ cellRef.current.setSnOptions(_objectSpread2(_objectSpread2(_objectSpread2({}, initialSnOptions), opts), {
34821
+ onInitialRender: createOnInitialRender(override)
34822
+ }));
34823
+ })();
34824
+ } else {
34825
+ // Handle setting options before mount
34826
+ initialSnOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, initialSnOptions), opts), {
34827
+ onInitialRender: createOnInitialRender(override)
34828
+ });
34829
+ }
34830
+ };
34831
+ const setSnPlugins = async plugins => {
34832
+ validatePlugins(plugins);
34833
+ if (mountedReference) {
34834
+ (async () => {
34835
+ await mounted;
34836
+ cellRef.current.setSnPlugins(plugins);
34837
+ })();
34838
+ } else {
34839
+ // Handle setting plugins before mount
34840
+ initialSnPlugins = plugins;
34841
+ }
34842
+ };
34843
+
34844
+ /**
34845
+ * @class
34846
+ * @alias Viz
34847
+ * @classdesc A controller to further modify a visualization after it has been rendered.
34848
+ * @example
34849
+ * const viz = await embed(app).render({
34850
+ * element,
34851
+ * type: 'barchart'
34852
+ * });
34853
+ * viz.destroy();
34854
+ */
34855
+ const api = /** @lends Viz# */{
34856
+ /**
34857
+ * The id of this visualization's generic object.
34858
+ * @type {string}
34859
+ */
34860
+ id: model.id,
34861
+ /**
34862
+ * This visualizations Enigma model, a representation of the generic object.
34863
+ * @type {EngineAPI.IGenericObject}
34864
+ */
34865
+ model,
34866
+ /**
34867
+ * Destroys the visualization and removes it from the the DOM.
34868
+ * @example
34869
+ * const viz = await embed(app).render({
34870
+ * element,
34871
+ * id: 'abc'
34872
+ * });
34873
+ * viz.destroy();
34874
+ */
34875
+ async destroy() {
34876
+ await onDestroy();
34877
+ unmountCell();
34878
+ unmountCell = noopi$1;
34879
+ },
34880
+ /**
34881
+ * Converts the visualization to a different registered type.
34882
+ *
34883
+ * Will update properties if permissions allow, else will patch (can be forced with forcePatch parameter)
34884
+ *
34885
+ * Not all chart types are compatible, similar structures are required.
34886
+ *
34887
+ * @since 1.1.0
34888
+ * @param {string} newType - Which registered type to convert to.
34889
+ * @param {boolean=} forceUpdate - Whether to apply the change or not, else simply returns the resulting properties, defaults to true.
34890
+ * @param {boolean=} forcePatch - Whether to always patch the change instead of making a permanent change
34891
+ * @throws {Error} Throws an error if the source or target chart does not support conversion
34892
+ * @returns {Promise<object>} Promise object that resolves to the full property tree of the converted visualization.
34893
+ * @example
34894
+ * const viz = await embed(app).render({
34895
+ * element,
34896
+ * id: 'abc'
34897
+ * });
34898
+ * await viz.convertTo('barChart');
34899
+ * // Change the barchart to a linechart, only in the current session
34900
+ * const newProperties = await viz.convertTo('lineChart', false, true);
34901
+ * // Remove the conversion by clearing the patches
34902
+ * await viz.model.clearSoftPatches();
34903
+ */
34904
+ async convertTo(newType) {
34905
+ let forceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
34906
+ let forcePatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
34907
+ if (forceUpdate) {
34908
+ const layout = await model.getLayout();
34909
+ if (canSetProperties(layout) && !forcePatch) {
34910
+ const propertyTree = await convertTo({
34911
+ halo,
34912
+ model,
34913
+ cellRef,
34914
+ newType
34915
+ });
34916
+ await setProperties(model, propertyTree.qProperty);
34917
+ return propertyTree;
34918
+ }
34919
+ const oldProperties = await model.getEffectiveProperties();
34920
+ const propertyTree = await convertTo({
34921
+ halo,
34922
+ model,
34923
+ cellRef,
34924
+ newType,
34925
+ properties: oldProperties
34926
+ });
34927
+ const newProperties = propertyTree.qProperty;
34928
+ await saveSoftProperties(model, oldProperties, newProperties);
34929
+ return propertyTree;
34930
+ }
34931
+ const propertyTree = await convertTo({
34932
+ halo,
34933
+ model,
34934
+ cellRef,
34935
+ newType
34936
+ });
34937
+ return propertyTree;
34938
+ },
34939
+ /**
34940
+ * Listens to custom events from inside the visualization. See useEmitter
34941
+ * @experimental
34942
+ * @param {string} eventName Event name to listen to
34943
+ * @param {Function} listener Callback function to invoke
34944
+ */
34945
+ addListener(eventName, listener) {
34946
+ emitter.addListener(eventName, listener);
34947
+ },
34948
+ /**
34949
+ * Removes a listener
34950
+ * @experimental
34951
+ * @param {string} eventName Event name to remove from
34952
+ * @param {Function} listener Callback function to remove
34953
+ */
34954
+ removeListener(eventName, listener) {
34955
+ emitter.removeListener(eventName, listener);
34956
+ },
34957
+ /**
34958
+ * Gets the specific api that a Viz exposes.
34959
+ * @returns {Promise<object>} object that contains the internal Viz api.
34960
+ */
34961
+ async getImperativeHandle() {
34962
+ await rendered;
34963
+ return cellRef.current.getImperativeHandle();
34964
+ },
34965
+ // ===== unexposed experimental API - use at own risk ======
34966
+ __DO_NOT_USE__: {
34967
+ mount(element) {
34968
+ if (mountedReference) {
34969
+ throw new Error('Already mounted');
34970
+ }
34971
+ if (!(element instanceof HTMLElement)) {
34972
+ throw new Error('Provided element is not a proper HTMLElement');
34973
+ }
34974
+ mountedReference = element;
34975
+ [unmountCell, cellRef] = glue$1({
34976
+ halo,
34977
+ element,
34978
+ model,
34979
+ initialSnOptions,
34980
+ initialSnPlugins,
34981
+ initialError,
34982
+ onMount,
34983
+ emitter
34984
+ });
34985
+ return mounted;
34986
+ },
34987
+ async applyProperties(props) {
34988
+ const current = await model.getEffectiveProperties();
34989
+ const patches = getPatches('/', props, current);
34990
+ if (patches.length) {
34991
+ return model.applyPatches(patches, true);
34992
+ }
34993
+ return undefined;
34994
+ },
34995
+ options(opts) {
34996
+ setSnOptions(opts);
34997
+ },
34998
+ plugins(plugins) {
34999
+ setSnPlugins(plugins);
35000
+ },
35001
+ exportImage() {
35002
+ return cellRef.current.exportImage();
35003
+ },
35004
+ takeSnapshot() {
35005
+ return cellRef.current.takeSnapshot();
35006
+ },
35007
+ getModel() {
35008
+ return model;
35009
+ },
35010
+ /**
35011
+ * Contains functionality related to conversions between types in the current session
35012
+ * @memberof Viz#
35013
+ * @ignore
35014
+ * @since 4.5.0
35015
+ */
35016
+ convert: {
35017
+ /**
35018
+ * Converts the visualization to a different registered type using a patch. Only persists in session
35019
+ * @since 4.5.0
35020
+ * @ignore
35021
+ * @memberof Viz.convert
35022
+ * @param {string} newType - Which registered type to convert to.
35023
+ * @throws {Error} Throws an error if the source or target chart does not support conversion
35024
+ * @returns {Promise<object>} Promise object that resolves to the full property tree of the converted visualization.
35025
+ * @example
35026
+ * const viz = await embed(app).render({
35027
+ * element,
35028
+ * id: 'abc'
35029
+ * });
35030
+ * viz.convert.toType('barChart');
35031
+ */
35032
+ async toType(newType) {
35033
+ const oldProperties = await model.getEffectiveProperties();
35034
+ const propertyTree = await convertTo({
35035
+ halo,
35036
+ model,
35037
+ cellRef,
35038
+ newType,
35039
+ properties: oldProperties
35040
+ });
35041
+ const newProperties = propertyTree.qProperty;
35042
+ await saveSoftProperties(model, oldProperties, newProperties);
35043
+ return propertyTree;
35044
+ },
35045
+ /**
35046
+ * Reverts any conversion done on the visualization
35047
+ * @since 4.5.0
35048
+ * @ignore
35049
+ * @memberof Viz.convert
35050
+ * @returns {Promise<object>} Promise object that resolves when the conversion is undone, returns result.
35051
+ * @example
35052
+ * const viz = await embed(app).render({
35053
+ * element,
35054
+ * id: 'abc'
35055
+ * });
35056
+ * viz.convert.toType('barChart');
35057
+ * viz.convert.revert();
35058
+ */
35059
+ async revert() {
35060
+ await model.clearSoftPatches();
35061
+ }
35062
+ }
35063
+ }
35064
+
35065
+ // old QVisualization API
35066
+ // close() {},
35067
+ // exportData() {},
35068
+ // exportImg() {},
35069
+ // exportPdf() {},
35070
+ // setOptions() {}, // applied soft patch
35071
+ // resize() {},
35072
+ // show() {},
35073
+ // toggleDataView() {},
35074
+ };
35075
+
35076
+ return api;
35077
+ }
35078
+
35079
+ /* eslint no-underscore-dangle:0 */
35080
+ async function init(model, optional, halo, initialError) {
35081
+ let onDestroy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : async () => {};
35082
+ const api = viz({
35083
+ model,
35084
+ halo,
35085
+ initialError,
35086
+ onDestroy
35087
+ });
35088
+ if (optional.options) {
35089
+ api.__DO_NOT_USE__.options(optional.options);
35090
+ }
35091
+ if (optional.plugins) {
35092
+ api.__DO_NOT_USE__.plugins(optional.plugins);
35093
+ }
35094
+ if (optional.element) {
35095
+ await api.__DO_NOT_USE__.mount(optional.element);
35096
+ }
35097
+ return api;
35098
+ }
35099
+
35100
+ /**
35101
+ * @typedef {string | EngineAPI.INxDimension | EngineAPI.INxMeasure | LibraryField} Field
35102
+ */
35103
+
35104
+ /**
35105
+ * @interface RenderConfig
35106
+ * @description Configuration for rendering a visualisation, either creating or fetching an existing object.
35107
+ * @property {HTMLElement} element Target html element to render in to
35108
+ * @property {object=} options Options passed into the visualisation
35109
+ * @property {Plugin[]} [plugins] plugins passed into the visualisation
35110
+ * @property {string=} id For existing objects: Engine identifier of object to render
35111
+ * @property {string=} type For creating objects: Type of visualisation to render
35112
+ * @property {string=} version For creating objects: Version of visualization to render
35113
+ * @property {(Field[])=} fields For creating objects: Data fields to use
35114
+ * @property {boolean=} [extendProperties=false] For creating objects: Whether to deeply extend properties or not. If false then subtrees will be overwritten.
35115
+ * @property {EngineAPI.IGenericObjectProperties=} properties For creating objects: Explicit properties to set
35116
+ * @example
35117
+ * // A config for Creating objects:
35118
+ * const createConfig = {
35119
+ * type: 'bar',
35120
+ * element: document.querySelector('.bar'),
35121
+ * extendProperties: true,
35122
+ * fields: ['[Country names]', '=Sum(Sales)'],
35123
+ * properties: {
35124
+ * legend: {
35125
+ * show: false,
35126
+ * },
35127
+ * }
35128
+ * };
35129
+ * nebbie.render(createConfig);
35130
+ * // A config for rendering an existing object:
35131
+ * const createConfig = {
35132
+ * id: 'jG5LP',
35133
+ * element: document.querySelector('.line'),
35134
+ * };
35135
+ * nebbie.render(createConfig);
35136
+ */
35137
+ async function createSessionObject(_ref, halo) {
35138
+ let {
35139
+ type,
35140
+ version,
35141
+ fields,
35142
+ properties,
35143
+ options,
35144
+ plugins,
35145
+ element,
35146
+ extendProperties
35147
+ } = _ref;
35148
+ let mergedProps = {};
35149
+ const children = [];
35150
+ let error;
35151
+ try {
35152
+ const t = halo.types.get({
35153
+ name: type,
35154
+ version
35155
+ });
35156
+ mergedProps = await t.initialProperties(properties, extendProperties);
35157
+ const sn = await t.supernova();
35158
+ if (fields) {
35159
+ await populateData({
35160
+ sn,
35161
+ properties: mergedProps,
35162
+ fields,
35163
+ children
35164
+ }, halo);
35165
+ }
35166
+ if (properties && sn && sn.qae.properties.onChange) {
35167
+ sn.qae.properties.onChange.call({}, mergedProps);
35168
+ }
35169
+ } catch (e) {
35170
+ error = e;
35171
+ // minimal dummy object properties to allow it to be created
35172
+ // and rendered with the error
35173
+ mergedProps = {
35174
+ qInfo: {
35175
+ qType: type
35176
+ },
35177
+ visualization: type
35178
+ };
35179
+ // console.error(e); // eslint-disable-line
35180
+ }
35181
+
35182
+ const model = await halo.app.createSessionObject(mergedProps);
35183
+ if (children.length > 0) {
35184
+ await model.setFullPropertyTree({
35185
+ qProperty: mergedProps,
35186
+ qChildren: children
35187
+ });
35188
+ }
35189
+ modelStore.set(model.id, model);
35190
+ const unsubscribe = subscribe(model);
35191
+ const onDestroy = async () => {
35192
+ await halo.app.destroySessionObject(model.id);
35193
+ unsubscribe();
35194
+ };
35195
+ return init(model, {
35196
+ options,
35197
+ plugins,
35198
+ element
35199
+ }, halo, error, onDestroy);
35200
+ }
35201
+
35202
+ /**
35203
+ * @typedef {string | EngineAPI.INxDimension | EngineAPI.INxMeasure | LibraryField} Field
35204
+ */
35205
+
35206
+ /**
35207
+ * @interface CreateConfig
35208
+ * @description Rendering configuration for creating and rendering a new object
35209
+ * @property {string} type
35210
+ * @property {string=} version
35211
+ * @property {(Field[])=} fields
35212
+ * @property {EngineAPI.IGenericObjectProperties=} properties
35213
+ */
35214
+
35215
+ async function createObject(_ref, halo, generateOnly) {
35216
+ let {
35217
+ type,
35218
+ version,
35219
+ fields,
35220
+ properties,
35221
+ extendProperties /* , options, plugins, element */
35222
+ } = _ref;
35223
+ let mergedProps = {};
35224
+ const children = [];
35225
+ // let error;
35226
+ try {
35227
+ const t = halo.types.get({
35228
+ name: type,
35229
+ version
35230
+ });
35231
+ mergedProps = await t.initialProperties(properties, extendProperties);
35232
+ const sn = await t.supernova();
35233
+ if (fields) {
35234
+ await populateData({
35235
+ sn,
35236
+ properties: mergedProps,
35237
+ fields,
35238
+ children
35239
+ }, halo);
35240
+ }
35241
+ if (properties && sn && sn.qae.properties.onChange) {
35242
+ sn.qae.properties.onChange.call({}, mergedProps);
35414
35243
  }
35415
- dataContainer = dataContainer[steps[i]];
35244
+ } catch (e) {
35245
+ // error = e;
35246
+ // minimal dummy object properties to allow it to be created
35247
+ // and rendered with the error
35248
+ if (!generateOnly) {
35249
+ mergedProps = {
35250
+ qInfo: {
35251
+ qType: type
35252
+ },
35253
+ visualization: type
35254
+ };
35255
+ } else {
35256
+ mergedProps = null;
35257
+ }
35258
+ // console.error(e); // eslint-disable-line
35416
35259
  }
35417
- return dataContainer;
35418
- };
35419
- function target(def) {
35420
- const propertyPath = def.path || '/qHyperCubeDef';
35421
- const layoutPath = propertyPath.slice(0, -3);
35422
- if (/\/(qHyperCube|qListObject|qChildList)$/.test(layoutPath) === false) {
35423
- const d = layoutPath.includes('/qHyperCube') ? 'qHyperCubeDef' : 'qListObjectDef';
35424
- throw new Error("Incorrect definition for ".concat(d, " at ").concat(propertyPath, ". Valid paths include /qHyperCubeDef, /qListObjectDef, or /qChildListDef, e.g. data/qHyperCubeDef"));
35260
+
35261
+ if (!generateOnly) {
35262
+ const model = await halo.app.createObject(mergedProps);
35263
+ if (children.length > 0) {
35264
+ await model.setFullPropertyTree({
35265
+ qProperty: mergedProps,
35266
+ qChildren: children
35267
+ });
35268
+ }
35269
+ modelStore.set(model.id, model);
35270
+ return model;
35425
35271
  }
35426
- return {
35427
- propertyPath,
35428
- layoutPath,
35429
- resolveLayout: layout => resolveValue(layout, layoutPath, {}),
35430
- dimensions: defFn(def.dimensions),
35431
- measures: defFn(def.measures)
35432
- };
35272
+ return mergedProps;
35433
35273
  }
35434
- function qae() {
35435
- let def = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35436
- let initial = def.properties || {};
35437
- let onChange;
35438
- if (def.properties && (def.properties.initial || def.properties.onChange)) {
35439
- initial = def.properties.initial;
35440
- onChange = def.properties.onChange;
35274
+
35275
+ async function getObject$1(_ref, halo) {
35276
+ let {
35277
+ id,
35278
+ options,
35279
+ plugins,
35280
+ element
35281
+ } = _ref;
35282
+ const key = "".concat(id);
35283
+ let rpc = rpcRequestModelStore.get(key);
35284
+ if (!rpc) {
35285
+ rpc = halo.app.getObject(id);
35286
+ rpcRequestModelStore.set(key, rpc);
35441
35287
  }
35442
- const q = {
35443
- properties: {
35444
- initial,
35445
- onChange
35446
- },
35447
- data: {
35448
- targets: ((def.data || {}).targets || []).map(target)
35449
- },
35450
- exportProperties: def.exportProperties,
35451
- importProperties: def.importProperties
35452
- };
35453
- return q;
35288
+ const model = await rpc;
35289
+ modelStore.set(key, model);
35290
+ return init(model, {
35291
+ options,
35292
+ plugins,
35293
+ element
35294
+ }, halo);
35454
35295
  }
35455
35296
 
35456
35297
  /**
35457
- * The entry point for defining a visualization.
35458
- * @interface Visualization
35459
- * @param {Galaxy} galaxy
35460
- * @returns {VisualizationDefinition}
35461
- * @example
35462
- * import { useElement, useLayout } from '@nebula.js/stardust';
35463
- *
35464
- * export default function() {
35465
- * return {
35466
- * qae: {
35467
- * properties: {
35468
- * dude: 'Heisenberg',
35469
- * }
35470
- * },
35471
- * component() {
35472
- * const el = useElement();
35473
- * const layout = useLayout();
35474
- * el.innerHTML = `What's my name? ${layout.dude}!!!`;
35475
- * }
35476
- * };
35477
- * }
35298
+ * @interface
35299
+ * @extends HTMLElement
35300
+ * @experimental
35301
+ * @since 3.1.0
35478
35302
  */
35303
+ const SheetElement = {
35304
+ /** @type {'njs-sheet'} */
35305
+ className: 'njs-sheet'
35306
+ };
35307
+ function getCellRenderer(cell, halo, initialSnOptions, initialSnPlugins, initialError, onMount) {
35308
+ const {
35309
+ x,
35310
+ y,
35311
+ width,
35312
+ height
35313
+ } = cell.bounds;
35314
+ return /*#__PURE__*/React.createElement("div", {
35315
+ style: {
35316
+ left: "".concat(x, "%"),
35317
+ top: "".concat(y, "%"),
35318
+ width: "".concat(width, "%"),
35319
+ height: "".concat(height, "%"),
35320
+ position: 'absolute'
35321
+ }
35322
+ }, /*#__PURE__*/React.createElement(Cell, {
35323
+ ref: cell.cellRef,
35324
+ halo: halo,
35325
+ model: cell.model,
35326
+ currentId: cell.currentId,
35327
+ initialSnOptions: initialSnOptions,
35328
+ initialSnPlugins: initialSnPlugins,
35329
+ initialError: initialError,
35330
+ onMount: onMount
35331
+ }));
35332
+ }
35333
+ function Sheet(_ref) {
35334
+ let {
35335
+ model,
35336
+ halo,
35337
+ initialSnOptions,
35338
+ initialSnPlugins,
35339
+ initialError,
35340
+ onMount
35341
+ } = _ref;
35342
+ const {
35343
+ root
35344
+ } = halo;
35345
+ const [layout] = useLayout$1(model);
35346
+ const {
35347
+ theme: themeName
35348
+ } = reactExports.useContext(InstanceContext);
35349
+ const [cells, setCells] = reactExports.useState([]);
35350
+ const [bgColor, setBgColor] = reactExports.useState(undefined);
35351
+ const [bgImage, setBgImage] = reactExports.useState(undefined);
35352
+ const [deepHash, setDeepHash] = reactExports.useState('');
35479
35353
 
35480
- /**
35481
- * @interface VisualizationDefinition
35482
- * @property {QAEDefinition} qae
35483
- * @property {function():void} component
35484
- */
35354
+ /// For each object
35355
+ reactExports.useEffect(() => {
35356
+ if (layout) {
35357
+ const hash = JSON.stringify(layout.cells);
35358
+ if (hash === deepHash) {
35359
+ return;
35360
+ }
35361
+ setDeepHash(hash);
35362
+ const fetchObjects = async () => {
35363
+ /*
35364
+ Need to always fetch and evaluate everything as the sheet need to support multiple instances of the same object?
35365
+ No, there is no way to add the same chart twice, so the optimization should be worth it.
35366
+ */
35485
35367
 
35486
- /**
35487
- * @interface snGenerator
35488
- * @param {Visualization} Sn
35489
- * @param {Galaxy} galaxy
35490
- * @returns {generator}
35491
- * @private
35492
- */
35493
- function generatorFn(UserSN, galaxy) {
35494
- let sn;
35368
+ // Clear the cell list
35369
+ cells.forEach(c => {
35370
+ root.removeCell(c.currentId);
35371
+ });
35372
+ const lCells = layout.cells;
35373
+ // TODO - should try reuse existing objects on subsequent renders
35374
+ // Non-id updates should only change the "css"
35375
+ const cs = await Promise.all(lCells.map(async c => {
35376
+ let mounted;
35377
+ const mountedPromise = new Promise(resolve => {
35378
+ mounted = resolve;
35379
+ });
35380
+ const cell = cells.find(ce => ce.id === c.name);
35381
+ if (cell) {
35382
+ cell.bounds = c.bounds;
35383
+ delete cell.mountedPromise;
35384
+ return cell;
35385
+ }
35386
+ const vs = await getObject$1({
35387
+ id: c.name
35388
+ }, halo);
35389
+ return {
35390
+ model: vs.model,
35391
+ id: c.name,
35392
+ bounds: c.bounds,
35393
+ cellRef: React.createRef(),
35394
+ currentId: uid(),
35395
+ mounted,
35396
+ mountedPromise
35397
+ };
35398
+ }));
35399
+ cs.forEach(c => root.addCell(c.currentId, c.cellRef));
35400
+ setCells(cs);
35401
+ };
35402
+ fetchObjects();
35403
+ }
35404
+ }, [layout]);
35405
+ const cellRenderers = reactExports.useMemo(() => cells ? cells.map(c => getCellRenderer(c, halo, initialSnOptions, initialSnPlugins, initialError, c.mounted)) : [], [cells]);
35406
+ reactExports.useEffect(() => {
35407
+ const bgComp = layout !== null && layout !== void 0 && layout.components ? layout.components.find(comp => comp.key === 'general') : null;
35408
+ setBgColor(resolveBgColor(bgComp, halo.public.theme));
35409
+ setBgImage(resolveBgImage(bgComp, halo.app));
35410
+ }, [layout, halo.public.theme, halo.app, themeName]);
35495
35411
 
35496
- // TODO validate galaxy API
35412
+ /* TODO
35413
+ - sheet title + bg + logo etc + as option
35414
+ - sheet exposed classnames for theming
35415
+ */
35497
35416
 
35498
- if (typeof UserSN === 'function') {
35499
- sn = UserSN(galaxy);
35500
- } else {
35501
- sn = UserSN;
35417
+ const height = !layout || Number.isNaN(layout.height) ? '100%' : "".concat(Number(layout.height), "%");
35418
+ const promises = cells.map(c => c.mountedPromise);
35419
+ const ps = promises.filter(p => !!p);
35420
+ if (ps.length) {
35421
+ Promise.all(promises).then(() => {
35422
+ // TODO - correct? Currently called each time a new cell is mounted?
35423
+ onMount();
35424
+ });
35502
35425
  }
35426
+ return /*#__PURE__*/React.createElement("div", {
35427
+ className: SheetElement.className,
35428
+ style: {
35429
+ width: "100%",
35430
+ height,
35431
+ position: 'relative',
35432
+ backgroundColor: bgColor,
35433
+ backgroundImage: bgImage && bgImage.url ? "url(".concat(bgImage.url, ")") : undefined,
35434
+ backgroundRepeat: 'no-repeat',
35435
+ backgroundSize: bgImage && bgImage.size,
35436
+ backgroundPosition: bgImage && bgImage.pos
35437
+ }
35438
+ }, cellRenderers);
35439
+ }
35440
+
35441
+ function glue(_ref) {
35442
+ let {
35443
+ halo,
35444
+ element,
35445
+ model,
35446
+ initialSnOptions,
35447
+ initialSnPlugins,
35448
+ onMount,
35449
+ initialError
35450
+ } = _ref;
35451
+ const {
35452
+ root
35453
+ } = halo;
35454
+ const sheetRef = React.createRef();
35455
+ const portal = ReactDOM.createPortal( /*#__PURE__*/React.createElement(Sheet, {
35456
+ ref: sheetRef,
35457
+ halo: halo,
35458
+ model: model,
35459
+ initialSnOptions: initialSnOptions,
35460
+ initialSnPlugins: initialSnPlugins,
35461
+ initialError: initialError,
35462
+ onMount: onMount
35463
+ }), element, model.id);
35464
+ const unmount = () => {
35465
+ root.remove(portal);
35466
+ model.removeListener('closed', unmount);
35467
+ };
35468
+ model.on('closed', unmount);
35469
+ root.add(portal);
35470
+ return [unmount, sheetRef];
35471
+ }
35472
+
35473
+ const noopi = () => {};
35474
+ function sheet() {
35475
+ let {
35476
+ model,
35477
+ halo,
35478
+ initialError,
35479
+ onDestroy = async () => {}
35480
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35481
+ let unmountSheet = noopi;
35482
+ let sheetRef = null;
35483
+ let mountedReference = null;
35484
+ let onMount = null;
35485
+ const mounted = new Promise(resolve => {
35486
+ onMount = resolve;
35487
+ });
35488
+ let initialSnOptions = {};
35489
+ let initialSnPlugins = [];
35490
+ const setSnOptions = async opts => {
35491
+ if (mountedReference) {
35492
+ (async () => {
35493
+ await mounted;
35494
+ sheetRef.current.setSnOptions(_objectSpread2(_objectSpread2({}, initialSnOptions), opts));
35495
+ })();
35496
+ } else {
35497
+ // Handle setting options before mount
35498
+ initialSnOptions = _objectSpread2(_objectSpread2({}, initialSnOptions), opts);
35499
+ }
35500
+ };
35501
+ const setSnPlugins = async plugins => {
35502
+ validatePlugins(plugins);
35503
+ if (mountedReference) {
35504
+ (async () => {
35505
+ await mounted;
35506
+ sheetRef.current.setSnPlugins(plugins);
35507
+ })();
35508
+ } else {
35509
+ // Handle setting plugins before mount
35510
+ initialSnPlugins = plugins;
35511
+ }
35512
+ };
35503
35513
 
35504
35514
  /**
35505
- * @alias generator
35506
- * @private
35515
+ * @class
35516
+ * @alias Sheet
35517
+ * @classdesc A controller to further modify a visualization after it has been rendered.
35518
+ * @experimental
35519
+ * @since 3.1.0
35520
+ * @example
35521
+ * const sheet = await embed(app).render({
35522
+ * element,
35523
+ * id: "jD5Gd"
35524
+ * });
35525
+ * sheet.destroy();
35507
35526
  */
35508
- const generator = /** @lends generator */{
35527
+ const api = /** @lends Sheet# */{
35509
35528
  /**
35510
- * @type {QAE}
35529
+ * The id of this sheets's generic object.
35530
+ * @type {string}
35511
35531
  */
35512
- qae: qae(sn.qae),
35532
+ id: model.id,
35513
35533
  /**
35514
- * @type {SnComponent}
35534
+ * This sheets Enigma model, a representation of the generic object.
35535
+ * @type {string}
35515
35536
  */
35516
- component: sn.component || {},
35537
+ model,
35517
35538
  /**
35518
- * @param {object} p
35519
- * @param {EnigmaAppModel} p.app
35520
- * @param {EnigmaObjectModel} p.model
35521
- * @param {ObjectSelections} p.selections
35539
+ * Destroys the sheet and removes it from the the DOM.
35540
+ * @example
35541
+ * const sheet = await embed(app).render({
35542
+ * element,
35543
+ * id: "jD5Gd"
35544
+ * });
35545
+ * sheet.destroy();
35522
35546
  */
35523
- create(params) {
35524
- const ss = create$2(generator, params, galaxy);
35525
- return ss;
35547
+ async destroy() {
35548
+ await onDestroy();
35549
+ unmountSheet();
35550
+ unmountSheet = noopi;
35526
35551
  },
35527
- definition: {}
35528
- };
35529
- Object.keys(sn).forEach(key => {
35530
- if (!generator[key]) {
35531
- generator.definition[key] = sn[key];
35552
+ // ===== unexposed experimental API - use at own risk ======
35553
+ __DO_NOT_USE__: {
35554
+ mount(element) {
35555
+ if (mountedReference) {
35556
+ throw new Error('Already mounted');
35557
+ }
35558
+ if (!(element instanceof HTMLElement)) {
35559
+ throw new Error('Provided element is not a proper HTMLElement');
35560
+ }
35561
+ mountedReference = element;
35562
+ [unmountSheet, sheetRef] = glue({
35563
+ halo,
35564
+ element,
35565
+ model,
35566
+ initialSnOptions,
35567
+ initialSnPlugins,
35568
+ initialError,
35569
+ onMount
35570
+ });
35571
+ return mounted;
35572
+ },
35573
+ async applyProperties(props) {
35574
+ const current = await model.getEffectiveProperties();
35575
+ const patches = getPatches('/', props, current);
35576
+ if (patches.length) {
35577
+ return model.applyPatches(patches, true);
35578
+ }
35579
+ return undefined;
35580
+ },
35581
+ options(opts) {
35582
+ setSnOptions(opts);
35583
+ },
35584
+ plugins(plugins) {
35585
+ setSnPlugins(plugins);
35586
+ },
35587
+ exportImage() {
35588
+ throw new Error('Not implemented');
35589
+ },
35590
+ takeSnapshot() {
35591
+ throw new Error('Not implemented');
35592
+ },
35593
+ getModel() {
35594
+ return model;
35595
+ }
35532
35596
  }
35597
+ };
35598
+ return api;
35599
+ }
35600
+
35601
+ /* eslint no-underscore-dangle:0 */
35602
+ async function initSheet(model, optional, halo, initialError) {
35603
+ let onDestroy = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : async () => {};
35604
+ const api = sheet({
35605
+ model,
35606
+ halo,
35607
+ initialError,
35608
+ onDestroy
35533
35609
  });
35534
- return generator;
35610
+ if (optional.options) {
35611
+ api.__DO_NOT_USE__.options(optional.options);
35612
+ }
35613
+ if (optional.plugins) {
35614
+ api.__DO_NOT_USE__.plugins(optional.plugins);
35615
+ }
35616
+ if (optional.element) {
35617
+ await api.__DO_NOT_USE__.mount(optional.element);
35618
+ }
35619
+ return api;
35620
+ }
35621
+
35622
+ async function getObject(_ref, halo) {
35623
+ let {
35624
+ id,
35625
+ options,
35626
+ plugins,
35627
+ element
35628
+ } = _ref;
35629
+ const key = "".concat(id);
35630
+ let rpc = rpcRequestModelStore.get(key);
35631
+ if (!rpc) {
35632
+ rpc = halo.app.getObject(id);
35633
+ rpcRequestModelStore.set(key, rpc);
35634
+ }
35635
+ const model = await rpc;
35636
+ modelStore.set(key, model);
35637
+ if (model.genericType === 'sheet') {
35638
+ return initSheet(model, {
35639
+ options,
35640
+ plugins,
35641
+ element
35642
+ }, halo);
35643
+ }
35644
+ return init(model, {
35645
+ options,
35646
+ plugins,
35647
+ element
35648
+ }, halo);
35649
+ }
35650
+
35651
+ function flagsFn () {
35652
+ let flags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35653
+ /**
35654
+ * @interface Flags
35655
+ */
35656
+
35657
+ return (/** @lends Flags */{
35658
+ /**
35659
+ * Checks whether the specified flag is enabled.
35660
+ * @param {string} flag - The value flag to check.
35661
+ * @returns {boolean} True if the specified flag is enabled, false otherwise.
35662
+ */
35663
+ isEnabled: f => flags[f] === true
35664
+ }
35665
+ );
35535
35666
  }
35536
35667
 
35537
35668
  var iterator;
@@ -37695,7 +37826,10 @@
37695
37826
  language: 'en-US',
37696
37827
  /** @type {string=} */
37697
37828
  deviceType: 'auto',
37698
- /** @type {Constraints=} Deprecated */
37829
+ /**
37830
+ * @type {Constraints=}
37831
+ * @deprecated
37832
+ * */
37699
37833
  constraints: {},
37700
37834
  /** @type {Interactions=} */
37701
37835
  interactions: {},
@@ -38246,6 +38380,7 @@
38246
38380
  getLayout: () => Promise.resolve(layout),
38247
38381
  getProperties: () => Promise.resolve(properties),
38248
38382
  getEffectiveProperties: () => Promise.resolve(properties),
38383
+ removeListener: () => {},
38249
38384
  id: properties.qInfo.qId
38250
38385
  }, properties));
38251
38386
  };