@pareto-engineering/design-system 0.0.1-alpha.67 → 0.0.1-alpha.70
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/config/global-setup.js +3 -0
- package/dist/cjs/a/Timestamp/Timestamp.js +139 -0
- package/dist/cjs/a/{RatingsInput/common/Rating → Timestamp}/index.js +3 -3
- package/dist/cjs/a/Timestamp/styles.scss +7 -0
- package/dist/cjs/a/index.js +9 -1
- package/dist/cjs/f/FormInput/FormInput.js +109 -0
- package/dist/cjs/{a/RatingsInput → f/FormInput}/index.js +3 -3
- package/dist/cjs/f/common/Label/Label.js +10 -3
- package/dist/cjs/f/common/Label/styles.scss +3 -3
- package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +3 -1
- package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +32 -11
- package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +10 -3
- package/dist/cjs/f/fields/ChoicesInput/styles.scss +32 -29
- package/dist/cjs/f/fields/RadioInput/RadioInput.js +3 -1
- package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +3 -1
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +15 -5
- package/dist/cjs/{a/RatingsInput/common/Rating/Rating.js → f/fields/TaskRecommendationInput/TaskRecommendationInput.js} +57 -46
- package/dist/cjs/f/fields/TaskRecommendationInput/index.js +15 -0
- package/{src/ui/f/fields/TaskRecommendation → dist/cjs/f/fields/TaskRecommendationInput}/styles.scss +1 -1
- package/dist/cjs/f/fields/TextInput/TextInput.js +15 -5
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +151 -0
- package/dist/cjs/f/fields/TextareaInput/index.js +15 -0
- package/{src/ui/f/fields/TextArea → dist/cjs/f/fields/TextareaInput}/styles.scss +1 -1
- package/dist/cjs/f/fields/index.js +6 -6
- package/dist/cjs/f/index.js +14 -1
- package/dist/es/a/Timestamp/Timestamp.js +122 -0
- package/dist/es/a/Timestamp/index.js +2 -0
- package/dist/es/a/Timestamp/styles.scss +7 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/f/FormInput/FormInput.js +84 -0
- package/dist/es/f/FormInput/index.js +2 -0
- package/dist/es/f/common/Label/Label.js +10 -3
- package/dist/es/f/common/Label/styles.scss +3 -3
- package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +2 -2
- package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +32 -13
- package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +10 -3
- package/dist/es/f/fields/ChoicesInput/styles.scss +32 -29
- package/dist/es/f/fields/RadioInput/RadioInput.js +2 -2
- package/dist/es/f/fields/RatingsInput/RatingsInput.js +2 -2
- package/dist/es/f/fields/SelectInput/SelectInput.js +14 -6
- package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +111 -0
- package/dist/es/f/fields/TaskRecommendationInput/index.js +2 -0
- package/dist/es/f/fields/TaskRecommendationInput/styles.scss +37 -0
- package/dist/es/f/fields/TextInput/TextInput.js +14 -6
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +132 -0
- package/dist/es/f/fields/TextareaInput/index.js +2 -0
- package/dist/es/f/fields/TextareaInput/styles.scss +19 -0
- package/dist/es/f/fields/index.js +2 -2
- package/dist/es/f/index.js +2 -1
- package/jest.config.js +2 -1
- package/package.json +1 -1
- package/src/__snapshots__/Storyshots.test.js.snap +1204 -383
- package/src/stories/a/Timestamp.stories.jsx +102 -0
- package/src/stories/f/ChoicesInput.stories.jsx +54 -6
- package/src/stories/f/FormInput.stories.jsx +187 -0
- package/src/stories/f/SelectInput.stories.jsx +14 -0
- package/src/stories/f/{TaskRecommendation.stories.jsx → TaskRecommendationInput.stories.jsx} +4 -4
- package/src/stories/f/TextInput.stories.jsx +10 -0
- package/src/stories/f/{TextArea.stories.jsx → TextareaInput.stories.jsx} +15 -5
- package/src/ui/a/Timestamp/Timestamp.jsx +168 -0
- package/src/ui/a/Timestamp/index.js +2 -0
- package/src/ui/a/Timestamp/styles.scss +7 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/f/FormInput/FormInput.jsx +121 -0
- package/src/ui/f/FormInput/index.js +2 -0
- package/src/ui/f/common/Label/Label.jsx +10 -2
- package/src/ui/f/common/Label/styles.scss +3 -3
- package/src/ui/f/fields/CheckboxInput/CheckboxInput.jsx +2 -2
- package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +37 -17
- package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +6 -0
- package/src/ui/f/fields/ChoicesInput/styles.scss +32 -29
- package/src/ui/f/fields/RadioInput/RadioInput.jsx +2 -2
- package/src/ui/f/fields/RatingsInput/RatingsInput.jsx +2 -2
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +9 -4
- package/src/ui/f/fields/{TaskRecommendation/TaskRecommendation.jsx → TaskRecommendationInput/TaskRecommendationInput.jsx} +6 -6
- package/src/ui/f/fields/TaskRecommendationInput/index.js +2 -0
- package/src/ui/f/fields/TaskRecommendationInput/styles.scss +37 -0
- package/src/ui/f/fields/TextInput/TextInput.jsx +10 -3
- package/src/ui/f/fields/{TextArea/TextArea.jsx → TextareaInput/TextareaInput.jsx} +13 -6
- package/src/ui/f/fields/TextareaInput/index.js +2 -0
- package/src/ui/f/fields/TextareaInput/styles.scss +19 -0
- package/src/ui/f/fields/index.js +2 -2
- package/src/ui/f/index.js +1 -0
- package/dist/cjs/a/RatingsInput/RatingsInput.js +0 -88
- package/dist/cjs/a/RatingsInput/common/index.js +0 -13
- package/dist/cjs/a/RatingsInput/styles.scss +0 -35
- package/dist/es/a/RatingsInput/RatingsInput.js +0 -72
- package/dist/es/a/RatingsInput/common/Rating/Rating.js +0 -102
- package/dist/es/a/RatingsInput/common/Rating/index.js +0 -2
- package/dist/es/a/RatingsInput/common/index.js +0 -1
- package/dist/es/a/RatingsInput/index.js +0 -2
- package/dist/es/a/RatingsInput/styles.scss +0 -35
- package/src/ui/f/fields/TaskRecommendation/index.js +0 -2
- package/src/ui/f/fields/TextArea/index.js +0 -2
|
@@ -13,55 +13,70 @@ var _formik = require("formik");
|
|
|
13
13
|
|
|
14
14
|
var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
|
|
15
15
|
|
|
16
|
+
var _common = require("../../common");
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
20
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
+
|
|
18
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
23
|
|
|
20
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
25
|
|
|
22
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
-
|
|
24
26
|
// Local Definitions
|
|
25
27
|
var baseClassName = _bem.default.base;
|
|
26
|
-
var componentClassName = '
|
|
28
|
+
var componentClassName = 'task-recommendation-input';
|
|
27
29
|
/**
|
|
28
30
|
* This is the component description.
|
|
29
31
|
*/
|
|
30
32
|
|
|
31
|
-
var
|
|
33
|
+
var TaskRecommendationInput = _ref => {
|
|
34
|
+
var _field$value;
|
|
35
|
+
|
|
32
36
|
var {
|
|
33
37
|
id,
|
|
34
38
|
className: userClassName,
|
|
35
39
|
style,
|
|
36
|
-
value,
|
|
37
40
|
name,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
value,
|
|
42
|
+
oneLiner,
|
|
43
|
+
label,
|
|
44
|
+
color,
|
|
45
|
+
image // ...otherProps
|
|
43
46
|
|
|
44
47
|
} = _ref;
|
|
48
|
+
(0, React.useLayoutEffect)(() => {
|
|
49
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
50
|
+
}, []);
|
|
45
51
|
var [field] = (0, _formik.useField)(name);
|
|
52
|
+
var isOptionSelected = !!(((_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.length) > 0 && field.value.includes(value));
|
|
46
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
54
|
id: id,
|
|
48
|
-
className: [baseClassName, componentClassName, userClassName, "x-".concat(
|
|
49
|
-
style: style
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
className: [baseClassName, componentClassName, userClassName, "x-".concat(color)].filter(e => e).join(' '),
|
|
56
|
+
style: style // {...otherProps}
|
|
57
|
+
|
|
58
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "task-content ".concat(isOptionSelected ? 'b-x' : 'b-on-x')
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: "v1 p-v task"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(_common.FormLabel, {
|
|
63
|
+
className: "uc mb-v ".concat(isOptionSelected ? 'c-on-x' : 'c-x'),
|
|
64
|
+
name: name
|
|
65
|
+
}, label), /*#__PURE__*/React.createElement("input", _extends({}, field, {
|
|
66
|
+
value: value,
|
|
67
|
+
id: name,
|
|
68
|
+
className: "input",
|
|
69
|
+
type: "checkbox"
|
|
70
|
+
})), /*#__PURE__*/React.createElement("img", {
|
|
71
|
+
className: "image",
|
|
72
|
+
src: image,
|
|
73
|
+
alt: "img"
|
|
74
|
+
}), /*#__PURE__*/React.createElement("p", {
|
|
75
|
+
className: ['uc u2 mt-u', isOptionSelected && 'c-on-x'].filter(e => e).join(' ')
|
|
76
|
+
}, oneLiner))));
|
|
62
77
|
};
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
TaskRecommendationInput.propTypes = {
|
|
65
80
|
/**
|
|
66
81
|
* The HTML id for this element
|
|
67
82
|
*/
|
|
@@ -78,43 +93,39 @@ Rating.propTypes = {
|
|
|
78
93
|
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
79
94
|
|
|
80
95
|
/**
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
value: _propTypes.default.number,
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The current hover value
|
|
96
|
+
* The name of the input
|
|
87
97
|
*/
|
|
88
|
-
|
|
98
|
+
name: _propTypes.default.string.isRequired,
|
|
89
99
|
|
|
90
100
|
/**
|
|
91
|
-
*
|
|
101
|
+
* The value of the input
|
|
92
102
|
*/
|
|
93
|
-
|
|
103
|
+
value: _propTypes.default.string.isRequired,
|
|
94
104
|
|
|
95
105
|
/**
|
|
96
|
-
*
|
|
106
|
+
* The task one liner description
|
|
97
107
|
*/
|
|
98
|
-
|
|
108
|
+
oneLiner: _propTypes.default.string.isRequired,
|
|
99
109
|
|
|
100
110
|
/**
|
|
101
|
-
*
|
|
111
|
+
* The task label
|
|
102
112
|
*/
|
|
103
|
-
|
|
113
|
+
label: _propTypes.default.string.isRequired,
|
|
104
114
|
|
|
105
115
|
/**
|
|
106
|
-
*
|
|
116
|
+
* The color
|
|
107
117
|
*/
|
|
108
|
-
|
|
118
|
+
color: _propTypes.default.string,
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
|
-
*
|
|
121
|
+
* Task image
|
|
112
122
|
*/
|
|
113
|
-
|
|
123
|
+
image: _propTypes.default.string.isRequired
|
|
114
124
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
inactiveBackgroundColor: 'background'
|
|
125
|
+
TaskRecommendationInput.defaultProps = {
|
|
126
|
+
color: 'main2'
|
|
118
127
|
};
|
|
119
|
-
|
|
128
|
+
|
|
129
|
+
var _default = /*#__PURE__*/(0, React.memo)(TaskRecommendationInput);
|
|
130
|
+
|
|
120
131
|
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TaskRecommendationInput", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _TaskRecommendationInput.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _TaskRecommendationInput = _interopRequireDefault(require("./TaskRecommendationInput"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -40,7 +40,8 @@ var TextInput = _ref => {
|
|
|
40
40
|
label,
|
|
41
41
|
validate,
|
|
42
42
|
oneInputLabel,
|
|
43
|
-
description
|
|
43
|
+
description,
|
|
44
|
+
disabled // ...otherProps
|
|
44
45
|
|
|
45
46
|
} = _ref;
|
|
46
47
|
(0, React.useLayoutEffect)(() => {
|
|
@@ -61,7 +62,8 @@ var TextInput = _ref => {
|
|
|
61
62
|
}, label), /*#__PURE__*/React.createElement("input", _extends({
|
|
62
63
|
id: name,
|
|
63
64
|
className: "input ".concat(meta.touched && meta.error ? 'input-border-error' : 'input-border'),
|
|
64
|
-
type: type
|
|
65
|
+
type: type,
|
|
66
|
+
disabled: disabled
|
|
65
67
|
}, field)), (description || meta.touched && meta.error) && /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
66
68
|
isError: !!meta.error,
|
|
67
69
|
className: "v50 mt-v s-1"
|
|
@@ -112,10 +114,18 @@ TextInput.propTypes = {
|
|
|
112
114
|
/**
|
|
113
115
|
* Input description
|
|
114
116
|
*/
|
|
115
|
-
description: _propTypes.default.string
|
|
117
|
+
description: _propTypes.default.string,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether the text input should be disabled
|
|
121
|
+
*/
|
|
122
|
+
disabled: _propTypes.default.bool
|
|
116
123
|
};
|
|
117
124
|
TextInput.defaultProps = {
|
|
118
|
-
type: 'text'
|
|
125
|
+
type: 'text',
|
|
126
|
+
disabled: false
|
|
119
127
|
};
|
|
120
|
-
|
|
128
|
+
|
|
129
|
+
var _default = /*#__PURE__*/(0, React.memo)(TextInput);
|
|
130
|
+
|
|
121
131
|
exports.default = _default;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
|
|
13
|
+
|
|
14
|
+
var _formik = require("formik");
|
|
15
|
+
|
|
16
|
+
var _common = require("../../common");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
var baseClassName = _bem.default.base;
|
|
27
|
+
var componentClassName = 'text-area-input';
|
|
28
|
+
/**
|
|
29
|
+
* This is the component description.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
var TextareaInput = _ref => {
|
|
33
|
+
var {
|
|
34
|
+
id,
|
|
35
|
+
className: userClassName,
|
|
36
|
+
style,
|
|
37
|
+
name,
|
|
38
|
+
label,
|
|
39
|
+
validate,
|
|
40
|
+
labelAsDescription,
|
|
41
|
+
textAreaId,
|
|
42
|
+
rows,
|
|
43
|
+
textAreaColor,
|
|
44
|
+
labelColor,
|
|
45
|
+
description,
|
|
46
|
+
disabled // ...otherProps
|
|
47
|
+
|
|
48
|
+
} = _ref;
|
|
49
|
+
(0, React.useLayoutEffect)(() => {
|
|
50
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
51
|
+
}, []);
|
|
52
|
+
var [field, meta] = (0, _formik.useField)({
|
|
53
|
+
name,
|
|
54
|
+
validate
|
|
55
|
+
});
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
id: id,
|
|
58
|
+
className: [baseClassName, componentClassName, userClassName, "x-".concat(textAreaColor), "y-".concat(labelColor)].filter(e => e).join(' '),
|
|
59
|
+
style: style // {...otherProps}
|
|
60
|
+
|
|
61
|
+
}, /*#__PURE__*/React.createElement(_common.FormLabel, {
|
|
62
|
+
className: ['c-y', labelAsDescription ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v'].filter(e => e).join(' '),
|
|
63
|
+
name: name
|
|
64
|
+
}, label), /*#__PURE__*/React.createElement("textarea", _extends({
|
|
65
|
+
id: textAreaId,
|
|
66
|
+
className: "textarea v50 pv-v ".concat(meta.touched && meta.error ? 'input-border-error' : 'input-border')
|
|
67
|
+
}, field, {
|
|
68
|
+
rows: rows,
|
|
69
|
+
disabled: disabled
|
|
70
|
+
})), (description || meta.touched && meta.error) && /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
71
|
+
isError: !!meta.error,
|
|
72
|
+
className: "v50 mt-v s-1"
|
|
73
|
+
}, meta.error || description), ' ');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
TextareaInput.propTypes = {
|
|
77
|
+
/**
|
|
78
|
+
* The HTML id for this element
|
|
79
|
+
*/
|
|
80
|
+
id: _propTypes.default.string,
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The HTML class names for this element
|
|
84
|
+
*/
|
|
85
|
+
className: _propTypes.default.string,
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The React-written, css properties for this element.
|
|
89
|
+
*/
|
|
90
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The input name (html - and Formik state)
|
|
94
|
+
*/
|
|
95
|
+
name: _propTypes.default.string.isRequired,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The input label
|
|
99
|
+
*/
|
|
100
|
+
label: _propTypes.default.string.isRequired,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The input value validator function
|
|
104
|
+
*/
|
|
105
|
+
validate: _propTypes.default.func,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* If the text area depends on it's label's text as the default description
|
|
109
|
+
*/
|
|
110
|
+
labelAsDescription: _propTypes.default.bool,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The textarea id
|
|
114
|
+
*/
|
|
115
|
+
textAreaId: _propTypes.default.string,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The number of rows int the text area
|
|
119
|
+
*/
|
|
120
|
+
rows: _propTypes.default.number,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Text area base color
|
|
124
|
+
*/
|
|
125
|
+
textAreaColor: _propTypes.default.string,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Label base color
|
|
129
|
+
*/
|
|
130
|
+
labelColor: _propTypes.default.string,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Text area description
|
|
134
|
+
*/
|
|
135
|
+
description: _propTypes.default.string,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether the text area should be disabled
|
|
139
|
+
*/
|
|
140
|
+
disabled: _propTypes.default.bool
|
|
141
|
+
};
|
|
142
|
+
TextareaInput.defaultProps = {
|
|
143
|
+
rows: 3,
|
|
144
|
+
textAreaColor: 'background',
|
|
145
|
+
labelColor: 'main1',
|
|
146
|
+
disabled: false
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
var _default = /*#__PURE__*/(0, React.memo)(TextareaInput);
|
|
150
|
+
|
|
151
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TextareaInput", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _TextareaInput.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _TextareaInput = _interopRequireDefault(require("./TextareaInput"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -27,10 +27,10 @@ Object.defineProperty(exports, "CheckboxInput", {
|
|
|
27
27
|
return _CheckboxInput.CheckboxInput;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "TaskRecommendationInput", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function get() {
|
|
33
|
-
return
|
|
33
|
+
return _TaskRecommendationInput.TaskRecommendationInput;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "ChoicesInput", {
|
|
@@ -39,10 +39,10 @@ Object.defineProperty(exports, "ChoicesInput", {
|
|
|
39
39
|
return _ChoicesInput.ChoicesInput;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "TextareaInput", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function get() {
|
|
45
|
-
return
|
|
45
|
+
return _TextareaInput.TextareaInput;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "RatingsInput", {
|
|
@@ -60,10 +60,10 @@ var _RadioInput = require("./RadioInput");
|
|
|
60
60
|
|
|
61
61
|
var _CheckboxInput = require("./CheckboxInput");
|
|
62
62
|
|
|
63
|
-
var
|
|
63
|
+
var _TaskRecommendationInput = require("./TaskRecommendationInput");
|
|
64
64
|
|
|
65
65
|
var _ChoicesInput = require("./ChoicesInput");
|
|
66
66
|
|
|
67
|
-
var
|
|
67
|
+
var _TextareaInput = require("./TextareaInput");
|
|
68
68
|
|
|
69
69
|
var _RatingsInput = require("./RatingsInput");
|
package/dist/cjs/f/index.js
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
FormInput: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "FormInput", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _FormInput.FormInput;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
6
15
|
|
|
7
16
|
var _common = require("./common");
|
|
8
17
|
|
|
9
18
|
Object.keys(_common).forEach(function (key) {
|
|
10
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
11
21
|
if (key in exports && exports[key] === _common[key]) return;
|
|
12
22
|
Object.defineProperty(exports, key, {
|
|
13
23
|
enumerable: true,
|
|
@@ -21,6 +31,7 @@ var _fields = require("./fields");
|
|
|
21
31
|
|
|
22
32
|
Object.keys(_fields).forEach(function (key) {
|
|
23
33
|
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
24
35
|
if (key in exports && exports[key] === _fields[key]) return;
|
|
25
36
|
Object.defineProperty(exports, key, {
|
|
26
37
|
enumerable: true,
|
|
@@ -28,4 +39,6 @@ Object.keys(_fields).forEach(function (key) {
|
|
|
28
39
|
return _fields[key];
|
|
29
40
|
}
|
|
30
41
|
});
|
|
31
|
-
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var _FormInput = require("./FormInput");
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useLayoutEffect, useMemo, useCallback, useState } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import styleNames from '@pareto-engineering/bem';
|
|
6
|
+
import { format, differenceInDays, formatDistance, formatRelative } from 'date-fns'; // Local Definitions
|
|
7
|
+
|
|
8
|
+
const baseClassName = styleNames.base;
|
|
9
|
+
const componentClassName = 'timestamp';
|
|
10
|
+
/**
|
|
11
|
+
* This is the component description.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Timestamp = ({
|
|
15
|
+
id,
|
|
16
|
+
className: userClassName,
|
|
17
|
+
style,
|
|
18
|
+
time,
|
|
19
|
+
prefix,
|
|
20
|
+
enabledFormats,
|
|
21
|
+
distanceMaxDays,
|
|
22
|
+
relativeMaxDays,
|
|
23
|
+
dateFormat,
|
|
24
|
+
locale,
|
|
25
|
+
// ...otherProps
|
|
26
|
+
as: Element
|
|
27
|
+
}) => {
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
import("./styles.scss");
|
|
30
|
+
}, []);
|
|
31
|
+
const [currentDisplay, setCurrentDisplay] = useState(enabledFormats[0]);
|
|
32
|
+
const formatMap = useMemo(() => ({
|
|
33
|
+
unix: unix => Number(unix),
|
|
34
|
+
date: unix => format(new Date(unix), dateFormat),
|
|
35
|
+
distance: unix => !distanceMaxDays || differenceInDays(Date.now(), new Date(unix)) < distanceMaxDays ? formatDistance(new Date(unix), new Date(), {
|
|
36
|
+
addSuffix: true,
|
|
37
|
+
locale
|
|
38
|
+
}) : format(new Date(unix), dateFormat),
|
|
39
|
+
relative: unix => !relativeMaxDays || differenceInDays(Date.now(), new Date(unix)) < relativeMaxDays ? formatRelative(new Date(unix), new Date(), {
|
|
40
|
+
locale
|
|
41
|
+
}) : format(new Date(unix), dateFormat)
|
|
42
|
+
}), []);
|
|
43
|
+
const onClick = useCallback(e => {
|
|
44
|
+
e.persist(); // eslint-disable-next-line no-shadow
|
|
45
|
+
|
|
46
|
+
const currentIndex = enabledFormats.findIndex(e => e === currentDisplay);
|
|
47
|
+
const nextIndex = (currentIndex + 1) % enabledFormats.length;
|
|
48
|
+
setCurrentDisplay(enabledFormats[nextIndex]);
|
|
49
|
+
}, [currentDisplay]);
|
|
50
|
+
if (!Number(time)) return null;
|
|
51
|
+
return /*#__PURE__*/React.createElement(Element, {
|
|
52
|
+
id: id,
|
|
53
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
54
|
+
style: style // {...otherProps}
|
|
55
|
+
,
|
|
56
|
+
onClick: enabledFormats.length > 1 ? onClick : undefined
|
|
57
|
+
}, prefix && prefix, prefix && ' ', formatMap[currentDisplay](Number(time)));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
Timestamp.propTypes = {
|
|
61
|
+
/**
|
|
62
|
+
* The HTML id for this element
|
|
63
|
+
*/
|
|
64
|
+
id: PropTypes.string,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The HTML class names for this element
|
|
68
|
+
*/
|
|
69
|
+
className: PropTypes.string,
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The React-written, css properties for this element.
|
|
73
|
+
*/
|
|
74
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The children JSX
|
|
78
|
+
*/
|
|
79
|
+
prefix: PropTypes.node,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Which html tag to use
|
|
83
|
+
*/
|
|
84
|
+
as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Formats
|
|
88
|
+
*/
|
|
89
|
+
enabledFormats: PropTypes.arrayOf(PropTypes.oneOf(['unix', 'date', 'distance', 'relative'])),
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* How many days to display distance before reverting to unix display
|
|
93
|
+
*/
|
|
94
|
+
distanceMaxDays: PropTypes.number,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* How many days to display distance before reverting to unix display
|
|
98
|
+
*/
|
|
99
|
+
relativeMaxDays: PropTypes.number,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Unix Format Read https://date-fns.org/v2.16.1/docs/format for options
|
|
103
|
+
*/
|
|
104
|
+
dateFormat: PropTypes.string,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The time to display
|
|
108
|
+
*/
|
|
109
|
+
time: PropTypes.oneOfType([PropTypes.object, PropTypes.number]).isRequired,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A Date-DNS locale object. Will default to english.
|
|
113
|
+
*/
|
|
114
|
+
locale: PropTypes.instanceOf(Object)
|
|
115
|
+
};
|
|
116
|
+
Timestamp.defaultProps = {
|
|
117
|
+
// someProp:false
|
|
118
|
+
as: 'p',
|
|
119
|
+
dateFormat: 'yyyy-MM-dd\'T\'HH:mm:ss.SSSxxx',
|
|
120
|
+
enabledFormats: ['unix', 'date']
|
|
121
|
+
};
|
|
122
|
+
export default Timestamp;
|
package/dist/es/a/index.js
CHANGED
|
@@ -16,4 +16,5 @@ export { Conversation } from "./Conversation";
|
|
|
16
16
|
export { CustomerStat } from "./CustomerStat";
|
|
17
17
|
export { Quote } from "./Quote";
|
|
18
18
|
export { ContentCard } from "./ContentCard";
|
|
19
|
-
export { DotInfo } from "./DotInfo";
|
|
19
|
+
export { DotInfo } from "./DotInfo";
|
|
20
|
+
export { Timestamp } from "./Timestamp";
|