rsuite 5.53.2 → 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 (100) hide show
  1. package/AutoComplete/styles/index.css +0 -2
  2. package/CHANGELOG.md +18 -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/DatePicker/DatePicker.js +1 -1
  25. package/cjs/DateRangePicker/DateRangePicker.js +5 -0
  26. package/cjs/InlineEdit/EditableControls.d.ts +8 -0
  27. package/cjs/InlineEdit/EditableControls.js +34 -0
  28. package/cjs/InlineEdit/InlineEdit.d.ts +56 -0
  29. package/cjs/InlineEdit/InlineEdit.js +98 -0
  30. package/cjs/InlineEdit/index.d.ts +3 -0
  31. package/cjs/InlineEdit/index.js +9 -0
  32. package/cjs/InlineEdit/renderChildren.d.ts +12 -0
  33. package/cjs/InlineEdit/renderChildren.js +40 -0
  34. package/cjs/InlineEdit/useEditState.d.ts +22 -0
  35. package/cjs/InlineEdit/useEditState.js +82 -0
  36. package/cjs/InlineEdit/useFocusEvent.d.ts +14 -0
  37. package/cjs/InlineEdit/useFocusEvent.js +61 -0
  38. package/cjs/Input/Input.js +6 -3
  39. package/cjs/InputPicker/InputPicker.js +6 -5
  40. package/cjs/Slider/Slider.d.ts +2 -0
  41. package/cjs/Slider/Slider.js +4 -2
  42. package/cjs/index.d.ts +2 -0
  43. package/cjs/index.js +3 -1
  44. package/cjs/internals/Picker/Listbox.d.ts +5 -1
  45. package/cjs/internals/Picker/Listbox.js +6 -5
  46. package/cjs/internals/Picker/hooks/usePickerRef.js +2 -0
  47. package/cjs/internals/Picker/types.d.ts +2 -0
  48. package/cjs/internals/symbols.d.ts +2 -0
  49. package/cjs/internals/symbols.js +9 -0
  50. package/cjs/utils/getDataGroupBy.d.ts +0 -1
  51. package/cjs/utils/getDataGroupBy.js +3 -5
  52. package/dist/rsuite-no-reset-rtl.css +91 -4
  53. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  54. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  55. package/dist/rsuite-no-reset.css +91 -4
  56. package/dist/rsuite-no-reset.min.css +1 -1
  57. package/dist/rsuite-no-reset.min.css.map +1 -1
  58. package/dist/rsuite-rtl.css +91 -4
  59. package/dist/rsuite-rtl.min.css +1 -1
  60. package/dist/rsuite-rtl.min.css.map +1 -1
  61. package/dist/rsuite.css +91 -4
  62. package/dist/rsuite.js +86 -9
  63. package/dist/rsuite.js.map +1 -1
  64. package/dist/rsuite.min.css +1 -1
  65. package/dist/rsuite.min.css.map +1 -1
  66. package/dist/rsuite.min.js +1 -1
  67. package/dist/rsuite.min.js.map +1 -1
  68. package/esm/DatePicker/DatePicker.js +1 -1
  69. package/esm/DateRangePicker/DateRangePicker.js +5 -0
  70. package/esm/InlineEdit/EditableControls.d.ts +8 -0
  71. package/esm/InlineEdit/EditableControls.js +28 -0
  72. package/esm/InlineEdit/InlineEdit.d.ts +56 -0
  73. package/esm/InlineEdit/InlineEdit.js +92 -0
  74. package/esm/InlineEdit/index.d.ts +3 -0
  75. package/esm/InlineEdit/index.js +3 -0
  76. package/esm/InlineEdit/renderChildren.d.ts +12 -0
  77. package/esm/InlineEdit/renderChildren.js +34 -0
  78. package/esm/InlineEdit/useEditState.d.ts +22 -0
  79. package/esm/InlineEdit/useEditState.js +76 -0
  80. package/esm/InlineEdit/useFocusEvent.d.ts +14 -0
  81. package/esm/InlineEdit/useFocusEvent.js +56 -0
  82. package/esm/Input/Input.js +6 -3
  83. package/esm/InputPicker/InputPicker.js +6 -5
  84. package/esm/Slider/Slider.d.ts +2 -0
  85. package/esm/Slider/Slider.js +4 -2
  86. package/esm/index.d.ts +2 -0
  87. package/esm/index.js +1 -0
  88. package/esm/internals/Picker/Listbox.d.ts +5 -1
  89. package/esm/internals/Picker/Listbox.js +7 -6
  90. package/esm/internals/Picker/hooks/usePickerRef.js +2 -0
  91. package/esm/internals/Picker/types.d.ts +2 -0
  92. package/esm/internals/symbols.d.ts +2 -0
  93. package/esm/internals/symbols.js +3 -0
  94. package/esm/utils/getDataGroupBy.d.ts +0 -1
  95. package/esm/utils/getDataGroupBy.js +2 -3
  96. package/package.json +1 -1
  97. package/styles/color-modes/dark.less +3 -0
  98. package/styles/color-modes/high-contrast.less +3 -0
  99. package/styles/color-modes/light.less +3 -0
  100. package/styles/index.less +1 -0
@@ -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, {
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';
package/esm/index.js CHANGED
@@ -57,6 +57,7 @@ export { default as Uploader } from './Uploader';
57
57
  export { default as Slider } from './Slider';
58
58
  export { default as RangeSlider } from './RangeSlider';
59
59
  export { default as Rate } from './Rate';
60
+ export { default as InlineEdit } from './InlineEdit';
60
61
  // Data display
61
62
  export { default as Tree } from './Tree';
62
63
  export { default as CheckTree } from './CheckTree';
@@ -1,9 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ListProps, ListHandle } from '../../internals/Windowing';
3
3
  import { StandardProps, ItemDataType } from '../../@types/common';
4
+ import { RSUITE_PICKER_GROUP_KEY } from '../../internals/symbols';
5
+ interface InnerItemDataType extends ItemDataType {
6
+ [RSUITE_PICKER_GROUP_KEY]?: boolean;
7
+ }
4
8
  export interface ListboxProps<Multiple = false> extends StandardProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
5
9
  classPrefix: string;
6
- data?: ItemDataType[];
10
+ data?: InnerItemDataType[];
7
11
  group?: boolean;
8
12
  groupBy?: string;
9
13
  disabledItemValues?: any[];
@@ -17,8 +17,9 @@ import { List, AutoSizer, VariableSizeList } from '../../internals/Windowing';
17
17
  import shallowEqual from '../../utils/shallowEqual';
18
18
  import { mergeRefs, useClassNames, useMount, useEventCallback } from '../../utils';
19
19
  import ListItemGroup from './ListItemGroup';
20
- import { KEY_GROUP, KEY_GROUP_TITLE } from '../../utils/getDataGroupBy';
20
+ import { KEY_GROUP_TITLE } from '../../utils/getDataGroupBy';
21
21
  import useCombobox from './hooks/useCombobox';
22
+ import { RSUITE_PICKER_GROUP_KEY } from '../../internals/symbols';
22
23
  var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
23
24
  var _props$data = props.data,
24
25
  data = _props$data === void 0 ? [] : _props$data,
@@ -86,7 +87,7 @@ var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
86
87
  });
87
88
  var getRowHeight = function getRowHeight(list, index) {
88
89
  var item = list[index];
89
- if (group && item[KEY_GROUP] && index !== 0) {
90
+ if (group && item[RSUITE_PICKER_GROUP_KEY] && index !== 0) {
90
91
  return rowGroupHeight;
91
92
  }
92
93
  return rowHeight;
@@ -115,7 +116,7 @@ var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
115
116
  var filteredItems = group ? data.filter(function (item) {
116
117
  var _item$parent;
117
118
  // Display group title items
118
- if (item[KEY_GROUP]) return true;
119
+ if (item[RSUITE_PICKER_GROUP_KEY]) return true;
119
120
 
120
121
  // Display items under the unfolded group
121
122
  // FIXME-Doma
@@ -139,7 +140,7 @@ var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
139
140
  var item = itemData || data[index];
140
141
  var value = item[valueKey];
141
142
  var label = item[labelKey];
142
- if (isUndefined(label) && !item[KEY_GROUP]) {
143
+ if (isUndefined(label) && !item[RSUITE_PICKER_GROUP_KEY]) {
143
144
  throw Error("labelKey \"" + labelKey + "\" is not defined in \"data\" : " + index);
144
145
  }
145
146
 
@@ -150,7 +151,7 @@ var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
150
151
  * Render <ListboxGroup>
151
152
  * when if `group` is enabled
152
153
  */
153
- if (group && item[KEY_GROUP]) {
154
+ if (group && item[RSUITE_PICKER_GROUP_KEY]) {
154
155
  var groupValue = item[KEY_GROUP_TITLE];
155
156
  // TODO: grouped options should be owned by group
156
157
  return /*#__PURE__*/React.createElement(ListItemGroup, {
@@ -164,7 +165,7 @@ var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
164
165
  key: "group-" + groupValue,
165
166
  onClick: handleGroupTitleClick.bind(null, groupValue)
166
167
  }, renderMenuGroup ? renderMenuGroup(groupValue, item) : groupValue);
167
- } else if (isUndefined(value) && !isUndefined(item[KEY_GROUP])) {
168
+ } else if (isUndefined(value) && !isUndefined(item[RSUITE_PICKER_GROUP_KEY])) {
168
169
  throw Error("valueKey \"" + valueKey + "\" is not defined in \"data\" : " + index + " ");
169
170
  }
170
171
  var disabled = disabledItemValues === null || disabledItemValues === void 0 ? void 0 : disabledItemValues.some(function (disabledValue) {
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { useImperativeHandle, useRef } from 'react';
3
3
  import useEventCallback from '../../../utils/useEventCallback';
4
+ import { RSUITE_PICKER_TYPE } from '../../../internals/symbols';
4
5
  /**
5
6
  * A hook of the exposed method of Picker
6
7
  */
@@ -64,6 +65,7 @@ function usePickerRef(ref, parmas) {
64
65
  }
65
66
  return list === null || list === void 0 ? void 0 : list.current;
66
67
  },
68
+ type: RSUITE_PICKER_TYPE,
67
69
  updatePosition: handleUpdatePosition,
68
70
  open: handleOpen,
69
71
  close: handleClose