rsuite 5.79.1 → 5.80.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 (72) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/cjs/Calendar/Calendar.js +1 -2
  3. package/cjs/Calendar/CalendarBody.js +0 -2
  4. package/cjs/Calendar/CalendarContainer.js +1 -2
  5. package/cjs/Calendar/CalendarProvider.d.ts +1 -1
  6. package/cjs/Calendar/Grid/GridHeaderRow.js +1 -2
  7. package/cjs/Calendar/Grid/GridRow.d.ts +2 -0
  8. package/cjs/Calendar/Grid/GridRow.js +6 -4
  9. package/cjs/Calendar/hooks/useCalendar.d.ts +25 -2
  10. package/cjs/Calendar/hooks/useCalendar.js +36 -1
  11. package/cjs/CustomProvider/CustomContext.d.ts +253 -0
  12. package/cjs/CustomProvider/CustomContext.js +8 -0
  13. package/cjs/CustomProvider/CustomProvider.d.ts +1 -258
  14. package/cjs/CustomProvider/CustomProvider.js +2 -3
  15. package/cjs/CustomProvider/FormattedDate.js +2 -2
  16. package/cjs/CustomProvider/FormattedNumber.js +2 -2
  17. package/cjs/CustomProvider/index.d.ts +2 -2
  18. package/cjs/CustomProvider/index.js +4 -4
  19. package/cjs/CustomProvider/useCustom.js +2 -2
  20. package/cjs/DatePicker/DatePicker.js +1 -2
  21. package/cjs/DateRangePicker/DateRangePicker.js +1 -2
  22. package/cjs/DateRangePicker/utils.d.ts +1 -1
  23. package/cjs/DateRangePicker/utils.js +2 -1
  24. package/cjs/Image/hooks/useImage.js +2 -3
  25. package/cjs/InlineEdit/InlineEdit.js +3 -1
  26. package/cjs/InlineEdit/useEditState.d.ts +2 -0
  27. package/cjs/InlineEdit/useEditState.js +9 -1
  28. package/cjs/internals/Picker/propTypes.d.ts +2 -2
  29. package/cjs/internals/hooks/useClassNames.js +2 -2
  30. package/cjs/internals/utils/date/getWeekStartDates.d.ts +0 -1
  31. package/cjs/internals/utils/date/getWeekStartDates.js +2 -5
  32. package/cjs/internals/utils/date/index.d.ts +1 -0
  33. package/cjs/internals/utils/date/index.js +4 -1
  34. package/cjs/useToaster/useToaster.js +2 -2
  35. package/dist/rsuite.js +68 -24
  36. package/dist/rsuite.js.map +1 -1
  37. package/dist/rsuite.min.js +1 -1
  38. package/dist/rsuite.min.js.map +1 -1
  39. package/esm/Calendar/Calendar.js +1 -2
  40. package/esm/Calendar/CalendarBody.js +0 -2
  41. package/esm/Calendar/CalendarContainer.js +1 -2
  42. package/esm/Calendar/CalendarProvider.d.ts +1 -1
  43. package/esm/Calendar/Grid/GridHeaderRow.js +1 -2
  44. package/esm/Calendar/Grid/GridRow.d.ts +2 -0
  45. package/esm/Calendar/Grid/GridRow.js +6 -4
  46. package/esm/Calendar/hooks/useCalendar.d.ts +25 -2
  47. package/esm/Calendar/hooks/useCalendar.js +36 -2
  48. package/esm/CustomProvider/CustomContext.d.ts +253 -0
  49. package/esm/CustomProvider/CustomContext.js +3 -0
  50. package/esm/CustomProvider/CustomProvider.d.ts +1 -258
  51. package/esm/CustomProvider/CustomProvider.js +1 -1
  52. package/esm/CustomProvider/FormattedDate.js +1 -1
  53. package/esm/CustomProvider/FormattedNumber.js +1 -1
  54. package/esm/CustomProvider/index.d.ts +2 -2
  55. package/esm/CustomProvider/index.js +1 -1
  56. package/esm/CustomProvider/useCustom.js +1 -1
  57. package/esm/DatePicker/DatePicker.js +1 -2
  58. package/esm/DateRangePicker/DateRangePicker.js +1 -2
  59. package/esm/DateRangePicker/utils.d.ts +1 -1
  60. package/esm/DateRangePicker/utils.js +2 -1
  61. package/esm/Image/hooks/useImage.js +1 -1
  62. package/esm/InlineEdit/InlineEdit.js +3 -1
  63. package/esm/InlineEdit/useEditState.d.ts +2 -0
  64. package/esm/InlineEdit/useEditState.js +9 -1
  65. package/esm/internals/Picker/propTypes.d.ts +2 -2
  66. package/esm/internals/hooks/useClassNames.js +1 -1
  67. package/esm/internals/utils/date/getWeekStartDates.d.ts +0 -1
  68. package/esm/internals/utils/date/getWeekStartDates.js +2 -5
  69. package/esm/internals/utils/date/index.d.ts +1 -0
  70. package/esm/internals/utils/date/index.js +1 -0
  71. package/esm/useToaster/useToaster.js +1 -1
  72. package/package.json +2 -2
@@ -7,8 +7,8 @@ import IconProvider from '@rsuite/icons/IconProvider';
7
7
  import { usePortal, useIsomorphicLayoutEffect } from "../internals/hooks/index.js";
8
8
  import { getClassNamePrefix, prefix } from "../internals/utils/prefix.js";
9
9
  import { addClass, removeClass, canUseDOM } from "../DOMHelper/index.js";
10
+ import { CustomContext } from "./CustomContext.js";
10
11
  import ToastContainer, { toastPlacements, defaultToasterContainer } from "../toaster/ToastContainer.js";
11
- export var CustomContext = /*#__PURE__*/React.createContext({});
12
12
  var themes = ['light', 'dark', 'high-contrast'];
13
13
 
14
14
  /**
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
- import { useCustom } from "./useCustom.js";
3
+ import { useCustom } from "./index.js";
4
4
  export function FormattedDate(_ref) {
5
5
  var date = _ref.date,
6
6
  formatStr = _ref.formatStr;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import React, { useMemo } from 'react';
3
- import { useCustom } from "./useCustom.js";
3
+ import { useCustom } from "./index.js";
4
4
  export function FormattedNumber(_ref) {
5
5
  var value = _ref.value,
6
6
  formatOptions = _ref.formatOptions;
@@ -2,7 +2,7 @@ import CustomProvider from './CustomProvider';
2
2
  export { FormattedDate } from './FormattedDate';
3
3
  export { FormattedNumber } from './FormattedNumber';
4
4
  export { useCustom } from './useCustom';
5
- export { CustomContext } from './CustomProvider';
6
- export type { CustomProviderProps } from './CustomProvider';
5
+ export { CustomContext } from './CustomContext';
6
+ export type { CustomProviderProps } from './CustomContext';
7
7
  export type { ReactSuiteComponents } from './types';
8
8
  export default CustomProvider;
@@ -3,5 +3,5 @@ import CustomProvider from "./CustomProvider.js";
3
3
  export { FormattedDate } from "./FormattedDate.js";
4
4
  export { FormattedNumber } from "./FormattedNumber.js";
5
5
  export { useCustom } from "./useCustom.js";
6
- export { CustomContext } from "./CustomProvider.js";
6
+ export { CustomContext } from "./CustomContext.js";
7
7
  export default CustomProvider;
@@ -6,7 +6,7 @@ import { useContext, useCallback, useMemo } from 'react';
6
6
  import assign from 'lodash/assign';
7
7
  import enGB from "../locales/en_GB.js";
8
8
  import { format, parse, isValid } from "../internals/utils/date/index.js";
9
- import { CustomContext } from "./CustomProvider.js";
9
+ import { CustomContext } from "./CustomContext.js";
10
10
  function getDefaultRTL() {
11
11
  return typeof document !== 'undefined' && (document.body.getAttribute('dir') || document.dir) === 'rtl';
12
12
  }
@@ -56,8 +56,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
56
56
  format = propsWithDefaults.format,
57
57
  idProp = propsWithDefaults.id,
58
58
  isoWeek = propsWithDefaults.isoWeek,
59
- _propsWithDefaults$we = propsWithDefaults.weekStart,
60
- weekStart = _propsWithDefaults$we === void 0 ? 0 : _propsWithDefaults$we,
59
+ weekStart = propsWithDefaults.weekStart,
61
60
  _propsWithDefaults$li = propsWithDefaults.limitEndYear,
62
61
  limitEndYear = _propsWithDefaults$li === void 0 ? 1000 : _propsWithDefaults$li,
63
62
  limitStartYear = propsWithDefaults.limitStartYear,
@@ -67,8 +67,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
67
67
  idProp = propsWithDefaults.id,
68
68
  _propsWithDefaults$is = propsWithDefaults.isoWeek,
69
69
  isoWeek = _propsWithDefaults$is === void 0 ? false : _propsWithDefaults$is,
70
- _propsWithDefaults$we = propsWithDefaults.weekStart,
71
- weekStart = _propsWithDefaults$we === void 0 ? 0 : _propsWithDefaults$we,
70
+ weekStart = propsWithDefaults.weekStart,
72
71
  _propsWithDefaults$li = propsWithDefaults.limitEndYear,
73
72
  limitEndYear = _propsWithDefaults$li === void 0 ? 1000 : _propsWithDefaults$li,
74
73
  limitStartYear = propsWithDefaults.limitStartYear,
@@ -9,6 +9,6 @@ export declare const isSameRange: (source: DateRange | null, dest: DateRange | n
9
9
  export declare const getMonthHoverRange: (date: Date) => DateRange;
10
10
  export declare const getWeekHoverRange: (date: Date, options: {
11
11
  isoWeek: boolean;
12
- weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
12
+ weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
13
13
  locale?: Locale;
14
14
  }) => DateRange;
@@ -46,7 +46,8 @@ export var getMonthHoverRange = function getMonthHoverRange(date) {
46
46
  };
47
47
  export var getWeekHoverRange = function getWeekHoverRange(date, options) {
48
48
  var isoWeek = options.isoWeek,
49
- weekStart = options.weekStart,
49
+ _options$weekStart = options.weekStart,
50
+ weekStart = _options$weekStart === void 0 ? 0 : _options$weekStart,
50
51
  locale = options.locale;
51
52
  if (isoWeek) {
52
53
  // set to the first day of this week according to ISO 8601, 12:00 am
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useState, useEffect, useRef, useCallback } from 'react';
3
- import useIsomorphicLayoutEffect from "../../internals/hooks/useIsomorphicLayoutEffect.js";
3
+ import { useIsomorphicLayoutEffect } from "../../internals/hooks/index.js";
4
4
  export var useImage = function useImage(props) {
5
5
  var src = props.src,
6
6
  fallbackSrc = props.fallbackSrc,
@@ -44,6 +44,7 @@ var InlineEdit = /*#__PURE__*/React.forwardRef(function (props, ref) {
44
44
  onChange = _useEditState.onChange,
45
45
  onKeyDown = _useEditState.onKeyDown,
46
46
  onClick = _useEditState.onClick,
47
+ onFocus = _useEditState.onFocus,
47
48
  htmlProps = _useEditState.htmlProps;
48
49
  var _useFocusEvent = useFocusEvent({
49
50
  isEditing: isEditing,
@@ -70,7 +71,8 @@ var InlineEdit = /*#__PURE__*/React.forwardRef(function (props, ref) {
70
71
  disabled: disabled
71
72
  })),
72
73
  onClick: onClick,
73
- onKeyDown: onKeyDown
74
+ onKeyDown: onKeyDown,
75
+ onFocus: onFocus
74
76
  }, htmlProps), renderChildren(children, childrenProps, target), showControls && isEditing && /*#__PURE__*/React.createElement(EditableControls, {
75
77
  className: prefix('controls'),
76
78
  onSave: onSave,
@@ -8,12 +8,14 @@ interface EditStateProps {
8
8
  onCancel?: (event?: React.MouseEvent) => void;
9
9
  onSave?: (event?: React.MouseEvent) => void;
10
10
  onClick?: (event: React.SyntheticEvent) => void;
11
+ onFocus?: (event?: React.FocusEvent) => void;
11
12
  }
12
13
  declare const useEditState: (props: EditStateProps) => {
13
14
  isEditing: boolean;
14
15
  value: any;
15
16
  onClick: (...args: any[]) => any;
16
17
  onChange: (...args: any[]) => any;
18
+ onFocus: (...args: any[]) => any;
17
19
  onCancel: (...args: any[]) => any;
18
20
  onSave: (...args: any[]) => any;
19
21
  onKeyDown: (...args: any[]) => any;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["value", "defaultValue", "disabled", "onChange", "onEdit", "onCancel", "onSave", "onClick"];
3
+ var _excluded = ["value", "defaultValue", "disabled", "onChange", "onEdit", "onCancel", "onSave", "onClick", "onFocus"];
4
4
  import { useState } from 'react';
5
5
  import { useEventCallback, useControlled } from "../internals/hooks/index.js";
6
6
  var useEditState = function useEditState(props) {
@@ -12,6 +12,7 @@ var useEditState = function useEditState(props) {
12
12
  onCancel = props.onCancel,
13
13
  onSave = props.onSave,
14
14
  onClick = props.onClick,
15
+ onFocus = props.onFocus,
15
16
  htmlProps = _objectWithoutPropertiesLoose(props, _excluded);
16
17
  var _useState = useState(false),
17
18
  isEditing = _useState[0],
@@ -33,6 +34,12 @@ var useEditState = function useEditState(props) {
33
34
  setIsEditing(true);
34
35
  setResetValue(value);
35
36
  });
37
+ var handleFocus = useEventCallback(function (event) {
38
+ if (disabled) return;
39
+ onFocus === null || onFocus === void 0 || onFocus(event);
40
+ setIsEditing(true);
41
+ setResetValue(value);
42
+ });
36
43
  var handleChange = useEventCallback(function (value, event) {
37
44
  setValue(value);
38
45
  onChange === null || onChange === void 0 || onChange(value, event);
@@ -70,6 +77,7 @@ var useEditState = function useEditState(props) {
70
77
  value: value,
71
78
  onClick: handleClick,
72
79
  onChange: handleChange,
80
+ onFocus: handleFocus,
73
81
  onCancel: handleCancel,
74
82
  onSave: handleSave,
75
83
  onKeyDown: handleKeyDown,
@@ -12,7 +12,7 @@ export declare const pickerPropTypes: {
12
12
  menuClassName: PropTypes.Requireable<string>;
13
13
  menuStyle: PropTypes.Requireable<object>;
14
14
  placeholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
15
- placement: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "bottomStart" | "bottomEnd" | "topStart" | "topEnd" | "leftStart" | "rightStart" | "leftEnd" | "rightEnd" | "auto" | "autoVertical" | "autoVerticalStart" | "autoVerticalEnd" | "autoHorizontal" | "autoHorizontalStart" | "autoHorizontalEnd">;
15
+ placement: PropTypes.Requireable<"top" | "bottom" | "right" | "left" | "bottomStart" | "bottomEnd" | "topStart" | "topEnd" | "leftStart" | "rightStart" | "leftEnd" | "rightEnd" | "auto" | "autoVertical" | "autoVerticalStart" | "autoVerticalEnd" | "autoHorizontal" | "autoHorizontalStart" | "autoHorizontalEnd">;
16
16
  preventOverflow: PropTypes.Requireable<boolean>;
17
17
  open: PropTypes.Requireable<boolean>;
18
18
  defaultOpen: PropTypes.Requireable<boolean>;
@@ -51,7 +51,7 @@ export declare const listPickerPropTypes: {
51
51
  menuClassName: PropTypes.Requireable<string>;
52
52
  menuStyle: PropTypes.Requireable<object>;
53
53
  placeholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
54
- placement: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "bottomStart" | "bottomEnd" | "topStart" | "topEnd" | "leftStart" | "rightStart" | "leftEnd" | "rightEnd" | "auto" | "autoVertical" | "autoVerticalStart" | "autoVerticalEnd" | "autoHorizontal" | "autoHorizontalStart" | "autoHorizontalEnd">;
54
+ placement: PropTypes.Requireable<"top" | "bottom" | "right" | "left" | "bottomStart" | "bottomEnd" | "topStart" | "topEnd" | "leftStart" | "rightStart" | "leftEnd" | "rightEnd" | "auto" | "autoVertical" | "autoVerticalStart" | "autoVerticalEnd" | "autoHorizontal" | "autoHorizontalStart" | "autoHorizontalEnd">;
55
55
  preventOverflow: PropTypes.Requireable<boolean>;
56
56
  open: PropTypes.Requireable<boolean>;
57
57
  defaultOpen: PropTypes.Requireable<boolean>;
@@ -2,7 +2,7 @@
2
2
  import { useCallback, useContext } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { prefix as addPrefix } from "../utils/prefix.js";
5
- import { CustomContext } from "../../CustomProvider/CustomProvider.js";
5
+ import { CustomContext } from "../../CustomProvider/CustomContext.js";
6
6
 
7
7
  // This is the only way I found to break circular references between ClassArray and ClassValue
8
8
  // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
@@ -8,7 +8,6 @@ import type { Locale } from 'date-fns';
8
8
  */
9
9
  export declare function getWeekStartDates(firstDayOfMonth: Date, options: {
10
10
  weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
11
- isoWeek?: boolean;
12
11
  locale?: Locale;
13
12
  }): Date[];
14
13
  export default getWeekStartDates;
@@ -9,13 +9,10 @@ import startOfWeek from 'date-fns/startOfWeek';
9
9
  * @returns A list of first days of weeks in a month
10
10
  */
11
11
  export function getWeekStartDates(firstDayOfMonth, options) {
12
- var _options$weekStart = options.weekStart,
13
- weekStart = _options$weekStart === void 0 ? 0 : _options$weekStart,
14
- isoWeek = options.isoWeek,
12
+ var weekStart = options.weekStart,
15
13
  locale = options.locale;
16
- var weekStartsOn = isoWeek ? 1 : weekStart;
17
14
  var firstDay = startOfWeek(firstDayOfMonth, {
18
- weekStartsOn: weekStartsOn,
15
+ weekStartsOn: weekStart,
19
16
  locale: locale
20
17
  });
21
18
  var days = [firstDay];
@@ -44,6 +44,7 @@ export { default as differenceInCalendarMonths } from 'date-fns/differenceInCale
44
44
  export { default as isLastDayOfMonth } from 'date-fns/isLastDayOfMonth';
45
45
  export { default as lastDayOfMonth } from 'date-fns/lastDayOfMonth';
46
46
  export { default as startOfToday } from 'date-fns/startOfToday';
47
+ export { default as getISOWeek } from 'date-fns/getISOWeek';
47
48
  export { getWeekStartDates } from './getWeekStartDates';
48
49
  export { getWeekKeys } from './getWeekKeys';
49
50
  export { reverseDateRangeOmitTime } from './reverseDateRangeOmitTime';
@@ -46,6 +46,7 @@ export { default as differenceInCalendarMonths } from 'date-fns/differenceInCale
46
46
  export { default as isLastDayOfMonth } from 'date-fns/isLastDayOfMonth';
47
47
  export { default as lastDayOfMonth } from 'date-fns/lastDayOfMonth';
48
48
  export { default as startOfToday } from 'date-fns/startOfToday';
49
+ export { default as getISOWeek } from 'date-fns/getISOWeek';
49
50
 
50
51
  // Export custom functions
51
52
  export { getWeekStartDates } from "./getWeekStartDates.js";
@@ -3,7 +3,7 @@ import { useMemo, useContext } from 'react';
3
3
  import toaster from "../toaster/index.js";
4
4
  // From CustomProvider/CustomProvider.tsx import CustomContext instead of directly from 'CustomProvider/index.ts'
5
5
  // because babel compiles commonjs, which causes CustomContext to be undefined
6
- import { CustomContext } from "../CustomProvider/CustomProvider.js";
6
+ import { CustomContext } from "../CustomProvider/CustomContext.js";
7
7
  /**
8
8
  * Toaster display brief, temporary notifications of actions, errors, or other events in an application.
9
9
  * It is often used with the Message and Notification components.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.79.1",
3
+ "version": "5.80.0",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -39,7 +39,7 @@
39
39
  "react-use-set": "^1.0.0",
40
40
  "react-window": "^1.8.8",
41
41
  "rsuite-table": "^5.19.1",
42
- "schema-typed": "^2.4.1"
42
+ "schema-typed": "^2.4.2"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": ">=16.8.0",