@nebula.js/stardust 2.6.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/esm/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v2.6.1
2
+ * @nebula.js/stardust v2.9.0
3
3
  * Copyright (c) 2022 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -7,7 +7,7 @@
7
7
  import React, { useState as useState$1, useEffect as useEffect$1, useReducer, forwardRef, useMemo as useMemo$1, useImperativeHandle as useImperativeHandle$1, useCallback, useLayoutEffect as useLayoutEffect$1, createElement, PureComponent, useRef, useContext } from 'react';
8
8
  import ReactDOM from 'react-dom';
9
9
  import { createGenerateClassName, StylesProvider, ThemeProvider, makeStyles, useTheme as useTheme$1 } from '@material-ui/styles';
10
- import { Checkbox, Grid, FormControlLabel, Typography, IconButton, makeStyles as makeStyles$1, Popover, MenuList, MenuItem, ListItemIcon, Divider, OutlinedInput, InputAdornment, Badge, List, ListItem, Button, Box, Icon, CircularProgress, Paper } from '@material-ui/core';
10
+ import { Checkbox, Radio, Grid, FormControlLabel, Typography, IconButton, makeStyles as makeStyles$1, Popover, MenuList, MenuItem, ListItemIcon, Divider, OutlinedInput, InputAdornment, Badge, List, ListItem, Button, Box, Icon, CircularProgress, Paper } from '@material-ui/core';
11
11
 
12
12
  var runtime = {exports: {}};
13
13
 
@@ -742,14 +742,9 @@ function ownKeys(object, enumerableOnly) {
742
742
 
743
743
  if (Object.getOwnPropertySymbols) {
744
744
  var symbols = Object.getOwnPropertySymbols(object);
745
-
746
- if (enumerableOnly) {
747
- symbols = symbols.filter(function (sym) {
748
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
749
- });
750
- }
751
-
752
- keys.push.apply(keys, symbols);
745
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
746
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
747
+ })), keys.push.apply(keys, symbols);
753
748
  }
754
749
 
755
750
  return keys;
@@ -757,19 +752,12 @@ function ownKeys(object, enumerableOnly) {
757
752
 
758
753
  function _objectSpread2(target) {
759
754
  for (var i = 1; i < arguments.length; i++) {
760
- var source = arguments[i] != null ? arguments[i] : {};
761
-
762
- if (i % 2) {
763
- ownKeys(Object(source), true).forEach(function (key) {
764
- _defineProperty$1(target, key, source[key]);
765
- });
766
- } else if (Object.getOwnPropertyDescriptors) {
767
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
768
- } else {
769
- ownKeys(Object(source)).forEach(function (key) {
770
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
771
- });
772
- }
755
+ var source = null != arguments[i] ? arguments[i] : {};
756
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
757
+ _defineProperty$1(target, key, source[key]);
758
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
759
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
760
+ });
773
761
  }
774
762
 
775
763
  return target;
@@ -1001,6 +989,26 @@ var CurrentSelections_Of = {
1001
989
  "zh-TW": "{0}/ {1}"
1002
990
  }
1003
991
  };
992
+ var Listbox_Lock = {
993
+ id: "Listbox.Lock",
994
+ locale: {
995
+ "de-DE": "Auswahlen sperren",
996
+ "en-US": "Lock selections",
997
+ "es-ES": "Bloquear selecciones",
998
+ "fr-FR": "Verrouiller les sélections",
999
+ "it-IT": "Blocca selezioni",
1000
+ "ja-JP": "選択をロック",
1001
+ "ko-KR": "선택 내용 잠금",
1002
+ "nl-NL": "Selecties vergrendelen",
1003
+ "pl-PL": "Zablokuj wybory",
1004
+ "pt-BR": "Bloquear seleções",
1005
+ "ru-RU": "Заблокировать выборки",
1006
+ "sv-SE": "Lås urval",
1007
+ "tr-TR": "Seçimleri kilitle",
1008
+ "zh-CN": "锁定选择项",
1009
+ "zh-TW": "鎖定選項"
1010
+ }
1011
+ };
1004
1012
  var Listbox_Search = {
1005
1013
  id: "Listbox.Search",
1006
1014
  locale: {
@@ -1021,6 +1029,26 @@ var Listbox_Search = {
1021
1029
  "zh-TW": "在清單方塊中搜尋"
1022
1030
  }
1023
1031
  };
1032
+ var Listbox_Unlock = {
1033
+ id: "Listbox.Unlock",
1034
+ locale: {
1035
+ "de-DE": "Auswahlen entsperren",
1036
+ "en-US": "Unlock selections",
1037
+ "es-ES": "Desbloquear selecciones",
1038
+ "fr-FR": "Déverrouiller les sélections",
1039
+ "it-IT": "Sblocca selezioni",
1040
+ "ja-JP": "選択をロック解除",
1041
+ "ko-KR": "선택 내용 잠금 해제",
1042
+ "nl-NL": "Selecties ontgrendelen",
1043
+ "pl-PL": "Odblokuj wybory",
1044
+ "pt-BR": "Desbloquear seleções",
1045
+ "ru-RU": "Разблокировать выборки",
1046
+ "sv-SE": "Lås upp urval",
1047
+ "tr-TR": "Seçimlerin kilidini aç",
1048
+ "zh-CN": "将选择项解锁",
1049
+ "zh-TW": "解鎖選項"
1050
+ }
1051
+ };
1024
1052
  var Menu_More = {
1025
1053
  id: "Menu.More",
1026
1054
  locale: {
@@ -1505,7 +1533,9 @@ var all = {
1505
1533
  Cancel: Cancel$1,
1506
1534
  CurrentSelections_All: CurrentSelections_All,
1507
1535
  CurrentSelections_Of: CurrentSelections_Of,
1536
+ Listbox_Lock: Listbox_Lock,
1508
1537
  Listbox_Search: Listbox_Search,
1538
+ Listbox_Unlock: Listbox_Unlock,
1509
1539
  Menu_More: Menu_More,
1510
1540
  Navigate_Back: Navigate_Back,
1511
1541
  Navigate_Forward: Navigate_Forward,
@@ -2928,7 +2958,7 @@ function generateOrdinalScales(scalesDef) {
2928
2958
  }
2929
2959
 
2930
2960
  /**
2931
- * Creates the follwing array of paths
2961
+ * Creates the following array of paths
2932
2962
  * object.barChart - legend.title - fontSize
2933
2963
  * object - legend.title - fontSize
2934
2964
  * legend.title - fontSize
@@ -2983,7 +3013,7 @@ function getObject$1(root, steps) {
2983
3013
  if (obj[steps[i]]) {
2984
3014
  obj = obj[steps[i]];
2985
3015
  } else {
2986
- return null;
3016
+ return undefined;
2987
3017
  }
2988
3018
  }
2989
3019
 
@@ -2991,12 +3021,11 @@ function getObject$1(root, steps) {
2991
3021
  }
2992
3022
 
2993
3023
  function searchPathArray(pathArray, attribute, theme) {
2994
- for (let i = 0; i < pathArray.length; i++) {
2995
- const target = getObject$1(theme, pathArray[i]);
3024
+ const attributeArray = attribute.split('.');
2996
3025
 
2997
- if (target !== null && target[attribute]) {
2998
- return target[attribute];
2999
- }
3026
+ for (let i = 0; i < pathArray.length; i++) {
3027
+ const restult = getObject$1(theme, [...pathArray[i], ...attributeArray]);
3028
+ if (restult !== undefined) return restult;
3000
3029
  }
3001
3030
 
3002
3031
  return undefined;
@@ -3032,11 +3061,15 @@ function styleResolver(basePath, themeJSON) {
3032
3061
  * object.barChart - fontSize
3033
3062
  * object - fontSize
3034
3063
  * fontSize
3064
+ * When attributes separated by dots is provided, they are required in the theme JSON file
3065
+ * Ex. Base path: "object" , Path: "legend", ", Attribute: "title.fontSize"
3066
+ * title: {fontSize: ...} must be matched and the rest is the same as above
3067
+ * If you want a exact match, you can use `getStyle('object', '', 'legend.title.fontSize');`
3035
3068
  * @ignore
3036
3069
  *
3037
- * @param {string} component string of properties seperated by dots to search in
3038
- * @param {string} attribute to return
3039
- * @returns {any} value of the resolved path, undefined if not found
3070
+ * @param {string} component String of properties separated by dots to search in
3071
+ * @param {string} attribute Name of the style attribute
3072
+ * @returns {string|undefined} The style value of the resolved path, undefined if not found
3040
3073
  */
3041
3074
  getStyle(component, attribute) {
3042
3075
  // TODO - object overrides
@@ -3199,17 +3232,23 @@ function theme() {
3199
3232
  },
3200
3233
 
3201
3234
  /**
3202
- * Get the value of a style attribute in the theme by searching in the theme's JSON structure.
3203
- * The search starts at the specified base path and continues upwards until the value is found.
3235
+ * Get the value of a style attribute in the theme
3236
+ * by searching in the theme's JSON structure.
3237
+ * The search starts at the specified base path
3238
+ * and continues upwards until the value is found.
3204
3239
  * If possible it will get the attribute's value using the given path.
3240
+ * When attributes separated by dots are provided, such as 'hover.color',
3241
+ * they are required in the theme JSON file
3205
3242
  *
3206
3243
  * @param {string} basePath - Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
3207
3244
  * @param {string} path - Expected path for the attribute (specified as a name path separated by dots).
3208
- * @param {string} attribute - Name of the style attribute.
3209
- * @returns {string} The style value
3245
+ * @param {string} attribute - Name of the style attribute. (specified as a name attribute separated by dots).
3246
+ * @returns {string|undefined} The style value or undefined if not found
3210
3247
  *
3211
3248
  * @example
3212
3249
  * theme.getStyle('object', 'title.main', 'fontSize');
3250
+ * theme.getStyle('object', 'title', 'main.fontSize');
3251
+ * theme.getStyle('object', '', 'title.main.fontSize');
3213
3252
  * theme.getStyle('', '', 'fontSize');
3214
3253
  */
3215
3254
  getStyle(basePath, path, attribute) {
@@ -3217,7 +3256,7 @@ function theme() {
3217
3256
  styleResolverInstanceCache[basePath] = styleResolver(basePath, resolvedThemeJSON);
3218
3257
  }
3219
3258
 
3220
- return styleResolverInstanceCache[basePath].getStyle(path, attribute, false);
3259
+ return styleResolverInstanceCache[basePath].getStyle(path, attribute);
3221
3260
  }
3222
3261
 
3223
3262
  };
@@ -3256,7 +3295,9 @@ function theme() {
3256
3295
 
3257
3296
  /* eslint no-underscore-dangle:0 */
3258
3297
 
3259
- const timed = (t, v) => new Promise(resolve => setTimeout(() => resolve(v), t));
3298
+ const timed = (t, v) => new Promise(resolve => {
3299
+ setTimeout(() => resolve(v), t);
3300
+ });
3260
3301
 
3261
3302
  const LOAD_THEME_TIMEOUT = 5000;
3262
3303
  function appTheme() {
@@ -5234,7 +5275,7 @@ function useAppSelections(app) {
5234
5275
  return [appSelections, navState];
5235
5276
  }
5236
5277
 
5237
- const NEBULA_VERSION_HASH = "375a" ;
5278
+ const NEBULA_VERSION_HASH = "0d6f" ;
5238
5279
  let counter = 0;
5239
5280
  const NebulaApp = forwardRef((_ref, ref) => {
5240
5281
  let {
@@ -5280,7 +5321,7 @@ const NebulaApp = forwardRef((_ref, ref) => {
5280
5321
  theme: theme
5281
5322
  }, /*#__PURE__*/React.createElement(InstanceContext.Provider, {
5282
5323
  value: context
5283
- }, /*#__PURE__*/React.createElement(React.Fragment, null, components))));
5324
+ }, components)));
5284
5325
  });
5285
5326
  function boot(_ref2) {
5286
5327
  let {
@@ -5294,7 +5335,7 @@ function boot(_ref2) {
5294
5335
  const appRef = React.createRef();
5295
5336
  const element = document.createElement('div');
5296
5337
  element.style.display = 'none';
5297
- element.setAttribute('data-nebulajs-version', "2.6.1" );
5338
+ element.setAttribute('data-nebulajs-version', "2.9.0" );
5298
5339
  element.setAttribute('data-app-id', app.id);
5299
5340
  document.body.appendChild(element);
5300
5341
  ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
@@ -6461,13 +6502,22 @@ function getSelectedValues(pages) {
6461
6502
  return flatten(elementNbrs);
6462
6503
  }
6463
6504
  function applySelectionsOnPages(pages, elmNumbers) {
6505
+ let clearAllButElmNumbers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6506
+
6464
6507
  const getNewSelectionState = qState => elmNumbers.length <= 1 && isStateSelected(qState) ? 'A' : 'S';
6465
6508
 
6466
6509
  const matrices = pages.map(page => {
6467
6510
  const qMatrix = page.qMatrix.map(p => {
6468
6511
  const [p0] = p;
6469
6512
  const selectionMatchesElement = elmNumbers.includes(p0.qElemNumber);
6470
- const qState = selectionMatchesElement ? getNewSelectionState(p0.qState) : p0.qState;
6513
+ let qState;
6514
+
6515
+ if (clearAllButElmNumbers) {
6516
+ qState = selectionMatchesElement ? 'S' : 'A';
6517
+ } else {
6518
+ qState = selectionMatchesElement ? getNewSelectionState(p0.qState) : p0.qState;
6519
+ }
6520
+
6471
6521
  return [_objectSpread2(_objectSpread2({}, p0), {}, {
6472
6522
  qState
6473
6523
  }), p.slice(1)];
@@ -6515,7 +6565,8 @@ function getElemNumbersFromPages(pages) {
6515
6565
  return elemNumbers;
6516
6566
  }
6517
6567
  /**
6518
- * @typedef {object} MinMaxResult
6568
+ * @ignore
6569
+ * @interface MinMaxResult
6519
6570
  * @property {number} min
6520
6571
  * @property {number} max
6521
6572
  */
@@ -6524,6 +6575,7 @@ function getElemNumbersFromPages(pages) {
6524
6575
  * Returns the min and max indices of elemNumbersOrdered which contains
6525
6576
  * all numbers in elementNbrs.
6526
6577
  *
6578
+ * @ignore
6527
6579
  * @param {number[]} elementNbrs
6528
6580
  * @param {number[]} elemNumbersOrdered
6529
6581
  * @returns {MinMaxResult}
@@ -6567,24 +6619,28 @@ function useSelectionsInteractions(_ref) {
6567
6619
  pages = [],
6568
6620
  rangeSelect = true,
6569
6621
  checkboxes = false,
6570
- doc = document
6622
+ selectDisabled,
6623
+ doc = document,
6624
+ isSingleSelect: singleSelect = false
6571
6625
  } = _ref;
6572
6626
  const [instantPages, setInstantPages] = useState$1(pages);
6573
6627
  const [mouseDown, setMouseDown] = useState$1(false);
6574
6628
  const [selectingValues, setSelectingValues] = useState$1(false);
6629
+ const [isSingleSelect, setIsSingleSelect] = useState$1(singleSelect);
6575
6630
  const [selected, setSelected] = useState$1([]);
6576
6631
  const [isRangeSelection, setIsRangeSelection] = useState$1(false);
6577
6632
  const [preSelected, setPreSelected] = useState$1([]);
6578
- const elemNumbersOrdered = getElemNumbersFromPages(pages);
6579
-
6580
- const getIsSingleSelect = () => !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne); // Select values for real, by calling the backend.
6581
-
6633
+ const elemNumbersOrdered = getElemNumbersFromPages(pages); // Select values for real, by calling the backend.
6582
6634
 
6583
6635
  const select = async function () {
6584
6636
  let elemNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6585
6637
  let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6638
+
6639
+ if (selectDisabled()) {
6640
+ return;
6641
+ }
6642
+
6586
6643
  setSelectingValues(true);
6587
- const isSingleSelect = getIsSingleSelect();
6588
6644
  const filtered = additive ? elemNumbers.filter(n => !selected.includes(n)) : elemNumbers;
6589
6645
  await selectValues({
6590
6646
  selections,
@@ -6592,11 +6648,17 @@ function useSelectionsInteractions(_ref) {
6592
6648
  isSingleSelect
6593
6649
  });
6594
6650
  setSelectingValues(false);
6651
+ setPreSelected([]);
6595
6652
  }; // Show estimated selection states instantly before applying the selections for real.
6596
6653
 
6597
6654
 
6598
6655
  const preSelect = function (elemNumbers) {
6599
6656
  let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6657
+
6658
+ if (selectDisabled()) {
6659
+ return;
6660
+ }
6661
+
6600
6662
  setPreSelected(existing => {
6601
6663
  const uniques = getUniques([...existing, ...elemNumbers]);
6602
6664
  const filtered = additive ? uniques.filter(n => !selected.includes(n)) : uniques;
@@ -6605,16 +6667,38 @@ function useSelectionsInteractions(_ref) {
6605
6667
  });
6606
6668
  };
6607
6669
 
6670
+ const selectManually = function () {
6671
+ let elementIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6672
+ let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6673
+ setIsRangeSelection(false); // range is not supported for manual select
6674
+
6675
+ setMouseDown(true);
6676
+ preSelect(elementIds, additive || isRangeSelection);
6677
+ const p = select(elementIds, additive || isRangeSelection);
6678
+ setMouseDown(false);
6679
+ return p;
6680
+ };
6681
+
6682
+ const handleSingleSelectKey = event => {
6683
+ if (event.ctrlKey || event.metaKey) {
6684
+ setIsSingleSelect(true);
6685
+ event.currentTarget.focus(); // will not be focused otherwise
6686
+
6687
+ event.preventDefault();
6688
+ }
6689
+ };
6690
+
6608
6691
  const onClick = useCallback(event => {
6609
- if (selectingValues) {
6692
+ if (selectingValues || selectDisabled()) {
6610
6693
  return;
6611
6694
  }
6612
6695
 
6613
6696
  const elemNumber = +event.currentTarget.getAttribute('data-n');
6614
6697
  setPreSelected([elemNumber]);
6615
- }, [selectingValues]);
6698
+ handleSingleSelectKey(event);
6699
+ }, [selectingValues, selectDisabled]);
6616
6700
  const onMouseDown = useCallback(event => {
6617
- if (selectingValues) {
6701
+ if (selectingValues || selectDisabled()) {
6618
6702
  return;
6619
6703
  }
6620
6704
 
@@ -6622,31 +6706,34 @@ function useSelectionsInteractions(_ref) {
6622
6706
  setMouseDown(true);
6623
6707
  const elemNumber = +event.currentTarget.getAttribute('data-n');
6624
6708
  setPreSelected([elemNumber]);
6625
- }, [selectingValues]);
6709
+ handleSingleSelectKey(event);
6710
+ }, [selectingValues, selectDisabled]);
6626
6711
  const onMouseUp = useCallback(event => {
6627
6712
  const elemNumber = +event.currentTarget.getAttribute('data-n');
6628
6713
 
6629
- if (getIsSingleSelect() || !rangeSelect || !mouseDown || selectingValues || preSelected.length === 1 && preSelected[0] === elemNumber // prevent toggling again on mouseup
6714
+ if (isSingleSelect || !rangeSelect || !mouseDown || selectingValues || preSelected.length === 1 && preSelected[0] === elemNumber // prevent toggling again on mouseup
6630
6715
  ) {
6631
6716
  return;
6632
6717
  }
6633
6718
 
6634
6719
  preSelect([elemNumber]);
6635
- }, [mouseDown, selectingValues, preSelected, selected, isRangeSelection]);
6720
+ }, [mouseDown, selectingValues, preSelected, selected, isRangeSelection, selectDisabled]);
6636
6721
  const onMouseUpDoc = useCallback(() => {
6637
6722
  // Ensure we end interactions when mouseup happens outside the Listbox.
6638
6723
  setMouseDown(false);
6639
6724
  setSelectingValues(false);
6725
+ setIsRangeSelection(false);
6726
+ setIsSingleSelect(singleSelect);
6640
6727
  }, []);
6641
6728
  const onMouseEnter = useCallback(event => {
6642
- if (getIsSingleSelect() || !mouseDown || selectingValues) {
6729
+ if (isSingleSelect || !mouseDown || selectingValues || selectDisabled()) {
6643
6730
  return;
6644
6731
  }
6645
6732
 
6646
6733
  setIsRangeSelection(true);
6647
6734
  const elemNumber = +event.currentTarget.getAttribute('data-n');
6648
6735
  preSelect([elemNumber], true);
6649
- }, [mouseDown, selectingValues, isRangeSelection, preSelected, selected, layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne]);
6736
+ }, [mouseDown, selectingValues, isRangeSelection, preSelected, selected, selectDisabled, layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne]);
6650
6737
  useEffect$1(() => {
6651
6738
  // Perform selections of pre-selected values. This can
6652
6739
  // happen only when interactions have finished (mouseup).
@@ -6657,7 +6744,7 @@ function useSelectionsInteractions(_ref) {
6657
6744
  }
6658
6745
 
6659
6746
  select(preSelected, isRangeSelection);
6660
- }, [preSelected, mouseDown]);
6747
+ }, [preSelected, mouseDown, selectDisabled()]);
6661
6748
  useEffect$1(() => {
6662
6749
  doc.addEventListener('mouseup', onMouseUpDoc);
6663
6750
  return () => {
@@ -6679,7 +6766,7 @@ function useSelectionsInteractions(_ref) {
6679
6766
  } // Render pre-selections before they have been selected in Engine.
6680
6767
 
6681
6768
 
6682
- const newPages = applySelectionsOnPages(pages, preSelected);
6769
+ const newPages = applySelectionsOnPages(pages, preSelected, isSingleSelect);
6683
6770
  setInstantPages(newPages);
6684
6771
  }, [preSelected]);
6685
6772
  const interactionEvents = {};
@@ -6703,7 +6790,9 @@ function useSelectionsInteractions(_ref) {
6703
6790
 
6704
6791
  return {
6705
6792
  instantPages,
6706
- interactionEvents
6793
+ interactionEvents,
6794
+ select: selectManually // preselect and select without having to trigger an event
6795
+
6707
6796
  };
6708
6797
  }
6709
6798
 
@@ -6720,17 +6809,21 @@ var Tick = (props => SvgIcon(tick(props)));
6720
6809
 
6721
6810
  const CheckboxChecked = "url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath" + " fill-rule='evenodd' clip-rule='evenodd' d='M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 " + "1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z' fill='%23fff'/%3E%3C/svg%3E\")";
6722
6811
 
6723
- const useStyles$b = makeStyles(theme => ({
6812
+ const borderRadius = 2;
6813
+ const useStyles$d = makeStyles(theme => ({
6724
6814
  cbIcon: {
6725
- borderRadius: 3,
6815
+ borderRadius,
6726
6816
  width: 16,
6727
6817
  height: 16,
6728
6818
  boxShadow: 'inset 0 0 0 1px rgba(16,22,26,.2), inset 0 -1px 0 rgba(16,22,26,.1)',
6729
6819
  backgroundColor: '#f5f8fa',
6730
- backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))'
6820
+ backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.8),hsla(0,0%,100%,0))',
6821
+ display: 'flex',
6822
+ alignItems: 'center',
6823
+ justifyContent: 'center'
6731
6824
  },
6732
6825
  cbIconChecked: {
6733
- borderRadius: 3,
6826
+ borderRadius,
6734
6827
  backgroundColor: theme.palette.selected.main,
6735
6828
  backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
6736
6829
  '&:before': {
@@ -6741,6 +6834,18 @@ const useStyles$b = makeStyles(theme => ({
6741
6834
  content: '""'
6742
6835
  }
6743
6836
  },
6837
+ cbIconExcluded: {
6838
+ borderRadius,
6839
+ width: 12,
6840
+ height: 12,
6841
+ backgroundColor: theme.palette.selected.excluded
6842
+ },
6843
+ cbIconAlternative: {
6844
+ borderRadius,
6845
+ width: 12,
6846
+ height: 12,
6847
+ backgroundColor: theme.palette.selected.alternative
6848
+ },
6744
6849
  checkbox: {
6745
6850
  margin: 0,
6746
6851
  '&:hover': {
@@ -6751,26 +6856,36 @@ const useStyles$b = makeStyles(theme => ({
6751
6856
  padding: '4px 8px'
6752
6857
  }
6753
6858
  }));
6859
+
6860
+ const getIcon = function (styles) {
6861
+ let excluded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6862
+ let alternative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6863
+ return /*#__PURE__*/React.createElement("span", {
6864
+ className: styles.cbIcon
6865
+ }, (excluded || alternative) && /*#__PURE__*/React.createElement("span", {
6866
+ className: [excluded && styles.cbIconExcluded, alternative && styles.cbIconAlternative].filter(Boolean).join(' ')
6867
+ }));
6868
+ };
6869
+
6754
6870
  function ListboxCheckbox(_ref) {
6755
6871
  let {
6756
6872
  checked,
6757
6873
  label,
6758
- dense
6874
+ dense,
6875
+ excluded,
6876
+ alternative
6759
6877
  } = _ref;
6760
- const styles = useStyles$b();
6878
+ const styles = useStyles$d();
6761
6879
  return /*#__PURE__*/React.createElement(Checkbox, {
6762
6880
  edge: "start",
6763
6881
  checked: checked,
6764
- tabIndex: -1,
6765
6882
  disableRipple: true,
6766
6883
  className: [styles.checkbox, dense && styles.dense].filter(Boolean).join(' '),
6767
6884
  inputProps: {
6768
6885
  'aria-labelledby': label
6769
6886
  },
6770
6887
  name: label,
6771
- icon: /*#__PURE__*/React.createElement("span", {
6772
- className: styles.cbIcon
6773
- }),
6888
+ icon: getIcon(styles, excluded, alternative),
6774
6889
  checkedIcon: /*#__PURE__*/React.createElement("span", {
6775
6890
  className: styles.cbIconChecked
6776
6891
  })
@@ -6778,18 +6893,21 @@ function ListboxCheckbox(_ref) {
6778
6893
  }
6779
6894
 
6780
6895
  /**
6781
- * @typedef {object} Range
6896
+ * @ignore
6897
+ * @interface Range
6782
6898
  * @property {number} qCharPos The (absolute) index where the highlighted range starts.
6783
6899
  * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
6784
6900
  */
6785
6901
 
6786
6902
  /**
6787
- * @typedef {object} Segment
6903
+ * @ignore
6904
+ * @interface Segment
6788
6905
  * @property {string} segment The sub-string/segment cut out from the original label.
6789
6906
  * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
6790
6907
  */
6791
6908
 
6792
6909
  /**
6910
+ * @ignore
6793
6911
  * @param {string} label The label we want to create segments out of.
6794
6912
  * @param {Range} range The indexes which define how to create the segments.
6795
6913
  * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
@@ -6814,6 +6932,7 @@ function getSegmentsFromRange(label, range) {
6814
6932
  return segments;
6815
6933
  }
6816
6934
  /**
6935
+ * @ignore
6817
6936
  * @param {string} label The label we want to create segments out of.
6818
6937
  * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
6819
6938
  * @returns {Segment[]} An array of segments, covering the entire string label.
@@ -6841,27 +6960,252 @@ function getSegmentsFromRanges(label, ranges) {
6841
6960
  return labels;
6842
6961
  }
6843
6962
 
6963
+ const useStyles$c = makeStyles(() => ({
6964
+ denseRadioButton: {
6965
+ height: '100%',
6966
+ boxSizing: 'border-box',
6967
+ '& svg': {
6968
+ width: '0.7em',
6969
+ height: '0.7em'
6970
+ }
6971
+ },
6972
+ radioButton: {
6973
+ right: '5px'
6974
+ }
6975
+ }));
6976
+ function ListBoxRadioButton(_ref) {
6977
+ let {
6978
+ checked,
6979
+ label,
6980
+ dense
6981
+ } = _ref;
6982
+ const styles = useStyles$c();
6983
+ return /*#__PURE__*/React.createElement(Radio, {
6984
+ checked: checked,
6985
+ value: label,
6986
+ name: label,
6987
+ inputProps: {
6988
+ 'aria-labelledby': label
6989
+ },
6990
+ className: dense ? styles.denseRadioButton : styles.radioButton,
6991
+ style: {
6992
+ backgroundColor: 'transparent'
6993
+ },
6994
+ disableRipple: true
6995
+ });
6996
+ }
6997
+
6998
+ const KEYS = Object.freeze({
6999
+ ENTER: 13,
7000
+ ESCAPE: 27,
7001
+ SPACE: 32,
7002
+ TAB: 9,
7003
+ BACKSPACE: 8,
7004
+ DELETE: 46,
7005
+ ALT: 18,
7006
+ CTRL: 17,
7007
+ SHIFT: 16,
7008
+ ARROW_UP: 38,
7009
+ ARROW_DOWN: 40,
7010
+ ARROW_LEFT: 37,
7011
+ ARROW_RIGHT: 39,
7012
+ PAGE_DOWN: 34,
7013
+ PAGE_UP: 33,
7014
+ HOME: 36,
7015
+ END: 35,
7016
+ F10: 121,
7017
+ A: 65,
7018
+ F: 70,
7019
+ ZERO: 48,
7020
+ NINE: 57,
7021
+ NUMPAD_ZERO: 96,
7022
+ NUMPAD_NINE: 105,
7023
+ SUBTRACTION: 189,
7024
+ DECIMAL: 190,
7025
+ NUMPAD_DECIMAL: 110,
7026
+ isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
7027
+ });
7028
+
7029
+ function getFieldKeyboardNavigation(_ref) {
7030
+ let {
7031
+ select,
7032
+ confirm,
7033
+ cancel
7034
+ } = _ref;
7035
+
7036
+ const getElement = function (elm) {
7037
+ let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7038
+ const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
7039
+ return parentElm && parentElm.querySelector('[role]');
7040
+ };
7041
+
7042
+ let startedRange = false;
7043
+
7044
+ const setStartedRange = val => {
7045
+ startedRange = val;
7046
+ };
7047
+
7048
+ const handleKeyDown = event => {
7049
+ let elementToFocus;
7050
+ const {
7051
+ keyCode,
7052
+ shiftKey = false
7053
+ } = event.nativeEvent;
7054
+
7055
+ switch (keyCode) {
7056
+ case KEYS.SHIFT:
7057
+ // This is to ensure we include the first value when starting a range selection.
7058
+ setStartedRange(true);
7059
+ break;
7060
+
7061
+ case KEYS.SPACE:
7062
+ select([+event.currentTarget.getAttribute('data-n')]);
7063
+ break;
7064
+
7065
+ case KEYS.ARROW_DOWN:
7066
+ case KEYS.ARROW_RIGHT:
7067
+ elementToFocus = getElement(event.currentTarget, true);
7068
+
7069
+ if (shiftKey && elementToFocus) {
7070
+ if (startedRange) {
7071
+ select([+event.currentTarget.getAttribute('data-n')], true);
7072
+ setStartedRange(false);
7073
+ }
7074
+
7075
+ select([+elementToFocus.getAttribute('data-n')], true);
7076
+ }
7077
+
7078
+ break;
7079
+
7080
+ case KEYS.ARROW_UP:
7081
+ case KEYS.ARROW_LEFT:
7082
+ elementToFocus = getElement(event.currentTarget, false);
7083
+
7084
+ if (shiftKey && elementToFocus) {
7085
+ if (startedRange) {
7086
+ select([+event.currentTarget.getAttribute('data-n')], true);
7087
+ setStartedRange(false);
7088
+ }
7089
+
7090
+ select([+elementToFocus.getAttribute('data-n')], true);
7091
+ }
7092
+
7093
+ break;
7094
+
7095
+ case KEYS.ENTER:
7096
+ confirm();
7097
+ break;
7098
+
7099
+ case KEYS.ESCAPE:
7100
+ cancel();
7101
+ return;
7102
+ // let it propagate to top-level
7103
+
7104
+ default:
7105
+ return;
7106
+ // don't stop propagation since we want to outsource keydown to other handlers.
7107
+ }
7108
+
7109
+ if (elementToFocus) {
7110
+ elementToFocus.focus();
7111
+ }
7112
+
7113
+ event.preventDefault();
7114
+ event.stopPropagation();
7115
+ };
7116
+
7117
+ return handleKeyDown;
7118
+ }
7119
+ function getListboxInlineKeyboardNavigation(_ref2) {
7120
+ let {
7121
+ setKeyboardActive
7122
+ } = _ref2;
7123
+
7124
+ const focusInsideListbox = element => {
7125
+ const fieldElement = element.querySelector('.search input, .value.selector, .value');
7126
+ setKeyboardActive(true);
7127
+
7128
+ if (fieldElement) {
7129
+ fieldElement.focus();
7130
+ }
7131
+ };
7132
+
7133
+ const focusContainer = element => {
7134
+ setKeyboardActive(false);
7135
+ element.focus();
7136
+ };
7137
+
7138
+ const handleKeyDown = event => {
7139
+ const {
7140
+ keyCode
7141
+ } = event.nativeEvent;
7142
+
7143
+ switch (keyCode) {
7144
+ // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
7145
+ case KEYS.ENTER:
7146
+ case KEYS.SPACE:
7147
+ focusInsideListbox(event.currentTarget);
7148
+ break;
7149
+
7150
+ case KEYS.ESCAPE:
7151
+ focusContainer(event.currentTarget);
7152
+ break;
7153
+
7154
+ default:
7155
+ return;
7156
+ } // Note: We should not stop propagation here as it will block the containing app
7157
+ // from handling keydown events.
7158
+
7159
+
7160
+ event.preventDefault();
7161
+ };
7162
+
7163
+ return handleKeyDown;
7164
+ }
7165
+
6844
7166
  const ellipsis = {
6845
7167
  width: '100%',
6846
7168
  overflow: 'hidden',
6847
7169
  textOverflow: 'ellipsis'
6848
7170
  };
6849
- const useStyles$a = makeStyles(theme => ({
6850
- row: {
6851
- flexWrap: 'nowrap',
6852
- borderBottom: "1px solid ".concat(theme.palette.divider),
6853
- color: theme.palette.text.primary,
7171
+ const barPadPx = 4;
7172
+ const barBorderWidthPx = 1;
7173
+ const barWithCheckboxLeftPadEm = 2;
7174
+ const frequencyTextNone = '0';
7175
+
7176
+ const getSelectedStyle = _ref => {
7177
+ let {
7178
+ theme
7179
+ } = _ref;
7180
+ return {
7181
+ background: theme.palette.selected.main,
7182
+ color: theme.palette.selected.mainContrastText,
6854
7183
  '&:focus': {
6855
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
7184
+ boxShadow: "inset 0 0 0 2px rgba(0, 0, 0, 0.3)",
6856
7185
  outline: 'none'
7186
+ },
7187
+ '& $cell': {
7188
+ paddingRight: 0
6857
7189
  }
7190
+ };
7191
+ };
7192
+
7193
+ const useStyles$b = makeStyles(theme => ({
7194
+ row: {
7195
+ flexWrap: 'nowrap',
7196
+ borderBottom: "1px solid ".concat(theme.palette.divider),
7197
+ color: theme.palette.text.primary
6858
7198
  },
6859
7199
  column: {
6860
7200
  flexWrap: 'nowrap',
6861
7201
  borderRight: "1px solid ".concat(theme.palette.divider),
6862
- color: theme.palette.text.primary,
7202
+ color: theme.palette.text.primary
7203
+ },
7204
+ fieldRoot: {
6863
7205
  '&:focus': {
6864
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
7206
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
7207
+ },
7208
+ '&:focus-visible': {
6865
7209
  outline: 'none'
6866
7210
  }
6867
7211
  },
@@ -6872,8 +7216,8 @@ const useStyles$a = makeStyles(theme => ({
6872
7216
  minWidth: 0,
6873
7217
  flexGrow: 1,
6874
7218
  // Note that this padding is overridden when using checkboxes.
6875
- paddingLeft: '12px',
6876
- paddingRight: '12px'
7219
+ paddingLeft: '9px',
7220
+ paddingRight: '9px'
6877
7221
  },
6878
7222
  // The leaf node, containing the label text.
6879
7223
  labelText: _objectSpread2({
@@ -6899,39 +7243,82 @@ const useStyles$a = makeStyles(theme => ({
6899
7243
  checkboxLabel: {
6900
7244
  margin: 0,
6901
7245
  width: '100%',
6902
- // For checkboxes the first child is the checkbox container, second is the label container.
6903
- '& > span:nth-child(2)': _objectSpread2({}, ellipsis)
7246
+ height: '100%',
7247
+ // The checkbox's span
7248
+ '& > span:nth-child(1)': {
7249
+ paddingRight: '7px'
7250
+ },
7251
+ // The checkbox's label container.
7252
+ '& > span:nth-child(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
7253
+ display: 'flex',
7254
+ alignItems: 'center',
7255
+ paddingLeft: 0
7256
+ })
6904
7257
  },
6905
7258
  // The icons container holding tick and lock, shown inside fields.
6906
7259
  icon: {
6907
7260
  display: 'flex',
6908
- padding: theme.spacing(1)
6909
- },
6910
- // Selection styles (S=Selected, A=Available, X=Excluded).
6911
- S: {
6912
- background: theme.palette.selected.main,
6913
- color: theme.palette.selected.mainContrastText,
6914
- '&:focus': {
6915
- boxShadow: "inset 0 0 0 2px rgba(0, 0, 0, 0.3)",
6916
- outline: 'none'
6917
- }
7261
+ padding: theme.spacing(1, 1, 1, 0)
6918
7262
  },
7263
+ // Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
7264
+ S: _objectSpread2({}, getSelectedStyle({
7265
+ theme
7266
+ })),
7267
+ XS: _objectSpread2(_objectSpread2({}, getSelectedStyle({
7268
+ theme
7269
+ })), {}, {
7270
+ background: theme.palette.selected.excluded,
7271
+ color: theme.palette.selected.mainContrastText
7272
+ }),
6919
7273
  A: {
6920
7274
  background: theme.palette.selected.alternative,
6921
7275
  color: theme.palette.selected.alternativeContrastText
6922
7276
  },
6923
7277
  X: {
6924
7278
  background: theme.palette.selected.excluded,
6925
- color: theme.palette.selected.excludedContrastText
7279
+ color: theme.palette.selected.mainContrastText
7280
+ },
7281
+ frequencyCount: {
7282
+ paddingLeft: '8px',
7283
+ paddingRight: '8px'
7284
+ },
7285
+ barContainer: {
7286
+ position: 'relative'
7287
+ },
7288
+ bar: {
7289
+ border: "".concat(barBorderWidthPx, "px solid"),
7290
+ borderColor: '#D9D9D9',
7291
+ height: '1em',
7292
+ position: 'absolute',
7293
+ zIndex: '-1',
7294
+ alignSelf: 'center',
7295
+ left: "".concat(barPadPx, "px"),
7296
+ transition: 'width 0.2s'
7297
+ },
7298
+ barSelected: {
7299
+ opacity: '30%',
7300
+ zIndex: '0',
7301
+ background: theme.palette.background.lighter
7302
+ },
7303
+ barWithCheckbox: {
7304
+ left: "".concat(barWithCheckboxLeftPadEm, "em")
7305
+ },
7306
+ barSelectedWithCheckbox: {
7307
+ background: '#BFE5D0',
7308
+ borderColor: '#BFE5D0'
7309
+ },
7310
+ excludedTextWithCheckbox: {
7311
+ color: '#828282'
6926
7312
  }
6927
7313
  }));
6928
- function RowColumn(_ref) {
7314
+
7315
+ function RowColumn(_ref2) {
6929
7316
  let {
6930
7317
  index,
6931
7318
  style,
6932
7319
  data,
6933
7320
  column = false
6934
- } = _ref;
7321
+ } = _ref2;
6935
7322
  const {
6936
7323
  onClick,
6937
7324
  onMouseDown,
@@ -6940,11 +7327,18 @@ function RowColumn(_ref) {
6940
7327
  pages,
6941
7328
  isLocked,
6942
7329
  checkboxes = false,
6943
- dense = false
7330
+ dense = false,
7331
+ frequencyMode = 'N',
7332
+ isSingleSelect,
7333
+ actions,
7334
+ frequencyMax = '',
7335
+ histogram = false,
7336
+ keyboard
6944
7337
  } = data;
7338
+ const handleKeyDownCallback = useCallback(getFieldKeyboardNavigation(actions), [actions]);
6945
7339
  const [isSelected, setSelected] = useState$1(false);
6946
7340
  const [cell, setCell] = useState$1();
6947
- const classes = useStyles$a();
7341
+ const classes = useStyles$b();
6948
7342
  const [classArr, setClassArr] = useState$1([]);
6949
7343
  useEffect$1(() => {
6950
7344
  if (!pages) {
@@ -6964,6 +7358,11 @@ function RowColumn(_ref) {
6964
7358
 
6965
7359
  setCell(c);
6966
7360
  }, [pages]);
7361
+
7362
+ const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
7363
+
7364
+ const isAlternative = c => c ? c.qState === 'A' : null;
7365
+
6967
7366
  useEffect$1(() => {
6968
7367
  if (!cell) {
6969
7368
  return;
@@ -6974,11 +7373,13 @@ function RowColumn(_ref) {
6974
7373
  const clazzArr = [column ? classes.column : classes.row];
6975
7374
 
6976
7375
  if (!checkboxes) {
6977
- if (cell.qState === 'S' || cell.qState === 'L') {
7376
+ if (cell.qState === 'XS') {
7377
+ clazzArr.push(classes.XS);
7378
+ } else if (cell.qState === 'S' || cell.qState === 'L') {
6978
7379
  clazzArr.push(classes.S);
6979
- } else if (cell.qState === 'A') {
7380
+ } else if (isAlternative(cell)) {
6980
7381
  clazzArr.push(classes.A);
6981
- } else if (cell.qState === 'X' || cell.qState === 'XS' || cell.qState === 'XL') {
7382
+ } else if (isExcluded(cell)) {
6982
7383
  clazzArr.push(classes.X);
6983
7384
  }
6984
7385
  }
@@ -6986,18 +7387,22 @@ function RowColumn(_ref) {
6986
7387
  setClassArr(clazzArr);
6987
7388
  }, [cell && cell.qState]);
6988
7389
 
6989
- const getValueField = _ref2 => {
7390
+ const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
7391
+
7392
+ const excludedOrAlternative = () => (isAlternative(cell) || isExcluded(cell)) && checkboxes;
7393
+
7394
+ const getValueField = _ref3 => {
6990
7395
  let {
6991
7396
  lbl,
6992
7397
  ix,
6993
7398
  color,
6994
7399
  highlighted = false
6995
- } = _ref2;
7400
+ } = _ref3;
6996
7401
  return /*#__PURE__*/React.createElement(Typography, {
6997
7402
  component: "span",
6998
7403
  variant: "body2",
6999
7404
  key: ix,
7000
- className: [classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense].filter(c => !!c).join(' ').trim(),
7405
+ className: joinClassNames([classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense, excludedOrAlternative() && classes.excludedTextWithCheckbox]),
7001
7406
  color: color
7002
7407
  }, /*#__PURE__*/React.createElement("span", {
7003
7408
  style: {
@@ -7006,13 +7411,29 @@ function RowColumn(_ref) {
7006
7411
  }, lbl));
7007
7412
  };
7008
7413
 
7009
- const getCheckboxField = _ref3 => {
7414
+ const preventContextMenu = event => {
7415
+ if (checkboxes) {
7416
+ // Event will not propagate in the checkbox/radiobutton case
7417
+ onClick(event);
7418
+ }
7419
+
7420
+ event.preventDefault();
7421
+ };
7422
+
7423
+ const getCheckboxField = _ref4 => {
7010
7424
  let {
7011
7425
  lbl,
7012
7426
  color,
7013
7427
  qElemNumber
7014
- } = _ref3;
7428
+ } = _ref4;
7015
7429
  const cb = /*#__PURE__*/React.createElement(ListboxCheckbox, {
7430
+ label: lbl,
7431
+ checked: isSelected,
7432
+ dense: dense,
7433
+ excluded: isExcluded(cell),
7434
+ alternative: isAlternative(cell)
7435
+ });
7436
+ const rb = /*#__PURE__*/React.createElement(ListBoxRadioButton, {
7016
7437
  label: lbl,
7017
7438
  checked: isSelected,
7018
7439
  dense: dense
@@ -7024,25 +7445,34 @@ function RowColumn(_ref) {
7024
7445
  }) : lbl;
7025
7446
  return /*#__PURE__*/React.createElement(FormControlLabel, {
7026
7447
  color: color,
7027
- control: cb,
7448
+ control: isSingleSelect ? rb : cb,
7028
7449
  className: classes.checkboxLabel,
7029
7450
  label: labelTag,
7030
7451
  key: qElemNumber
7031
7452
  });
7032
7453
  };
7033
7454
 
7034
- const label = cell ? cell.qText : ''; // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
7455
+ const label = cell ? cell.qText : '';
7456
+
7457
+ const getFrequencyText = () => {
7458
+ if (cell) {
7459
+ return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
7460
+ }
7461
+
7462
+ return '';
7463
+ }; // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
7464
+
7035
7465
 
7036
7466
  const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
7037
7467
  const labels = getSegmentsFromRanges(label, ranges);
7038
7468
  const getField = checkboxes ? getCheckboxField : getValueField;
7039
7469
 
7040
- const getFieldWithRanges = _ref4 => {
7470
+ const getFieldWithRanges = _ref5 => {
7041
7471
  let {
7042
7472
  lbls
7043
- } = _ref4;
7044
- const labelsWithRanges = lbls.map((_ref5, ix) => {
7045
- let [lbl, highlighted] = _ref5;
7473
+ } = _ref5;
7474
+ const labelsWithRanges = lbls.map((_ref6, ix) => {
7475
+ let [lbl, highlighted] = _ref6;
7046
7476
  return getValueField({
7047
7477
  ix,
7048
7478
  highlighted,
@@ -7067,29 +7497,66 @@ function RowColumn(_ref) {
7067
7497
  flexGrow: 1,
7068
7498
  padding: checkboxes ? 0 : undefined
7069
7499
  };
7070
- return /*#__PURE__*/React.createElement(Grid, {
7500
+
7501
+ const hasHistogramBar = () => cell && histogram && getFrequencyText() !== frequencyTextNone;
7502
+
7503
+ const getBarWidth = qFrequency => {
7504
+ const freqStr = String(qFrequency);
7505
+ const isPercent = freqStr.substring(freqStr.length - 1) === '%';
7506
+ const freq = parseFloat(isPercent ? freqStr : qFrequency);
7507
+ const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadEm, "em + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
7508
+ const width = isPercent ? freq : freq / frequencyMax * 100;
7509
+ return "calc(".concat(width, "% - ").concat(rightSlice, ")");
7510
+ };
7511
+
7512
+ const isFirstElement = index === 0;
7513
+ return /*#__PURE__*/React.createElement("div", {
7514
+ className: classes.barContainer
7515
+ }, /*#__PURE__*/React.createElement(Grid, {
7071
7516
  container: true,
7072
7517
  spacing: 0,
7073
- className: ['value', ...classArr].join(' ').trim(),
7518
+ className: joinClassNames(['value', ...classArr]),
7519
+ classes: {
7520
+ root: classes.fieldRoot
7521
+ },
7074
7522
  style: style,
7075
7523
  onClick: onClick,
7076
7524
  onMouseDown: onMouseDown,
7077
7525
  onMouseUp: onMouseUp,
7078
7526
  onMouseEnter: onMouseEnter,
7527
+ onKeyDown: handleKeyDownCallback,
7528
+ onContextMenu: preventContextMenu,
7079
7529
  role: column ? 'column' : 'row',
7080
- tabIndex: 0,
7530
+ tabIndex: isFirstElement && (!keyboard.enabled || keyboard.active) ? 0 : -1,
7081
7531
  "data-n": cell && cell.qElemNumber
7082
- }, /*#__PURE__*/React.createElement(Grid, {
7532
+ }, hasHistogramBar() && /*#__PURE__*/React.createElement("div", {
7533
+ className: joinClassNames([classes.bar, checkboxes && classes.barWithCheckbox, isSelected && (checkboxes ? classes.barSelectedWithCheckbox : classes.barSelected)]),
7534
+ style: {
7535
+ width: getBarWidth(cell.qFrequency)
7536
+ }
7537
+ }), /*#__PURE__*/React.createElement(Grid, {
7083
7538
  item: true,
7084
7539
  style: cellStyle,
7085
- className: classes.cell,
7540
+ className: joinClassNames([classes.cell, classes.selectedCell]),
7086
7541
  title: "".concat(label)
7087
7542
  }, ranges.length === 0 ? getField({
7088
7543
  lbl: label,
7089
7544
  color: 'inherit'
7090
7545
  }) : getFieldWithRanges({
7091
7546
  lbls: labels
7092
- })), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid, {
7547
+ })), frequencyMode !== 'N' && /*#__PURE__*/React.createElement(Grid, {
7548
+ item: true,
7549
+ style: {
7550
+ display: 'flex',
7551
+ alignItems: 'center'
7552
+ },
7553
+ className: classes.frequencyCount
7554
+ }, /*#__PURE__*/React.createElement(Typography, {
7555
+ noWrap: true,
7556
+ color: "inherit",
7557
+ variant: "body2",
7558
+ className: joinClassNames([dense && classes.labelDense, classes.labelText, excludedOrAlternative() && classes.excludedTextWithCheckbox])
7559
+ }, getFrequencyText())), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid, {
7093
7560
  item: true,
7094
7561
  className: classes.icon
7095
7562
  }, showLock && /*#__PURE__*/React.createElement(Lock, {
@@ -7098,7 +7565,7 @@ function RowColumn(_ref) {
7098
7565
  }), showTick && /*#__PURE__*/React.createElement(Tick, {
7099
7566
  style: iconStyles,
7100
7567
  size: "small"
7101
- })));
7568
+ }))));
7102
7569
  }
7103
7570
 
7104
7571
  function getSizeInfo(_ref) {
@@ -7130,24 +7597,32 @@ function ListBox(_ref2) {
7130
7597
  height,
7131
7598
  width,
7132
7599
  listLayout = 'vertical',
7600
+ frequencyMode = 'N',
7601
+ histogram = false,
7133
7602
  rangeSelect = true,
7134
7603
  checkboxes = false,
7135
7604
  update = undefined,
7136
- dense = false
7605
+ dense = false,
7606
+ keyboard = {},
7607
+ selectDisabled = () => false
7137
7608
  } = _ref2;
7138
7609
  const [layout] = useLayout$1(model);
7610
+ const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
7139
7611
  const [pages, setPages] = useState$1(null);
7140
7612
  const [isLoadingData, setIsLoadingData] = useState$1(false);
7141
7613
  const {
7142
7614
  instantPages = [],
7143
- interactionEvents
7615
+ interactionEvents,
7616
+ select
7144
7617
  } = useSelectionsInteractions({
7145
7618
  layout,
7146
7619
  selections,
7147
7620
  pages,
7148
7621
  rangeSelect,
7149
7622
  checkboxes,
7150
- doc: document
7623
+ selectDisabled,
7624
+ doc: document,
7625
+ isSingleSelect
7151
7626
  });
7152
7627
  const loaderRef = useRef(null);
7153
7628
  const local = useRef({
@@ -7248,6 +7723,9 @@ function ListBox(_ref2) {
7248
7723
  height
7249
7724
  });
7250
7725
  const isLocked = layout && layout.qListObject.qDimensionInfo.qLocked;
7726
+ const {
7727
+ frequencyMax
7728
+ } = layout;
7251
7729
  return /*#__PURE__*/React.createElement(InfiniteLoader, {
7252
7730
  isItemLoaded: isItemLoaded,
7253
7731
  itemCount: count,
@@ -7274,9 +7752,19 @@ function ListBox(_ref2) {
7274
7752
  isLocked,
7275
7753
  column: !isVertical,
7276
7754
  pages
7277
- }, isLocked ? {} : interactionEvents), {}, {
7755
+ }, isLocked || selectDisabled() ? {} : interactionEvents), {}, {
7278
7756
  checkboxes,
7279
- dense
7757
+ dense,
7758
+ frequencyMode,
7759
+ isSingleSelect,
7760
+ actions: {
7761
+ select,
7762
+ confirm: () => selections && selections.confirm.call(selections),
7763
+ cancel: () => selections && selections.cancel.call(selections)
7764
+ },
7765
+ frequencyMax,
7766
+ histogram,
7767
+ keyboard
7280
7768
  }),
7281
7769
  itemSize: itemSize,
7282
7770
  onItemsRendered: onItemsRendered,
@@ -7512,13 +8000,13 @@ function useDefaultSelectionActions(_ref) {
7512
8000
  }];
7513
8001
  }
7514
8002
 
7515
- const useStyles$9 = makeStyles$1(theme => ({
8003
+ const useStyles$a = makeStyles$1(theme => ({
7516
8004
  icon: {
7517
8005
  color: theme.palette.text.primary
7518
8006
  }
7519
8007
  }));
7520
8008
 
7521
- const MoreItem = _ref => {
8009
+ function MoreItem(_ref) {
7522
8010
  let {
7523
8011
  item,
7524
8012
  onActionClick = () => {}
@@ -7530,7 +8018,7 @@ const MoreItem = _ref => {
7530
8018
  } = useActionState(item);
7531
8019
  const {
7532
8020
  icon
7533
- } = useStyles$9();
8021
+ } = useStyles$a();
7534
8022
 
7535
8023
  const handleClick = () => {
7536
8024
  item.action();
@@ -7546,7 +8034,7 @@ const MoreItem = _ref => {
7546
8034
  }, SvgIcon(item.getSvgIconShape())), /*#__PURE__*/React.createElement(Typography, {
7547
8035
  noWrap: true
7548
8036
  }, item.label)) : null;
7549
- };
8037
+ }
7550
8038
 
7551
8039
  const More$1 = React.forwardRef((_ref2, ref) => {
7552
8040
  let {
@@ -7606,7 +8094,7 @@ const ActionToolbarElement = {
7606
8094
  /** @type {'njs-action-toolbar-popover'} */
7607
8095
  className: 'njs-action-toolbar-popover'
7608
8096
  };
7609
- const useStyles$8 = makeStyles$1(theme => ({
8097
+ const useStyles$9 = makeStyles$1(theme => ({
7610
8098
  itemSpacing: {
7611
8099
  padding: theme.spacing(0, 0.5)
7612
8100
  },
@@ -7628,7 +8116,7 @@ const ActionsGroup = React.forwardRef((_ref, ref) => {
7628
8116
  itemSpacing,
7629
8117
  firstItemSpacing,
7630
8118
  lastItemSpacing
7631
- } = useStyles$8();
8119
+ } = useStyles$9();
7632
8120
  return actions.length > 0 ? /*#__PURE__*/React.createElement(Grid, {
7633
8121
  item: true,
7634
8122
  container: true,
@@ -7675,7 +8163,7 @@ const popoverTransformOrigin = {
7675
8163
  horizontal: 'right'
7676
8164
  };
7677
8165
 
7678
- const ActionsToolbar = _ref2 => {
8166
+ function ActionsToolbar(_ref2) {
7679
8167
  let {
7680
8168
  show = true,
7681
8169
  actions = [],
@@ -7704,7 +8192,7 @@ const ActionsToolbar = _ref2 => {
7704
8192
  const defaultSelectionActions = useDefaultSelectionActions(selections);
7705
8193
  const {
7706
8194
  itemSpacing
7707
- } = useStyles$8();
8195
+ } = useStyles$9();
7708
8196
  const {
7709
8197
  translator,
7710
8198
  keyboardNavigation
@@ -7837,7 +8325,7 @@ const ActionsToolbar = _ref2 => {
7837
8325
  }
7838
8326
  }
7839
8327
  }, Actions) : show && Actions;
7840
- };
8328
+ }
7841
8329
 
7842
8330
  const search = props => _objectSpread2(_objectSpread2({}, props), {}, {
7843
8331
  shapes: [{
@@ -7848,13 +8336,19 @@ const search = props => _objectSpread2(_objectSpread2({}, props), {}, {
7848
8336
  }]
7849
8337
  });
7850
8338
 
7851
- var Search = (props => SvgIcon(search(props)));
8339
+ var SearchIcon = (props => SvgIcon(search(props)));
7852
8340
 
7853
- const useStyles$7 = makeStyles(theme => ({
8341
+ const useStyles$8 = makeStyles(theme => ({
7854
8342
  root: {
8343
+ border: 'none',
8344
+ borderRadius: 0,
7855
8345
  '& fieldset': {
7856
- borderRadius: 0,
7857
- borderColor: "".concat(theme.palette.divider, " transparent")
8346
+ border: "1px solid ".concat(theme.palette.divider),
8347
+ borderWidth: '1px 0 1px 0',
8348
+ borderRadius: 0
8349
+ },
8350
+ '&:hover': {
8351
+ border: 'none'
7858
8352
  }
7859
8353
  },
7860
8354
  dense: {
@@ -7870,7 +8364,7 @@ const TREE_PATH = '/qListObjectDef';
7870
8364
  function ListBoxSearch(_ref) {
7871
8365
  let {
7872
8366
  model,
7873
- autoFocus = true,
8367
+ keyboard,
7874
8368
  dense = false
7875
8369
  } = _ref;
7876
8370
  const {
@@ -7896,21 +8390,23 @@ function ListBoxSearch(_ref) {
7896
8390
  }
7897
8391
  };
7898
8392
 
7899
- const classes = useStyles$7();
8393
+ const classes = useStyles$8();
7900
8394
  return /*#__PURE__*/React.createElement(OutlinedInput, {
7901
8395
  startAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
7902
8396
  position: "start"
7903
- }, /*#__PURE__*/React.createElement(Search, {
8397
+ }, /*#__PURE__*/React.createElement(SearchIcon, {
7904
8398
  size: dense ? 'small' : 'normal'
7905
8399
  })),
7906
8400
  className: ['search', classes.root, dense && classes.dense].filter(Boolean).join(' '),
7907
- autoFocus: autoFocus,
7908
8401
  margin: "dense",
7909
8402
  fullWidth: true,
7910
8403
  placeholder: translator.get('Listbox.Search'),
7911
8404
  value: value,
7912
8405
  onChange: onChange,
7913
- onKeyDown: onKeyDown
8406
+ onKeyDown: onKeyDown,
8407
+ inputProps: {
8408
+ tabIndex: keyboard && (!keyboard.enabled || keyboard.active) ? 0 : -1
8409
+ }
7914
8410
  });
7915
8411
  }
7916
8412
 
@@ -8232,10 +8728,14 @@ function ListBoxPopover(_ref) {
8232
8728
  }, isLocked ? /*#__PURE__*/React.createElement(IconButton, {
8233
8729
  onClick: unlock,
8234
8730
  disabled: !isLocked
8235
- }, /*#__PURE__*/React.createElement(Lock, null)) : /*#__PURE__*/React.createElement(IconButton, {
8731
+ }, /*#__PURE__*/React.createElement(Lock, {
8732
+ title: translator.get('Listbox.Unlock')
8733
+ })) : /*#__PURE__*/React.createElement(IconButton, {
8236
8734
  onClick: lock,
8237
8735
  disabled: !hasSelections
8238
- }, /*#__PURE__*/React.createElement(Unlock, null))), /*#__PURE__*/React.createElement(Grid, {
8736
+ }, /*#__PURE__*/React.createElement(Unlock, {
8737
+ title: translator.get('Listbox.Lock')
8738
+ }))), /*#__PURE__*/React.createElement(Grid, {
8239
8739
  item: true,
8240
8740
  xs: true
8241
8741
  }), /*#__PURE__*/React.createElement(Grid, {
@@ -8273,7 +8773,7 @@ function ListBoxPopover(_ref) {
8273
8773
  }))));
8274
8774
  }
8275
8775
 
8276
- const useStyles$6 = makeStyles(theme => ({
8776
+ const useStyles$7 = makeStyles(theme => ({
8277
8777
  item: {
8278
8778
  backgroundColor: theme.palette.background.paper,
8279
8779
  position: 'relative',
@@ -8299,7 +8799,7 @@ function OneField(_ref) {
8299
8799
  const alignTo = moreAlignTo || useRef();
8300
8800
  const theme = useTheme$1();
8301
8801
  const [showListBoxPopover, setShowListBoxPopover] = useState$1(false);
8302
- const classes = useStyles$6();
8802
+ const classes = useStyles$7();
8303
8803
 
8304
8804
  const handleShowListBoxPopover = e => {
8305
8805
  if (e.currentTarget.contains(e.target)) {
@@ -8456,7 +8956,7 @@ const downArrow = props => _objectSpread2(_objectSpread2({}, props), {}, {
8456
8956
 
8457
8957
  var DownArrow = (props => SvgIcon(downArrow(props)));
8458
8958
 
8459
- const useStyles$5 = makeStyles(theme => ({
8959
+ const useStyles$6 = makeStyles(theme => ({
8460
8960
  item: {
8461
8961
  backgroundColor: theme.palette.background.paper,
8462
8962
  position: 'relative',
@@ -8479,7 +8979,7 @@ function MultiState(_ref) {
8479
8979
  moreAlignTo = null,
8480
8980
  onClose = () => {}
8481
8981
  } = _ref;
8482
- const classes = useStyles$5(); // If originated from the `more` item show fields directly
8982
+ const classes = useStyles$6(); // If originated from the `more` item show fields directly
8483
8983
 
8484
8984
  const [showFields, setShowFields] = useState$1(!!moreAlignTo);
8485
8985
  const [showStateIx, setShowStateIx] = useState$1(-1); // If originated from the `more` item align it
@@ -8619,7 +9119,7 @@ function MultiState(_ref) {
8619
9119
  }) : Component;
8620
9120
  }
8621
9121
 
8622
- const useStyles$4 = makeStyles(theme => ({
9122
+ const useStyles$5 = makeStyles(theme => ({
8623
9123
  item: {
8624
9124
  backgroundColor: theme.palette.background.paper,
8625
9125
  position: 'relative',
@@ -8640,7 +9140,7 @@ function More(_ref) {
8640
9140
  items = [],
8641
9141
  api
8642
9142
  } = _ref;
8643
- const classes = useStyles$4();
9143
+ const classes = useStyles$5();
8644
9144
  const theme = useTheme$1();
8645
9145
  const [showMoreItems, setShowMoreItems] = useState$1(false);
8646
9146
  const [showItemIx, setShowItemIx] = useState$1(-1);
@@ -8959,7 +9459,7 @@ function Nav(_ref) {
8959
9459
  }, /*#__PURE__*/React.createElement(ClearSelections, null))));
8960
9460
  }
8961
9461
 
8962
- const AppSelections = _ref => {
9462
+ function AppSelections(_ref) {
8963
9463
  let {
8964
9464
  app
8965
9465
  } = _ref;
@@ -8993,7 +9493,7 @@ const AppSelections = _ref => {
8993
9493
  api: appSelections,
8994
9494
  app: app
8995
9495
  })));
8996
- };
9496
+ }
8997
9497
  function mount(_ref2) {
8998
9498
  let {
8999
9499
  element,
@@ -9487,33 +9987,26 @@ AutoSizer.defaultProps = {
9487
9987
  style: {}
9488
9988
  };
9489
9989
 
9490
- function ListBoxPortal(_ref) {
9491
- let {
9492
- app,
9493
- fieldIdentifier,
9494
- stateName,
9495
- element,
9496
- options
9497
- } = _ref;
9498
- return ReactDOM.createPortal( /*#__PURE__*/React.createElement(ListBoxInline, {
9499
- app: app,
9500
- fieldIdentifier: fieldIdentifier,
9501
- stateName: stateName,
9502
- options: options
9503
- }), element);
9504
- }
9505
- function ListBoxInline(_ref2) {
9990
+ const useStyles$4 = makeStyles(() => ({
9991
+ listBoxHeader: {
9992
+ alignSelf: 'center',
9993
+ display: 'inline-flex'
9994
+ }
9995
+ }));
9996
+ function ListBoxInline(_ref) {
9506
9997
  let {
9507
9998
  app,
9508
9999
  fieldIdentifier,
9509
10000
  stateName = '$',
9510
- options = {}
9511
- } = _ref2;
10001
+ options = {},
10002
+ fieldDef
10003
+ } = _ref;
9512
10004
  const {
9513
10005
  title,
9514
10006
  direction,
9515
10007
  listLayout,
9516
10008
  search = true,
10009
+ focusSearch = false,
9517
10010
  toolbar = true,
9518
10011
  rangeSelect = true,
9519
10012
  checkboxes = false,
@@ -9521,9 +10014,55 @@ function ListBoxInline(_ref2) {
9521
10014
  sessionModel = undefined,
9522
10015
  selectionsApi = undefined,
9523
10016
  update = undefined,
9524
- dense = false
10017
+ dense = false,
10018
+ selectDisabled = () => false
10019
+ } = options;
10020
+ let {
10021
+ frequencyMode,
10022
+ histogram = false
9525
10023
  } = options;
9526
10024
 
10025
+ if (fieldDef && fieldDef.failedToFetchFieldDef) {
10026
+ histogram = false;
10027
+ frequencyMode = 'N';
10028
+ }
10029
+
10030
+ switch (true) {
10031
+ case ['none', 'N', 'NX_FREQUENCY_NONE'].includes(frequencyMode):
10032
+ frequencyMode = 'N';
10033
+ break;
10034
+
10035
+ case ['value', 'V', 'NX_FREQUENCY_VALUE', 'default'].includes(frequencyMode):
10036
+ frequencyMode = 'V';
10037
+ break;
10038
+
10039
+ case ['percent', 'P', 'NX_FREQUENCY_PERCENT'].includes(frequencyMode):
10040
+ frequencyMode = 'P';
10041
+ break;
10042
+
10043
+ case ['relative', 'R', 'NX_FREQUENCY_RELATIVE'].includes(frequencyMode):
10044
+ frequencyMode = 'R';
10045
+ break;
10046
+
10047
+ default:
10048
+ frequencyMode = 'N';
10049
+ break;
10050
+ }
10051
+
10052
+ const getListdefFrequencyMode = () => histogram && frequencyMode === 'N' ? 'V' : frequencyMode; // Hook that will trigger update when used in useEffects.
10053
+ // Modified from: https://medium.com/@teh_builder/ref-objects-inside-useeffect-hooks-eb7c15198780
10054
+
10055
+
10056
+ const useRefWithCallback = () => {
10057
+ const [ref, setInternalRef] = useState$1({});
10058
+ const setRef = useCallback(node => {
10059
+ setInternalRef({
10060
+ current: node
10061
+ });
10062
+ }, [setInternalRef]);
10063
+ return [ref, setRef];
10064
+ };
10065
+
9527
10066
  const listdef = _objectSpread2({
9528
10067
  qInfo: {
9529
10068
  qType: 'njsListbox'
@@ -9531,6 +10070,7 @@ function ListBoxInline(_ref2) {
9531
10070
  qListObjectDef: {
9532
10071
  qStateName: stateName,
9533
10072
  qShowAlternatives: true,
10073
+ qFrequencyMode: getListdefFrequencyMode(),
9534
10074
  qInitialDataFetch: [{
9535
10075
  qTop: 0,
9536
10076
  qLeft: 0,
@@ -9560,6 +10100,13 @@ function ListBoxInline(_ref2) {
9560
10100
  fieldName = fieldIdentifier;
9561
10101
  }
9562
10102
 
10103
+ if (frequencyMode !== 'N' || histogram) {
10104
+ const field = fieldIdentifier.qLibraryId ? fieldDef : fieldName;
10105
+ listdef.frequencyMax = {
10106
+ qValueExpression: "Max(AGGR(Count([".concat(field, "]), [").concat(field, "]))")
10107
+ };
10108
+ }
10109
+
9563
10110
  let [model] = useSessionModel(listdef, sessionModel ? null : app, fieldName, stateName);
9564
10111
 
9565
10112
  if (sessionModel) {
@@ -9573,6 +10120,7 @@ function ListBoxInline(_ref2) {
9573
10120
  }
9574
10121
 
9575
10122
  const theme = useTheme$1();
10123
+ const classes = useStyles$4();
9576
10124
  const lock = useCallback(() => {
9577
10125
  model.lock('/qListObjectDef');
9578
10126
  }, [model]);
@@ -9580,11 +10128,24 @@ function ListBoxInline(_ref2) {
9580
10128
  model.unlock('/qListObjectDef');
9581
10129
  }, [model]);
9582
10130
  const {
9583
- translator
10131
+ translator,
10132
+ keyboardNavigation
9584
10133
  } = useContext(InstanceContext);
9585
10134
  const moreAlignTo = useRef();
10135
+ const [searchContainer, searchContainerRef] = useRefWithCallback();
9586
10136
  const [layout] = useLayout$1(model);
9587
10137
  const [showToolbar, setShowToolbar] = useState$1(false);
10138
+ const [showSearch, setShowSearch] = useState$1(false);
10139
+ const [keyboardActive, setKeyboardActive] = useState$1(false);
10140
+ const handleKeyDown = getListboxInlineKeyboardNavigation({
10141
+ setKeyboardActive
10142
+ }); // Expose the keyboard flags in the same way as the keyboard hook does.
10143
+
10144
+ const keyboard = {
10145
+ enabled: keyboardNavigation,
10146
+ // this will be static until we can access the useKeyboard hook
10147
+ active: keyboardActive
10148
+ };
9588
10149
  useEffect$1(() => {
9589
10150
  if (selections) {
9590
10151
  if (!selections.isModal(model)) {
@@ -9596,12 +10157,30 @@ function ListBoxInline(_ref2) {
9596
10157
  });
9597
10158
  }
9598
10159
  }
10160
+
10161
+ return () => {
10162
+ if (selections) {
10163
+ selections.off('deactivated');
10164
+ selections.off('activated');
10165
+ }
10166
+ };
9599
10167
  }, [selections]);
9600
10168
  useEffect$1(() => {
9601
10169
  if (selections) {
9602
10170
  setShowToolbar(selections.isActive());
9603
10171
  }
9604
10172
  }, [selections]);
10173
+ useEffect$1(() => {
10174
+ if (!searchContainer || !searchContainer.current) {
10175
+ return;
10176
+ } // Focus search field on toggle-show or when focusSearch is true.
10177
+
10178
+
10179
+ if (search && focusSearch || search === 'toggle' && showSearch) {
10180
+ const input = searchContainer.current.querySelector('input');
10181
+ input && input.focus();
10182
+ }
10183
+ }, [searchContainer && searchContainer.current, showSearch, search, focusSearch]);
9605
10184
 
9606
10185
  if (!model || !layout || !translator) {
9607
10186
  return null;
@@ -9615,32 +10194,51 @@ function ListBoxInline(_ref2) {
9615
10194
  }) : [];
9616
10195
  const counts = layout.qListObject.qDimensionInfo.qStateCounts;
9617
10196
  const hasSelections = counts.qSelected + counts.qSelectedExcluded + counts.qLocked + counts.qLockedExcluded > 0;
9618
- const minHeight = 49 + (search ? 40 : 0) + 49;
10197
+ const searchVisible = (search === true || search === 'toggle' && showSearch) && !selectDisabled();
10198
+ const minHeight = 49 + (searchVisible ? 40 : 0) + 49;
10199
+
10200
+ const onShowSearch = () => {
10201
+ const newValue = !showSearch;
10202
+ setShowSearch(newValue);
10203
+ };
10204
+
10205
+ const getSearchOrUnlock = () => search === 'toggle' && !hasSelections ? /*#__PURE__*/React.createElement(IconButton, {
10206
+ onClick: onShowSearch,
10207
+ tabIndex: -1,
10208
+ title: translator.get('Listbox.Search')
10209
+ }, /*#__PURE__*/React.createElement(SearchIcon, null)) : /*#__PURE__*/React.createElement(IconButton, {
10210
+ onClick: lock,
10211
+ tabIndex: -1,
10212
+ disabled: !hasSelections
10213
+ }, /*#__PURE__*/React.createElement(Unlock, null));
10214
+
9619
10215
  return /*#__PURE__*/React.createElement(Grid, {
9620
10216
  container: true,
10217
+ tabIndex: keyboard.enabled && !keyboard.active ? 0 : -1,
9621
10218
  direction: "column",
9622
10219
  spacing: 0,
9623
10220
  style: {
9624
10221
  height: '100%',
9625
10222
  minHeight: "".concat(minHeight, "px")
9626
- }
10223
+ },
10224
+ onKeyDown: handleKeyDown
9627
10225
  }, toolbar && /*#__PURE__*/React.createElement(Grid, {
9628
10226
  item: true,
9629
10227
  container: true,
9630
10228
  style: {
9631
- padding: theme.spacing(1),
9632
- borderBottom: "1px solid ".concat(theme.palette.divider)
10229
+ padding: theme.spacing(1)
9633
10230
  }
9634
10231
  }, /*#__PURE__*/React.createElement(Grid, {
9635
10232
  item: true
9636
10233
  }, isLocked ? /*#__PURE__*/React.createElement(IconButton, {
10234
+ tabIndex: -1,
9637
10235
  onClick: unlock,
9638
10236
  disabled: !isLocked
9639
- }, /*#__PURE__*/React.createElement(Lock, null)) : /*#__PURE__*/React.createElement(IconButton, {
9640
- onClick: lock,
9641
- disabled: !hasSelections
9642
- }, /*#__PURE__*/React.createElement(Unlock, null))), /*#__PURE__*/React.createElement(Grid, {
9643
- item: true
10237
+ }, /*#__PURE__*/React.createElement(Lock, {
10238
+ title: translator.get('Listbox.Unlock')
10239
+ })) : getSearchOrUnlock()), /*#__PURE__*/React.createElement(Grid, {
10240
+ item: true,
10241
+ className: classes.listBoxHeader
9644
10242
  }, /*#__PURE__*/React.createElement(Typography, {
9645
10243
  variant: "h6",
9646
10244
  noWrap: true
@@ -9668,37 +10266,103 @@ function ListBoxInline(_ref2) {
9668
10266
  onConfirm: () => {},
9669
10267
  onCancel: () => {}
9670
10268
  }
9671
- }))), search ? /*#__PURE__*/React.createElement(Grid, {
9672
- item: true
10269
+ }))), searchVisible && /*#__PURE__*/React.createElement(Grid, {
10270
+ item: true,
10271
+ ref: searchContainerRef
9673
10272
  }, /*#__PURE__*/React.createElement(ListBoxSearch, {
9674
10273
  model: model,
9675
- autoFocus: false,
9676
- dense: dense
9677
- })) : '', /*#__PURE__*/React.createElement(Grid, {
10274
+ dense: dense,
10275
+ keyboard: keyboard
10276
+ })), /*#__PURE__*/React.createElement(Grid, {
9678
10277
  item: true,
9679
10278
  xs: true
9680
10279
  }, /*#__PURE__*/React.createElement("div", {
9681
10280
  ref: moreAlignTo
9682
- }), /*#__PURE__*/React.createElement(AutoSizer, null, _ref3 => {
10281
+ }), /*#__PURE__*/React.createElement(AutoSizer, null, _ref2 => {
9683
10282
  let {
9684
10283
  height,
9685
10284
  width
9686
- } = _ref3;
10285
+ } = _ref2;
9687
10286
  return /*#__PURE__*/React.createElement(ListBox, {
9688
10287
  model: model,
9689
10288
  selections: selections,
9690
10289
  direction: direction,
9691
10290
  listLayout: listLayout,
10291
+ frequencyMode: frequencyMode,
10292
+ histogram: histogram,
9692
10293
  rangeSelect: rangeSelect,
9693
10294
  checkboxes: checkboxes,
9694
10295
  height: height,
9695
10296
  width: width,
9696
10297
  update: update,
9697
- dense: dense
10298
+ dense: dense,
10299
+ selectDisabled: selectDisabled,
10300
+ keyboard: keyboard
9698
10301
  });
9699
10302
  })));
9700
10303
  }
9701
10304
 
10305
+ function ListBoxFetchMasterItem(_ref) {
10306
+ let {
10307
+ app,
10308
+ fieldIdentifier,
10309
+ stateName = '$',
10310
+ options = {}
10311
+ } = _ref;
10312
+ const [fieldDef, setFieldDef] = useState$1('');
10313
+ const [isFetchingData, setIsFetchingData] = useState$1(false);
10314
+ useEffect$1(() => {
10315
+ async function fetchData() {
10316
+ setIsFetchingData(true);
10317
+
10318
+ try {
10319
+ const dim = await app.getDimension(fieldIdentifier.qLibraryId);
10320
+ const dimLayout = await dim.getLayout();
10321
+ setFieldDef(dimLayout.qDim.qFieldDefs ? dimLayout.qDim.qFieldDefs[0] : '');
10322
+ setIsFetchingData(false);
10323
+ } catch (e) {
10324
+ setIsFetchingData(false);
10325
+ setFieldDef({
10326
+ failedToFetchFieldDef: true
10327
+ });
10328
+ throw new Error("Disabling frequency count and histogram: ".concat(e && e.message));
10329
+ }
10330
+ }
10331
+
10332
+ fetchData();
10333
+ }, []);
10334
+
10335
+ if (isFetchingData) {
10336
+ return null;
10337
+ }
10338
+
10339
+ return /*#__PURE__*/React.createElement(ListBoxInline, {
10340
+ app: app,
10341
+ fieldIdentifier: fieldIdentifier,
10342
+ stateName: stateName,
10343
+ options: options,
10344
+ fieldDef: fieldDef
10345
+ });
10346
+ }
10347
+ function ListBoxPortal(_ref2) {
10348
+ let {
10349
+ app,
10350
+ fieldIdentifier,
10351
+ stateName,
10352
+ element,
10353
+ options
10354
+ } = _ref2;
10355
+ const isFrequencyMaxNeeded = options.histogram || options.frequencyMode !== 'N';
10356
+ const TheComponent = fieldIdentifier.qLibraryId && isFrequencyMaxNeeded ? ListBoxFetchMasterItem : ListBoxInline;
10357
+ return ReactDOM.createPortal( /*#__PURE__*/React.createElement(TheComponent, {
10358
+ app: app,
10359
+ fieldIdentifier: fieldIdentifier,
10360
+ stateName: stateName,
10361
+ element: element,
10362
+ options: options
10363
+ }), element);
10364
+ }
10365
+
9702
10366
  const idGen = [[10, 31], [0, 31], [0, 31], [0, 31], [0, 31], [0, 31]];
9703
10367
 
9704
10368
  function toChar(_ref) {
@@ -10034,7 +10698,7 @@ const setValue = (data, reference, value) => {
10034
10698
  dataContainer = dataContainer[step];
10035
10699
  }
10036
10700
 
10037
- if (typeof value !== 'undefined') {
10701
+ if (typeof value !== 'undefined' && propertyName !== '__proto__' && propertyName !== 'constructor') {
10038
10702
  dataContainer[propertyName] = value;
10039
10703
  } else {
10040
10704
  delete dataContainer[propertyName];
@@ -10874,7 +11538,7 @@ var WarningTriangle = (props => SvgIcon(warning(props)));
10874
11538
 
10875
11539
  /* eslint-disable react/no-array-index-key */
10876
11540
 
10877
- const DescriptionRow = _ref => {
11541
+ function DescriptionRow(_ref) {
10878
11542
  let {
10879
11543
  d
10880
11544
  } = _ref;
@@ -10931,9 +11595,9 @@ const DescriptionRow = _ref => {
10931
11595
  fontWeight: 400
10932
11596
  }
10933
11597
  }, d.label))));
10934
- };
11598
+ }
10935
11599
 
10936
- const Descriptions = _ref2 => {
11600
+ function Descriptions(_ref2) {
10937
11601
  let {
10938
11602
  data
10939
11603
  } = _ref2;
@@ -10966,7 +11630,7 @@ const Descriptions = _ref2 => {
10966
11630
  color: "textSecondary"
10967
11631
  }, e.title), Rows);
10968
11632
  }));
10969
- };
11633
+ }
10970
11634
 
10971
11635
  function Error$1(_ref3) {
10972
11636
  let {
@@ -11071,7 +11735,7 @@ const useStyles$2 = makeStyles$1(() => ({
11071
11735
  }
11072
11736
  }
11073
11737
  }));
11074
- const Cancel = _ref => {
11738
+ function Cancel(_ref) {
11075
11739
  let {
11076
11740
  cancel,
11077
11741
  translator
@@ -11090,15 +11754,16 @@ const Cancel = _ref => {
11090
11754
  item: true
11091
11755
  }, /*#__PURE__*/React.createElement(Typography, {
11092
11756
  variant: "h6",
11093
- align: "center"
11757
+ align: "center",
11758
+ "data-tid": "update-active"
11094
11759
  }, translator.get('Object.Update.Active')))), /*#__PURE__*/React.createElement(Grid, _extends$4({
11095
11760
  item: true
11096
11761
  }, props), /*#__PURE__*/React.createElement(Button, {
11097
11762
  variant: "contained",
11098
11763
  onClick: cancel
11099
11764
  }, translator.get('Cancel'))));
11100
- };
11101
- const Retry = _ref2 => {
11765
+ }
11766
+ function Retry(_ref2) {
11102
11767
  let {
11103
11768
  retry,
11104
11769
  translator
@@ -11115,14 +11780,15 @@ const Retry = _ref2 => {
11115
11780
  item: true
11116
11781
  }, /*#__PURE__*/React.createElement(Typography, {
11117
11782
  variant: "h6",
11118
- align: "center"
11783
+ align: "center",
11784
+ "data-tid": "update-cancelled"
11119
11785
  }, translator.get('Object.Update.Cancelled'))), /*#__PURE__*/React.createElement(Grid, {
11120
11786
  item: true
11121
11787
  }, /*#__PURE__*/React.createElement(Button, _extends$4({
11122
11788
  variant: "contained",
11123
11789
  onClick: retry
11124
11790
  }, props), translator.get('Retry'))));
11125
- };
11791
+ }
11126
11792
  function LongRunningQuery(_ref3) {
11127
11793
  let {
11128
11794
  canCancel,
@@ -11216,7 +11882,7 @@ const useStyles$1 = makeStyles$1(theme => ({
11216
11882
  }
11217
11883
  }));
11218
11884
 
11219
- const Header = _ref => {
11885
+ function Header(_ref) {
11220
11886
  let {
11221
11887
  layout,
11222
11888
  sn,
@@ -11293,7 +11959,7 @@ const Header = _ref => {
11293
11959
  }, layout.subtitle))), /*#__PURE__*/React.createElement(Grid, {
11294
11960
  item: true
11295
11961
  }, Toolbar));
11296
- };
11962
+ }
11297
11963
 
11298
11964
  /**
11299
11965
  * @interface
@@ -11312,7 +11978,7 @@ const useStyles = makeStyles$1(theme => ({
11312
11978
  }
11313
11979
  }));
11314
11980
 
11315
- const Footer = _ref => {
11981
+ function Footer(_ref) {
11316
11982
  let {
11317
11983
  layout
11318
11984
  } = _ref;
@@ -11329,7 +11995,7 @@ const Footer = _ref => {
11329
11995
  variant: "body2",
11330
11996
  className: CellFooter.className
11331
11997
  }, layout.footnote))) : null;
11332
- };
11998
+ }
11333
11999
 
11334
12000
  class RenderDebouncer {
11335
12001
  constructor() {
@@ -11399,7 +12065,7 @@ const VizElement = {
11399
12065
  className: 'njs-viz'
11400
12066
  };
11401
12067
 
11402
- const Supernova = _ref => {
12068
+ function Supernova(_ref) {
11403
12069
  let {
11404
12070
  sn,
11405
12071
  snOptions: options,
@@ -11519,7 +12185,7 @@ const Supernova = _ref => {
11519
12185
  height: '100%'
11520
12186
  }
11521
12187
  }));
11522
- };
12188
+ }
11523
12189
 
11524
12190
  /**
11525
12191
  * @interface
@@ -11597,7 +12263,7 @@ const contentReducer = (state, action) => {
11597
12263
  }
11598
12264
  };
11599
12265
 
11600
- const LoadingSn = _ref => {
12266
+ function LoadingSn(_ref) {
11601
12267
  let {
11602
12268
  delay = 750
11603
12269
  } = _ref;
@@ -11607,7 +12273,7 @@ const LoadingSn = _ref => {
11607
12273
  return () => clearTimeout(handle);
11608
12274
  }, []);
11609
12275
  return showLoading ? /*#__PURE__*/React.createElement(Loading, null) : null;
11610
- };
12276
+ }
11611
12277
 
11612
12278
  const handleModal = _ref2 => {
11613
12279
  let {
@@ -12182,7 +12848,8 @@ function isEqual(a, b) {
12182
12848
  }
12183
12849
 
12184
12850
  return a === b;
12185
- }
12851
+ } // eslint-disable-next-line default-param-last
12852
+
12186
12853
 
12187
12854
  function getPatches() {
12188
12855
  let path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
@@ -13054,7 +13721,7 @@ function actionhero (_ref) {
13054
13721
  /* eslint no-console: 0 */
13055
13722
 
13056
13723
  /* eslint no-use-before-define: 0 */
13057
- // Hooks implementation heavily inspired by prect hooks
13724
+ // Hooks implementation heavily inspired by preact hooks
13058
13725
  let currentComponent;
13059
13726
  let currentIndex;
13060
13727
 
@@ -14864,1556 +15531,1603 @@ function generatorFn(UserSN, galaxy) {
14864
15531
  var semver = {exports: {}};
14865
15532
 
14866
15533
  (function (module, exports) {
14867
- exports = module.exports = SemVer;
14868
- var debug;
14869
- /* istanbul ignore next */
14870
-
14871
- if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
14872
- debug = function () {
14873
- var args = Array.prototype.slice.call(arguments, 0);
14874
- args.unshift('SEMVER');
14875
- console.log.apply(console, args);
14876
- };
14877
- } else {
14878
- debug = function () {};
14879
- } // Note: this is the semver.org version of the spec that it implements
14880
- // Not necessarily the package version of this code.
14881
-
14882
-
14883
- exports.SEMVER_SPEC_VERSION = '2.0.0';
14884
- var MAX_LENGTH = 256;
14885
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
14886
- /* istanbul ignore next */
14887
- 9007199254740991; // Max safe segment length for coercion.
14888
-
14889
- var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
14890
-
14891
- var re = exports.re = [];
14892
- var src = exports.src = [];
14893
- var t = exports.tokens = {};
14894
- var R = 0;
14895
-
14896
- function tok(n) {
14897
- t[n] = R++;
14898
- } // The following Regular Expressions can be used for tokenizing,
14899
- // validating, and parsing SemVer version strings.
14900
- // ## Numeric Identifier
14901
- // A single `0`, or a non-zero digit followed by zero or more digits.
14902
-
14903
-
14904
- tok('NUMERICIDENTIFIER');
14905
- src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
14906
- tok('NUMERICIDENTIFIERLOOSE');
14907
- src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
14908
- // Zero or more digits, followed by a letter or hyphen, and then zero or
14909
- // more letters, digits, or hyphens.
14910
-
14911
- tok('NONNUMERICIDENTIFIER');
14912
- src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
14913
- // Three dot-separated numeric identifiers.
14914
-
14915
- tok('MAINVERSION');
14916
- src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')';
14917
- tok('MAINVERSIONLOOSE');
14918
- src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
14919
- // A numeric identifier, or a non-numeric identifier.
14920
-
14921
- tok('PRERELEASEIDENTIFIER');
14922
- src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
14923
- tok('PRERELEASEIDENTIFIERLOOSE');
14924
- src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + '|' + src[t.NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
14925
- // Hyphen, followed by one or more dot-separated pre-release version
14926
- // identifiers.
14927
-
14928
- tok('PRERELEASE');
14929
- src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
14930
- tok('PRERELEASELOOSE');
14931
- src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
14932
- // Any combination of digits, letters, or hyphens.
14933
-
14934
- tok('BUILDIDENTIFIER');
14935
- src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
14936
- // Plus sign, followed by one or more period-separated build metadata
14937
- // identifiers.
14938
-
14939
- tok('BUILD');
14940
- src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'; // ## Full Version String
14941
- // A main version, followed optionally by a pre-release version and
14942
- // build metadata.
14943
- // Note that the only major, minor, patch, and pre-release sections of
14944
- // the version string are capturing groups. The build metadata is not a
14945
- // capturing group, because it should not ever be used in version
14946
- // comparison.
14947
-
14948
- tok('FULL');
14949
- tok('FULLPLAIN');
14950
- src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?';
14951
- src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
14952
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
14953
- // common in the npm registry.
14954
-
14955
- tok('LOOSEPLAIN');
14956
- src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + '?' + src[t.BUILD] + '?';
14957
- tok('LOOSE');
14958
- src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
14959
- tok('GTLT');
14960
- src[t.GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
14961
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
14962
- // Only the first item is strictly required.
14963
-
14964
- tok('XRANGEIDENTIFIERLOOSE');
14965
- src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
14966
- tok('XRANGEIDENTIFIER');
14967
- src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
14968
- tok('XRANGEPLAIN');
14969
- src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:' + src[t.PRERELEASE] + ')?' + src[t.BUILD] + '?' + ')?)?';
14970
- tok('XRANGEPLAINLOOSE');
14971
- src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[t.PRERELEASELOOSE] + ')?' + src[t.BUILD] + '?' + ')?)?';
14972
- tok('XRANGE');
14973
- src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
14974
- tok('XRANGELOOSE');
14975
- src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'; // Coercion.
14976
- // Extract anything that could conceivably be a part of a valid semver
14977
-
14978
- tok('COERCE');
14979
- src[t.COERCE] = '(^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
14980
- tok('COERCERTL');
14981
- re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g'); // Tilde ranges.
14982
- // Meaning is "reasonably at or greater than"
14983
-
14984
- tok('LONETILDE');
14985
- src[t.LONETILDE] = '(?:~>?)';
14986
- tok('TILDETRIM');
14987
- src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
14988
- re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
14989
- var tildeTrimReplace = '$1~';
14990
- tok('TILDE');
14991
- src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
14992
- tok('TILDELOOSE');
14993
- src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'; // Caret ranges.
14994
- // Meaning is "at least and backwards compatible with"
14995
-
14996
- tok('LONECARET');
14997
- src[t.LONECARET] = '(?:\\^)';
14998
- tok('CARETTRIM');
14999
- src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
15000
- re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
15001
- var caretTrimReplace = '$1^';
15002
- tok('CARET');
15003
- src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
15004
- tok('CARETLOOSE');
15005
- src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
15006
-
15007
- tok('COMPARATORLOOSE');
15008
- src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
15009
- tok('COMPARATOR');
15010
- src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
15011
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
15012
-
15013
- tok('COMPARATORTRIM');
15014
- src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'; // this one has to use the /g flag
15015
-
15016
- re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
15017
- var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
15018
- // Note that these all use the loose form, because they'll be
15019
- // checked against either the strict or loose comparator form
15020
- // later.
15021
-
15022
- tok('HYPHENRANGE');
15023
- src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAIN] + ')' + '\\s*$';
15024
- tok('HYPHENRANGELOOSE');
15025
- src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
15026
-
15027
- tok('STAR');
15028
- src[t.STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
15029
- // All are flag-free, unless they were created above with a flag.
15030
-
15031
- for (var i = 0; i < R; i++) {
15032
- debug(i, src[i]);
15033
-
15034
- if (!re[i]) {
15035
- re[i] = new RegExp(src[i]);
15036
- }
15037
- }
15038
-
15039
- exports.parse = parse;
15040
-
15041
- function parse(version, options) {
15042
- if (!options || typeof options !== 'object') {
15043
- options = {
15044
- loose: !!options,
15045
- includePrerelease: false
15046
- };
15047
- }
15048
-
15049
- if (version instanceof SemVer) {
15050
- return version;
15051
- }
15534
+ exports = module.exports = SemVer;
15535
+
15536
+ var debug;
15537
+ /* istanbul ignore next */
15538
+ if (typeof process === 'object' &&
15539
+ process.env &&
15540
+ process.env.NODE_DEBUG &&
15541
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
15542
+ debug = function () {
15543
+ var args = Array.prototype.slice.call(arguments, 0);
15544
+ args.unshift('SEMVER');
15545
+ console.log.apply(console, args);
15546
+ };
15547
+ } else {
15548
+ debug = function () {};
15549
+ }
15052
15550
 
15053
- if (typeof version !== 'string') {
15054
- return null;
15055
- }
15551
+ // Note: this is the semver.org version of the spec that it implements
15552
+ // Not necessarily the package version of this code.
15553
+ exports.SEMVER_SPEC_VERSION = '2.0.0';
15056
15554
 
15057
- if (version.length > MAX_LENGTH) {
15058
- return null;
15059
- }
15555
+ var MAX_LENGTH = 256;
15556
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
15557
+ /* istanbul ignore next */ 9007199254740991;
15060
15558
 
15061
- var r = options.loose ? re[t.LOOSE] : re[t.FULL];
15559
+ // Max safe segment length for coercion.
15560
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
15062
15561
 
15063
- if (!r.test(version)) {
15064
- return null;
15065
- }
15562
+ // The actual regexps go on exports.re
15563
+ var re = exports.re = [];
15564
+ var src = exports.src = [];
15565
+ var t = exports.tokens = {};
15566
+ var R = 0;
15066
15567
 
15067
- try {
15068
- return new SemVer(version, options);
15069
- } catch (er) {
15070
- return null;
15071
- }
15072
- }
15568
+ function tok (n) {
15569
+ t[n] = R++;
15570
+ }
15073
15571
 
15074
- exports.valid = valid;
15572
+ // The following Regular Expressions can be used for tokenizing,
15573
+ // validating, and parsing SemVer version strings.
15075
15574
 
15076
- function valid(version, options) {
15077
- var v = parse(version, options);
15078
- return v ? v.version : null;
15079
- }
15575
+ // ## Numeric Identifier
15576
+ // A single `0`, or a non-zero digit followed by zero or more digits.
15080
15577
 
15081
- exports.clean = clean;
15578
+ tok('NUMERICIDENTIFIER');
15579
+ src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
15580
+ tok('NUMERICIDENTIFIERLOOSE');
15581
+ src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
15082
15582
 
15083
- function clean(version, options) {
15084
- var s = parse(version.trim().replace(/^[=v]+/, ''), options);
15085
- return s ? s.version : null;
15086
- }
15583
+ // ## Non-numeric Identifier
15584
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
15585
+ // more letters, digits, or hyphens.
15087
15586
 
15088
- exports.SemVer = SemVer;
15587
+ tok('NONNUMERICIDENTIFIER');
15588
+ src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
15089
15589
 
15090
- function SemVer(version, options) {
15091
- if (!options || typeof options !== 'object') {
15092
- options = {
15093
- loose: !!options,
15094
- includePrerelease: false
15095
- };
15096
- }
15590
+ // ## Main Version
15591
+ // Three dot-separated numeric identifiers.
15592
+
15593
+ tok('MAINVERSION');
15594
+ src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
15595
+ '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
15596
+ '(' + src[t.NUMERICIDENTIFIER] + ')';
15597
+
15598
+ tok('MAINVERSIONLOOSE');
15599
+ src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
15600
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
15601
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
15602
+
15603
+ // ## Pre-release Version Identifier
15604
+ // A numeric identifier, or a non-numeric identifier.
15605
+
15606
+ tok('PRERELEASEIDENTIFIER');
15607
+ src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
15608
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
15609
+
15610
+ tok('PRERELEASEIDENTIFIERLOOSE');
15611
+ src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
15612
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
15613
+
15614
+ // ## Pre-release Version
15615
+ // Hyphen, followed by one or more dot-separated pre-release version
15616
+ // identifiers.
15617
+
15618
+ tok('PRERELEASE');
15619
+ src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
15620
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
15621
+
15622
+ tok('PRERELEASELOOSE');
15623
+ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
15624
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
15625
+
15626
+ // ## Build Metadata Identifier
15627
+ // Any combination of digits, letters, or hyphens.
15628
+
15629
+ tok('BUILDIDENTIFIER');
15630
+ src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
15631
+
15632
+ // ## Build Metadata
15633
+ // Plus sign, followed by one or more period-separated build metadata
15634
+ // identifiers.
15635
+
15636
+ tok('BUILD');
15637
+ src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
15638
+ '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
15639
+
15640
+ // ## Full Version String
15641
+ // A main version, followed optionally by a pre-release version and
15642
+ // build metadata.
15643
+
15644
+ // Note that the only major, minor, patch, and pre-release sections of
15645
+ // the version string are capturing groups. The build metadata is not a
15646
+ // capturing group, because it should not ever be used in version
15647
+ // comparison.
15648
+
15649
+ tok('FULL');
15650
+ tok('FULLPLAIN');
15651
+ src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
15652
+ src[t.PRERELEASE] + '?' +
15653
+ src[t.BUILD] + '?';
15654
+
15655
+ src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
15656
+
15657
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
15658
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
15659
+ // common in the npm registry.
15660
+ tok('LOOSEPLAIN');
15661
+ src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
15662
+ src[t.PRERELEASELOOSE] + '?' +
15663
+ src[t.BUILD] + '?';
15664
+
15665
+ tok('LOOSE');
15666
+ src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
15667
+
15668
+ tok('GTLT');
15669
+ src[t.GTLT] = '((?:<|>)?=?)';
15670
+
15671
+ // Something like "2.*" or "1.2.x".
15672
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
15673
+ // Only the first item is strictly required.
15674
+ tok('XRANGEIDENTIFIERLOOSE');
15675
+ src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
15676
+ tok('XRANGEIDENTIFIER');
15677
+ src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
15678
+
15679
+ tok('XRANGEPLAIN');
15680
+ src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
15681
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
15682
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
15683
+ '(?:' + src[t.PRERELEASE] + ')?' +
15684
+ src[t.BUILD] + '?' +
15685
+ ')?)?';
15686
+
15687
+ tok('XRANGEPLAINLOOSE');
15688
+ src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
15689
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
15690
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
15691
+ '(?:' + src[t.PRERELEASELOOSE] + ')?' +
15692
+ src[t.BUILD] + '?' +
15693
+ ')?)?';
15694
+
15695
+ tok('XRANGE');
15696
+ src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
15697
+ tok('XRANGELOOSE');
15698
+ src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
15699
+
15700
+ // Coercion.
15701
+ // Extract anything that could conceivably be a part of a valid semver
15702
+ tok('COERCE');
15703
+ src[t.COERCE] = '(^|[^\\d])' +
15704
+ '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
15705
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
15706
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
15707
+ '(?:$|[^\\d])';
15708
+ tok('COERCERTL');
15709
+ re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
15710
+
15711
+ // Tilde ranges.
15712
+ // Meaning is "reasonably at or greater than"
15713
+ tok('LONETILDE');
15714
+ src[t.LONETILDE] = '(?:~>?)';
15715
+
15716
+ tok('TILDETRIM');
15717
+ src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
15718
+ re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
15719
+ var tildeTrimReplace = '$1~';
15720
+
15721
+ tok('TILDE');
15722
+ src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
15723
+ tok('TILDELOOSE');
15724
+ src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
15725
+
15726
+ // Caret ranges.
15727
+ // Meaning is "at least and backwards compatible with"
15728
+ tok('LONECARET');
15729
+ src[t.LONECARET] = '(?:\\^)';
15730
+
15731
+ tok('CARETTRIM');
15732
+ src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
15733
+ re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
15734
+ var caretTrimReplace = '$1^';
15735
+
15736
+ tok('CARET');
15737
+ src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
15738
+ tok('CARETLOOSE');
15739
+ src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
15740
+
15741
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
15742
+ tok('COMPARATORLOOSE');
15743
+ src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
15744
+ tok('COMPARATOR');
15745
+ src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
15746
+
15747
+ // An expression to strip any whitespace between the gtlt and the thing
15748
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
15749
+ tok('COMPARATORTRIM');
15750
+ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
15751
+ '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
15752
+
15753
+ // this one has to use the /g flag
15754
+ re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
15755
+ var comparatorTrimReplace = '$1$2$3';
15756
+
15757
+ // Something like `1.2.3 - 1.2.4`
15758
+ // Note that these all use the loose form, because they'll be
15759
+ // checked against either the strict or loose comparator form
15760
+ // later.
15761
+ tok('HYPHENRANGE');
15762
+ src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
15763
+ '\\s+-\\s+' +
15764
+ '(' + src[t.XRANGEPLAIN] + ')' +
15765
+ '\\s*$';
15766
+
15767
+ tok('HYPHENRANGELOOSE');
15768
+ src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
15769
+ '\\s+-\\s+' +
15770
+ '(' + src[t.XRANGEPLAINLOOSE] + ')' +
15771
+ '\\s*$';
15772
+
15773
+ // Star ranges basically just allow anything at all.
15774
+ tok('STAR');
15775
+ src[t.STAR] = '(<|>)?=?\\s*\\*';
15776
+
15777
+ // Compile to actual regexp objects.
15778
+ // All are flag-free, unless they were created above with a flag.
15779
+ for (var i = 0; i < R; i++) {
15780
+ debug(i, src[i]);
15781
+ if (!re[i]) {
15782
+ re[i] = new RegExp(src[i]);
15783
+ }
15784
+ }
15785
+
15786
+ exports.parse = parse;
15787
+ function parse (version, options) {
15788
+ if (!options || typeof options !== 'object') {
15789
+ options = {
15790
+ loose: !!options,
15791
+ includePrerelease: false
15792
+ };
15793
+ }
15097
15794
 
15098
- if (version instanceof SemVer) {
15099
- if (version.loose === options.loose) {
15100
- return version;
15101
- } else {
15102
- version = version.version;
15103
- }
15104
- } else if (typeof version !== 'string') {
15105
- throw new TypeError('Invalid Version: ' + version);
15106
- }
15795
+ if (version instanceof SemVer) {
15796
+ return version
15797
+ }
15107
15798
 
15108
- if (version.length > MAX_LENGTH) {
15109
- throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
15110
- }
15799
+ if (typeof version !== 'string') {
15800
+ return null
15801
+ }
15111
15802
 
15112
- if (!(this instanceof SemVer)) {
15113
- return new SemVer(version, options);
15114
- }
15803
+ if (version.length > MAX_LENGTH) {
15804
+ return null
15805
+ }
15115
15806
 
15116
- debug('SemVer', version, options);
15117
- this.options = options;
15118
- this.loose = !!options.loose;
15119
- var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
15807
+ var r = options.loose ? re[t.LOOSE] : re[t.FULL];
15808
+ if (!r.test(version)) {
15809
+ return null
15810
+ }
15120
15811
 
15121
- if (!m) {
15122
- throw new TypeError('Invalid Version: ' + version);
15123
- }
15812
+ try {
15813
+ return new SemVer(version, options)
15814
+ } catch (er) {
15815
+ return null
15816
+ }
15817
+ }
15124
15818
 
15125
- this.raw = version; // these are actually numbers
15819
+ exports.valid = valid;
15820
+ function valid (version, options) {
15821
+ var v = parse(version, options);
15822
+ return v ? v.version : null
15823
+ }
15126
15824
 
15127
- this.major = +m[1];
15128
- this.minor = +m[2];
15129
- this.patch = +m[3];
15825
+ exports.clean = clean;
15826
+ function clean (version, options) {
15827
+ var s = parse(version.trim().replace(/^[=v]+/, ''), options);
15828
+ return s ? s.version : null
15829
+ }
15130
15830
 
15131
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
15132
- throw new TypeError('Invalid major version');
15133
- }
15831
+ exports.SemVer = SemVer;
15134
15832
 
15135
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
15136
- throw new TypeError('Invalid minor version');
15833
+ function SemVer (version, options) {
15834
+ if (!options || typeof options !== 'object') {
15835
+ options = {
15836
+ loose: !!options,
15837
+ includePrerelease: false
15838
+ };
15839
+ }
15840
+ if (version instanceof SemVer) {
15841
+ if (version.loose === options.loose) {
15842
+ return version
15843
+ } else {
15844
+ version = version.version;
15137
15845
  }
15846
+ } else if (typeof version !== 'string') {
15847
+ throw new TypeError('Invalid Version: ' + version)
15848
+ }
15138
15849
 
15139
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
15140
- throw new TypeError('Invalid patch version');
15141
- } // numberify any prerelease numeric ids
15142
-
15850
+ if (version.length > MAX_LENGTH) {
15851
+ throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
15852
+ }
15143
15853
 
15144
- if (!m[4]) {
15145
- this.prerelease = [];
15146
- } else {
15147
- this.prerelease = m[4].split('.').map(function (id) {
15148
- if (/^[0-9]+$/.test(id)) {
15149
- var num = +id;
15854
+ if (!(this instanceof SemVer)) {
15855
+ return new SemVer(version, options)
15856
+ }
15150
15857
 
15151
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
15152
- return num;
15153
- }
15154
- }
15858
+ debug('SemVer', version, options);
15859
+ this.options = options;
15860
+ this.loose = !!options.loose;
15155
15861
 
15156
- return id;
15157
- });
15158
- }
15862
+ var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
15159
15863
 
15160
- this.build = m[5] ? m[5].split('.') : [];
15161
- this.format();
15864
+ if (!m) {
15865
+ throw new TypeError('Invalid Version: ' + version)
15162
15866
  }
15163
15867
 
15164
- SemVer.prototype.format = function () {
15165
- this.version = this.major + '.' + this.minor + '.' + this.patch;
15868
+ this.raw = version;
15166
15869
 
15167
- if (this.prerelease.length) {
15168
- this.version += '-' + this.prerelease.join('.');
15169
- }
15170
-
15171
- return this.version;
15172
- };
15173
-
15174
- SemVer.prototype.toString = function () {
15175
- return this.version;
15176
- };
15870
+ // these are actually numbers
15871
+ this.major = +m[1];
15872
+ this.minor = +m[2];
15873
+ this.patch = +m[3];
15177
15874
 
15178
- SemVer.prototype.compare = function (other) {
15179
- debug('SemVer.compare', this.version, this.options, other);
15875
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
15876
+ throw new TypeError('Invalid major version')
15877
+ }
15180
15878
 
15181
- if (!(other instanceof SemVer)) {
15182
- other = new SemVer(other, this.options);
15183
- }
15879
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
15880
+ throw new TypeError('Invalid minor version')
15881
+ }
15184
15882
 
15185
- return this.compareMain(other) || this.comparePre(other);
15186
- };
15883
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
15884
+ throw new TypeError('Invalid patch version')
15885
+ }
15187
15886
 
15188
- SemVer.prototype.compareMain = function (other) {
15189
- if (!(other instanceof SemVer)) {
15190
- other = new SemVer(other, this.options);
15191
- }
15887
+ // numberify any prerelease numeric ids
15888
+ if (!m[4]) {
15889
+ this.prerelease = [];
15890
+ } else {
15891
+ this.prerelease = m[4].split('.').map(function (id) {
15892
+ if (/^[0-9]+$/.test(id)) {
15893
+ var num = +id;
15894
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
15895
+ return num
15896
+ }
15897
+ }
15898
+ return id
15899
+ });
15900
+ }
15192
15901
 
15193
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
15194
- };
15902
+ this.build = m[5] ? m[5].split('.') : [];
15903
+ this.format();
15904
+ }
15195
15905
 
15196
- SemVer.prototype.comparePre = function (other) {
15197
- if (!(other instanceof SemVer)) {
15198
- other = new SemVer(other, this.options);
15199
- } // NOT having a prerelease is > having one
15906
+ SemVer.prototype.format = function () {
15907
+ this.version = this.major + '.' + this.minor + '.' + this.patch;
15908
+ if (this.prerelease.length) {
15909
+ this.version += '-' + this.prerelease.join('.');
15910
+ }
15911
+ return this.version
15912
+ };
15200
15913
 
15914
+ SemVer.prototype.toString = function () {
15915
+ return this.version
15916
+ };
15201
15917
 
15202
- if (this.prerelease.length && !other.prerelease.length) {
15203
- return -1;
15204
- } else if (!this.prerelease.length && other.prerelease.length) {
15205
- return 1;
15206
- } else if (!this.prerelease.length && !other.prerelease.length) {
15207
- return 0;
15208
- }
15918
+ SemVer.prototype.compare = function (other) {
15919
+ debug('SemVer.compare', this.version, this.options, other);
15920
+ if (!(other instanceof SemVer)) {
15921
+ other = new SemVer(other, this.options);
15922
+ }
15209
15923
 
15210
- var i = 0;
15924
+ return this.compareMain(other) || this.comparePre(other)
15925
+ };
15211
15926
 
15212
- do {
15213
- var a = this.prerelease[i];
15214
- var b = other.prerelease[i];
15215
- debug('prerelease compare', i, a, b);
15927
+ SemVer.prototype.compareMain = function (other) {
15928
+ if (!(other instanceof SemVer)) {
15929
+ other = new SemVer(other, this.options);
15930
+ }
15216
15931
 
15217
- if (a === undefined && b === undefined) {
15218
- return 0;
15219
- } else if (b === undefined) {
15220
- return 1;
15221
- } else if (a === undefined) {
15222
- return -1;
15223
- } else if (a === b) {
15224
- continue;
15225
- } else {
15226
- return compareIdentifiers(a, b);
15227
- }
15228
- } while (++i);
15229
- };
15932
+ return compareIdentifiers(this.major, other.major) ||
15933
+ compareIdentifiers(this.minor, other.minor) ||
15934
+ compareIdentifiers(this.patch, other.patch)
15935
+ };
15230
15936
 
15231
- SemVer.prototype.compareBuild = function (other) {
15232
- if (!(other instanceof SemVer)) {
15233
- other = new SemVer(other, this.options);
15937
+ SemVer.prototype.comparePre = function (other) {
15938
+ if (!(other instanceof SemVer)) {
15939
+ other = new SemVer(other, this.options);
15940
+ }
15941
+
15942
+ // NOT having a prerelease is > having one
15943
+ if (this.prerelease.length && !other.prerelease.length) {
15944
+ return -1
15945
+ } else if (!this.prerelease.length && other.prerelease.length) {
15946
+ return 1
15947
+ } else if (!this.prerelease.length && !other.prerelease.length) {
15948
+ return 0
15949
+ }
15950
+
15951
+ var i = 0;
15952
+ do {
15953
+ var a = this.prerelease[i];
15954
+ var b = other.prerelease[i];
15955
+ debug('prerelease compare', i, a, b);
15956
+ if (a === undefined && b === undefined) {
15957
+ return 0
15958
+ } else if (b === undefined) {
15959
+ return 1
15960
+ } else if (a === undefined) {
15961
+ return -1
15962
+ } else if (a === b) {
15963
+ continue
15964
+ } else {
15965
+ return compareIdentifiers(a, b)
15234
15966
  }
15967
+ } while (++i)
15968
+ };
15235
15969
 
15236
- var i = 0;
15237
-
15238
- do {
15239
- var a = this.build[i];
15240
- var b = other.build[i];
15241
- debug('prerelease compare', i, a, b);
15970
+ SemVer.prototype.compareBuild = function (other) {
15971
+ if (!(other instanceof SemVer)) {
15972
+ other = new SemVer(other, this.options);
15973
+ }
15974
+
15975
+ var i = 0;
15976
+ do {
15977
+ var a = this.build[i];
15978
+ var b = other.build[i];
15979
+ debug('prerelease compare', i, a, b);
15980
+ if (a === undefined && b === undefined) {
15981
+ return 0
15982
+ } else if (b === undefined) {
15983
+ return 1
15984
+ } else if (a === undefined) {
15985
+ return -1
15986
+ } else if (a === b) {
15987
+ continue
15988
+ } else {
15989
+ return compareIdentifiers(a, b)
15990
+ }
15991
+ } while (++i)
15992
+ };
15242
15993
 
15243
- if (a === undefined && b === undefined) {
15244
- return 0;
15245
- } else if (b === undefined) {
15246
- return 1;
15247
- } else if (a === undefined) {
15248
- return -1;
15249
- } else if (a === b) {
15250
- continue;
15251
- } else {
15252
- return compareIdentifiers(a, b);
15994
+ // preminor will bump the version up to the next minor release, and immediately
15995
+ // down to pre-release. premajor and prepatch work the same way.
15996
+ SemVer.prototype.inc = function (release, identifier) {
15997
+ switch (release) {
15998
+ case 'premajor':
15999
+ this.prerelease.length = 0;
16000
+ this.patch = 0;
16001
+ this.minor = 0;
16002
+ this.major++;
16003
+ this.inc('pre', identifier);
16004
+ break
16005
+ case 'preminor':
16006
+ this.prerelease.length = 0;
16007
+ this.patch = 0;
16008
+ this.minor++;
16009
+ this.inc('pre', identifier);
16010
+ break
16011
+ case 'prepatch':
16012
+ // If this is already a prerelease, it will bump to the next version
16013
+ // drop any prereleases that might already exist, since they are not
16014
+ // relevant at this point.
16015
+ this.prerelease.length = 0;
16016
+ this.inc('patch', identifier);
16017
+ this.inc('pre', identifier);
16018
+ break
16019
+ // If the input is a non-prerelease version, this acts the same as
16020
+ // prepatch.
16021
+ case 'prerelease':
16022
+ if (this.prerelease.length === 0) {
16023
+ this.inc('patch', identifier);
15253
16024
  }
15254
- } while (++i);
15255
- }; // preminor will bump the version up to the next minor release, and immediately
15256
- // down to pre-release. premajor and prepatch work the same way.
15257
-
15258
-
15259
- SemVer.prototype.inc = function (release, identifier) {
15260
- switch (release) {
15261
- case 'premajor':
15262
- this.prerelease.length = 0;
15263
- this.patch = 0;
15264
- this.minor = 0;
16025
+ this.inc('pre', identifier);
16026
+ break
16027
+
16028
+ case 'major':
16029
+ // If this is a pre-major version, bump up to the same major version.
16030
+ // Otherwise increment major.
16031
+ // 1.0.0-5 bumps to 1.0.0
16032
+ // 1.1.0 bumps to 2.0.0
16033
+ if (this.minor !== 0 ||
16034
+ this.patch !== 0 ||
16035
+ this.prerelease.length === 0) {
15265
16036
  this.major++;
15266
- this.inc('pre', identifier);
15267
- break;
15268
-
15269
- case 'preminor':
15270
- this.prerelease.length = 0;
15271
- this.patch = 0;
16037
+ }
16038
+ this.minor = 0;
16039
+ this.patch = 0;
16040
+ this.prerelease = [];
16041
+ break
16042
+ case 'minor':
16043
+ // If this is a pre-minor version, bump up to the same minor version.
16044
+ // Otherwise increment minor.
16045
+ // 1.2.0-5 bumps to 1.2.0
16046
+ // 1.2.1 bumps to 1.3.0
16047
+ if (this.patch !== 0 || this.prerelease.length === 0) {
15272
16048
  this.minor++;
15273
- this.inc('pre', identifier);
15274
- break;
15275
-
15276
- case 'prepatch':
15277
- // If this is already a prerelease, it will bump to the next version
15278
- // drop any prereleases that might already exist, since they are not
15279
- // relevant at this point.
15280
- this.prerelease.length = 0;
15281
- this.inc('patch', identifier);
15282
- this.inc('pre', identifier);
15283
- break;
15284
- // If the input is a non-prerelease version, this acts the same as
15285
- // prepatch.
15286
-
15287
- case 'prerelease':
15288
- if (this.prerelease.length === 0) {
15289
- this.inc('patch', identifier);
15290
- }
15291
-
15292
- this.inc('pre', identifier);
15293
- break;
15294
-
15295
- case 'major':
15296
- // If this is a pre-major version, bump up to the same major version.
15297
- // Otherwise increment major.
15298
- // 1.0.0-5 bumps to 1.0.0
15299
- // 1.1.0 bumps to 2.0.0
15300
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
15301
- this.major++;
15302
- }
15303
-
15304
- this.minor = 0;
15305
- this.patch = 0;
15306
- this.prerelease = [];
15307
- break;
15308
-
15309
- case 'minor':
15310
- // If this is a pre-minor version, bump up to the same minor version.
15311
- // Otherwise increment minor.
15312
- // 1.2.0-5 bumps to 1.2.0
15313
- // 1.2.1 bumps to 1.3.0
15314
- if (this.patch !== 0 || this.prerelease.length === 0) {
15315
- this.minor++;
15316
- }
15317
-
15318
- this.patch = 0;
15319
- this.prerelease = [];
15320
- break;
15321
-
15322
- case 'patch':
15323
- // If this is not a pre-release version, it will increment the patch.
15324
- // If it is a pre-release it will bump up to the same patch version.
15325
- // 1.2.0-5 patches to 1.2.0
15326
- // 1.2.0 patches to 1.2.1
15327
- if (this.prerelease.length === 0) {
15328
- this.patch++;
15329
- }
15330
-
15331
- this.prerelease = [];
15332
- break;
15333
- // This probably shouldn't be used publicly.
15334
- // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
15335
-
15336
- case 'pre':
15337
- if (this.prerelease.length === 0) {
15338
- this.prerelease = [0];
15339
- } else {
15340
- var i = this.prerelease.length;
15341
-
15342
- while (--i >= 0) {
15343
- if (typeof this.prerelease[i] === 'number') {
15344
- this.prerelease[i]++;
15345
- i = -2;
15346
- }
15347
- }
15348
-
15349
- if (i === -1) {
15350
- // didn't increment anything
15351
- this.prerelease.push(0);
16049
+ }
16050
+ this.patch = 0;
16051
+ this.prerelease = [];
16052
+ break
16053
+ case 'patch':
16054
+ // If this is not a pre-release version, it will increment the patch.
16055
+ // If it is a pre-release it will bump up to the same patch version.
16056
+ // 1.2.0-5 patches to 1.2.0
16057
+ // 1.2.0 patches to 1.2.1
16058
+ if (this.prerelease.length === 0) {
16059
+ this.patch++;
16060
+ }
16061
+ this.prerelease = [];
16062
+ break
16063
+ // This probably shouldn't be used publicly.
16064
+ // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
16065
+ case 'pre':
16066
+ if (this.prerelease.length === 0) {
16067
+ this.prerelease = [0];
16068
+ } else {
16069
+ var i = this.prerelease.length;
16070
+ while (--i >= 0) {
16071
+ if (typeof this.prerelease[i] === 'number') {
16072
+ this.prerelease[i]++;
16073
+ i = -2;
15352
16074
  }
15353
16075
  }
15354
-
15355
- if (identifier) {
15356
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
15357
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
15358
- if (this.prerelease[0] === identifier) {
15359
- if (isNaN(this.prerelease[1])) {
15360
- this.prerelease = [identifier, 0];
15361
- }
15362
- } else {
16076
+ if (i === -1) {
16077
+ // didn't increment anything
16078
+ this.prerelease.push(0);
16079
+ }
16080
+ }
16081
+ if (identifier) {
16082
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
16083
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
16084
+ if (this.prerelease[0] === identifier) {
16085
+ if (isNaN(this.prerelease[1])) {
15363
16086
  this.prerelease = [identifier, 0];
15364
16087
  }
16088
+ } else {
16089
+ this.prerelease = [identifier, 0];
15365
16090
  }
16091
+ }
16092
+ break
15366
16093
 
15367
- break;
15368
-
15369
- default:
15370
- throw new Error('invalid increment argument: ' + release);
15371
- }
15372
-
15373
- this.format();
15374
- this.raw = this.version;
15375
- return this;
15376
- };
15377
-
15378
- exports.inc = inc;
15379
-
15380
- function inc(version, release, loose, identifier) {
15381
- if (typeof loose === 'string') {
15382
- identifier = loose;
15383
- loose = undefined;
15384
- }
15385
-
15386
- try {
15387
- return new SemVer(version, loose).inc(release, identifier).version;
15388
- } catch (er) {
15389
- return null;
15390
- }
16094
+ default:
16095
+ throw new Error('invalid increment argument: ' + release)
15391
16096
  }
16097
+ this.format();
16098
+ this.raw = this.version;
16099
+ return this
16100
+ };
15392
16101
 
15393
- exports.diff = diff;
15394
-
15395
- function diff(version1, version2) {
15396
- if (eq(version1, version2)) {
15397
- return null;
15398
- } else {
15399
- var v1 = parse(version1);
15400
- var v2 = parse(version2);
15401
- var prefix = '';
16102
+ exports.inc = inc;
16103
+ function inc (version, release, loose, identifier) {
16104
+ if (typeof (loose) === 'string') {
16105
+ identifier = loose;
16106
+ loose = undefined;
16107
+ }
15402
16108
 
15403
- if (v1.prerelease.length || v2.prerelease.length) {
15404
- prefix = 'pre';
15405
- var defaultResult = 'prerelease';
15406
- }
16109
+ try {
16110
+ return new SemVer(version, loose).inc(release, identifier).version
16111
+ } catch (er) {
16112
+ return null
16113
+ }
16114
+ }
15407
16115
 
15408
- for (var key in v1) {
15409
- if (key === 'major' || key === 'minor' || key === 'patch') {
15410
- if (v1[key] !== v2[key]) {
15411
- return prefix + key;
15412
- }
16116
+ exports.diff = diff;
16117
+ function diff (version1, version2) {
16118
+ if (eq(version1, version2)) {
16119
+ return null
16120
+ } else {
16121
+ var v1 = parse(version1);
16122
+ var v2 = parse(version2);
16123
+ var prefix = '';
16124
+ if (v1.prerelease.length || v2.prerelease.length) {
16125
+ prefix = 'pre';
16126
+ var defaultResult = 'prerelease';
16127
+ }
16128
+ for (var key in v1) {
16129
+ if (key === 'major' || key === 'minor' || key === 'patch') {
16130
+ if (v1[key] !== v2[key]) {
16131
+ return prefix + key
15413
16132
  }
15414
16133
  }
15415
-
15416
- return defaultResult; // may be undefined
15417
16134
  }
16135
+ return defaultResult // may be undefined
15418
16136
  }
16137
+ }
15419
16138
 
15420
- exports.compareIdentifiers = compareIdentifiers;
15421
- var numeric = /^[0-9]+$/;
15422
-
15423
- function compareIdentifiers(a, b) {
15424
- var anum = numeric.test(a);
15425
- var bnum = numeric.test(b);
16139
+ exports.compareIdentifiers = compareIdentifiers;
15426
16140
 
15427
- if (anum && bnum) {
15428
- a = +a;
15429
- b = +b;
15430
- }
16141
+ var numeric = /^[0-9]+$/;
16142
+ function compareIdentifiers (a, b) {
16143
+ var anum = numeric.test(a);
16144
+ var bnum = numeric.test(b);
15431
16145
 
15432
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
16146
+ if (anum && bnum) {
16147
+ a = +a;
16148
+ b = +b;
15433
16149
  }
15434
16150
 
15435
- exports.rcompareIdentifiers = rcompareIdentifiers;
16151
+ return a === b ? 0
16152
+ : (anum && !bnum) ? -1
16153
+ : (bnum && !anum) ? 1
16154
+ : a < b ? -1
16155
+ : 1
16156
+ }
15436
16157
 
15437
- function rcompareIdentifiers(a, b) {
15438
- return compareIdentifiers(b, a);
15439
- }
16158
+ exports.rcompareIdentifiers = rcompareIdentifiers;
16159
+ function rcompareIdentifiers (a, b) {
16160
+ return compareIdentifiers(b, a)
16161
+ }
15440
16162
 
15441
- exports.major = major;
16163
+ exports.major = major;
16164
+ function major (a, loose) {
16165
+ return new SemVer(a, loose).major
16166
+ }
15442
16167
 
15443
- function major(a, loose) {
15444
- return new SemVer(a, loose).major;
15445
- }
16168
+ exports.minor = minor;
16169
+ function minor (a, loose) {
16170
+ return new SemVer(a, loose).minor
16171
+ }
15446
16172
 
15447
- exports.minor = minor;
16173
+ exports.patch = patch;
16174
+ function patch (a, loose) {
16175
+ return new SemVer(a, loose).patch
16176
+ }
15448
16177
 
15449
- function minor(a, loose) {
15450
- return new SemVer(a, loose).minor;
15451
- }
16178
+ exports.compare = compare;
16179
+ function compare (a, b, loose) {
16180
+ return new SemVer(a, loose).compare(new SemVer(b, loose))
16181
+ }
15452
16182
 
15453
- exports.patch = patch;
16183
+ exports.compareLoose = compareLoose;
16184
+ function compareLoose (a, b) {
16185
+ return compare(a, b, true)
16186
+ }
15454
16187
 
15455
- function patch(a, loose) {
15456
- return new SemVer(a, loose).patch;
15457
- }
16188
+ exports.compareBuild = compareBuild;
16189
+ function compareBuild (a, b, loose) {
16190
+ var versionA = new SemVer(a, loose);
16191
+ var versionB = new SemVer(b, loose);
16192
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
16193
+ }
15458
16194
 
15459
- exports.compare = compare;
16195
+ exports.rcompare = rcompare;
16196
+ function rcompare (a, b, loose) {
16197
+ return compare(b, a, loose)
16198
+ }
15460
16199
 
15461
- function compare(a, b, loose) {
15462
- return new SemVer(a, loose).compare(new SemVer(b, loose));
15463
- }
16200
+ exports.sort = sort;
16201
+ function sort (list, loose) {
16202
+ return list.sort(function (a, b) {
16203
+ return exports.compareBuild(a, b, loose)
16204
+ })
16205
+ }
15464
16206
 
15465
- exports.compareLoose = compareLoose;
16207
+ exports.rsort = rsort;
16208
+ function rsort (list, loose) {
16209
+ return list.sort(function (a, b) {
16210
+ return exports.compareBuild(b, a, loose)
16211
+ })
16212
+ }
15466
16213
 
15467
- function compareLoose(a, b) {
15468
- return compare(a, b, true);
15469
- }
16214
+ exports.gt = gt;
16215
+ function gt (a, b, loose) {
16216
+ return compare(a, b, loose) > 0
16217
+ }
15470
16218
 
15471
- exports.compareBuild = compareBuild;
16219
+ exports.lt = lt;
16220
+ function lt (a, b, loose) {
16221
+ return compare(a, b, loose) < 0
16222
+ }
15472
16223
 
15473
- function compareBuild(a, b, loose) {
15474
- var versionA = new SemVer(a, loose);
15475
- var versionB = new SemVer(b, loose);
15476
- return versionA.compare(versionB) || versionA.compareBuild(versionB);
15477
- }
16224
+ exports.eq = eq;
16225
+ function eq (a, b, loose) {
16226
+ return compare(a, b, loose) === 0
16227
+ }
15478
16228
 
15479
- exports.rcompare = rcompare;
16229
+ exports.neq = neq;
16230
+ function neq (a, b, loose) {
16231
+ return compare(a, b, loose) !== 0
16232
+ }
15480
16233
 
15481
- function rcompare(a, b, loose) {
15482
- return compare(b, a, loose);
15483
- }
16234
+ exports.gte = gte;
16235
+ function gte (a, b, loose) {
16236
+ return compare(a, b, loose) >= 0
16237
+ }
15484
16238
 
15485
- exports.sort = sort;
16239
+ exports.lte = lte;
16240
+ function lte (a, b, loose) {
16241
+ return compare(a, b, loose) <= 0
16242
+ }
15486
16243
 
15487
- function sort(list, loose) {
15488
- return list.sort(function (a, b) {
15489
- return exports.compareBuild(a, b, loose);
15490
- });
15491
- }
16244
+ exports.cmp = cmp;
16245
+ function cmp (a, op, b, loose) {
16246
+ switch (op) {
16247
+ case '===':
16248
+ if (typeof a === 'object')
16249
+ a = a.version;
16250
+ if (typeof b === 'object')
16251
+ b = b.version;
16252
+ return a === b
15492
16253
 
15493
- exports.rsort = rsort;
16254
+ case '!==':
16255
+ if (typeof a === 'object')
16256
+ a = a.version;
16257
+ if (typeof b === 'object')
16258
+ b = b.version;
16259
+ return a !== b
15494
16260
 
15495
- function rsort(list, loose) {
15496
- return list.sort(function (a, b) {
15497
- return exports.compareBuild(b, a, loose);
15498
- });
15499
- }
16261
+ case '':
16262
+ case '=':
16263
+ case '==':
16264
+ return eq(a, b, loose)
15500
16265
 
15501
- exports.gt = gt;
16266
+ case '!=':
16267
+ return neq(a, b, loose)
15502
16268
 
15503
- function gt(a, b, loose) {
15504
- return compare(a, b, loose) > 0;
15505
- }
16269
+ case '>':
16270
+ return gt(a, b, loose)
15506
16271
 
15507
- exports.lt = lt;
16272
+ case '>=':
16273
+ return gte(a, b, loose)
15508
16274
 
15509
- function lt(a, b, loose) {
15510
- return compare(a, b, loose) < 0;
15511
- }
16275
+ case '<':
16276
+ return lt(a, b, loose)
15512
16277
 
15513
- exports.eq = eq;
16278
+ case '<=':
16279
+ return lte(a, b, loose)
15514
16280
 
15515
- function eq(a, b, loose) {
15516
- return compare(a, b, loose) === 0;
16281
+ default:
16282
+ throw new TypeError('Invalid operator: ' + op)
15517
16283
  }
16284
+ }
15518
16285
 
15519
- exports.neq = neq;
15520
-
15521
- function neq(a, b, loose) {
15522
- return compare(a, b, loose) !== 0;
16286
+ exports.Comparator = Comparator;
16287
+ function Comparator (comp, options) {
16288
+ if (!options || typeof options !== 'object') {
16289
+ options = {
16290
+ loose: !!options,
16291
+ includePrerelease: false
16292
+ };
15523
16293
  }
15524
16294
 
15525
- exports.gte = gte;
15526
-
15527
- function gte(a, b, loose) {
15528
- return compare(a, b, loose) >= 0;
16295
+ if (comp instanceof Comparator) {
16296
+ if (comp.loose === !!options.loose) {
16297
+ return comp
16298
+ } else {
16299
+ comp = comp.value;
16300
+ }
15529
16301
  }
15530
16302
 
15531
- exports.lte = lte;
15532
-
15533
- function lte(a, b, loose) {
15534
- return compare(a, b, loose) <= 0;
16303
+ if (!(this instanceof Comparator)) {
16304
+ return new Comparator(comp, options)
15535
16305
  }
15536
16306
 
15537
- exports.cmp = cmp;
15538
-
15539
- function cmp(a, op, b, loose) {
15540
- switch (op) {
15541
- case '===':
15542
- if (typeof a === 'object') a = a.version;
15543
- if (typeof b === 'object') b = b.version;
15544
- return a === b;
16307
+ debug('comparator', comp, options);
16308
+ this.options = options;
16309
+ this.loose = !!options.loose;
16310
+ this.parse(comp);
15545
16311
 
15546
- case '!==':
15547
- if (typeof a === 'object') a = a.version;
15548
- if (typeof b === 'object') b = b.version;
15549
- return a !== b;
15550
-
15551
- case '':
15552
- case '=':
15553
- case '==':
15554
- return eq(a, b, loose);
15555
-
15556
- case '!=':
15557
- return neq(a, b, loose);
15558
-
15559
- case '>':
15560
- return gt(a, b, loose);
15561
-
15562
- case '>=':
15563
- return gte(a, b, loose);
16312
+ if (this.semver === ANY) {
16313
+ this.value = '';
16314
+ } else {
16315
+ this.value = this.operator + this.semver.version;
16316
+ }
15564
16317
 
15565
- case '<':
15566
- return lt(a, b, loose);
16318
+ debug('comp', this);
16319
+ }
15567
16320
 
15568
- case '<=':
15569
- return lte(a, b, loose);
16321
+ var ANY = {};
16322
+ Comparator.prototype.parse = function (comp) {
16323
+ var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
16324
+ var m = comp.match(r);
15570
16325
 
15571
- default:
15572
- throw new TypeError('Invalid operator: ' + op);
15573
- }
16326
+ if (!m) {
16327
+ throw new TypeError('Invalid comparator: ' + comp)
15574
16328
  }
15575
16329
 
15576
- exports.Comparator = Comparator;
16330
+ this.operator = m[1] !== undefined ? m[1] : '';
16331
+ if (this.operator === '=') {
16332
+ this.operator = '';
16333
+ }
15577
16334
 
15578
- function Comparator(comp, options) {
15579
- if (!options || typeof options !== 'object') {
15580
- options = {
15581
- loose: !!options,
15582
- includePrerelease: false
15583
- };
15584
- }
16335
+ // if it literally is just '>' or '' then allow anything.
16336
+ if (!m[2]) {
16337
+ this.semver = ANY;
16338
+ } else {
16339
+ this.semver = new SemVer(m[2], this.options.loose);
16340
+ }
16341
+ };
15585
16342
 
15586
- if (comp instanceof Comparator) {
15587
- if (comp.loose === !!options.loose) {
15588
- return comp;
15589
- } else {
15590
- comp = comp.value;
15591
- }
15592
- }
16343
+ Comparator.prototype.toString = function () {
16344
+ return this.value
16345
+ };
15593
16346
 
15594
- if (!(this instanceof Comparator)) {
15595
- return new Comparator(comp, options);
15596
- }
16347
+ Comparator.prototype.test = function (version) {
16348
+ debug('Comparator.test', version, this.options.loose);
15597
16349
 
15598
- debug('comparator', comp, options);
15599
- this.options = options;
15600
- this.loose = !!options.loose;
15601
- this.parse(comp);
16350
+ if (this.semver === ANY || version === ANY) {
16351
+ return true
16352
+ }
15602
16353
 
15603
- if (this.semver === ANY) {
15604
- this.value = '';
15605
- } else {
15606
- this.value = this.operator + this.semver.version;
16354
+ if (typeof version === 'string') {
16355
+ try {
16356
+ version = new SemVer(version, this.options);
16357
+ } catch (er) {
16358
+ return false
15607
16359
  }
15608
-
15609
- debug('comp', this);
15610
16360
  }
15611
16361
 
15612
- var ANY = {};
15613
-
15614
- Comparator.prototype.parse = function (comp) {
15615
- var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
15616
- var m = comp.match(r);
16362
+ return cmp(version, this.operator, this.semver, this.options)
16363
+ };
15617
16364
 
15618
- if (!m) {
15619
- throw new TypeError('Invalid comparator: ' + comp);
15620
- }
16365
+ Comparator.prototype.intersects = function (comp, options) {
16366
+ if (!(comp instanceof Comparator)) {
16367
+ throw new TypeError('a Comparator is required')
16368
+ }
15621
16369
 
15622
- this.operator = m[1] !== undefined ? m[1] : '';
16370
+ if (!options || typeof options !== 'object') {
16371
+ options = {
16372
+ loose: !!options,
16373
+ includePrerelease: false
16374
+ };
16375
+ }
15623
16376
 
15624
- if (this.operator === '=') {
15625
- this.operator = '';
15626
- } // if it literally is just '>' or '' then allow anything.
16377
+ var rangeTmp;
16378
+
16379
+ if (this.operator === '') {
16380
+ if (this.value === '') {
16381
+ return true
16382
+ }
16383
+ rangeTmp = new Range(comp.value, options);
16384
+ return satisfies(this.value, rangeTmp, options)
16385
+ } else if (comp.operator === '') {
16386
+ if (comp.value === '') {
16387
+ return true
16388
+ }
16389
+ rangeTmp = new Range(this.value, options);
16390
+ return satisfies(comp.semver, rangeTmp, options)
16391
+ }
16392
+
16393
+ var sameDirectionIncreasing =
16394
+ (this.operator === '>=' || this.operator === '>') &&
16395
+ (comp.operator === '>=' || comp.operator === '>');
16396
+ var sameDirectionDecreasing =
16397
+ (this.operator === '<=' || this.operator === '<') &&
16398
+ (comp.operator === '<=' || comp.operator === '<');
16399
+ var sameSemVer = this.semver.version === comp.semver.version;
16400
+ var differentDirectionsInclusive =
16401
+ (this.operator === '>=' || this.operator === '<=') &&
16402
+ (comp.operator === '>=' || comp.operator === '<=');
16403
+ var oppositeDirectionsLessThan =
16404
+ cmp(this.semver, '<', comp.semver, options) &&
16405
+ ((this.operator === '>=' || this.operator === '>') &&
16406
+ (comp.operator === '<=' || comp.operator === '<'));
16407
+ var oppositeDirectionsGreaterThan =
16408
+ cmp(this.semver, '>', comp.semver, options) &&
16409
+ ((this.operator === '<=' || this.operator === '<') &&
16410
+ (comp.operator === '>=' || comp.operator === '>'));
16411
+
16412
+ return sameDirectionIncreasing || sameDirectionDecreasing ||
16413
+ (sameSemVer && differentDirectionsInclusive) ||
16414
+ oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
16415
+ };
15627
16416
 
16417
+ exports.Range = Range;
16418
+ function Range (range, options) {
16419
+ if (!options || typeof options !== 'object') {
16420
+ options = {
16421
+ loose: !!options,
16422
+ includePrerelease: false
16423
+ };
16424
+ }
15628
16425
 
15629
- if (!m[2]) {
15630
- this.semver = ANY;
16426
+ if (range instanceof Range) {
16427
+ if (range.loose === !!options.loose &&
16428
+ range.includePrerelease === !!options.includePrerelease) {
16429
+ return range
15631
16430
  } else {
15632
- this.semver = new SemVer(m[2], this.options.loose);
15633
- }
15634
- };
15635
-
15636
- Comparator.prototype.toString = function () {
15637
- return this.value;
15638
- };
15639
-
15640
- Comparator.prototype.test = function (version) {
15641
- debug('Comparator.test', version, this.options.loose);
15642
-
15643
- if (this.semver === ANY || version === ANY) {
15644
- return true;
15645
- }
15646
-
15647
- if (typeof version === 'string') {
15648
- try {
15649
- version = new SemVer(version, this.options);
15650
- } catch (er) {
15651
- return false;
15652
- }
15653
- }
15654
-
15655
- return cmp(version, this.operator, this.semver, this.options);
15656
- };
15657
-
15658
- Comparator.prototype.intersects = function (comp, options) {
15659
- if (!(comp instanceof Comparator)) {
15660
- throw new TypeError('a Comparator is required');
15661
- }
15662
-
15663
- if (!options || typeof options !== 'object') {
15664
- options = {
15665
- loose: !!options,
15666
- includePrerelease: false
15667
- };
15668
- }
15669
-
15670
- var rangeTmp;
15671
-
15672
- if (this.operator === '') {
15673
- if (this.value === '') {
15674
- return true;
15675
- }
15676
-
15677
- rangeTmp = new Range(comp.value, options);
15678
- return satisfies(this.value, rangeTmp, options);
15679
- } else if (comp.operator === '') {
15680
- if (comp.value === '') {
15681
- return true;
15682
- }
15683
-
15684
- rangeTmp = new Range(this.value, options);
15685
- return satisfies(comp.semver, rangeTmp, options);
15686
- }
15687
-
15688
- var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
15689
- var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
15690
- var sameSemVer = this.semver.version === comp.semver.version;
15691
- var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
15692
- var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
15693
- var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
15694
- return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
15695
- };
15696
-
15697
- exports.Range = Range;
15698
-
15699
- function Range(range, options) {
15700
- if (!options || typeof options !== 'object') {
15701
- options = {
15702
- loose: !!options,
15703
- includePrerelease: false
15704
- };
15705
- }
15706
-
15707
- if (range instanceof Range) {
15708
- if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
15709
- return range;
15710
- } else {
15711
- return new Range(range.raw, options);
15712
- }
15713
- }
15714
-
15715
- if (range instanceof Comparator) {
15716
- return new Range(range.value, options);
15717
- }
15718
-
15719
- if (!(this instanceof Range)) {
15720
- return new Range(range, options);
15721
- }
15722
-
15723
- this.options = options;
15724
- this.loose = !!options.loose;
15725
- this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
15726
-
15727
- this.raw = range;
15728
- this.set = range.split(/\s*\|\|\s*/).map(function (range) {
15729
- return this.parseRange(range.trim());
15730
- }, this).filter(function (c) {
15731
- // throw out any that are not relevant for whatever reason
15732
- return c.length;
15733
- });
15734
-
15735
- if (!this.set.length) {
15736
- throw new TypeError('Invalid SemVer Range: ' + range);
16431
+ return new Range(range.raw, options)
15737
16432
  }
15738
-
15739
- this.format();
15740
16433
  }
15741
16434
 
15742
- Range.prototype.format = function () {
15743
- this.range = this.set.map(function (comps) {
15744
- return comps.join(' ').trim();
15745
- }).join('||').trim();
15746
- return this.range;
15747
- };
15748
-
15749
- Range.prototype.toString = function () {
15750
- return this.range;
15751
- };
15752
-
15753
- Range.prototype.parseRange = function (range) {
15754
- var loose = this.options.loose;
15755
- range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
15756
-
15757
- var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
15758
- range = range.replace(hr, hyphenReplace);
15759
- debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
15760
-
15761
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
15762
- debug('comparator trim', range, re[t.COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
16435
+ if (range instanceof Comparator) {
16436
+ return new Range(range.value, options)
16437
+ }
15763
16438
 
15764
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
16439
+ if (!(this instanceof Range)) {
16440
+ return new Range(range, options)
16441
+ }
15765
16442
 
15766
- range = range.replace(re[t.CARETTRIM], caretTrimReplace); // normalize spaces
16443
+ this.options = options;
16444
+ this.loose = !!options.loose;
16445
+ this.includePrerelease = !!options.includePrerelease;
15767
16446
 
15768
- range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
15769
- // ready to be split into comparators.
16447
+ // First, split based on boolean or ||
16448
+ this.raw = range;
16449
+ this.set = range.split(/\s*\|\|\s*/).map(function (range) {
16450
+ return this.parseRange(range.trim())
16451
+ }, this).filter(function (c) {
16452
+ // throw out any that are not relevant for whatever reason
16453
+ return c.length
16454
+ });
15770
16455
 
15771
- var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
15772
- var set = range.split(' ').map(function (comp) {
15773
- return parseComparator(comp, this.options);
15774
- }, this).join(' ').split(/\s+/);
16456
+ if (!this.set.length) {
16457
+ throw new TypeError('Invalid SemVer Range: ' + range)
16458
+ }
15775
16459
 
15776
- if (this.options.loose) {
15777
- // in loose mode, throw out any that are not valid comparators
15778
- set = set.filter(function (comp) {
15779
- return !!comp.match(compRe);
15780
- });
15781
- }
16460
+ this.format();
16461
+ }
15782
16462
 
15783
- set = set.map(function (comp) {
15784
- return new Comparator(comp, this.options);
15785
- }, this);
15786
- return set;
15787
- };
16463
+ Range.prototype.format = function () {
16464
+ this.range = this.set.map(function (comps) {
16465
+ return comps.join(' ').trim()
16466
+ }).join('||').trim();
16467
+ return this.range
16468
+ };
15788
16469
 
15789
- Range.prototype.intersects = function (range, options) {
15790
- if (!(range instanceof Range)) {
15791
- throw new TypeError('a Range is required');
15792
- }
16470
+ Range.prototype.toString = function () {
16471
+ return this.range
16472
+ };
15793
16473
 
15794
- return this.set.some(function (thisComparators) {
15795
- return isSatisfiable(thisComparators, options) && range.set.some(function (rangeComparators) {
15796
- return isSatisfiable(rangeComparators, options) && thisComparators.every(function (thisComparator) {
15797
- return rangeComparators.every(function (rangeComparator) {
15798
- return thisComparator.intersects(rangeComparator, options);
15799
- });
15800
- });
15801
- });
16474
+ Range.prototype.parseRange = function (range) {
16475
+ var loose = this.options.loose;
16476
+ range = range.trim();
16477
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
16478
+ var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
16479
+ range = range.replace(hr, hyphenReplace);
16480
+ debug('hyphen replace', range);
16481
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
16482
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
16483
+ debug('comparator trim', range, re[t.COMPARATORTRIM]);
16484
+
16485
+ // `~ 1.2.3` => `~1.2.3`
16486
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
16487
+
16488
+ // `^ 1.2.3` => `^1.2.3`
16489
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
16490
+
16491
+ // normalize spaces
16492
+ range = range.split(/\s+/).join(' ');
16493
+
16494
+ // At this point, the range is completely trimmed and
16495
+ // ready to be split into comparators.
16496
+
16497
+ var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
16498
+ var set = range.split(' ').map(function (comp) {
16499
+ return parseComparator(comp, this.options)
16500
+ }, this).join(' ').split(/\s+/);
16501
+ if (this.options.loose) {
16502
+ // in loose mode, throw out any that are not valid comparators
16503
+ set = set.filter(function (comp) {
16504
+ return !!comp.match(compRe)
15802
16505
  });
15803
- }; // take a set of comparators and determine whether there
15804
- // exists a version which can satisfy it
15805
-
15806
-
15807
- function isSatisfiable(comparators, options) {
15808
- var result = true;
15809
- var remainingComparators = comparators.slice();
15810
- var testComparator = remainingComparators.pop();
16506
+ }
16507
+ set = set.map(function (comp) {
16508
+ return new Comparator(comp, this.options)
16509
+ }, this);
15811
16510
 
15812
- while (result && remainingComparators.length) {
15813
- result = remainingComparators.every(function (otherComparator) {
15814
- return testComparator.intersects(otherComparator, options);
15815
- });
15816
- testComparator = remainingComparators.pop();
15817
- }
16511
+ return set
16512
+ };
15818
16513
 
15819
- return result;
15820
- } // Mostly just for testing and legacy API reasons
16514
+ Range.prototype.intersects = function (range, options) {
16515
+ if (!(range instanceof Range)) {
16516
+ throw new TypeError('a Range is required')
16517
+ }
15821
16518
 
16519
+ return this.set.some(function (thisComparators) {
16520
+ return (
16521
+ isSatisfiable(thisComparators, options) &&
16522
+ range.set.some(function (rangeComparators) {
16523
+ return (
16524
+ isSatisfiable(rangeComparators, options) &&
16525
+ thisComparators.every(function (thisComparator) {
16526
+ return rangeComparators.every(function (rangeComparator) {
16527
+ return thisComparator.intersects(rangeComparator, options)
16528
+ })
16529
+ })
16530
+ )
16531
+ })
16532
+ )
16533
+ })
16534
+ };
15822
16535
 
15823
- exports.toComparators = toComparators;
16536
+ // take a set of comparators and determine whether there
16537
+ // exists a version which can satisfy it
16538
+ function isSatisfiable (comparators, options) {
16539
+ var result = true;
16540
+ var remainingComparators = comparators.slice();
16541
+ var testComparator = remainingComparators.pop();
15824
16542
 
15825
- function toComparators(range, options) {
15826
- return new Range(range, options).set.map(function (comp) {
15827
- return comp.map(function (c) {
15828
- return c.value;
15829
- }).join(' ').trim().split(' ');
16543
+ while (result && remainingComparators.length) {
16544
+ result = remainingComparators.every(function (otherComparator) {
16545
+ return testComparator.intersects(otherComparator, options)
15830
16546
  });
15831
- } // comprised of xranges, tildes, stars, and gtlt's at this point.
15832
- // already replaced the hyphen ranges
15833
- // turn into a set of JUST comparators.
15834
-
15835
-
15836
- function parseComparator(comp, options) {
15837
- debug('comp', comp, options);
15838
- comp = replaceCarets(comp, options);
15839
- debug('caret', comp);
15840
- comp = replaceTildes(comp, options);
15841
- debug('tildes', comp);
15842
- comp = replaceXRanges(comp, options);
15843
- debug('xrange', comp);
15844
- comp = replaceStars(comp, options);
15845
- debug('stars', comp);
15846
- return comp;
15847
- }
15848
-
15849
- function isX(id) {
15850
- return !id || id.toLowerCase() === 'x' || id === '*';
15851
- } // ~, ~> --> * (any, kinda silly)
15852
- // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
15853
- // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
15854
- // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
15855
- // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
15856
- // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
15857
-
15858
-
15859
- function replaceTildes(comp, options) {
15860
- return comp.trim().split(/\s+/).map(function (comp) {
15861
- return replaceTilde(comp, options);
15862
- }).join(' ');
15863
- }
15864
-
15865
- function replaceTilde(comp, options) {
15866
- var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
15867
- return comp.replace(r, function (_, M, m, p, pr) {
15868
- debug('tilde', comp, _, M, m, p, pr);
15869
- var ret;
15870
16547
 
15871
- if (isX(M)) {
15872
- ret = '';
15873
- } else if (isX(m)) {
15874
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
15875
- } else if (isX(p)) {
15876
- // ~1.2 == >=1.2.0 <1.3.0
16548
+ testComparator = remainingComparators.pop();
16549
+ }
16550
+
16551
+ return result
16552
+ }
16553
+
16554
+ // Mostly just for testing and legacy API reasons
16555
+ exports.toComparators = toComparators;
16556
+ function toComparators (range, options) {
16557
+ return new Range(range, options).set.map(function (comp) {
16558
+ return comp.map(function (c) {
16559
+ return c.value
16560
+ }).join(' ').trim().split(' ')
16561
+ })
16562
+ }
16563
+
16564
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
16565
+ // already replaced the hyphen ranges
16566
+ // turn into a set of JUST comparators.
16567
+ function parseComparator (comp, options) {
16568
+ debug('comp', comp, options);
16569
+ comp = replaceCarets(comp, options);
16570
+ debug('caret', comp);
16571
+ comp = replaceTildes(comp, options);
16572
+ debug('tildes', comp);
16573
+ comp = replaceXRanges(comp, options);
16574
+ debug('xrange', comp);
16575
+ comp = replaceStars(comp, options);
16576
+ debug('stars', comp);
16577
+ return comp
16578
+ }
16579
+
16580
+ function isX (id) {
16581
+ return !id || id.toLowerCase() === 'x' || id === '*'
16582
+ }
16583
+
16584
+ // ~, ~> --> * (any, kinda silly)
16585
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
16586
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
16587
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
16588
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
16589
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
16590
+ function replaceTildes (comp, options) {
16591
+ return comp.trim().split(/\s+/).map(function (comp) {
16592
+ return replaceTilde(comp, options)
16593
+ }).join(' ')
16594
+ }
16595
+
16596
+ function replaceTilde (comp, options) {
16597
+ var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
16598
+ return comp.replace(r, function (_, M, m, p, pr) {
16599
+ debug('tilde', comp, _, M, m, p, pr);
16600
+ var ret;
16601
+
16602
+ if (isX(M)) {
16603
+ ret = '';
16604
+ } else if (isX(m)) {
16605
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
16606
+ } else if (isX(p)) {
16607
+ // ~1.2 == >=1.2.0 <1.3.0
16608
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
16609
+ } else if (pr) {
16610
+ debug('replaceTilde pr', pr);
16611
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
16612
+ ' <' + M + '.' + (+m + 1) + '.0';
16613
+ } else {
16614
+ // ~1.2.3 == >=1.2.3 <1.3.0
16615
+ ret = '>=' + M + '.' + m + '.' + p +
16616
+ ' <' + M + '.' + (+m + 1) + '.0';
16617
+ }
16618
+
16619
+ debug('tilde return', ret);
16620
+ return ret
16621
+ })
16622
+ }
16623
+
16624
+ // ^ --> * (any, kinda silly)
16625
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
16626
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
16627
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
16628
+ // ^1.2.3 --> >=1.2.3 <2.0.0
16629
+ // ^1.2.0 --> >=1.2.0 <2.0.0
16630
+ function replaceCarets (comp, options) {
16631
+ return comp.trim().split(/\s+/).map(function (comp) {
16632
+ return replaceCaret(comp, options)
16633
+ }).join(' ')
16634
+ }
16635
+
16636
+ function replaceCaret (comp, options) {
16637
+ debug('caret', comp, options);
16638
+ var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
16639
+ return comp.replace(r, function (_, M, m, p, pr) {
16640
+ debug('caret', comp, _, M, m, p, pr);
16641
+ var ret;
16642
+
16643
+ if (isX(M)) {
16644
+ ret = '';
16645
+ } else if (isX(m)) {
16646
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
16647
+ } else if (isX(p)) {
16648
+ if (M === '0') {
15877
16649
  ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
15878
- } else if (pr) {
15879
- debug('replaceTilde pr', pr);
15880
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
15881
16650
  } else {
15882
- // ~1.2.3 == >=1.2.3 <1.3.0
15883
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
16651
+ ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
15884
16652
  }
15885
-
15886
- debug('tilde return', ret);
15887
- return ret;
15888
- });
15889
- } // ^ --> * (any, kinda silly)
15890
- // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
15891
- // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
15892
- // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
15893
- // ^1.2.3 --> >=1.2.3 <2.0.0
15894
- // ^1.2.0 --> >=1.2.0 <2.0.0
15895
-
15896
-
15897
- function replaceCarets(comp, options) {
15898
- return comp.trim().split(/\s+/).map(function (comp) {
15899
- return replaceCaret(comp, options);
15900
- }).join(' ');
15901
- }
15902
-
15903
- function replaceCaret(comp, options) {
15904
- debug('caret', comp, options);
15905
- var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
15906
- return comp.replace(r, function (_, M, m, p, pr) {
15907
- debug('caret', comp, _, M, m, p, pr);
15908
- var ret;
15909
-
15910
- if (isX(M)) {
15911
- ret = '';
15912
- } else if (isX(m)) {
15913
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
15914
- } else if (isX(p)) {
15915
- if (M === '0') {
15916
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
15917
- } else {
15918
- ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
15919
- }
15920
- } else if (pr) {
15921
- debug('replaceCaret pr', pr);
15922
-
15923
- if (M === '0') {
15924
- if (m === '0') {
15925
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
15926
- } else {
15927
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
15928
- }
16653
+ } else if (pr) {
16654
+ debug('replaceCaret pr', pr);
16655
+ if (M === '0') {
16656
+ if (m === '0') {
16657
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
16658
+ ' <' + M + '.' + m + '.' + (+p + 1);
15929
16659
  } else {
15930
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
16660
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
16661
+ ' <' + M + '.' + (+m + 1) + '.0';
15931
16662
  }
15932
16663
  } else {
15933
- debug('no pr');
15934
-
15935
- if (M === '0') {
15936
- if (m === '0') {
15937
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
15938
- } else {
15939
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
15940
- }
16664
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
16665
+ ' <' + (+M + 1) + '.0.0';
16666
+ }
16667
+ } else {
16668
+ debug('no pr');
16669
+ if (M === '0') {
16670
+ if (m === '0') {
16671
+ ret = '>=' + M + '.' + m + '.' + p +
16672
+ ' <' + M + '.' + m + '.' + (+p + 1);
15941
16673
  } else {
15942
- ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
16674
+ ret = '>=' + M + '.' + m + '.' + p +
16675
+ ' <' + M + '.' + (+m + 1) + '.0';
15943
16676
  }
16677
+ } else {
16678
+ ret = '>=' + M + '.' + m + '.' + p +
16679
+ ' <' + (+M + 1) + '.0.0';
15944
16680
  }
16681
+ }
15945
16682
 
15946
- debug('caret return', ret);
15947
- return ret;
15948
- });
15949
- }
16683
+ debug('caret return', ret);
16684
+ return ret
16685
+ })
16686
+ }
15950
16687
 
15951
- function replaceXRanges(comp, options) {
15952
- debug('replaceXRanges', comp, options);
15953
- return comp.split(/\s+/).map(function (comp) {
15954
- return replaceXRange(comp, options);
15955
- }).join(' ');
15956
- }
16688
+ function replaceXRanges (comp, options) {
16689
+ debug('replaceXRanges', comp, options);
16690
+ return comp.split(/\s+/).map(function (comp) {
16691
+ return replaceXRange(comp, options)
16692
+ }).join(' ')
16693
+ }
15957
16694
 
15958
- function replaceXRange(comp, options) {
15959
- comp = comp.trim();
15960
- var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
15961
- return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
15962
- debug('xRange', comp, ret, gtlt, M, m, p, pr);
15963
- var xM = isX(M);
15964
- var xm = xM || isX(m);
15965
- var xp = xm || isX(p);
15966
- var anyX = xp;
16695
+ function replaceXRange (comp, options) {
16696
+ comp = comp.trim();
16697
+ var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
16698
+ return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
16699
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
16700
+ var xM = isX(M);
16701
+ var xm = xM || isX(m);
16702
+ var xp = xm || isX(p);
16703
+ var anyX = xp;
15967
16704
 
15968
- if (gtlt === '=' && anyX) {
15969
- gtlt = '';
15970
- } // if we're including prereleases in the match, then we need
15971
- // to fix this to -0, the lowest possible prerelease value
16705
+ if (gtlt === '=' && anyX) {
16706
+ gtlt = '';
16707
+ }
15972
16708
 
16709
+ // if we're including prereleases in the match, then we need
16710
+ // to fix this to -0, the lowest possible prerelease value
16711
+ pr = options.includePrerelease ? '-0' : '';
15973
16712
 
15974
- pr = options.includePrerelease ? '-0' : '';
16713
+ if (xM) {
16714
+ if (gtlt === '>' || gtlt === '<') {
16715
+ // nothing is allowed
16716
+ ret = '<0.0.0-0';
16717
+ } else {
16718
+ // nothing is forbidden
16719
+ ret = '*';
16720
+ }
16721
+ } else if (gtlt && anyX) {
16722
+ // we know patch is an x, because we have any x at all.
16723
+ // replace X with 0
16724
+ if (xm) {
16725
+ m = 0;
16726
+ }
16727
+ p = 0;
15975
16728
 
15976
- if (xM) {
15977
- if (gtlt === '>' || gtlt === '<') {
15978
- // nothing is allowed
15979
- ret = '<0.0.0-0';
15980
- } else {
15981
- // nothing is forbidden
15982
- ret = '*';
15983
- }
15984
- } else if (gtlt && anyX) {
15985
- // we know patch is an x, because we have any x at all.
15986
- // replace X with 0
16729
+ if (gtlt === '>') {
16730
+ // >1 => >=2.0.0
16731
+ // >1.2 => >=1.3.0
16732
+ // >1.2.3 => >= 1.2.4
16733
+ gtlt = '>=';
15987
16734
  if (xm) {
16735
+ M = +M + 1;
15988
16736
  m = 0;
16737
+ p = 0;
16738
+ } else {
16739
+ m = +m + 1;
16740
+ p = 0;
15989
16741
  }
15990
-
15991
- p = 0;
15992
-
15993
- if (gtlt === '>') {
15994
- // >1 => >=2.0.0
15995
- // >1.2 => >=1.3.0
15996
- // >1.2.3 => >= 1.2.4
15997
- gtlt = '>=';
15998
-
15999
- if (xm) {
16000
- M = +M + 1;
16001
- m = 0;
16002
- p = 0;
16003
- } else {
16004
- m = +m + 1;
16005
- p = 0;
16006
- }
16007
- } else if (gtlt === '<=') {
16008
- // <=0.7.x is actually <0.8.0, since any 0.7.x should
16009
- // pass. Similarly, <=7.x is actually <8.0.0, etc.
16010
- gtlt = '<';
16011
-
16012
- if (xm) {
16013
- M = +M + 1;
16014
- } else {
16015
- m = +m + 1;
16016
- }
16742
+ } else if (gtlt === '<=') {
16743
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
16744
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
16745
+ gtlt = '<';
16746
+ if (xm) {
16747
+ M = +M + 1;
16748
+ } else {
16749
+ m = +m + 1;
16017
16750
  }
16018
-
16019
- ret = gtlt + M + '.' + m + '.' + p + pr;
16020
- } else if (xm) {
16021
- ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
16022
- } else if (xp) {
16023
- ret = '>=' + M + '.' + m + '.0' + pr + ' <' + M + '.' + (+m + 1) + '.0' + pr;
16024
16751
  }
16025
16752
 
16026
- debug('xRange return', ret);
16027
- return ret;
16028
- });
16029
- } // Because * is AND-ed with everything else in the comparator,
16030
- // and '' means "any version", just remove the *s entirely.
16031
-
16032
-
16033
- function replaceStars(comp, options) {
16034
- debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
16035
-
16036
- return comp.trim().replace(re[t.STAR], '');
16037
- } // This function is passed to string.replace(re[t.HYPHENRANGE])
16038
- // M, m, patch, prerelease, build
16039
- // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
16040
- // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
16041
- // 1.2 - 3.4 => >=1.2.0 <3.5.0
16042
-
16043
-
16044
- function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
16045
- if (isX(fM)) {
16046
- from = '';
16047
- } else if (isX(fm)) {
16048
- from = '>=' + fM + '.0.0';
16049
- } else if (isX(fp)) {
16050
- from = '>=' + fM + '.' + fm + '.0';
16051
- } else {
16052
- from = '>=' + from;
16053
- }
16753
+ ret = gtlt + M + '.' + m + '.' + p + pr;
16754
+ } else if (xm) {
16755
+ ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
16756
+ } else if (xp) {
16757
+ ret = '>=' + M + '.' + m + '.0' + pr +
16758
+ ' <' + M + '.' + (+m + 1) + '.0' + pr;
16759
+ }
16760
+
16761
+ debug('xRange return', ret);
16762
+
16763
+ return ret
16764
+ })
16765
+ }
16766
+
16767
+ // Because * is AND-ed with everything else in the comparator,
16768
+ // and '' means "any version", just remove the *s entirely.
16769
+ function replaceStars (comp, options) {
16770
+ debug('replaceStars', comp, options);
16771
+ // Looseness is ignored here. star is always as loose as it gets!
16772
+ return comp.trim().replace(re[t.STAR], '')
16773
+ }
16774
+
16775
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
16776
+ // M, m, patch, prerelease, build
16777
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
16778
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
16779
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0
16780
+ function hyphenReplace ($0,
16781
+ from, fM, fm, fp, fpr, fb,
16782
+ to, tM, tm, tp, tpr, tb) {
16783
+ if (isX(fM)) {
16784
+ from = '';
16785
+ } else if (isX(fm)) {
16786
+ from = '>=' + fM + '.0.0';
16787
+ } else if (isX(fp)) {
16788
+ from = '>=' + fM + '.' + fm + '.0';
16789
+ } else {
16790
+ from = '>=' + from;
16791
+ }
16054
16792
 
16055
- if (isX(tM)) {
16056
- to = '';
16057
- } else if (isX(tm)) {
16058
- to = '<' + (+tM + 1) + '.0.0';
16059
- } else if (isX(tp)) {
16060
- to = '<' + tM + '.' + (+tm + 1) + '.0';
16061
- } else if (tpr) {
16062
- to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
16063
- } else {
16064
- to = '<=' + to;
16065
- }
16793
+ if (isX(tM)) {
16794
+ to = '';
16795
+ } else if (isX(tm)) {
16796
+ to = '<' + (+tM + 1) + '.0.0';
16797
+ } else if (isX(tp)) {
16798
+ to = '<' + tM + '.' + (+tm + 1) + '.0';
16799
+ } else if (tpr) {
16800
+ to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
16801
+ } else {
16802
+ to = '<=' + to;
16803
+ }
16066
16804
 
16067
- return (from + ' ' + to).trim();
16068
- } // if ANY of the sets match ALL of its comparators, then pass
16805
+ return (from + ' ' + to).trim()
16806
+ }
16069
16807
 
16808
+ // if ANY of the sets match ALL of its comparators, then pass
16809
+ Range.prototype.test = function (version) {
16810
+ if (!version) {
16811
+ return false
16812
+ }
16070
16813
 
16071
- Range.prototype.test = function (version) {
16072
- if (!version) {
16073
- return false;
16814
+ if (typeof version === 'string') {
16815
+ try {
16816
+ version = new SemVer(version, this.options);
16817
+ } catch (er) {
16818
+ return false
16074
16819
  }
16820
+ }
16075
16821
 
16076
- if (typeof version === 'string') {
16077
- try {
16078
- version = new SemVer(version, this.options);
16079
- } catch (er) {
16080
- return false;
16081
- }
16822
+ for (var i = 0; i < this.set.length; i++) {
16823
+ if (testSet(this.set[i], version, this.options)) {
16824
+ return true
16082
16825
  }
16826
+ }
16827
+ return false
16828
+ };
16083
16829
 
16084
- for (var i = 0; i < this.set.length; i++) {
16085
- if (testSet(this.set[i], version, this.options)) {
16086
- return true;
16087
- }
16830
+ function testSet (set, version, options) {
16831
+ for (var i = 0; i < set.length; i++) {
16832
+ if (!set[i].test(version)) {
16833
+ return false
16088
16834
  }
16835
+ }
16089
16836
 
16090
- return false;
16091
- };
16092
-
16093
- function testSet(set, version, options) {
16094
- for (var i = 0; i < set.length; i++) {
16095
- if (!set[i].test(version)) {
16096
- return false;
16837
+ if (version.prerelease.length && !options.includePrerelease) {
16838
+ // Find the set of versions that are allowed to have prereleases
16839
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
16840
+ // That should allow `1.2.3-pr.2` to pass.
16841
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
16842
+ // even though it's within the range set by the comparators.
16843
+ for (i = 0; i < set.length; i++) {
16844
+ debug(set[i].semver);
16845
+ if (set[i].semver === ANY) {
16846
+ continue
16097
16847
  }
16098
- }
16099
-
16100
- if (version.prerelease.length && !options.includePrerelease) {
16101
- // Find the set of versions that are allowed to have prereleases
16102
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
16103
- // That should allow `1.2.3-pr.2` to pass.
16104
- // However, `1.2.4-alpha.notready` should NOT be allowed,
16105
- // even though it's within the range set by the comparators.
16106
- for (i = 0; i < set.length; i++) {
16107
- debug(set[i].semver);
16108
-
16109
- if (set[i].semver === ANY) {
16110
- continue;
16111
- }
16112
-
16113
- if (set[i].semver.prerelease.length > 0) {
16114
- var allowed = set[i].semver;
16115
16848
 
16116
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
16117
- return true;
16118
- }
16849
+ if (set[i].semver.prerelease.length > 0) {
16850
+ var allowed = set[i].semver;
16851
+ if (allowed.major === version.major &&
16852
+ allowed.minor === version.minor &&
16853
+ allowed.patch === version.patch) {
16854
+ return true
16119
16855
  }
16120
- } // Version has a -pre, but it's not one of the ones we like.
16121
-
16122
-
16123
- return false;
16856
+ }
16124
16857
  }
16125
16858
 
16126
- return true;
16859
+ // Version has a -pre, but it's not one of the ones we like.
16860
+ return false
16127
16861
  }
16128
16862
 
16129
- exports.satisfies = satisfies;
16130
-
16131
- function satisfies(version, range, options) {
16132
- try {
16133
- range = new Range(range, options);
16134
- } catch (er) {
16135
- return false;
16136
- }
16863
+ return true
16864
+ }
16137
16865
 
16138
- return range.test(version);
16866
+ exports.satisfies = satisfies;
16867
+ function satisfies (version, range, options) {
16868
+ try {
16869
+ range = new Range(range, options);
16870
+ } catch (er) {
16871
+ return false
16139
16872
  }
16873
+ return range.test(version)
16874
+ }
16140
16875
 
16141
- exports.maxSatisfying = maxSatisfying;
16142
-
16143
- function maxSatisfying(versions, range, options) {
16144
- var max = null;
16145
- var maxSV = null;
16146
-
16147
- try {
16148
- var rangeObj = new Range(range, options);
16149
- } catch (er) {
16150
- return null;
16876
+ exports.maxSatisfying = maxSatisfying;
16877
+ function maxSatisfying (versions, range, options) {
16878
+ var max = null;
16879
+ var maxSV = null;
16880
+ try {
16881
+ var rangeObj = new Range(range, options);
16882
+ } catch (er) {
16883
+ return null
16884
+ }
16885
+ versions.forEach(function (v) {
16886
+ if (rangeObj.test(v)) {
16887
+ // satisfies(v, range, options)
16888
+ if (!max || maxSV.compare(v) === -1) {
16889
+ // compare(max, v, true)
16890
+ max = v;
16891
+ maxSV = new SemVer(max, options);
16892
+ }
16151
16893
  }
16894
+ });
16895
+ return max
16896
+ }
16152
16897
 
16153
- versions.forEach(function (v) {
16154
- if (rangeObj.test(v)) {
16155
- // satisfies(v, range, options)
16156
- if (!max || maxSV.compare(v) === -1) {
16157
- // compare(max, v, true)
16158
- max = v;
16159
- maxSV = new SemVer(max, options);
16160
- }
16898
+ exports.minSatisfying = minSatisfying;
16899
+ function minSatisfying (versions, range, options) {
16900
+ var min = null;
16901
+ var minSV = null;
16902
+ try {
16903
+ var rangeObj = new Range(range, options);
16904
+ } catch (er) {
16905
+ return null
16906
+ }
16907
+ versions.forEach(function (v) {
16908
+ if (rangeObj.test(v)) {
16909
+ // satisfies(v, range, options)
16910
+ if (!min || minSV.compare(v) === 1) {
16911
+ // compare(min, v, true)
16912
+ min = v;
16913
+ minSV = new SemVer(min, options);
16161
16914
  }
16162
- });
16163
- return max;
16164
- }
16915
+ }
16916
+ });
16917
+ return min
16918
+ }
16165
16919
 
16166
- exports.minSatisfying = minSatisfying;
16920
+ exports.minVersion = minVersion;
16921
+ function minVersion (range, loose) {
16922
+ range = new Range(range, loose);
16167
16923
 
16168
- function minSatisfying(versions, range, options) {
16169
- var min = null;
16170
- var minSV = null;
16924
+ var minver = new SemVer('0.0.0');
16925
+ if (range.test(minver)) {
16926
+ return minver
16927
+ }
16171
16928
 
16172
- try {
16173
- var rangeObj = new Range(range, options);
16174
- } catch (er) {
16175
- return null;
16176
- }
16929
+ minver = new SemVer('0.0.0-0');
16930
+ if (range.test(minver)) {
16931
+ return minver
16932
+ }
16177
16933
 
16178
- versions.forEach(function (v) {
16179
- if (rangeObj.test(v)) {
16180
- // satisfies(v, range, options)
16181
- if (!min || minSV.compare(v) === 1) {
16182
- // compare(min, v, true)
16183
- min = v;
16184
- minSV = new SemVer(min, options);
16185
- }
16934
+ minver = null;
16935
+ for (var i = 0; i < range.set.length; ++i) {
16936
+ var comparators = range.set[i];
16937
+
16938
+ comparators.forEach(function (comparator) {
16939
+ // Clone to avoid manipulating the comparator's semver object.
16940
+ var compver = new SemVer(comparator.semver.version);
16941
+ switch (comparator.operator) {
16942
+ case '>':
16943
+ if (compver.prerelease.length === 0) {
16944
+ compver.patch++;
16945
+ } else {
16946
+ compver.prerelease.push(0);
16947
+ }
16948
+ compver.raw = compver.format();
16949
+ /* fallthrough */
16950
+ case '':
16951
+ case '>=':
16952
+ if (!minver || gt(minver, compver)) {
16953
+ minver = compver;
16954
+ }
16955
+ break
16956
+ case '<':
16957
+ case '<=':
16958
+ /* Ignore maximum versions */
16959
+ break
16960
+ /* istanbul ignore next */
16961
+ default:
16962
+ throw new Error('Unexpected operation: ' + comparator.operator)
16186
16963
  }
16187
16964
  });
16188
- return min;
16189
16965
  }
16190
16966
 
16191
- exports.minVersion = minVersion;
16192
-
16193
- function minVersion(range, loose) {
16194
- range = new Range(range, loose);
16195
- var minver = new SemVer('0.0.0');
16196
-
16197
- if (range.test(minver)) {
16198
- return minver;
16199
- }
16200
-
16201
- minver = new SemVer('0.0.0-0');
16202
-
16203
- if (range.test(minver)) {
16204
- return minver;
16205
- }
16206
-
16207
- minver = null;
16967
+ if (minver && range.test(minver)) {
16968
+ return minver
16969
+ }
16208
16970
 
16209
- for (var i = 0; i < range.set.length; ++i) {
16210
- var comparators = range.set[i];
16211
- comparators.forEach(function (comparator) {
16212
- // Clone to avoid manipulating the comparator's semver object.
16213
- var compver = new SemVer(comparator.semver.version);
16971
+ return null
16972
+ }
16214
16973
 
16215
- switch (comparator.operator) {
16216
- case '>':
16217
- if (compver.prerelease.length === 0) {
16218
- compver.patch++;
16219
- } else {
16220
- compver.prerelease.push(0);
16221
- }
16974
+ exports.validRange = validRange;
16975
+ function validRange (range, options) {
16976
+ try {
16977
+ // Return '*' instead of '' so that truthiness works.
16978
+ // This will throw if it's invalid anyway
16979
+ return new Range(range, options).range || '*'
16980
+ } catch (er) {
16981
+ return null
16982
+ }
16983
+ }
16984
+
16985
+ // Determine if version is less than all the versions possible in the range
16986
+ exports.ltr = ltr;
16987
+ function ltr (version, range, options) {
16988
+ return outside(version, range, '<', options)
16989
+ }
16990
+
16991
+ // Determine if version is greater than all the versions possible in the range.
16992
+ exports.gtr = gtr;
16993
+ function gtr (version, range, options) {
16994
+ return outside(version, range, '>', options)
16995
+ }
16996
+
16997
+ exports.outside = outside;
16998
+ function outside (version, range, hilo, options) {
16999
+ version = new SemVer(version, options);
17000
+ range = new Range(range, options);
17001
+
17002
+ var gtfn, ltefn, ltfn, comp, ecomp;
17003
+ switch (hilo) {
17004
+ case '>':
17005
+ gtfn = gt;
17006
+ ltefn = lte;
17007
+ ltfn = lt;
17008
+ comp = '>';
17009
+ ecomp = '>=';
17010
+ break
17011
+ case '<':
17012
+ gtfn = lt;
17013
+ ltefn = gte;
17014
+ ltfn = gt;
17015
+ comp = '<';
17016
+ ecomp = '<=';
17017
+ break
17018
+ default:
17019
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
17020
+ }
16222
17021
 
16223
- compver.raw = compver.format();
17022
+ // If it satisifes the range it is not outside
17023
+ if (satisfies(version, range, options)) {
17024
+ return false
17025
+ }
16224
17026
 
16225
- /* fallthrough */
17027
+ // From now on, variable terms are as if we're in "gtr" mode.
17028
+ // but note that everything is flipped for the "ltr" function.
16226
17029
 
16227
- case '':
16228
- case '>=':
16229
- if (!minver || gt(minver, compver)) {
16230
- minver = compver;
16231
- }
17030
+ for (var i = 0; i < range.set.length; ++i) {
17031
+ var comparators = range.set[i];
16232
17032
 
16233
- break;
17033
+ var high = null;
17034
+ var low = null;
16234
17035
 
16235
- case '<':
16236
- case '<=':
16237
- /* Ignore maximum versions */
16238
- break;
16239
-
16240
- /* istanbul ignore next */
17036
+ comparators.forEach(function (comparator) {
17037
+ if (comparator.semver === ANY) {
17038
+ comparator = new Comparator('>=0.0.0');
17039
+ }
17040
+ high = high || comparator;
17041
+ low = low || comparator;
17042
+ if (gtfn(comparator.semver, high.semver, options)) {
17043
+ high = comparator;
17044
+ } else if (ltfn(comparator.semver, low.semver, options)) {
17045
+ low = comparator;
17046
+ }
17047
+ });
16241
17048
 
16242
- default:
16243
- throw new Error('Unexpected operation: ' + comparator.operator);
16244
- }
16245
- });
17049
+ // If the edge version comparator has a operator then our version
17050
+ // isn't outside it
17051
+ if (high.operator === comp || high.operator === ecomp) {
17052
+ return false
16246
17053
  }
16247
17054
 
16248
- if (minver && range.test(minver)) {
16249
- return minver;
17055
+ // If the lowest version comparator has an operator and our version
17056
+ // is less than it then it isn't higher than the range
17057
+ if ((!low.operator || low.operator === comp) &&
17058
+ ltefn(version, low.semver)) {
17059
+ return false
17060
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
17061
+ return false
16250
17062
  }
16251
-
16252
- return null;
16253
17063
  }
17064
+ return true
17065
+ }
16254
17066
 
16255
- exports.validRange = validRange;
16256
-
16257
- function validRange(range, options) {
16258
- try {
16259
- // Return '*' instead of '' so that truthiness works.
16260
- // This will throw if it's invalid anyway
16261
- return new Range(range, options).range || '*';
16262
- } catch (er) {
16263
- return null;
16264
- }
16265
- } // Determine if version is less than all the versions possible in the range
16266
-
16267
-
16268
- exports.ltr = ltr;
16269
-
16270
- function ltr(version, range, options) {
16271
- return outside(version, range, '<', options);
16272
- } // Determine if version is greater than all the versions possible in the range.
16273
-
17067
+ exports.prerelease = prerelease;
17068
+ function prerelease (version, options) {
17069
+ var parsed = parse(version, options);
17070
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
17071
+ }
16274
17072
 
16275
- exports.gtr = gtr;
17073
+ exports.intersects = intersects;
17074
+ function intersects (r1, r2, options) {
17075
+ r1 = new Range(r1, options);
17076
+ r2 = new Range(r2, options);
17077
+ return r1.intersects(r2)
17078
+ }
16276
17079
 
16277
- function gtr(version, range, options) {
16278
- return outside(version, range, '>', options);
17080
+ exports.coerce = coerce;
17081
+ function coerce (version, options) {
17082
+ if (version instanceof SemVer) {
17083
+ return version
16279
17084
  }
16280
17085
 
16281
- exports.outside = outside;
16282
-
16283
- function outside(version, range, hilo, options) {
16284
- version = new SemVer(version, options);
16285
- range = new Range(range, options);
16286
- var gtfn, ltefn, ltfn, comp, ecomp;
16287
-
16288
- switch (hilo) {
16289
- case '>':
16290
- gtfn = gt;
16291
- ltefn = lte;
16292
- ltfn = lt;
16293
- comp = '>';
16294
- ecomp = '>=';
16295
- break;
16296
-
16297
- case '<':
16298
- gtfn = lt;
16299
- ltefn = gte;
16300
- ltfn = gt;
16301
- comp = '<';
16302
- ecomp = '<=';
16303
- break;
16304
-
16305
- default:
16306
- throw new TypeError('Must provide a hilo val of "<" or ">"');
16307
- } // If it satisifes the range it is not outside
16308
-
16309
-
16310
- if (satisfies(version, range, options)) {
16311
- return false;
16312
- } // From now on, variable terms are as if we're in "gtr" mode.
16313
- // but note that everything is flipped for the "ltr" function.
16314
-
16315
-
16316
- for (var i = 0; i < range.set.length; ++i) {
16317
- var comparators = range.set[i];
16318
- var high = null;
16319
- var low = null;
16320
- comparators.forEach(function (comparator) {
16321
- if (comparator.semver === ANY) {
16322
- comparator = new Comparator('>=0.0.0');
16323
- }
16324
-
16325
- high = high || comparator;
16326
- low = low || comparator;
16327
-
16328
- if (gtfn(comparator.semver, high.semver, options)) {
16329
- high = comparator;
16330
- } else if (ltfn(comparator.semver, low.semver, options)) {
16331
- low = comparator;
16332
- }
16333
- }); // If the edge version comparator has a operator then our version
16334
- // isn't outside it
17086
+ if (typeof version === 'number') {
17087
+ version = String(version);
17088
+ }
16335
17089
 
16336
- if (high.operator === comp || high.operator === ecomp) {
16337
- return false;
16338
- } // If the lowest version comparator has an operator and our version
16339
- // is less than it then it isn't higher than the range
17090
+ if (typeof version !== 'string') {
17091
+ return null
17092
+ }
16340
17093
 
17094
+ options = options || {};
16341
17095
 
16342
- if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
16343
- return false;
16344
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
16345
- return false;
17096
+ var match = null;
17097
+ if (!options.rtl) {
17098
+ match = version.match(re[t.COERCE]);
17099
+ } else {
17100
+ // Find the right-most coercible string that does not share
17101
+ // a terminus with a more left-ward coercible string.
17102
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
17103
+ //
17104
+ // Walk through the string checking with a /g regexp
17105
+ // Manually set the index so as to pick up overlapping matches.
17106
+ // Stop when we get a match that ends at the string end, since no
17107
+ // coercible string can be more right-ward without the same terminus.
17108
+ var next;
17109
+ while ((next = re[t.COERCERTL].exec(version)) &&
17110
+ (!match || match.index + match[0].length !== version.length)
17111
+ ) {
17112
+ if (!match ||
17113
+ next.index + next[0].length !== match.index + match[0].length) {
17114
+ match = next;
16346
17115
  }
17116
+ re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
16347
17117
  }
16348
-
16349
- return true;
16350
- }
16351
-
16352
- exports.prerelease = prerelease;
16353
-
16354
- function prerelease(version, options) {
16355
- var parsed = parse(version, options);
16356
- return parsed && parsed.prerelease.length ? parsed.prerelease : null;
17118
+ // leave it in a clean state
17119
+ re[t.COERCERTL].lastIndex = -1;
16357
17120
  }
16358
17121
 
16359
- exports.intersects = intersects;
16360
-
16361
- function intersects(r1, r2, options) {
16362
- r1 = new Range(r1, options);
16363
- r2 = new Range(r2, options);
16364
- return r1.intersects(r2);
17122
+ if (match === null) {
17123
+ return null
16365
17124
  }
16366
17125
 
16367
- exports.coerce = coerce;
16368
-
16369
- function coerce(version, options) {
16370
- if (version instanceof SemVer) {
16371
- return version;
16372
- }
16373
-
16374
- if (typeof version === 'number') {
16375
- version = String(version);
16376
- }
16377
-
16378
- if (typeof version !== 'string') {
16379
- return null;
16380
- }
16381
-
16382
- options = options || {};
16383
- var match = null;
16384
-
16385
- if (!options.rtl) {
16386
- match = version.match(re[t.COERCE]);
16387
- } else {
16388
- // Find the right-most coercible string that does not share
16389
- // a terminus with a more left-ward coercible string.
16390
- // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
16391
- //
16392
- // Walk through the string checking with a /g regexp
16393
- // Manually set the index so as to pick up overlapping matches.
16394
- // Stop when we get a match that ends at the string end, since no
16395
- // coercible string can be more right-ward without the same terminus.
16396
- var next;
16397
-
16398
- while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
16399
- if (!match || next.index + next[0].length !== match.index + match[0].length) {
16400
- match = next;
16401
- }
16402
-
16403
- re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
16404
- } // leave it in a clean state
16405
-
16406
-
16407
- re[t.COERCERTL].lastIndex = -1;
16408
- }
16409
-
16410
- if (match === null) {
16411
- return null;
16412
- }
16413
-
16414
- return parse(match[2] + '.' + (match[3] || '0') + '.' + (match[4] || '0'), options);
16415
- }
16416
- })(semver, semver.exports);
17126
+ return parse(match[2] +
17127
+ '.' + (match[3] || '0') +
17128
+ '.' + (match[4] || '0'), options)
17129
+ }
17130
+ }(semver, semver.exports));
16417
17131
 
16418
17132
  const LOADED = {};
16419
17133
  /**
@@ -16973,6 +17687,22 @@ function nuked() {
16973
17687
  if (!fieldName) {
16974
17688
  throw new Error("Field identifier must be provided");
16975
17689
  }
17690
+ /**
17691
+ * @typedef { 'ltr' | 'rtl' } Direction
17692
+ */
17693
+
17694
+ /**
17695
+ * @typedef { 'vertical' | 'horizontal' } ListLayout
17696
+ */
17697
+
17698
+ /**
17699
+ * @typedef { 'none' | 'value' | 'percent' | 'relative' } FrequencyMode
17700
+ */
17701
+
17702
+ /**
17703
+ * @typedef { boolean | 'toggle' } SearchMode
17704
+ */
17705
+
16976
17706
  /**
16977
17707
  * @typedef {function(function)} ReceiverFunction A callback function which receives another function as input.
16978
17708
  */
@@ -16992,9 +17722,13 @@ function nuked() {
16992
17722
  * @param {HTMLElement} element
16993
17723
  * @param {object=} options Settings for the embedded listbox
16994
17724
  * @param {string=} options.title Custom title, defaults to fieldname
16995
- * @param {string=} [options.direction=ltr] Direction setting ltr|rtl.
16996
- * @param {string=} [options.listLayout=vertical] Layout direction vertical|horizontal
16997
- * @param {boolean=} [options.search=true] Show the search bar
17725
+ * @param {Direction=} [options.direction=ltr] Direction setting ltr|rtl.
17726
+ * @param {ListLayout=} [options.listLayout=vertical] Layout direction vertical|horizontal
17727
+ * @param {FrequencyMode=} [options.frequencyMode=none] Show frequency none|value|percent|relative
17728
+ * @param {boolean=} [options.histogram=false] Show histogram bar
17729
+ * @param {SearchMode=} [options.search=true] Show the search bar permanently or using the toggle button: false|true|toggle|toggleShow
17730
+ * @param {boolean=} [options.focusSearch=false] Initialize the Listbox with the search input focused. Only applicable when
17731
+ * search is true, since toggling will always focus the search input on show.
16998
17732
  * @param {boolean=} [options.toolbar=true] Show the toolbar
16999
17733
  * @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields
17000
17734
  * @param {boolean=} [options.rangeSelect=true] Enable range selection
@@ -17003,6 +17737,7 @@ function nuked() {
17003
17737
  * @param {object=} [options.properties={}] Properties object to extend default properties with
17004
17738
  * @param {object} [options.sessionModel] Use a custom sessionModel.
17005
17739
  * @param {object} [options.selectionsApi] Use a custom selectionsApi to customize how values are selected.
17740
+ * @param {function():boolean} [options.selectDisabled=] Define a function which tells when selections are disabled (true) or enabled (false). By default, always returns false.
17006
17741
  * @param {ReceiverFunction} [options.update] A function which receives an update function which upon call will trigger a data fetch.
17007
17742
  * @since 1.1.0
17008
17743
  * @instance