@arcblock/ux 2.1.42 → 2.1.43
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/lib/Datatable/index.js +20 -16
- package/lib/RelativeTime/index.js +23 -11
- package/package.json +4 -4
- package/src/Datatable/index.js +20 -14
- package/src/RelativeTime/index.js +18 -6
package/lib/Datatable/index.js
CHANGED
|
@@ -56,6 +56,24 @@ function Datatable(_ref) {
|
|
|
56
56
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ReDatatable, _objectSpread({}, props))
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
const fixCellProp = (tempObj, cellProps) => {
|
|
61
|
+
const cellStyle = {};
|
|
62
|
+
|
|
63
|
+
if (tempObj.align) {
|
|
64
|
+
cellProps.className = (0, _clsx.default)(cellProps.className, "pc-align-".concat(tempObj.align));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (tempObj.verticalKeyAlign) {
|
|
68
|
+
cellProps.className = (0, _clsx.default)(cellProps.className, "vertical-align-".concat(tempObj.verticalKeyAlign));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (tempObj.minWidth) {
|
|
72
|
+
cellStyle.minWidth = tempObj.minWidth;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
cellProps.style = Object.assign({}, cellProps.style, cellStyle);
|
|
76
|
+
};
|
|
59
77
|
/**
|
|
60
78
|
* @param {Object} props.options The options of mui-datatable,detail see https://github.com/gregnb/mui-datatables/tree/b8d2eee6af4589d254b40918e5d7e70b1ee4baca
|
|
61
79
|
* @param {Array} props.customButtons Custom buttons for toolbar
|
|
@@ -147,14 +165,7 @@ function ReDatatable(_ref2) {
|
|
|
147
165
|
cellProps.width = tempObj.width;
|
|
148
166
|
}
|
|
149
167
|
|
|
150
|
-
|
|
151
|
-
cellProps.className = (0, _clsx.default)(cellProps.className, "pc-align-".concat(tempObj.align));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (tempObj.verticalKeyAlign) {
|
|
155
|
-
cellProps.className = (0, _clsx.default)(cellProps.className, "vertical-align-".concat(tempObj.verticalKeyAlign));
|
|
156
|
-
}
|
|
157
|
-
|
|
168
|
+
fixCellProp(tempObj, cellProps);
|
|
158
169
|
return cellProps;
|
|
159
170
|
}; // Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
|
|
160
171
|
|
|
@@ -171,14 +182,7 @@ function ReDatatable(_ref2) {
|
|
|
171
182
|
cellProps = _objectSpread(_objectSpread({}, cellProps), setCellProps(...arguments) || {});
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
|
|
175
|
-
cellProps.className = (0, _clsx.default)(cellProps.className, "pc-align-".concat(tempObj.align));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (tempObj.verticalKeyAlign) {
|
|
179
|
-
cellProps.className = (0, _clsx.default)(cellProps.className, "vertical-align-".concat(tempObj.verticalKeyAlign));
|
|
180
|
-
}
|
|
181
|
-
|
|
185
|
+
fixCellProp(tempObj, cellProps);
|
|
182
186
|
return cellProps;
|
|
183
187
|
};
|
|
184
188
|
|
|
@@ -27,7 +27,7 @@ var _Util = require("../Util");
|
|
|
27
27
|
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
|
|
30
|
-
const _excluded = ["value", "locale", "withoutSuffix", "from", "to"];
|
|
30
|
+
const _excluded = ["value", "locale", "withoutSuffix", "from", "to", "type"];
|
|
31
31
|
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
33
|
|
|
@@ -78,7 +78,8 @@ function RelativeTime(_ref) {
|
|
|
78
78
|
locale,
|
|
79
79
|
withoutSuffix,
|
|
80
80
|
from,
|
|
81
|
-
to
|
|
81
|
+
to,
|
|
82
|
+
type
|
|
82
83
|
} = _ref,
|
|
83
84
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
84
85
|
|
|
@@ -87,20 +88,29 @@ function RelativeTime(_ref) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
const localeOption = locale === 'zh' ? 'zh-cn' : 'zh-us';
|
|
90
|
-
let
|
|
91
|
+
let relativeString;
|
|
91
92
|
|
|
92
93
|
if (from) {
|
|
93
|
-
|
|
94
|
+
relativeString = (0, _dayjs.default)(value).locale(localeOption).from(from, withoutSuffix);
|
|
94
95
|
} else if (to) {
|
|
95
|
-
|
|
96
|
+
relativeString = (0, _dayjs.default)(value).locale(localeOption).to(to, withoutSuffix);
|
|
96
97
|
} else {
|
|
97
|
-
|
|
98
|
+
relativeString = (0, _dayjs.default)(value).locale(localeOption).fromNow(withoutSuffix);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const absoluteString = (0, _Util.formatToDatetime)(value, {
|
|
102
|
+
locale: localeOption
|
|
103
|
+
});
|
|
104
|
+
let innerContent = relativeString;
|
|
105
|
+
let popContent = absoluteString;
|
|
106
|
+
|
|
107
|
+
if (type === 'absolute') {
|
|
108
|
+
innerContent = absoluteString;
|
|
109
|
+
popContent = relativeString;
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
101
|
-
title:
|
|
102
|
-
locale: localeOption
|
|
103
|
-
}),
|
|
113
|
+
title: popContent,
|
|
104
114
|
placement: "top-end",
|
|
105
115
|
enterTouchDelay: 0,
|
|
106
116
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -114,11 +124,13 @@ RelativeTime.propTypes = {
|
|
|
114
124
|
locale: _propTypes.default.string,
|
|
115
125
|
withoutSuffix: _propTypes.default.bool,
|
|
116
126
|
from: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
117
|
-
to: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
127
|
+
to: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
128
|
+
type: _propTypes.default.string
|
|
118
129
|
};
|
|
119
130
|
RelativeTime.defaultProps = {
|
|
120
131
|
locale: 'en',
|
|
121
132
|
withoutSuffix: false,
|
|
122
133
|
from: '',
|
|
123
|
-
to: ''
|
|
134
|
+
to: '',
|
|
135
|
+
type: 'relative'
|
|
124
136
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.43",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=18.1.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a9cd5a9d9c5e58bba3a4adbf13069ebc37120515",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.43",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.43",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/Datatable/index.js
CHANGED
|
@@ -20,6 +20,24 @@ export default function Datatable({ ...props }) {
|
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const fixCellProp = (tempObj, cellProps) => {
|
|
24
|
+
const cellStyle = {};
|
|
25
|
+
|
|
26
|
+
if (tempObj.align) {
|
|
27
|
+
cellProps.className = clsx(cellProps.className, `pc-align-${tempObj.align}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (tempObj.verticalKeyAlign) {
|
|
31
|
+
cellProps.className = clsx(cellProps.className, `vertical-align-${tempObj.verticalKeyAlign}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (tempObj.minWidth) {
|
|
35
|
+
cellStyle.minWidth = tempObj.minWidth;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
cellProps.style = Object.assign({}, cellProps.style, cellStyle);
|
|
39
|
+
};
|
|
40
|
+
|
|
23
41
|
/**
|
|
24
42
|
* @param {Object} props.options The options of mui-datatable,detail see https://github.com/gregnb/mui-datatables/tree/b8d2eee6af4589d254b40918e5d7e70b1ee4baca
|
|
25
43
|
* @param {Array} props.customButtons Custom buttons for toolbar
|
|
@@ -102,13 +120,7 @@ function ReDatatable({
|
|
|
102
120
|
cellProps.width = tempObj.width;
|
|
103
121
|
}
|
|
104
122
|
|
|
105
|
-
|
|
106
|
-
cellProps.className = clsx(cellProps.className, `pc-align-${tempObj.align}`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (tempObj.verticalKeyAlign) {
|
|
110
|
-
cellProps.className = clsx(cellProps.className, `vertical-align-${tempObj.verticalKeyAlign}`);
|
|
111
|
-
}
|
|
123
|
+
fixCellProp(tempObj, cellProps);
|
|
112
124
|
|
|
113
125
|
return cellProps;
|
|
114
126
|
};
|
|
@@ -130,13 +142,7 @@ function ReDatatable({
|
|
|
130
142
|
};
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
|
|
134
|
-
cellProps.className = clsx(cellProps.className, `pc-align-${tempObj.align}`);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (tempObj.verticalKeyAlign) {
|
|
138
|
-
cellProps.className = clsx(cellProps.className, `vertical-align-${tempObj.verticalKeyAlign}`);
|
|
139
|
-
}
|
|
145
|
+
fixCellProp(tempObj, cellProps);
|
|
140
146
|
|
|
141
147
|
return cellProps;
|
|
142
148
|
};
|
|
@@ -34,25 +34,35 @@ dayjs.updateLocale('zh-cn', {
|
|
|
34
34
|
});
|
|
35
35
|
setDateTool(dayjs);
|
|
36
36
|
|
|
37
|
-
export default function RelativeTime({ value, locale, withoutSuffix, from, to, ...rest }) {
|
|
37
|
+
export default function RelativeTime({ value, locale, withoutSuffix, from, to, type, ...rest }) {
|
|
38
38
|
if (!value) {
|
|
39
39
|
return '-';
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const localeOption = locale === 'zh' ? 'zh-cn' : 'zh-us';
|
|
43
43
|
|
|
44
|
-
let
|
|
44
|
+
let relativeString;
|
|
45
45
|
|
|
46
46
|
if (from) {
|
|
47
|
-
|
|
47
|
+
relativeString = dayjs(value).locale(localeOption).from(from, withoutSuffix);
|
|
48
48
|
} else if (to) {
|
|
49
|
-
|
|
49
|
+
relativeString = dayjs(value).locale(localeOption).to(to, withoutSuffix);
|
|
50
50
|
} else {
|
|
51
|
-
|
|
51
|
+
relativeString = dayjs(value).locale(localeOption).fromNow(withoutSuffix);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const absoluteString = formatToDatetime(value, { locale: localeOption });
|
|
55
|
+
|
|
56
|
+
let innerContent = relativeString;
|
|
57
|
+
let popContent = absoluteString;
|
|
58
|
+
|
|
59
|
+
if (type === 'absolute') {
|
|
60
|
+
innerContent = absoluteString;
|
|
61
|
+
popContent = relativeString;
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
return (
|
|
55
|
-
<Tooltip title={
|
|
65
|
+
<Tooltip title={popContent} placement="top-end" enterTouchDelay={0}>
|
|
56
66
|
<span {...rest}>{innerContent}</span>
|
|
57
67
|
</Tooltip>
|
|
58
68
|
);
|
|
@@ -64,6 +74,7 @@ RelativeTime.propTypes = {
|
|
|
64
74
|
withoutSuffix: PropTypes.bool,
|
|
65
75
|
from: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
66
76
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
77
|
+
type: PropTypes.string,
|
|
67
78
|
};
|
|
68
79
|
|
|
69
80
|
RelativeTime.defaultProps = {
|
|
@@ -71,4 +82,5 @@ RelativeTime.defaultProps = {
|
|
|
71
82
|
withoutSuffix: false,
|
|
72
83
|
from: '',
|
|
73
84
|
to: '',
|
|
85
|
+
type: 'relative',
|
|
74
86
|
};
|