rsuite 5.2.0 → 5.2.4
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/Button/styles/index.less +6 -0
- package/CHANGELOG.md +42 -0
- package/PanelGroup/styles/index.less +12 -12
- package/README.md +3 -44
- package/Sidenav/styles/index.less +4 -0
- package/Table/styles/index.less +0 -4
- package/cjs/Carousel/Carousel.d.ts +1 -1
- package/cjs/CheckTreePicker/CheckTreePicker.js +6 -3
- package/cjs/CheckTreePicker/utils.d.ts +1 -1
- package/cjs/CheckTreePicker/utils.js +7 -6
- package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
- package/cjs/DateRangePicker/Calendar.d.ts +2 -1
- package/cjs/DateRangePicker/Calendar.js +26 -5
- package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -0
- package/cjs/DateRangePicker/DateRangePicker.js +25 -3
- package/cjs/Dropdown/DropdownItem.js +16 -19
- package/cjs/Dropdown/useRenderDropdownItem.d.ts +2 -0
- package/cjs/Dropdown/useRenderDropdownItem.js +26 -0
- package/cjs/InputPicker/InputPicker.js +1 -1
- package/cjs/MaskedInput/MaskedInput.d.ts +5 -42
- package/cjs/MaskedInput/MaskedInput.js +9 -63
- package/cjs/MaskedInput/TextMask.d.ts +43 -0
- package/cjs/MaskedInput/TextMask.js +80 -0
- package/cjs/Menu/Menu.js +46 -34
- package/cjs/Menu/MenuItem.js +16 -12
- package/cjs/Modal/utils.js +9 -10
- package/cjs/Overlay/Position.js +7 -4
- package/cjs/Picker/PickerToggle.js +7 -5
- package/cjs/Picker/VirtualizedList.d.ts +29 -2
- package/cjs/Picker/utils.d.ts +6 -14
- package/cjs/Picker/utils.js +54 -33
- package/cjs/RadioGroup/RadioGroup.js +2 -2
- package/cjs/Rate/Rate.js +3 -1
- package/cjs/Sidenav/SidenavDropdownItem.js +17 -10
- package/cjs/TreePicker/TreePicker.js +6 -3
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +11 -6
- package/dist/rsuite-rtl.css +48 -6
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +48 -6
- package/dist/rsuite.js +349 -359
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.LICENSE.txt +9 -0
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Carousel/Carousel.d.ts +1 -1
- package/esm/CheckTreePicker/CheckTreePicker.js +6 -3
- package/esm/CheckTreePicker/utils.d.ts +1 -1
- package/esm/CheckTreePicker/utils.js +7 -6
- package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
- package/esm/DateRangePicker/Calendar.d.ts +2 -1
- package/esm/DateRangePicker/Calendar.js +27 -5
- package/esm/DateRangePicker/DateRangePicker.d.ts +2 -0
- package/esm/DateRangePicker/DateRangePicker.js +23 -3
- package/esm/Dropdown/DropdownItem.js +15 -19
- package/esm/Dropdown/useRenderDropdownItem.d.ts +2 -0
- package/esm/Dropdown/useRenderDropdownItem.js +18 -0
- package/esm/InputPicker/InputPicker.js +1 -1
- package/esm/MaskedInput/MaskedInput.d.ts +5 -42
- package/esm/MaskedInput/MaskedInput.js +9 -63
- package/esm/MaskedInput/TextMask.d.ts +43 -0
- package/esm/MaskedInput/TextMask.js +67 -0
- package/esm/Menu/Menu.js +46 -36
- package/esm/Menu/MenuItem.js +16 -12
- package/esm/Modal/utils.js +8 -7
- package/esm/Overlay/Position.js +6 -3
- package/esm/Picker/PickerToggle.js +7 -5
- package/esm/Picker/VirtualizedList.d.ts +29 -2
- package/esm/Picker/utils.d.ts +6 -14
- package/esm/Picker/utils.js +54 -33
- package/esm/RadioGroup/RadioGroup.js +2 -2
- package/esm/Rate/Rate.js +2 -1
- package/esm/Sidenav/SidenavDropdownItem.js +16 -10
- package/esm/TreePicker/TreePicker.js +6 -3
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +12 -5
- package/package.json +3 -3
|
@@ -10,7 +10,7 @@ export interface CarouselProps extends WithAsProps {
|
|
|
10
10
|
/** Button shape */
|
|
11
11
|
shape?: 'dot' | 'bar';
|
|
12
12
|
/** Callback fired when the active item changes */
|
|
13
|
-
onSelect
|
|
13
|
+
onSelect?: (index: number, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
14
|
/** Callback fired when a slide transition starts */
|
|
15
15
|
onSlideStart?: (index: number, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
16
|
/** Callback fired when a slide transition ends */
|
|
@@ -406,10 +406,13 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
406
406
|
}
|
|
407
407
|
}, [childrenKey, expandItemValues, getChildren, loadChildren, onExpand, setExpandItemValues, valueKey]);
|
|
408
408
|
usePublicMethods(ref, {
|
|
409
|
+
rootRef: inline ? treeViewRef : null,
|
|
409
410
|
triggerRef: triggerRef,
|
|
410
411
|
overlayRef: overlayRef,
|
|
411
|
-
targetRef: targetRef
|
|
412
|
-
|
|
412
|
+
targetRef: targetRef,
|
|
413
|
+
listRef: listRef,
|
|
414
|
+
inline: inline
|
|
415
|
+
});
|
|
413
416
|
var handleClean = useCallback(function (event) {
|
|
414
417
|
var target = event.target; // exclude searchBar
|
|
415
418
|
|
|
@@ -630,7 +633,7 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
630
633
|
}, style) : {};
|
|
631
634
|
return /*#__PURE__*/React.createElement("div", {
|
|
632
635
|
id: id ? id + "-listbox" : undefined,
|
|
633
|
-
ref:
|
|
636
|
+
ref: treeViewRef,
|
|
634
637
|
role: "tree",
|
|
635
638
|
"aria-multiselectable": true,
|
|
636
639
|
className: classes,
|
|
@@ -19,7 +19,7 @@ export interface TreeNodesType {
|
|
|
19
19
|
[key: string]: TreeNodeType;
|
|
20
20
|
}
|
|
21
21
|
export declare function isEveryChildChecked(nodes: TreeNodesType, parent: TreeNodeType): boolean;
|
|
22
|
-
export declare function isSomeChildChecked(nodes: TreeNodesType, parent: TreeNodeType): boolean;
|
|
22
|
+
export declare function isSomeChildChecked(nodes: TreeNodesType, parent: TreeNodeType, childrenKey: string): boolean;
|
|
23
23
|
export declare function isSomeNodeHasChildren(data: any[], childrenKey: string): boolean;
|
|
24
24
|
/**
|
|
25
25
|
* is all siblings nodes is uncheckable
|
|
@@ -18,18 +18,19 @@ export function isEveryChildChecked(nodes, parent) {
|
|
|
18
18
|
return nodes[child.refKey].check;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
export function isSomeChildChecked(nodes, parent) {
|
|
21
|
+
export function isSomeChildChecked(nodes, parent, childrenKey) {
|
|
22
22
|
if (_isNil(nodes[parent.refKey])) {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
var children = getChildrenByFlattenNodes(nodes, parent);
|
|
27
|
+
return children.some(function (child) {
|
|
28
|
+
var _child$childrenKey;
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if ((child === null || child === void 0 ? void 0 : (_child$childrenKey = child[childrenKey]) === null || _child$childrenKey === void 0 ? void 0 : _child$childrenKey.length) > 0) {
|
|
31
|
+
return isSomeChildChecked(nodes, child, childrenKey);
|
|
32
|
+
}
|
|
31
33
|
|
|
32
|
-
return children.some(function (child) {
|
|
33
34
|
return nodes[child.refKey].check;
|
|
34
35
|
});
|
|
35
36
|
}
|
|
@@ -184,7 +185,7 @@ export function getNodeCheckState(_ref) {
|
|
|
184
185
|
return CHECK_STATE.CHECK;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
if (isSomeChildChecked(nodes, node)) {
|
|
188
|
+
if (isSomeChildChecked(nodes, node, childrenKey)) {
|
|
188
189
|
nodes[node.refKey].checkAll = false;
|
|
189
190
|
return CHECK_STATE.INDETERMINATE;
|
|
190
191
|
}
|
|
@@ -65,10 +65,10 @@ var CheckboxGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
65
65
|
}, [disabled, handleChange, inline, isControlled, name, plaintext, readOnly, value]);
|
|
66
66
|
return /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
|
|
67
67
|
value: contextValue
|
|
68
|
-
}, plaintext ? /*#__PURE__*/React.createElement(Plaintext, {
|
|
68
|
+
}, plaintext ? /*#__PURE__*/React.createElement(Plaintext, _extends({
|
|
69
69
|
ref: ref,
|
|
70
70
|
localeKey: "notSelected"
|
|
71
|
-
}, value !== null && value !== void 0 && value.length ? children : null) : /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
71
|
+
}, rest), value !== null && value !== void 0 && value.length ? children : null) : /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
72
72
|
ref: ref,
|
|
73
73
|
role: "group",
|
|
74
74
|
className: classes
|
|
@@ -3,7 +3,7 @@ import { CalendarProps as CalendarCoreProps } from '../Calendar/Calendar';
|
|
|
3
3
|
import { ValueType } from './types';
|
|
4
4
|
import { RsRefForwardingComponent, WithAsProps } from '../@types/common';
|
|
5
5
|
import { DatePickerLocale } from '../locales';
|
|
6
|
-
declare type OmitCalendarCoreTypes = 'disabledDate' | 'onSelect' | 'onMouseMove' | 'calendarDate';
|
|
6
|
+
declare type OmitCalendarCoreTypes = 'disabledDate' | 'onSelect' | 'onMouseMove' | 'calendarDate' | 'onToggleMeridian';
|
|
7
7
|
export interface CalendarProps extends WithAsProps, Omit<CalendarCoreProps, OmitCalendarCoreTypes> {
|
|
8
8
|
calendarDate?: ValueType;
|
|
9
9
|
disabledDate?: (date: Date, selectValue: ValueType, type: string) => boolean;
|
|
@@ -15,6 +15,7 @@ export interface CalendarProps extends WithAsProps, Omit<CalendarCoreProps, Omit
|
|
|
15
15
|
locale?: DatePickerLocale;
|
|
16
16
|
onChangeCalendarDate?: (index: number, date: Date) => void;
|
|
17
17
|
onChangeCalendarTime?: (index: number, date: Date) => void;
|
|
18
|
+
onToggleMeridian: (index: number, event: React.MouseEvent) => void;
|
|
18
19
|
onMouseMove?: (date: Date) => void;
|
|
19
20
|
onSelect?: (date: Date, event?: React.SyntheticEvent) => void;
|
|
20
21
|
showOneCalendar?: boolean;
|
|
@@ -5,6 +5,15 @@ import React, { useCallback, useState } from 'react';
|
|
|
5
5
|
import { addMonths, isAfter, isSameMonth, setDate } from '../utils/dateUtils';
|
|
6
6
|
import CalendarCore, { CalendarState } from '../Calendar/Calendar';
|
|
7
7
|
import { DATERANGE_DISABLED_TARGET } from '../utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Omit the time in the date, which is used to compare and judge the date.
|
|
11
|
+
* eg: isAfter/isBefore
|
|
12
|
+
*/
|
|
13
|
+
function omitTime(date) {
|
|
14
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
18
|
var _props$as = props.as,
|
|
10
19
|
Component = _props$as === void 0 ? CalendarCore : _props$as,
|
|
@@ -18,10 +27,11 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
18
27
|
limitEndYear = props.limitEndYear,
|
|
19
28
|
onChangeCalendarDate = props.onChangeCalendarDate,
|
|
20
29
|
onChangeCalendarTime = props.onChangeCalendarTime,
|
|
30
|
+
onToggleMeridian = props.onToggleMeridian,
|
|
21
31
|
showOneCalendar = props.showOneCalendar,
|
|
22
32
|
_props$value = props.value,
|
|
23
33
|
value = _props$value === void 0 ? [] : _props$value,
|
|
24
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "calendarDate", "format", "disabledDate", "index", "limitEndYear", "onChangeCalendarDate", "onChangeCalendarTime", "showOneCalendar", "value"]);
|
|
34
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "calendarDate", "format", "disabledDate", "index", "limitEndYear", "onChangeCalendarDate", "onChangeCalendarTime", "onToggleMeridian", "showOneCalendar", "value"]);
|
|
25
35
|
|
|
26
36
|
var _useState = useState(),
|
|
27
37
|
calendarState = _useState[0],
|
|
@@ -40,6 +50,9 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
40
50
|
var handleChangePageTime = useCallback(function (nextPageDate) {
|
|
41
51
|
onChangeCalendarTime(index, nextPageDate);
|
|
42
52
|
}, [index, onChangeCalendarTime]);
|
|
53
|
+
var handleToggleMeridian = useCallback(function (event) {
|
|
54
|
+
onToggleMeridian(index, event);
|
|
55
|
+
}, [index, onToggleMeridian]);
|
|
43
56
|
var toggleMonthDropdown = useCallback(function () {
|
|
44
57
|
setCalendarState(calendarState === CalendarState.DROP_MONTH ? undefined : CalendarState.DROP_MONTH);
|
|
45
58
|
}, [calendarState]);
|
|
@@ -59,22 +72,30 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
59
72
|
onMoveBackward === null || onMoveBackward === void 0 ? void 0 : onMoveBackward(addMonths(getCalendarDate(), -1));
|
|
60
73
|
}, [getCalendarDate, onMoveBackward]);
|
|
61
74
|
var disabledBackward = useCallback(function () {
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
// Do not disable the Backward button on the first calendar.
|
|
64
76
|
if (index === 0) {
|
|
65
77
|
return false;
|
|
66
78
|
}
|
|
67
79
|
|
|
80
|
+
var startDate = setDate(addMonths(calendarDate[0], 1), 1);
|
|
81
|
+
var endDate = setDate(omitTime(calendarDate[1]), 1);
|
|
82
|
+
var after = isAfter(endDate, startDate);
|
|
68
83
|
return !after;
|
|
69
84
|
}, [calendarDate, index]);
|
|
70
85
|
var disabledForward = useCallback(function () {
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
// If only one calendar is displayed, do not disable
|
|
87
|
+
if (showOneCalendar) {
|
|
88
|
+
return false;
|
|
89
|
+
} // Do not disable the Forward button on the second calendar.
|
|
90
|
+
|
|
73
91
|
|
|
74
92
|
if (index === 1) {
|
|
75
93
|
return false;
|
|
76
94
|
}
|
|
77
95
|
|
|
96
|
+
var startDate = setDate(addMonths(omitTime(calendarDate[0]), 1), 1);
|
|
97
|
+
var endDate = setDate(omitTime(calendarDate[1]), 1);
|
|
98
|
+
var after = isAfter(endDate, startDate);
|
|
78
99
|
return !after;
|
|
79
100
|
}, [calendarDate, index, showOneCalendar]);
|
|
80
101
|
var disabledMonth = useCallback(function (date) {
|
|
@@ -110,6 +131,7 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
110
131
|
onMoveForward: handleMoveForward,
|
|
111
132
|
onToggleMonthDropdown: toggleMonthDropdown,
|
|
112
133
|
onToggleTimeDropdown: toggleTimeDropdown,
|
|
134
|
+
onToggleMeridian: handleToggleMeridian,
|
|
113
135
|
calendarDate: getCalendarDate(),
|
|
114
136
|
ref: ref
|
|
115
137
|
}));
|
|
@@ -19,6 +19,8 @@ export interface DateRangePickerProps extends PickerBaseProps, FormControlBasePr
|
|
|
19
19
|
showWeekNumbers?: boolean;
|
|
20
20
|
/** Show only one calendar select */
|
|
21
21
|
showOneCalendar?: boolean;
|
|
22
|
+
/** Meridian format */
|
|
23
|
+
showMeridian?: boolean;
|
|
22
24
|
/** Set default date for calendar */
|
|
23
25
|
defaultCalendarValue?: ValueType;
|
|
24
26
|
/** The character that separates two dates */
|
|
@@ -52,6 +52,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
52
52
|
_props$showOneCalenda = props.showOneCalendar,
|
|
53
53
|
showOneCalendar = _props$showOneCalenda === void 0 ? false : _props$showOneCalenda,
|
|
54
54
|
showWeekNumbers = props.showWeekNumbers,
|
|
55
|
+
showMeridian = props.showMeridian,
|
|
55
56
|
style = props.style,
|
|
56
57
|
toggleAs = props.toggleAs,
|
|
57
58
|
valueProp = props.value,
|
|
@@ -64,7 +65,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
64
65
|
onOk = props.onOk,
|
|
65
66
|
onOpen = props.onOpen,
|
|
66
67
|
onSelect = props.onSelect,
|
|
67
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "style", "toggleAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect"]);
|
|
68
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "showMeridian", "style", "toggleAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect"]);
|
|
68
69
|
|
|
69
70
|
var _useClassNames = useClassNames(classPrefix),
|
|
70
71
|
merge = _useClassNames.merge,
|
|
@@ -344,6 +345,22 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
344
345
|
});
|
|
345
346
|
handleChangeCalendarDate(index, date);
|
|
346
347
|
}, [handleChangeCalendarDate]);
|
|
348
|
+
/**
|
|
349
|
+
* The callback triggered when PM/AM is switched.
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
var handleToggleMeridian = useCallback(function (index) {
|
|
353
|
+
var next = Array.from(calendarDate);
|
|
354
|
+
var clonedDate = new Date(next[index].valueOf());
|
|
355
|
+
var hours = DateUtils.getHours(clonedDate);
|
|
356
|
+
var nextHours = hours >= 12 ? hours - 12 : hours + 12;
|
|
357
|
+
next[index] = DateUtils.setHours(clonedDate, nextHours);
|
|
358
|
+
setCalendarDate(next); // If the value already exists, update the value again.
|
|
359
|
+
|
|
360
|
+
if (selectValue.length === 2) {
|
|
361
|
+
setSelectValue(next);
|
|
362
|
+
}
|
|
363
|
+
}, [calendarDate, selectValue]);
|
|
347
364
|
/**
|
|
348
365
|
* Toolbar operation callback function
|
|
349
366
|
*/
|
|
@@ -511,10 +528,12 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
511
528
|
showOneCalendar: showOneCalendar,
|
|
512
529
|
showWeekNumbers: showWeekNumbers,
|
|
513
530
|
value: selectValue,
|
|
531
|
+
showMeridian: showMeridian,
|
|
514
532
|
onChangeCalendarDate: handleChangeCalendarDate,
|
|
515
533
|
onChangeCalendarTime: handleChangeCalendarTime,
|
|
516
534
|
onMouseMove: handleMouseMove,
|
|
517
|
-
onSelect: handleSelectValueChange
|
|
535
|
+
onSelect: handleSelectValueChange,
|
|
536
|
+
onToggleMeridian: handleToggleMeridian
|
|
518
537
|
};
|
|
519
538
|
return /*#__PURE__*/React.createElement(PickerOverlay, {
|
|
520
539
|
className: classes,
|
|
@@ -609,11 +628,12 @@ DateRangePicker.propTypes = _extends({}, pickerPropTypes, {
|
|
|
609
628
|
isoWeek: PropTypes.bool,
|
|
610
629
|
oneTap: PropTypes.bool,
|
|
611
630
|
limitEndYear: PropTypes.number,
|
|
612
|
-
showWeekNumbers: PropTypes.bool,
|
|
613
631
|
onChange: PropTypes.func,
|
|
614
632
|
onOk: PropTypes.func,
|
|
615
633
|
disabledDate: PropTypes.func,
|
|
616
634
|
onSelect: PropTypes.func,
|
|
635
|
+
showWeekNumbers: PropTypes.bool,
|
|
636
|
+
showMeridian: PropTypes.bool,
|
|
617
637
|
showOneCalendar: PropTypes.bool
|
|
618
638
|
});
|
|
619
639
|
export default DateRangePicker;
|
|
@@ -15,6 +15,7 @@ import SafeAnchor from '../SafeAnchor';
|
|
|
15
15
|
import NavContext from '../Nav/NavContext';
|
|
16
16
|
import useInternalId from '../utils/useInternalId';
|
|
17
17
|
import { DropdownActionType } from './DropdownState';
|
|
18
|
+
import { useRenderDropdownItem } from './useRenderDropdownItem';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The <Dropdown.Item> API
|
|
@@ -88,15 +89,7 @@ var DropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
}, [internalId, selected, dispatch]);
|
|
91
|
-
var renderDropdownItem =
|
|
92
|
-
if (Component === 'li') {
|
|
93
|
-
return ui;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
97
|
-
role: "none presentation"
|
|
98
|
-
}, ui);
|
|
99
|
-
}, [Component]);
|
|
92
|
+
var renderDropdownItem = useRenderDropdownItem(Component);
|
|
100
93
|
|
|
101
94
|
if (sidenav !== null && sidenav !== void 0 && sidenav.expanded) {
|
|
102
95
|
return /*#__PURE__*/React.createElement(SidenavDropdownItem, _extends({
|
|
@@ -105,18 +98,19 @@ var DropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
if (divider) {
|
|
108
|
-
return renderDropdownItem(
|
|
101
|
+
return renderDropdownItem(_extends({
|
|
109
102
|
ref: ref,
|
|
110
|
-
role:
|
|
103
|
+
role: 'separator',
|
|
111
104
|
className: merge(prefix('divider'), className)
|
|
112
|
-
}, restProps))
|
|
105
|
+
}, restProps));
|
|
113
106
|
}
|
|
114
107
|
|
|
115
108
|
if (panel) {
|
|
116
|
-
return renderDropdownItem(
|
|
109
|
+
return renderDropdownItem(_extends({
|
|
117
110
|
ref: ref,
|
|
118
|
-
className: merge(prefix('panel'), className)
|
|
119
|
-
|
|
111
|
+
className: merge(prefix('panel'), className),
|
|
112
|
+
children: children
|
|
113
|
+
}, restProps));
|
|
120
114
|
}
|
|
121
115
|
|
|
122
116
|
if (navbar) {
|
|
@@ -172,12 +166,14 @@ var DropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
172
166
|
dataAttributes['data-event-key-type'] = typeof eventKey;
|
|
173
167
|
}
|
|
174
168
|
|
|
175
|
-
return renderDropdownItem(
|
|
169
|
+
return renderDropdownItem(_extends({
|
|
176
170
|
ref: mergeRefs(ref, menuitemRef),
|
|
177
171
|
className: classes
|
|
178
|
-
}, menuitem, dataAttributes, restProps
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
}, menuitem, dataAttributes, restProps, {
|
|
173
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
174
|
+
className: prefix('menu-icon')
|
|
175
|
+
}), children)
|
|
176
|
+
}));
|
|
181
177
|
});
|
|
182
178
|
});
|
|
183
179
|
DropdownItem.displayName = 'Dropdown.Item';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
export function useRenderDropdownItem(Component) {
|
|
3
|
+
return useCallback(function (props, OverrideComponent) {
|
|
4
|
+
if (Component === 'li') {
|
|
5
|
+
if (OverrideComponent) {
|
|
6
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
7
|
+
role: "none presentation"
|
|
8
|
+
}, /*#__PURE__*/React.createElement(OverrideComponent, props));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return /*#__PURE__*/React.createElement(Component, props);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
15
|
+
role: "none presentation"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(Component, props));
|
|
17
|
+
}, [Component]);
|
|
18
|
+
}
|
|
@@ -666,7 +666,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
666
666
|
var plaintextProps = {}; // TagPicker has -6px margin-left on the plaintext wrapper
|
|
667
667
|
// for fixing margin-left on tags from 2nd line on
|
|
668
668
|
|
|
669
|
-
if (multi) {
|
|
669
|
+
if (multi && hasValue) {
|
|
670
670
|
plaintextProps.style = {
|
|
671
671
|
marginLeft: -6
|
|
672
672
|
};
|
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface TextMaskProps {
|
|
7
|
-
/**
|
|
8
|
-
* `guide` is a boolean that tells the component whether to be in guide or no guide mode.
|
|
9
|
-
*/
|
|
10
|
-
guide?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* `mask` is an array or a function that defines how the user input is going to be masked.
|
|
13
|
-
*/
|
|
14
|
-
mask?: MaskType | MaskFunctionType | boolean;
|
|
15
|
-
/**
|
|
16
|
-
* `showMask` is a boolean that tells the Text Mask component to display the mask as a placeholder
|
|
17
|
-
* in place of the regular placeholder when the input element value is empty.
|
|
18
|
-
*/
|
|
19
|
-
showMask?: boolean;
|
|
20
|
-
/** The placeholder character represents the fillable spot in the mask. The default placeholder character is underscore, _. */
|
|
21
|
-
placeholderChar?: string;
|
|
22
|
-
/** `keepCharPositions` changes the general behavior of the Text Mask component. */
|
|
23
|
-
keepCharPositions?: boolean;
|
|
24
|
-
/** You can provide a `pipe` function that will give you the opportunity to modify the conformed value before it is displayed on the screen. */
|
|
25
|
-
pipe?: (conformedValue: string, config: ConfigType) => string;
|
|
26
|
-
}
|
|
27
|
-
export declare type MaskedInputProps = TextMaskProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
28
|
-
/** Custom rendering DOM */
|
|
29
|
-
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
30
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
-
value?: string | number;
|
|
32
|
-
readOnly?: boolean;
|
|
33
|
-
disabled?: boolean;
|
|
34
|
-
};
|
|
35
|
-
declare const MaskedInput: React.ForwardRefExoticComponent<TextMaskProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
36
|
-
/** Custom rendering DOM */
|
|
37
|
-
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
38
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
39
|
-
value?: string | number;
|
|
40
|
-
readOnly?: boolean;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
} & React.RefAttributes<HTMLInputElement>>;
|
|
1
|
+
import { InputProps } from '../Input';
|
|
2
|
+
import type { TextMaskProps } from './TextMask';
|
|
3
|
+
import { RsRefForwardingComponent } from '../@types/common';
|
|
4
|
+
export declare type MaskedInputProps = Omit<TextMaskProps, 'onChange'> & Omit<InputProps, 'type'>;
|
|
5
|
+
declare const MaskedInput: RsRefForwardingComponent<'input', MaskedInputProps>;
|
|
43
6
|
export default MaskedInput;
|
|
@@ -1,67 +1,13 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
import React
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import createTextMaskInputElement from './createTextMaskInputElement';
|
|
7
|
-
import { mergeRefs } from '../utils';
|
|
8
|
-
/**
|
|
9
|
-
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var defaultRender = function defaultRender(ref, props) {
|
|
13
|
-
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
-
ref: ref
|
|
15
|
-
}, props));
|
|
16
|
-
};
|
|
17
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import TextMask from './TextMask';
|
|
4
|
+
import Input from '../Input';
|
|
18
5
|
var MaskedInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
-
var
|
|
20
|
-
_props$
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
pipe = props.pipe,
|
|
26
|
-
_props$render = props.render,
|
|
27
|
-
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
28
|
-
onChange = props.onChange,
|
|
29
|
-
rest = _objectWithoutPropertiesLoose(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
30
|
-
|
|
31
|
-
var inputRef = useRef(null);
|
|
32
|
-
var textMaskInputElement = useRef();
|
|
33
|
-
var initTextMask = useCallback(function () {
|
|
34
|
-
var _textMaskInputElement;
|
|
35
|
-
|
|
36
|
-
textMaskInputElement.current = createTextMaskInputElement(_extends({
|
|
37
|
-
inputElement: inputRef.current
|
|
38
|
-
}, props));
|
|
39
|
-
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
40
|
-
}, [props, value]);
|
|
41
|
-
var handleChange = useCallback(function (event) {
|
|
42
|
-
var _textMaskInputElement2;
|
|
43
|
-
|
|
44
|
-
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
45
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
46
|
-
}, [onChange]);
|
|
47
|
-
useEffect(function () {
|
|
48
|
-
initTextMask();
|
|
49
|
-
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
50
|
-
return render(mergeRefs(inputRef, ref), _extends({
|
|
51
|
-
onChange: handleChange,
|
|
52
|
-
defaultValue: value
|
|
53
|
-
}, omit(rest, ['keepCharPositions'])));
|
|
6
|
+
var _props$as = props.as,
|
|
7
|
+
inputAs = _props$as === void 0 ? TextMask : _props$as;
|
|
8
|
+
return /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
9
|
+
as: inputAs,
|
|
10
|
+
ref: ref
|
|
11
|
+
}));
|
|
54
12
|
});
|
|
55
|
-
MaskedInput.displayName = 'MaskedInput';
|
|
56
|
-
MaskedInput.propTypes = {
|
|
57
|
-
render: PropTypes.func,
|
|
58
|
-
onChange: PropTypes.func,
|
|
59
|
-
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.bool]).isRequired,
|
|
60
|
-
guide: PropTypes.bool,
|
|
61
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
62
|
-
pipe: PropTypes.func,
|
|
63
|
-
placeholderChar: PropTypes.string,
|
|
64
|
-
keepCharPositions: PropTypes.bool,
|
|
65
|
-
showMask: PropTypes.bool
|
|
66
|
-
};
|
|
67
13
|
export default MaskedInput;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MaskType, MaskFunctionType, ConfigType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
5
|
+
*/
|
|
6
|
+
interface TextMaskBaseProps {
|
|
7
|
+
/**
|
|
8
|
+
* `guide` is a boolean that tells the component whether to be in guide or no guide mode.
|
|
9
|
+
*/
|
|
10
|
+
guide?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* `mask` is an array or a function that defines how the user input is going to be masked.
|
|
13
|
+
*/
|
|
14
|
+
mask?: MaskType | MaskFunctionType | boolean;
|
|
15
|
+
/**
|
|
16
|
+
* `showMask` is a boolean that tells the Text Mask component to display the mask as a placeholder
|
|
17
|
+
* in place of the regular placeholder when the input element value is empty.
|
|
18
|
+
*/
|
|
19
|
+
showMask?: boolean;
|
|
20
|
+
/** The placeholder character represents the fillable spot in the mask. The default placeholder character is underscore, _. */
|
|
21
|
+
placeholderChar?: string;
|
|
22
|
+
/** `keepCharPositions` changes the general behavior of the Text Mask component. */
|
|
23
|
+
keepCharPositions?: boolean;
|
|
24
|
+
/** You can provide a `pipe` function that will give you the opportunity to modify the conformed value before it is displayed on the screen. */
|
|
25
|
+
pipe?: (conformedValue: string, config: ConfigType) => string;
|
|
26
|
+
}
|
|
27
|
+
export declare type TextMaskProps = TextMaskBaseProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
28
|
+
/** Custom rendering DOM */
|
|
29
|
+
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
30
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
+
value?: string | number;
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare const TextMask: React.ForwardRefExoticComponent<TextMaskBaseProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
36
|
+
/** Custom rendering DOM */
|
|
37
|
+
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
38
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
39
|
+
value?: string | number;
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
43
|
+
export default TextMask;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import omit from 'lodash/omit';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import createTextMaskInputElement from './createTextMaskInputElement';
|
|
7
|
+
import { mergeRefs } from '../utils';
|
|
8
|
+
/**
|
|
9
|
+
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var defaultRender = function defaultRender(ref, props) {
|
|
13
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
+
ref: ref
|
|
15
|
+
}, props));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var TextMask = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
+
var mask = props.mask,
|
|
20
|
+
_props$guide = props.guide,
|
|
21
|
+
guide = _props$guide === void 0 ? true : _props$guide,
|
|
22
|
+
placeholderChar = props.placeholderChar,
|
|
23
|
+
value = props.value,
|
|
24
|
+
showMask = props.showMask,
|
|
25
|
+
pipe = props.pipe,
|
|
26
|
+
_props$render = props.render,
|
|
27
|
+
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
28
|
+
onChange = props.onChange,
|
|
29
|
+
rest = _objectWithoutPropertiesLoose(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
30
|
+
|
|
31
|
+
var inputRef = useRef(null);
|
|
32
|
+
var textMaskInputElement = useRef();
|
|
33
|
+
var initTextMask = useCallback(function () {
|
|
34
|
+
var _textMaskInputElement;
|
|
35
|
+
|
|
36
|
+
textMaskInputElement.current = createTextMaskInputElement(_extends({
|
|
37
|
+
inputElement: inputRef.current
|
|
38
|
+
}, props));
|
|
39
|
+
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
40
|
+
}, [props, value]);
|
|
41
|
+
var handleChange = useCallback(function (event) {
|
|
42
|
+
var _textMaskInputElement2;
|
|
43
|
+
|
|
44
|
+
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
46
|
+
}, [onChange]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
initTextMask();
|
|
49
|
+
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
50
|
+
return render(mergeRefs(inputRef, ref), _extends({
|
|
51
|
+
onChange: handleChange,
|
|
52
|
+
defaultValue: value
|
|
53
|
+
}, omit(rest, ['keepCharPositions'])));
|
|
54
|
+
});
|
|
55
|
+
TextMask.displayName = 'TextMask';
|
|
56
|
+
TextMask.propTypes = {
|
|
57
|
+
render: PropTypes.func,
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.bool]).isRequired,
|
|
60
|
+
guide: PropTypes.bool,
|
|
61
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
62
|
+
pipe: PropTypes.func,
|
|
63
|
+
placeholderChar: PropTypes.string,
|
|
64
|
+
keepCharPositions: PropTypes.bool,
|
|
65
|
+
showMask: PropTypes.bool
|
|
66
|
+
};
|
|
67
|
+
export default TextMask;
|