@panneau/display-text-description 3.0.133
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 +54 -0
- package/lib/index.js +58 -0
- package/package.json +59 -0
package/es/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import isObject from 'lodash/isObject';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
|
|
7
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
8
|
+
var propTypes = {
|
|
9
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
10
|
+
item: PropTypes.shape({
|
|
11
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
12
|
+
}),
|
|
13
|
+
descriptionPath: PropTypes.string,
|
|
14
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
15
|
+
descriptionValues: PropTypes.object,
|
|
16
|
+
locale: PropTypes.string
|
|
17
|
+
};
|
|
18
|
+
var defaultProps = {
|
|
19
|
+
value: null,
|
|
20
|
+
item: null,
|
|
21
|
+
descriptionPath: null,
|
|
22
|
+
descriptionValues: null,
|
|
23
|
+
locale: null
|
|
24
|
+
};
|
|
25
|
+
var TextDescription = function TextDescription(_ref) {
|
|
26
|
+
var initialValue = _ref.value,
|
|
27
|
+
parentLocale = _ref.locale,
|
|
28
|
+
item = _ref.item,
|
|
29
|
+
descriptionPath = _ref.descriptionPath,
|
|
30
|
+
descriptionValues = _ref.descriptionValues;
|
|
31
|
+
var _useIntl = useIntl(),
|
|
32
|
+
locale = _useIntl.locale;
|
|
33
|
+
var _useMemo = useMemo(function () {
|
|
34
|
+
var partialValue = initialValue !== null && isObject(initialValue) ? initialValue[parentLocale || locale] || null : initialValue;
|
|
35
|
+
var labelValue = get(item, descriptionPath);
|
|
36
|
+
var partialLabel = labelValue !== null && isObject(descriptionValues) ? descriptionValues[labelValue] || null : labelValue;
|
|
37
|
+
return {
|
|
38
|
+
value: partialValue,
|
|
39
|
+
label: partialLabel
|
|
40
|
+
};
|
|
41
|
+
}, [initialValue, descriptionPath, descriptionValues, item, locale, parentLocale]),
|
|
42
|
+
value = _useMemo.value,
|
|
43
|
+
label = _useMemo.label;
|
|
44
|
+
return label !== null ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", {
|
|
45
|
+
className: "d-block m-0 p-0"
|
|
46
|
+
}, value), /*#__PURE__*/React.createElement("p", {
|
|
47
|
+
className: "d-block m-0 p-0 text-secondary text-opacity-75 lh-sm"
|
|
48
|
+
}, /*#__PURE__*/React.createElement("small", null, label))) : /*#__PURE__*/React.createElement(React.Fragment, null, value);
|
|
49
|
+
};
|
|
50
|
+
TextDescription.propTypes = propTypes;
|
|
51
|
+
TextDescription.defaultProps = defaultProps;
|
|
52
|
+
var TextDescription$1 = TextDescription;
|
|
53
|
+
|
|
54
|
+
export { TextDescription$1 as default };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var get = require('lodash/get');
|
|
6
|
+
var isObject = require('lodash/isObject');
|
|
7
|
+
var PropTypes = require('prop-types');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactIntl = require('react-intl');
|
|
10
|
+
|
|
11
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
12
|
+
var propTypes = {
|
|
13
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
14
|
+
item: PropTypes.shape({
|
|
15
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
16
|
+
}),
|
|
17
|
+
descriptionPath: PropTypes.string,
|
|
18
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
19
|
+
descriptionValues: PropTypes.object,
|
|
20
|
+
locale: PropTypes.string
|
|
21
|
+
};
|
|
22
|
+
var defaultProps = {
|
|
23
|
+
value: null,
|
|
24
|
+
item: null,
|
|
25
|
+
descriptionPath: null,
|
|
26
|
+
descriptionValues: null,
|
|
27
|
+
locale: null
|
|
28
|
+
};
|
|
29
|
+
var TextDescription = function TextDescription(_ref) {
|
|
30
|
+
var initialValue = _ref.value,
|
|
31
|
+
parentLocale = _ref.locale,
|
|
32
|
+
item = _ref.item,
|
|
33
|
+
descriptionPath = _ref.descriptionPath,
|
|
34
|
+
descriptionValues = _ref.descriptionValues;
|
|
35
|
+
var _useIntl = reactIntl.useIntl(),
|
|
36
|
+
locale = _useIntl.locale;
|
|
37
|
+
var _useMemo = React.useMemo(function () {
|
|
38
|
+
var partialValue = initialValue !== null && isObject(initialValue) ? initialValue[parentLocale || locale] || null : initialValue;
|
|
39
|
+
var labelValue = get(item, descriptionPath);
|
|
40
|
+
var partialLabel = labelValue !== null && isObject(descriptionValues) ? descriptionValues[labelValue] || null : labelValue;
|
|
41
|
+
return {
|
|
42
|
+
value: partialValue,
|
|
43
|
+
label: partialLabel
|
|
44
|
+
};
|
|
45
|
+
}, [initialValue, descriptionPath, descriptionValues, item, locale, parentLocale]),
|
|
46
|
+
value = _useMemo.value,
|
|
47
|
+
label = _useMemo.label;
|
|
48
|
+
return label !== null ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", {
|
|
49
|
+
className: "d-block m-0 p-0"
|
|
50
|
+
}, value), /*#__PURE__*/React.createElement("p", {
|
|
51
|
+
className: "d-block m-0 p-0 text-secondary text-opacity-75 lh-sm"
|
|
52
|
+
}, /*#__PURE__*/React.createElement("small", null, label))) : /*#__PURE__*/React.createElement(React.Fragment, null, value);
|
|
53
|
+
};
|
|
54
|
+
TextDescription.propTypes = propTypes;
|
|
55
|
+
TextDescription.defaultProps = defaultProps;
|
|
56
|
+
var TextDescription$1 = TextDescription;
|
|
57
|
+
|
|
58
|
+
exports.default = TextDescription$1;
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@panneau/display-text-description",
|
|
3
|
+
"version": "3.0.133",
|
|
4
|
+
"description": "Text with description in list",
|
|
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.133",
|
|
50
|
+
"@panneau/themes": "^3.0.133",
|
|
51
|
+
"lodash": "^4.17.21",
|
|
52
|
+
"prop-types": "^15.7.2",
|
|
53
|
+
"react-intl": "^5.15.8||^6.0.0"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "75cf7713976a4b1c04991285984ab634f767b4e6"
|
|
59
|
+
}
|