rsuite 5.0.0 → 5.1.0
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/CHANGELOG.md +67 -6
- package/Grid/styles/index.less +1 -2
- package/IconButton/styles/index.less +1 -1
- package/MaskedInput/package.json +7 -0
- package/MultiCascader/styles/index.less +3 -0
- package/Navbar/styles/index.less +8 -0
- package/Picker/styles/index.less +1 -1
- package/Picker/styles/mixin.less +1 -1
- package/README.md +16 -10
- package/Sidenav/styles/index.less +13 -16
- package/Toggle/styles/index.less +20 -0
- package/Toggle/styles/mixin.less +12 -0
- package/Uploader/styles/index.less +10 -1
- package/cjs/@types/common.d.ts +0 -1
- package/cjs/Animation/Collapse.js +8 -8
- package/cjs/AutoComplete/AutoComplete.js +10 -14
- package/cjs/Badge/Badge.js +6 -10
- package/cjs/Breadcrumb/Breadcrumb.js +8 -12
- package/cjs/Breadcrumb/BreadcrumbItem.js +4 -8
- package/cjs/Button/Button.js +6 -10
- package/cjs/ButtonGroup/ButtonGroup.js +6 -10
- package/cjs/Calendar/Calendar.js +4 -8
- package/cjs/Calendar/CalendarPanel.js +6 -10
- package/cjs/Calendar/Header.js +4 -8
- package/cjs/Calendar/MonthDropdown.js +10 -14
- package/cjs/Calendar/MonthDropdownItem.js +6 -10
- package/cjs/Calendar/Table.js +6 -10
- package/cjs/Calendar/TableHeaderRow.js +4 -7
- package/cjs/Calendar/TableRow.js +7 -11
- package/cjs/Calendar/TimeDropdown.js +4 -8
- package/cjs/Calendar/View.js +4 -8
- package/cjs/Carousel/Carousel.js +10 -14
- package/cjs/Cascader/Cascader.js +29 -26
- package/cjs/Cascader/DropdownMenu.js +19 -21
- package/cjs/CheckPicker/CheckPicker.js +33 -29
- package/cjs/CheckTreePicker/CheckTreeNode.js +4 -6
- package/cjs/CheckTreePicker/CheckTreePicker.js +47 -35
- package/cjs/Checkbox/Checkbox.js +8 -13
- package/cjs/CheckboxGroup/CheckboxGroup.d.ts +1 -12
- package/cjs/CheckboxGroup/CheckboxGroup.js +7 -13
- package/cjs/CheckboxGroup/CheckboxGroupContext.d.ts +13 -0
- package/cjs/CheckboxGroup/CheckboxGroupContext.js +12 -0
- package/cjs/CheckboxGroup/index.d.ts +4 -3
- package/cjs/CheckboxGroup/index.js +6 -4
- package/cjs/Col/Col.js +3 -2
- package/cjs/Container/Container.js +4 -7
- package/cjs/DOMHelper/index.d.ts +1 -1
- package/cjs/DatePicker/DatePicker.js +27 -22
- package/cjs/DatePicker/Toolbar.js +4 -8
- package/cjs/DateRangePicker/Calendar.js +12 -14
- package/cjs/DateRangePicker/DateRangePicker.js +40 -33
- package/cjs/Divider/Divider.js +4 -8
- package/cjs/Drawer/Drawer.js +8 -10
- package/cjs/Dropdown/Dropdown.js +8 -12
- package/cjs/Dropdown/DropdownItem.js +25 -22
- package/cjs/Dropdown/DropdownMenu.js +2 -6
- package/cjs/Dropdown/DropdownToggle.js +4 -8
- package/cjs/FlexboxGrid/FlexboxGrid.js +8 -12
- package/cjs/FlexboxGrid/FlexboxGridItem.js +8 -12
- package/cjs/Form/Form.js +12 -16
- package/cjs/FormControl/FormControl.js +6 -2
- package/cjs/IconButton/IconButton.js +4 -8
- package/cjs/Input/Input.js +6 -10
- package/cjs/InputNumber/InputNumber.js +14 -18
- package/cjs/InputPicker/InputAutosize.js +2 -4
- package/cjs/InputPicker/InputPicker.js +32 -30
- package/cjs/List/List.js +12 -16
- package/cjs/List/ListItem.js +6 -10
- package/cjs/Loader/Loader.js +6 -10
- package/cjs/MaskedInput/MaskedInput.d.ts +43 -0
- package/cjs/MaskedInput/MaskedInput.js +80 -0
- package/cjs/MaskedInput/adjustCaretPosition.d.ts +11 -0
- package/cjs/MaskedInput/adjustCaretPosition.js +218 -0
- package/cjs/MaskedInput/conformToMask.d.ts +8 -0
- package/cjs/MaskedInput/conformToMask.js +247 -0
- package/cjs/MaskedInput/createTextMaskInputElement.d.ts +7 -0
- package/cjs/MaskedInput/createTextMaskInputElement.js +226 -0
- package/cjs/MaskedInput/index.d.ts +3 -0
- package/cjs/MaskedInput/index.js +11 -0
- package/cjs/MaskedInput/types.d.ts +10 -0
- package/cjs/{@types/icons.js → MaskedInput/types.js} +0 -0
- package/cjs/MaskedInput/utilities.d.ts +7 -0
- package/cjs/MaskedInput/utilities.js +47 -0
- package/cjs/Menu/Menu.d.ts +0 -1
- package/cjs/Menu/Menu.js +3 -5
- package/cjs/Message/Message.js +8 -12
- package/cjs/Modal/Modal.d.ts +1 -10
- package/cjs/Modal/Modal.js +35 -27
- package/cjs/Modal/ModalBody.js +6 -10
- package/cjs/Modal/ModalContext.d.ts +12 -0
- package/cjs/Modal/ModalContext.js +12 -0
- package/cjs/Modal/ModalDialog.js +8 -8
- package/cjs/Modal/ModalHeader.js +8 -12
- package/cjs/Modal/ModalTitle.d.ts +3 -2
- package/cjs/Modal/ModalTitle.js +43 -4
- package/cjs/MultiCascader/DropdownMenu.js +21 -23
- package/cjs/MultiCascader/MultiCascader.js +35 -32
- package/cjs/Nav/Nav.js +6 -10
- package/cjs/Navbar/Navbar.js +6 -9
- package/cjs/Notification/Notification.js +6 -10
- package/cjs/Overlay/Modal.js +11 -18
- package/cjs/Overlay/Overlay.js +2 -5
- package/cjs/Overlay/OverlayTrigger.js +9 -9
- package/cjs/Overlay/Position.js +4 -8
- package/cjs/Overlay/positionUtils.js +1 -1
- package/cjs/Pagination/Pagination.js +10 -13
- package/cjs/Pagination/PaginationButton.js +4 -8
- package/cjs/Pagination/PaginationGroup.js +11 -12
- package/cjs/Panel/Panel.js +6 -10
- package/cjs/PanelGroup/PanelGroup.js +4 -8
- package/cjs/Picker/DropdownMenu.js +2 -3
- package/cjs/Picker/DropdownMenuGroup.js +4 -8
- package/cjs/Picker/DropdownMenuItem.js +4 -8
- package/cjs/Picker/PickerToggle.js +15 -14
- package/cjs/Picker/propTypes.d.ts +2 -16
- package/cjs/Picker/propTypes.js +4 -17
- package/cjs/Picker/utils.js +14 -9
- package/cjs/Placeholder/PlaceholderGraph.js +6 -10
- package/cjs/Placeholder/PlaceholderGrid.js +12 -16
- package/cjs/Placeholder/PlaceholderParagraph.js +10 -14
- package/cjs/Popover/Popover.js +4 -8
- package/cjs/Progress/ProgressCircle.js +18 -22
- package/cjs/Progress/ProgressLine.js +8 -12
- package/cjs/Radio/Radio.js +6 -11
- package/cjs/RadioGroup/RadioGroup.js +6 -9
- package/cjs/RangeSlider/RangeSlider.js +17 -20
- package/cjs/Rate/Character.js +4 -7
- package/cjs/Rate/Rate.js +14 -18
- package/cjs/Ripple/Ripple.js +4 -8
- package/cjs/SelectPicker/SelectPicker.js +31 -28
- package/cjs/Sidebar/Sidebar.js +6 -10
- package/cjs/Sidenav/Sidenav.js +8 -11
- package/cjs/Sidenav/SidenavDropdown.d.ts +6 -1
- package/cjs/Sidenav/SidenavDropdown.js +19 -19
- package/cjs/Sidenav/SidenavDropdownCollapse.js +2 -6
- package/cjs/Sidenav/SidenavDropdownItem.js +4 -8
- package/cjs/Sidenav/SidenavDropdownMenu.js +4 -8
- package/cjs/Sidenav/SidenavToggle.js +4 -8
- package/cjs/Slider/Graduated.js +4 -8
- package/cjs/Slider/Handle.d.ts +2 -0
- package/cjs/Slider/Handle.js +23 -12
- package/cjs/Slider/Input.d.ts +3 -0
- package/cjs/Slider/Input.js +35 -0
- package/cjs/Slider/Mark.js +4 -8
- package/cjs/Slider/ProgressBar.js +4 -8
- package/cjs/Slider/Slider.d.ts +0 -3
- package/cjs/Slider/Slider.js +14 -22
- package/cjs/Steps/StepItem.js +4 -7
- package/cjs/Steps/Steps.js +8 -12
- package/cjs/Table/Table.d.ts +7 -7
- package/cjs/Table/Table.js +5 -5
- package/cjs/TagInput/index.js +4 -6
- package/cjs/TagPicker/index.d.ts +1 -1
- package/cjs/TagPicker/index.js +4 -6
- package/cjs/Timeline/Timeline.js +6 -11
- package/cjs/Timeline/TimelineItem.js +4 -8
- package/cjs/Toggle/Toggle.d.ts +2 -0
- package/cjs/Toggle/Toggle.js +27 -13
- package/cjs/Tooltip/Tooltip.js +4 -8
- package/cjs/Tree/Tree.d.ts +6 -0
- package/cjs/TreePicker/TreeNode.js +4 -6
- package/cjs/TreePicker/TreePicker.js +38 -29
- package/cjs/Uploader/UploadFileItem.d.ts +1 -0
- package/cjs/Uploader/UploadFileItem.js +42 -33
- package/cjs/Uploader/UploadTrigger.js +4 -8
- package/cjs/Uploader/Uploader.d.ts +2 -0
- package/cjs/Uploader/Uploader.js +28 -29
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +5 -1
- package/cjs/locales/fa_IR.d.ts +105 -0
- package/cjs/locales/fa_IR.js +84 -0
- package/cjs/locales/index.d.ts +1 -0
- package/cjs/locales/index.js +6 -2
- package/cjs/toaster/ToastContainer.js +6 -10
- package/cjs/utils/createComponent.d.ts +1 -2
- package/cjs/utils/createComponent.js +10 -13
- package/cjs/utils/previewFile.d.ts +1 -0
- package/cjs/utils/previewFile.js +11 -0
- package/cjs/utils/useUniqueId.d.ts +3 -1
- package/cjs/utils/useUniqueId.js +4 -2
- package/dist/rsuite-rtl.css +115 -44
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +115 -44
- package/dist/rsuite.js +233 -144
- 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.map +1 -1
- package/esm/@types/common.d.ts +0 -1
- package/esm/Animation/Collapse.js +8 -8
- package/esm/AutoComplete/AutoComplete.js +11 -14
- package/esm/Badge/Badge.js +6 -9
- package/esm/Breadcrumb/Breadcrumb.js +8 -11
- package/esm/Breadcrumb/BreadcrumbItem.js +4 -7
- package/esm/Button/Button.js +6 -9
- package/esm/ButtonGroup/ButtonGroup.js +6 -9
- package/esm/Calendar/Calendar.js +4 -7
- package/esm/Calendar/CalendarPanel.js +6 -9
- package/esm/Calendar/Header.js +4 -7
- package/esm/Calendar/MonthDropdown.js +10 -13
- package/esm/Calendar/MonthDropdownItem.js +6 -9
- package/esm/Calendar/Table.js +6 -9
- package/esm/Calendar/TableHeaderRow.js +4 -7
- package/esm/Calendar/TableRow.js +7 -10
- package/esm/Calendar/TimeDropdown.js +4 -7
- package/esm/Calendar/View.js +4 -7
- package/esm/Carousel/Carousel.js +10 -13
- package/esm/Cascader/Cascader.js +29 -26
- package/esm/Cascader/DropdownMenu.js +19 -21
- package/esm/CheckPicker/CheckPicker.js +33 -29
- package/esm/CheckTreePicker/CheckTreeNode.js +4 -6
- package/esm/CheckTreePicker/CheckTreePicker.js +47 -37
- package/esm/Checkbox/Checkbox.js +8 -12
- package/esm/CheckboxGroup/CheckboxGroup.d.ts +1 -12
- package/esm/CheckboxGroup/CheckboxGroup.js +5 -8
- package/esm/CheckboxGroup/CheckboxGroupContext.d.ts +13 -0
- package/esm/CheckboxGroup/CheckboxGroupContext.js +2 -0
- package/esm/CheckboxGroup/index.d.ts +4 -3
- package/esm/CheckboxGroup/index.js +2 -2
- package/esm/Col/Col.js +3 -2
- package/esm/Container/Container.js +4 -7
- package/esm/DOMHelper/index.d.ts +1 -1
- package/esm/DatePicker/DatePicker.js +27 -23
- package/esm/DatePicker/Toolbar.js +5 -8
- package/esm/DateRangePicker/Calendar.js +12 -13
- package/esm/DateRangePicker/DateRangePicker.js +40 -34
- package/esm/Divider/Divider.js +4 -7
- package/esm/Drawer/Drawer.js +8 -9
- package/esm/Dropdown/Dropdown.js +9 -12
- package/esm/Dropdown/DropdownItem.js +26 -22
- package/esm/Dropdown/DropdownMenu.js +3 -6
- package/esm/Dropdown/DropdownToggle.js +4 -7
- package/esm/FlexboxGrid/FlexboxGrid.js +8 -11
- package/esm/FlexboxGrid/FlexboxGridItem.js +8 -11
- package/esm/Form/Form.js +12 -15
- package/esm/FormControl/FormControl.js +6 -2
- package/esm/IconButton/IconButton.js +4 -7
- package/esm/Input/Input.js +6 -9
- package/esm/InputNumber/InputNumber.js +14 -17
- package/esm/InputPicker/InputAutosize.js +2 -4
- package/esm/InputPicker/InputPicker.js +32 -30
- package/esm/List/List.js +12 -15
- package/esm/List/ListItem.js +6 -9
- package/esm/Loader/Loader.js +6 -9
- package/esm/MaskedInput/MaskedInput.d.ts +43 -0
- package/esm/MaskedInput/MaskedInput.js +67 -0
- package/esm/MaskedInput/adjustCaretPosition.d.ts +11 -0
- package/esm/MaskedInput/adjustCaretPosition.js +213 -0
- package/esm/MaskedInput/conformToMask.d.ts +8 -0
- package/esm/MaskedInput/conformToMask.js +239 -0
- package/esm/MaskedInput/createTextMaskInputElement.d.ts +7 -0
- package/esm/MaskedInput/createTextMaskInputElement.js +212 -0
- package/esm/MaskedInput/index.d.ts +3 -0
- package/esm/MaskedInput/index.js +2 -0
- package/esm/MaskedInput/types.d.ts +10 -0
- package/esm/{@types/icons.js → MaskedInput/types.js} +0 -0
- package/esm/MaskedInput/utilities.d.ts +7 -0
- package/esm/MaskedInput/utilities.js +38 -0
- package/esm/Menu/Menu.d.ts +0 -1
- package/esm/Menu/Menu.js +3 -5
- package/esm/Message/Message.js +8 -11
- package/esm/Modal/Modal.d.ts +1 -10
- package/esm/Modal/Modal.js +31 -21
- package/esm/Modal/ModalBody.js +5 -8
- package/esm/Modal/ModalContext.d.ts +12 -0
- package/esm/Modal/ModalContext.js +2 -0
- package/esm/Modal/ModalDialog.js +8 -8
- package/esm/Modal/ModalHeader.js +7 -10
- package/esm/Modal/ModalTitle.d.ts +3 -2
- package/esm/Modal/ModalTitle.js +35 -4
- package/esm/MultiCascader/DropdownMenu.js +21 -23
- package/esm/MultiCascader/MultiCascader.js +35 -32
- package/esm/Nav/Nav.js +6 -9
- package/esm/Navbar/Navbar.js +6 -9
- package/esm/Notification/Notification.js +6 -9
- package/esm/Overlay/Modal.js +11 -18
- package/esm/Overlay/Overlay.js +2 -5
- package/esm/Overlay/OverlayTrigger.js +9 -9
- package/esm/Overlay/Position.js +4 -7
- package/esm/Overlay/positionUtils.js +1 -1
- package/esm/Pagination/Pagination.js +10 -13
- package/esm/Pagination/PaginationButton.js +4 -7
- package/esm/Pagination/PaginationGroup.js +10 -11
- package/esm/Panel/Panel.js +6 -9
- package/esm/PanelGroup/PanelGroup.js +4 -7
- package/esm/Picker/DropdownMenu.js +2 -3
- package/esm/Picker/DropdownMenuGroup.js +4 -7
- package/esm/Picker/DropdownMenuItem.js +4 -7
- package/esm/Picker/PickerToggle.js +13 -12
- package/esm/Picker/propTypes.d.ts +2 -16
- package/esm/Picker/propTypes.js +2 -13
- package/esm/Picker/utils.js +14 -9
- package/esm/Placeholder/PlaceholderGraph.js +6 -9
- package/esm/Placeholder/PlaceholderGrid.js +12 -15
- package/esm/Placeholder/PlaceholderParagraph.js +10 -13
- package/esm/Popover/Popover.js +4 -7
- package/esm/Progress/ProgressCircle.js +18 -21
- package/esm/Progress/ProgressLine.js +8 -11
- package/esm/Radio/Radio.js +6 -10
- package/esm/RadioGroup/RadioGroup.js +6 -9
- package/esm/RangeSlider/RangeSlider.js +17 -20
- package/esm/Rate/Character.js +4 -7
- package/esm/Rate/Rate.js +14 -17
- package/esm/Ripple/Ripple.js +4 -7
- package/esm/SelectPicker/SelectPicker.js +31 -28
- package/esm/Sidebar/Sidebar.js +6 -9
- package/esm/Sidenav/Sidenav.js +8 -11
- package/esm/Sidenav/SidenavDropdown.d.ts +6 -1
- package/esm/Sidenav/SidenavDropdown.js +19 -18
- package/esm/Sidenav/SidenavDropdownCollapse.js +2 -5
- package/esm/Sidenav/SidenavDropdownItem.js +5 -8
- package/esm/Sidenav/SidenavDropdownMenu.js +5 -8
- package/esm/Sidenav/SidenavToggle.js +4 -7
- package/esm/Slider/Graduated.js +4 -7
- package/esm/Slider/Handle.d.ts +2 -0
- package/esm/Slider/Handle.js +23 -12
- package/esm/Slider/Input.d.ts +3 -0
- package/esm/Slider/Input.js +23 -0
- package/esm/Slider/Mark.js +4 -7
- package/esm/Slider/ProgressBar.js +4 -7
- package/esm/Slider/Slider.d.ts +0 -3
- package/esm/Slider/Slider.js +14 -22
- package/esm/Steps/StepItem.js +4 -7
- package/esm/Steps/Steps.js +8 -11
- package/esm/Table/Table.d.ts +7 -7
- package/esm/Table/Table.js +5 -5
- package/esm/TagInput/index.js +4 -6
- package/esm/TagPicker/index.d.ts +1 -1
- package/esm/TagPicker/index.js +4 -6
- package/esm/Timeline/Timeline.js +6 -10
- package/esm/Timeline/TimelineItem.js +4 -7
- package/esm/Toggle/Toggle.d.ts +2 -0
- package/esm/Toggle/Toggle.js +27 -13
- package/esm/Tooltip/Tooltip.js +4 -7
- package/esm/Tree/Tree.d.ts +6 -0
- package/esm/TreePicker/TreeNode.js +4 -6
- package/esm/TreePicker/TreePicker.js +38 -31
- package/esm/Uploader/UploadFileItem.d.ts +1 -0
- package/esm/Uploader/UploadFileItem.js +42 -33
- package/esm/Uploader/UploadTrigger.js +4 -7
- package/esm/Uploader/Uploader.d.ts +2 -0
- package/esm/Uploader/Uploader.js +28 -28
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/locales/fa_IR.d.ts +105 -0
- package/esm/locales/fa_IR.js +74 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +2 -1
- package/esm/toaster/ToastContainer.js +6 -9
- package/esm/utils/createComponent.d.ts +1 -2
- package/esm/utils/createComponent.js +10 -13
- package/esm/utils/previewFile.d.ts +1 -0
- package/esm/utils/previewFile.js +9 -0
- package/esm/utils/useUniqueId.d.ts +3 -1
- package/esm/utils/useUniqueId.js +4 -2
- package/locales/fa_IR/package.json +7 -0
- package/package.json +6 -8
- package/styles/color-modes/dark.less +1 -0
- package/styles/color-modes/high-contrast.less +1 -0
- package/styles/color-modes/light.less +3 -0
- package/styles/variables.less +3 -1
- package/cjs/@types/icons.d.ts +0 -1
- package/esm/@types/icons.d.ts +0 -1
|
@@ -96,20 +96,12 @@ function disableMinValue(value, min) {
|
|
|
96
96
|
return false;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
var defaultProps = {
|
|
100
|
-
as: _InputGroup.default,
|
|
101
|
-
classPrefix: 'input-number',
|
|
102
|
-
min: -Infinity,
|
|
103
|
-
max: Infinity,
|
|
104
|
-
step: 1,
|
|
105
|
-
buttonAppearance: 'subtle',
|
|
106
|
-
scrollable: true
|
|
107
|
-
};
|
|
108
|
-
|
|
109
99
|
var InputNumber = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
110
|
-
var
|
|
100
|
+
var _props$as = props.as,
|
|
101
|
+
Component = _props$as === void 0 ? _InputGroup.default : _props$as,
|
|
111
102
|
className = props.className,
|
|
112
|
-
classPrefix = props.classPrefix,
|
|
103
|
+
_props$classPrefix = props.classPrefix,
|
|
104
|
+
classPrefix = _props$classPrefix === void 0 ? 'input-number' : _props$classPrefix,
|
|
113
105
|
disabled = props.disabled,
|
|
114
106
|
readOnly = props.readOnly,
|
|
115
107
|
plaintext = props.plaintext,
|
|
@@ -118,11 +110,16 @@ var InputNumber = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
118
110
|
size = props.size,
|
|
119
111
|
prefixElement = props.prefix,
|
|
120
112
|
postfix = props.postfix,
|
|
121
|
-
step = props.step,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
_props$step = props.step,
|
|
114
|
+
step = _props$step === void 0 ? 1 : _props$step,
|
|
115
|
+
_props$buttonAppearan = props.buttonAppearance,
|
|
116
|
+
buttonAppearance = _props$buttonAppearan === void 0 ? 'subtle' : _props$buttonAppearan,
|
|
117
|
+
_props$min = props.min,
|
|
118
|
+
min = _props$min === void 0 ? -Infinity : _props$min,
|
|
119
|
+
_props$max = props.max,
|
|
120
|
+
max = _props$max === void 0 ? Infinity : _props$max,
|
|
121
|
+
_props$scrollable = props.scrollable,
|
|
122
|
+
scrollable = _props$scrollable === void 0 ? true : _props$scrollable,
|
|
126
123
|
onChange = props.onChange,
|
|
127
124
|
onWheel = props.onWheel,
|
|
128
125
|
restProps = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "className", "classPrefix", "disabled", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel"]);
|
|
@@ -270,7 +267,6 @@ var InputNumber = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
270
267
|
});
|
|
271
268
|
|
|
272
269
|
InputNumber.displayName = 'InputNumber';
|
|
273
|
-
InputNumber.defaultProps = defaultProps;
|
|
274
270
|
InputNumber.propTypes = {
|
|
275
271
|
className: _propTypes.default.string,
|
|
276
272
|
classPrefix: _propTypes.default.string,
|
|
@@ -42,7 +42,8 @@ var copyStyles = function copyStyles(styles, node) {
|
|
|
42
42
|
* @param placeholderRef
|
|
43
43
|
*/
|
|
44
44
|
var useInputWidth = function useInputWidth(props, sizerRef, placeholderRef) {
|
|
45
|
-
var minWidth = props.minWidth,
|
|
45
|
+
var _props$minWidth = props.minWidth,
|
|
46
|
+
minWidth = _props$minWidth === void 0 ? 1 : _props$minWidth,
|
|
46
47
|
placeholder = props.placeholder,
|
|
47
48
|
value = props.value,
|
|
48
49
|
onAutosize = props.onAutosize;
|
|
@@ -181,8 +182,5 @@ InputAutosize.propTypes = {
|
|
|
181
182
|
value: _propTypes.default.any,
|
|
182
183
|
onAutosize: _propTypes.default.func
|
|
183
184
|
};
|
|
184
|
-
InputAutosize.defaultProps = {
|
|
185
|
-
minWidth: 1
|
|
186
|
-
};
|
|
187
185
|
var _default = InputAutosize;
|
|
188
186
|
exports.default = _default;
|
|
@@ -56,52 +56,50 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _temp
|
|
|
56
56
|
var InputPickerContext = /*#__PURE__*/_react.default.createContext({});
|
|
57
57
|
|
|
58
58
|
exports.InputPickerContext = InputPickerContext;
|
|
59
|
-
var defaultProps = {
|
|
60
|
-
as: 'div',
|
|
61
|
-
appearance: 'default',
|
|
62
|
-
cleanable: true,
|
|
63
|
-
cacheData: [],
|
|
64
|
-
classPrefix: 'picker',
|
|
65
|
-
data: [],
|
|
66
|
-
disabledItemValues: [],
|
|
67
|
-
valueKey: 'value',
|
|
68
|
-
labelKey: 'label',
|
|
69
|
-
placement: 'bottomStart',
|
|
70
|
-
searchable: true,
|
|
71
|
-
menuAutoWidth: true,
|
|
72
|
-
menuMaxHeight: 320
|
|
73
|
-
};
|
|
74
59
|
|
|
75
60
|
var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
76
61
|
var _merge;
|
|
77
62
|
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
var _props$as = props.as,
|
|
64
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
65
|
+
_props$appearance = props.appearance,
|
|
66
|
+
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
67
|
+
_props$cleanable = props.cleanable,
|
|
68
|
+
cleanable = _props$cleanable === void 0 ? true : _props$cleanable,
|
|
69
|
+
_props$cacheData = props.cacheData,
|
|
70
|
+
cacheData = _props$cacheData === void 0 ? [] : _props$cacheData,
|
|
71
|
+
_props$classPrefix = props.classPrefix,
|
|
72
|
+
classPrefix = _props$classPrefix === void 0 ? 'picker' : _props$classPrefix,
|
|
73
|
+
_props$data = props.data,
|
|
74
|
+
controlledData = _props$data === void 0 ? [] : _props$data,
|
|
83
75
|
disabled = props.disabled,
|
|
84
76
|
readOnly = props.readOnly,
|
|
85
77
|
plaintext = props.plaintext,
|
|
86
78
|
defaultValue = props.defaultValue,
|
|
87
79
|
defaultOpen = props.defaultOpen,
|
|
88
|
-
|
|
80
|
+
_props$disabledItemVa = props.disabledItemValues,
|
|
81
|
+
disabledItemValues = _props$disabledItemVa === void 0 ? [] : _props$disabledItemVa,
|
|
89
82
|
overrideLocale = props.locale,
|
|
90
83
|
toggleAs = props.toggleAs,
|
|
91
84
|
style = props.style,
|
|
92
|
-
searchable = props.searchable,
|
|
85
|
+
_props$searchable = props.searchable,
|
|
86
|
+
searchable = _props$searchable === void 0 ? true : _props$searchable,
|
|
93
87
|
controlledOpen = props.open,
|
|
94
88
|
placeholder = props.placeholder,
|
|
95
89
|
groupBy = props.groupBy,
|
|
96
90
|
menuClassName = props.menuClassName,
|
|
97
91
|
menuStyle = props.menuStyle,
|
|
98
|
-
menuAutoWidth = props.menuAutoWidth,
|
|
99
|
-
|
|
92
|
+
_props$menuAutoWidth = props.menuAutoWidth,
|
|
93
|
+
menuAutoWidth = _props$menuAutoWidth === void 0 ? true : _props$menuAutoWidth,
|
|
94
|
+
_props$menuMaxHeight = props.menuMaxHeight,
|
|
95
|
+
menuMaxHeight = _props$menuMaxHeight === void 0 ? 320 : _props$menuMaxHeight,
|
|
100
96
|
creatable = props.creatable,
|
|
101
97
|
valueProp = props.value,
|
|
102
|
-
valueKey = props.valueKey,
|
|
98
|
+
_props$valueKey = props.valueKey,
|
|
99
|
+
valueKey = _props$valueKey === void 0 ? 'value' : _props$valueKey,
|
|
103
100
|
virtualized = props.virtualized,
|
|
104
|
-
labelKey = props.labelKey,
|
|
101
|
+
_props$labelKey = props.labelKey,
|
|
102
|
+
labelKey = _props$labelKey === void 0 ? 'label' : _props$labelKey,
|
|
105
103
|
listProps = props.listProps,
|
|
106
104
|
id = props.id,
|
|
107
105
|
tabIndex = props.tabIndex,
|
|
@@ -125,8 +123,9 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
125
123
|
onBlur = props.onBlur,
|
|
126
124
|
onFocus = props.onFocus,
|
|
127
125
|
searchBy = props.searchBy,
|
|
128
|
-
placement = props.placement,
|
|
129
|
-
|
|
126
|
+
_props$placement = props.placement,
|
|
127
|
+
placement = _props$placement === void 0 ? 'bottomStart' : _props$placement,
|
|
128
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "appearance", "cleanable", "cacheData", "classPrefix", "data", "disabled", "readOnly", "plaintext", "defaultValue", "defaultOpen", "disabledItemValues", "locale", "toggleAs", "style", "searchable", "open", "placeholder", "groupBy", "menuClassName", "menuStyle", "menuAutoWidth", "menuMaxHeight", "creatable", "value", "valueKey", "virtualized", "labelKey", "listProps", "id", "tabIndex", "sort", "renderMenu", "renderExtraFooter", "renderValue", "renderMenuItem", "renderMenuGroup", "onEnter", "onEntered", "onExit", "onExited", "onChange", "onClean", "onCreate", "onSearch", "onSelect", "onOpen", "onClose", "onBlur", "onFocus", "searchBy", "placement"]);
|
|
130
129
|
|
|
131
130
|
var _useContext = (0, _react.useContext)(InputPickerContext),
|
|
132
131
|
multi = _useContext.multi,
|
|
@@ -672,8 +671,11 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
672
671
|
var hasValue = multi ? !!(tagElements !== null && tagElements !== void 0 && tagElements.length) || hasMultiValue : isValid || hasSingleValue;
|
|
673
672
|
|
|
674
673
|
var _usePickerClassName = (0, _Picker.usePickerClassName)((0, _extends2.default)({}, props, {
|
|
674
|
+
classPrefix: classPrefix,
|
|
675
|
+
appearance: appearance,
|
|
675
676
|
hasValue: hasValue,
|
|
676
|
-
name: 'input'
|
|
677
|
+
name: 'input',
|
|
678
|
+
cleanable: cleanable
|
|
677
679
|
})),
|
|
678
680
|
pickerClasses = _usePickerClassName[0],
|
|
679
681
|
usedClassNamePropKeys = _usePickerClassName[1];
|
|
@@ -724,6 +726,7 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
724
726
|
onKeyDown: onPickerKeyDown
|
|
725
727
|
}, /*#__PURE__*/_react.default.createElement(_Picker.PickerToggle, (0, _extends2.default)({}, (0, _omit.default)(rest, [].concat(_Picker.omitTriggerPropKeys, usedClassNamePropKeys)), {
|
|
726
728
|
id: id,
|
|
729
|
+
appearance: appearance,
|
|
727
730
|
readOnly: readOnly,
|
|
728
731
|
plaintext: plaintext,
|
|
729
732
|
ref: targetRef,
|
|
@@ -751,7 +754,6 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
751
754
|
});
|
|
752
755
|
|
|
753
756
|
InputPicker.displayName = 'InputPicker';
|
|
754
|
-
InputPicker.defaultProps = defaultProps;
|
|
755
757
|
InputPicker.propTypes = (0, _extends2.default)({}, _Picker.listPickerPropTypes, {
|
|
756
758
|
locale: _propTypes.default.any,
|
|
757
759
|
appearance: _propTypes.default.oneOf(['default', 'subtle']),
|
package/cjs/List/List.js
CHANGED
|
@@ -23,26 +23,23 @@ var _ListContext = _interopRequireDefault(require("./ListContext"));
|
|
|
23
23
|
|
|
24
24
|
var _ListItem = _interopRequireDefault(require("./ListItem"));
|
|
25
25
|
|
|
26
|
-
var defaultProps = {
|
|
27
|
-
as: 'div',
|
|
28
|
-
classPrefix: 'list',
|
|
29
|
-
size: 'md',
|
|
30
|
-
autoScroll: true,
|
|
31
|
-
pressDelay: 0,
|
|
32
|
-
transitionDuration: 300
|
|
33
|
-
};
|
|
34
|
-
|
|
35
26
|
var List = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
36
|
-
var
|
|
37
|
-
|
|
27
|
+
var _props$as = props.as,
|
|
28
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
29
|
+
_props$classPrefix = props.classPrefix,
|
|
30
|
+
classPrefix = _props$classPrefix === void 0 ? 'list' : _props$classPrefix,
|
|
38
31
|
className = props.className,
|
|
39
32
|
bordered = props.bordered,
|
|
40
33
|
hover = props.hover,
|
|
41
|
-
size = props.size,
|
|
34
|
+
_props$size = props.size,
|
|
35
|
+
size = _props$size === void 0 ? 'md' : _props$size,
|
|
42
36
|
sortable = props.sortable,
|
|
43
|
-
autoScroll = props.autoScroll,
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
_props$autoScroll = props.autoScroll,
|
|
38
|
+
autoScroll = _props$autoScroll === void 0 ? true : _props$autoScroll,
|
|
39
|
+
_props$pressDelay = props.pressDelay,
|
|
40
|
+
pressDelay = _props$pressDelay === void 0 ? 0 : _props$pressDelay,
|
|
41
|
+
_props$transitionDura = props.transitionDuration,
|
|
42
|
+
transitionDuration = _props$transitionDura === void 0 ? 300 : _props$transitionDura,
|
|
46
43
|
children = props.children,
|
|
47
44
|
onSort = props.onSort,
|
|
48
45
|
onSortEnd = props.onSortEnd,
|
|
@@ -96,7 +93,6 @@ var List = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
96
93
|
|
|
97
94
|
List.Item = _ListItem.default;
|
|
98
95
|
List.displayName = 'List';
|
|
99
|
-
List.defaultProps = defaultProps;
|
|
100
96
|
List.propTypes = {
|
|
101
97
|
className: _propTypes.default.string,
|
|
102
98
|
classPrefix: _propTypes.default.string,
|
package/cjs/List/ListItem.js
CHANGED
|
@@ -19,18 +19,15 @@ var _utils = require("../utils");
|
|
|
19
19
|
|
|
20
20
|
var _ListContext = _interopRequireDefault(require("./ListContext"));
|
|
21
21
|
|
|
22
|
-
var defaultProps = {
|
|
23
|
-
as: 'div',
|
|
24
|
-
classPrefix: 'list-item',
|
|
25
|
-
collection: 0
|
|
26
|
-
};
|
|
27
|
-
|
|
28
22
|
var ListItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
29
|
-
var
|
|
23
|
+
var _props$as = props.as,
|
|
24
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
30
25
|
children = props.children,
|
|
31
26
|
className = props.className,
|
|
32
|
-
classPrefix = props.classPrefix,
|
|
33
|
-
|
|
27
|
+
_props$classPrefix = props.classPrefix,
|
|
28
|
+
classPrefix = _props$classPrefix === void 0 ? 'list-item' : _props$classPrefix,
|
|
29
|
+
_props$collection = props.collection,
|
|
30
|
+
collection = _props$collection === void 0 ? 0 : _props$collection,
|
|
34
31
|
disabled = props.disabled,
|
|
35
32
|
index = props.index,
|
|
36
33
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "children", "className", "classPrefix", "collection", "disabled", "index"]);
|
|
@@ -73,7 +70,6 @@ var ListItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
73
70
|
});
|
|
74
71
|
|
|
75
72
|
ListItem.displayName = 'ListItem';
|
|
76
|
-
ListItem.defaultProps = defaultProps;
|
|
77
73
|
ListItem.propTypes = {
|
|
78
74
|
index: _propTypes.default.number,
|
|
79
75
|
collection: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
package/cjs/Loader/Loader.js
CHANGED
|
@@ -15,19 +15,16 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
-
var defaultProps = {
|
|
19
|
-
as: 'div',
|
|
20
|
-
classPrefix: 'loader',
|
|
21
|
-
speed: 'normal'
|
|
22
|
-
};
|
|
23
|
-
|
|
24
18
|
var Loader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
25
|
-
var
|
|
26
|
-
|
|
19
|
+
var _props$as = props.as,
|
|
20
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
21
|
+
_props$classPrefix = props.classPrefix,
|
|
22
|
+
classPrefix = _props$classPrefix === void 0 ? 'loader' : _props$classPrefix,
|
|
27
23
|
className = props.className,
|
|
28
24
|
inverse = props.inverse,
|
|
29
25
|
backdrop = props.backdrop,
|
|
30
|
-
speed = props.speed,
|
|
26
|
+
_props$speed = props.speed,
|
|
27
|
+
speed = _props$speed === void 0 ? 'normal' : _props$speed,
|
|
31
28
|
center = props.center,
|
|
32
29
|
vertical = props.vertical,
|
|
33
30
|
content = props.content,
|
|
@@ -64,7 +61,6 @@ var Loader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
64
61
|
});
|
|
65
62
|
|
|
66
63
|
Loader.displayName = 'Loader';
|
|
67
|
-
Loader.defaultProps = defaultProps;
|
|
68
64
|
Loader.propTypes = {
|
|
69
65
|
as: _propTypes.default.elementType,
|
|
70
66
|
className: _propTypes.default.string,
|
|
@@ -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 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>>;
|
|
43
|
+
export default MaskedInput;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
var _createTextMaskInputElement = _interopRequireDefault(require("./createTextMaskInputElement"));
|
|
21
|
+
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
|
|
24
|
+
var defaultRender = function defaultRender(ref, props) {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
|
|
26
|
+
ref: ref
|
|
27
|
+
}, props));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var MaskedInput = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
31
|
+
var mask = props.mask,
|
|
32
|
+
_props$guide = props.guide,
|
|
33
|
+
guide = _props$guide === void 0 ? true : _props$guide,
|
|
34
|
+
placeholderChar = props.placeholderChar,
|
|
35
|
+
value = props.value,
|
|
36
|
+
showMask = props.showMask,
|
|
37
|
+
pipe = props.pipe,
|
|
38
|
+
_props$render = props.render,
|
|
39
|
+
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
40
|
+
onChange = props.onChange,
|
|
41
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
42
|
+
var inputRef = (0, _react.useRef)(null);
|
|
43
|
+
var textMaskInputElement = (0, _react.useRef)();
|
|
44
|
+
var initTextMask = (0, _react.useCallback)(function () {
|
|
45
|
+
var _textMaskInputElement;
|
|
46
|
+
|
|
47
|
+
textMaskInputElement.current = (0, _createTextMaskInputElement.default)((0, _extends2.default)({
|
|
48
|
+
inputElement: inputRef.current
|
|
49
|
+
}, props));
|
|
50
|
+
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
51
|
+
}, [props, value]);
|
|
52
|
+
var handleChange = (0, _react.useCallback)(function (event) {
|
|
53
|
+
var _textMaskInputElement2;
|
|
54
|
+
|
|
55
|
+
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
56
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
57
|
+
}, [onChange]);
|
|
58
|
+
(0, _react.useEffect)(function () {
|
|
59
|
+
initTextMask();
|
|
60
|
+
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
61
|
+
return render((0, _utils.mergeRefs)(inputRef, ref), (0, _extends2.default)({
|
|
62
|
+
onChange: handleChange,
|
|
63
|
+
defaultValue: value
|
|
64
|
+
}, (0, _omit.default)(rest, ['keepCharPositions'])));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
MaskedInput.displayName = 'MaskedInput';
|
|
68
|
+
MaskedInput.propTypes = {
|
|
69
|
+
render: _propTypes.default.func,
|
|
70
|
+
onChange: _propTypes.default.func,
|
|
71
|
+
mask: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func, _propTypes.default.bool]).isRequired,
|
|
72
|
+
guide: _propTypes.default.bool,
|
|
73
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
74
|
+
pipe: _propTypes.default.func,
|
|
75
|
+
placeholderChar: _propTypes.default.string,
|
|
76
|
+
keepCharPositions: _propTypes.default.bool,
|
|
77
|
+
showMask: _propTypes.default.bool
|
|
78
|
+
};
|
|
79
|
+
var _default = MaskedInput;
|
|
80
|
+
exports.default = _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function adjustCaretPosition({ previousConformedValue, previousPlaceholder, currentCaretPosition, conformedValue, rawValue, placeholderChar, placeholder, indexesOfPipedChars, caretTrapIndexes }: {
|
|
2
|
+
previousConformedValue?: string;
|
|
3
|
+
previousPlaceholder?: string;
|
|
4
|
+
currentCaretPosition?: number;
|
|
5
|
+
conformedValue: any;
|
|
6
|
+
rawValue: any;
|
|
7
|
+
placeholderChar: any;
|
|
8
|
+
placeholder: any;
|
|
9
|
+
indexesOfPipedChars?: any[];
|
|
10
|
+
caretTrapIndexes?: any[];
|
|
11
|
+
}): number;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = adjustCaretPosition;
|
|
5
|
+
var defaultArray = [];
|
|
6
|
+
var emptyString = '';
|
|
7
|
+
|
|
8
|
+
function adjustCaretPosition(_ref) {
|
|
9
|
+
var _ref$previousConforme = _ref.previousConformedValue,
|
|
10
|
+
previousConformedValue = _ref$previousConforme === void 0 ? emptyString : _ref$previousConforme,
|
|
11
|
+
_ref$previousPlacehol = _ref.previousPlaceholder,
|
|
12
|
+
previousPlaceholder = _ref$previousPlacehol === void 0 ? emptyString : _ref$previousPlacehol,
|
|
13
|
+
_ref$currentCaretPosi = _ref.currentCaretPosition,
|
|
14
|
+
currentCaretPosition = _ref$currentCaretPosi === void 0 ? 0 : _ref$currentCaretPosi,
|
|
15
|
+
conformedValue = _ref.conformedValue,
|
|
16
|
+
rawValue = _ref.rawValue,
|
|
17
|
+
placeholderChar = _ref.placeholderChar,
|
|
18
|
+
placeholder = _ref.placeholder,
|
|
19
|
+
_ref$indexesOfPipedCh = _ref.indexesOfPipedChars,
|
|
20
|
+
indexesOfPipedChars = _ref$indexesOfPipedCh === void 0 ? defaultArray : _ref$indexesOfPipedCh,
|
|
21
|
+
_ref$caretTrapIndexes = _ref.caretTrapIndexes,
|
|
22
|
+
caretTrapIndexes = _ref$caretTrapIndexes === void 0 ? defaultArray : _ref$caretTrapIndexes;
|
|
23
|
+
|
|
24
|
+
if (currentCaretPosition === 0 || !rawValue.length) {
|
|
25
|
+
return 0;
|
|
26
|
+
} // Store lengths for faster performance?
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var rawValueLength = rawValue.length;
|
|
30
|
+
var previousConformedValueLength = previousConformedValue.length;
|
|
31
|
+
var placeholderLength = placeholder.length;
|
|
32
|
+
var conformedValueLength = conformedValue.length; // This tells us how long the edit is. If user modified input from `(2__)` to `(243__)`,
|
|
33
|
+
// we know the user in this instance pasted two characters
|
|
34
|
+
|
|
35
|
+
var editLength = rawValueLength - previousConformedValueLength; // If the edit length is positive, that means the user is adding characters, not deleting.
|
|
36
|
+
|
|
37
|
+
var isAddition = editLength > 0; // This is the first raw value the user entered that needs to be conformed to mask
|
|
38
|
+
|
|
39
|
+
var isFirstRawValue = previousConformedValueLength === 0; // A partial multi-character edit happens when the user makes a partial selection in their
|
|
40
|
+
// input and edits that selection. That is going from `(123) 432-4348` to `() 432-4348` by
|
|
41
|
+
// selecting the first 3 digits and pressing backspace.
|
|
42
|
+
//
|
|
43
|
+
// Such cases can also happen when the user presses the backspace while holding down the ALT
|
|
44
|
+
// key.
|
|
45
|
+
|
|
46
|
+
var isPartialMultiCharEdit = editLength > 1 && !isFirstRawValue; // This algorithm doesn't support all cases of multi-character edits, so we just return
|
|
47
|
+
// the current caret position.
|
|
48
|
+
//
|
|
49
|
+
// This works fine for most cases.
|
|
50
|
+
|
|
51
|
+
if (isPartialMultiCharEdit) {
|
|
52
|
+
return currentCaretPosition;
|
|
53
|
+
} // For a mask like (111), if the `previousConformedValue` is (1__) and user attempts to enter
|
|
54
|
+
// `f` so the `rawValue` becomes (1f__), the new `conformedValue` would be (1__), which is the
|
|
55
|
+
// same as the original `previousConformedValue`. We handle this case differently for caret
|
|
56
|
+
// positioning.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var possiblyHasRejectedChar = isAddition && (previousConformedValue === conformedValue || conformedValue === placeholder);
|
|
60
|
+
var startingSearchIndex = 0;
|
|
61
|
+
var trackRightCharacter;
|
|
62
|
+
var targetChar;
|
|
63
|
+
|
|
64
|
+
if (possiblyHasRejectedChar) {
|
|
65
|
+
startingSearchIndex = currentCaretPosition - editLength;
|
|
66
|
+
} else {
|
|
67
|
+
// At this point in the algorithm, we want to know where the caret is right before the raw input
|
|
68
|
+
// has been conformed, and then see if we can find that same spot in the conformed input.
|
|
69
|
+
//
|
|
70
|
+
// We do that by seeing what character lies immediately before the caret, and then look for that
|
|
71
|
+
// same character in the conformed input and place the caret there.
|
|
72
|
+
// First, we need to normalize the inputs so that letter capitalization between raw input and
|
|
73
|
+
// conformed input wouldn't matter.
|
|
74
|
+
var normalizedConformedValue = conformedValue.toLowerCase();
|
|
75
|
+
var normalizedRawValue = rawValue.toLowerCase(); // Then we take all characters that come before where the caret currently is.
|
|
76
|
+
|
|
77
|
+
var leftHalfChars = normalizedRawValue.substr(0, currentCaretPosition).split(emptyString); // Now we find all the characters in the left half that exist in the conformed input
|
|
78
|
+
// This step ensures that we don't look for a character that was filtered out or rejected by `conformToMask`.
|
|
79
|
+
|
|
80
|
+
var intersection = leftHalfChars.filter(function (char) {
|
|
81
|
+
return normalizedConformedValue.indexOf(char) !== -1;
|
|
82
|
+
}); // The last character in the intersection is the character we want to look for in the conformed
|
|
83
|
+
// value and the one we want to adjust the caret close to
|
|
84
|
+
|
|
85
|
+
targetChar = intersection[intersection.length - 1]; // Calculate the number of mask characters in the previous placeholder
|
|
86
|
+
// from the start of the string up to the place where the caret is
|
|
87
|
+
|
|
88
|
+
var previousLeftMaskChars = previousPlaceholder.substr(0, intersection.length).split(emptyString).filter(function (char) {
|
|
89
|
+
return char !== placeholderChar;
|
|
90
|
+
}).length; // Calculate the number of mask characters in the current placeholder
|
|
91
|
+
// from the start of the string up to the place where the caret is
|
|
92
|
+
|
|
93
|
+
var leftMaskChars = placeholder.substr(0, intersection.length).split(emptyString).filter(function (char) {
|
|
94
|
+
return char !== placeholderChar;
|
|
95
|
+
}).length; // Has the number of mask characters up to the caret changed?
|
|
96
|
+
|
|
97
|
+
var masklengthChanged = leftMaskChars !== previousLeftMaskChars; // Detect if `targetChar` is a mask character and has moved to the left
|
|
98
|
+
|
|
99
|
+
var targetIsMaskMovingLeft = previousPlaceholder[intersection.length - 1] !== undefined && placeholder[intersection.length - 2] !== undefined && previousPlaceholder[intersection.length - 1] !== placeholderChar && previousPlaceholder[intersection.length - 1] !== placeholder[intersection.length - 1] && previousPlaceholder[intersection.length - 1] === placeholder[intersection.length - 2]; // If deleting and the `targetChar` `is a mask character and `masklengthChanged` is true
|
|
100
|
+
// or the mask is moving to the left, we can't use the selected `targetChar` any longer
|
|
101
|
+
// if we are not at the end of the string.
|
|
102
|
+
// In this case, change tracking strategy and track the character to the right of the caret.
|
|
103
|
+
|
|
104
|
+
if (!isAddition && (masklengthChanged || targetIsMaskMovingLeft) && previousLeftMaskChars > 0 && placeholder.indexOf(targetChar) > -1 && rawValue[currentCaretPosition] !== undefined) {
|
|
105
|
+
trackRightCharacter = true;
|
|
106
|
+
targetChar = rawValue[currentCaretPosition];
|
|
107
|
+
} // It is possible that `targetChar` will appear multiple times in the conformed value.
|
|
108
|
+
// We need to know not to select a character that looks like our target character from the placeholder or
|
|
109
|
+
// the piped characters, so we inspect the piped characters and the placeholder to see if they contain
|
|
110
|
+
// characters that match our target character.
|
|
111
|
+
// If the `conformedValue` got piped, we need to know which characters were piped in so that when we look for
|
|
112
|
+
// our `targetChar`, we don't select a piped char by mistake
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
var pipedChars = indexesOfPipedChars.map(function (index) {
|
|
116
|
+
return normalizedConformedValue[index];
|
|
117
|
+
}); // We need to know how many times the `targetChar` occurs in the piped characters.
|
|
118
|
+
|
|
119
|
+
var countTargetCharInPipedChars = pipedChars.filter(function (char) {
|
|
120
|
+
return char === targetChar;
|
|
121
|
+
}).length; // We need to know how many times it occurs in the intersection
|
|
122
|
+
|
|
123
|
+
var countTargetCharInIntersection = intersection.filter(function (char) {
|
|
124
|
+
return char === targetChar;
|
|
125
|
+
}).length; // We need to know if the placeholder contains characters that look like
|
|
126
|
+
// our `targetChar`, so we don't select one of those by mistake.
|
|
127
|
+
|
|
128
|
+
var countTargetCharInPlaceholder = placeholder.substr(0, placeholder.indexOf(placeholderChar)).split(emptyString).filter(function (char, index) {
|
|
129
|
+
return (// Check if `char` is the same as our `targetChar`, so we account for it
|
|
130
|
+
char === targetChar && // but also make sure that both the `rawValue` and placeholder don't have the same character at the same
|
|
131
|
+
// index because if they are equal, that means we are already counting those characters in
|
|
132
|
+
// `countTargetCharInIntersection`
|
|
133
|
+
rawValue[index] !== char
|
|
134
|
+
);
|
|
135
|
+
}).length; // The number of times we need to see occurrences of the `targetChar` before we know it is the one we're looking
|
|
136
|
+
// for is:
|
|
137
|
+
|
|
138
|
+
var requiredNumberOfMatches = countTargetCharInPlaceholder + countTargetCharInIntersection + countTargetCharInPipedChars + ( // The character to the right of the caret isn't included in `intersection`
|
|
139
|
+
// so add one if we are tracking the character to the right
|
|
140
|
+
trackRightCharacter ? 1 : 0); // Now we start looking for the location of the `targetChar`.
|
|
141
|
+
// We keep looping forward and store the index in every iteration. Once we have encountered
|
|
142
|
+
// enough occurrences of the target character, we break out of the loop
|
|
143
|
+
// If are searching for the second `1` in `1214`, `startingSearchIndex` will point at `4`.
|
|
144
|
+
|
|
145
|
+
var numberOfEncounteredMatches = 0;
|
|
146
|
+
|
|
147
|
+
for (var i = 0; i < conformedValueLength; i++) {
|
|
148
|
+
var conformedValueChar = normalizedConformedValue[i];
|
|
149
|
+
startingSearchIndex = i + 1;
|
|
150
|
+
|
|
151
|
+
if (conformedValueChar === targetChar) {
|
|
152
|
+
numberOfEncounteredMatches++;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (numberOfEncounteredMatches >= requiredNumberOfMatches) {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
} // At this point, if we simply return `startingSearchIndex` as the adjusted caret position,
|
|
160
|
+
// most cases would be handled. However, we want to fast forward or rewind the caret to the
|
|
161
|
+
// closest placeholder character if it happens to be in a non-editable spot. That's what the next
|
|
162
|
+
// logic is for.
|
|
163
|
+
// In case of addition, we fast forward.
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if (isAddition) {
|
|
167
|
+
// We want to remember the last placeholder character encountered so that if the mask
|
|
168
|
+
// contains more characters after the last placeholder character, we don't forward the caret
|
|
169
|
+
// that far to the right. Instead, we stop it at the last encountered placeholder character.
|
|
170
|
+
var lastPlaceholderChar = startingSearchIndex;
|
|
171
|
+
|
|
172
|
+
for (var _i = startingSearchIndex; _i <= placeholderLength; _i++) {
|
|
173
|
+
if (placeholder[_i] === placeholderChar) {
|
|
174
|
+
lastPlaceholderChar = _i;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if ( // If we're adding, we can position the caret at the next placeholder character.
|
|
178
|
+
placeholder[_i] === placeholderChar || // If a caret trap was set by a mask function, we need to stop at the trap.
|
|
179
|
+
caretTrapIndexes.indexOf(_i) !== -1 || // This is the end of the placeholder. We cannot move any further. Let's put the caret there.
|
|
180
|
+
_i === placeholderLength) {
|
|
181
|
+
return lastPlaceholderChar;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
// In case of deletion, we rewind.
|
|
186
|
+
if (trackRightCharacter) {
|
|
187
|
+
// Searching for the character that was to the right of the caret
|
|
188
|
+
// We start at `startingSearchIndex` - 1 because it includes one character extra to the right
|
|
189
|
+
for (var _i2 = startingSearchIndex - 1; _i2 >= 0; _i2--) {
|
|
190
|
+
// If tracking the character to the right of the cursor, we move to the left until
|
|
191
|
+
// we found the character and then place the caret right before it
|
|
192
|
+
if ( // `targetChar` should be in `conformedValue`, since it was in `rawValue`, just
|
|
193
|
+
// to the right of the caret
|
|
194
|
+
conformedValue[_i2] === targetChar || // If a caret trap was set by a mask function, we need to stop at the trap.
|
|
195
|
+
caretTrapIndexes.indexOf(_i2) !== -1 || // This is the beginning of the placeholder. We cannot move any further.
|
|
196
|
+
// Let's put the caret there.
|
|
197
|
+
_i2 === 0) {
|
|
198
|
+
return _i2;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
// Searching for the first placeholder or caret trap to the left
|
|
203
|
+
for (var _i3 = startingSearchIndex; _i3 >= 0; _i3--) {
|
|
204
|
+
// If we're deleting, we stop the caret right before the placeholder character.
|
|
205
|
+
// For example, for mask `(111) 11`, current conformed input `(456) 86`. If user
|
|
206
|
+
// modifies input to `(456 86`. That is, they deleted the `)`, we place the caret
|
|
207
|
+
// right after the first `6`
|
|
208
|
+
if ( // If we're deleting, we can position the caret right before the placeholder character
|
|
209
|
+
placeholder[_i3 - 1] === placeholderChar || // If a caret trap was set by a mask function, we need to stop at the trap.
|
|
210
|
+
caretTrapIndexes.indexOf(_i3) !== -1 || // This is the beginning of the placeholder. We cannot move any further.
|
|
211
|
+
// Let's put the caret there.
|
|
212
|
+
_i3 === 0) {
|
|
213
|
+
return _i3;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|