diginet-core-ui 1.3.78 → 1.3.79
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/accordion/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
@@ -41,8 +41,8 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
const [, setActiveValueTo] = useState(Date.now());
|
|
42
42
|
const [, setNavigatorValueFr] = useState(Date.now());
|
|
43
43
|
const [, setNavigatorValueTo] = useState(Date.now());
|
|
44
|
-
const [, setValues] = useState(Date.now());
|
|
45
|
-
|
|
44
|
+
const [, setValues] = useState(Date.now());
|
|
45
|
+
// const [id] = useState(randomString(6, { allowSymbol: false }));
|
|
46
46
|
const unique = {
|
|
47
47
|
container: 'DGN-UI-Calendar-Range',
|
|
48
48
|
divider: 'DGN-UI-Calendar-Range-Divider',
|
|
@@ -145,37 +145,32 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
145
145
|
} else {
|
|
146
146
|
values.current.splice(0, 2, Date.parse(new Date(v)));
|
|
147
147
|
}
|
|
148
|
-
|
|
149
148
|
setValues();
|
|
150
149
|
}, [values]);
|
|
151
|
-
|
|
152
150
|
const onCalFrClick = e => {
|
|
153
151
|
console.log(e.currentTarget.dataset.time);
|
|
154
152
|
};
|
|
155
|
-
|
|
156
153
|
const onCalToClick = e => {
|
|
157
154
|
console.log(e.currentTarget.dataset.time);
|
|
158
155
|
};
|
|
159
|
-
|
|
160
156
|
const clearHovering = e => {
|
|
161
157
|
const arr = Array.from(e.getElementsByTagName('td'));
|
|
162
|
-
|
|
163
158
|
for (let i in arr) {
|
|
164
159
|
arr[i].classList.remove('hover-start', 'hover-between', 'hover-end');
|
|
165
160
|
}
|
|
166
161
|
};
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
const onDayHover = () => {
|
|
163
|
+
// const hoverTime = parseInt(e.target.dataset.time, 10);
|
|
169
164
|
// console.log(hoverTime);
|
|
170
165
|
};
|
|
171
|
-
|
|
172
166
|
const onPickerHover = e => {
|
|
173
167
|
if (e.target.tagName && e.target.tagName.toLowerCase() === 'td') {
|
|
174
168
|
onDayHover(e);
|
|
175
169
|
} else {
|
|
176
170
|
clearHovering(e.currentTarget);
|
|
177
171
|
}
|
|
178
|
-
};
|
|
172
|
+
};
|
|
173
|
+
// const onUpdateFrom = (value) => {
|
|
179
174
|
// const newValue = new Date(value).setHours(0, 0, 0, 0);
|
|
180
175
|
// onUpdateActiveValueFr(newValue);
|
|
181
176
|
// onUpdateCalendar(newValue, navigatorFromRefs, min, max, tableFrRef.current, [activeValueFr.current, activeValueTo.current], unique.from, displayAnotherMonth, onCalFrClick, onUpdateNavigatorValueFr);
|
|
@@ -185,12 +180,9 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
185
180
|
// onUpdateActiveValueTo(newValue);
|
|
186
181
|
// onUpdateCalendar(newValue, navigatorToRefs, min, max, tableToRef.current, [activeValueFr.current, activeValueTo.current], unique.to, displayAnotherMonth, onCalToClick, onUpdateNavigatorValueTo);
|
|
187
182
|
// };
|
|
188
|
-
|
|
189
|
-
|
|
190
183
|
const onUpdateNavigatorValue = values => {
|
|
191
184
|
const fr = new Date(values[0]);
|
|
192
185
|
const to = new Date(values[1]);
|
|
193
|
-
|
|
194
186
|
if (fr.getFullYear() === to.getFullYear() && fr.getMonth() === to.getMonth()) {
|
|
195
187
|
onUpdateNavigatorValueFr(new Date(fr.getFullYear(), fr.getMonth()));
|
|
196
188
|
onUpdateNavigatorValueTo(new Date(to.getFullYear(), to.getMonth() + 1));
|
|
@@ -199,7 +191,6 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
199
191
|
onUpdateNavigatorValueTo(new Date(to.getFullYear(), to.getMonth()));
|
|
200
192
|
}
|
|
201
193
|
};
|
|
202
|
-
|
|
203
194
|
const onUpdateActiveValue = values => {
|
|
204
195
|
if (values[1] && isValidDate(values[1])) {
|
|
205
196
|
onUpdateValues(values[0], false);
|
|
@@ -214,14 +205,12 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
214
205
|
onUpdateActiveValueTo(values[1]);
|
|
215
206
|
}
|
|
216
207
|
};
|
|
217
|
-
|
|
218
208
|
const onUpdate = array => {
|
|
219
209
|
onUpdateActiveValue(array);
|
|
220
210
|
onUpdateNavigatorValue(array);
|
|
221
211
|
onUpdateCalendar(navigatorValueFr.current, navigatorFromRefs, min, max, tableFrRef.current, values.current, unique.from, displayAnotherMonth, onCalFrClick, onUpdateNavigatorValueFr);
|
|
222
212
|
onUpdateCalendar(navigatorValueTo.current, navigatorToRefs, min, max, tableToRef.current, values.current, unique.to, displayAnotherMonth, onCalToClick, onUpdateNavigatorValueTo);
|
|
223
213
|
};
|
|
224
|
-
|
|
225
214
|
const calendarFrom = jsx("div", {
|
|
226
215
|
className: unique.from.container,
|
|
227
216
|
css: generateCalendarCSS(unique.from, false, false)
|
|
@@ -248,18 +237,18 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
248
237
|
useImperativeHandle(reference, () => {
|
|
249
238
|
const currentRef = ref.current || {};
|
|
250
239
|
const _instance = {}; // methods
|
|
251
|
-
|
|
252
240
|
_instance.__proto__ = {}; // hidden methods
|
|
253
|
-
|
|
254
241
|
currentRef.instance = _instance;
|
|
255
242
|
return currentRef;
|
|
256
243
|
});
|
|
257
|
-
return jsx("div", {
|
|
244
|
+
return jsx("div", {
|
|
245
|
+
...props,
|
|
258
246
|
className: unique.container,
|
|
259
247
|
onMouseOver: onPickerHover,
|
|
260
248
|
css: containerCSS,
|
|
261
249
|
ref: ref
|
|
262
|
-
}, calendarFrom, jsx(Divider, {
|
|
250
|
+
}, calendarFrom, jsx(Divider, {
|
|
251
|
+
...dividerProps
|
|
263
252
|
}), calendarTo, actions);
|
|
264
253
|
}));
|
|
265
254
|
CalendarRange.defaultProps = {
|
|
@@ -270,22 +259,16 @@ CalendarRange.defaultProps = {
|
|
|
270
259
|
CalendarRange.propTypes = {
|
|
271
260
|
/** the footer actions */
|
|
272
261
|
actions: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
|
|
273
|
-
|
|
274
262
|
/** the default value of the calendar */
|
|
275
263
|
defaultValue: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
|
|
276
|
-
|
|
277
264
|
/** display days of previous or next month */
|
|
278
265
|
displayAnotherMonth: PropTypes.bool,
|
|
279
|
-
|
|
280
266
|
/** the last date that can be selected within the UI component. */
|
|
281
267
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
|
|
282
|
-
|
|
283
268
|
/** the minimum date that can be selected within the UI component. */
|
|
284
269
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
|
|
285
|
-
|
|
286
270
|
/** a callback function when click on a day of calendar */
|
|
287
271
|
onClick: PropTypes.func,
|
|
288
|
-
|
|
289
272
|
/** value of the calendar */
|
|
290
273
|
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array])
|
|
291
274
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { css, jsx } from '@emotion/core';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -55,29 +54,22 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
55
54
|
if (!inputRef) {
|
|
56
55
|
inputRef = useRef(null);
|
|
57
56
|
}
|
|
58
|
-
|
|
59
57
|
const ref = useRef(null);
|
|
60
58
|
if (typeof width === 'number') width += 'px';
|
|
61
59
|
const [checkedState, setCheckedState] = useState(checked || defaultChecked);
|
|
62
|
-
|
|
63
60
|
if (!id) {
|
|
64
61
|
[id] = useState('DGN-UI-' + randomString(10, {
|
|
65
62
|
allowNumber: false,
|
|
66
63
|
allowSymbol: false
|
|
67
64
|
}));
|
|
68
65
|
}
|
|
69
|
-
|
|
70
66
|
const clMain = colors[color] || color;
|
|
71
|
-
|
|
72
67
|
const _CheckBoxSquareCSS = CheckBoxSquareCSS(width, clMain);
|
|
73
|
-
|
|
74
68
|
const _CheckBoxInputCSS = CheckBoxInputCSS(_CheckBoxSquareCSS.name, clMain);
|
|
75
|
-
|
|
76
69
|
const handleChange = event => {
|
|
77
70
|
stopPropagation && event.stopPropagation();
|
|
78
71
|
if (readOnly || inputProps.readOnly || disabled || inputProps.disabled) return;
|
|
79
72
|
const oldLogicChecked = inputRef.current.checked; //Use for TreeView
|
|
80
|
-
|
|
81
73
|
if (forTreeView) {
|
|
82
74
|
inputRef.current.checked = !oldLogicChecked; //Use for TreeView
|
|
83
75
|
}
|
|
@@ -91,13 +83,11 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
91
83
|
};
|
|
92
84
|
if (onChange) onChange(e, checkedState);
|
|
93
85
|
};
|
|
94
|
-
|
|
95
86
|
const setChecked = check => {
|
|
96
87
|
if (typeof check === 'boolean') {
|
|
97
88
|
setCheckedState(check);
|
|
98
89
|
}
|
|
99
90
|
};
|
|
100
|
-
|
|
101
91
|
useEffect(() => {
|
|
102
92
|
if (checked !== undefined) setCheckedState(Boolean(checked));
|
|
103
93
|
}, [checked]);
|
|
@@ -110,15 +100,11 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
110
100
|
getChecked: () => checkedState,
|
|
111
101
|
...action
|
|
112
102
|
}; // methods
|
|
113
|
-
|
|
114
103
|
_instance.__proto__ = {}; // hidden methods
|
|
115
|
-
|
|
116
104
|
currentRef.instance = _instance;
|
|
117
105
|
currentRef.determinate = determinate;
|
|
118
106
|
currentRef.setChecked = setChecked;
|
|
119
|
-
|
|
120
107
|
currentRef.getChecked = () => checkedState;
|
|
121
|
-
|
|
122
108
|
return currentRef;
|
|
123
109
|
});
|
|
124
110
|
return jsx("div", {
|
|
@@ -163,7 +149,6 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
163
149
|
}
|
|
164
150
|
}, "*"))))));
|
|
165
151
|
}));
|
|
166
|
-
|
|
167
152
|
const CheckBoxSquareCSS = (width, clMain) => css`
|
|
168
153
|
${flexRow};
|
|
169
154
|
${positionRelative};
|
|
@@ -222,7 +207,6 @@ const CheckBoxSquareCSS = (width, clMain) => css`
|
|
|
222
207
|
${cursorNoDrop};
|
|
223
208
|
}
|
|
224
209
|
`;
|
|
225
|
-
|
|
226
210
|
const CheckBoxInputCSS = (CheckBoxSquareCSSName, clMain) => css`
|
|
227
211
|
&:checked + label > span.css-${CheckBoxSquareCSSName} {
|
|
228
212
|
&.determinate {
|
|
@@ -260,7 +244,6 @@ const CheckBoxInputCSS = (CheckBoxSquareCSSName, clMain) => css`
|
|
|
260
244
|
}
|
|
261
245
|
}
|
|
262
246
|
`;
|
|
263
|
-
|
|
264
247
|
const CheckBoxLabelCSS = css`
|
|
265
248
|
${flexRow};
|
|
266
249
|
${positionRelative};
|
|
@@ -294,56 +277,40 @@ Checkbox.defaultProps = {
|
|
|
294
277
|
Checkbox.propTypes = {
|
|
295
278
|
/** If `true`, the component is checked. */
|
|
296
279
|
checked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf([0, 1])]),
|
|
297
|
-
|
|
298
280
|
/** Class for component. */
|
|
299
281
|
className: PropTypes.string,
|
|
300
|
-
|
|
301
282
|
/** The main color of the component. ['primary', 'info', 'success', 'warning', 'danger', #hex, rgb(#, #, #)] */
|
|
302
283
|
color: PropTypes.string,
|
|
303
|
-
|
|
304
284
|
/** The default checked state. Use when the component is not controlled. */
|
|
305
285
|
defaultChecked: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf([0, 1])]),
|
|
306
|
-
|
|
307
286
|
/** If `true` display tick or indeterminate if `false`. */
|
|
308
287
|
determinate: PropTypes.bool,
|
|
309
|
-
|
|
310
288
|
/** If `true`, the component is disabled. */
|
|
311
289
|
disabled: PropTypes.bool,
|
|
312
|
-
|
|
313
290
|
/** The id of the component. */
|
|
314
291
|
id: PropTypes.string,
|
|
315
|
-
|
|
316
292
|
/** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element. */
|
|
317
293
|
inputProps: PropTypes.object,
|
|
318
|
-
|
|
319
294
|
/** Pass a ref to the input element. */
|
|
320
295
|
inputRef: ref,
|
|
321
|
-
|
|
322
296
|
/** The name of the Radio is displayed on the interface. */
|
|
323
297
|
label: PropTypes.string,
|
|
324
|
-
|
|
325
298
|
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography--title) applied to the `Typography` label. */
|
|
326
299
|
labelProps: PropTypes.object,
|
|
327
|
-
|
|
328
300
|
/** The name of the Checkbox corresponds to the label displayed on the interface. */
|
|
329
301
|
name: PropTypes.string,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
|
|
302
|
+
/**
|
|
303
|
+
* Callback fired when the state is changed.
|
|
304
|
+
*
|
|
305
|
+
* You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
|
|
335
306
|
*/
|
|
336
307
|
onChange: PropTypes.func,
|
|
337
|
-
|
|
338
308
|
/** If `true`, the component is readonly. */
|
|
339
309
|
readOnly: PropTypes.bool,
|
|
340
|
-
|
|
341
310
|
/** If `true`, the label will indicate that the checkbox is required. */
|
|
342
311
|
required: PropTypes.bool,
|
|
343
|
-
|
|
344
312
|
/** The value of input */
|
|
345
313
|
value: PropTypes.any,
|
|
346
|
-
|
|
347
314
|
/** The width of checkbox. */
|
|
348
315
|
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
349
316
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { forwardRef, memo, useImperativeHandle, useLayoutEffect, useRef } from 'react';
|
|
5
5
|
import { css, jsx } from '@emotion/core';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -28,17 +28,14 @@ const Control = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
28
|
if (disabled) {
|
|
29
29
|
ref.current.classList.add(classes.disabled);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
if (!disabled && error) {
|
|
33
32
|
ref.current.classList.add(classes.error);
|
|
34
33
|
ref.current.querySelector('div.DGN-UI-InputBase').classList.add('danger');
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
return () => {
|
|
38
36
|
if (disabled) {
|
|
39
37
|
ref.current.classList.remove(classes.disabled);
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
if (!disabled && error) {
|
|
43
40
|
ref.current.classList.remove(classes.error);
|
|
44
41
|
ref.current.querySelector('div.DGN-UI-InputBase').classList.remove('danger');
|
|
@@ -48,20 +45,18 @@ const Control = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
48
45
|
useImperativeHandle(reference, () => {
|
|
49
46
|
const currentRef = ref.current || {};
|
|
50
47
|
const _instance = {}; // methods
|
|
51
|
-
|
|
52
48
|
_instance.__proto__ = {}; // hidden methods
|
|
53
|
-
|
|
54
49
|
currentRef.instance = _instance;
|
|
55
50
|
return currentRef;
|
|
56
51
|
});
|
|
57
|
-
return jsx("div", {
|
|
52
|
+
return jsx("div", {
|
|
53
|
+
...props,
|
|
58
54
|
className: ['DGN-UI-Control', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
59
55
|
css: controlRootCSS(classes),
|
|
60
56
|
style: style,
|
|
61
57
|
ref: ref
|
|
62
58
|
}, children);
|
|
63
59
|
}));
|
|
64
|
-
|
|
65
60
|
const controlRootCSS = classes => css`
|
|
66
61
|
${displayBlock}
|
|
67
62
|
${positionRelative}
|
|
@@ -76,7 +71,6 @@ const controlRootCSS = classes => css`
|
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
`;
|
|
79
|
-
|
|
80
74
|
Control.defaultProps = {
|
|
81
75
|
className: '',
|
|
82
76
|
style: {},
|
|
@@ -86,16 +80,12 @@ Control.defaultProps = {
|
|
|
86
80
|
Control.propTypes = {
|
|
87
81
|
/** children of the form control */
|
|
88
82
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.node]).isRequired,
|
|
89
|
-
|
|
90
83
|
/** the class for the form control */
|
|
91
84
|
className: PropTypes.string,
|
|
92
|
-
|
|
93
85
|
/** prevent all event if true, hide all icon */
|
|
94
86
|
disabled: PropTypes.bool,
|
|
95
|
-
|
|
96
87
|
/** error for input */
|
|
97
88
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
98
|
-
|
|
99
89
|
/** style of the component */
|
|
100
90
|
style: PropTypes.object
|
|
101
91
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// import { randomString, useOnClickOutside } from '../../../utils';
|
|
8
8
|
// import { blue4, blue13, brand, danger5, danger8, dark, dark4, dark6, dark8, info5, info8, success5, white } from '../../../styles/colors';
|
|
9
9
|
// // import CalendarNavigator from './calendar-navigator'
|
|
10
|
+
|
|
10
11
|
// const getElById = (id) => {
|
|
11
12
|
// return document.getElementById(id);
|
|
12
13
|
// };
|
|
@@ -35,8 +36,10 @@
|
|
|
35
36
|
// }
|
|
36
37
|
// }
|
|
37
38
|
// // if (/^(mm|MM)[\/\-](dd|DD)[\/\-]((y|Y){4})$/.test(format)) {
|
|
39
|
+
|
|
38
40
|
// // }
|
|
39
41
|
// // if (/^((y|Y){4})[\/\-](mm|MM)[\/\-](dd|DD)$/.test(format)) {
|
|
42
|
+
|
|
40
43
|
// // }
|
|
41
44
|
// };
|
|
42
45
|
// // const cutPX = (x) => {
|
|
@@ -46,6 +49,7 @@
|
|
|
46
49
|
// const weekdaysShort = ['H', 'B', 'T', 'N', 'S', 'B', 'CN'];
|
|
47
50
|
// const months = ['tháng 01', 'tháng 02', 'tháng 03', 'tháng 04', 'tháng 05', 'tháng 06', 'tháng 07', 'tháng 08', 'tháng 09', 'tháng 10', 'tháng 11', 'tháng 12'];
|
|
48
51
|
// const validateAlert = 'Invalidate value';
|
|
52
|
+
|
|
49
53
|
// const DatePicker = memo(forwardRef(({defaultValue, disabled, error, helperInvalid, helperValid, inputProps, inputRef, label, onChange, required, size, viewType, ...props}, ref) => {
|
|
50
54
|
// const Id = randomString(7, { allowSymbol: false, allowNumber: false });
|
|
51
55
|
// const IDs = {
|
|
@@ -69,6 +73,7 @@
|
|
|
69
73
|
// const inputContainerRef = useRef(null);
|
|
70
74
|
// const nowDate = !isNaN(Date.parse(defaultValue)) ? new Date(defaultValue) : new Date();
|
|
71
75
|
// useOnClickOutside(inputContainerRef, () => onClickOutside());
|
|
76
|
+
|
|
72
77
|
// const styles = {
|
|
73
78
|
// container: css`
|
|
74
79
|
// * {
|
|
@@ -520,6 +525,7 @@
|
|
|
520
525
|
// }
|
|
521
526
|
// `,
|
|
522
527
|
// };
|
|
528
|
+
|
|
523
529
|
// const getScrollParent = element => {
|
|
524
530
|
// const style = getComputedStyle (element);
|
|
525
531
|
// let scrollParent = window;
|
|
@@ -544,6 +550,7 @@
|
|
|
544
550
|
// return;
|
|
545
551
|
// }
|
|
546
552
|
// const { bottom, left, top } = target.getBoundingClientRect();
|
|
553
|
+
|
|
547
554
|
// if (top > window.innerHeight) {
|
|
548
555
|
// el.style.top = null;
|
|
549
556
|
// el.style.bottom = '5px';
|
|
@@ -613,6 +620,7 @@
|
|
|
613
620
|
// const lastDayIndex = changeDayOfWeek(lastTime);
|
|
614
621
|
// const firstDayIndex = changeDayOfWeek(date);
|
|
615
622
|
// const daysOfNextMonth = 7 - lastDayIndex;
|
|
623
|
+
|
|
616
624
|
// let days = [];
|
|
617
625
|
// let x = firstDayIndex;
|
|
618
626
|
// for (x; x > 0; x--) {
|
|
@@ -622,6 +630,7 @@
|
|
|
622
630
|
// else {
|
|
623
631
|
// days.push(`<td id='${IDs.daysOfPrevMonth + '-' + (prevLastDay - x + 1)}' class='days-of-month prev-date'>${prevLastDay - x + 1}</td>`);
|
|
624
632
|
// }
|
|
633
|
+
|
|
625
634
|
// }
|
|
626
635
|
// for (let i = 1; i <= lastDay; i++) {
|
|
627
636
|
// if (i === new Date().getDate() && date.getMonth() === new Date().getMonth() && date.getFullYear() === new Date().getFullYear()) {
|
|
@@ -636,7 +645,9 @@
|
|
|
636
645
|
// } else {
|
|
637
646
|
// days.push(`<td id='${IDs.daysOfNextMonth + '-' + j}' class='days-of-month next-date'>${j}</td>`);
|
|
638
647
|
// }
|
|
648
|
+
|
|
639
649
|
// }
|
|
650
|
+
|
|
640
651
|
// let table = '';
|
|
641
652
|
// table += '<tr>';
|
|
642
653
|
// for (let i = 0; i < weekdaysLong.length; i++){
|
|
@@ -656,6 +667,7 @@
|
|
|
656
667
|
// }
|
|
657
668
|
// monthDays.innerHTML = table;
|
|
658
669
|
// header.innerHTML = size === 'medium' ? `${months[date.getMonth()]} năm ${date.getFullYear()}` : addZeroToText(date.getMonth() + 1) + '/' + date.getFullYear();
|
|
670
|
+
|
|
659
671
|
// monthDays.querySelectorAll('.days-of-month.this-month').forEach((dc) => {
|
|
660
672
|
// dc.addEventListener('click', (e) => setActiveDay(e, date));
|
|
661
673
|
// });
|
|
@@ -817,13 +829,16 @@
|
|
|
817
829
|
// getElById(`${IDs.daysOfThisMonth + '-' + defaultTime.getDate()}`).classList.add('day-active');
|
|
818
830
|
// }
|
|
819
831
|
// };
|
|
832
|
+
|
|
820
833
|
// useEffect(() => {
|
|
821
834
|
// const input = inputRef.current;
|
|
822
835
|
// const container = ref.current;
|
|
823
836
|
// const scrollArea = getScrollParent(container);
|
|
837
|
+
|
|
824
838
|
// setPosition();
|
|
825
839
|
// renderCalendar(nowDate);
|
|
826
840
|
// checkDefaultValue(nowDate, input);
|
|
841
|
+
|
|
827
842
|
// scrollArea.addEventListener('scroll', setPosition);
|
|
828
843
|
// window.addEventListener('resize', setPosition);
|
|
829
844
|
// document.addEventListener('keydown', e => escKeyFunc(e));
|
|
@@ -843,6 +858,7 @@
|
|
|
843
858
|
// useEffect(() => {
|
|
844
859
|
// renderCalendar(nowDate)
|
|
845
860
|
// }, [size]);
|
|
861
|
+
|
|
846
862
|
// const RequireMemo = useMemo(() => ( required && <span css={styles.require}>*</span> ), [error, required]);
|
|
847
863
|
// const LabelMemo = useMemo(() => (
|
|
848
864
|
// <label css={styles.label} disabled={disabled}>
|
|
@@ -906,6 +922,7 @@
|
|
|
906
922
|
// {CalendarMemo}
|
|
907
923
|
// </div>
|
|
908
924
|
// ), [defaultValue, disabled, error, size, viewType]);
|
|
925
|
+
|
|
909
926
|
// return (
|
|
910
927
|
// <div {...props} css={styles.container} ref={ref}>
|
|
911
928
|
// {LabelMemo}
|
|
@@ -948,4 +965,5 @@
|
|
|
948
965
|
// /** view type of the form control */
|
|
949
966
|
// viewType : PropTypes.oneOf(['outlined', 'underlined']),
|
|
950
967
|
// };
|
|
968
|
+
|
|
951
969
|
// export default DatePicker;
|