@nebula.js/stardust 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v2.6.1
2
+ * @nebula.js/stardust v2.7.0
3
3
  * Copyright (c) 2022 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -743,14 +743,9 @@
743
743
 
744
744
  if (Object.getOwnPropertySymbols) {
745
745
  var symbols = Object.getOwnPropertySymbols(object);
746
-
747
- if (enumerableOnly) {
748
- symbols = symbols.filter(function (sym) {
749
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
750
- });
751
- }
752
-
753
- keys.push.apply(keys, symbols);
746
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
747
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
748
+ })), keys.push.apply(keys, symbols);
754
749
  }
755
750
 
756
751
  return keys;
@@ -758,19 +753,12 @@
758
753
 
759
754
  function _objectSpread2(target) {
760
755
  for (var i = 1; i < arguments.length; i++) {
761
- var source = arguments[i] != null ? arguments[i] : {};
762
-
763
- if (i % 2) {
764
- ownKeys(Object(source), true).forEach(function (key) {
765
- _defineProperty$2(target, key, source[key]);
766
- });
767
- } else if (Object.getOwnPropertyDescriptors) {
768
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
769
- } else {
770
- ownKeys(Object(source)).forEach(function (key) {
771
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
772
- });
773
- }
756
+ var source = null != arguments[i] ? arguments[i] : {};
757
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
758
+ _defineProperty$2(target, key, source[key]);
759
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
760
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
761
+ });
774
762
  }
775
763
 
776
764
  return target;
@@ -1002,6 +990,26 @@
1002
990
  "zh-TW": "{0}/ {1}"
1003
991
  }
1004
992
  };
993
+ var Listbox_Lock = {
994
+ id: "Listbox.Lock",
995
+ locale: {
996
+ "de-DE": "Auswahlen sperren",
997
+ "en-US": "Lock selections",
998
+ "es-ES": "Bloquear selecciones",
999
+ "fr-FR": "Verrouiller les sélections",
1000
+ "it-IT": "Blocca selezioni",
1001
+ "ja-JP": "選択をロック",
1002
+ "ko-KR": "선택 내용 잠금",
1003
+ "nl-NL": "Selecties vergrendelen",
1004
+ "pl-PL": "Zablokuj wybory",
1005
+ "pt-BR": "Bloquear seleções",
1006
+ "ru-RU": "Заблокировать выборки",
1007
+ "sv-SE": "Lås urval",
1008
+ "tr-TR": "Seçimleri kilitle",
1009
+ "zh-CN": "锁定选择项",
1010
+ "zh-TW": "鎖定選項"
1011
+ }
1012
+ };
1005
1013
  var Listbox_Search = {
1006
1014
  id: "Listbox.Search",
1007
1015
  locale: {
@@ -1022,6 +1030,26 @@
1022
1030
  "zh-TW": "在清單方塊中搜尋"
1023
1031
  }
1024
1032
  };
1033
+ var Listbox_Unlock = {
1034
+ id: "Listbox.Unlock",
1035
+ locale: {
1036
+ "de-DE": "Auswahlen entsperren",
1037
+ "en-US": "Unlock selections",
1038
+ "es-ES": "Desbloquear selecciones",
1039
+ "fr-FR": "Déverrouiller les sélections",
1040
+ "it-IT": "Sblocca selezioni",
1041
+ "ja-JP": "選択をロック解除",
1042
+ "ko-KR": "선택 내용 잠금 해제",
1043
+ "nl-NL": "Selecties ontgrendelen",
1044
+ "pl-PL": "Odblokuj wybory",
1045
+ "pt-BR": "Desbloquear seleções",
1046
+ "ru-RU": "Разблокировать выборки",
1047
+ "sv-SE": "Lås upp urval",
1048
+ "tr-TR": "Seçimlerin kilidini aç",
1049
+ "zh-CN": "将选择项解锁",
1050
+ "zh-TW": "解鎖選項"
1051
+ }
1052
+ };
1025
1053
  var Menu_More = {
1026
1054
  id: "Menu.More",
1027
1055
  locale: {
@@ -1506,7 +1534,9 @@
1506
1534
  Cancel: Cancel$1,
1507
1535
  CurrentSelections_All: CurrentSelections_All,
1508
1536
  CurrentSelections_Of: CurrentSelections_Of,
1537
+ Listbox_Lock: Listbox_Lock,
1509
1538
  Listbox_Search: Listbox_Search,
1539
+ Listbox_Unlock: Listbox_Unlock,
1510
1540
  Menu_More: Menu_More,
1511
1541
  Navigate_Back: Navigate_Back,
1512
1542
  Navigate_Forward: Navigate_Forward,
@@ -2929,7 +2959,7 @@
2929
2959
  }
2930
2960
 
2931
2961
  /**
2932
- * Creates the follwing array of paths
2962
+ * Creates the following array of paths
2933
2963
  * object.barChart - legend.title - fontSize
2934
2964
  * object - legend.title - fontSize
2935
2965
  * legend.title - fontSize
@@ -2984,7 +3014,7 @@
2984
3014
  if (obj[steps[i]]) {
2985
3015
  obj = obj[steps[i]];
2986
3016
  } else {
2987
- return null;
3017
+ return undefined;
2988
3018
  }
2989
3019
  }
2990
3020
 
@@ -2992,12 +3022,11 @@
2992
3022
  }
2993
3023
 
2994
3024
  function searchPathArray(pathArray, attribute, theme) {
2995
- for (let i = 0; i < pathArray.length; i++) {
2996
- const target = getObject$1(theme, pathArray[i]);
3025
+ const attributeArray = attribute.split('.');
2997
3026
 
2998
- if (target !== null && target[attribute]) {
2999
- return target[attribute];
3000
- }
3027
+ for (let i = 0; i < pathArray.length; i++) {
3028
+ const restult = getObject$1(theme, [...pathArray[i], ...attributeArray]);
3029
+ if (restult !== undefined) return restult;
3001
3030
  }
3002
3031
 
3003
3032
  return undefined;
@@ -3033,11 +3062,15 @@
3033
3062
  * object.barChart - fontSize
3034
3063
  * object - fontSize
3035
3064
  * fontSize
3065
+ * When attributes separated by dots is provided, they are required in the theme JSON file
3066
+ * Ex. Base path: "object" , Path: "legend", ", Attribute: "title.fontSize"
3067
+ * title: {fontSize: ...} must be matched and the rest is the same as above
3068
+ * If you want a exact match, you can use `getStyle('object', '', 'legend.title.fontSize');`
3036
3069
  * @ignore
3037
3070
  *
3038
- * @param {string} component string of properties seperated by dots to search in
3039
- * @param {string} attribute to return
3040
- * @returns {any} value of the resolved path, undefined if not found
3071
+ * @param {string} component String of properties separated by dots to search in
3072
+ * @param {string} attribute Name of the style attribute
3073
+ * @returns {string|undefined} The style value of the resolved path, undefined if not found
3041
3074
  */
3042
3075
  getStyle(component, attribute) {
3043
3076
  // TODO - object overrides
@@ -3200,17 +3233,23 @@
3200
3233
  },
3201
3234
 
3202
3235
  /**
3203
- * Get the value of a style attribute in the theme by searching in the theme's JSON structure.
3204
- * The search starts at the specified base path and continues upwards until the value is found.
3236
+ * Get the value of a style attribute in the theme
3237
+ * by searching in the theme's JSON structure.
3238
+ * The search starts at the specified base path
3239
+ * and continues upwards until the value is found.
3205
3240
  * If possible it will get the attribute's value using the given path.
3241
+ * When attributes separated by dots are provided, such as 'hover.color',
3242
+ * they are required in the theme JSON file
3206
3243
  *
3207
3244
  * @param {string} basePath - Base path in the theme's JSON structure to start the search in (specified as a name path separated by dots).
3208
3245
  * @param {string} path - Expected path for the attribute (specified as a name path separated by dots).
3209
- * @param {string} attribute - Name of the style attribute.
3210
- * @returns {string} The style value
3246
+ * @param {string} attribute - Name of the style attribute. (specified as a name attribute separated by dots).
3247
+ * @returns {string|undefined} The style value or undefined if not found
3211
3248
  *
3212
3249
  * @example
3213
3250
  * theme.getStyle('object', 'title.main', 'fontSize');
3251
+ * theme.getStyle('object', 'title', 'main.fontSize');
3252
+ * theme.getStyle('object', '', 'title.main.fontSize');
3214
3253
  * theme.getStyle('', '', 'fontSize');
3215
3254
  */
3216
3255
  getStyle(basePath, path, attribute) {
@@ -3218,7 +3257,7 @@
3218
3257
  styleResolverInstanceCache[basePath] = styleResolver(basePath, resolvedThemeJSON);
3219
3258
  }
3220
3259
 
3221
- return styleResolverInstanceCache[basePath].getStyle(path, attribute, false);
3260
+ return styleResolverInstanceCache[basePath].getStyle(path, attribute);
3222
3261
  }
3223
3262
 
3224
3263
  };
@@ -3257,7 +3296,9 @@
3257
3296
 
3258
3297
  /* eslint no-underscore-dangle:0 */
3259
3298
 
3260
- const timed = (t, v) => new Promise(resolve => setTimeout(() => resolve(v), t));
3299
+ const timed = (t, v) => new Promise(resolve => {
3300
+ setTimeout(() => resolve(v), t);
3301
+ });
3261
3302
 
3262
3303
  const LOAD_THEME_TIMEOUT = 5000;
3263
3304
  function appTheme() {
@@ -11023,7 +11064,7 @@
11023
11064
  return [appSelections, navState];
11024
11065
  }
11025
11066
 
11026
- const NEBULA_VERSION_HASH = "375a" ;
11067
+ const NEBULA_VERSION_HASH = "b1d7" ;
11027
11068
  let counter = 0;
11028
11069
  const NebulaApp = react.exports.forwardRef((_ref, ref) => {
11029
11070
  let {
@@ -11069,7 +11110,7 @@
11069
11110
  theme: theme
11070
11111
  }, /*#__PURE__*/React.createElement(InstanceContext.Provider, {
11071
11112
  value: context
11072
- }, /*#__PURE__*/React.createElement(React.Fragment, null, components))));
11113
+ }, components)));
11073
11114
  });
11074
11115
  function boot(_ref2) {
11075
11116
  let {
@@ -11083,7 +11124,7 @@
11083
11124
  const appRef = React.createRef();
11084
11125
  const element = document.createElement('div');
11085
11126
  element.style.display = 'none';
11086
- element.setAttribute('data-nebulajs-version', "2.6.1" );
11127
+ element.setAttribute('data-nebulajs-version', "2.7.0" );
11087
11128
  element.setAttribute('data-app-id', app.id);
11088
11129
  document.body.appendChild(element);
11089
11130
  ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
@@ -18896,7 +18937,8 @@
18896
18937
  return elemNumbers;
18897
18938
  }
18898
18939
  /**
18899
- * @typedef {object} MinMaxResult
18940
+ * @ignore
18941
+ * @interface MinMaxResult
18900
18942
  * @property {number} min
18901
18943
  * @property {number} max
18902
18944
  */
@@ -18905,6 +18947,7 @@
18905
18947
  * Returns the min and max indices of elemNumbersOrdered which contains
18906
18948
  * all numbers in elementNbrs.
18907
18949
  *
18950
+ * @ignore
18908
18951
  * @param {number[]} elementNbrs
18909
18952
  * @param {number[]} elemNumbersOrdered
18910
18953
  * @returns {MinMaxResult}
@@ -18948,6 +18991,7 @@
18948
18991
  pages = [],
18949
18992
  rangeSelect = true,
18950
18993
  checkboxes = false,
18994
+ selectDisabled,
18951
18995
  doc = document
18952
18996
  } = _ref;
18953
18997
  const [instantPages, setInstantPages] = react.exports.useState(pages);
@@ -18964,6 +19008,11 @@
18964
19008
  const select = async function () {
18965
19009
  let elemNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
18966
19010
  let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19011
+
19012
+ if (selectDisabled()) {
19013
+ return;
19014
+ }
19015
+
18967
19016
  setSelectingValues(true);
18968
19017
  const isSingleSelect = getIsSingleSelect();
18969
19018
  const filtered = additive ? elemNumbers.filter(n => !selected.includes(n)) : elemNumbers;
@@ -18978,6 +19027,11 @@
18978
19027
 
18979
19028
  const preSelect = function (elemNumbers) {
18980
19029
  let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19030
+
19031
+ if (selectDisabled()) {
19032
+ return;
19033
+ }
19034
+
18981
19035
  setPreSelected(existing => {
18982
19036
  const uniques = getUniques([...existing, ...elemNumbers]);
18983
19037
  const filtered = additive ? uniques.filter(n => !selected.includes(n)) : uniques;
@@ -18986,16 +19040,26 @@
18986
19040
  });
18987
19041
  };
18988
19042
 
19043
+ const selectManually = function () {
19044
+ let elementIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
19045
+ let additive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19046
+ setMouseDown(true);
19047
+ preSelect(elementIds, additive || isRangeSelection);
19048
+ const p = select(elementIds, additive || isRangeSelection);
19049
+ setMouseDown(false);
19050
+ return p;
19051
+ };
19052
+
18989
19053
  const onClick = react.exports.useCallback(event => {
18990
- if (selectingValues) {
19054
+ if (selectingValues || selectDisabled()) {
18991
19055
  return;
18992
19056
  }
18993
19057
 
18994
19058
  const elemNumber = +event.currentTarget.getAttribute('data-n');
18995
19059
  setPreSelected([elemNumber]);
18996
- }, [selectingValues]);
19060
+ }, [selectingValues, selectDisabled]);
18997
19061
  const onMouseDown = react.exports.useCallback(event => {
18998
- if (selectingValues) {
19062
+ if (selectingValues || selectDisabled()) {
18999
19063
  return;
19000
19064
  }
19001
19065
 
@@ -19003,7 +19067,7 @@
19003
19067
  setMouseDown(true);
19004
19068
  const elemNumber = +event.currentTarget.getAttribute('data-n');
19005
19069
  setPreSelected([elemNumber]);
19006
- }, [selectingValues]);
19070
+ }, [selectingValues, selectDisabled]);
19007
19071
  const onMouseUp = react.exports.useCallback(event => {
19008
19072
  const elemNumber = +event.currentTarget.getAttribute('data-n');
19009
19073
 
@@ -19013,21 +19077,21 @@
19013
19077
  }
19014
19078
 
19015
19079
  preSelect([elemNumber]);
19016
- }, [mouseDown, selectingValues, preSelected, selected, isRangeSelection]);
19080
+ }, [mouseDown, selectingValues, preSelected, selected, isRangeSelection, selectDisabled]);
19017
19081
  const onMouseUpDoc = react.exports.useCallback(() => {
19018
19082
  // Ensure we end interactions when mouseup happens outside the Listbox.
19019
19083
  setMouseDown(false);
19020
19084
  setSelectingValues(false);
19021
19085
  }, []);
19022
19086
  const onMouseEnter = react.exports.useCallback(event => {
19023
- if (getIsSingleSelect() || !mouseDown || selectingValues) {
19087
+ if (getIsSingleSelect() || !mouseDown || selectingValues || selectDisabled()) {
19024
19088
  return;
19025
19089
  }
19026
19090
 
19027
19091
  setIsRangeSelection(true);
19028
19092
  const elemNumber = +event.currentTarget.getAttribute('data-n');
19029
19093
  preSelect([elemNumber], true);
19030
- }, [mouseDown, selectingValues, isRangeSelection, preSelected, selected, layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne]);
19094
+ }, [mouseDown, selectingValues, isRangeSelection, preSelected, selected, selectDisabled, layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne]);
19031
19095
  react.exports.useEffect(() => {
19032
19096
  // Perform selections of pre-selected values. This can
19033
19097
  // happen only when interactions have finished (mouseup).
@@ -19038,7 +19102,7 @@
19038
19102
  }
19039
19103
 
19040
19104
  select(preSelected, isRangeSelection);
19041
- }, [preSelected, mouseDown]);
19105
+ }, [preSelected, mouseDown, selectDisabled()]);
19042
19106
  react.exports.useEffect(() => {
19043
19107
  doc.addEventListener('mouseup', onMouseUpDoc);
19044
19108
  return () => {
@@ -19084,7 +19148,9 @@
19084
19148
 
19085
19149
  return {
19086
19150
  instantPages,
19087
- interactionEvents
19151
+ interactionEvents,
19152
+ select: selectManually // preselect and select without having to trigger an event
19153
+
19088
19154
  };
19089
19155
  }
19090
19156
 
@@ -19101,7 +19167,7 @@
19101
19167
 
19102
19168
  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\")";
19103
19169
 
19104
- const useStyles$b = makeStyles$1(theme => ({
19170
+ const useStyles$c = makeStyles$1(theme => ({
19105
19171
  cbIcon: {
19106
19172
  borderRadius: 3,
19107
19173
  width: 16,
@@ -19138,11 +19204,10 @@
19138
19204
  label,
19139
19205
  dense
19140
19206
  } = _ref;
19141
- const styles = useStyles$b();
19207
+ const styles = useStyles$c();
19142
19208
  return /*#__PURE__*/React.createElement(Checkbox$1, {
19143
19209
  edge: "start",
19144
19210
  checked: checked,
19145
- tabIndex: -1,
19146
19211
  disableRipple: true,
19147
19212
  className: [styles.checkbox, dense && styles.dense].filter(Boolean).join(' '),
19148
19213
  inputProps: {
@@ -19159,18 +19224,21 @@
19159
19224
  }
19160
19225
 
19161
19226
  /**
19162
- * @typedef {object} Range
19227
+ * @ignore
19228
+ * @interface Range
19163
19229
  * @property {number} qCharPos The (absolute) index where the highlighted range starts.
19164
19230
  * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
19165
19231
  */
19166
19232
 
19167
19233
  /**
19168
- * @typedef {object} Segment
19234
+ * @ignore
19235
+ * @interface Segment
19169
19236
  * @property {string} segment The sub-string/segment cut out from the original label.
19170
19237
  * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
19171
19238
  */
19172
19239
 
19173
19240
  /**
19241
+ * @ignore
19174
19242
  * @param {string} label The label we want to create segments out of.
19175
19243
  * @param {Range} range The indexes which define how to create the segments.
19176
19244
  * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
@@ -19195,6 +19263,7 @@
19195
19263
  return segments;
19196
19264
  }
19197
19265
  /**
19266
+ * @ignore
19198
19267
  * @param {string} label The label we want to create segments out of.
19199
19268
  * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
19200
19269
  * @returns {Segment[]} An array of segments, covering the entire string label.
@@ -19222,27 +19291,199 @@
19222
19291
  return labels;
19223
19292
  }
19224
19293
 
19294
+ const KEYS = Object.freeze({
19295
+ ENTER: 13,
19296
+ ESCAPE: 27,
19297
+ SPACE: 32,
19298
+ TAB: 9,
19299
+ BACKSPACE: 8,
19300
+ DELETE: 46,
19301
+ ALT: 18,
19302
+ CTRL: 17,
19303
+ SHIFT: 16,
19304
+ ARROW_UP: 38,
19305
+ ARROW_DOWN: 40,
19306
+ ARROW_LEFT: 37,
19307
+ ARROW_RIGHT: 39,
19308
+ PAGE_DOWN: 34,
19309
+ PAGE_UP: 33,
19310
+ HOME: 36,
19311
+ END: 35,
19312
+ F10: 121,
19313
+ A: 65,
19314
+ F: 70,
19315
+ ZERO: 48,
19316
+ NINE: 57,
19317
+ NUMPAD_ZERO: 96,
19318
+ NUMPAD_NINE: 105,
19319
+ SUBTRACTION: 189,
19320
+ DECIMAL: 190,
19321
+ NUMPAD_DECIMAL: 110,
19322
+ isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
19323
+ });
19324
+
19325
+ function getFieldKeyboardNavigation(_ref) {
19326
+ let {
19327
+ select,
19328
+ confirm,
19329
+ cancel
19330
+ } = _ref;
19331
+
19332
+ const getElement = function (elm) {
19333
+ let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19334
+ const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
19335
+ return parentElm && parentElm.querySelector('[role]');
19336
+ };
19337
+
19338
+ let startedRange = false;
19339
+
19340
+ const setStartedRange = val => {
19341
+ startedRange = val;
19342
+ };
19343
+
19344
+ const handleKeyDown = event => {
19345
+ let elementToFocus;
19346
+ const {
19347
+ keyCode,
19348
+ shiftKey = false
19349
+ } = event.nativeEvent;
19350
+
19351
+ switch (keyCode) {
19352
+ case KEYS.SHIFT:
19353
+ // This is to ensure we include the first value when starting a range selection.
19354
+ setStartedRange(true);
19355
+ break;
19356
+
19357
+ case KEYS.SPACE:
19358
+ select([+event.currentTarget.getAttribute('data-n')]);
19359
+ break;
19360
+
19361
+ case KEYS.ARROW_DOWN:
19362
+ case KEYS.ARROW_RIGHT:
19363
+ elementToFocus = getElement(event.currentTarget, true);
19364
+
19365
+ if (shiftKey && elementToFocus) {
19366
+ if (startedRange) {
19367
+ select([+event.currentTarget.getAttribute('data-n')], true);
19368
+ setStartedRange(false);
19369
+ }
19370
+
19371
+ select([+elementToFocus.getAttribute('data-n')], true);
19372
+ }
19373
+
19374
+ break;
19375
+
19376
+ case KEYS.ARROW_UP:
19377
+ case KEYS.ARROW_LEFT:
19378
+ elementToFocus = getElement(event.currentTarget, false);
19379
+
19380
+ if (shiftKey && elementToFocus) {
19381
+ if (startedRange) {
19382
+ select([+event.currentTarget.getAttribute('data-n')], true);
19383
+ setStartedRange(false);
19384
+ }
19385
+
19386
+ select([+elementToFocus.getAttribute('data-n')], true);
19387
+ }
19388
+
19389
+ break;
19390
+
19391
+ case KEYS.ENTER:
19392
+ confirm();
19393
+ break;
19394
+
19395
+ case KEYS.ESCAPE:
19396
+ cancel();
19397
+ return;
19398
+ // let it propagate to top-level
19399
+
19400
+ default:
19401
+ return;
19402
+ // don't stop propagation since we want to outsource keydown to other handlers.
19403
+ }
19404
+
19405
+ if (elementToFocus) {
19406
+ elementToFocus.focus();
19407
+ }
19408
+
19409
+ event.preventDefault();
19410
+ event.stopPropagation();
19411
+ };
19412
+
19413
+ return handleKeyDown;
19414
+ }
19415
+ function getListboxInlineKeyboardNavigation(_ref2) {
19416
+ let {
19417
+ setKeyboardActive
19418
+ } = _ref2;
19419
+
19420
+ const focusInsideListbox = element => {
19421
+ const fieldElement = element.querySelector('.search input, .value.selector, .value');
19422
+ setKeyboardActive(true);
19423
+
19424
+ if (fieldElement) {
19425
+ fieldElement.focus();
19426
+ }
19427
+ };
19428
+
19429
+ const focusContainer = element => {
19430
+ setKeyboardActive(false);
19431
+ element.focus();
19432
+ };
19433
+
19434
+ const handleKeyDown = event => {
19435
+ const {
19436
+ keyCode
19437
+ } = event.nativeEvent;
19438
+
19439
+ switch (keyCode) {
19440
+ // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
19441
+ case KEYS.ENTER:
19442
+ case KEYS.SPACE:
19443
+ focusInsideListbox(event.currentTarget);
19444
+ break;
19445
+
19446
+ case KEYS.ESCAPE:
19447
+ focusContainer(event.currentTarget);
19448
+ break;
19449
+
19450
+ default:
19451
+ return;
19452
+ } // Note: We should not stop propagation here as it will block the containing app
19453
+ // from handling keydown events.
19454
+
19455
+
19456
+ event.preventDefault();
19457
+ };
19458
+
19459
+ return handleKeyDown;
19460
+ }
19461
+
19225
19462
  const ellipsis = {
19226
19463
  width: '100%',
19227
19464
  overflow: 'hidden',
19228
19465
  textOverflow: 'ellipsis'
19229
19466
  };
19230
- const useStyles$a = makeStyles$1(theme => ({
19467
+ const barPadPx = 4;
19468
+ const barBorderWidthPx = 1;
19469
+ const barWithCheckboxLeftPadEm = 2;
19470
+ const frequencyTextNone = '0';
19471
+ const useStyles$b = makeStyles$1(theme => ({
19231
19472
  row: {
19232
19473
  flexWrap: 'nowrap',
19233
19474
  borderBottom: "1px solid ".concat(theme.palette.divider),
19234
- color: theme.palette.text.primary,
19235
- '&:focus': {
19236
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
19237
- outline: 'none'
19238
- }
19475
+ color: theme.palette.text.primary
19239
19476
  },
19240
19477
  column: {
19241
19478
  flexWrap: 'nowrap',
19242
19479
  borderRight: "1px solid ".concat(theme.palette.divider),
19243
- color: theme.palette.text.primary,
19480
+ color: theme.palette.text.primary
19481
+ },
19482
+ fieldRoot: {
19244
19483
  '&:focus': {
19245
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusOutline),
19484
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
19485
+ },
19486
+ '&:focus-visible': {
19246
19487
  outline: 'none'
19247
19488
  }
19248
19489
  },
@@ -19281,7 +19522,11 @@
19281
19522
  margin: 0,
19282
19523
  width: '100%',
19283
19524
  // For checkboxes the first child is the checkbox container, second is the label container.
19284
- '& > span:nth-child(2)': _objectSpread2({}, ellipsis)
19525
+ '& > span:nth-child(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
19526
+ display: 'flex',
19527
+ alignItems: 'center',
19528
+ paddingLeft: '8px'
19529
+ })
19285
19530
  },
19286
19531
  // The icons container holding tick and lock, shown inside fields.
19287
19532
  icon: {
@@ -19304,6 +19549,38 @@
19304
19549
  X: {
19305
19550
  background: theme.palette.selected.excluded,
19306
19551
  color: theme.palette.selected.excludedContrastText
19552
+ },
19553
+ frequencyCount: {
19554
+ paddingLeft: '8px',
19555
+ paddingRight: '8px'
19556
+ },
19557
+ barContainer: {
19558
+ position: 'relative'
19559
+ },
19560
+ bar: {
19561
+ border: "".concat(barBorderWidthPx, "px solid"),
19562
+ borderColor: '#D9D9D9',
19563
+ height: '1em',
19564
+ position: 'absolute',
19565
+ zIndex: '-1',
19566
+ alignSelf: 'center',
19567
+ left: "".concat(barPadPx, "px"),
19568
+ transition: 'width 0.2s'
19569
+ },
19570
+ barSelected: {
19571
+ opacity: '30%',
19572
+ zIndex: '0',
19573
+ background: theme.palette.background.lighter
19574
+ },
19575
+ barWithCheckbox: {
19576
+ left: "".concat(barWithCheckboxLeftPadEm, "em")
19577
+ },
19578
+ barSelectedWithCheckbox: {
19579
+ background: '#BFE5D0',
19580
+ borderColor: '#BFE5D0'
19581
+ },
19582
+ excludedTextWithCheckbox: {
19583
+ color: '#828282'
19307
19584
  }
19308
19585
  }));
19309
19586
  function RowColumn(_ref) {
@@ -19321,11 +19598,17 @@
19321
19598
  pages,
19322
19599
  isLocked,
19323
19600
  checkboxes = false,
19324
- dense = false
19601
+ dense = false,
19602
+ frequencyMode = 'N',
19603
+ actions,
19604
+ frequencyMax = '',
19605
+ histogram = false,
19606
+ keyboard
19325
19607
  } = data;
19608
+ const handleKeyDownCallback = react.exports.useCallback(getFieldKeyboardNavigation(actions), [actions]);
19326
19609
  const [isSelected, setSelected] = react.exports.useState(false);
19327
19610
  const [cell, setCell] = react.exports.useState();
19328
- const classes = useStyles$a();
19611
+ const classes = useStyles$b();
19329
19612
  const [classArr, setClassArr] = react.exports.useState([]);
19330
19613
  react.exports.useEffect(() => {
19331
19614
  if (!pages) {
@@ -19345,6 +19628,11 @@
19345
19628
 
19346
19629
  setCell(c);
19347
19630
  }, [pages]);
19631
+
19632
+ const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
19633
+
19634
+ const isAlternative = c => c ? c.qState === 'A' : null;
19635
+
19348
19636
  react.exports.useEffect(() => {
19349
19637
  if (!cell) {
19350
19638
  return;
@@ -19357,9 +19645,9 @@
19357
19645
  if (!checkboxes) {
19358
19646
  if (cell.qState === 'S' || cell.qState === 'L') {
19359
19647
  clazzArr.push(classes.S);
19360
- } else if (cell.qState === 'A') {
19648
+ } else if (isAlternative(cell)) {
19361
19649
  clazzArr.push(classes.A);
19362
- } else if (cell.qState === 'X' || cell.qState === 'XS' || cell.qState === 'XL') {
19650
+ } else if (isExcluded(cell)) {
19363
19651
  clazzArr.push(classes.X);
19364
19652
  }
19365
19653
  }
@@ -19367,6 +19655,10 @@
19367
19655
  setClassArr(clazzArr);
19368
19656
  }, [cell && cell.qState]);
19369
19657
 
19658
+ const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
19659
+
19660
+ const hasGrayText = () => (isAlternative(cell) || isExcluded(cell)) && checkboxes ? classes.excludedTextWithCheckbox : false;
19661
+
19370
19662
  const getValueField = _ref2 => {
19371
19663
  let {
19372
19664
  lbl,
@@ -19378,7 +19670,7 @@
19378
19670
  component: "span",
19379
19671
  variant: "body2",
19380
19672
  key: ix,
19381
- className: [classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense].filter(c => !!c).join(' ').trim(),
19673
+ className: joinClassNames([classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense, hasGrayText()]),
19382
19674
  color: color
19383
19675
  }, /*#__PURE__*/React.createElement("span", {
19384
19676
  style: {
@@ -19412,7 +19704,16 @@
19412
19704
  });
19413
19705
  };
19414
19706
 
19415
- const label = cell ? cell.qText : ''; // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
19707
+ const label = cell ? cell.qText : '';
19708
+
19709
+ const getFrequencyText = () => {
19710
+ if (cell) {
19711
+ return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
19712
+ }
19713
+
19714
+ return '';
19715
+ }; // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
19716
+
19416
19717
 
19417
19718
  const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
19418
19719
  const labels = getSegmentsFromRanges(label, ranges);
@@ -19448,19 +19749,43 @@
19448
19749
  flexGrow: 1,
19449
19750
  padding: checkboxes ? 0 : undefined
19450
19751
  };
19451
- return /*#__PURE__*/React.createElement(Grid$1, {
19752
+
19753
+ const hasHistogramBar = () => cell && histogram && getFrequencyText() !== frequencyTextNone;
19754
+
19755
+ const getBarWidth = qFrequency => {
19756
+ const freqStr = String(qFrequency);
19757
+ const isPercent = freqStr.substring(freqStr.length - 1) === '%';
19758
+ const freq = parseFloat(isPercent ? freqStr : qFrequency);
19759
+ const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadEm, "em + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
19760
+ const width = isPercent ? freq : freq / frequencyMax * 100;
19761
+ return "calc(".concat(width, "% - ").concat(rightSlice, ")");
19762
+ };
19763
+
19764
+ const isFirstElement = index === 0;
19765
+ return /*#__PURE__*/React.createElement("div", {
19766
+ className: classes.barContainer
19767
+ }, /*#__PURE__*/React.createElement(Grid$1, {
19452
19768
  container: true,
19453
19769
  spacing: 0,
19454
- className: ['value', ...classArr].join(' ').trim(),
19770
+ className: joinClassNames(['value', ...classArr]),
19771
+ classes: {
19772
+ root: classes.fieldRoot
19773
+ },
19455
19774
  style: style,
19456
19775
  onClick: onClick,
19457
19776
  onMouseDown: onMouseDown,
19458
19777
  onMouseUp: onMouseUp,
19459
19778
  onMouseEnter: onMouseEnter,
19779
+ onKeyDown: handleKeyDownCallback,
19460
19780
  role: column ? 'column' : 'row',
19461
- tabIndex: 0,
19781
+ tabIndex: isFirstElement && (!keyboard.enabled || keyboard.active) ? 0 : -1,
19462
19782
  "data-n": cell && cell.qElemNumber
19463
- }, /*#__PURE__*/React.createElement(Grid$1, {
19783
+ }, hasHistogramBar() && /*#__PURE__*/React.createElement("div", {
19784
+ className: joinClassNames([classes.bar, checkboxes && classes.barWithCheckbox, isSelected && (checkboxes ? classes.barSelectedWithCheckbox : classes.barSelected)]),
19785
+ style: {
19786
+ width: getBarWidth(cell.qFrequency)
19787
+ }
19788
+ }), /*#__PURE__*/React.createElement(Grid$1, {
19464
19789
  item: true,
19465
19790
  style: cellStyle,
19466
19791
  className: classes.cell,
@@ -19470,7 +19795,19 @@
19470
19795
  color: 'inherit'
19471
19796
  }) : getFieldWithRanges({
19472
19797
  lbls: labels
19473
- })), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid$1, {
19798
+ })), frequencyMode !== 'N' && /*#__PURE__*/React.createElement(Grid$1, {
19799
+ item: true,
19800
+ style: {
19801
+ display: 'flex',
19802
+ alignItems: 'center'
19803
+ },
19804
+ className: classes.frequencyCount
19805
+ }, /*#__PURE__*/React.createElement(Typography$1, {
19806
+ noWrap: true,
19807
+ color: "inherit",
19808
+ variant: "body2",
19809
+ className: joinClassNames([dense && classes.labelDense, classes.labelText, hasGrayText()])
19810
+ }, getFrequencyText())), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid$1, {
19474
19811
  item: true,
19475
19812
  className: classes.icon
19476
19813
  }, showLock && /*#__PURE__*/React.createElement(Lock, {
@@ -19479,7 +19816,7 @@
19479
19816
  }), showTick && /*#__PURE__*/React.createElement(Tick, {
19480
19817
  style: iconStyles,
19481
19818
  size: "small"
19482
- })));
19819
+ }))));
19483
19820
  }
19484
19821
 
19485
19822
  function getSizeInfo(_ref) {
@@ -19511,23 +19848,29 @@
19511
19848
  height,
19512
19849
  width,
19513
19850
  listLayout = 'vertical',
19851
+ frequencyMode = 'N',
19852
+ histogram = false,
19514
19853
  rangeSelect = true,
19515
19854
  checkboxes = false,
19516
19855
  update = undefined,
19517
- dense = false
19856
+ dense = false,
19857
+ keyboard = {},
19858
+ selectDisabled = () => false
19518
19859
  } = _ref2;
19519
19860
  const [layout] = useLayout$1(model);
19520
19861
  const [pages, setPages] = react.exports.useState(null);
19521
19862
  const [isLoadingData, setIsLoadingData] = react.exports.useState(false);
19522
19863
  const {
19523
19864
  instantPages = [],
19524
- interactionEvents
19865
+ interactionEvents,
19866
+ select
19525
19867
  } = useSelectionsInteractions({
19526
19868
  layout,
19527
19869
  selections,
19528
19870
  pages,
19529
19871
  rangeSelect,
19530
19872
  checkboxes,
19873
+ selectDisabled,
19531
19874
  doc: document
19532
19875
  });
19533
19876
  const loaderRef = react.exports.useRef(null);
@@ -19629,6 +19972,9 @@
19629
19972
  height
19630
19973
  });
19631
19974
  const isLocked = layout && layout.qListObject.qDimensionInfo.qLocked;
19975
+ const {
19976
+ frequencyMax
19977
+ } = layout;
19632
19978
  return /*#__PURE__*/React.createElement(InfiniteLoader, {
19633
19979
  isItemLoaded: isItemLoaded,
19634
19980
  itemCount: count,
@@ -19655,9 +20001,18 @@
19655
20001
  isLocked,
19656
20002
  column: !isVertical,
19657
20003
  pages
19658
- }, isLocked ? {} : interactionEvents), {}, {
20004
+ }, isLocked || selectDisabled() ? {} : interactionEvents), {}, {
19659
20005
  checkboxes,
19660
- dense
20006
+ dense,
20007
+ frequencyMode,
20008
+ actions: {
20009
+ select,
20010
+ confirm: () => selections && selections.confirm.call(selections),
20011
+ cancel: () => selections && selections.cancel.call(selections)
20012
+ },
20013
+ frequencyMax,
20014
+ histogram,
20015
+ keyboard
19661
20016
  }),
19662
20017
  itemSize: itemSize,
19663
20018
  onItemsRendered: onItemsRendered,
@@ -19893,13 +20248,13 @@
19893
20248
  }];
19894
20249
  }
19895
20250
 
19896
- const useStyles$9 = makeStyles(theme => ({
20251
+ const useStyles$a = makeStyles(theme => ({
19897
20252
  icon: {
19898
20253
  color: theme.palette.text.primary
19899
20254
  }
19900
20255
  }));
19901
20256
 
19902
- const MoreItem = _ref => {
20257
+ function MoreItem(_ref) {
19903
20258
  let {
19904
20259
  item,
19905
20260
  onActionClick = () => {}
@@ -19911,7 +20266,7 @@
19911
20266
  } = useActionState(item);
19912
20267
  const {
19913
20268
  icon
19914
- } = useStyles$9();
20269
+ } = useStyles$a();
19915
20270
 
19916
20271
  const handleClick = () => {
19917
20272
  item.action();
@@ -19927,7 +20282,7 @@
19927
20282
  }, SvgIcon(item.getSvgIconShape())), /*#__PURE__*/React.createElement(Typography$1, {
19928
20283
  noWrap: true
19929
20284
  }, item.label)) : null;
19930
- };
20285
+ }
19931
20286
 
19932
20287
  const More$1 = React.forwardRef((_ref2, ref) => {
19933
20288
  let {
@@ -19987,7 +20342,7 @@
19987
20342
  /** @type {'njs-action-toolbar-popover'} */
19988
20343
  className: 'njs-action-toolbar-popover'
19989
20344
  };
19990
- const useStyles$8 = makeStyles(theme => ({
20345
+ const useStyles$9 = makeStyles(theme => ({
19991
20346
  itemSpacing: {
19992
20347
  padding: theme.spacing(0, 0.5)
19993
20348
  },
@@ -20009,7 +20364,7 @@
20009
20364
  itemSpacing,
20010
20365
  firstItemSpacing,
20011
20366
  lastItemSpacing
20012
- } = useStyles$8();
20367
+ } = useStyles$9();
20013
20368
  return actions.length > 0 ? /*#__PURE__*/React.createElement(Grid$1, {
20014
20369
  item: true,
20015
20370
  container: true,
@@ -20056,7 +20411,7 @@
20056
20411
  horizontal: 'right'
20057
20412
  };
20058
20413
 
20059
- const ActionsToolbar = _ref2 => {
20414
+ function ActionsToolbar(_ref2) {
20060
20415
  let {
20061
20416
  show = true,
20062
20417
  actions = [],
@@ -20085,7 +20440,7 @@
20085
20440
  const defaultSelectionActions = useDefaultSelectionActions(selections);
20086
20441
  const {
20087
20442
  itemSpacing
20088
- } = useStyles$8();
20443
+ } = useStyles$9();
20089
20444
  const {
20090
20445
  translator,
20091
20446
  keyboardNavigation
@@ -20218,7 +20573,7 @@
20218
20573
  }
20219
20574
  }
20220
20575
  }, Actions) : show && Actions;
20221
- };
20576
+ }
20222
20577
 
20223
20578
  const search = props => _objectSpread2(_objectSpread2({}, props), {}, {
20224
20579
  shapes: [{
@@ -20229,13 +20584,19 @@
20229
20584
  }]
20230
20585
  });
20231
20586
 
20232
- var Search = (props => SvgIcon(search(props)));
20587
+ var SearchIcon = (props => SvgIcon(search(props)));
20233
20588
 
20234
- const useStyles$7 = makeStyles$1(theme => ({
20589
+ const useStyles$8 = makeStyles$1(theme => ({
20235
20590
  root: {
20591
+ border: 'none',
20592
+ borderRadius: 0,
20236
20593
  '& fieldset': {
20237
- borderRadius: 0,
20238
- borderColor: "".concat(theme.palette.divider, " transparent")
20594
+ border: "1px solid ".concat(theme.palette.divider),
20595
+ borderWidth: '1px 0 1px 0',
20596
+ borderRadius: 0
20597
+ },
20598
+ '&:hover': {
20599
+ border: 'none'
20239
20600
  }
20240
20601
  },
20241
20602
  dense: {
@@ -20251,6 +20612,7 @@
20251
20612
  function ListBoxSearch(_ref) {
20252
20613
  let {
20253
20614
  model,
20615
+ keyboard,
20254
20616
  autoFocus = true,
20255
20617
  dense = false
20256
20618
  } = _ref;
@@ -20277,11 +20639,11 @@
20277
20639
  }
20278
20640
  };
20279
20641
 
20280
- const classes = useStyles$7();
20642
+ const classes = useStyles$8();
20281
20643
  return /*#__PURE__*/React.createElement(OutlinedInput$1, {
20282
20644
  startAdornment: /*#__PURE__*/React.createElement(InputAdornment$1, {
20283
20645
  position: "start"
20284
- }, /*#__PURE__*/React.createElement(Search, {
20646
+ }, /*#__PURE__*/React.createElement(SearchIcon, {
20285
20647
  size: dense ? 'small' : 'normal'
20286
20648
  })),
20287
20649
  className: ['search', classes.root, dense && classes.dense].filter(Boolean).join(' '),
@@ -20291,7 +20653,10 @@
20291
20653
  placeholder: translator.get('Listbox.Search'),
20292
20654
  value: value,
20293
20655
  onChange: onChange,
20294
- onKeyDown: onKeyDown
20656
+ onKeyDown: onKeyDown,
20657
+ inputProps: {
20658
+ tabIndex: !keyboard.enabled || keyboard.active ? 0 : -1
20659
+ }
20295
20660
  });
20296
20661
  }
20297
20662
 
@@ -20613,10 +20978,14 @@
20613
20978
  }, isLocked ? /*#__PURE__*/React.createElement(IconButton$1, {
20614
20979
  onClick: unlock,
20615
20980
  disabled: !isLocked
20616
- }, /*#__PURE__*/React.createElement(Lock, null)) : /*#__PURE__*/React.createElement(IconButton$1, {
20981
+ }, /*#__PURE__*/React.createElement(Lock, {
20982
+ title: translator.get('Listbox.Unlock')
20983
+ })) : /*#__PURE__*/React.createElement(IconButton$1, {
20617
20984
  onClick: lock,
20618
20985
  disabled: !hasSelections
20619
- }, /*#__PURE__*/React.createElement(Unlock, null))), /*#__PURE__*/React.createElement(Grid$1, {
20986
+ }, /*#__PURE__*/React.createElement(Unlock, {
20987
+ title: translator.get('Listbox.Lock')
20988
+ }))), /*#__PURE__*/React.createElement(Grid$1, {
20620
20989
  item: true,
20621
20990
  xs: true
20622
20991
  }), /*#__PURE__*/React.createElement(Grid$1, {
@@ -20654,7 +21023,7 @@
20654
21023
  }))));
20655
21024
  }
20656
21025
 
20657
- const useStyles$6 = makeStyles$1(theme => ({
21026
+ const useStyles$7 = makeStyles$1(theme => ({
20658
21027
  item: {
20659
21028
  backgroundColor: theme.palette.background.paper,
20660
21029
  position: 'relative',
@@ -20680,7 +21049,7 @@
20680
21049
  const alignTo = moreAlignTo || react.exports.useRef();
20681
21050
  const theme = useTheme$2();
20682
21051
  const [showListBoxPopover, setShowListBoxPopover] = react.exports.useState(false);
20683
- const classes = useStyles$6();
21052
+ const classes = useStyles$7();
20684
21053
 
20685
21054
  const handleShowListBoxPopover = e => {
20686
21055
  if (e.currentTarget.contains(e.target)) {
@@ -20837,7 +21206,7 @@
20837
21206
 
20838
21207
  var DownArrow = (props => SvgIcon(downArrow(props)));
20839
21208
 
20840
- const useStyles$5 = makeStyles$1(theme => ({
21209
+ const useStyles$6 = makeStyles$1(theme => ({
20841
21210
  item: {
20842
21211
  backgroundColor: theme.palette.background.paper,
20843
21212
  position: 'relative',
@@ -20860,7 +21229,7 @@
20860
21229
  moreAlignTo = null,
20861
21230
  onClose = () => {}
20862
21231
  } = _ref;
20863
- const classes = useStyles$5(); // If originated from the `more` item show fields directly
21232
+ const classes = useStyles$6(); // If originated from the `more` item show fields directly
20864
21233
 
20865
21234
  const [showFields, setShowFields] = react.exports.useState(!!moreAlignTo);
20866
21235
  const [showStateIx, setShowStateIx] = react.exports.useState(-1); // If originated from the `more` item align it
@@ -21000,7 +21369,7 @@
21000
21369
  }) : Component;
21001
21370
  }
21002
21371
 
21003
- const useStyles$4 = makeStyles$1(theme => ({
21372
+ const useStyles$5 = makeStyles$1(theme => ({
21004
21373
  item: {
21005
21374
  backgroundColor: theme.palette.background.paper,
21006
21375
  position: 'relative',
@@ -21021,7 +21390,7 @@
21021
21390
  items = [],
21022
21391
  api
21023
21392
  } = _ref;
21024
- const classes = useStyles$4();
21393
+ const classes = useStyles$5();
21025
21394
  const theme = useTheme$2();
21026
21395
  const [showMoreItems, setShowMoreItems] = react.exports.useState(false);
21027
21396
  const [showItemIx, setShowItemIx] = react.exports.useState(-1);
@@ -21340,7 +21709,7 @@
21340
21709
  }, /*#__PURE__*/React.createElement(ClearSelections, null))));
21341
21710
  }
21342
21711
 
21343
- const AppSelections = _ref => {
21712
+ function AppSelections(_ref) {
21344
21713
  let {
21345
21714
  app
21346
21715
  } = _ref;
@@ -21374,7 +21743,7 @@
21374
21743
  api: appSelections,
21375
21744
  app: app
21376
21745
  })));
21377
- };
21746
+ }
21378
21747
  function mount(_ref2) {
21379
21748
  let {
21380
21749
  element,
@@ -21868,33 +22237,26 @@
21868
22237
  style: {}
21869
22238
  };
21870
22239
 
21871
- function ListBoxPortal(_ref) {
21872
- let {
21873
- app,
21874
- fieldIdentifier,
21875
- stateName,
21876
- element,
21877
- options
21878
- } = _ref;
21879
- return ReactDOM.createPortal( /*#__PURE__*/React.createElement(ListBoxInline, {
21880
- app: app,
21881
- fieldIdentifier: fieldIdentifier,
21882
- stateName: stateName,
21883
- options: options
21884
- }), element);
21885
- }
21886
- function ListBoxInline(_ref2) {
22240
+ const useStyles$4 = makeStyles$1(() => ({
22241
+ listBoxHeader: {
22242
+ alignSelf: 'center',
22243
+ display: 'inline-flex'
22244
+ }
22245
+ }));
22246
+ function ListBoxInline(_ref) {
21887
22247
  let {
21888
22248
  app,
21889
22249
  fieldIdentifier,
21890
22250
  stateName = '$',
21891
- options = {}
21892
- } = _ref2;
22251
+ options = {},
22252
+ fieldDef
22253
+ } = _ref;
21893
22254
  const {
21894
22255
  title,
21895
22256
  direction,
21896
22257
  listLayout,
21897
22258
  search = true,
22259
+ focusSearch = false,
21898
22260
  toolbar = true,
21899
22261
  rangeSelect = true,
21900
22262
  checkboxes = false,
@@ -21902,9 +22264,43 @@
21902
22264
  sessionModel = undefined,
21903
22265
  selectionsApi = undefined,
21904
22266
  update = undefined,
21905
- dense = false
22267
+ dense = false,
22268
+ selectDisabled = () => false
22269
+ } = options;
22270
+ let {
22271
+ frequencyMode,
22272
+ histogram = false
21906
22273
  } = options;
21907
22274
 
22275
+ if (fieldDef && fieldDef.failedToFetchFieldDef) {
22276
+ histogram = false;
22277
+ frequencyMode = 'N';
22278
+ }
22279
+
22280
+ switch (true) {
22281
+ case ['none', 'N', 'NX_FREQUENCY_NONE'].includes(frequencyMode):
22282
+ frequencyMode = 'N';
22283
+ break;
22284
+
22285
+ case ['value', 'V', 'NX_FREQUENCY_VALUE', 'default'].includes(frequencyMode):
22286
+ frequencyMode = 'V';
22287
+ break;
22288
+
22289
+ case ['percent', 'P', 'NX_FREQUENCY_PERCENT'].includes(frequencyMode):
22290
+ frequencyMode = 'P';
22291
+ break;
22292
+
22293
+ case ['relative', 'R', 'NX_FREQUENCY_RELATIVE'].includes(frequencyMode):
22294
+ frequencyMode = 'R';
22295
+ break;
22296
+
22297
+ default:
22298
+ frequencyMode = 'N';
22299
+ break;
22300
+ }
22301
+
22302
+ const getListdefFrequencyMode = () => histogram && frequencyMode === 'N' ? 'V' : frequencyMode;
22303
+
21908
22304
  const listdef = _objectSpread2({
21909
22305
  qInfo: {
21910
22306
  qType: 'njsListbox'
@@ -21912,6 +22308,7 @@
21912
22308
  qListObjectDef: {
21913
22309
  qStateName: stateName,
21914
22310
  qShowAlternatives: true,
22311
+ qFrequencyMode: getListdefFrequencyMode(),
21915
22312
  qInitialDataFetch: [{
21916
22313
  qTop: 0,
21917
22314
  qLeft: 0,
@@ -21941,6 +22338,13 @@
21941
22338
  fieldName = fieldIdentifier;
21942
22339
  }
21943
22340
 
22341
+ if (frequencyMode !== 'N' || histogram) {
22342
+ const field = fieldIdentifier.qLibraryId ? fieldDef : fieldName;
22343
+ listdef.frequencyMax = {
22344
+ qValueExpression: "Max(AGGR(Count([".concat(field, "]), [").concat(field, "]))")
22345
+ };
22346
+ }
22347
+
21944
22348
  let [model] = useSessionModel(listdef, sessionModel ? null : app, fieldName, stateName);
21945
22349
 
21946
22350
  if (sessionModel) {
@@ -21954,6 +22358,7 @@
21954
22358
  }
21955
22359
 
21956
22360
  const theme = useTheme$2();
22361
+ const classes = useStyles$4();
21957
22362
  const lock = react.exports.useCallback(() => {
21958
22363
  model.lock('/qListObjectDef');
21959
22364
  }, [model]);
@@ -21961,11 +22366,24 @@
21961
22366
  model.unlock('/qListObjectDef');
21962
22367
  }, [model]);
21963
22368
  const {
21964
- translator
22369
+ translator,
22370
+ keyboardNavigation
21965
22371
  } = react.exports.useContext(InstanceContext);
21966
22372
  const moreAlignTo = react.exports.useRef();
21967
22373
  const [layout] = useLayout$1(model);
21968
22374
  const [showToolbar, setShowToolbar] = react.exports.useState(false);
22375
+ const [showSearch, setShowSearch] = react.exports.useState(false);
22376
+ const [autoFocusSearch, setAutoFocusSearch] = react.exports.useState(focusSearch);
22377
+ const [keyboardActive, setKeyboardActive] = react.exports.useState(false);
22378
+ const handleKeyDown = getListboxInlineKeyboardNavigation({
22379
+ setKeyboardActive
22380
+ }); // Expose the keyboard flags in the same way as the keyboard hook does.
22381
+
22382
+ const keyboard = {
22383
+ enabled: keyboardNavigation,
22384
+ // this will be static until we can access the useKeyboard hook
22385
+ active: keyboardActive
22386
+ };
21969
22387
  react.exports.useEffect(() => {
21970
22388
  if (selections) {
21971
22389
  if (!selections.isModal(model)) {
@@ -21996,32 +22414,52 @@
21996
22414
  }) : [];
21997
22415
  const counts = layout.qListObject.qDimensionInfo.qStateCounts;
21998
22416
  const hasSelections = counts.qSelected + counts.qSelectedExcluded + counts.qLocked + counts.qLockedExcluded > 0;
21999
- const minHeight = 49 + (search ? 40 : 0) + 49;
22417
+ const searchVisible = (search === true || search === 'toggle' && showSearch) && !selectDisabled();
22418
+ const minHeight = 49 + (searchVisible ? 40 : 0) + 49;
22419
+
22420
+ const onShowSearch = () => {
22421
+ const newValue = !showSearch;
22422
+ setShowSearch(newValue);
22423
+ setAutoFocusSearch(newValue);
22424
+ };
22425
+
22426
+ const getSearchOrUnlock = () => search === 'toggle' && !hasSelections ? /*#__PURE__*/React.createElement(IconButton$1, {
22427
+ onClick: onShowSearch,
22428
+ tabIndex: -1,
22429
+ title: translator.get('Listbox.Search')
22430
+ }, /*#__PURE__*/React.createElement(SearchIcon, null)) : /*#__PURE__*/React.createElement(IconButton$1, {
22431
+ onClick: lock,
22432
+ tabIndex: -1,
22433
+ disabled: !hasSelections
22434
+ }, /*#__PURE__*/React.createElement(Unlock, null));
22435
+
22000
22436
  return /*#__PURE__*/React.createElement(Grid$1, {
22001
22437
  container: true,
22438
+ tabIndex: keyboard.enabled && !keyboard.active ? 0 : -1,
22002
22439
  direction: "column",
22003
22440
  spacing: 0,
22004
22441
  style: {
22005
22442
  height: '100%',
22006
22443
  minHeight: "".concat(minHeight, "px")
22007
- }
22444
+ },
22445
+ onKeyDown: handleKeyDown
22008
22446
  }, toolbar && /*#__PURE__*/React.createElement(Grid$1, {
22009
22447
  item: true,
22010
22448
  container: true,
22011
22449
  style: {
22012
- padding: theme.spacing(1),
22013
- borderBottom: "1px solid ".concat(theme.palette.divider)
22450
+ padding: theme.spacing(1)
22014
22451
  }
22015
22452
  }, /*#__PURE__*/React.createElement(Grid$1, {
22016
22453
  item: true
22017
22454
  }, isLocked ? /*#__PURE__*/React.createElement(IconButton$1, {
22455
+ tabIndex: -1,
22018
22456
  onClick: unlock,
22019
22457
  disabled: !isLocked
22020
- }, /*#__PURE__*/React.createElement(Lock, null)) : /*#__PURE__*/React.createElement(IconButton$1, {
22021
- onClick: lock,
22022
- disabled: !hasSelections
22023
- }, /*#__PURE__*/React.createElement(Unlock, null))), /*#__PURE__*/React.createElement(Grid$1, {
22024
- item: true
22458
+ }, /*#__PURE__*/React.createElement(Lock, {
22459
+ title: translator.get('Listbox.Unlock')
22460
+ })) : getSearchOrUnlock()), /*#__PURE__*/React.createElement(Grid$1, {
22461
+ item: true,
22462
+ className: classes.listBoxHeader
22025
22463
  }, /*#__PURE__*/React.createElement(Typography$1, {
22026
22464
  variant: "h6",
22027
22465
  noWrap: true
@@ -22049,37 +22487,103 @@
22049
22487
  onConfirm: () => {},
22050
22488
  onCancel: () => {}
22051
22489
  }
22052
- }))), search ? /*#__PURE__*/React.createElement(Grid$1, {
22490
+ }))), searchVisible && /*#__PURE__*/React.createElement(Grid$1, {
22053
22491
  item: true
22054
22492
  }, /*#__PURE__*/React.createElement(ListBoxSearch, {
22055
22493
  model: model,
22056
- autoFocus: false,
22057
- dense: dense
22058
- })) : '', /*#__PURE__*/React.createElement(Grid$1, {
22494
+ autoFocus: autoFocusSearch,
22495
+ dense: dense,
22496
+ keyboard: keyboard
22497
+ })), /*#__PURE__*/React.createElement(Grid$1, {
22059
22498
  item: true,
22060
22499
  xs: true
22061
22500
  }, /*#__PURE__*/React.createElement("div", {
22062
22501
  ref: moreAlignTo
22063
- }), /*#__PURE__*/React.createElement(AutoSizer, null, _ref3 => {
22502
+ }), /*#__PURE__*/React.createElement(AutoSizer, null, _ref2 => {
22064
22503
  let {
22065
22504
  height,
22066
22505
  width
22067
- } = _ref3;
22506
+ } = _ref2;
22068
22507
  return /*#__PURE__*/React.createElement(ListBox, {
22069
22508
  model: model,
22070
22509
  selections: selections,
22071
22510
  direction: direction,
22072
22511
  listLayout: listLayout,
22512
+ frequencyMode: frequencyMode,
22513
+ histogram: histogram,
22073
22514
  rangeSelect: rangeSelect,
22074
22515
  checkboxes: checkboxes,
22075
22516
  height: height,
22076
22517
  width: width,
22077
22518
  update: update,
22078
- dense: dense
22519
+ dense: dense,
22520
+ selectDisabled: selectDisabled,
22521
+ keyboard: keyboard
22079
22522
  });
22080
22523
  })));
22081
22524
  }
22082
22525
 
22526
+ function ListBoxFetchMasterItem(_ref) {
22527
+ let {
22528
+ app,
22529
+ fieldIdentifier,
22530
+ stateName = '$',
22531
+ options = {}
22532
+ } = _ref;
22533
+ const [fieldDef, setFieldDef] = react.exports.useState('');
22534
+ const [isFetchingData, setIsFetchingData] = react.exports.useState(false);
22535
+ react.exports.useEffect(() => {
22536
+ async function fetchData() {
22537
+ setIsFetchingData(true);
22538
+
22539
+ try {
22540
+ const dim = await app.getDimension(fieldIdentifier.qLibraryId);
22541
+ const dimLayout = await dim.getLayout();
22542
+ setFieldDef(dimLayout.qDim.qFieldDefs ? dimLayout.qDim.qFieldDefs[0] : '');
22543
+ setIsFetchingData(false);
22544
+ } catch (e) {
22545
+ setIsFetchingData(false);
22546
+ setFieldDef({
22547
+ failedToFetchFieldDef: true
22548
+ });
22549
+ throw new Error("Disabling frequency count and histogram: ".concat(e && e.message));
22550
+ }
22551
+ }
22552
+
22553
+ fetchData();
22554
+ }, []);
22555
+
22556
+ if (isFetchingData) {
22557
+ return null;
22558
+ }
22559
+
22560
+ return /*#__PURE__*/React.createElement(ListBoxInline, {
22561
+ app: app,
22562
+ fieldIdentifier: fieldIdentifier,
22563
+ stateName: stateName,
22564
+ options: options,
22565
+ fieldDef: fieldDef
22566
+ });
22567
+ }
22568
+ function ListBoxPortal(_ref2) {
22569
+ let {
22570
+ app,
22571
+ fieldIdentifier,
22572
+ stateName,
22573
+ element,
22574
+ options
22575
+ } = _ref2;
22576
+ const isFrequencyMaxNeeded = options.histogram || options.frequencyMode !== 'N';
22577
+ const TheComponent = fieldIdentifier.qLibraryId && isFrequencyMaxNeeded ? ListBoxFetchMasterItem : ListBoxInline;
22578
+ return ReactDOM.createPortal( /*#__PURE__*/React.createElement(TheComponent, {
22579
+ app: app,
22580
+ fieldIdentifier: fieldIdentifier,
22581
+ stateName: stateName,
22582
+ element: element,
22583
+ options: options
22584
+ }), element);
22585
+ }
22586
+
22083
22587
  const idGen = [[10, 31], [0, 31], [0, 31], [0, 31], [0, 31], [0, 31]];
22084
22588
 
22085
22589
  function toChar(_ref) {
@@ -23255,7 +23759,7 @@
23255
23759
 
23256
23760
  /* eslint-disable react/no-array-index-key */
23257
23761
 
23258
- const DescriptionRow = _ref => {
23762
+ function DescriptionRow(_ref) {
23259
23763
  let {
23260
23764
  d
23261
23765
  } = _ref;
@@ -23312,9 +23816,9 @@
23312
23816
  fontWeight: 400
23313
23817
  }
23314
23818
  }, d.label))));
23315
- };
23819
+ }
23316
23820
 
23317
- const Descriptions = _ref2 => {
23821
+ function Descriptions(_ref2) {
23318
23822
  let {
23319
23823
  data
23320
23824
  } = _ref2;
@@ -23347,7 +23851,7 @@
23347
23851
  color: "textSecondary"
23348
23852
  }, e.title), Rows);
23349
23853
  }));
23350
- };
23854
+ }
23351
23855
 
23352
23856
  function Error$1(_ref3) {
23353
23857
  let {
@@ -23452,7 +23956,7 @@
23452
23956
  }
23453
23957
  }
23454
23958
  }));
23455
- const Cancel = _ref => {
23959
+ function Cancel(_ref) {
23456
23960
  let {
23457
23961
  cancel,
23458
23962
  translator
@@ -23478,8 +23982,8 @@
23478
23982
  variant: "contained",
23479
23983
  onClick: cancel
23480
23984
  }, translator.get('Cancel'))));
23481
- };
23482
- const Retry = _ref2 => {
23985
+ }
23986
+ function Retry(_ref2) {
23483
23987
  let {
23484
23988
  retry,
23485
23989
  translator
@@ -23503,7 +24007,7 @@
23503
24007
  variant: "contained",
23504
24008
  onClick: retry
23505
24009
  }, props), translator.get('Retry'))));
23506
- };
24010
+ }
23507
24011
  function LongRunningQuery(_ref3) {
23508
24012
  let {
23509
24013
  canCancel,
@@ -23597,7 +24101,7 @@
23597
24101
  }
23598
24102
  }));
23599
24103
 
23600
- const Header = _ref => {
24104
+ function Header(_ref) {
23601
24105
  let {
23602
24106
  layout,
23603
24107
  sn,
@@ -23674,7 +24178,7 @@
23674
24178
  }, layout.subtitle))), /*#__PURE__*/React.createElement(Grid$1, {
23675
24179
  item: true
23676
24180
  }, Toolbar));
23677
- };
24181
+ }
23678
24182
 
23679
24183
  /**
23680
24184
  * @interface
@@ -23693,7 +24197,7 @@
23693
24197
  }
23694
24198
  }));
23695
24199
 
23696
- const Footer = _ref => {
24200
+ function Footer(_ref) {
23697
24201
  let {
23698
24202
  layout
23699
24203
  } = _ref;
@@ -23710,7 +24214,7 @@
23710
24214
  variant: "body2",
23711
24215
  className: CellFooter.className
23712
24216
  }, layout.footnote))) : null;
23713
- };
24217
+ }
23714
24218
 
23715
24219
  class RenderDebouncer {
23716
24220
  constructor() {
@@ -23780,7 +24284,7 @@
23780
24284
  className: 'njs-viz'
23781
24285
  };
23782
24286
 
23783
- const Supernova = _ref => {
24287
+ function Supernova(_ref) {
23784
24288
  let {
23785
24289
  sn,
23786
24290
  snOptions: options,
@@ -23900,7 +24404,7 @@
23900
24404
  height: '100%'
23901
24405
  }
23902
24406
  }));
23903
- };
24407
+ }
23904
24408
 
23905
24409
  /**
23906
24410
  * @interface
@@ -23978,7 +24482,7 @@
23978
24482
  }
23979
24483
  };
23980
24484
 
23981
- const LoadingSn = _ref => {
24485
+ function LoadingSn(_ref) {
23982
24486
  let {
23983
24487
  delay = 750
23984
24488
  } = _ref;
@@ -23988,7 +24492,7 @@
23988
24492
  return () => clearTimeout(handle);
23989
24493
  }, []);
23990
24494
  return showLoading ? /*#__PURE__*/React.createElement(Loading, null) : null;
23991
- };
24495
+ }
23992
24496
 
23993
24497
  const handleModal = _ref2 => {
23994
24498
  let {
@@ -24563,7 +25067,8 @@
24563
25067
  }
24564
25068
 
24565
25069
  return a === b;
24566
- }
25070
+ } // eslint-disable-next-line default-param-last
25071
+
24567
25072
 
24568
25073
  function getPatches() {
24569
25074
  let path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
@@ -25435,7 +25940,7 @@
25435
25940
  /* eslint no-console: 0 */
25436
25941
 
25437
25942
  /* eslint no-use-before-define: 0 */
25438
- // Hooks implementation heavily inspired by prect hooks
25943
+ // Hooks implementation heavily inspired by preact hooks
25439
25944
  let currentComponent;
25440
25945
  let currentIndex;
25441
25946
 
@@ -27245,1556 +27750,1603 @@
27245
27750
  var semver = {exports: {}};
27246
27751
 
27247
27752
  (function (module, exports) {
27248
- exports = module.exports = SemVer;
27249
- var debug;
27250
- /* istanbul ignore next */
27251
-
27252
- if (typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
27253
- debug = function () {
27254
- var args = Array.prototype.slice.call(arguments, 0);
27255
- args.unshift('SEMVER');
27256
- console.log.apply(console, args);
27257
- };
27258
- } else {
27259
- debug = function () {};
27260
- } // Note: this is the semver.org version of the spec that it implements
27261
- // Not necessarily the package version of this code.
27262
-
27263
-
27264
- exports.SEMVER_SPEC_VERSION = '2.0.0';
27265
- var MAX_LENGTH = 256;
27266
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
27267
- /* istanbul ignore next */
27268
- 9007199254740991; // Max safe segment length for coercion.
27269
-
27270
- var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
27271
-
27272
- var re = exports.re = [];
27273
- var src = exports.src = [];
27274
- var t = exports.tokens = {};
27275
- var R = 0;
27276
-
27277
- function tok(n) {
27278
- t[n] = R++;
27279
- } // The following Regular Expressions can be used for tokenizing,
27280
- // validating, and parsing SemVer version strings.
27281
- // ## Numeric Identifier
27282
- // A single `0`, or a non-zero digit followed by zero or more digits.
27283
-
27284
-
27285
- tok('NUMERICIDENTIFIER');
27286
- src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
27287
- tok('NUMERICIDENTIFIERLOOSE');
27288
- src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
27289
- // Zero or more digits, followed by a letter or hyphen, and then zero or
27290
- // more letters, digits, or hyphens.
27291
-
27292
- tok('NONNUMERICIDENTIFIER');
27293
- src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
27294
- // Three dot-separated numeric identifiers.
27295
-
27296
- tok('MAINVERSION');
27297
- src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + '(' + src[t.NUMERICIDENTIFIER] + ')';
27298
- tok('MAINVERSIONLOOSE');
27299
- src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
27300
- // A numeric identifier, or a non-numeric identifier.
27301
-
27302
- tok('PRERELEASEIDENTIFIER');
27303
- src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + '|' + src[t.NONNUMERICIDENTIFIER] + ')';
27304
- tok('PRERELEASEIDENTIFIERLOOSE');
27305
- src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + '|' + src[t.NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
27306
- // Hyphen, followed by one or more dot-separated pre-release version
27307
- // identifiers.
27308
-
27309
- tok('PRERELEASE');
27310
- src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
27311
- tok('PRERELEASELOOSE');
27312
- src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
27313
- // Any combination of digits, letters, or hyphens.
27314
-
27315
- tok('BUILDIDENTIFIER');
27316
- src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
27317
- // Plus sign, followed by one or more period-separated build metadata
27318
- // identifiers.
27319
-
27320
- tok('BUILD');
27321
- src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'; // ## Full Version String
27322
- // A main version, followed optionally by a pre-release version and
27323
- // build metadata.
27324
- // Note that the only major, minor, patch, and pre-release sections of
27325
- // the version string are capturing groups. The build metadata is not a
27326
- // capturing group, because it should not ever be used in version
27327
- // comparison.
27328
-
27329
- tok('FULL');
27330
- tok('FULLPLAIN');
27331
- src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?';
27332
- src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
27333
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
27334
- // common in the npm registry.
27335
-
27336
- tok('LOOSEPLAIN');
27337
- src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + '?' + src[t.BUILD] + '?';
27338
- tok('LOOSE');
27339
- src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
27340
- tok('GTLT');
27341
- src[t.GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
27342
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
27343
- // Only the first item is strictly required.
27344
-
27345
- tok('XRANGEIDENTIFIERLOOSE');
27346
- src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
27347
- tok('XRANGEIDENTIFIER');
27348
- src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
27349
- tok('XRANGEPLAIN');
27350
- src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + '(?:' + src[t.PRERELEASE] + ')?' + src[t.BUILD] + '?' + ')?)?';
27351
- tok('XRANGEPLAINLOOSE');
27352
- src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[t.PRERELEASELOOSE] + ')?' + src[t.BUILD] + '?' + ')?)?';
27353
- tok('XRANGE');
27354
- src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
27355
- tok('XRANGELOOSE');
27356
- src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'; // Coercion.
27357
- // Extract anything that could conceivably be a part of a valid semver
27358
-
27359
- tok('COERCE');
27360
- src[t.COERCE] = '(^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
27361
- tok('COERCERTL');
27362
- re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g'); // Tilde ranges.
27363
- // Meaning is "reasonably at or greater than"
27364
-
27365
- tok('LONETILDE');
27366
- src[t.LONETILDE] = '(?:~>?)';
27367
- tok('TILDETRIM');
27368
- src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
27369
- re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
27370
- var tildeTrimReplace = '$1~';
27371
- tok('TILDE');
27372
- src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
27373
- tok('TILDELOOSE');
27374
- src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'; // Caret ranges.
27375
- // Meaning is "at least and backwards compatible with"
27376
-
27377
- tok('LONECARET');
27378
- src[t.LONECARET] = '(?:\\^)';
27379
- tok('CARETTRIM');
27380
- src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
27381
- re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
27382
- var caretTrimReplace = '$1^';
27383
- tok('CARET');
27384
- src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
27385
- tok('CARETLOOSE');
27386
- src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
27387
-
27388
- tok('COMPARATORLOOSE');
27389
- src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
27390
- tok('COMPARATOR');
27391
- src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
27392
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
27393
-
27394
- tok('COMPARATORTRIM');
27395
- src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'; // this one has to use the /g flag
27396
-
27397
- re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
27398
- var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
27399
- // Note that these all use the loose form, because they'll be
27400
- // checked against either the strict or loose comparator form
27401
- // later.
27402
-
27403
- tok('HYPHENRANGE');
27404
- src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAIN] + ')' + '\\s*$';
27405
- tok('HYPHENRANGELOOSE');
27406
- src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[t.XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
27407
-
27408
- tok('STAR');
27409
- src[t.STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
27410
- // All are flag-free, unless they were created above with a flag.
27411
-
27412
- for (var i = 0; i < R; i++) {
27413
- debug(i, src[i]);
27414
-
27415
- if (!re[i]) {
27416
- re[i] = new RegExp(src[i]);
27417
- }
27418
- }
27419
-
27420
- exports.parse = parse;
27421
-
27422
- function parse(version, options) {
27423
- if (!options || typeof options !== 'object') {
27424
- options = {
27425
- loose: !!options,
27426
- includePrerelease: false
27427
- };
27428
- }
27753
+ exports = module.exports = SemVer;
27754
+
27755
+ var debug;
27756
+ /* istanbul ignore next */
27757
+ if (typeof process === 'object' &&
27758
+ process.env &&
27759
+ process.env.NODE_DEBUG &&
27760
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
27761
+ debug = function () {
27762
+ var args = Array.prototype.slice.call(arguments, 0);
27763
+ args.unshift('SEMVER');
27764
+ console.log.apply(console, args);
27765
+ };
27766
+ } else {
27767
+ debug = function () {};
27768
+ }
27429
27769
 
27430
- if (version instanceof SemVer) {
27431
- return version;
27432
- }
27770
+ // Note: this is the semver.org version of the spec that it implements
27771
+ // Not necessarily the package version of this code.
27772
+ exports.SEMVER_SPEC_VERSION = '2.0.0';
27433
27773
 
27434
- if (typeof version !== 'string') {
27435
- return null;
27436
- }
27774
+ var MAX_LENGTH = 256;
27775
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
27776
+ /* istanbul ignore next */ 9007199254740991;
27437
27777
 
27438
- if (version.length > MAX_LENGTH) {
27439
- return null;
27440
- }
27778
+ // Max safe segment length for coercion.
27779
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
27441
27780
 
27442
- var r = options.loose ? re[t.LOOSE] : re[t.FULL];
27781
+ // The actual regexps go on exports.re
27782
+ var re = exports.re = [];
27783
+ var src = exports.src = [];
27784
+ var t = exports.tokens = {};
27785
+ var R = 0;
27443
27786
 
27444
- if (!r.test(version)) {
27445
- return null;
27446
- }
27787
+ function tok (n) {
27788
+ t[n] = R++;
27789
+ }
27447
27790
 
27448
- try {
27449
- return new SemVer(version, options);
27450
- } catch (er) {
27451
- return null;
27452
- }
27791
+ // The following Regular Expressions can be used for tokenizing,
27792
+ // validating, and parsing SemVer version strings.
27793
+
27794
+ // ## Numeric Identifier
27795
+ // A single `0`, or a non-zero digit followed by zero or more digits.
27796
+
27797
+ tok('NUMERICIDENTIFIER');
27798
+ src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
27799
+ tok('NUMERICIDENTIFIERLOOSE');
27800
+ src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
27801
+
27802
+ // ## Non-numeric Identifier
27803
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
27804
+ // more letters, digits, or hyphens.
27805
+
27806
+ tok('NONNUMERICIDENTIFIER');
27807
+ src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
27808
+
27809
+ // ## Main Version
27810
+ // Three dot-separated numeric identifiers.
27811
+
27812
+ tok('MAINVERSION');
27813
+ src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
27814
+ '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
27815
+ '(' + src[t.NUMERICIDENTIFIER] + ')';
27816
+
27817
+ tok('MAINVERSIONLOOSE');
27818
+ src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
27819
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
27820
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
27821
+
27822
+ // ## Pre-release Version Identifier
27823
+ // A numeric identifier, or a non-numeric identifier.
27824
+
27825
+ tok('PRERELEASEIDENTIFIER');
27826
+ src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
27827
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
27828
+
27829
+ tok('PRERELEASEIDENTIFIERLOOSE');
27830
+ src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
27831
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
27832
+
27833
+ // ## Pre-release Version
27834
+ // Hyphen, followed by one or more dot-separated pre-release version
27835
+ // identifiers.
27836
+
27837
+ tok('PRERELEASE');
27838
+ src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
27839
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
27840
+
27841
+ tok('PRERELEASELOOSE');
27842
+ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
27843
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
27844
+
27845
+ // ## Build Metadata Identifier
27846
+ // Any combination of digits, letters, or hyphens.
27847
+
27848
+ tok('BUILDIDENTIFIER');
27849
+ src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
27850
+
27851
+ // ## Build Metadata
27852
+ // Plus sign, followed by one or more period-separated build metadata
27853
+ // identifiers.
27854
+
27855
+ tok('BUILD');
27856
+ src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
27857
+ '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
27858
+
27859
+ // ## Full Version String
27860
+ // A main version, followed optionally by a pre-release version and
27861
+ // build metadata.
27862
+
27863
+ // Note that the only major, minor, patch, and pre-release sections of
27864
+ // the version string are capturing groups. The build metadata is not a
27865
+ // capturing group, because it should not ever be used in version
27866
+ // comparison.
27867
+
27868
+ tok('FULL');
27869
+ tok('FULLPLAIN');
27870
+ src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
27871
+ src[t.PRERELEASE] + '?' +
27872
+ src[t.BUILD] + '?';
27873
+
27874
+ src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
27875
+
27876
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
27877
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
27878
+ // common in the npm registry.
27879
+ tok('LOOSEPLAIN');
27880
+ src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
27881
+ src[t.PRERELEASELOOSE] + '?' +
27882
+ src[t.BUILD] + '?';
27883
+
27884
+ tok('LOOSE');
27885
+ src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
27886
+
27887
+ tok('GTLT');
27888
+ src[t.GTLT] = '((?:<|>)?=?)';
27889
+
27890
+ // Something like "2.*" or "1.2.x".
27891
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
27892
+ // Only the first item is strictly required.
27893
+ tok('XRANGEIDENTIFIERLOOSE');
27894
+ src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
27895
+ tok('XRANGEIDENTIFIER');
27896
+ src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
27897
+
27898
+ tok('XRANGEPLAIN');
27899
+ src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
27900
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
27901
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
27902
+ '(?:' + src[t.PRERELEASE] + ')?' +
27903
+ src[t.BUILD] + '?' +
27904
+ ')?)?';
27905
+
27906
+ tok('XRANGEPLAINLOOSE');
27907
+ src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
27908
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
27909
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
27910
+ '(?:' + src[t.PRERELEASELOOSE] + ')?' +
27911
+ src[t.BUILD] + '?' +
27912
+ ')?)?';
27913
+
27914
+ tok('XRANGE');
27915
+ src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
27916
+ tok('XRANGELOOSE');
27917
+ src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
27918
+
27919
+ // Coercion.
27920
+ // Extract anything that could conceivably be a part of a valid semver
27921
+ tok('COERCE');
27922
+ src[t.COERCE] = '(^|[^\\d])' +
27923
+ '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
27924
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
27925
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
27926
+ '(?:$|[^\\d])';
27927
+ tok('COERCERTL');
27928
+ re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
27929
+
27930
+ // Tilde ranges.
27931
+ // Meaning is "reasonably at or greater than"
27932
+ tok('LONETILDE');
27933
+ src[t.LONETILDE] = '(?:~>?)';
27934
+
27935
+ tok('TILDETRIM');
27936
+ src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
27937
+ re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
27938
+ var tildeTrimReplace = '$1~';
27939
+
27940
+ tok('TILDE');
27941
+ src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
27942
+ tok('TILDELOOSE');
27943
+ src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
27944
+
27945
+ // Caret ranges.
27946
+ // Meaning is "at least and backwards compatible with"
27947
+ tok('LONECARET');
27948
+ src[t.LONECARET] = '(?:\\^)';
27949
+
27950
+ tok('CARETTRIM');
27951
+ src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
27952
+ re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
27953
+ var caretTrimReplace = '$1^';
27954
+
27955
+ tok('CARET');
27956
+ src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
27957
+ tok('CARETLOOSE');
27958
+ src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
27959
+
27960
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
27961
+ tok('COMPARATORLOOSE');
27962
+ src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
27963
+ tok('COMPARATOR');
27964
+ src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
27965
+
27966
+ // An expression to strip any whitespace between the gtlt and the thing
27967
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
27968
+ tok('COMPARATORTRIM');
27969
+ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
27970
+ '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
27971
+
27972
+ // this one has to use the /g flag
27973
+ re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
27974
+ var comparatorTrimReplace = '$1$2$3';
27975
+
27976
+ // Something like `1.2.3 - 1.2.4`
27977
+ // Note that these all use the loose form, because they'll be
27978
+ // checked against either the strict or loose comparator form
27979
+ // later.
27980
+ tok('HYPHENRANGE');
27981
+ src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
27982
+ '\\s+-\\s+' +
27983
+ '(' + src[t.XRANGEPLAIN] + ')' +
27984
+ '\\s*$';
27985
+
27986
+ tok('HYPHENRANGELOOSE');
27987
+ src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
27988
+ '\\s+-\\s+' +
27989
+ '(' + src[t.XRANGEPLAINLOOSE] + ')' +
27990
+ '\\s*$';
27991
+
27992
+ // Star ranges basically just allow anything at all.
27993
+ tok('STAR');
27994
+ src[t.STAR] = '(<|>)?=?\\s*\\*';
27995
+
27996
+ // Compile to actual regexp objects.
27997
+ // All are flag-free, unless they were created above with a flag.
27998
+ for (var i = 0; i < R; i++) {
27999
+ debug(i, src[i]);
28000
+ if (!re[i]) {
28001
+ re[i] = new RegExp(src[i]);
28002
+ }
28003
+ }
28004
+
28005
+ exports.parse = parse;
28006
+ function parse (version, options) {
28007
+ if (!options || typeof options !== 'object') {
28008
+ options = {
28009
+ loose: !!options,
28010
+ includePrerelease: false
28011
+ };
27453
28012
  }
27454
28013
 
27455
- exports.valid = valid;
28014
+ if (version instanceof SemVer) {
28015
+ return version
28016
+ }
27456
28017
 
27457
- function valid(version, options) {
27458
- var v = parse(version, options);
27459
- return v ? v.version : null;
28018
+ if (typeof version !== 'string') {
28019
+ return null
27460
28020
  }
27461
28021
 
27462
- exports.clean = clean;
28022
+ if (version.length > MAX_LENGTH) {
28023
+ return null
28024
+ }
27463
28025
 
27464
- function clean(version, options) {
27465
- var s = parse(version.trim().replace(/^[=v]+/, ''), options);
27466
- return s ? s.version : null;
28026
+ var r = options.loose ? re[t.LOOSE] : re[t.FULL];
28027
+ if (!r.test(version)) {
28028
+ return null
27467
28029
  }
27468
28030
 
27469
- exports.SemVer = SemVer;
28031
+ try {
28032
+ return new SemVer(version, options)
28033
+ } catch (er) {
28034
+ return null
28035
+ }
28036
+ }
27470
28037
 
27471
- function SemVer(version, options) {
27472
- if (!options || typeof options !== 'object') {
27473
- options = {
27474
- loose: !!options,
27475
- includePrerelease: false
27476
- };
27477
- }
28038
+ exports.valid = valid;
28039
+ function valid (version, options) {
28040
+ var v = parse(version, options);
28041
+ return v ? v.version : null
28042
+ }
27478
28043
 
27479
- if (version instanceof SemVer) {
27480
- if (version.loose === options.loose) {
27481
- return version;
27482
- } else {
27483
- version = version.version;
27484
- }
27485
- } else if (typeof version !== 'string') {
27486
- throw new TypeError('Invalid Version: ' + version);
27487
- }
28044
+ exports.clean = clean;
28045
+ function clean (version, options) {
28046
+ var s = parse(version.trim().replace(/^[=v]+/, ''), options);
28047
+ return s ? s.version : null
28048
+ }
27488
28049
 
27489
- if (version.length > MAX_LENGTH) {
27490
- throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
27491
- }
28050
+ exports.SemVer = SemVer;
27492
28051
 
27493
- if (!(this instanceof SemVer)) {
27494
- return new SemVer(version, options);
28052
+ function SemVer (version, options) {
28053
+ if (!options || typeof options !== 'object') {
28054
+ options = {
28055
+ loose: !!options,
28056
+ includePrerelease: false
28057
+ };
28058
+ }
28059
+ if (version instanceof SemVer) {
28060
+ if (version.loose === options.loose) {
28061
+ return version
28062
+ } else {
28063
+ version = version.version;
27495
28064
  }
28065
+ } else if (typeof version !== 'string') {
28066
+ throw new TypeError('Invalid Version: ' + version)
28067
+ }
27496
28068
 
27497
- debug('SemVer', version, options);
27498
- this.options = options;
27499
- this.loose = !!options.loose;
27500
- var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
28069
+ if (version.length > MAX_LENGTH) {
28070
+ throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
28071
+ }
27501
28072
 
27502
- if (!m) {
27503
- throw new TypeError('Invalid Version: ' + version);
27504
- }
28073
+ if (!(this instanceof SemVer)) {
28074
+ return new SemVer(version, options)
28075
+ }
27505
28076
 
27506
- this.raw = version; // these are actually numbers
28077
+ debug('SemVer', version, options);
28078
+ this.options = options;
28079
+ this.loose = !!options.loose;
27507
28080
 
27508
- this.major = +m[1];
27509
- this.minor = +m[2];
27510
- this.patch = +m[3];
28081
+ var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
27511
28082
 
27512
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
27513
- throw new TypeError('Invalid major version');
27514
- }
28083
+ if (!m) {
28084
+ throw new TypeError('Invalid Version: ' + version)
28085
+ }
27515
28086
 
27516
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
27517
- throw new TypeError('Invalid minor version');
27518
- }
28087
+ this.raw = version;
28088
+
28089
+ // these are actually numbers
28090
+ this.major = +m[1];
28091
+ this.minor = +m[2];
28092
+ this.patch = +m[3];
27519
28093
 
27520
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
27521
- throw new TypeError('Invalid patch version');
27522
- } // numberify any prerelease numeric ids
28094
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
28095
+ throw new TypeError('Invalid major version')
28096
+ }
27523
28097
 
28098
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
28099
+ throw new TypeError('Invalid minor version')
28100
+ }
27524
28101
 
27525
- if (!m[4]) {
27526
- this.prerelease = [];
27527
- } else {
27528
- this.prerelease = m[4].split('.').map(function (id) {
27529
- if (/^[0-9]+$/.test(id)) {
27530
- var num = +id;
28102
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
28103
+ throw new TypeError('Invalid patch version')
28104
+ }
27531
28105
 
27532
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
27533
- return num;
27534
- }
28106
+ // numberify any prerelease numeric ids
28107
+ if (!m[4]) {
28108
+ this.prerelease = [];
28109
+ } else {
28110
+ this.prerelease = m[4].split('.').map(function (id) {
28111
+ if (/^[0-9]+$/.test(id)) {
28112
+ var num = +id;
28113
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
28114
+ return num
27535
28115
  }
28116
+ }
28117
+ return id
28118
+ });
28119
+ }
27536
28120
 
27537
- return id;
27538
- });
27539
- }
28121
+ this.build = m[5] ? m[5].split('.') : [];
28122
+ this.format();
28123
+ }
27540
28124
 
27541
- this.build = m[5] ? m[5].split('.') : [];
27542
- this.format();
28125
+ SemVer.prototype.format = function () {
28126
+ this.version = this.major + '.' + this.minor + '.' + this.patch;
28127
+ if (this.prerelease.length) {
28128
+ this.version += '-' + this.prerelease.join('.');
27543
28129
  }
28130
+ return this.version
28131
+ };
27544
28132
 
27545
- SemVer.prototype.format = function () {
27546
- this.version = this.major + '.' + this.minor + '.' + this.patch;
28133
+ SemVer.prototype.toString = function () {
28134
+ return this.version
28135
+ };
27547
28136
 
27548
- if (this.prerelease.length) {
27549
- this.version += '-' + this.prerelease.join('.');
27550
- }
28137
+ SemVer.prototype.compare = function (other) {
28138
+ debug('SemVer.compare', this.version, this.options, other);
28139
+ if (!(other instanceof SemVer)) {
28140
+ other = new SemVer(other, this.options);
28141
+ }
27551
28142
 
27552
- return this.version;
27553
- };
28143
+ return this.compareMain(other) || this.comparePre(other)
28144
+ };
27554
28145
 
27555
- SemVer.prototype.toString = function () {
27556
- return this.version;
27557
- };
28146
+ SemVer.prototype.compareMain = function (other) {
28147
+ if (!(other instanceof SemVer)) {
28148
+ other = new SemVer(other, this.options);
28149
+ }
27558
28150
 
27559
- SemVer.prototype.compare = function (other) {
27560
- debug('SemVer.compare', this.version, this.options, other);
28151
+ return compareIdentifiers(this.major, other.major) ||
28152
+ compareIdentifiers(this.minor, other.minor) ||
28153
+ compareIdentifiers(this.patch, other.patch)
28154
+ };
27561
28155
 
27562
- if (!(other instanceof SemVer)) {
27563
- other = new SemVer(other, this.options);
28156
+ SemVer.prototype.comparePre = function (other) {
28157
+ if (!(other instanceof SemVer)) {
28158
+ other = new SemVer(other, this.options);
28159
+ }
28160
+
28161
+ // NOT having a prerelease is > having one
28162
+ if (this.prerelease.length && !other.prerelease.length) {
28163
+ return -1
28164
+ } else if (!this.prerelease.length && other.prerelease.length) {
28165
+ return 1
28166
+ } else if (!this.prerelease.length && !other.prerelease.length) {
28167
+ return 0
28168
+ }
28169
+
28170
+ var i = 0;
28171
+ do {
28172
+ var a = this.prerelease[i];
28173
+ var b = other.prerelease[i];
28174
+ debug('prerelease compare', i, a, b);
28175
+ if (a === undefined && b === undefined) {
28176
+ return 0
28177
+ } else if (b === undefined) {
28178
+ return 1
28179
+ } else if (a === undefined) {
28180
+ return -1
28181
+ } else if (a === b) {
28182
+ continue
28183
+ } else {
28184
+ return compareIdentifiers(a, b)
27564
28185
  }
28186
+ } while (++i)
28187
+ };
27565
28188
 
27566
- return this.compareMain(other) || this.comparePre(other);
27567
- };
27568
-
27569
- SemVer.prototype.compareMain = function (other) {
27570
- if (!(other instanceof SemVer)) {
27571
- other = new SemVer(other, this.options);
28189
+ SemVer.prototype.compareBuild = function (other) {
28190
+ if (!(other instanceof SemVer)) {
28191
+ other = new SemVer(other, this.options);
28192
+ }
28193
+
28194
+ var i = 0;
28195
+ do {
28196
+ var a = this.build[i];
28197
+ var b = other.build[i];
28198
+ debug('prerelease compare', i, a, b);
28199
+ if (a === undefined && b === undefined) {
28200
+ return 0
28201
+ } else if (b === undefined) {
28202
+ return 1
28203
+ } else if (a === undefined) {
28204
+ return -1
28205
+ } else if (a === b) {
28206
+ continue
28207
+ } else {
28208
+ return compareIdentifiers(a, b)
27572
28209
  }
28210
+ } while (++i)
28211
+ };
27573
28212
 
27574
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
27575
- };
27576
-
27577
- SemVer.prototype.comparePre = function (other) {
27578
- if (!(other instanceof SemVer)) {
27579
- other = new SemVer(other, this.options);
27580
- } // NOT having a prerelease is > having one
27581
-
28213
+ // preminor will bump the version up to the next minor release, and immediately
28214
+ // down to pre-release. premajor and prepatch work the same way.
28215
+ SemVer.prototype.inc = function (release, identifier) {
28216
+ switch (release) {
28217
+ case 'premajor':
28218
+ this.prerelease.length = 0;
28219
+ this.patch = 0;
28220
+ this.minor = 0;
28221
+ this.major++;
28222
+ this.inc('pre', identifier);
28223
+ break
28224
+ case 'preminor':
28225
+ this.prerelease.length = 0;
28226
+ this.patch = 0;
28227
+ this.minor++;
28228
+ this.inc('pre', identifier);
28229
+ break
28230
+ case 'prepatch':
28231
+ // If this is already a prerelease, it will bump to the next version
28232
+ // drop any prereleases that might already exist, since they are not
28233
+ // relevant at this point.
28234
+ this.prerelease.length = 0;
28235
+ this.inc('patch', identifier);
28236
+ this.inc('pre', identifier);
28237
+ break
28238
+ // If the input is a non-prerelease version, this acts the same as
28239
+ // prepatch.
28240
+ case 'prerelease':
28241
+ if (this.prerelease.length === 0) {
28242
+ this.inc('patch', identifier);
28243
+ }
28244
+ this.inc('pre', identifier);
28245
+ break
28246
+
28247
+ case 'major':
28248
+ // If this is a pre-major version, bump up to the same major version.
28249
+ // Otherwise increment major.
28250
+ // 1.0.0-5 bumps to 1.0.0
28251
+ // 1.1.0 bumps to 2.0.0
28252
+ if (this.minor !== 0 ||
28253
+ this.patch !== 0 ||
28254
+ this.prerelease.length === 0) {
28255
+ this.major++;
28256
+ }
28257
+ this.minor = 0;
28258
+ this.patch = 0;
28259
+ this.prerelease = [];
28260
+ break
28261
+ case 'minor':
28262
+ // If this is a pre-minor version, bump up to the same minor version.
28263
+ // Otherwise increment minor.
28264
+ // 1.2.0-5 bumps to 1.2.0
28265
+ // 1.2.1 bumps to 1.3.0
28266
+ if (this.patch !== 0 || this.prerelease.length === 0) {
28267
+ this.minor++;
28268
+ }
28269
+ this.patch = 0;
28270
+ this.prerelease = [];
28271
+ break
28272
+ case 'patch':
28273
+ // If this is not a pre-release version, it will increment the patch.
28274
+ // If it is a pre-release it will bump up to the same patch version.
28275
+ // 1.2.0-5 patches to 1.2.0
28276
+ // 1.2.0 patches to 1.2.1
28277
+ if (this.prerelease.length === 0) {
28278
+ this.patch++;
28279
+ }
28280
+ this.prerelease = [];
28281
+ break
28282
+ // This probably shouldn't be used publicly.
28283
+ // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
28284
+ case 'pre':
28285
+ if (this.prerelease.length === 0) {
28286
+ this.prerelease = [0];
28287
+ } else {
28288
+ var i = this.prerelease.length;
28289
+ while (--i >= 0) {
28290
+ if (typeof this.prerelease[i] === 'number') {
28291
+ this.prerelease[i]++;
28292
+ i = -2;
28293
+ }
28294
+ }
28295
+ if (i === -1) {
28296
+ // didn't increment anything
28297
+ this.prerelease.push(0);
28298
+ }
28299
+ }
28300
+ if (identifier) {
28301
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
28302
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
28303
+ if (this.prerelease[0] === identifier) {
28304
+ if (isNaN(this.prerelease[1])) {
28305
+ this.prerelease = [identifier, 0];
28306
+ }
28307
+ } else {
28308
+ this.prerelease = [identifier, 0];
28309
+ }
28310
+ }
28311
+ break
27582
28312
 
27583
- if (this.prerelease.length && !other.prerelease.length) {
27584
- return -1;
27585
- } else if (!this.prerelease.length && other.prerelease.length) {
27586
- return 1;
27587
- } else if (!this.prerelease.length && !other.prerelease.length) {
27588
- return 0;
27589
- }
28313
+ default:
28314
+ throw new Error('invalid increment argument: ' + release)
28315
+ }
28316
+ this.format();
28317
+ this.raw = this.version;
28318
+ return this
28319
+ };
27590
28320
 
27591
- var i = 0;
28321
+ exports.inc = inc;
28322
+ function inc (version, release, loose, identifier) {
28323
+ if (typeof (loose) === 'string') {
28324
+ identifier = loose;
28325
+ loose = undefined;
28326
+ }
27592
28327
 
27593
- do {
27594
- var a = this.prerelease[i];
27595
- var b = other.prerelease[i];
27596
- debug('prerelease compare', i, a, b);
28328
+ try {
28329
+ return new SemVer(version, loose).inc(release, identifier).version
28330
+ } catch (er) {
28331
+ return null
28332
+ }
28333
+ }
27597
28334
 
27598
- if (a === undefined && b === undefined) {
27599
- return 0;
27600
- } else if (b === undefined) {
27601
- return 1;
27602
- } else if (a === undefined) {
27603
- return -1;
27604
- } else if (a === b) {
27605
- continue;
27606
- } else {
27607
- return compareIdentifiers(a, b);
28335
+ exports.diff = diff;
28336
+ function diff (version1, version2) {
28337
+ if (eq(version1, version2)) {
28338
+ return null
28339
+ } else {
28340
+ var v1 = parse(version1);
28341
+ var v2 = parse(version2);
28342
+ var prefix = '';
28343
+ if (v1.prerelease.length || v2.prerelease.length) {
28344
+ prefix = 'pre';
28345
+ var defaultResult = 'prerelease';
28346
+ }
28347
+ for (var key in v1) {
28348
+ if (key === 'major' || key === 'minor' || key === 'patch') {
28349
+ if (v1[key] !== v2[key]) {
28350
+ return prefix + key
28351
+ }
27608
28352
  }
27609
- } while (++i);
27610
- };
27611
-
27612
- SemVer.prototype.compareBuild = function (other) {
27613
- if (!(other instanceof SemVer)) {
27614
- other = new SemVer(other, this.options);
27615
28353
  }
28354
+ return defaultResult // may be undefined
28355
+ }
28356
+ }
27616
28357
 
27617
- var i = 0;
27618
-
27619
- do {
27620
- var a = this.build[i];
27621
- var b = other.build[i];
27622
- debug('prerelease compare', i, a, b);
28358
+ exports.compareIdentifiers = compareIdentifiers;
27623
28359
 
27624
- if (a === undefined && b === undefined) {
27625
- return 0;
27626
- } else if (b === undefined) {
27627
- return 1;
27628
- } else if (a === undefined) {
27629
- return -1;
27630
- } else if (a === b) {
27631
- continue;
27632
- } else {
27633
- return compareIdentifiers(a, b);
27634
- }
27635
- } while (++i);
27636
- }; // preminor will bump the version up to the next minor release, and immediately
27637
- // down to pre-release. premajor and prepatch work the same way.
28360
+ var numeric = /^[0-9]+$/;
28361
+ function compareIdentifiers (a, b) {
28362
+ var anum = numeric.test(a);
28363
+ var bnum = numeric.test(b);
27638
28364
 
28365
+ if (anum && bnum) {
28366
+ a = +a;
28367
+ b = +b;
28368
+ }
27639
28369
 
27640
- SemVer.prototype.inc = function (release, identifier) {
27641
- switch (release) {
27642
- case 'premajor':
27643
- this.prerelease.length = 0;
27644
- this.patch = 0;
27645
- this.minor = 0;
27646
- this.major++;
27647
- this.inc('pre', identifier);
27648
- break;
28370
+ return a === b ? 0
28371
+ : (anum && !bnum) ? -1
28372
+ : (bnum && !anum) ? 1
28373
+ : a < b ? -1
28374
+ : 1
28375
+ }
27649
28376
 
27650
- case 'preminor':
27651
- this.prerelease.length = 0;
27652
- this.patch = 0;
27653
- this.minor++;
27654
- this.inc('pre', identifier);
27655
- break;
28377
+ exports.rcompareIdentifiers = rcompareIdentifiers;
28378
+ function rcompareIdentifiers (a, b) {
28379
+ return compareIdentifiers(b, a)
28380
+ }
27656
28381
 
27657
- case 'prepatch':
27658
- // If this is already a prerelease, it will bump to the next version
27659
- // drop any prereleases that might already exist, since they are not
27660
- // relevant at this point.
27661
- this.prerelease.length = 0;
27662
- this.inc('patch', identifier);
27663
- this.inc('pre', identifier);
27664
- break;
27665
- // If the input is a non-prerelease version, this acts the same as
27666
- // prepatch.
28382
+ exports.major = major;
28383
+ function major (a, loose) {
28384
+ return new SemVer(a, loose).major
28385
+ }
27667
28386
 
27668
- case 'prerelease':
27669
- if (this.prerelease.length === 0) {
27670
- this.inc('patch', identifier);
27671
- }
28387
+ exports.minor = minor;
28388
+ function minor (a, loose) {
28389
+ return new SemVer(a, loose).minor
28390
+ }
27672
28391
 
27673
- this.inc('pre', identifier);
27674
- break;
28392
+ exports.patch = patch;
28393
+ function patch (a, loose) {
28394
+ return new SemVer(a, loose).patch
28395
+ }
27675
28396
 
27676
- case 'major':
27677
- // If this is a pre-major version, bump up to the same major version.
27678
- // Otherwise increment major.
27679
- // 1.0.0-5 bumps to 1.0.0
27680
- // 1.1.0 bumps to 2.0.0
27681
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
27682
- this.major++;
27683
- }
28397
+ exports.compare = compare;
28398
+ function compare (a, b, loose) {
28399
+ return new SemVer(a, loose).compare(new SemVer(b, loose))
28400
+ }
27684
28401
 
27685
- this.minor = 0;
27686
- this.patch = 0;
27687
- this.prerelease = [];
27688
- break;
28402
+ exports.compareLoose = compareLoose;
28403
+ function compareLoose (a, b) {
28404
+ return compare(a, b, true)
28405
+ }
27689
28406
 
27690
- case 'minor':
27691
- // If this is a pre-minor version, bump up to the same minor version.
27692
- // Otherwise increment minor.
27693
- // 1.2.0-5 bumps to 1.2.0
27694
- // 1.2.1 bumps to 1.3.0
27695
- if (this.patch !== 0 || this.prerelease.length === 0) {
27696
- this.minor++;
27697
- }
28407
+ exports.compareBuild = compareBuild;
28408
+ function compareBuild (a, b, loose) {
28409
+ var versionA = new SemVer(a, loose);
28410
+ var versionB = new SemVer(b, loose);
28411
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
28412
+ }
27698
28413
 
27699
- this.patch = 0;
27700
- this.prerelease = [];
27701
- break;
28414
+ exports.rcompare = rcompare;
28415
+ function rcompare (a, b, loose) {
28416
+ return compare(b, a, loose)
28417
+ }
27702
28418
 
27703
- case 'patch':
27704
- // If this is not a pre-release version, it will increment the patch.
27705
- // If it is a pre-release it will bump up to the same patch version.
27706
- // 1.2.0-5 patches to 1.2.0
27707
- // 1.2.0 patches to 1.2.1
27708
- if (this.prerelease.length === 0) {
27709
- this.patch++;
27710
- }
28419
+ exports.sort = sort;
28420
+ function sort (list, loose) {
28421
+ return list.sort(function (a, b) {
28422
+ return exports.compareBuild(a, b, loose)
28423
+ })
28424
+ }
27711
28425
 
27712
- this.prerelease = [];
27713
- break;
27714
- // This probably shouldn't be used publicly.
27715
- // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
28426
+ exports.rsort = rsort;
28427
+ function rsort (list, loose) {
28428
+ return list.sort(function (a, b) {
28429
+ return exports.compareBuild(b, a, loose)
28430
+ })
28431
+ }
27716
28432
 
27717
- case 'pre':
27718
- if (this.prerelease.length === 0) {
27719
- this.prerelease = [0];
27720
- } else {
27721
- var i = this.prerelease.length;
28433
+ exports.gt = gt;
28434
+ function gt (a, b, loose) {
28435
+ return compare(a, b, loose) > 0
28436
+ }
27722
28437
 
27723
- while (--i >= 0) {
27724
- if (typeof this.prerelease[i] === 'number') {
27725
- this.prerelease[i]++;
27726
- i = -2;
27727
- }
27728
- }
28438
+ exports.lt = lt;
28439
+ function lt (a, b, loose) {
28440
+ return compare(a, b, loose) < 0
28441
+ }
27729
28442
 
27730
- if (i === -1) {
27731
- // didn't increment anything
27732
- this.prerelease.push(0);
27733
- }
27734
- }
28443
+ exports.eq = eq;
28444
+ function eq (a, b, loose) {
28445
+ return compare(a, b, loose) === 0
28446
+ }
27735
28447
 
27736
- if (identifier) {
27737
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
27738
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
27739
- if (this.prerelease[0] === identifier) {
27740
- if (isNaN(this.prerelease[1])) {
27741
- this.prerelease = [identifier, 0];
27742
- }
27743
- } else {
27744
- this.prerelease = [identifier, 0];
27745
- }
27746
- }
28448
+ exports.neq = neq;
28449
+ function neq (a, b, loose) {
28450
+ return compare(a, b, loose) !== 0
28451
+ }
27747
28452
 
27748
- break;
28453
+ exports.gte = gte;
28454
+ function gte (a, b, loose) {
28455
+ return compare(a, b, loose) >= 0
28456
+ }
27749
28457
 
27750
- default:
27751
- throw new Error('invalid increment argument: ' + release);
27752
- }
28458
+ exports.lte = lte;
28459
+ function lte (a, b, loose) {
28460
+ return compare(a, b, loose) <= 0
28461
+ }
27753
28462
 
27754
- this.format();
27755
- this.raw = this.version;
27756
- return this;
27757
- };
28463
+ exports.cmp = cmp;
28464
+ function cmp (a, op, b, loose) {
28465
+ switch (op) {
28466
+ case '===':
28467
+ if (typeof a === 'object')
28468
+ a = a.version;
28469
+ if (typeof b === 'object')
28470
+ b = b.version;
28471
+ return a === b
27758
28472
 
27759
- exports.inc = inc;
28473
+ case '!==':
28474
+ if (typeof a === 'object')
28475
+ a = a.version;
28476
+ if (typeof b === 'object')
28477
+ b = b.version;
28478
+ return a !== b
27760
28479
 
27761
- function inc(version, release, loose, identifier) {
27762
- if (typeof loose === 'string') {
27763
- identifier = loose;
27764
- loose = undefined;
27765
- }
28480
+ case '':
28481
+ case '=':
28482
+ case '==':
28483
+ return eq(a, b, loose)
27766
28484
 
27767
- try {
27768
- return new SemVer(version, loose).inc(release, identifier).version;
27769
- } catch (er) {
27770
- return null;
27771
- }
27772
- }
28485
+ case '!=':
28486
+ return neq(a, b, loose)
27773
28487
 
27774
- exports.diff = diff;
28488
+ case '>':
28489
+ return gt(a, b, loose)
27775
28490
 
27776
- function diff(version1, version2) {
27777
- if (eq(version1, version2)) {
27778
- return null;
27779
- } else {
27780
- var v1 = parse(version1);
27781
- var v2 = parse(version2);
27782
- var prefix = '';
28491
+ case '>=':
28492
+ return gte(a, b, loose)
27783
28493
 
27784
- if (v1.prerelease.length || v2.prerelease.length) {
27785
- prefix = 'pre';
27786
- var defaultResult = 'prerelease';
27787
- }
28494
+ case '<':
28495
+ return lt(a, b, loose)
27788
28496
 
27789
- for (var key in v1) {
27790
- if (key === 'major' || key === 'minor' || key === 'patch') {
27791
- if (v1[key] !== v2[key]) {
27792
- return prefix + key;
27793
- }
27794
- }
27795
- }
28497
+ case '<=':
28498
+ return lte(a, b, loose)
27796
28499
 
27797
- return defaultResult; // may be undefined
27798
- }
28500
+ default:
28501
+ throw new TypeError('Invalid operator: ' + op)
27799
28502
  }
28503
+ }
27800
28504
 
27801
- exports.compareIdentifiers = compareIdentifiers;
27802
- var numeric = /^[0-9]+$/;
27803
-
27804
- function compareIdentifiers(a, b) {
27805
- var anum = numeric.test(a);
27806
- var bnum = numeric.test(b);
28505
+ exports.Comparator = Comparator;
28506
+ function Comparator (comp, options) {
28507
+ if (!options || typeof options !== 'object') {
28508
+ options = {
28509
+ loose: !!options,
28510
+ includePrerelease: false
28511
+ };
28512
+ }
27807
28513
 
27808
- if (anum && bnum) {
27809
- a = +a;
27810
- b = +b;
28514
+ if (comp instanceof Comparator) {
28515
+ if (comp.loose === !!options.loose) {
28516
+ return comp
28517
+ } else {
28518
+ comp = comp.value;
27811
28519
  }
28520
+ }
27812
28521
 
27813
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
28522
+ if (!(this instanceof Comparator)) {
28523
+ return new Comparator(comp, options)
27814
28524
  }
27815
28525
 
27816
- exports.rcompareIdentifiers = rcompareIdentifiers;
28526
+ debug('comparator', comp, options);
28527
+ this.options = options;
28528
+ this.loose = !!options.loose;
28529
+ this.parse(comp);
27817
28530
 
27818
- function rcompareIdentifiers(a, b) {
27819
- return compareIdentifiers(b, a);
28531
+ if (this.semver === ANY) {
28532
+ this.value = '';
28533
+ } else {
28534
+ this.value = this.operator + this.semver.version;
27820
28535
  }
27821
28536
 
27822
- exports.major = major;
28537
+ debug('comp', this);
28538
+ }
28539
+
28540
+ var ANY = {};
28541
+ Comparator.prototype.parse = function (comp) {
28542
+ var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
28543
+ var m = comp.match(r);
27823
28544
 
27824
- function major(a, loose) {
27825
- return new SemVer(a, loose).major;
28545
+ if (!m) {
28546
+ throw new TypeError('Invalid comparator: ' + comp)
27826
28547
  }
27827
28548
 
27828
- exports.minor = minor;
27829
-
27830
- function minor(a, loose) {
27831
- return new SemVer(a, loose).minor;
28549
+ this.operator = m[1] !== undefined ? m[1] : '';
28550
+ if (this.operator === '=') {
28551
+ this.operator = '';
27832
28552
  }
27833
28553
 
27834
- exports.patch = patch;
27835
-
27836
- function patch(a, loose) {
27837
- return new SemVer(a, loose).patch;
27838
- }
27839
-
27840
- exports.compare = compare;
27841
-
27842
- function compare(a, b, loose) {
27843
- return new SemVer(a, loose).compare(new SemVer(b, loose));
27844
- }
27845
-
27846
- exports.compareLoose = compareLoose;
27847
-
27848
- function compareLoose(a, b) {
27849
- return compare(a, b, true);
27850
- }
27851
-
27852
- exports.compareBuild = compareBuild;
27853
-
27854
- function compareBuild(a, b, loose) {
27855
- var versionA = new SemVer(a, loose);
27856
- var versionB = new SemVer(b, loose);
27857
- return versionA.compare(versionB) || versionA.compareBuild(versionB);
27858
- }
27859
-
27860
- exports.rcompare = rcompare;
27861
-
27862
- function rcompare(a, b, loose) {
27863
- return compare(b, a, loose);
28554
+ // if it literally is just '>' or '' then allow anything.
28555
+ if (!m[2]) {
28556
+ this.semver = ANY;
28557
+ } else {
28558
+ this.semver = new SemVer(m[2], this.options.loose);
27864
28559
  }
28560
+ };
27865
28561
 
27866
- exports.sort = sort;
27867
-
27868
- function sort(list, loose) {
27869
- return list.sort(function (a, b) {
27870
- return exports.compareBuild(a, b, loose);
27871
- });
27872
- }
28562
+ Comparator.prototype.toString = function () {
28563
+ return this.value
28564
+ };
27873
28565
 
27874
- exports.rsort = rsort;
28566
+ Comparator.prototype.test = function (version) {
28567
+ debug('Comparator.test', version, this.options.loose);
27875
28568
 
27876
- function rsort(list, loose) {
27877
- return list.sort(function (a, b) {
27878
- return exports.compareBuild(b, a, loose);
27879
- });
28569
+ if (this.semver === ANY || version === ANY) {
28570
+ return true
27880
28571
  }
27881
28572
 
27882
- exports.gt = gt;
27883
-
27884
- function gt(a, b, loose) {
27885
- return compare(a, b, loose) > 0;
28573
+ if (typeof version === 'string') {
28574
+ try {
28575
+ version = new SemVer(version, this.options);
28576
+ } catch (er) {
28577
+ return false
28578
+ }
27886
28579
  }
27887
28580
 
27888
- exports.lt = lt;
28581
+ return cmp(version, this.operator, this.semver, this.options)
28582
+ };
27889
28583
 
27890
- function lt(a, b, loose) {
27891
- return compare(a, b, loose) < 0;
28584
+ Comparator.prototype.intersects = function (comp, options) {
28585
+ if (!(comp instanceof Comparator)) {
28586
+ throw new TypeError('a Comparator is required')
27892
28587
  }
27893
28588
 
27894
- exports.eq = eq;
27895
-
27896
- function eq(a, b, loose) {
27897
- return compare(a, b, loose) === 0;
28589
+ if (!options || typeof options !== 'object') {
28590
+ options = {
28591
+ loose: !!options,
28592
+ includePrerelease: false
28593
+ };
27898
28594
  }
27899
28595
 
27900
- exports.neq = neq;
28596
+ var rangeTmp;
28597
+
28598
+ if (this.operator === '') {
28599
+ if (this.value === '') {
28600
+ return true
28601
+ }
28602
+ rangeTmp = new Range(comp.value, options);
28603
+ return satisfies(this.value, rangeTmp, options)
28604
+ } else if (comp.operator === '') {
28605
+ if (comp.value === '') {
28606
+ return true
28607
+ }
28608
+ rangeTmp = new Range(this.value, options);
28609
+ return satisfies(comp.semver, rangeTmp, options)
28610
+ }
28611
+
28612
+ var sameDirectionIncreasing =
28613
+ (this.operator === '>=' || this.operator === '>') &&
28614
+ (comp.operator === '>=' || comp.operator === '>');
28615
+ var sameDirectionDecreasing =
28616
+ (this.operator === '<=' || this.operator === '<') &&
28617
+ (comp.operator === '<=' || comp.operator === '<');
28618
+ var sameSemVer = this.semver.version === comp.semver.version;
28619
+ var differentDirectionsInclusive =
28620
+ (this.operator === '>=' || this.operator === '<=') &&
28621
+ (comp.operator === '>=' || comp.operator === '<=');
28622
+ var oppositeDirectionsLessThan =
28623
+ cmp(this.semver, '<', comp.semver, options) &&
28624
+ ((this.operator === '>=' || this.operator === '>') &&
28625
+ (comp.operator === '<=' || comp.operator === '<'));
28626
+ var oppositeDirectionsGreaterThan =
28627
+ cmp(this.semver, '>', comp.semver, options) &&
28628
+ ((this.operator === '<=' || this.operator === '<') &&
28629
+ (comp.operator === '>=' || comp.operator === '>'));
28630
+
28631
+ return sameDirectionIncreasing || sameDirectionDecreasing ||
28632
+ (sameSemVer && differentDirectionsInclusive) ||
28633
+ oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
28634
+ };
27901
28635
 
27902
- function neq(a, b, loose) {
27903
- return compare(a, b, loose) !== 0;
28636
+ exports.Range = Range;
28637
+ function Range (range, options) {
28638
+ if (!options || typeof options !== 'object') {
28639
+ options = {
28640
+ loose: !!options,
28641
+ includePrerelease: false
28642
+ };
27904
28643
  }
27905
28644
 
27906
- exports.gte = gte;
27907
-
27908
- function gte(a, b, loose) {
27909
- return compare(a, b, loose) >= 0;
28645
+ if (range instanceof Range) {
28646
+ if (range.loose === !!options.loose &&
28647
+ range.includePrerelease === !!options.includePrerelease) {
28648
+ return range
28649
+ } else {
28650
+ return new Range(range.raw, options)
28651
+ }
27910
28652
  }
27911
28653
 
27912
- exports.lte = lte;
27913
-
27914
- function lte(a, b, loose) {
27915
- return compare(a, b, loose) <= 0;
28654
+ if (range instanceof Comparator) {
28655
+ return new Range(range.value, options)
27916
28656
  }
27917
28657
 
27918
- exports.cmp = cmp;
27919
-
27920
- function cmp(a, op, b, loose) {
27921
- switch (op) {
27922
- case '===':
27923
- if (typeof a === 'object') a = a.version;
27924
- if (typeof b === 'object') b = b.version;
27925
- return a === b;
27926
-
27927
- case '!==':
27928
- if (typeof a === 'object') a = a.version;
27929
- if (typeof b === 'object') b = b.version;
27930
- return a !== b;
27931
-
27932
- case '':
27933
- case '=':
27934
- case '==':
27935
- return eq(a, b, loose);
27936
-
27937
- case '!=':
27938
- return neq(a, b, loose);
27939
-
27940
- case '>':
27941
- return gt(a, b, loose);
27942
-
27943
- case '>=':
27944
- return gte(a, b, loose);
27945
-
27946
- case '<':
27947
- return lt(a, b, loose);
27948
-
27949
- case '<=':
27950
- return lte(a, b, loose);
27951
-
27952
- default:
27953
- throw new TypeError('Invalid operator: ' + op);
27954
- }
28658
+ if (!(this instanceof Range)) {
28659
+ return new Range(range, options)
27955
28660
  }
27956
28661
 
27957
- exports.Comparator = Comparator;
27958
-
27959
- function Comparator(comp, options) {
27960
- if (!options || typeof options !== 'object') {
27961
- options = {
27962
- loose: !!options,
27963
- includePrerelease: false
27964
- };
27965
- }
28662
+ this.options = options;
28663
+ this.loose = !!options.loose;
28664
+ this.includePrerelease = !!options.includePrerelease;
27966
28665
 
27967
- if (comp instanceof Comparator) {
27968
- if (comp.loose === !!options.loose) {
27969
- return comp;
27970
- } else {
27971
- comp = comp.value;
27972
- }
27973
- }
27974
-
27975
- if (!(this instanceof Comparator)) {
27976
- return new Comparator(comp, options);
27977
- }
27978
-
27979
- debug('comparator', comp, options);
27980
- this.options = options;
27981
- this.loose = !!options.loose;
27982
- this.parse(comp);
27983
-
27984
- if (this.semver === ANY) {
27985
- this.value = '';
27986
- } else {
27987
- this.value = this.operator + this.semver.version;
27988
- }
28666
+ // First, split based on boolean or ||
28667
+ this.raw = range;
28668
+ this.set = range.split(/\s*\|\|\s*/).map(function (range) {
28669
+ return this.parseRange(range.trim())
28670
+ }, this).filter(function (c) {
28671
+ // throw out any that are not relevant for whatever reason
28672
+ return c.length
28673
+ });
27989
28674
 
27990
- debug('comp', this);
28675
+ if (!this.set.length) {
28676
+ throw new TypeError('Invalid SemVer Range: ' + range)
27991
28677
  }
27992
28678
 
27993
- var ANY = {};
27994
-
27995
- Comparator.prototype.parse = function (comp) {
27996
- var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
27997
- var m = comp.match(r);
27998
-
27999
- if (!m) {
28000
- throw new TypeError('Invalid comparator: ' + comp);
28001
- }
28002
-
28003
- this.operator = m[1] !== undefined ? m[1] : '';
28004
-
28005
- if (this.operator === '=') {
28006
- this.operator = '';
28007
- } // if it literally is just '>' or '' then allow anything.
28008
-
28009
-
28010
- if (!m[2]) {
28011
- this.semver = ANY;
28012
- } else {
28013
- this.semver = new SemVer(m[2], this.options.loose);
28014
- }
28015
- };
28016
-
28017
- Comparator.prototype.toString = function () {
28018
- return this.value;
28019
- };
28020
-
28021
- Comparator.prototype.test = function (version) {
28022
- debug('Comparator.test', version, this.options.loose);
28023
-
28024
- if (this.semver === ANY || version === ANY) {
28025
- return true;
28026
- }
28027
-
28028
- if (typeof version === 'string') {
28029
- try {
28030
- version = new SemVer(version, this.options);
28031
- } catch (er) {
28032
- return false;
28033
- }
28034
- }
28035
-
28036
- return cmp(version, this.operator, this.semver, this.options);
28037
- };
28038
-
28039
- Comparator.prototype.intersects = function (comp, options) {
28040
- if (!(comp instanceof Comparator)) {
28041
- throw new TypeError('a Comparator is required');
28042
- }
28043
-
28044
- if (!options || typeof options !== 'object') {
28045
- options = {
28046
- loose: !!options,
28047
- includePrerelease: false
28048
- };
28049
- }
28050
-
28051
- var rangeTmp;
28052
-
28053
- if (this.operator === '') {
28054
- if (this.value === '') {
28055
- return true;
28056
- }
28057
-
28058
- rangeTmp = new Range(comp.value, options);
28059
- return satisfies(this.value, rangeTmp, options);
28060
- } else if (comp.operator === '') {
28061
- if (comp.value === '') {
28062
- return true;
28063
- }
28064
-
28065
- rangeTmp = new Range(this.value, options);
28066
- return satisfies(comp.semver, rangeTmp, options);
28067
- }
28068
-
28069
- var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
28070
- var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
28071
- var sameSemVer = this.semver.version === comp.semver.version;
28072
- var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
28073
- var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
28074
- var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
28075
- return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
28076
- };
28077
-
28078
- exports.Range = Range;
28079
-
28080
- function Range(range, options) {
28081
- if (!options || typeof options !== 'object') {
28082
- options = {
28083
- loose: !!options,
28084
- includePrerelease: false
28085
- };
28086
- }
28087
-
28088
- if (range instanceof Range) {
28089
- if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
28090
- return range;
28091
- } else {
28092
- return new Range(range.raw, options);
28093
- }
28094
- }
28679
+ this.format();
28680
+ }
28095
28681
 
28096
- if (range instanceof Comparator) {
28097
- return new Range(range.value, options);
28098
- }
28682
+ Range.prototype.format = function () {
28683
+ this.range = this.set.map(function (comps) {
28684
+ return comps.join(' ').trim()
28685
+ }).join('||').trim();
28686
+ return this.range
28687
+ };
28099
28688
 
28100
- if (!(this instanceof Range)) {
28101
- return new Range(range, options);
28102
- }
28689
+ Range.prototype.toString = function () {
28690
+ return this.range
28691
+ };
28103
28692
 
28104
- this.options = options;
28105
- this.loose = !!options.loose;
28106
- this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
28107
-
28108
- this.raw = range;
28109
- this.set = range.split(/\s*\|\|\s*/).map(function (range) {
28110
- return this.parseRange(range.trim());
28111
- }, this).filter(function (c) {
28112
- // throw out any that are not relevant for whatever reason
28113
- return c.length;
28693
+ Range.prototype.parseRange = function (range) {
28694
+ var loose = this.options.loose;
28695
+ range = range.trim();
28696
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
28697
+ var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
28698
+ range = range.replace(hr, hyphenReplace);
28699
+ debug('hyphen replace', range);
28700
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
28701
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
28702
+ debug('comparator trim', range, re[t.COMPARATORTRIM]);
28703
+
28704
+ // `~ 1.2.3` => `~1.2.3`
28705
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
28706
+
28707
+ // `^ 1.2.3` => `^1.2.3`
28708
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
28709
+
28710
+ // normalize spaces
28711
+ range = range.split(/\s+/).join(' ');
28712
+
28713
+ // At this point, the range is completely trimmed and
28714
+ // ready to be split into comparators.
28715
+
28716
+ var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
28717
+ var set = range.split(' ').map(function (comp) {
28718
+ return parseComparator(comp, this.options)
28719
+ }, this).join(' ').split(/\s+/);
28720
+ if (this.options.loose) {
28721
+ // in loose mode, throw out any that are not valid comparators
28722
+ set = set.filter(function (comp) {
28723
+ return !!comp.match(compRe)
28114
28724
  });
28115
-
28116
- if (!this.set.length) {
28117
- throw new TypeError('Invalid SemVer Range: ' + range);
28118
- }
28119
-
28120
- this.format();
28121
28725
  }
28726
+ set = set.map(function (comp) {
28727
+ return new Comparator(comp, this.options)
28728
+ }, this);
28122
28729
 
28123
- Range.prototype.format = function () {
28124
- this.range = this.set.map(function (comps) {
28125
- return comps.join(' ').trim();
28126
- }).join('||').trim();
28127
- return this.range;
28128
- };
28129
-
28130
- Range.prototype.toString = function () {
28131
- return this.range;
28132
- };
28133
-
28134
- Range.prototype.parseRange = function (range) {
28135
- var loose = this.options.loose;
28136
- range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
28137
-
28138
- var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
28139
- range = range.replace(hr, hyphenReplace);
28140
- debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
28141
-
28142
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
28143
- debug('comparator trim', range, re[t.COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
28144
-
28145
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
28146
-
28147
- range = range.replace(re[t.CARETTRIM], caretTrimReplace); // normalize spaces
28148
-
28149
- range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
28150
- // ready to be split into comparators.
28151
-
28152
- var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
28153
- var set = range.split(' ').map(function (comp) {
28154
- return parseComparator(comp, this.options);
28155
- }, this).join(' ').split(/\s+/);
28156
-
28157
- if (this.options.loose) {
28158
- // in loose mode, throw out any that are not valid comparators
28159
- set = set.filter(function (comp) {
28160
- return !!comp.match(compRe);
28161
- });
28162
- }
28163
-
28164
- set = set.map(function (comp) {
28165
- return new Comparator(comp, this.options);
28166
- }, this);
28167
- return set;
28168
- };
28169
-
28170
- Range.prototype.intersects = function (range, options) {
28171
- if (!(range instanceof Range)) {
28172
- throw new TypeError('a Range is required');
28173
- }
28174
-
28175
- return this.set.some(function (thisComparators) {
28176
- return isSatisfiable(thisComparators, options) && range.set.some(function (rangeComparators) {
28177
- return isSatisfiable(rangeComparators, options) && thisComparators.every(function (thisComparator) {
28178
- return rangeComparators.every(function (rangeComparator) {
28179
- return thisComparator.intersects(rangeComparator, options);
28180
- });
28181
- });
28182
- });
28183
- });
28184
- }; // take a set of comparators and determine whether there
28185
- // exists a version which can satisfy it
28186
-
28187
-
28188
- function isSatisfiable(comparators, options) {
28189
- var result = true;
28190
- var remainingComparators = comparators.slice();
28191
- var testComparator = remainingComparators.pop();
28192
-
28193
- while (result && remainingComparators.length) {
28194
- result = remainingComparators.every(function (otherComparator) {
28195
- return testComparator.intersects(otherComparator, options);
28196
- });
28197
- testComparator = remainingComparators.pop();
28198
- }
28730
+ return set
28731
+ };
28199
28732
 
28200
- return result;
28201
- } // Mostly just for testing and legacy API reasons
28733
+ Range.prototype.intersects = function (range, options) {
28734
+ if (!(range instanceof Range)) {
28735
+ throw new TypeError('a Range is required')
28736
+ }
28202
28737
 
28738
+ return this.set.some(function (thisComparators) {
28739
+ return (
28740
+ isSatisfiable(thisComparators, options) &&
28741
+ range.set.some(function (rangeComparators) {
28742
+ return (
28743
+ isSatisfiable(rangeComparators, options) &&
28744
+ thisComparators.every(function (thisComparator) {
28745
+ return rangeComparators.every(function (rangeComparator) {
28746
+ return thisComparator.intersects(rangeComparator, options)
28747
+ })
28748
+ })
28749
+ )
28750
+ })
28751
+ )
28752
+ })
28753
+ };
28203
28754
 
28204
- exports.toComparators = toComparators;
28755
+ // take a set of comparators and determine whether there
28756
+ // exists a version which can satisfy it
28757
+ function isSatisfiable (comparators, options) {
28758
+ var result = true;
28759
+ var remainingComparators = comparators.slice();
28760
+ var testComparator = remainingComparators.pop();
28205
28761
 
28206
- function toComparators(range, options) {
28207
- return new Range(range, options).set.map(function (comp) {
28208
- return comp.map(function (c) {
28209
- return c.value;
28210
- }).join(' ').trim().split(' ');
28762
+ while (result && remainingComparators.length) {
28763
+ result = remainingComparators.every(function (otherComparator) {
28764
+ return testComparator.intersects(otherComparator, options)
28211
28765
  });
28212
- } // comprised of xranges, tildes, stars, and gtlt's at this point.
28213
- // already replaced the hyphen ranges
28214
- // turn into a set of JUST comparators.
28215
-
28216
-
28217
- function parseComparator(comp, options) {
28218
- debug('comp', comp, options);
28219
- comp = replaceCarets(comp, options);
28220
- debug('caret', comp);
28221
- comp = replaceTildes(comp, options);
28222
- debug('tildes', comp);
28223
- comp = replaceXRanges(comp, options);
28224
- debug('xrange', comp);
28225
- comp = replaceStars(comp, options);
28226
- debug('stars', comp);
28227
- return comp;
28228
- }
28229
-
28230
- function isX(id) {
28231
- return !id || id.toLowerCase() === 'x' || id === '*';
28232
- } // ~, ~> --> * (any, kinda silly)
28233
- // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
28234
- // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
28235
- // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
28236
- // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
28237
- // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
28238
-
28239
-
28240
- function replaceTildes(comp, options) {
28241
- return comp.trim().split(/\s+/).map(function (comp) {
28242
- return replaceTilde(comp, options);
28243
- }).join(' ');
28244
- }
28245
28766
 
28246
- function replaceTilde(comp, options) {
28247
- var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
28248
- return comp.replace(r, function (_, M, m, p, pr) {
28249
- debug('tilde', comp, _, M, m, p, pr);
28250
- var ret;
28251
-
28252
- if (isX(M)) {
28253
- ret = '';
28254
- } else if (isX(m)) {
28255
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
28256
- } else if (isX(p)) {
28257
- // ~1.2 == >=1.2.0 <1.3.0
28767
+ testComparator = remainingComparators.pop();
28768
+ }
28769
+
28770
+ return result
28771
+ }
28772
+
28773
+ // Mostly just for testing and legacy API reasons
28774
+ exports.toComparators = toComparators;
28775
+ function toComparators (range, options) {
28776
+ return new Range(range, options).set.map(function (comp) {
28777
+ return comp.map(function (c) {
28778
+ return c.value
28779
+ }).join(' ').trim().split(' ')
28780
+ })
28781
+ }
28782
+
28783
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
28784
+ // already replaced the hyphen ranges
28785
+ // turn into a set of JUST comparators.
28786
+ function parseComparator (comp, options) {
28787
+ debug('comp', comp, options);
28788
+ comp = replaceCarets(comp, options);
28789
+ debug('caret', comp);
28790
+ comp = replaceTildes(comp, options);
28791
+ debug('tildes', comp);
28792
+ comp = replaceXRanges(comp, options);
28793
+ debug('xrange', comp);
28794
+ comp = replaceStars(comp, options);
28795
+ debug('stars', comp);
28796
+ return comp
28797
+ }
28798
+
28799
+ function isX (id) {
28800
+ return !id || id.toLowerCase() === 'x' || id === '*'
28801
+ }
28802
+
28803
+ // ~, ~> --> * (any, kinda silly)
28804
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
28805
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
28806
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
28807
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
28808
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
28809
+ function replaceTildes (comp, options) {
28810
+ return comp.trim().split(/\s+/).map(function (comp) {
28811
+ return replaceTilde(comp, options)
28812
+ }).join(' ')
28813
+ }
28814
+
28815
+ function replaceTilde (comp, options) {
28816
+ var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
28817
+ return comp.replace(r, function (_, M, m, p, pr) {
28818
+ debug('tilde', comp, _, M, m, p, pr);
28819
+ var ret;
28820
+
28821
+ if (isX(M)) {
28822
+ ret = '';
28823
+ } else if (isX(m)) {
28824
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
28825
+ } else if (isX(p)) {
28826
+ // ~1.2 == >=1.2.0 <1.3.0
28827
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
28828
+ } else if (pr) {
28829
+ debug('replaceTilde pr', pr);
28830
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
28831
+ ' <' + M + '.' + (+m + 1) + '.0';
28832
+ } else {
28833
+ // ~1.2.3 == >=1.2.3 <1.3.0
28834
+ ret = '>=' + M + '.' + m + '.' + p +
28835
+ ' <' + M + '.' + (+m + 1) + '.0';
28836
+ }
28837
+
28838
+ debug('tilde return', ret);
28839
+ return ret
28840
+ })
28841
+ }
28842
+
28843
+ // ^ --> * (any, kinda silly)
28844
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
28845
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
28846
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
28847
+ // ^1.2.3 --> >=1.2.3 <2.0.0
28848
+ // ^1.2.0 --> >=1.2.0 <2.0.0
28849
+ function replaceCarets (comp, options) {
28850
+ return comp.trim().split(/\s+/).map(function (comp) {
28851
+ return replaceCaret(comp, options)
28852
+ }).join(' ')
28853
+ }
28854
+
28855
+ function replaceCaret (comp, options) {
28856
+ debug('caret', comp, options);
28857
+ var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
28858
+ return comp.replace(r, function (_, M, m, p, pr) {
28859
+ debug('caret', comp, _, M, m, p, pr);
28860
+ var ret;
28861
+
28862
+ if (isX(M)) {
28863
+ ret = '';
28864
+ } else if (isX(m)) {
28865
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
28866
+ } else if (isX(p)) {
28867
+ if (M === '0') {
28258
28868
  ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
28259
- } else if (pr) {
28260
- debug('replaceTilde pr', pr);
28261
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
28262
28869
  } else {
28263
- // ~1.2.3 == >=1.2.3 <1.3.0
28264
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
28265
- }
28266
-
28267
- debug('tilde return', ret);
28268
- return ret;
28269
- });
28270
- } // ^ --> * (any, kinda silly)
28271
- // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
28272
- // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
28273
- // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
28274
- // ^1.2.3 --> >=1.2.3 <2.0.0
28275
- // ^1.2.0 --> >=1.2.0 <2.0.0
28276
-
28277
-
28278
- function replaceCarets(comp, options) {
28279
- return comp.trim().split(/\s+/).map(function (comp) {
28280
- return replaceCaret(comp, options);
28281
- }).join(' ');
28282
- }
28283
-
28284
- function replaceCaret(comp, options) {
28285
- debug('caret', comp, options);
28286
- var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
28287
- return comp.replace(r, function (_, M, m, p, pr) {
28288
- debug('caret', comp, _, M, m, p, pr);
28289
- var ret;
28290
-
28291
- if (isX(M)) {
28292
- ret = '';
28293
- } else if (isX(m)) {
28294
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
28295
- } else if (isX(p)) {
28296
- if (M === '0') {
28297
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
28298
- } else {
28299
- ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
28300
- }
28301
- } else if (pr) {
28302
- debug('replaceCaret pr', pr);
28303
-
28304
- if (M === '0') {
28305
- if (m === '0') {
28306
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
28307
- } else {
28308
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
28309
- }
28870
+ ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
28871
+ }
28872
+ } else if (pr) {
28873
+ debug('replaceCaret pr', pr);
28874
+ if (M === '0') {
28875
+ if (m === '0') {
28876
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
28877
+ ' <' + M + '.' + m + '.' + (+p + 1);
28310
28878
  } else {
28311
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
28879
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
28880
+ ' <' + M + '.' + (+m + 1) + '.0';
28312
28881
  }
28313
28882
  } else {
28314
- debug('no pr');
28315
-
28316
- if (M === '0') {
28317
- if (m === '0') {
28318
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
28319
- } else {
28320
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
28321
- }
28883
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
28884
+ ' <' + (+M + 1) + '.0.0';
28885
+ }
28886
+ } else {
28887
+ debug('no pr');
28888
+ if (M === '0') {
28889
+ if (m === '0') {
28890
+ ret = '>=' + M + '.' + m + '.' + p +
28891
+ ' <' + M + '.' + m + '.' + (+p + 1);
28322
28892
  } else {
28323
- ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
28893
+ ret = '>=' + M + '.' + m + '.' + p +
28894
+ ' <' + M + '.' + (+m + 1) + '.0';
28324
28895
  }
28896
+ } else {
28897
+ ret = '>=' + M + '.' + m + '.' + p +
28898
+ ' <' + (+M + 1) + '.0.0';
28325
28899
  }
28900
+ }
28326
28901
 
28327
- debug('caret return', ret);
28328
- return ret;
28329
- });
28330
- }
28331
-
28332
- function replaceXRanges(comp, options) {
28333
- debug('replaceXRanges', comp, options);
28334
- return comp.split(/\s+/).map(function (comp) {
28335
- return replaceXRange(comp, options);
28336
- }).join(' ');
28337
- }
28902
+ debug('caret return', ret);
28903
+ return ret
28904
+ })
28905
+ }
28338
28906
 
28339
- function replaceXRange(comp, options) {
28340
- comp = comp.trim();
28341
- var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
28342
- return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
28343
- debug('xRange', comp, ret, gtlt, M, m, p, pr);
28344
- var xM = isX(M);
28345
- var xm = xM || isX(m);
28346
- var xp = xm || isX(p);
28347
- var anyX = xp;
28907
+ function replaceXRanges (comp, options) {
28908
+ debug('replaceXRanges', comp, options);
28909
+ return comp.split(/\s+/).map(function (comp) {
28910
+ return replaceXRange(comp, options)
28911
+ }).join(' ')
28912
+ }
28348
28913
 
28349
- if (gtlt === '=' && anyX) {
28350
- gtlt = '';
28351
- } // if we're including prereleases in the match, then we need
28352
- // to fix this to -0, the lowest possible prerelease value
28914
+ function replaceXRange (comp, options) {
28915
+ comp = comp.trim();
28916
+ var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
28917
+ return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
28918
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
28919
+ var xM = isX(M);
28920
+ var xm = xM || isX(m);
28921
+ var xp = xm || isX(p);
28922
+ var anyX = xp;
28353
28923
 
28924
+ if (gtlt === '=' && anyX) {
28925
+ gtlt = '';
28926
+ }
28354
28927
 
28355
- pr = options.includePrerelease ? '-0' : '';
28928
+ // if we're including prereleases in the match, then we need
28929
+ // to fix this to -0, the lowest possible prerelease value
28930
+ pr = options.includePrerelease ? '-0' : '';
28356
28931
 
28357
- if (xM) {
28358
- if (gtlt === '>' || gtlt === '<') {
28359
- // nothing is allowed
28360
- ret = '<0.0.0-0';
28361
- } else {
28362
- // nothing is forbidden
28363
- ret = '*';
28364
- }
28365
- } else if (gtlt && anyX) {
28366
- // we know patch is an x, because we have any x at all.
28367
- // replace X with 0
28932
+ if (xM) {
28933
+ if (gtlt === '>' || gtlt === '<') {
28934
+ // nothing is allowed
28935
+ ret = '<0.0.0-0';
28936
+ } else {
28937
+ // nothing is forbidden
28938
+ ret = '*';
28939
+ }
28940
+ } else if (gtlt && anyX) {
28941
+ // we know patch is an x, because we have any x at all.
28942
+ // replace X with 0
28943
+ if (xm) {
28944
+ m = 0;
28945
+ }
28946
+ p = 0;
28947
+
28948
+ if (gtlt === '>') {
28949
+ // >1 => >=2.0.0
28950
+ // >1.2 => >=1.3.0
28951
+ // >1.2.3 => >= 1.2.4
28952
+ gtlt = '>=';
28368
28953
  if (xm) {
28954
+ M = +M + 1;
28369
28955
  m = 0;
28956
+ p = 0;
28957
+ } else {
28958
+ m = +m + 1;
28959
+ p = 0;
28370
28960
  }
28371
-
28372
- p = 0;
28373
-
28374
- if (gtlt === '>') {
28375
- // >1 => >=2.0.0
28376
- // >1.2 => >=1.3.0
28377
- // >1.2.3 => >= 1.2.4
28378
- gtlt = '>=';
28379
-
28380
- if (xm) {
28381
- M = +M + 1;
28382
- m = 0;
28383
- p = 0;
28384
- } else {
28385
- m = +m + 1;
28386
- p = 0;
28387
- }
28388
- } else if (gtlt === '<=') {
28389
- // <=0.7.x is actually <0.8.0, since any 0.7.x should
28390
- // pass. Similarly, <=7.x is actually <8.0.0, etc.
28391
- gtlt = '<';
28392
-
28393
- if (xm) {
28394
- M = +M + 1;
28395
- } else {
28396
- m = +m + 1;
28397
- }
28961
+ } else if (gtlt === '<=') {
28962
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
28963
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
28964
+ gtlt = '<';
28965
+ if (xm) {
28966
+ M = +M + 1;
28967
+ } else {
28968
+ m = +m + 1;
28398
28969
  }
28399
-
28400
- ret = gtlt + M + '.' + m + '.' + p + pr;
28401
- } else if (xm) {
28402
- ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
28403
- } else if (xp) {
28404
- ret = '>=' + M + '.' + m + '.0' + pr + ' <' + M + '.' + (+m + 1) + '.0' + pr;
28405
28970
  }
28406
28971
 
28407
- debug('xRange return', ret);
28408
- return ret;
28409
- });
28410
- } // Because * is AND-ed with everything else in the comparator,
28411
- // and '' means "any version", just remove the *s entirely.
28412
-
28972
+ ret = gtlt + M + '.' + m + '.' + p + pr;
28973
+ } else if (xm) {
28974
+ ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
28975
+ } else if (xp) {
28976
+ ret = '>=' + M + '.' + m + '.0' + pr +
28977
+ ' <' + M + '.' + (+m + 1) + '.0' + pr;
28978
+ }
28413
28979
 
28414
- function replaceStars(comp, options) {
28415
- debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
28980
+ debug('xRange return', ret);
28416
28981
 
28417
- return comp.trim().replace(re[t.STAR], '');
28418
- } // This function is passed to string.replace(re[t.HYPHENRANGE])
28419
- // M, m, patch, prerelease, build
28420
- // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
28421
- // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
28422
- // 1.2 - 3.4 => >=1.2.0 <3.5.0
28982
+ return ret
28983
+ })
28984
+ }
28423
28985
 
28986
+ // Because * is AND-ed with everything else in the comparator,
28987
+ // and '' means "any version", just remove the *s entirely.
28988
+ function replaceStars (comp, options) {
28989
+ debug('replaceStars', comp, options);
28990
+ // Looseness is ignored here. star is always as loose as it gets!
28991
+ return comp.trim().replace(re[t.STAR], '')
28992
+ }
28424
28993
 
28425
- function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
28426
- if (isX(fM)) {
28427
- from = '';
28428
- } else if (isX(fm)) {
28429
- from = '>=' + fM + '.0.0';
28430
- } else if (isX(fp)) {
28431
- from = '>=' + fM + '.' + fm + '.0';
28432
- } else {
28433
- from = '>=' + from;
28434
- }
28994
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
28995
+ // M, m, patch, prerelease, build
28996
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
28997
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
28998
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0
28999
+ function hyphenReplace ($0,
29000
+ from, fM, fm, fp, fpr, fb,
29001
+ to, tM, tm, tp, tpr, tb) {
29002
+ if (isX(fM)) {
29003
+ from = '';
29004
+ } else if (isX(fm)) {
29005
+ from = '>=' + fM + '.0.0';
29006
+ } else if (isX(fp)) {
29007
+ from = '>=' + fM + '.' + fm + '.0';
29008
+ } else {
29009
+ from = '>=' + from;
29010
+ }
28435
29011
 
28436
- if (isX(tM)) {
28437
- to = '';
28438
- } else if (isX(tm)) {
28439
- to = '<' + (+tM + 1) + '.0.0';
28440
- } else if (isX(tp)) {
28441
- to = '<' + tM + '.' + (+tm + 1) + '.0';
28442
- } else if (tpr) {
28443
- to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
28444
- } else {
28445
- to = '<=' + to;
28446
- }
29012
+ if (isX(tM)) {
29013
+ to = '';
29014
+ } else if (isX(tm)) {
29015
+ to = '<' + (+tM + 1) + '.0.0';
29016
+ } else if (isX(tp)) {
29017
+ to = '<' + tM + '.' + (+tm + 1) + '.0';
29018
+ } else if (tpr) {
29019
+ to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
29020
+ } else {
29021
+ to = '<=' + to;
29022
+ }
28447
29023
 
28448
- return (from + ' ' + to).trim();
28449
- } // if ANY of the sets match ALL of its comparators, then pass
29024
+ return (from + ' ' + to).trim()
29025
+ }
28450
29026
 
29027
+ // if ANY of the sets match ALL of its comparators, then pass
29028
+ Range.prototype.test = function (version) {
29029
+ if (!version) {
29030
+ return false
29031
+ }
28451
29032
 
28452
- Range.prototype.test = function (version) {
28453
- if (!version) {
28454
- return false;
29033
+ if (typeof version === 'string') {
29034
+ try {
29035
+ version = new SemVer(version, this.options);
29036
+ } catch (er) {
29037
+ return false
28455
29038
  }
29039
+ }
28456
29040
 
28457
- if (typeof version === 'string') {
28458
- try {
28459
- version = new SemVer(version, this.options);
28460
- } catch (er) {
28461
- return false;
28462
- }
29041
+ for (var i = 0; i < this.set.length; i++) {
29042
+ if (testSet(this.set[i], version, this.options)) {
29043
+ return true
28463
29044
  }
29045
+ }
29046
+ return false
29047
+ };
28464
29048
 
28465
- for (var i = 0; i < this.set.length; i++) {
28466
- if (testSet(this.set[i], version, this.options)) {
28467
- return true;
28468
- }
29049
+ function testSet (set, version, options) {
29050
+ for (var i = 0; i < set.length; i++) {
29051
+ if (!set[i].test(version)) {
29052
+ return false
28469
29053
  }
29054
+ }
28470
29055
 
28471
- return false;
28472
- };
28473
-
28474
- function testSet(set, version, options) {
28475
- for (var i = 0; i < set.length; i++) {
28476
- if (!set[i].test(version)) {
28477
- return false;
29056
+ if (version.prerelease.length && !options.includePrerelease) {
29057
+ // Find the set of versions that are allowed to have prereleases
29058
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
29059
+ // That should allow `1.2.3-pr.2` to pass.
29060
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
29061
+ // even though it's within the range set by the comparators.
29062
+ for (i = 0; i < set.length; i++) {
29063
+ debug(set[i].semver);
29064
+ if (set[i].semver === ANY) {
29065
+ continue
28478
29066
  }
28479
- }
28480
-
28481
- if (version.prerelease.length && !options.includePrerelease) {
28482
- // Find the set of versions that are allowed to have prereleases
28483
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
28484
- // That should allow `1.2.3-pr.2` to pass.
28485
- // However, `1.2.4-alpha.notready` should NOT be allowed,
28486
- // even though it's within the range set by the comparators.
28487
- for (i = 0; i < set.length; i++) {
28488
- debug(set[i].semver);
28489
-
28490
- if (set[i].semver === ANY) {
28491
- continue;
28492
- }
28493
29067
 
28494
- if (set[i].semver.prerelease.length > 0) {
28495
- var allowed = set[i].semver;
28496
-
28497
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
28498
- return true;
28499
- }
29068
+ if (set[i].semver.prerelease.length > 0) {
29069
+ var allowed = set[i].semver;
29070
+ if (allowed.major === version.major &&
29071
+ allowed.minor === version.minor &&
29072
+ allowed.patch === version.patch) {
29073
+ return true
28500
29074
  }
28501
- } // Version has a -pre, but it's not one of the ones we like.
28502
-
28503
-
28504
- return false;
29075
+ }
28505
29076
  }
28506
29077
 
28507
- return true;
29078
+ // Version has a -pre, but it's not one of the ones we like.
29079
+ return false
28508
29080
  }
28509
29081
 
28510
- exports.satisfies = satisfies;
28511
-
28512
- function satisfies(version, range, options) {
28513
- try {
28514
- range = new Range(range, options);
28515
- } catch (er) {
28516
- return false;
28517
- }
29082
+ return true
29083
+ }
28518
29084
 
28519
- return range.test(version);
29085
+ exports.satisfies = satisfies;
29086
+ function satisfies (version, range, options) {
29087
+ try {
29088
+ range = new Range(range, options);
29089
+ } catch (er) {
29090
+ return false
28520
29091
  }
29092
+ return range.test(version)
29093
+ }
28521
29094
 
28522
- exports.maxSatisfying = maxSatisfying;
28523
-
28524
- function maxSatisfying(versions, range, options) {
28525
- var max = null;
28526
- var maxSV = null;
28527
-
28528
- try {
28529
- var rangeObj = new Range(range, options);
28530
- } catch (er) {
28531
- return null;
29095
+ exports.maxSatisfying = maxSatisfying;
29096
+ function maxSatisfying (versions, range, options) {
29097
+ var max = null;
29098
+ var maxSV = null;
29099
+ try {
29100
+ var rangeObj = new Range(range, options);
29101
+ } catch (er) {
29102
+ return null
29103
+ }
29104
+ versions.forEach(function (v) {
29105
+ if (rangeObj.test(v)) {
29106
+ // satisfies(v, range, options)
29107
+ if (!max || maxSV.compare(v) === -1) {
29108
+ // compare(max, v, true)
29109
+ max = v;
29110
+ maxSV = new SemVer(max, options);
29111
+ }
28532
29112
  }
29113
+ });
29114
+ return max
29115
+ }
28533
29116
 
28534
- versions.forEach(function (v) {
28535
- if (rangeObj.test(v)) {
28536
- // satisfies(v, range, options)
28537
- if (!max || maxSV.compare(v) === -1) {
28538
- // compare(max, v, true)
28539
- max = v;
28540
- maxSV = new SemVer(max, options);
28541
- }
28542
- }
28543
- });
28544
- return max;
29117
+ exports.minSatisfying = minSatisfying;
29118
+ function minSatisfying (versions, range, options) {
29119
+ var min = null;
29120
+ var minSV = null;
29121
+ try {
29122
+ var rangeObj = new Range(range, options);
29123
+ } catch (er) {
29124
+ return null
28545
29125
  }
29126
+ versions.forEach(function (v) {
29127
+ if (rangeObj.test(v)) {
29128
+ // satisfies(v, range, options)
29129
+ if (!min || minSV.compare(v) === 1) {
29130
+ // compare(min, v, true)
29131
+ min = v;
29132
+ minSV = new SemVer(min, options);
29133
+ }
29134
+ }
29135
+ });
29136
+ return min
29137
+ }
28546
29138
 
28547
- exports.minSatisfying = minSatisfying;
29139
+ exports.minVersion = minVersion;
29140
+ function minVersion (range, loose) {
29141
+ range = new Range(range, loose);
28548
29142
 
28549
- function minSatisfying(versions, range, options) {
28550
- var min = null;
28551
- var minSV = null;
29143
+ var minver = new SemVer('0.0.0');
29144
+ if (range.test(minver)) {
29145
+ return minver
29146
+ }
28552
29147
 
28553
- try {
28554
- var rangeObj = new Range(range, options);
28555
- } catch (er) {
28556
- return null;
28557
- }
29148
+ minver = new SemVer('0.0.0-0');
29149
+ if (range.test(minver)) {
29150
+ return minver
29151
+ }
28558
29152
 
28559
- versions.forEach(function (v) {
28560
- if (rangeObj.test(v)) {
28561
- // satisfies(v, range, options)
28562
- if (!min || minSV.compare(v) === 1) {
28563
- // compare(min, v, true)
28564
- min = v;
28565
- minSV = new SemVer(min, options);
28566
- }
29153
+ minver = null;
29154
+ for (var i = 0; i < range.set.length; ++i) {
29155
+ var comparators = range.set[i];
29156
+
29157
+ comparators.forEach(function (comparator) {
29158
+ // Clone to avoid manipulating the comparator's semver object.
29159
+ var compver = new SemVer(comparator.semver.version);
29160
+ switch (comparator.operator) {
29161
+ case '>':
29162
+ if (compver.prerelease.length === 0) {
29163
+ compver.patch++;
29164
+ } else {
29165
+ compver.prerelease.push(0);
29166
+ }
29167
+ compver.raw = compver.format();
29168
+ /* fallthrough */
29169
+ case '':
29170
+ case '>=':
29171
+ if (!minver || gt(minver, compver)) {
29172
+ minver = compver;
29173
+ }
29174
+ break
29175
+ case '<':
29176
+ case '<=':
29177
+ /* Ignore maximum versions */
29178
+ break
29179
+ /* istanbul ignore next */
29180
+ default:
29181
+ throw new Error('Unexpected operation: ' + comparator.operator)
28567
29182
  }
28568
29183
  });
28569
- return min;
28570
29184
  }
28571
29185
 
28572
- exports.minVersion = minVersion;
28573
-
28574
- function minVersion(range, loose) {
28575
- range = new Range(range, loose);
28576
- var minver = new SemVer('0.0.0');
28577
-
28578
- if (range.test(minver)) {
28579
- return minver;
28580
- }
28581
-
28582
- minver = new SemVer('0.0.0-0');
28583
-
28584
- if (range.test(minver)) {
28585
- return minver;
28586
- }
28587
-
28588
- minver = null;
28589
-
28590
- for (var i = 0; i < range.set.length; ++i) {
28591
- var comparators = range.set[i];
28592
- comparators.forEach(function (comparator) {
28593
- // Clone to avoid manipulating the comparator's semver object.
28594
- var compver = new SemVer(comparator.semver.version);
29186
+ if (minver && range.test(minver)) {
29187
+ return minver
29188
+ }
28595
29189
 
28596
- switch (comparator.operator) {
28597
- case '>':
28598
- if (compver.prerelease.length === 0) {
28599
- compver.patch++;
28600
- } else {
28601
- compver.prerelease.push(0);
28602
- }
29190
+ return null
29191
+ }
28603
29192
 
28604
- compver.raw = compver.format();
29193
+ exports.validRange = validRange;
29194
+ function validRange (range, options) {
29195
+ try {
29196
+ // Return '*' instead of '' so that truthiness works.
29197
+ // This will throw if it's invalid anyway
29198
+ return new Range(range, options).range || '*'
29199
+ } catch (er) {
29200
+ return null
29201
+ }
29202
+ }
29203
+
29204
+ // Determine if version is less than all the versions possible in the range
29205
+ exports.ltr = ltr;
29206
+ function ltr (version, range, options) {
29207
+ return outside(version, range, '<', options)
29208
+ }
29209
+
29210
+ // Determine if version is greater than all the versions possible in the range.
29211
+ exports.gtr = gtr;
29212
+ function gtr (version, range, options) {
29213
+ return outside(version, range, '>', options)
29214
+ }
29215
+
29216
+ exports.outside = outside;
29217
+ function outside (version, range, hilo, options) {
29218
+ version = new SemVer(version, options);
29219
+ range = new Range(range, options);
29220
+
29221
+ var gtfn, ltefn, ltfn, comp, ecomp;
29222
+ switch (hilo) {
29223
+ case '>':
29224
+ gtfn = gt;
29225
+ ltefn = lte;
29226
+ ltfn = lt;
29227
+ comp = '>';
29228
+ ecomp = '>=';
29229
+ break
29230
+ case '<':
29231
+ gtfn = lt;
29232
+ ltefn = gte;
29233
+ ltfn = gt;
29234
+ comp = '<';
29235
+ ecomp = '<=';
29236
+ break
29237
+ default:
29238
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
29239
+ }
28605
29240
 
28606
- /* fallthrough */
29241
+ // If it satisifes the range it is not outside
29242
+ if (satisfies(version, range, options)) {
29243
+ return false
29244
+ }
28607
29245
 
28608
- case '':
28609
- case '>=':
28610
- if (!minver || gt(minver, compver)) {
28611
- minver = compver;
28612
- }
29246
+ // From now on, variable terms are as if we're in "gtr" mode.
29247
+ // but note that everything is flipped for the "ltr" function.
28613
29248
 
28614
- break;
29249
+ for (var i = 0; i < range.set.length; ++i) {
29250
+ var comparators = range.set[i];
28615
29251
 
28616
- case '<':
28617
- case '<=':
28618
- /* Ignore maximum versions */
28619
- break;
29252
+ var high = null;
29253
+ var low = null;
28620
29254
 
28621
- /* istanbul ignore next */
29255
+ comparators.forEach(function (comparator) {
29256
+ if (comparator.semver === ANY) {
29257
+ comparator = new Comparator('>=0.0.0');
29258
+ }
29259
+ high = high || comparator;
29260
+ low = low || comparator;
29261
+ if (gtfn(comparator.semver, high.semver, options)) {
29262
+ high = comparator;
29263
+ } else if (ltfn(comparator.semver, low.semver, options)) {
29264
+ low = comparator;
29265
+ }
29266
+ });
28622
29267
 
28623
- default:
28624
- throw new Error('Unexpected operation: ' + comparator.operator);
28625
- }
28626
- });
29268
+ // If the edge version comparator has a operator then our version
29269
+ // isn't outside it
29270
+ if (high.operator === comp || high.operator === ecomp) {
29271
+ return false
28627
29272
  }
28628
29273
 
28629
- if (minver && range.test(minver)) {
28630
- return minver;
29274
+ // If the lowest version comparator has an operator and our version
29275
+ // is less than it then it isn't higher than the range
29276
+ if ((!low.operator || low.operator === comp) &&
29277
+ ltefn(version, low.semver)) {
29278
+ return false
29279
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
29280
+ return false
28631
29281
  }
28632
-
28633
- return null;
28634
29282
  }
29283
+ return true
29284
+ }
28635
29285
 
28636
- exports.validRange = validRange;
28637
-
28638
- function validRange(range, options) {
28639
- try {
28640
- // Return '*' instead of '' so that truthiness works.
28641
- // This will throw if it's invalid anyway
28642
- return new Range(range, options).range || '*';
28643
- } catch (er) {
28644
- return null;
28645
- }
28646
- } // Determine if version is less than all the versions possible in the range
28647
-
28648
-
28649
- exports.ltr = ltr;
28650
-
28651
- function ltr(version, range, options) {
28652
- return outside(version, range, '<', options);
28653
- } // Determine if version is greater than all the versions possible in the range.
28654
-
29286
+ exports.prerelease = prerelease;
29287
+ function prerelease (version, options) {
29288
+ var parsed = parse(version, options);
29289
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
29290
+ }
28655
29291
 
28656
- exports.gtr = gtr;
29292
+ exports.intersects = intersects;
29293
+ function intersects (r1, r2, options) {
29294
+ r1 = new Range(r1, options);
29295
+ r2 = new Range(r2, options);
29296
+ return r1.intersects(r2)
29297
+ }
28657
29298
 
28658
- function gtr(version, range, options) {
28659
- return outside(version, range, '>', options);
29299
+ exports.coerce = coerce;
29300
+ function coerce (version, options) {
29301
+ if (version instanceof SemVer) {
29302
+ return version
28660
29303
  }
28661
29304
 
28662
- exports.outside = outside;
28663
-
28664
- function outside(version, range, hilo, options) {
28665
- version = new SemVer(version, options);
28666
- range = new Range(range, options);
28667
- var gtfn, ltefn, ltfn, comp, ecomp;
28668
-
28669
- switch (hilo) {
28670
- case '>':
28671
- gtfn = gt;
28672
- ltefn = lte;
28673
- ltfn = lt;
28674
- comp = '>';
28675
- ecomp = '>=';
28676
- break;
28677
-
28678
- case '<':
28679
- gtfn = lt;
28680
- ltefn = gte;
28681
- ltfn = gt;
28682
- comp = '<';
28683
- ecomp = '<=';
28684
- break;
28685
-
28686
- default:
28687
- throw new TypeError('Must provide a hilo val of "<" or ">"');
28688
- } // If it satisifes the range it is not outside
28689
-
28690
-
28691
- if (satisfies(version, range, options)) {
28692
- return false;
28693
- } // From now on, variable terms are as if we're in "gtr" mode.
28694
- // but note that everything is flipped for the "ltr" function.
28695
-
28696
-
28697
- for (var i = 0; i < range.set.length; ++i) {
28698
- var comparators = range.set[i];
28699
- var high = null;
28700
- var low = null;
28701
- comparators.forEach(function (comparator) {
28702
- if (comparator.semver === ANY) {
28703
- comparator = new Comparator('>=0.0.0');
28704
- }
28705
-
28706
- high = high || comparator;
28707
- low = low || comparator;
28708
-
28709
- if (gtfn(comparator.semver, high.semver, options)) {
28710
- high = comparator;
28711
- } else if (ltfn(comparator.semver, low.semver, options)) {
28712
- low = comparator;
28713
- }
28714
- }); // If the edge version comparator has a operator then our version
28715
- // isn't outside it
29305
+ if (typeof version === 'number') {
29306
+ version = String(version);
29307
+ }
28716
29308
 
28717
- if (high.operator === comp || high.operator === ecomp) {
28718
- return false;
28719
- } // If the lowest version comparator has an operator and our version
28720
- // is less than it then it isn't higher than the range
29309
+ if (typeof version !== 'string') {
29310
+ return null
29311
+ }
28721
29312
 
29313
+ options = options || {};
28722
29314
 
28723
- if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
28724
- return false;
28725
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
28726
- return false;
29315
+ var match = null;
29316
+ if (!options.rtl) {
29317
+ match = version.match(re[t.COERCE]);
29318
+ } else {
29319
+ // Find the right-most coercible string that does not share
29320
+ // a terminus with a more left-ward coercible string.
29321
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
29322
+ //
29323
+ // Walk through the string checking with a /g regexp
29324
+ // Manually set the index so as to pick up overlapping matches.
29325
+ // Stop when we get a match that ends at the string end, since no
29326
+ // coercible string can be more right-ward without the same terminus.
29327
+ var next;
29328
+ while ((next = re[t.COERCERTL].exec(version)) &&
29329
+ (!match || match.index + match[0].length !== version.length)
29330
+ ) {
29331
+ if (!match ||
29332
+ next.index + next[0].length !== match.index + match[0].length) {
29333
+ match = next;
28727
29334
  }
29335
+ re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
28728
29336
  }
28729
-
28730
- return true;
28731
- }
28732
-
28733
- exports.prerelease = prerelease;
28734
-
28735
- function prerelease(version, options) {
28736
- var parsed = parse(version, options);
28737
- return parsed && parsed.prerelease.length ? parsed.prerelease : null;
29337
+ // leave it in a clean state
29338
+ re[t.COERCERTL].lastIndex = -1;
28738
29339
  }
28739
29340
 
28740
- exports.intersects = intersects;
28741
-
28742
- function intersects(r1, r2, options) {
28743
- r1 = new Range(r1, options);
28744
- r2 = new Range(r2, options);
28745
- return r1.intersects(r2);
29341
+ if (match === null) {
29342
+ return null
28746
29343
  }
28747
29344
 
28748
- exports.coerce = coerce;
28749
-
28750
- function coerce(version, options) {
28751
- if (version instanceof SemVer) {
28752
- return version;
28753
- }
28754
-
28755
- if (typeof version === 'number') {
28756
- version = String(version);
28757
- }
28758
-
28759
- if (typeof version !== 'string') {
28760
- return null;
28761
- }
28762
-
28763
- options = options || {};
28764
- var match = null;
28765
-
28766
- if (!options.rtl) {
28767
- match = version.match(re[t.COERCE]);
28768
- } else {
28769
- // Find the right-most coercible string that does not share
28770
- // a terminus with a more left-ward coercible string.
28771
- // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
28772
- //
28773
- // Walk through the string checking with a /g regexp
28774
- // Manually set the index so as to pick up overlapping matches.
28775
- // Stop when we get a match that ends at the string end, since no
28776
- // coercible string can be more right-ward without the same terminus.
28777
- var next;
28778
-
28779
- while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
28780
- if (!match || next.index + next[0].length !== match.index + match[0].length) {
28781
- match = next;
28782
- }
28783
-
28784
- re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
28785
- } // leave it in a clean state
28786
-
28787
-
28788
- re[t.COERCERTL].lastIndex = -1;
28789
- }
28790
-
28791
- if (match === null) {
28792
- return null;
28793
- }
28794
-
28795
- return parse(match[2] + '.' + (match[3] || '0') + '.' + (match[4] || '0'), options);
28796
- }
28797
- })(semver, semver.exports);
29345
+ return parse(match[2] +
29346
+ '.' + (match[3] || '0') +
29347
+ '.' + (match[4] || '0'), options)
29348
+ }
29349
+ }(semver, semver.exports));
28798
29350
 
28799
29351
  const LOADED = {};
28800
29352
  /**
@@ -29354,6 +29906,22 @@
29354
29906
  if (!fieldName) {
29355
29907
  throw new Error("Field identifier must be provided");
29356
29908
  }
29909
+ /**
29910
+ * @typedef { 'ltr' | 'rtl' } Direction
29911
+ */
29912
+
29913
+ /**
29914
+ * @typedef { 'vertical' | 'horizontal' } ListLayout
29915
+ */
29916
+
29917
+ /**
29918
+ * @typedef { 'none' | 'value' | 'percent' | 'relative' } FrequencyMode
29919
+ */
29920
+
29921
+ /**
29922
+ * @typedef { false | true | 'toggle' } SearchMode
29923
+ */
29924
+
29357
29925
  /**
29358
29926
  * @typedef {function(function)} ReceiverFunction A callback function which receives another function as input.
29359
29927
  */
@@ -29373,9 +29941,13 @@
29373
29941
  * @param {HTMLElement} element
29374
29942
  * @param {object=} options Settings for the embedded listbox
29375
29943
  * @param {string=} options.title Custom title, defaults to fieldname
29376
- * @param {string=} [options.direction=ltr] Direction setting ltr|rtl.
29377
- * @param {string=} [options.listLayout=vertical] Layout direction vertical|horizontal
29378
- * @param {boolean=} [options.search=true] Show the search bar
29944
+ * @param {Direction=} [options.direction=ltr] Direction setting ltr|rtl.
29945
+ * @param {ListLayout=} [options.listLayout=vertical] Layout direction vertical|horizontal
29946
+ * @param {FrequencyMode=} [options.frequencyMode=none] Show frequency none|value|percent|relative
29947
+ * @param {boolean=} [options.histogram=false] Show histogram bar
29948
+ * @param {SearchMode=} [options.search=true] Show the search bar permanently or using the toggle button: false|true|toggle|toggleShow
29949
+ * @param {boolean=} [options.focusSearch=false] Initialize the Listbox with the search input focused. Only applicable when
29950
+ * search is true, since toggling will always focus the search input on show.
29379
29951
  * @param {boolean=} [options.toolbar=true] Show the toolbar
29380
29952
  * @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields
29381
29953
  * @param {boolean=} [options.rangeSelect=true] Enable range selection
@@ -29384,6 +29956,7 @@
29384
29956
  * @param {object=} [options.properties={}] Properties object to extend default properties with
29385
29957
  * @param {object} [options.sessionModel] Use a custom sessionModel.
29386
29958
  * @param {object} [options.selectionsApi] Use a custom selectionsApi to customize how values are selected.
29959
+ * @param {function():boolean} [options.selectDisabled=] Define a function which tells when selections are disabled (true) or enabled (false). By default, always returns false.
29387
29960
  * @param {ReceiverFunction} [options.update] A function which receives an update function which upon call will trigger a data fetch.
29388
29961
  * @since 1.1.0
29389
29962
  * @instance