@panneau/display-unit 3.0.130
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/es/index.js +55 -0
- package/lib/index.js +59 -0
- package/package.json +60 -0
package/es/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import prettyBytes from 'pretty-bytes';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { formatDuration } from '@panneau/core/utils';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
7
|
+
var propTypes = {
|
|
8
|
+
format: PropTypes.string,
|
|
9
|
+
suffix: PropTypes.string,
|
|
10
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
11
|
+
};
|
|
12
|
+
var defaultProps = {
|
|
13
|
+
format: null,
|
|
14
|
+
suffix: null,
|
|
15
|
+
value: null
|
|
16
|
+
};
|
|
17
|
+
var Unit = function Unit(_ref) {
|
|
18
|
+
var format = _ref.format,
|
|
19
|
+
value = _ref.value,
|
|
20
|
+
suffix = _ref.suffix;
|
|
21
|
+
var finalValue = useMemo(function () {
|
|
22
|
+
if (value === null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (format === 'bytes') {
|
|
26
|
+
return prettyBytes(parseInt(value, 10));
|
|
27
|
+
}
|
|
28
|
+
if (format === 'dimensions') {
|
|
29
|
+
var _ref2 = value || {},
|
|
30
|
+
_ref2$width = _ref2.width,
|
|
31
|
+
width = _ref2$width === void 0 ? null : _ref2$width,
|
|
32
|
+
_ref2$height = _ref2.height,
|
|
33
|
+
height = _ref2$height === void 0 ? null : _ref2$height,
|
|
34
|
+
_ref2$depth = _ref2.depth,
|
|
35
|
+
depth = _ref2$depth === void 0 ? null : _ref2$depth;
|
|
36
|
+
var finalWidth = width !== null && width > 0 ? width : null;
|
|
37
|
+
var finalHeight = height !== null && height > 0 ? height : null;
|
|
38
|
+
var finalDepth = depth !== null && depth > 0 ? depth : null;
|
|
39
|
+
var finalSuffix = suffix !== null ? suffix : '';
|
|
40
|
+
return "".concat(finalWidth !== null ? "".concat(finalWidth).concat(finalSuffix) : '').concat(finalHeight !== null ? " x ".concat(finalHeight).concat(finalSuffix) : '').concat(finalDepth !== null ? " x ".concat(finalDepth).concat(finalSuffix) : '');
|
|
41
|
+
}
|
|
42
|
+
if (format === 'duration') {
|
|
43
|
+
return formatDuration(value);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}, [value]);
|
|
47
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
48
|
+
className: "text-nowrap"
|
|
49
|
+
}, finalValue);
|
|
50
|
+
};
|
|
51
|
+
Unit.propTypes = propTypes;
|
|
52
|
+
Unit.defaultProps = defaultProps;
|
|
53
|
+
var Unit$1 = Unit;
|
|
54
|
+
|
|
55
|
+
export { Unit$1 as default };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var prettyBytes = require('pretty-bytes');
|
|
6
|
+
var PropTypes = require('prop-types');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var utils = require('@panneau/core/utils');
|
|
9
|
+
|
|
10
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
11
|
+
var propTypes = {
|
|
12
|
+
format: PropTypes.string,
|
|
13
|
+
suffix: PropTypes.string,
|
|
14
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
15
|
+
};
|
|
16
|
+
var defaultProps = {
|
|
17
|
+
format: null,
|
|
18
|
+
suffix: null,
|
|
19
|
+
value: null
|
|
20
|
+
};
|
|
21
|
+
var Unit = function Unit(_ref) {
|
|
22
|
+
var format = _ref.format,
|
|
23
|
+
value = _ref.value,
|
|
24
|
+
suffix = _ref.suffix;
|
|
25
|
+
var finalValue = React.useMemo(function () {
|
|
26
|
+
if (value === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (format === 'bytes') {
|
|
30
|
+
return prettyBytes(parseInt(value, 10));
|
|
31
|
+
}
|
|
32
|
+
if (format === 'dimensions') {
|
|
33
|
+
var _ref2 = value || {},
|
|
34
|
+
_ref2$width = _ref2.width,
|
|
35
|
+
width = _ref2$width === void 0 ? null : _ref2$width,
|
|
36
|
+
_ref2$height = _ref2.height,
|
|
37
|
+
height = _ref2$height === void 0 ? null : _ref2$height,
|
|
38
|
+
_ref2$depth = _ref2.depth,
|
|
39
|
+
depth = _ref2$depth === void 0 ? null : _ref2$depth;
|
|
40
|
+
var finalWidth = width !== null && width > 0 ? width : null;
|
|
41
|
+
var finalHeight = height !== null && height > 0 ? height : null;
|
|
42
|
+
var finalDepth = depth !== null && depth > 0 ? depth : null;
|
|
43
|
+
var finalSuffix = suffix !== null ? suffix : '';
|
|
44
|
+
return "".concat(finalWidth !== null ? "".concat(finalWidth).concat(finalSuffix) : '').concat(finalHeight !== null ? " x ".concat(finalHeight).concat(finalSuffix) : '').concat(finalDepth !== null ? " x ".concat(finalDepth).concat(finalSuffix) : '');
|
|
45
|
+
}
|
|
46
|
+
if (format === 'duration') {
|
|
47
|
+
return utils.formatDuration(value);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}, [value]);
|
|
51
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "text-nowrap"
|
|
53
|
+
}, finalValue);
|
|
54
|
+
};
|
|
55
|
+
Unit.propTypes = propTypes;
|
|
56
|
+
Unit.defaultProps = defaultProps;
|
|
57
|
+
var Unit$1 = Unit;
|
|
58
|
+
|
|
59
|
+
exports.default = Unit$1;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@panneau/display-unit",
|
|
3
|
+
"version": "3.0.130",
|
|
4
|
+
"description": "Unit display",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"javascript"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/folkloreinc/panneau-js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/folkloreinc/panneau-js.git"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Folklore",
|
|
15
|
+
"email": "info@folklore.email"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [
|
|
18
|
+
{
|
|
19
|
+
"name": "David Mongeau-Petitpas",
|
|
20
|
+
"email": "dmp@folklore.email"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Nicolas Roy-Bourdages",
|
|
24
|
+
"email": "nrb@folklore.email"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"main": "lib/index.js",
|
|
29
|
+
"module": "es/index.js",
|
|
30
|
+
"files": [
|
|
31
|
+
"lib",
|
|
32
|
+
"es",
|
|
33
|
+
"assets"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"build": "../../scripts/prepare-package.sh"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
41
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
45
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@babel/runtime": "^7.12.5",
|
|
49
|
+
"@panneau/core": "^3.0.130",
|
|
50
|
+
"@panneau/themes": "^3.0.130",
|
|
51
|
+
"lodash": "^4.17.21",
|
|
52
|
+
"pretty-bytes": "^6.1.1",
|
|
53
|
+
"prop-types": "^15.7.2",
|
|
54
|
+
"react-intl": "^5.15.8||^6.0.0"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "e6070daacb45351ccbef67ae8006f1a293ca8e2b"
|
|
60
|
+
}
|