rsuite 5.76.3 → 5.77.1

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 (42) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/Dropdown/styles/index.css +0 -1
  3. package/Dropdown/styles/index.less +0 -1
  4. package/Nav/styles/index.css +0 -1
  5. package/Navbar/styles/index.css +0 -1
  6. package/Tabs/styles/index.css +0 -1
  7. package/cjs/DatePicker/DatePicker.js +2 -1
  8. package/cjs/DatePicker/types.d.ts +2 -2
  9. package/cjs/DateRangePicker/DateRangePicker.d.ts +6 -0
  10. package/cjs/DateRangePicker/DateRangePicker.js +9 -3
  11. package/cjs/DateRangePicker/types.d.ts +3 -8
  12. package/cjs/FormControl/utils.d.ts +8 -0
  13. package/cjs/FormControl/utils.js +44 -1
  14. package/cjs/InputPicker/InputPicker.js +7 -1
  15. package/cjs/internals/Menu/Menubar.js +4 -1
  16. package/dist/rsuite-no-reset-rtl.css +0 -1
  17. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  18. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  19. package/dist/rsuite-no-reset.css +0 -1
  20. package/dist/rsuite-no-reset.min.css +1 -1
  21. package/dist/rsuite-no-reset.min.css.map +1 -1
  22. package/dist/rsuite-rtl.css +0 -1
  23. package/dist/rsuite-rtl.min.css +1 -1
  24. package/dist/rsuite-rtl.min.css.map +1 -1
  25. package/dist/rsuite.css +0 -1
  26. package/dist/rsuite.js +10 -64
  27. package/dist/rsuite.js.map +1 -1
  28. package/dist/rsuite.min.css +1 -1
  29. package/dist/rsuite.min.css.map +1 -1
  30. package/dist/rsuite.min.js +1 -1
  31. package/dist/rsuite.min.js.LICENSE.txt +0 -35
  32. package/dist/rsuite.min.js.map +1 -1
  33. package/esm/DatePicker/DatePicker.js +2 -1
  34. package/esm/DatePicker/types.d.ts +2 -2
  35. package/esm/DateRangePicker/DateRangePicker.d.ts +6 -0
  36. package/esm/DateRangePicker/DateRangePicker.js +9 -3
  37. package/esm/DateRangePicker/types.d.ts +3 -8
  38. package/esm/FormControl/utils.d.ts +8 -0
  39. package/esm/FormControl/utils.js +44 -1
  40. package/esm/InputPicker/InputPicker.js +7 -1
  41. package/esm/internals/Menu/Menubar.js +4 -1
  42. package/package.json +4 -4
@@ -430,6 +430,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
430
430
  };
431
431
  var hasValue = isValid(value);
432
432
  var _usePickerClassName = usePickerClassName(_extends({}, props, {
433
+ className: className,
433
434
  classPrefix: classPrefix,
434
435
  name: 'date',
435
436
  appearance: appearance,
@@ -485,7 +486,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
485
486
  onExit: createChainedFunction(events.onInactive, onExit),
486
487
  speaker: renderCalendarOverlay
487
488
  }, /*#__PURE__*/React.createElement(Component, {
488
- className: merge(className, classes, (_merge = {}, _merge[prefix('error')] = invalidValue, _merge)),
489
+ className: merge(classes, (_merge = {}, _merge[prefix('error')] = invalidValue, _merge)),
489
490
  style: style,
490
491
  ref: root
491
492
  }, plaintext ? /*#__PURE__*/React.createElement(DateInput, {
@@ -3,11 +3,11 @@ export type ToolbarValue = Date | [Date?, Date?];
3
3
  export interface RangeType<T> {
4
4
  label: ReactNode;
5
5
  closeOverlay?: boolean;
6
- value: T | ((value: T) => T);
6
+ value: T | ((value: T) => T) | null;
7
7
  placement?: 'bottom' | 'left';
8
8
  }
9
9
  export interface InnerRange<T> extends Omit<RangeType<T>, 'value'> {
10
- value: T;
10
+ value: T | null;
11
11
  }
12
12
  export interface DeprecatedProps {
13
13
  /**
@@ -159,6 +159,12 @@ export interface DateRangePickerProps extends PickerBaseProps<DateRangePickerLoc
159
159
  * Custom render for calendar title
160
160
  */
161
161
  renderTitle?: (date: Date) => React.ReactNode;
162
+ /**
163
+ * Custom rendering calendar cell content.
164
+ *
165
+ * @version 5.77.0
166
+ */
167
+ renderCell?: (date: Date) => React.ReactNode;
162
168
  }
163
169
  export interface DateRangePickerComponent extends PickerComponent<DateRangePickerProps> {
164
170
  /** Allow the maximum number of days specified, other dates are disabled */
@@ -3,7 +3,7 @@ import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTempla
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  var _templateObject, _templateObject2;
6
- var _excluded = ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "calendarSnapping", "defaultCalendarValue", "defaultValue", "plaintext", "disabled", "disabledDate", "shouldDisableDate", "shouldDisableHour", "shouldDisableMinute", "shouldDisableSecond", "format", "hoverRange", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "readOnly", "showOneCalendar", "showWeekNumbers", "showMeridian", "showMeridiem", "showHeader", "style", "size", "caretAs", "value", "monthDropdownProps", "hideHours", "hideMinutes", "hideSeconds", "onChange", "onClean", "onEnter", "onExit", "onOk", "onSelect", "onShortcutClick", "renderTitle", "renderValue"];
6
+ var _excluded = ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "calendarSnapping", "defaultCalendarValue", "defaultValue", "plaintext", "disabled", "disabledDate", "shouldDisableDate", "shouldDisableHour", "shouldDisableMinute", "shouldDisableSecond", "format", "hoverRange", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "readOnly", "showOneCalendar", "showWeekNumbers", "showMeridian", "showMeridiem", "showHeader", "style", "size", "caretAs", "value", "monthDropdownProps", "hideHours", "hideMinutes", "hideSeconds", "onChange", "onClean", "onEnter", "onExit", "onOk", "onSelect", "onShortcutClick", "renderTitle", "renderValue", "renderCell"];
7
7
  import React, { useEffect, useRef, useState, useMemo } from 'react';
8
8
  import isNil from 'lodash/isNil';
9
9
  import omit from 'lodash/omit';
@@ -109,6 +109,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
109
109
  onShortcutClick = propsWithDefaults.onShortcutClick,
110
110
  renderTitle = propsWithDefaults.renderTitle,
111
111
  renderValue = propsWithDefaults.renderValue,
112
+ renderCell = propsWithDefaults.renderCell,
112
113
  restProps = _objectWithoutPropertiesLoose(propsWithDefaults, _excluded);
113
114
  var id = useUniqueId('rs-', idProp);
114
115
  var _usePickerRef = usePickerRef(ref),
@@ -584,6 +585,9 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
584
585
  if (selectedDates === void 0) {
585
586
  selectedDates = [];
586
587
  }
588
+ if (selectedDates === null) {
589
+ return false;
590
+ }
587
591
  var _selectedDates = selectedDates,
588
592
  startDate = _selectedDates[0],
589
593
  endDate = _selectedDates[1];
@@ -666,7 +670,8 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
666
670
  onChangeCalendarMonth: onChangeCalendarMonth,
667
671
  onChangeCalendarTime: onChangeCalendarTime,
668
672
  onMouseMove: onMouseMove,
669
- renderTitle: renderTitle
673
+ renderTitle: renderTitle,
674
+ renderCellOnPicker: renderCell
670
675
  };
671
676
  var getCalendars = function getCalendars() {
672
677
  if (showOneCalendar) {
@@ -738,6 +743,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
738
743
  var hasValue = !isNil(value) && value.length > 1;
739
744
  var _usePickerClassName = usePickerClassName(_extends({}, props, {
740
745
  classPrefix: classPrefix,
746
+ className: className,
741
747
  name: 'daterange',
742
748
  appearance: appearance,
743
749
  hasValue: hasValue,
@@ -809,7 +815,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
809
815
  speaker: renderCalendarOverlay
810
816
  }, /*#__PURE__*/React.createElement(Component, {
811
817
  ref: root,
812
- className: merge(className, classes, (_merge = {}, _merge[prefix('error')] = invalidValue, _merge)),
818
+ className: merge(classes, (_merge = {}, _merge[prefix('error')] = invalidValue, _merge)),
813
819
  style: style
814
820
  }, plaintext ? /*#__PURE__*/React.createElement(DateRangeInput, {
815
821
  value: value,
@@ -1,13 +1,8 @@
1
- import React from 'react';
2
1
  import { DATERANGE_DISABLED_TARGET } from '../internals/constants';
3
- export type ValueType = [Date?, Date?];
2
+ import type { RangeType as DatePickerRangeType } from '../DatePicker/types';
3
+ export type ValueType = [Date?, Date?] | null;
4
4
  export type DateRange = [Date, Date];
5
- export interface RangeType<T = DateRange> {
6
- label: React.ReactNode;
7
- value: T | ((value?: T) => T);
8
- closeOverlay?: boolean;
9
- placement?: 'bottom' | 'left';
10
- }
5
+ export type RangeType<T = DateRange> = DatePickerRangeType<T>;
11
6
  export type DisabledDateFunction = (
12
7
  /**
13
8
  * Date used to determine if disabling is required.
@@ -1 +1,9 @@
1
+ /**
2
+ * Converts a field name to a path that can be used in a nested object.
3
+ * @example
4
+ * nameToPath('a.b.c') // 'a.object.b.object.c'
5
+ * nameToPath('items[0].name') // 'items.array[0].object.name'
6
+ * @param name the field name to convert
7
+ * @returns the converted path
8
+ */
1
9
  export declare function nameToPath(name: string): string;
@@ -1,4 +1,47 @@
1
1
  'use client';
2
+ /**
3
+ * Converts a field name to a path that can be used in a nested object.
4
+ * @example
5
+ * nameToPath('a.b.c') // 'a.object.b.object.c'
6
+ * nameToPath('items[0].name') // 'items.array[0].object.name'
7
+ * @param name the field name to convert
8
+ * @returns the converted path
9
+ */
2
10
  export function nameToPath(name) {
3
- return name.includes('.') ? name.replace('.', '.object.') : name;
11
+ if (!name.includes('.') && !name.includes('[')) {
12
+ return name;
13
+ }
14
+
15
+ // Split the path by dots and array accessors
16
+ var parts = name.split(/\.|\[|\]\.?/).filter(Boolean);
17
+ var result = [];
18
+ for (var i = 0; i < parts.length; i++) {
19
+ var part = parts[i];
20
+ var isLast = i === parts.length - 1;
21
+ if (part.match(/^\d+$/)) {
22
+ // If it's a number (array index), add array accessor
23
+ result.push("array[" + part + "]");
24
+ // If there's a next part and it's not an array index, add .object
25
+ if (!isLast && !parts[i + 1].match(/^\d+$/)) {
26
+ result.push('object');
27
+ }
28
+ } else {
29
+ // For regular property names
30
+ if (!isLast) {
31
+ // Not the last part, add .object unless next part is array index
32
+ var nextPart = parts[i + 1];
33
+ if (nextPart && nextPart.match(/^\d+$/)) {
34
+ // Next part is array index
35
+ result.push(part);
36
+ } else {
37
+ // Next part is object property
38
+ result.push(part + ".object");
39
+ }
40
+ } else {
41
+ // Last part, just add the name
42
+ result.push(part);
43
+ }
44
+ }
45
+ }
46
+ return result.join('.');
4
47
  }
@@ -390,7 +390,13 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
390
390
  handleChange(val, event);
391
391
  });
392
392
  var handleClean = useEventCallback(function (event) {
393
- if (disabled || searchKeyword !== '') {
393
+ if (disabled) {
394
+ return;
395
+ }
396
+
397
+ // When there is a value in the search box and the user presses the delete key on the keyboard,
398
+ // do not trigger clearing
399
+ if (inputRef.current === event.target && searchKeyword !== '') {
394
400
  return;
395
401
  }
396
402
  setValue(null);
@@ -29,7 +29,10 @@ export default function Menubar(_ref) {
29
29
  if (isFocusEntering(event) &&
30
30
  // Skip if focus is moving to a focusable element within this menu
31
31
  !(event.target !== event.currentTarget && isFocusableElement(event.target))) {
32
- if (activeItemIndex === null) {
32
+ var disabled = event.target.getAttribute('aria-disabled');
33
+
34
+ // Skip if the item is disabled
35
+ if (activeItemIndex === null && disabled !== 'true') {
33
36
  dispatch({
34
37
  type: MenuActionTypes.MoveFocus,
35
38
  to: MoveFocusTo.First
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.76.3",
3
+ "version": "5.77.1",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -28,18 +28,18 @@
28
28
  "@babel/runtime": "^7.20.1",
29
29
  "@juggle/resize-observer": "^3.4.0",
30
30
  "@rsuite/icons": "^1.3.0",
31
- "@types/lodash": "^4.14.184",
31
+ "@types/lodash": "^4.17.15",
32
32
  "@types/prop-types": "^15.7.5",
33
33
  "@types/react-window": "^1.8.5",
34
34
  "classnames": "^2.3.1",
35
35
  "date-fns": "^2.29.3",
36
36
  "dom-lib": "^3.3.1",
37
- "lodash": "^4.17.11",
37
+ "lodash": "^4.17.21",
38
38
  "prop-types": "^15.8.1",
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.2.2"
42
+ "schema-typed": "^2.3.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": ">=16.8.0",