rsuite 5.53.1 → 5.54.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.
Files changed (106) hide show
  1. package/AutoComplete/styles/index.css +0 -2
  2. package/CHANGELOG.md +28 -0
  3. package/Cascader/styles/index.css +0 -2
  4. package/CheckPicker/styles/index.css +0 -2
  5. package/CheckTree/styles/index.css +0 -2
  6. package/CheckTreePicker/styles/index.css +0 -2
  7. package/DatePicker/styles/index.css +0 -2
  8. package/DateRangePicker/styles/index.css +0 -2
  9. package/FormGroup/styles/index.css +3 -0
  10. package/FormGroup/styles/index.less +2 -0
  11. package/InlineEdit/package.json +7 -0
  12. package/InlineEdit/styles/index.css +112 -0
  13. package/InlineEdit/styles/index.less +48 -0
  14. package/InputGroup/styles/index.css +0 -2
  15. package/InputGroup/styles/index.less +0 -2
  16. package/InputNumber/styles/index.css +0 -2
  17. package/InputPicker/styles/index.css +0 -2
  18. package/MultiCascader/styles/index.css +0 -2
  19. package/Pagination/styles/index.css +0 -2
  20. package/SelectPicker/styles/index.css +0 -2
  21. package/TagInput/styles/index.css +1 -4
  22. package/TagPicker/styles/index.css +1 -4
  23. package/TagPicker/styles/index.less +1 -2
  24. package/cjs/CheckTreePicker/CheckTreePicker.js +20 -10
  25. package/cjs/DatePicker/DatePicker.js +1 -1
  26. package/cjs/DateRangePicker/DateRangePicker.js +5 -0
  27. package/cjs/InlineEdit/EditableControls.d.ts +8 -0
  28. package/cjs/InlineEdit/EditableControls.js +34 -0
  29. package/cjs/InlineEdit/InlineEdit.d.ts +56 -0
  30. package/cjs/InlineEdit/InlineEdit.js +98 -0
  31. package/cjs/InlineEdit/index.d.ts +3 -0
  32. package/cjs/InlineEdit/index.js +9 -0
  33. package/cjs/InlineEdit/renderChildren.d.ts +12 -0
  34. package/cjs/InlineEdit/renderChildren.js +40 -0
  35. package/cjs/InlineEdit/useEditState.d.ts +22 -0
  36. package/cjs/InlineEdit/useEditState.js +82 -0
  37. package/cjs/InlineEdit/useFocusEvent.d.ts +14 -0
  38. package/cjs/InlineEdit/useFocusEvent.js +61 -0
  39. package/cjs/Input/Input.js +6 -3
  40. package/cjs/InputPicker/InputPicker.js +6 -5
  41. package/cjs/Slider/Slider.d.ts +2 -0
  42. package/cjs/Slider/Slider.js +4 -2
  43. package/cjs/TreePicker/TreePicker.js +20 -11
  44. package/cjs/index.d.ts +2 -0
  45. package/cjs/index.js +3 -1
  46. package/cjs/internals/Picker/ListCheckItem.js +0 -1
  47. package/cjs/internals/Picker/Listbox.d.ts +5 -1
  48. package/cjs/internals/Picker/Listbox.js +6 -5
  49. package/cjs/internals/Picker/hooks/usePickerRef.js +2 -0
  50. package/cjs/internals/Picker/types.d.ts +2 -0
  51. package/cjs/internals/symbols.d.ts +2 -0
  52. package/cjs/internals/symbols.js +9 -0
  53. package/cjs/utils/getDataGroupBy.d.ts +0 -1
  54. package/cjs/utils/getDataGroupBy.js +3 -5
  55. package/dist/rsuite-no-reset-rtl.css +91 -4
  56. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  57. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  58. package/dist/rsuite-no-reset.css +91 -4
  59. package/dist/rsuite-no-reset.min.css +1 -1
  60. package/dist/rsuite-no-reset.min.css.map +1 -1
  61. package/dist/rsuite-rtl.css +91 -4
  62. package/dist/rsuite-rtl.min.css +1 -1
  63. package/dist/rsuite-rtl.min.css.map +1 -1
  64. package/dist/rsuite.css +91 -4
  65. package/dist/rsuite.js +89 -12
  66. package/dist/rsuite.js.map +1 -1
  67. package/dist/rsuite.min.css +1 -1
  68. package/dist/rsuite.min.css.map +1 -1
  69. package/dist/rsuite.min.js +1 -1
  70. package/dist/rsuite.min.js.map +1 -1
  71. package/esm/CheckTreePicker/CheckTreePicker.js +20 -10
  72. package/esm/DatePicker/DatePicker.js +1 -1
  73. package/esm/DateRangePicker/DateRangePicker.js +5 -0
  74. package/esm/InlineEdit/EditableControls.d.ts +8 -0
  75. package/esm/InlineEdit/EditableControls.js +28 -0
  76. package/esm/InlineEdit/InlineEdit.d.ts +56 -0
  77. package/esm/InlineEdit/InlineEdit.js +92 -0
  78. package/esm/InlineEdit/index.d.ts +3 -0
  79. package/esm/InlineEdit/index.js +3 -0
  80. package/esm/InlineEdit/renderChildren.d.ts +12 -0
  81. package/esm/InlineEdit/renderChildren.js +34 -0
  82. package/esm/InlineEdit/useEditState.d.ts +22 -0
  83. package/esm/InlineEdit/useEditState.js +76 -0
  84. package/esm/InlineEdit/useFocusEvent.d.ts +14 -0
  85. package/esm/InlineEdit/useFocusEvent.js +56 -0
  86. package/esm/Input/Input.js +6 -3
  87. package/esm/InputPicker/InputPicker.js +6 -5
  88. package/esm/Slider/Slider.d.ts +2 -0
  89. package/esm/Slider/Slider.js +4 -2
  90. package/esm/TreePicker/TreePicker.js +20 -11
  91. package/esm/index.d.ts +2 -0
  92. package/esm/index.js +1 -0
  93. package/esm/internals/Picker/ListCheckItem.js +0 -1
  94. package/esm/internals/Picker/Listbox.d.ts +5 -1
  95. package/esm/internals/Picker/Listbox.js +7 -6
  96. package/esm/internals/Picker/hooks/usePickerRef.js +2 -0
  97. package/esm/internals/Picker/types.d.ts +2 -0
  98. package/esm/internals/symbols.d.ts +2 -0
  99. package/esm/internals/symbols.js +3 -0
  100. package/esm/utils/getDataGroupBy.d.ts +0 -1
  101. package/esm/utils/getDataGroupBy.js +2 -3
  102. package/package.json +1 -1
  103. package/styles/color-modes/dark.less +3 -0
  104. package/styles/color-modes/high-contrast.less +3 -0
  105. package/styles/color-modes/light.less +3 -0
  106. package/styles/index.less +1 -0
@@ -130,7 +130,7 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
130
130
  var _useClassNames = useClassNames(classPrefix),
131
131
  prefix = _useClassNames.prefix,
132
132
  merge = _useClassNames.merge;
133
- var _useClassNames2 = useClassNames('check-tree'),
133
+ var _useClassNames2 = useClassNames(inline && classPrefix !== 'picker' ? classPrefix : 'check-tree'),
134
134
  checkTreePrefix = _useClassNames2.prefix,
135
135
  withCheckTreeClassPrefix = _useClassNames2.withClassPrefix;
136
136
  var _useControlled = useControlled(controlledValue, defaultValue),
@@ -602,8 +602,11 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
602
602
  }, nodeProps));
603
603
  };
604
604
  var renderCheckTree = function renderCheckTree() {
605
- var _withCheckTreeClassPr, _merge2;
606
- var classes = withCheckTreeClassPrefix((_withCheckTreeClassPr = {}, _withCheckTreeClassPr[className !== null && className !== void 0 ? className : ''] = inline, _withCheckTreeClassPr['without-children'] = !isSomeNodeHasChildren(data, childrenKey), _withCheckTreeClassPr.virtualized = virtualized, _withCheckTreeClassPr));
605
+ var _merge2, _merge3;
606
+ var classes = merge(withCheckTreeClassPrefix({
607
+ 'without-children': !isSomeNodeHasChildren(data, childrenKey),
608
+ virtualized: virtualized
609
+ }), (_merge2 = {}, _merge2[className !== null && className !== void 0 ? className : ''] = inline, _merge2));
607
610
  var formattedNodes = getFormattedNodes(renderNode);
608
611
  if (!formattedNodes.some(function (v) {
609
612
  return v !== null;
@@ -612,18 +615,25 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
612
615
  className: prefix('none')
613
616
  }, locale.noResultsText);
614
617
  }
615
- var treeNodesClass = merge(checkTreePrefix('root'), (_merge2 = {}, _merge2[checkTreePrefix('all-uncheckable')] = isEveryFirstLevelNodeUncheckable(flattenNodes, uncheckableItemValues, valueKey), _merge2));
616
- return /*#__PURE__*/React.createElement(TreeView, {
617
- ref: inline ? root : treeView,
618
+ var treeNodesClass = merge(checkTreePrefix('root'), (_merge3 = {}, _merge3[checkTreePrefix('all-uncheckable')] = isEveryFirstLevelNodeUncheckable(flattenNodes, uncheckableItemValues, valueKey), _merge3));
619
+ var treeViewProps = {
620
+ ref: treeView
621
+ };
622
+ if (inline) {
623
+ treeViewProps = _extends({
624
+ ref: root,
625
+ style: _extends({
626
+ height: height
627
+ }, style)
628
+ }, rest);
629
+ }
630
+ return /*#__PURE__*/React.createElement(TreeView, _extends({}, treeViewProps, {
618
631
  multiselectable: true,
619
632
  treeRootClassName: treeNodesClass,
620
633
  className: classes,
621
- style: inline ? _extends({
622
- height: height
623
- }, style) : {},
624
634
  onScroll: onScroll,
625
635
  onKeyDown: inline ? handleTreeKeydown : undefined
626
- }, virtualized ? /*#__PURE__*/React.createElement(AutoSizer, {
636
+ }), virtualized ? /*#__PURE__*/React.createElement(AutoSizer, {
627
637
  defaultHeight: inline ? height : menuMaxHeight,
628
638
  style: {
629
639
  width: 'auto',
@@ -437,7 +437,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
437
437
  locale: locale,
438
438
  disabledShortcut: disabledToolbarHandle,
439
439
  onShortcutClick: handleShortcutPageDate
440
- }), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarContainer, _extends({}, calendarProps, {
440
+ }), /*#__PURE__*/React.createElement(Stack.Item, null, /*#__PURE__*/React.createElement(CalendarContainer, _extends({}, calendarProps, {
441
441
  targetId: id,
442
442
  locale: locale,
443
443
  showWeekNumbers: showWeekNumbers,
@@ -668,6 +668,11 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
668
668
  if (!value) {
669
669
  return false;
670
670
  }
671
+
672
+ // If the value is an empty array, it is not an error value.
673
+ if (Array.isArray(value) && value.length === 0) {
674
+ return false;
675
+ }
671
676
  var startDate = value[0],
672
677
  endDate = value[1];
673
678
  if (!isValid(startDate) || !isValid(endDate)) {
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { type StackProps } from '../Stack';
3
+ interface EditableControlsProps extends StackProps {
4
+ onSave: () => void;
5
+ onCancel: () => void;
6
+ }
7
+ declare const EditableControls: React.ForwardRefExoticComponent<EditableControlsProps & React.RefAttributes<HTMLDivElement>>;
8
+ export default EditableControls;
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
+ import React from 'react';
5
+ import CheckIcon from '@rsuite/icons/Check';
6
+ import CloseIcon from '@rsuite/icons/Close';
7
+ import IconButton from '../IconButton';
8
+ import Stack from '../Stack';
9
+ var EditableControls = /*#__PURE__*/React.forwardRef(function (props, ref) {
10
+ var onSave = props.onSave,
11
+ onCancel = props.onCancel,
12
+ rest = _objectWithoutPropertiesLoose(props, ["onSave", "onCancel"]);
13
+ return /*#__PURE__*/React.createElement(Stack, _extends({
14
+ ref: ref,
15
+ spacing: 6
16
+ }, rest), /*#__PURE__*/React.createElement(IconButton, {
17
+ size: "sm",
18
+ icon: /*#__PURE__*/React.createElement(CheckIcon, null),
19
+ "aria-label": "Save",
20
+ onClick: onSave
21
+ }), /*#__PURE__*/React.createElement(IconButton, {
22
+ size: "sm",
23
+ icon: /*#__PURE__*/React.createElement(CloseIcon, null),
24
+ "aria-label": "Cancel",
25
+ onClick: onCancel
26
+ }));
27
+ });
28
+ export default EditableControls;
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
3
+ import { type ChildrenProps } from './renderChildren';
4
+ export interface InlineEditProps extends WithAsProps {
5
+ /**
6
+ * If true, the InlineEdit will be disabled.
7
+ */
8
+ disabled?: boolean;
9
+ /**
10
+ * The initial value of the InlineEdit when it is not controlled.
11
+ */
12
+ defaultValue?: any;
13
+ /**
14
+ * The value of the InlineEdit.
15
+ */
16
+ value?: any;
17
+ /**
18
+ * show the control buttons when editing.
19
+ * @default true
20
+ */
21
+ showControls?: boolean;
22
+ /**
23
+ * The placeholder of the InlineEdit.
24
+ */
25
+ placeholder?: string;
26
+ /**
27
+ * The size of the InlineEdit.
28
+ */
29
+ size?: 'lg' | 'md' | 'sm' | 'xs';
30
+ /**
31
+ * The state of the InlineEdit when it is blurred.
32
+ */
33
+ stateOnBlur?: 'save' | 'cancel';
34
+ /**
35
+ * The callback function that is called when the value of the InlineEdit is changed.
36
+ */
37
+ onChange?: (value: any, event: React.ChangeEvent) => void;
38
+ /**
39
+ * The callback function that is called when the InlineEdit is canceled.
40
+ */
41
+ onCancel?: (event?: React.SyntheticEvent) => void;
42
+ /**
43
+ * The callback function that is called when the InlineEdit is saved.
44
+ */
45
+ onSave?: (event?: React.SyntheticEvent) => void;
46
+ /**
47
+ * The callback function that is called when the InlineEdit is clicked.
48
+ */
49
+ onEdit?: (event: React.SyntheticEvent) => void;
50
+ /**
51
+ * The render function of the InlineEdit.
52
+ */
53
+ children?: ((props: ChildrenProps, ref: React.Ref<any>) => React.ReactElement) | React.ReactElement;
54
+ }
55
+ declare const InlineEdit: RsRefForwardingComponent<'div', InlineEditProps>;
56
+ export default InlineEdit;
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useClassNames, mergeRefs } from '../utils';
7
+ import { oneOf } from '../internals/propTypes';
8
+ import EditableControls from './EditableControls';
9
+ import useFocusEvent from './useFocusEvent';
10
+ import useEditState from './useEditState';
11
+ import { renderChildren, defaultRenderInput } from './renderChildren';
12
+ var InlineEdit = /*#__PURE__*/React.forwardRef(function (props, ref) {
13
+ var _props$as = props.as,
14
+ Component = _props$as === void 0 ? 'div' : _props$as,
15
+ _props$children = props.children,
16
+ children = _props$children === void 0 ? defaultRenderInput : _props$children,
17
+ _props$classPrefix = props.classPrefix,
18
+ classPrefix = _props$classPrefix === void 0 ? 'inline-edit' : _props$classPrefix,
19
+ className = props.className,
20
+ disabled = props.disabled,
21
+ size = props.size,
22
+ _props$showControls = props.showControls,
23
+ showControls = _props$showControls === void 0 ? true : _props$showControls,
24
+ _props$stateOnBlur = props.stateOnBlur,
25
+ stateOnBlur = _props$stateOnBlur === void 0 ? 'save' : _props$stateOnBlur,
26
+ placeholder = props.placeholder,
27
+ rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "className", "disabled", "size", "showControls", "stateOnBlur", "placeholder"]);
28
+ var _useClassNames = useClassNames(classPrefix),
29
+ withClassPrefix = _useClassNames.withClassPrefix,
30
+ merge = _useClassNames.merge,
31
+ prefix = _useClassNames.prefix;
32
+ var _useEditState = useEditState(_extends({}, rest, {
33
+ disabled: disabled
34
+ })),
35
+ value = _useEditState.value,
36
+ isEditing = _useEditState.isEditing,
37
+ onSave = _useEditState.onSave,
38
+ onCancel = _useEditState.onCancel,
39
+ onChange = _useEditState.onChange,
40
+ onKeyDown = _useEditState.onKeyDown,
41
+ onClick = _useEditState.onClick,
42
+ htmlProps = _useEditState.htmlProps;
43
+ var _useFocusEvent = useFocusEvent({
44
+ isEditing: isEditing,
45
+ stateOnBlur: stateOnBlur,
46
+ onSave: onSave,
47
+ onCancel: onCancel
48
+ }),
49
+ target = _useFocusEvent.target,
50
+ root = _useFocusEvent.root,
51
+ onBlur = _useFocusEvent.onBlur;
52
+ var childrenProps = {
53
+ size: size,
54
+ value: value,
55
+ disabled: disabled,
56
+ placeholder: placeholder,
57
+ plaintext: !isEditing,
58
+ onChange: onChange,
59
+ onBlur: onBlur
60
+ };
61
+ return /*#__PURE__*/React.createElement(Component, _extends({
62
+ ref: mergeRefs(root, ref),
63
+ tabIndex: 0,
64
+ className: merge(className, withClassPrefix(size, {
65
+ disabled: disabled
66
+ })),
67
+ onClick: onClick,
68
+ onKeyDown: onKeyDown
69
+ }, htmlProps), renderChildren(children, childrenProps, target), showControls && isEditing && /*#__PURE__*/React.createElement(EditableControls, {
70
+ className: prefix('controls'),
71
+ onSave: onSave,
72
+ onCancel: onCancel
73
+ }));
74
+ });
75
+ InlineEdit.displayName = 'InlineEdit';
76
+ InlineEdit.propTypes = {
77
+ children: PropTypes.any,
78
+ classPrefix: PropTypes.string,
79
+ className: PropTypes.string,
80
+ disabled: PropTypes.bool,
81
+ defaultValue: PropTypes.any,
82
+ value: PropTypes.any,
83
+ showControls: PropTypes.bool,
84
+ placeholder: PropTypes.string,
85
+ size: oneOf(['lg', 'md', 'sm', 'xs']),
86
+ stateOnBlur: oneOf(['save', 'cancel']),
87
+ onChange: PropTypes.func,
88
+ onCancel: PropTypes.func,
89
+ onSave: PropTypes.func,
90
+ onEdit: PropTypes.func
91
+ };
92
+ export default InlineEdit;
@@ -0,0 +1,3 @@
1
+ import InlineEdit from './InlineEdit';
2
+ export type { InlineEditProps } from './InlineEdit';
3
+ export default InlineEdit;
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ import InlineEdit from './InlineEdit';
3
+ export default InlineEdit;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface ChildrenProps {
3
+ size?: 'lg' | 'md' | 'sm' | 'xs';
4
+ disabled?: boolean;
5
+ placeholder?: string;
6
+ plaintext?: boolean;
7
+ value: any;
8
+ onChange: (value: any, event: React.SyntheticEvent) => void;
9
+ onBlur?: (event: React.SyntheticEvent) => void;
10
+ }
11
+ export declare function defaultRenderInput(props: ChildrenProps, ref: React.Ref<any>): JSX.Element;
12
+ export declare function renderChildren(children: ((props: ChildrenProps, ref: React.Ref<any>) => React.ReactElement) | React.ReactElement, props: ChildrenProps, ref: React.Ref<any>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import React from 'react';
5
+ import Input from '../Input';
6
+ export function defaultRenderInput(props, ref) {
7
+ return /*#__PURE__*/React.createElement(Input, _extends({
8
+ ref: ref
9
+ }, props));
10
+ }
11
+ var pickers = ['DatePicker', 'DateRangePicker', 'InputPicker', 'TagPicker', 'Cascader', 'MultiCascader', 'SelectPicker', 'CheckPicker', 'CheckTreePicker', 'TreePicker'];
12
+ function getDisplayName(Component) {
13
+ var _Component$type;
14
+ if (typeof (Component === null || Component === void 0 ? void 0 : Component.type) === 'string') {
15
+ return Component === null || Component === void 0 ? void 0 : Component.type;
16
+ }
17
+ return (Component === null || Component === void 0 ? void 0 : (_Component$type = Component.type) === null || _Component$type === void 0 ? void 0 : _Component$type.displayName) || '';
18
+ }
19
+ export function renderChildren(children, props, ref) {
20
+ if (typeof children === 'function') {
21
+ return children(props, ref);
22
+ }
23
+ if (pickers.includes(getDisplayName(children))) {
24
+ var onBlur = props.onBlur,
25
+ rest = _objectWithoutPropertiesLoose(props, ["onBlur"]); // if the children is a picker, we should pass the onBlur to the onClose
26
+ return /*#__PURE__*/React.cloneElement(children, _extends({}, rest, {
27
+ onClose: onBlur,
28
+ ref: ref
29
+ }));
30
+ }
31
+ return /*#__PURE__*/React.cloneElement(children, _extends({}, props, {
32
+ ref: ref
33
+ }));
34
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ interface EditStateProps {
3
+ value?: any;
4
+ defaultValue?: any;
5
+ disabled?: boolean;
6
+ onChange?: (value: any, event: React.ChangeEvent) => void;
7
+ onEdit?: (event: React.SyntheticEvent) => void;
8
+ onCancel?: (event?: React.MouseEvent) => void;
9
+ onSave?: (event?: React.MouseEvent) => void;
10
+ onClick?: (event: React.SyntheticEvent) => void;
11
+ }
12
+ declare const useEditState: (props: EditStateProps) => {
13
+ isEditing: boolean;
14
+ value: any;
15
+ onClick: (...args: any[]) => any;
16
+ onChange: (...args: any[]) => any;
17
+ onCancel: (...args: any[]) => any;
18
+ onSave: (...args: any[]) => any;
19
+ onKeyDown: (...args: any[]) => any;
20
+ htmlProps: {};
21
+ };
22
+ export default useEditState;
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ import { useState } from 'react';
4
+ import { useEventCallback, useControlled } from '../utils';
5
+ var useEditState = function useEditState(props) {
6
+ var valueProp = props.value,
7
+ defaultValue = props.defaultValue,
8
+ disabled = props.disabled,
9
+ onChange = props.onChange,
10
+ onEdit = props.onEdit,
11
+ onCancel = props.onCancel,
12
+ onSave = props.onSave,
13
+ onClick = props.onClick,
14
+ htmlProps = _objectWithoutPropertiesLoose(props, ["value", "defaultValue", "disabled", "onChange", "onEdit", "onCancel", "onSave", "onClick"]);
15
+ var _useState = useState(false),
16
+ isEditing = _useState[0],
17
+ setIsEditing = _useState[1];
18
+ var _useControlled = useControlled(valueProp, defaultValue),
19
+ value = _useControlled[0],
20
+ setValue = _useControlled[1]; // When editing, the value is not updated, and the original value is restored when canceling
21
+ var _useState2 = useState(),
22
+ resetValue = _useState2[0],
23
+ setResetValue = _useState2[1];
24
+ var handleClick = useEventCallback(function (event) {
25
+ if (disabled) {
26
+ return;
27
+ }
28
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
29
+ onEdit === null || onEdit === void 0 ? void 0 : onEdit(event);
30
+ setIsEditing(true);
31
+ setResetValue(value);
32
+ });
33
+ var handleChange = useEventCallback(function (value, event) {
34
+ setValue(value);
35
+ onChange === null || onChange === void 0 ? void 0 : onChange(value, event);
36
+ });
37
+ var handleCancel = useEventCallback(function (event) {
38
+ var _event$stopPropagatio;
39
+ setIsEditing(false);
40
+ setValue(resetValue);
41
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel(event);
42
+ event === null || event === void 0 ? void 0 : (_event$stopPropagatio = event.stopPropagation) === null || _event$stopPropagatio === void 0 ? void 0 : _event$stopPropagatio.call(event);
43
+ });
44
+ var handleSave = useEventCallback(function (event) {
45
+ var _event$stopPropagatio2;
46
+ setIsEditing(false);
47
+ onSave === null || onSave === void 0 ? void 0 : onSave(event);
48
+ event === null || event === void 0 ? void 0 : (_event$stopPropagatio2 = event.stopPropagation) === null || _event$stopPropagatio2 === void 0 ? void 0 : _event$stopPropagatio2.call(event);
49
+ });
50
+ var handleKeyDown = useEventCallback(function (event) {
51
+ var _event$target;
52
+ if (isEditing) {
53
+ switch (event.key) {
54
+ case 'Enter':
55
+ if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) === 'INPUT') {
56
+ handleSave(event);
57
+ }
58
+ break;
59
+ case 'Escape':
60
+ handleCancel(event);
61
+ break;
62
+ }
63
+ }
64
+ });
65
+ return {
66
+ isEditing: isEditing,
67
+ value: value,
68
+ onClick: handleClick,
69
+ onChange: handleChange,
70
+ onCancel: handleCancel,
71
+ onSave: handleSave,
72
+ onKeyDown: handleKeyDown,
73
+ htmlProps: htmlProps
74
+ };
75
+ };
76
+ export default useEditState;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { PickerHandle } from '../internals/Picker/types';
3
+ interface FocusEventProps {
4
+ isEditing: boolean;
5
+ stateOnBlur?: 'save' | 'cancel';
6
+ onSave?: (event?: React.FocusEvent) => void;
7
+ onCancel?: (event?: React.FocusEvent) => void;
8
+ }
9
+ declare const useFocusEvent: ({ isEditing, stateOnBlur, onSave, onCancel }: FocusEventProps) => {
10
+ target: import("react").RefObject<HTMLInputElement | PickerHandle>;
11
+ root: import("react").RefObject<HTMLDivElement>;
12
+ onBlur: (...args: any[]) => any;
13
+ };
14
+ export default useFocusEvent;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import { useRef } from 'react';
3
+ import { contains, ownerDocument } from 'dom-lib';
4
+ import { useIsomorphicLayoutEffect, useUpdateEffect, useEventCallback } from '../utils';
5
+ import { RSUITE_PICKER_TYPE } from '../internals/symbols';
6
+ var useFocusEvent = function useFocusEvent(_ref) {
7
+ var _ref$current;
8
+ var isEditing = _ref.isEditing,
9
+ stateOnBlur = _ref.stateOnBlur,
10
+ onSave = _ref.onSave,
11
+ onCancel = _ref.onCancel;
12
+ var ref = useRef(null);
13
+ var rootRef = useRef(null);
14
+ var isPicker = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.type) === RSUITE_PICKER_TYPE;
15
+ var focus = function focus() {
16
+ if (isPicker) {
17
+ setTimeout(function () {
18
+ var _ref$current2, _ref$current2$target, _ref$current2$target$;
19
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : (_ref$current2$target = _ref$current2.target) === null || _ref$current2$target === void 0 ? void 0 : (_ref$current2$target$ = _ref$current2$target.focus) === null || _ref$current2$target$ === void 0 ? void 0 : _ref$current2$target$.call(_ref$current2$target);
20
+ }, 100);
21
+ } else {
22
+ var _ref$current3, _ref$current3$focus;
23
+ (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : (_ref$current3$focus = _ref$current3.focus) === null || _ref$current3$focus === void 0 ? void 0 : _ref$current3$focus.call(_ref$current3);
24
+ }
25
+ };
26
+ var handleBlur = useEventCallback(function (event) {
27
+ if (event) {
28
+ var _event$relatedTarget;
29
+ var relatedTarget = (_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 ? _event$relatedTarget : ownerDocument(event.currentTarget).activeElement;
30
+ if (rootRef.current && contains(rootRef.current, relatedTarget)) {
31
+ return;
32
+ }
33
+ }
34
+ if (stateOnBlur === 'save') {
35
+ onSave === null || onSave === void 0 ? void 0 : onSave(event);
36
+ } else if (stateOnBlur === 'cancel') {
37
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel(event);
38
+ }
39
+ });
40
+ useIsomorphicLayoutEffect(function () {
41
+ if (isEditing) {
42
+ focus();
43
+ }
44
+ }, []);
45
+ useUpdateEffect(function () {
46
+ if (isEditing) {
47
+ focus();
48
+ }
49
+ }, [isEditing]);
50
+ return {
51
+ target: ref,
52
+ root: rootRef,
53
+ onBlur: handleBlur
54
+ };
55
+ };
56
+ export default useFocusEvent;
@@ -29,13 +29,14 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
29
29
  size = props.size,
30
30
  htmlSize = props.htmlSize,
31
31
  plaintext = props.plaintext,
32
+ placeholder = props.placeholder,
32
33
  readOnly = props.readOnly,
33
34
  onPressEnter = props.onPressEnter,
34
35
  onFocus = props.onFocus,
35
36
  onBlur = props.onBlur,
36
37
  onKeyDown = props.onKeyDown,
37
38
  onChange = props.onChange,
38
- rest = _objectWithoutPropertiesLoose(props, ["className", "classPrefix", "as", "type", "disabled", "value", "defaultValue", "inputRef", "id", "size", "htmlSize", "plaintext", "readOnly", "onPressEnter", "onFocus", "onBlur", "onKeyDown", "onChange"]);
39
+ rest = _objectWithoutPropertiesLoose(props, ["className", "classPrefix", "as", "type", "disabled", "value", "defaultValue", "inputRef", "id", "size", "htmlSize", "plaintext", "placeholder", "readOnly", "onPressEnter", "onFocus", "onBlur", "onKeyDown", "onChange"]);
39
40
  var handleKeyDown = function handleKeyDown(event) {
40
41
  if (event.key === KEY_VALUES.ENTER) {
41
42
  onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event);
@@ -60,7 +61,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
60
61
  if (plaintext) {
61
62
  return /*#__PURE__*/React.createElement(Plaintext, {
62
63
  ref: ref,
63
- localeKey: "unfilled"
64
+ localeKey: "unfilled",
65
+ placeholder: placeholder
64
66
  }, typeof value === 'undefined' ? defaultValue : value);
65
67
  }
66
68
  var inputable = !disabled && !readOnly;
@@ -80,7 +82,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
80
82
  defaultValue: defaultValue,
81
83
  disabled: disabled,
82
84
  readOnly: readOnly,
83
- size: htmlSize
85
+ size: htmlSize,
86
+ placeholder: placeholder
84
87
  }));
85
88
  });
86
89
  Input.displayName = 'Input';
@@ -25,6 +25,7 @@ import Tag from '../Tag';
25
25
  import InputAutosize from './InputAutosize';
26
26
  import TextBox from './TextBox';
27
27
  import InputPickerContext from './InputPickerContext';
28
+ import Stack from '../Stack';
28
29
  var convertSize = function convertSize(size) {
29
30
  switch (size) {
30
31
  case 'lg':
@@ -636,12 +637,12 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
636
637
  if (plaintext) {
637
638
  var plaintextProps = {};
638
639
 
639
- // TagPicker has -6px margin-left on the plaintext wrapper
640
- // for fixing margin-left on tags from 2nd line on
640
+ // When multiple selection, the tag is displayed in a stack layout.
641
641
  if (multi && hasValue) {
642
- plaintextProps.style = {
643
- marginLeft: -6
644
- };
642
+ plaintextProps.as = Stack;
643
+ plaintextProps.spacing = 6;
644
+ plaintextProps.wrap = true;
645
+ plaintextProps.childrenRenderMode = 'clone';
645
646
  }
646
647
  return /*#__PURE__*/React.createElement(Plaintext, _extends({
647
648
  localeKey: "notSelected",
@@ -40,6 +40,8 @@ export interface SliderProps<T = number> extends WithAsProps, FormControlBasePro
40
40
  tooltip?: boolean;
41
41
  /** Show sliding progress bar */
42
42
  progress?: boolean;
43
+ /** Placeholder text */
44
+ placeholder?: React.ReactNode;
43
45
  /** Vertical Slide */
44
46
  vertical?: boolean;
45
47
  /** Customize labels on the render ruler */
@@ -73,12 +73,13 @@ var Slider = /*#__PURE__*/React.forwardRef(function (props, ref) {
73
73
  valueProp = props.value,
74
74
  _props$max = props.max,
75
75
  maxProp = _props$max === void 0 ? 100 : _props$max,
76
+ placeholder = props.placeholder,
76
77
  getAriaValueText = props.getAriaValueText,
77
78
  renderTooltip = props.renderTooltip,
78
79
  renderMark = props.renderMark,
79
80
  onChange = props.onChange,
80
81
  onChangeCommitted = props.onChangeCommitted,
81
- rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "graduated", "className", "barClassName", "progress", "vertical", "disabled", "readOnly", "plaintext", "classPrefix", "min", "handleClassName", "handleStyle", "handleTitle", "tooltip", "step", "defaultValue", "value", "max", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
82
+ rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "graduated", "className", "barClassName", "progress", "vertical", "disabled", "readOnly", "plaintext", "classPrefix", "min", "handleClassName", "handleStyle", "handleTitle", "tooltip", "step", "defaultValue", "value", "max", "placeholder", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
82
83
  var barRef = useRef(null);
83
84
  var _useClassNames = useClassNames(classPrefix),
84
85
  merge = _useClassNames.merge,
@@ -200,7 +201,8 @@ var Slider = /*#__PURE__*/React.forwardRef(function (props, ref) {
200
201
  if (plaintext) {
201
202
  return /*#__PURE__*/React.createElement(Plaintext, {
202
203
  localeKey: "notSelected",
203
- ref: ref
204
+ ref: ref,
205
+ placeholder: placeholder
204
206
  }, value);
205
207
  }
206
208
  return /*#__PURE__*/React.createElement(Componnet, _extends({}, rest, {
@@ -157,7 +157,7 @@ var TreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
157
157
  var _useClassNames = useClassNames(classPrefix),
158
158
  prefix = _useClassNames.prefix,
159
159
  merge = _useClassNames.merge;
160
- var _useClassNames2 = useClassNames('tree'),
160
+ var _useClassNames2 = useClassNames(inline && classPrefix !== 'picker' ? classPrefix : 'tree'),
161
161
  treePrefix = _useClassNames2.prefix,
162
162
  withTreeClassPrefix = _useClassNames2.withClassPrefix;
163
163
  var _useTreeSearch = useTreeSearch({
@@ -584,18 +584,27 @@ var TreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
584
584
  }, nodeProps));
585
585
  };
586
586
  var renderTree = function renderTree() {
587
- var _withTreeClassPrefix;
588
- var classes = withTreeClassPrefix((_withTreeClassPrefix = {}, _withTreeClassPrefix[className !== null && className !== void 0 ? className : ''] = inline, _withTreeClassPrefix.virtualized = virtualized, _withTreeClassPrefix));
587
+ var _merge2;
588
+ var classes = merge(withTreeClassPrefix({
589
+ virtualized: virtualized
590
+ }), (_merge2 = {}, _merge2[className !== null && className !== void 0 ? className : ''] = inline, _merge2));
589
591
  var formattedNodes = getFormattedNodes(renderNode);
590
- return /*#__PURE__*/React.createElement(TreeView, {
592
+ var treeViewProps = {
593
+ ref: treeView
594
+ };
595
+ if (inline) {
596
+ treeViewProps = _extends({
597
+ ref: root,
598
+ style: _extends({
599
+ height: height
600
+ }, style),
601
+ onKeyDown: handleTreeKeyDown
602
+ }, rest);
603
+ }
604
+ return /*#__PURE__*/React.createElement(TreeView, _extends({}, treeViewProps, {
591
605
  treeRootClassName: treePrefix('root'),
592
- ref: inline ? root : treeView,
593
- className: classes,
594
- style: inline ? _extends({
595
- height: height
596
- }, style) : {},
597
- onKeyDown: inline ? handleTreeKeyDown : undefined
598
- }, virtualized ? /*#__PURE__*/React.createElement(AutoSizer, {
606
+ className: classes
607
+ }), virtualized ? /*#__PURE__*/React.createElement(AutoSizer, {
599
608
  defaultHeight: inline ? height : menuMaxHeight,
600
609
  style: {
601
610
  width: 'auto',
package/esm/index.d.ts CHANGED
@@ -108,6 +108,8 @@ export { default as RangeSlider } from './RangeSlider';
108
108
  export type { RangeSliderProps } from './RangeSlider';
109
109
  export { default as Rate } from './Rate';
110
110
  export type { RateProps } from './Rate';
111
+ export { default as InlineEdit } from './InlineEdit';
112
+ export type { InlineEditProps } from './InlineEdit';
111
113
  export { default as Tree } from './Tree';
112
114
  export type { TreeProps } from './Tree';
113
115
  export { default as CheckTree } from './CheckTree';