diginet-core-ui 1.3.53-beta.3 → 1.3.53-beta.6
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/components/form-control/checkbox/index.js +165 -159
- package/components/form-control/dropdown/index.js +35 -35
- package/components/form-control/number-input/index2.js +4 -6
- package/components/paging/page-info.js +35 -11
- package/components/popup/v2/index.js +240 -260
- package/package.json +1 -1
- package/theme/createBreakpoints.js +13 -13
- package/utils/string/capitalize.js +4 -3
- package/utils/useMediaQuery.js +44 -0
- package/components/popup/v2/danger-popup.js +0 -15
- package/components/popup/v2/info-popup.js +0 -15
- package/components/popup/v2/success-popup.js +0 -15
- package/components/popup/v2/warning-popup.js +0 -15
- package/components/popup/v2/yes-no-popup.js +0 -18
|
@@ -5,7 +5,7 @@ import { css, jsx } from '@emotion/core';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useEffect, useRef, useState, useImperativeHandle } from 'react';
|
|
7
7
|
import { Typography } from '../..';
|
|
8
|
-
import { alignCenter, alignStart, borderBox, cursorPointer, displayBlock, flexRow, positionAbsolute, positionRelative, cursorNoDrop } from '../../../styles/general';
|
|
8
|
+
import { alignCenter, alignStart, borderBox, cursorPointer, displayBlock, flexRow, positionAbsolute, positionRelative, cursorNoDrop, parseWidthHeight } from '../../../styles/general';
|
|
9
9
|
import { randomString } from '../../../utils';
|
|
10
10
|
import { color as colors } from '../../../styles/colors';
|
|
11
11
|
import theme from '../../../theme/settings';
|
|
@@ -24,6 +24,7 @@ const {
|
|
|
24
24
|
},
|
|
25
25
|
spacing
|
|
26
26
|
} = theme;
|
|
27
|
+
const padding = spacing(0.75);
|
|
27
28
|
const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
28
29
|
id,
|
|
29
30
|
className,
|
|
@@ -52,7 +53,6 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
52
53
|
const ref = useRef(null);
|
|
53
54
|
if (typeof width === 'number') width += 'px';
|
|
54
55
|
const [checkedState, setCheckedState] = useState(checked || defaultChecked);
|
|
55
|
-
const padding = spacing(0.5);
|
|
56
56
|
|
|
57
57
|
if (!id) {
|
|
58
58
|
[id] = useState('DGN-UI-' + randomString(10, {
|
|
@@ -62,123 +62,13 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const clMain = colors[color] || color;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
height: ${width};
|
|
73
|
-
min-height: ${width};
|
|
74
|
-
background-color: ${white};
|
|
75
|
-
border: 2px solid ${rest};
|
|
76
|
-
border-radius: 2px;
|
|
77
|
-
margin-right: ${spacing(2)}px;
|
|
78
|
-
&.determinate {
|
|
79
|
-
&::after {
|
|
80
|
-
${displayBlock}
|
|
81
|
-
${positionAbsolute}
|
|
82
|
-
content : '';
|
|
83
|
-
height: 7px;
|
|
84
|
-
left: 50%;
|
|
85
|
-
top: 43%;
|
|
86
|
-
transform: translate(-50%, -50%) scale(0) rotate(45deg);
|
|
87
|
-
transition: transform 0.3s;
|
|
88
|
-
width: 12.6px;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
&.indeterminate {
|
|
92
|
-
&::after {
|
|
93
|
-
${flexRow}
|
|
94
|
-
${positionAbsolute}
|
|
95
|
-
content: "";
|
|
96
|
-
background-color: white;
|
|
97
|
-
left: 2px;
|
|
98
|
-
top: 6px;
|
|
99
|
-
width: 10px;
|
|
100
|
-
height: 2px;
|
|
101
|
-
transition: transform 0.3s;
|
|
102
|
-
transform: scale(0);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
&:not(.disabled):not(.read-only) {
|
|
106
|
-
&:hover {
|
|
107
|
-
box-shadow: 0 0 0 3px ${clFillHover};
|
|
108
|
-
background-color: ${clFillHover};
|
|
109
|
-
border-color: ${clMain};
|
|
110
|
-
}
|
|
111
|
-
&:focus,
|
|
112
|
-
&:active {
|
|
113
|
-
box-shadow: 0 0 0 3px ${clFillPressed};
|
|
114
|
-
background-color: ${clFillPressed};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
&:not(disabled):focus {
|
|
118
|
-
box-shadow: 0 0 0 3px ${clFillPressed};
|
|
119
|
-
background-color: ${clFillPressed};
|
|
120
|
-
}
|
|
121
|
-
&.disabled,
|
|
122
|
-
&.read-only {
|
|
123
|
-
${cursorNoDrop};
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
126
|
-
const CheckBoxInput = css`
|
|
127
|
-
&:checked + label > span.css-${CheckBoxSquare.name} {
|
|
128
|
-
&.determinate {
|
|
129
|
-
&::after {
|
|
130
|
-
transform: translate(-50%, -66%) scale(1) rotate(-45deg);
|
|
131
|
-
background: linear-gradient(${white}, ${white}) left bottom/2px 100%,
|
|
132
|
-
linear-gradient(${white}, ${white}) left bottom/100% 2px;
|
|
133
|
-
background-repeat: no-repeat;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
&.indeterminate {
|
|
137
|
-
&::after {
|
|
138
|
-
transform: scale(1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
&:checked:not(:disabled) + label > span.css-${CheckBoxSquare.name} {
|
|
143
|
-
background-color: ${clMain} !important;
|
|
144
|
-
border-color: ${clMain} !important;
|
|
145
|
-
}
|
|
146
|
-
&:checked:disabled {
|
|
147
|
-
& + label > span.css-${CheckBoxSquare.name} {
|
|
148
|
-
&:not(.indeterminate) {
|
|
149
|
-
background-color: ${clDisabled} !important;
|
|
150
|
-
}
|
|
151
|
-
&.indeterminate {
|
|
152
|
-
background-color: ${clFormal2} !important;
|
|
153
|
-
border-color: ${clFormal2} !important;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
&:disabled {
|
|
158
|
-
& + label > span.css-${CheckBoxSquare.name} {
|
|
159
|
-
border-color: ${clDisabled};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
`;
|
|
163
|
-
const CheckBoxLabel = css`
|
|
164
|
-
${flexRow};
|
|
165
|
-
${positionRelative};
|
|
166
|
-
${alignCenter};
|
|
167
|
-
${borderBox};
|
|
168
|
-
margin-bottom: 0 !important;
|
|
169
|
-
`;
|
|
170
|
-
const CheckBoxRoot = css`
|
|
171
|
-
${flexRow};
|
|
172
|
-
${alignStart};
|
|
173
|
-
${borderBox};
|
|
174
|
-
`;
|
|
175
|
-
const CheckboxContainer = css`
|
|
176
|
-
${displayBlock};
|
|
177
|
-
${positionRelative};
|
|
178
|
-
padding: ${padding}px;
|
|
179
|
-
`;
|
|
180
|
-
|
|
181
|
-
const handleChange = () => {
|
|
65
|
+
|
|
66
|
+
const _CheckBoxSquareCSS = CheckBoxSquareCSS(width, clMain);
|
|
67
|
+
|
|
68
|
+
const _CheckBoxInputCSS = CheckBoxInputCSS(_CheckBoxSquareCSS.name, clMain);
|
|
69
|
+
|
|
70
|
+
const handleChange = event => {
|
|
71
|
+
event.stopPropagation();
|
|
182
72
|
if (readOnly || inputProps.readOnly || disabled || inputProps.disabled) return;
|
|
183
73
|
const oldLogicChecked = inputRef.current.checked; //Use for TreeView
|
|
184
74
|
|
|
@@ -225,14 +115,14 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
225
115
|
});
|
|
226
116
|
return jsx("div", {
|
|
227
117
|
id: 'DGN-UI-Checkbox-' + id.replace('DGN-UI-', ''),
|
|
228
|
-
css:
|
|
118
|
+
css: CheckboxContainerCSS,
|
|
229
119
|
className: ['DGN-UI-Checkbox', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
230
120
|
ref: ref,
|
|
231
121
|
...props,
|
|
232
122
|
onClick: handleChange
|
|
233
123
|
}, jsx("div", {
|
|
234
|
-
css:
|
|
235
|
-
className: disabled ? 'disabled' : readOnly ? 'read-only' : ''
|
|
124
|
+
css: CheckBoxRootCSS,
|
|
125
|
+
className: ['DGN-UI-Checkbox-Root', disabled ? 'disabled' : readOnly ? 'read-only' : ''].join(' ').trim().replace(/\s+/g, ' ')
|
|
236
126
|
}, jsx("input", {
|
|
237
127
|
value: value,
|
|
238
128
|
...inputProps,
|
|
@@ -240,7 +130,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
240
130
|
readOnly: readOnly || inputProps.readOnly,
|
|
241
131
|
disabled: disabled || inputProps.disabled,
|
|
242
132
|
ref: inputRef,
|
|
243
|
-
css:
|
|
133
|
+
css: _CheckBoxInputCSS,
|
|
244
134
|
id: id,
|
|
245
135
|
name: name,
|
|
246
136
|
type: "checkbox",
|
|
@@ -248,16 +138,136 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
248
138
|
onChange: handleChange,
|
|
249
139
|
hidden: true
|
|
250
140
|
}), jsx("label", {
|
|
251
|
-
css:
|
|
141
|
+
css: CheckBoxLabelCSS
|
|
252
142
|
}, jsx("span", {
|
|
253
143
|
className: [determinate ? 'determinate' : 'indeterminate', readOnly ? 'read-only' : '', disabled ? 'disabled' : ''].join(' '),
|
|
254
|
-
css:
|
|
144
|
+
css: _CheckBoxSquareCSS
|
|
255
145
|
}), (children || label) && jsx(Typography, {
|
|
256
146
|
type: 'p1',
|
|
147
|
+
style: {
|
|
148
|
+
marginLeft: spacing(1)
|
|
149
|
+
},
|
|
257
150
|
color: disabled ? clDisabled : '',
|
|
258
151
|
...labelProps
|
|
259
152
|
}, children || label))));
|
|
260
153
|
}));
|
|
154
|
+
|
|
155
|
+
const CheckBoxSquareCSS = (width, clMain) => css`
|
|
156
|
+
${flexRow};
|
|
157
|
+
${positionRelative};
|
|
158
|
+
${cursorPointer};
|
|
159
|
+
${borderBox};
|
|
160
|
+
${parseWidthHeight(width, width)};
|
|
161
|
+
min-width: ${width};
|
|
162
|
+
min-height: ${width};
|
|
163
|
+
background-color: ${white};
|
|
164
|
+
border: 2px solid ${rest};
|
|
165
|
+
border-radius: 2px;
|
|
166
|
+
margin: ${padding}px;
|
|
167
|
+
&.determinate {
|
|
168
|
+
&::after {
|
|
169
|
+
${displayBlock};
|
|
170
|
+
${positionAbsolute};
|
|
171
|
+
content: '';
|
|
172
|
+
height: 7px;
|
|
173
|
+
left: 50%;
|
|
174
|
+
top: 43%;
|
|
175
|
+
transform: translate(-50%, -50%) scale(0) rotate(45deg);
|
|
176
|
+
transition: transform 0.3s;
|
|
177
|
+
width: 12.6px;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
&.indeterminate {
|
|
181
|
+
&::after {
|
|
182
|
+
${flexRow};
|
|
183
|
+
${positionAbsolute};
|
|
184
|
+
content: '';
|
|
185
|
+
background-color: white;
|
|
186
|
+
left: 2px;
|
|
187
|
+
top: 6px;
|
|
188
|
+
width: 10px;
|
|
189
|
+
height: 2px;
|
|
190
|
+
transition: transform 0.3s;
|
|
191
|
+
transform: scale(0);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
&:not(.disabled):not(.read-only) {
|
|
195
|
+
&:hover {
|
|
196
|
+
box-shadow: 0 0 0 3px ${clFillHover};
|
|
197
|
+
background-color: ${clFillHover};
|
|
198
|
+
border-color: ${clMain};
|
|
199
|
+
}
|
|
200
|
+
&:focus,
|
|
201
|
+
&:active {
|
|
202
|
+
box-shadow: 0 0 0 3px ${clFillPressed};
|
|
203
|
+
background-color: ${clFillPressed};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
&:not(disabled):focus {
|
|
207
|
+
box-shadow: 0 0 0 3px ${clFillPressed};
|
|
208
|
+
background-color: ${clFillPressed};
|
|
209
|
+
}
|
|
210
|
+
&.disabled,
|
|
211
|
+
&.read-only {
|
|
212
|
+
${cursorNoDrop};
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
|
|
216
|
+
const CheckBoxInputCSS = (CheckBoxSquareCSSName, clMain) => css`
|
|
217
|
+
&:checked + label > span.css-${CheckBoxSquareCSSName} {
|
|
218
|
+
&.determinate {
|
|
219
|
+
&::after {
|
|
220
|
+
transform: translate(-50%, -66%) scale(1) rotate(-45deg);
|
|
221
|
+
background: linear-gradient(${white}, ${white}) left bottom/2px 100%,
|
|
222
|
+
linear-gradient(${white}, ${white}) left bottom/100% 2px;
|
|
223
|
+
background-repeat: no-repeat;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
&.indeterminate {
|
|
227
|
+
&::after {
|
|
228
|
+
transform: scale(1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
&:checked:not(:disabled) + label > span.css-${CheckBoxSquareCSSName} {
|
|
233
|
+
background-color: ${clMain} !important;
|
|
234
|
+
border-color: ${clMain} !important;
|
|
235
|
+
}
|
|
236
|
+
&:checked:disabled {
|
|
237
|
+
& + label > span.css-${CheckBoxSquareCSSName} {
|
|
238
|
+
&:not(.indeterminate) {
|
|
239
|
+
background-color: ${clDisabled} !important;
|
|
240
|
+
}
|
|
241
|
+
&.indeterminate {
|
|
242
|
+
background-color: ${clFormal2} !important;
|
|
243
|
+
border-color: ${clFormal2} !important;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
&:disabled {
|
|
248
|
+
& + label > span.css-${CheckBoxSquareCSSName} {
|
|
249
|
+
border-color: ${clDisabled};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
`;
|
|
253
|
+
|
|
254
|
+
const CheckBoxLabelCSS = css`
|
|
255
|
+
${flexRow};
|
|
256
|
+
${positionRelative};
|
|
257
|
+
${alignCenter};
|
|
258
|
+
${borderBox};
|
|
259
|
+
margin-bottom: 0 !important;
|
|
260
|
+
`;
|
|
261
|
+
const CheckBoxRootCSS = css`
|
|
262
|
+
${flexRow};
|
|
263
|
+
${alignStart};
|
|
264
|
+
${borderBox};
|
|
265
|
+
`;
|
|
266
|
+
const CheckboxContainerCSS = css`
|
|
267
|
+
${displayBlock};
|
|
268
|
+
${positionRelative};
|
|
269
|
+
width: fit-content;
|
|
270
|
+
`;
|
|
261
271
|
Checkbox.defaultProps = {
|
|
262
272
|
label: '',
|
|
263
273
|
className: '',
|
|
@@ -271,57 +281,53 @@ Checkbox.defaultProps = {
|
|
|
271
281
|
width: 18
|
|
272
282
|
};
|
|
273
283
|
Checkbox.propTypes = {
|
|
274
|
-
/**
|
|
284
|
+
/** If `true`, the component is checked. */
|
|
275
285
|
checked: PropTypes.bool,
|
|
276
286
|
|
|
277
|
-
/**
|
|
278
|
-
|
|
287
|
+
/** Class for component. */
|
|
288
|
+
className: PropTypes.string,
|
|
279
289
|
|
|
280
|
-
/**
|
|
281
|
-
|
|
290
|
+
/** The main color of the component. ['primary', 'info', 'success', 'warning', 'danger', #hex, rgb(#, #, #)] */
|
|
291
|
+
color: PropTypes.string,
|
|
282
292
|
|
|
283
|
-
/**
|
|
284
|
-
|
|
293
|
+
/** The default checked state. Use when the component is not controlled. */
|
|
294
|
+
defaultChecked: PropTypes.bool,
|
|
285
295
|
|
|
286
|
-
/** display tick or
|
|
296
|
+
/** If `true` display tick or indeterminate if `false`. */
|
|
287
297
|
determinate: PropTypes.bool,
|
|
288
298
|
|
|
289
|
-
/**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/** value of input */
|
|
293
|
-
value: PropTypes.string,
|
|
299
|
+
/** If `true`, the component is disabled. */
|
|
300
|
+
disabled: PropTypes.bool,
|
|
294
301
|
|
|
295
|
-
/**
|
|
296
|
-
|
|
302
|
+
/** The id of the component. */
|
|
303
|
+
id: PropTypes.string,
|
|
297
304
|
|
|
298
|
-
/**
|
|
299
|
-
|
|
305
|
+
/** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element. */
|
|
306
|
+
inputProps: PropTypes.object,
|
|
300
307
|
|
|
301
|
-
/** The name of the Radio is displayed on the interface */
|
|
308
|
+
/** The name of the Radio is displayed on the interface. */
|
|
302
309
|
label: PropTypes.string,
|
|
303
310
|
|
|
304
|
-
/**
|
|
305
|
-
color: PropTypes.string,
|
|
306
|
-
|
|
307
|
-
/** props for Typography of label */
|
|
311
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography--title) applied to the `Typography` label. */
|
|
308
312
|
labelProps: PropTypes.object,
|
|
309
313
|
|
|
310
|
-
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
/** width is a number || string, width of Checkbox default 18 */
|
|
314
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
315
|
-
|
|
316
|
-
/** The function will run to return a true or false value of Radio Component */
|
|
317
|
-
onChange: PropTypes.func,
|
|
314
|
+
/** The name of the Checkbox corresponds to the label displayed on the interface. */
|
|
315
|
+
name: PropTypes.string,
|
|
318
316
|
|
|
319
317
|
/**
|
|
320
|
-
*
|
|
318
|
+
* Callback fired when the state is changed.
|
|
321
319
|
*
|
|
322
|
-
*
|
|
323
|
-
* * getChecked: Get check of input
|
|
320
|
+
* You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
|
|
324
321
|
*/
|
|
325
|
-
|
|
322
|
+
onChange: PropTypes.func,
|
|
323
|
+
|
|
324
|
+
/** If `true`, the component is readonly. */
|
|
325
|
+
readOnly: PropTypes.bool,
|
|
326
|
+
|
|
327
|
+
/** The width of checkbox. */
|
|
328
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
329
|
+
|
|
330
|
+
/** The value of input */
|
|
331
|
+
value: PropTypes.any
|
|
326
332
|
};
|
|
327
333
|
export default Checkbox;
|
|
@@ -1786,14 +1786,14 @@ Dropdown.propTypes = {
|
|
|
1786
1786
|
/** The icon to display if not found the icon follow `iconExpr`. */
|
|
1787
1787
|
iconDefault: PropTypes.string,
|
|
1788
1788
|
|
|
1789
|
-
/** Field name used for icon display.<br/>
|
|
1790
|
-
* Example:<br/>
|
|
1791
|
-
* string: 'icon'<br/>
|
|
1792
|
-
* object: {<br/>
|
|
1793
|
-
* key: 'icon',<br/>
|
|
1794
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1795
|
-
* suffix: '.jpg'<br/>
|
|
1796
|
-
* }
|
|
1789
|
+
/** Field name used for icon display.<br/>
|
|
1790
|
+
* Example:<br/>
|
|
1791
|
+
* string: 'icon'<br/>
|
|
1792
|
+
* object: {<br/>
|
|
1793
|
+
* key: 'icon',<br/>
|
|
1794
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1795
|
+
* suffix: '.jpg'<br/>
|
|
1796
|
+
* }
|
|
1797
1797
|
*/
|
|
1798
1798
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1799
1799
|
key: PropTypes.string,
|
|
@@ -1808,9 +1808,9 @@ Dropdown.propTypes = {
|
|
|
1808
1808
|
/** The displayed value of component. */
|
|
1809
1809
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1810
1810
|
|
|
1811
|
-
/** Field name used for text display in dropdown list.<br/>
|
|
1812
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1813
|
-
* Note: don't use 'id - name', return undefined
|
|
1811
|
+
/** Field name used for text display in dropdown list.<br/>
|
|
1812
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1813
|
+
* Note: don't use 'id - name', return undefined
|
|
1814
1814
|
*/
|
|
1815
1815
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1816
1816
|
|
|
@@ -1820,10 +1820,10 @@ Dropdown.propTypes = {
|
|
|
1820
1820
|
/** The field name used for the returned result. */
|
|
1821
1821
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1822
1822
|
|
|
1823
|
-
/**
|
|
1824
|
-
* Duration wait enter search content on search.<br/>
|
|
1825
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1826
|
-
* If `true`, used default delayOnInput.
|
|
1823
|
+
/**
|
|
1824
|
+
* Duration wait enter search content on search.<br/>
|
|
1825
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1826
|
+
* If `true`, used default delayOnInput.
|
|
1827
1827
|
*/
|
|
1828
1828
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1829
1829
|
|
|
@@ -1890,19 +1890,19 @@ Dropdown.propTypes = {
|
|
|
1890
1890
|
/** The array of elements that appear in the dropdown list. */
|
|
1891
1891
|
dataSource: PropTypes.array,
|
|
1892
1892
|
|
|
1893
|
-
/** Function displays items by custom.<br/>
|
|
1894
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1895
|
-
* --> such as: displayExpr={'name - role'}
|
|
1893
|
+
/** Function displays items by custom.<br/>
|
|
1894
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1895
|
+
* --> such as: displayExpr={'name - role'}
|
|
1896
1896
|
*/
|
|
1897
1897
|
renderItem: PropTypes.func,
|
|
1898
1898
|
|
|
1899
|
-
/** Function displays selected items by custom, example:<br/>
|
|
1900
|
-
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1899
|
+
/** Function displays selected items by custom, example:<br/>
|
|
1900
|
+
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1901
1901
|
*/
|
|
1902
1902
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1903
1903
|
|
|
1904
|
-
/** Callback fired when the input value changes.<br/>
|
|
1905
|
-
* if undefined: the filter function will run (default)
|
|
1904
|
+
/** Callback fired when the input value changes.<br/>
|
|
1905
|
+
* if undefined: the filter function will run (default)
|
|
1906
1906
|
*/
|
|
1907
1907
|
onInput: PropTypes.func,
|
|
1908
1908
|
|
|
@@ -1921,19 +1921,19 @@ Dropdown.propTypes = {
|
|
|
1921
1921
|
/** The contents in Dropdown box (Exp: TreeView). */
|
|
1922
1922
|
children: PropTypes.node,
|
|
1923
1923
|
|
|
1924
|
-
/**
|
|
1925
|
-
* ref methods
|
|
1926
|
-
*
|
|
1927
|
-
* how to get component element? ref.current
|
|
1928
|
-
*
|
|
1929
|
-
* how to call method? ref.current.instance.{method}
|
|
1930
|
-
*
|
|
1931
|
-
* * showDropdown(): Show dropdown
|
|
1932
|
-
* * closeDropdown(): Close dropdown
|
|
1933
|
-
* * onClear(): Clear selected value
|
|
1934
|
-
* * setPreviousValue(): Set value to previous value
|
|
1935
|
-
* * setValue(value): Set value of dropdown
|
|
1936
|
-
* * @param {value} - string || number || array
|
|
1924
|
+
/**
|
|
1925
|
+
* ref methods
|
|
1926
|
+
*
|
|
1927
|
+
* how to get component element? ref.current
|
|
1928
|
+
*
|
|
1929
|
+
* how to call method? ref.current.instance.{method}
|
|
1930
|
+
*
|
|
1931
|
+
* * showDropdown(): Show dropdown
|
|
1932
|
+
* * closeDropdown(): Close dropdown
|
|
1933
|
+
* * onClear(): Clear selected value
|
|
1934
|
+
* * setPreviousValue(): Set value to previous value
|
|
1935
|
+
* * setValue(value): Set value of dropdown
|
|
1936
|
+
* * @param {value} - string || number || array
|
|
1937
1937
|
*/
|
|
1938
1938
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1939
1939
|
current: PropTypes.instanceOf(Element)
|
|
@@ -108,10 +108,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
108
108
|
if (!decimalDigit) number.length = 1;else if (number[1]) number[1] = (_number$ = number[1]) === null || _number$ === void 0 ? void 0 : _number$.slice(0, decimalDigit || 0);
|
|
109
109
|
number = number.join(decimalSymbol); // keep focus position
|
|
110
110
|
|
|
111
|
-
if ((_number3 = number)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
pos.current = selectionStart + (((_number4 = number) === null || _number4 === void 0 ? void 0 : _number4.toString().split(thousandSymbol).length) - (vl === null || vl === void 0 ? void 0 : vl.toString().split(thousandSymbol).length));
|
|
111
|
+
if (((_number3 = number) === null || _number3 === void 0 ? void 0 : _number3.indexOf(thousandSymbol)) > -1 && selectionStart !== number.length + 1) {
|
|
112
|
+
pos.current = selectionStart + (number.toString().length - 1 === vl.toString().length ? 1 : 0);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
return number;
|
|
@@ -126,12 +124,12 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
126
124
|
*/
|
|
127
125
|
|
|
128
126
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
129
|
-
var
|
|
127
|
+
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
130
128
|
|
|
131
129
|
let number = vl === null || vl === void 0 ? void 0 : vl.toString().replace(regexValidNumber, ''); // allow number and , || . || -
|
|
132
130
|
// remove <thousandSymbol> and replace . to <decimalSymbol>
|
|
133
131
|
|
|
134
|
-
if (!isNumber) number = (
|
|
132
|
+
if (!isNumber) number = (_number4 = number) === null || _number4 === void 0 ? void 0 : (_number4$toString = _number4.toString()) === null || _number4$toString === void 0 ? void 0 : (_number4$toString$rep = _number4$toString.replaceAll) === null || _number4$toString$rep === void 0 ? void 0 : (_number4$toString$rep2 = (_number4$toString$rep3 = _number4$toString$rep.call(_number4$toString, thousandSymbol, '')).replaceAll) === null || _number4$toString$rep2 === void 0 ? void 0 : _number4$toString$rep2.call(_number4$toString$rep3, decimalSymbol, '.');
|
|
135
133
|
return number;
|
|
136
134
|
}, [decimalSymbol]);
|
|
137
135
|
|
|
@@ -8,7 +8,7 @@ import OptionWrapper from '../others/option-wrapper';
|
|
|
8
8
|
import { ButtonIcon, NumberInput, Dropdown, Typography, Divider } from '../';
|
|
9
9
|
import { getGlobal } from '../../global';
|
|
10
10
|
import theme from '../../theme/settings';
|
|
11
|
-
import { alignCenter, borderBox, flexRow, noMargin, noPadding, border, textCenter, cursorPointer } from '../../styles/general';
|
|
11
|
+
import { alignCenter, borderBox, flexRow, noMargin, noPadding, border, textCenter, cursorPointer, parseHeight } from '../../styles/general';
|
|
12
12
|
const {
|
|
13
13
|
colors: {
|
|
14
14
|
system: {
|
|
@@ -40,6 +40,7 @@ const getLastPage = (totalItems, itemsPerPage) => {
|
|
|
40
40
|
return _lastPage + 1;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const delayOnInput = getGlobal('delayOnInput');
|
|
43
44
|
const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
44
45
|
id,
|
|
45
46
|
typeShort,
|
|
@@ -59,6 +60,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
59
60
|
|
|
60
61
|
const ref = useRef(null);
|
|
61
62
|
const timer = useRef(null);
|
|
63
|
+
const currentPageRef = useRef(null);
|
|
62
64
|
const [totalItemsState, setTotalItemsState] = useState(totalItems);
|
|
63
65
|
const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || listPerPage[0] || 10);
|
|
64
66
|
const [currentPageState, setCurrentPageState] = useState(currentPage);
|
|
@@ -105,6 +107,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
currentPageRef.current = page;
|
|
108
111
|
setCurrentPageState(page);
|
|
109
112
|
setDisablePrevState(disablePrev);
|
|
110
113
|
setDisableNextState(disableNext);
|
|
@@ -133,6 +136,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
|
|
139
|
+
currentPageRef.current = 0;
|
|
136
140
|
setItemsPerPageState(per);
|
|
137
141
|
setCurrentPageState(0);
|
|
138
142
|
setDisablePrevState(true);
|
|
@@ -153,7 +157,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
153
157
|
currentPage = page - 1;
|
|
154
158
|
timer.current = setTimeout(() => {
|
|
155
159
|
_onChangePage(page - 1, isInit, e);
|
|
156
|
-
},
|
|
160
|
+
}, delayOnInput);
|
|
157
161
|
};
|
|
158
162
|
|
|
159
163
|
const checkKeyPress = e => {
|
|
@@ -172,7 +176,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
172
176
|
|
|
173
177
|
timer.current = setTimeout(() => {
|
|
174
178
|
_onChangePage(currentPageState !== null && currentPageState !== void 0 ? currentPageState : 0, true);
|
|
175
|
-
},
|
|
179
|
+
}, delayOnInput);
|
|
176
180
|
}, [totalItemsState, itemsPerPageState]);
|
|
177
181
|
useEffect(() => {
|
|
178
182
|
setItemsPerPageState(itemsPerPage);
|
|
@@ -235,7 +239,17 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
235
239
|
size: 'small',
|
|
236
240
|
name: 'ArrowLeft',
|
|
237
241
|
disabled: disablePrevState,
|
|
238
|
-
onClick: e =>
|
|
242
|
+
onClick: e => {
|
|
243
|
+
currentPageRef.current = currentPageRef.current - 1;
|
|
244
|
+
|
|
245
|
+
if (timer.current) {
|
|
246
|
+
clearTimeout(timer.current);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
timer.current = setTimeout(() => {
|
|
250
|
+
_onChangePage(currentPageRef.current, false, e);
|
|
251
|
+
}, delayOnInput);
|
|
252
|
+
}
|
|
239
253
|
}), jsx(NumberInput, {
|
|
240
254
|
css: _dynamicWidthCSS,
|
|
241
255
|
disabledNegative: true,
|
|
@@ -256,7 +270,17 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
256
270
|
size: 'small',
|
|
257
271
|
name: 'ArrowRight',
|
|
258
272
|
disabled: disableNextState,
|
|
259
|
-
onClick: e =>
|
|
273
|
+
onClick: e => {
|
|
274
|
+
currentPageRef.current = currentPageRef.current + 1;
|
|
275
|
+
|
|
276
|
+
if (timer.current) {
|
|
277
|
+
clearTimeout(timer.current);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
timer.current = setTimeout(() => {
|
|
281
|
+
_onChangePage(currentPageRef.current, false, e);
|
|
282
|
+
}, delayOnInput);
|
|
283
|
+
}
|
|
260
284
|
}), jsx(ButtonIcon, {
|
|
261
285
|
circular: true,
|
|
262
286
|
viewType: 'text',
|
|
@@ -300,10 +324,10 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
300
324
|
${paragraph2};
|
|
301
325
|
${borderBox};
|
|
302
326
|
${border(1, system)};
|
|
303
|
-
|
|
327
|
+
${parseHeight(40)}
|
|
304
328
|
border-left: none;
|
|
305
329
|
border-right: none;
|
|
306
|
-
padding: ${spacing()}
|
|
330
|
+
padding: ${spacing([1, 0])};
|
|
307
331
|
background-color: ${bgColor};
|
|
308
332
|
color: ${main};
|
|
309
333
|
.inputPage {
|
|
@@ -321,13 +345,13 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
321
345
|
}
|
|
322
346
|
}
|
|
323
347
|
.txt-line-number {
|
|
324
|
-
margin-left: ${spacing(4)}
|
|
348
|
+
margin-left: ${spacing([4])};
|
|
325
349
|
}
|
|
326
350
|
.DGN-UI-Divider {
|
|
327
|
-
margin:
|
|
351
|
+
margin: ${spacing([0, 2])};
|
|
328
352
|
}
|
|
329
353
|
.DGN-UI-Dropdown {
|
|
330
|
-
margin-left: ${typeShort ?
|
|
354
|
+
margin-left: ${`${spacing(typeShort ? [0] : [2])}`};
|
|
331
355
|
margin-bottom: 0;
|
|
332
356
|
min-width: 52px;
|
|
333
357
|
.DGN-UI-Dropdown-Form {
|
|
@@ -352,7 +376,7 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
352
376
|
}
|
|
353
377
|
}
|
|
354
378
|
.total-items {
|
|
355
|
-
margin-left: ${typeShort ?
|
|
379
|
+
margin-left: ${`${spacing(typeShort ? [0] : [4])}`};
|
|
356
380
|
}
|
|
357
381
|
`;
|
|
358
382
|
|