@splunk/visualizations-shared 26.4.1 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.loki/reference/chrome_docker_SizeAwareWrapper_50_parent.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Fix_size_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container.png +0 -0
- package/.loki/reference/chrome_docker_SizeAwareWrapper_Flex_layout_container_with_extra_wrapper.png +0 -0
- package/Downloader.js +164 -403
- package/Downloader.js.map +7 -1
- package/FileDownloader.js +121 -557
- package/FileDownloader.js.map +7 -1
- package/JSONSchemaUtils.js +58 -134
- package/JSONSchemaUtils.js.map +7 -1
- package/Message.js +105 -270
- package/Message.js.map +7 -1
- package/RemoteIcon.js +272 -736
- package/RemoteIcon.js.map +7 -1
- package/RemoteImage.js +190 -458
- package/RemoteImage.js.map +7 -1
- package/SanitizeProps.js +117 -238
- package/SanitizeProps.js.map +7 -1
- package/SizeAwareWrapper.js +108 -306
- package/SizeAwareWrapper.js.map +7 -1
- package/SizeAwareWrapperDeprecated.js +117 -326
- package/SizeAwareWrapperDeprecated.js.map +7 -1
- package/VisualizationDocPage.js +212 -461
- package/VisualizationDocPage.js.map +7 -1
- package/colorConstants.js +81 -132
- package/colorConstants.js.map +7 -1
- package/colorUtils.js +47 -134
- package/colorUtils.js.map +7 -1
- package/configUtils.js +28 -112
- package/configUtils.js.map +7 -1
- package/console.js +45 -183
- package/console.js.map +7 -1
- package/dataSourceUtils.js +45 -140
- package/dataSourceUtils.js.map +7 -1
- package/domUtils.js +58 -122
- package/domUtils.js.map +7 -1
- package/hocUtils.js +45 -122
- package/hocUtils.js.map +7 -1
- package/i18n.js +168 -323
- package/i18n.js.map +7 -1
- package/iconUtils.js +47 -178
- package/iconUtils.js.map +7 -1
- package/mapUtils.js +45 -122
- package/mapUtils.js.map +7 -1
- package/numberUtils.js +101 -275
- package/numberUtils.js.map +7 -1
- package/package.json +18 -22
- package/previewVizMessage.js +28 -108
- package/previewVizMessage.js.map +7 -1
- package/propUtils.js +88 -212
- package/propUtils.js.map +7 -1
- package/schemaUtils.js +58 -185
- package/schemaUtils.js.map +7 -1
- package/simpleXMLOptions.js +142 -225
- package/simpleXMLOptions.js.map +7 -1
- package/style.js +65 -168
- package/style.js.map +7 -1
- package/testHelper.js +247 -303
- package/testHelper.js.map +7 -1
- package/themeUtils.js +63 -142
- package/themeUtils.js.map +7 -1
- package/trellisUtils.js +108 -276
- package/trellisUtils.js.map +7 -1
package/numberUtils.js
CHANGED
|
@@ -1,314 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
45
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
46
|
-
/******/ }
|
|
47
|
-
/******/ };
|
|
48
|
-
/******/
|
|
49
|
-
/******/ // define __esModule on exports
|
|
50
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
51
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
52
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
53
|
-
/******/ }
|
|
54
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
55
|
-
/******/ };
|
|
56
|
-
/******/
|
|
57
|
-
/******/ // create a fake namespace object
|
|
58
|
-
/******/ // mode & 1: value is a module id, require it
|
|
59
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
60
|
-
/******/ // mode & 4: return value when already ns object
|
|
61
|
-
/******/ // mode & 8|1: behave like require
|
|
62
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
63
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
64
|
-
/******/ if(mode & 8) return value;
|
|
65
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
66
|
-
/******/ var ns = Object.create(null);
|
|
67
|
-
/******/ __webpack_require__.r(ns);
|
|
68
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
69
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
70
|
-
/******/ return ns;
|
|
71
|
-
/******/ };
|
|
72
|
-
/******/
|
|
73
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
74
|
-
/******/ __webpack_require__.n = function(module) {
|
|
75
|
-
/******/ var getter = module && module.__esModule ?
|
|
76
|
-
/******/ function getDefault() { return module['default']; } :
|
|
77
|
-
/******/ function getModuleExports() { return module; };
|
|
78
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
79
|
-
/******/ return getter;
|
|
80
|
-
/******/ };
|
|
81
|
-
/******/
|
|
82
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
83
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
84
|
-
/******/
|
|
85
|
-
/******/ // __webpack_public_path__
|
|
86
|
-
/******/ __webpack_require__.p = "";
|
|
87
|
-
/******/
|
|
88
|
-
/******/
|
|
89
|
-
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s = 60);
|
|
91
|
-
/******/ })
|
|
92
|
-
/************************************************************************/
|
|
93
|
-
/******/ ({
|
|
94
|
-
|
|
95
|
-
/***/ 15:
|
|
96
|
-
/***/ (function(module, exports) {
|
|
97
|
-
|
|
98
|
-
module.exports = require("@splunk/moment");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
|
|
102
|
-
/***/ 22:
|
|
103
|
-
/***/ (function(module, exports) {
|
|
104
|
-
|
|
105
|
-
module.exports = require("@babel/runtime/helpers/typeof");
|
|
106
|
-
|
|
107
|
-
/***/ }),
|
|
108
|
-
|
|
109
|
-
/***/ 4:
|
|
110
|
-
/***/ (function(module, exports) {
|
|
111
|
-
|
|
112
|
-
module.exports = require("lodash");
|
|
113
|
-
|
|
114
|
-
/***/ }),
|
|
115
|
-
|
|
116
|
-
/***/ 60:
|
|
117
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
118
|
-
|
|
119
|
-
"use strict";
|
|
120
|
-
__webpack_require__.r(__webpack_exports__);
|
|
121
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNumerialStr", function() { return isNumerialStr; });
|
|
122
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNumerial", function() { return isNumerial; });
|
|
123
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseNumber", function() { return parseNumber; });
|
|
124
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "startsWithNumber", function() { return startsWithNumber; });
|
|
125
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatNumber", function() { return formatNumber; });
|
|
126
|
-
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
|
|
127
|
-
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
|
|
128
|
-
/* harmony import */ var _splunk_moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
|
|
129
|
-
/* harmony import */ var _splunk_moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_splunk_moment__WEBPACK_IMPORTED_MODULE_1__);
|
|
130
|
-
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
131
|
-
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);
|
|
132
|
-
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
133
|
-
/* harmony import */ var _splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_3__);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// Todo: need break out this utils after breaking out all visualizations
|
|
1
|
+
/* Copyright © 2020 Splunk Inc.
|
|
2
|
+
SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
|
|
3
|
+
in part without a valid written license from Splunk Inc. is PROHIBITED. */
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __pow = Math.pow;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// src/numberUtils.js
|
|
35
|
+
var numberUtils_exports = {};
|
|
36
|
+
__export(numberUtils_exports, {
|
|
37
|
+
formatNumber: () => formatNumber,
|
|
38
|
+
isNumerial: () => isNumerial,
|
|
39
|
+
isNumerialStr: () => isNumerialStr,
|
|
40
|
+
parseNumber: () => parseNumber,
|
|
41
|
+
startsWithNumber: () => startsWithNumber
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(numberUtils_exports);
|
|
138
44
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
45
|
+
// esm-externals:@splunk/moment
|
|
46
|
+
var moment_exports = {};
|
|
47
|
+
__export(moment_exports, {
|
|
48
|
+
default: () => moment_default
|
|
49
|
+
});
|
|
50
|
+
var defaultImport = __toESM(require("@splunk/moment"));
|
|
51
|
+
__reExport(moment_exports, require("@splunk/moment"));
|
|
52
|
+
var moment_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
53
|
+
|
|
54
|
+
// esm-externals:lodash
|
|
55
|
+
var lodash_exports = {};
|
|
56
|
+
__export(lodash_exports, {
|
|
57
|
+
default: () => lodash_default
|
|
58
|
+
});
|
|
59
|
+
var defaultImport2 = __toESM(require("lodash"));
|
|
60
|
+
__reExport(lodash_exports, require("lodash"));
|
|
61
|
+
var lodash_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
62
|
+
|
|
63
|
+
// esm-externals:@splunk/ui-utils/i18n
|
|
64
|
+
var i18n_exports = {};
|
|
65
|
+
__export(i18n_exports, {
|
|
66
|
+
default: () => i18n_default
|
|
67
|
+
});
|
|
68
|
+
var defaultImport3 = __toESM(require("@splunk/ui-utils/i18n"));
|
|
69
|
+
__reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
|
|
70
|
+
var i18n_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
|
|
143
71
|
|
|
72
|
+
// src/numberUtils.js
|
|
144
73
|
var DECIMAL_OR_SCIENTIFIC_REGEX = /(^[-+]?[0-9]*[.]?[0-9]*$)|(^[-+]?[0-9][.]?[0-9]*e[-+]?[0-9][0-9]*$)/i;
|
|
145
74
|
var COMMA_SEPARATED_NUMBER_REGEX = /(^[-+]?([0]|([1-9][0-9]{0,2})|(([1-9][0-9]{0,2}[,])([0-9]{3}[,])*[0-9]{3}))(([.][0-9]+)?)$)/;
|
|
146
75
|
var STARTS_WITH_NUMBER_REGEX = /^[-+]?\d/;
|
|
147
|
-
|
|
148
76
|
function isDecimalOrExpo(str) {
|
|
149
77
|
return DECIMAL_OR_SCIENTIFIC_REGEX.test(str);
|
|
150
78
|
}
|
|
151
|
-
|
|
152
79
|
function isCommaSeparatedNumber(str) {
|
|
153
80
|
return COMMA_SEPARATED_NUMBER_REGEX.test(str);
|
|
154
81
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Check if a string can be considered as numeric, this includes decimal, scientific number and number with comma separator
|
|
157
|
-
*
|
|
158
|
-
* Examples:
|
|
159
|
-
* ```js
|
|
160
|
-
* const { isNumerialStr } from '@splunk/react-visualizations/utils/numberUtils';
|
|
161
|
-
* assert.ok(isNumerialStr('11.123'));
|
|
162
|
-
* ```
|
|
163
|
-
* @param {String} str input value
|
|
164
|
-
* @return {Boolean}
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
82
|
function isNumerialStr(str) {
|
|
170
83
|
return isDecimalOrExpo(str) || isCommaSeparatedNumber(str);
|
|
171
84
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Check if a value can be considered as numeric
|
|
174
|
-
*
|
|
175
|
-
* Examples:
|
|
176
|
-
* ```js
|
|
177
|
-
* const { isNumerial } from '@splunk/react-visualizations/utils/numberUtils';
|
|
178
|
-
* assert.equal(isNumerial('11.123') == 11.123);
|
|
179
|
-
* ```
|
|
180
|
-
* @param {any} value input value
|
|
181
|
-
* @return {Boolean}
|
|
182
|
-
* @public
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
85
|
function isNumerial(value) {
|
|
186
|
-
return
|
|
86
|
+
return (0, lodash_exports.isFinite)(value) || (0, lodash_exports.isString)(value) && isNumerialStr(value);
|
|
187
87
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Parse input value into number, return NaN for not numercial value
|
|
190
|
-
* @param {*} value input value
|
|
191
|
-
* @return {Number}
|
|
192
|
-
* @public
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
88
|
function parseNumber(value) {
|
|
196
|
-
if (
|
|
197
|
-
// only parses the value consider as numeric.
|
|
89
|
+
if ((0, lodash_exports.isFinite)(value) || (0, lodash_exports.isString)(value) && isDecimalOrExpo(value)) {
|
|
198
90
|
return parseFloat(value);
|
|
199
91
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return parseFloat(value.replace(/,/g, ''));
|
|
92
|
+
if ((0, lodash_exports.isString)(value) && isCommaSeparatedNumber(value)) {
|
|
93
|
+
return parseFloat(value.replace(/,/g, ""));
|
|
203
94
|
}
|
|
204
|
-
|
|
205
95
|
return NaN;
|
|
206
96
|
}
|
|
207
|
-
/**
|
|
208
|
-
* Returns whether a string starts with a number.
|
|
209
|
-
* @param {string} value
|
|
210
|
-
* @returns boolean
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
97
|
function startsWithNumber(value) {
|
|
214
98
|
return STARTS_WITH_NUMBER_REGEX.test(value);
|
|
215
99
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
- * Examples:
|
|
231
|
-
- * ```js
|
|
232
|
-
- * const { formatNumber } from '@splunk/react-visualizations/utils/numberUtils';
|
|
233
|
-
- * assert.equal(formatNumber('1100’, 2, { useThousandSeparators: true }), '1,100.00’)
|
|
234
|
-
- * ```
|
|
235
|
-
- * @param {Number} number // value to format
|
|
236
|
-
- * @param {Number} [precision] // number of digits after the decimal point
|
|
237
|
-
- * @param {Object} [options]
|
|
238
|
-
- * @param {Boolean} [options.useThousandSeparators=false] // flag to determine if grouping is desired
|
|
239
|
-
- * @param {Object} [options.locale=moment.locale()] // Locale of the user for determinining how numbers are grouped
|
|
240
|
-
- * @param {Number} [options.defaultPrecision=0] // The default precision to use if none is defined
|
|
241
|
-
- * @param {Number} [options.useTrendUnits=false] // Add K, M, B, T to end of value, and divide by the appropriate order of magnitude
|
|
242
|
-
- * @return {String}
|
|
243
|
-
- * @public
|
|
244
|
-
- */
|
|
245
|
-
|
|
246
|
-
function formatNumber(number, precision) {
|
|
247
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
248
|
-
var formatOptions = {}; // Precision is optional, so check if precision is an object, and use it as the options, otherwise load from options
|
|
249
|
-
|
|
250
|
-
var _ref = precision && _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(precision) === 'object' ? precision : options,
|
|
251
|
-
_ref$useThousandSepar = _ref.useThousandSeparators,
|
|
252
|
-
useThousandSeparators = _ref$useThousandSepar === void 0 ? false : _ref$useThousandSepar,
|
|
253
|
-
_ref$locale = _ref.locale,
|
|
254
|
-
locale = _ref$locale === void 0 ? _splunk_moment__WEBPACK_IMPORTED_MODULE_1___default.a.locale() : _ref$locale,
|
|
255
|
-
_ref$defaultPrecision = _ref.defaultPrecision,
|
|
256
|
-
defaultPrecision = _ref$defaultPrecision === void 0 ? 0 : _ref$defaultPrecision,
|
|
257
|
-
_ref$useTrendUnits = _ref.useTrendUnits,
|
|
258
|
-
useTrendUnits = _ref$useTrendUnits === void 0 ? false : _ref$useTrendUnits; // Apply precision only when it is a positive integer
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (Object(lodash__WEBPACK_IMPORTED_MODULE_2__["isInteger"])(precision) && precision >= 0) {
|
|
262
|
-
// Validate precision is within acceptable bounds
|
|
263
|
-
var p = precision > 20 ? 20 : precision;
|
|
100
|
+
var getThousandSeparatorDecimalPrecisionFormatter = (0, lodash_exports.memoize)(
|
|
101
|
+
(locale = "en", options = {}) => new Intl.NumberFormat(locale, options),
|
|
102
|
+
(locale, options) => `${locale}${JSON.stringify(options)}`
|
|
103
|
+
);
|
|
104
|
+
function formatNumber(number, precision, options = {}) {
|
|
105
|
+
const formatOptions = {};
|
|
106
|
+
const {
|
|
107
|
+
useThousandSeparators = false,
|
|
108
|
+
locale = moment_default.locale(),
|
|
109
|
+
defaultPrecision = 0,
|
|
110
|
+
useTrendUnits = false
|
|
111
|
+
} = precision && typeof precision === "object" ? precision : options;
|
|
112
|
+
if ((0, lodash_exports.isInteger)(precision) && precision >= 0) {
|
|
113
|
+
const p = precision > 20 ? 20 : precision;
|
|
264
114
|
formatOptions.minimumFractionDigits = p;
|
|
265
115
|
formatOptions.maximumFractionDigits = p;
|
|
266
116
|
} else {
|
|
267
117
|
formatOptions.maximumFractionDigits = defaultPrecision;
|
|
268
118
|
}
|
|
269
|
-
|
|
270
119
|
formatOptions.useGrouping = useThousandSeparators === true;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
letter:
|
|
275
|
-
power:
|
|
276
|
-
|
|
277
|
-
letter:
|
|
278
|
-
|
|
279
|
-
}, {
|
|
280
|
-
letter: 'M',
|
|
281
|
-
power: 6
|
|
282
|
-
}, {
|
|
283
|
-
letter: 'K',
|
|
284
|
-
power: 3
|
|
285
|
-
}];
|
|
286
|
-
|
|
120
|
+
let trendUnit = "";
|
|
121
|
+
let value = number;
|
|
122
|
+
const units = [
|
|
123
|
+
{ letter: "T", power: 12 },
|
|
124
|
+
{ letter: "B", power: 9 },
|
|
125
|
+
{ letter: "M", power: 6 },
|
|
126
|
+
{ letter: "K", power: 3 }
|
|
127
|
+
];
|
|
287
128
|
if (useTrendUnits) {
|
|
288
|
-
|
|
289
|
-
return Math.abs(value) > Math.pow(10, unit.power);
|
|
290
|
-
});
|
|
291
|
-
|
|
129
|
+
const found = units.find((unit) => Math.abs(value) > __pow(10, unit.power));
|
|
292
130
|
if (found) {
|
|
293
|
-
value /=
|
|
131
|
+
value /= __pow(10, found.power);
|
|
294
132
|
trendUnit = found.letter;
|
|
295
133
|
formatOptions.maximumFractionDigits = 2;
|
|
296
134
|
formatOptions.minimumFractionDigits = 0;
|
|
297
135
|
}
|
|
298
136
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return "".concat(formatter.format(value)).concat(trendUnit ? Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_3__["_"])(trendUnit) : '');
|
|
137
|
+
const formatter = getThousandSeparatorDecimalPrecisionFormatter(locale, formatOptions);
|
|
138
|
+
return `${formatter.format(value)}${trendUnit ? (0, i18n_exports._)(trendUnit) : ""}`;
|
|
302
139
|
}
|
|
303
|
-
|
|
304
|
-
/***/ }),
|
|
305
|
-
|
|
306
|
-
/***/ 9:
|
|
307
|
-
/***/ (function(module, exports) {
|
|
308
|
-
|
|
309
|
-
module.exports = require("@splunk/ui-utils/i18n");
|
|
310
|
-
|
|
311
|
-
/***/ })
|
|
312
|
-
|
|
313
|
-
/******/ });
|
|
314
|
-
//# sourceMappingURL=numberUtils.js.map
|
|
140
|
+
//# sourceMappingURL=numberUtils.js.map
|
package/numberUtils.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@splunk/moment\"","webpack:///external \"@babel/runtime/helpers/typeof\"","webpack:///external \"lodash\"","webpack:///./src/numberUtils.js","webpack:///external \"@splunk/ui-utils/i18n\""],"names":["DECIMAL_OR_SCIENTIFIC_REGEX","COMMA_SEPARATED_NUMBER_REGEX","STARTS_WITH_NUMBER_REGEX","isDecimalOrExpo","isCommaSeparatedNumber","isFinite","isString","isNumerialStr","parseFloat","value","getThousandSeparatorDecimalPrecisionFormatter","memoize","locale","options","Intl","JSON","formatOptions","precision","useThousandSeparators","moment","defaultPrecision","useTrendUnits","isInteger","p","trendUnit","units","letter","power","found","Math","unit","formatter","_"],"mappings":";;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2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f,QAAMC,KAAK,GAAG,KAAK,CAAL,KAAW,gBAAI;AAAA,aAAIC,IAAI,CAAJA,0BAAwBC,IAAI,CAAhC,KAAID,CAAJ;AAA7B,KAAc,CAAd;;AAEA,eAAW;AACPpB,WAAK,iBAAUmB,KAAK,CAApBnB,KAAK,CAALA;AACAe,eAAS,GAAGI,KAAK,CAAjBJ;AACAR,mBAAa,CAAbA;AACAA,mBAAa,CAAbA;AACH;AACJ;;AAED,MAAMe,SAAS,GAAGrB,6CAA6C,SAA/D,aAA+D,CAA/D;AAEA,mBAAUqB,SAAS,CAATA,OAAV,KAAUA,CAAV,SAAoCP,SAAS,GAAGQ,+DAAC,CAAJ,SAAI,CAAJ,GAA7C;AACH,C;;;;;;;ACtJD,kD","file":"numberUtils.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 60);\n","module.exports = require(\"@splunk/moment\");","module.exports = require(\"@babel/runtime/helpers/typeof\");","module.exports = require(\"lodash\");","import moment from '@splunk/moment';\nimport { isFinite, isString, isInteger, memoize } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\n\n// Todo: need break out this utils after breaking out all visualizations\n/**\n * @file\n * A set of number formatting function used in Table\n */\nconst DECIMAL_OR_SCIENTIFIC_REGEX = /(^[-+]?[0-9]*[.]?[0-9]*$)|(^[-+]?[0-9][.]?[0-9]*e[-+]?[0-9][0-9]*$)/i;\nconst COMMA_SEPARATED_NUMBER_REGEX = /(^[-+]?([0]|([1-9][0-9]{0,2})|(([1-9][0-9]{0,2}[,])([0-9]{3}[,])*[0-9]{3}))(([.][0-9]+)?)$)/;\nconst STARTS_WITH_NUMBER_REGEX = /^[-+]?\\d/;\nfunction isDecimalOrExpo(str) {\n return DECIMAL_OR_SCIENTIFIC_REGEX.test(str);\n}\nfunction isCommaSeparatedNumber(str) {\n return COMMA_SEPARATED_NUMBER_REGEX.test(str);\n}\n\n/**\n * Check if a string can be considered as numeric, this includes decimal, scientific number and number with comma separator\n *\n * Examples:\n * ```js\n * const { isNumerialStr } from '@splunk/react-visualizations/utils/numberUtils';\n * assert.ok(isNumerialStr('11.123'));\n * ```\n * @param {String} str input value\n * @return {Boolean}\n * @public\n */\nexport function isNumerialStr(str) {\n return isDecimalOrExpo(str) || isCommaSeparatedNumber(str);\n}\n\n/**\n * Check if a value can be considered as numeric\n *\n * Examples:\n * ```js\n * const { isNumerial } from '@splunk/react-visualizations/utils/numberUtils';\n * assert.equal(isNumerial('11.123') == 11.123);\n * ```\n * @param {any} value input value\n * @return {Boolean}\n * @public\n */\nexport function isNumerial(value) {\n return isFinite(value) || (isString(value) && isNumerialStr(value));\n}\n\n/**\n * Parse input value into number, return NaN for not numercial value\n * @param {*} value input value\n * @return {Number}\n * @public\n */\nexport function parseNumber(value) {\n if (isFinite(value) || (isString(value) && isDecimalOrExpo(value))) {\n // only parses the value consider as numeric.\n return parseFloat(value);\n }\n if (isString(value) && isCommaSeparatedNumber(value)) {\n return parseFloat(value.replace(/,/g, ''));\n }\n return NaN;\n}\n\n/**\n * Returns whether a string starts with a number.\n * @param {string} value\n * @returns boolean\n */\nexport function startsWithNumber(value) {\n return STARTS_WITH_NUMBER_REGEX.test(value);\n}\n\n/**\n *\n */\nconst getThousandSeparatorDecimalPrecisionFormatter = memoize(\n (locale = 'en', options = {}) => new Intl.NumberFormat(locale, options),\n (locale, options) => `${locale}${JSON.stringify(options)}`\n);\n\n/**\n- * Format number into string with precision and/or grouping\n- *\n- * Examples:\n- * ```js\n- * const { formatNumber } from '@splunk/react-visualizations/utils/numberUtils';\n- * assert.equal(formatNumber('1100’, 2, { useThousandSeparators: true }), '1,100.00’)\n- * ```\n- * @param {Number} number // value to format\n- * @param {Number} [precision] // number of digits after the decimal point\n- * @param {Object} [options]\n- * @param {Boolean} [options.useThousandSeparators=false] // flag to determine if grouping is desired\n- * @param {Object} [options.locale=moment.locale()] // Locale of the user for determinining how numbers are grouped\n- * @param {Number} [options.defaultPrecision=0] // The default precision to use if none is defined\n- * @param {Number} [options.useTrendUnits=false] // Add K, M, B, T to end of value, and divide by the appropriate order of magnitude\n- * @return {String}\n- * @public\n- */\nexport function formatNumber(number, precision, options = {}) {\n const formatOptions = {};\n\n // Precision is optional, so check if precision is an object, and use it as the options, otherwise load from options\n const {\n useThousandSeparators = false,\n locale = moment.locale(),\n defaultPrecision = 0,\n useTrendUnits = false,\n } = precision && typeof precision === 'object' ? precision : options;\n\n // Apply precision only when it is a positive integer\n if (isInteger(precision) && precision >= 0) {\n // Validate precision is within acceptable bounds\n const p = precision > 20 ? 20 : precision;\n\n formatOptions.minimumFractionDigits = p;\n formatOptions.maximumFractionDigits = p;\n } else {\n formatOptions.maximumFractionDigits = defaultPrecision;\n }\n\n formatOptions.useGrouping = useThousandSeparators === true;\n\n let trendUnit = '';\n let value = number;\n const units = [\n { letter: 'T', power: 12 },\n { letter: 'B', power: 9 },\n { letter: 'M', power: 6 },\n { letter: 'K', power: 3 },\n ];\n\n if (useTrendUnits) {\n const found = units.find(unit => Math.abs(value) > 10 ** unit.power);\n\n if (found) {\n value /= 10 ** found.power;\n trendUnit = found.letter;\n formatOptions.maximumFractionDigits = 2;\n formatOptions.minimumFractionDigits = 0;\n }\n }\n\n const formatter = getThousandSeparatorDecimalPrecisionFormatter(locale, formatOptions);\n\n return `${formatter.format(value)}${trendUnit ? _(trendUnit) : ''}`;\n}\n","module.exports = require(\"@splunk/ui-utils/i18n\");"],"sourceRoot":""}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/numberUtils.js", "esm-externals:@splunk/moment", "esm-externals:lodash", "esm-externals:@splunk/ui-utils/i18n"],
|
|
4
|
+
"sourcesContent": ["import moment from '@splunk/moment';\nimport { isFinite, isString, isInteger, memoize } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\n\n// Todo: need break out this utils after breaking out all visualizations\n/**\n * @file\n * A set of number formatting function used in Table\n */\nconst DECIMAL_OR_SCIENTIFIC_REGEX = /(^[-+]?[0-9]*[.]?[0-9]*$)|(^[-+]?[0-9][.]?[0-9]*e[-+]?[0-9][0-9]*$)/i;\nconst COMMA_SEPARATED_NUMBER_REGEX = /(^[-+]?([0]|([1-9][0-9]{0,2})|(([1-9][0-9]{0,2}[,])([0-9]{3}[,])*[0-9]{3}))(([.][0-9]+)?)$)/;\nconst STARTS_WITH_NUMBER_REGEX = /^[-+]?\\d/;\nfunction isDecimalOrExpo(str) {\n return DECIMAL_OR_SCIENTIFIC_REGEX.test(str);\n}\nfunction isCommaSeparatedNumber(str) {\n return COMMA_SEPARATED_NUMBER_REGEX.test(str);\n}\n\n/**\n * Check if a string can be considered as numeric, this includes decimal, scientific number and number with comma separator\n *\n * Examples:\n * ```js\n * const { isNumerialStr } from '@splunk/react-visualizations/utils/numberUtils';\n * assert.ok(isNumerialStr('11.123'));\n * ```\n * @param {String} str input value\n * @return {Boolean}\n * @public\n */\nexport function isNumerialStr(str) {\n return isDecimalOrExpo(str) || isCommaSeparatedNumber(str);\n}\n\n/**\n * Check if a value can be considered as numeric\n *\n * Examples:\n * ```js\n * const { isNumerial } from '@splunk/react-visualizations/utils/numberUtils';\n * assert.equal(isNumerial('11.123') == 11.123);\n * ```\n * @param {any} value input value\n * @return {Boolean}\n * @public\n */\nexport function isNumerial(value) {\n return isFinite(value) || (isString(value) && isNumerialStr(value));\n}\n\n/**\n * Parse input value into number, return NaN for not numercial value\n * @param {*} value input value\n * @return {Number}\n * @public\n */\nexport function parseNumber(value) {\n if (isFinite(value) || (isString(value) && isDecimalOrExpo(value))) {\n // only parses the value consider as numeric.\n return parseFloat(value);\n }\n if (isString(value) && isCommaSeparatedNumber(value)) {\n return parseFloat(value.replace(/,/g, ''));\n }\n return NaN;\n}\n\n/**\n * Returns whether a string starts with a number.\n * @param {string} value\n * @returns boolean\n */\nexport function startsWithNumber(value) {\n return STARTS_WITH_NUMBER_REGEX.test(value);\n}\n\n/**\n *\n */\nconst getThousandSeparatorDecimalPrecisionFormatter = memoize(\n (locale = 'en', options = {}) => new Intl.NumberFormat(locale, options),\n (locale, options) => `${locale}${JSON.stringify(options)}`\n);\n\n/**\n- * Format number into string with precision and/or grouping\n- *\n- * Examples:\n- * ```js\n- * const { formatNumber } from '@splunk/react-visualizations/utils/numberUtils';\n- * assert.equal(formatNumber('1100\u2019, 2, { useThousandSeparators: true }), '1,100.00\u2019)\n- * ```\n- * @param {Number} number // value to format\n- * @param {Number} [precision] // number of digits after the decimal point\n- * @param {Object} [options]\n- * @param {Boolean} [options.useThousandSeparators=false] // flag to determine if grouping is desired\n- * @param {Object} [options.locale=moment.locale()] // Locale of the user for determinining how numbers are grouped\n- * @param {Number} [options.defaultPrecision=0] // The default precision to use if none is defined\n- * @param {Number} [options.useTrendUnits=false] // Add K, M, B, T to end of value, and divide by the appropriate order of magnitude\n- * @return {String}\n- * @public\n- */\nexport function formatNumber(number, precision, options = {}) {\n const formatOptions = {};\n\n // Precision is optional, so check if precision is an object, and use it as the options, otherwise load from options\n const {\n useThousandSeparators = false,\n locale = moment.locale(),\n defaultPrecision = 0,\n useTrendUnits = false,\n } = precision && typeof precision === 'object' ? precision : options;\n\n // Apply precision only when it is a positive integer\n if (isInteger(precision) && precision >= 0) {\n // Validate precision is within acceptable bounds\n const p = precision > 20 ? 20 : precision;\n\n formatOptions.minimumFractionDigits = p;\n formatOptions.maximumFractionDigits = p;\n } else {\n formatOptions.maximumFractionDigits = defaultPrecision;\n }\n\n formatOptions.useGrouping = useThousandSeparators === true;\n\n let trendUnit = '';\n let value = number;\n const units = [\n { letter: 'T', power: 12 },\n { letter: 'B', power: 9 },\n { letter: 'M', power: 6 },\n { letter: 'K', power: 3 },\n ];\n\n if (useTrendUnits) {\n const found = units.find(unit => Math.abs(value) > 10 ** unit.power);\n\n if (found) {\n value /= 10 ** found.power;\n trendUnit = found.letter;\n formatOptions.maximumFractionDigits = 2;\n formatOptions.minimumFractionDigits = 0;\n }\n }\n\n const formatter = getThousandSeparatorDecimalPrecisionFormatter(locale, formatOptions);\n\n return `${formatter.format(value)}${trendUnit ? _(trendUnit) : ''}`;\n}\n", "\nimport * as defaultImport from \"@splunk/moment\";\nexport * from \"@splunk/moment\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/ui-utils/i18n\";\nexport * from \"@splunk/ui-utils/i18n\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,yBAAc;AACd,IAAO,eAAS,aAAaA,iBAA8B,yBAAUA;;;AHMrE,IAAM,8BAA8B;AACpC,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,SAAS,gBAAgB,KAAK;AAC1B,SAAO,4BAA4B,KAAK,GAAG;AAC/C;AACA,SAAS,uBAAuB,KAAK;AACjC,SAAO,6BAA6B,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AAG;AAAA,IACzB,EAAE,QAAQ,KAAK,OAAO,EAAE;AAAA,IACxB,EAAE,QAAQ,KAAK,OAAO,EAAE;AAAA,IACxB,EAAE,QAAQ,KAAK,OAAO,EAAE;AAAA,EAC5B;AAEA,MAAI,eAAe;AACf,UAAM,QAAQ,MAAM,KAAK,UAAQ,KAAK,IAAI,KAAK,IAAI,UAAM,KAAK,MAAK;AAEnE,QAAI,OAAO;AACP,eAAS,UAAM,MAAM;AACrB,kBAAY,MAAM;AAClB,oBAAc,wBAAwB;AACtC,oBAAc,wBAAwB;AAAA,IAC1C;AAAA,EACJ;AAEA,QAAM,YAAY,8CAA8C,QAAQ,aAAa;AAErF,SAAO,GAAG,UAAU,OAAO,KAAK,CAAC,GAAG,gBAAY,gBAAE,SAAS,IAAI,EAAE;AACrE;",
|
|
6
|
+
"names": ["defaultImport", "defaultImport"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
"description": "Visualizations Shared Files",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"author": "Splunk",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "27.1.0",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"build-storybook": "
|
|
10
|
-
"clean": "yarn clean:storybook && yarn clean:
|
|
8
|
+
"build": "viz-build --no-types",
|
|
9
|
+
"build-storybook": "sb build -c .storybook -o .storybook-bundle",
|
|
10
|
+
"clean": "yarn clean:storybook && yarn clean:esbuild && yarn clean:test-reports",
|
|
11
11
|
"clean:storybook": "rm -rf .storybook-bundle",
|
|
12
|
-
"clean:
|
|
12
|
+
"clean:esbuild": "git ls-files --others -i --exclude-standard *.js *.map | xargs rm",
|
|
13
13
|
"clean:test-reports": "rm -rf ./test-reports",
|
|
14
|
-
"dev": "
|
|
15
|
-
"storybook": "
|
|
14
|
+
"dev": "viz-build --no-types --watch",
|
|
15
|
+
"storybook": "sb dev -p 9001 -c .storybook",
|
|
16
16
|
"lint": "eslint src --ext \".js,.jsx,.es,.ts,.tsx\"",
|
|
17
17
|
"lint:fix": "yarn run lint --fix",
|
|
18
18
|
"test": "yarn run test:unit && yarn run test:integration",
|
|
@@ -26,14 +26,13 @@
|
|
|
26
26
|
"test:visual:update": "yarn loki approve"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.25.9",
|
|
30
29
|
"@splunk/moment": "^0.6.1",
|
|
31
30
|
"@splunk/react-icons": "^4.8.0",
|
|
32
|
-
"@splunk/react-ui": "^4.
|
|
31
|
+
"@splunk/react-ui": "^4.41.0",
|
|
33
32
|
"@splunk/themes": "^0.22.0",
|
|
34
33
|
"@splunk/ui-utils": "^1.7.1",
|
|
35
|
-
"@splunk/visualization-encoding": "^
|
|
36
|
-
"@splunk/visualization-schemas": "^
|
|
34
|
+
"@splunk/visualization-encoding": "^27.1.0",
|
|
35
|
+
"@splunk/visualization-schemas": "^27.1.0",
|
|
37
36
|
"element-resize-detector": "^1.2.4",
|
|
38
37
|
"lodash": "^4.17.21",
|
|
39
38
|
"numeral": "^2.0.6",
|
|
@@ -45,20 +44,17 @@
|
|
|
45
44
|
"styled-components": "^5.3.10"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@storybook/
|
|
54
|
-
"@storybook/addons": "^6.4.0",
|
|
55
|
-
"@storybook/react": "^6.5.16",
|
|
47
|
+
"@splunk/visualization-build-tools": "^27.1.0",
|
|
48
|
+
"@splunk/visualization-context": "^27.1.0",
|
|
49
|
+
"@storybook/addon-actions": "^7.6.20",
|
|
50
|
+
"@storybook/addons": "^7.6.20",
|
|
51
|
+
"@storybook/react": "^7.6.20",
|
|
52
|
+
"@storybook/react-webpack5": "^7.6.20",
|
|
56
53
|
"ajv": "^6.12.6",
|
|
54
|
+
"loki": "^0.35.1",
|
|
57
55
|
"react": "^16.13.1",
|
|
58
56
|
"react-dom": "^16.13.1",
|
|
59
57
|
"styled-components": "^5.3.10",
|
|
60
|
-
"text-encoding": "^0.7.0"
|
|
61
|
-
"webpack": "^4.29.6",
|
|
62
|
-
"webpack-merge": "^4.2.1"
|
|
58
|
+
"text-encoding": "^0.7.0"
|
|
63
59
|
}
|
|
64
60
|
}
|