rsuite 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/Accordion/styles/index.scss +3 -0
  2. package/Animation/styles/_animation.scss +95 -0
  3. package/Animation/styles/_bounce.scss +36 -0
  4. package/Animation/styles/_collapse.scss +23 -0
  5. package/Animation/styles/_fade.scss +10 -0
  6. package/Animation/styles/_mixin.scss +15 -0
  7. package/Animation/styles/_slide.scss +34 -0
  8. package/Animation/styles/_variables.scss +4 -0
  9. package/Animation/styles/index.scss +8 -0
  10. package/AutoComplete/styles/index.scss +43 -0
  11. package/Avatar/styles/index.scss +48 -0
  12. package/AvatarGroup/styles/index.scss +27 -0
  13. package/Badge/styles/_variables.scss +48 -0
  14. package/Badge/styles/index.scss +111 -0
  15. package/Box/styles/index.scss +1 -0
  16. package/Breadcrumb/styles/index.scss +50 -0
  17. package/Button/styles/_mixin.scss +83 -0
  18. package/Button/styles/_variables.scss +38 -0
  19. package/Button/styles/index.scss +374 -0
  20. package/ButtonGroup/styles/index.scss +96 -0
  21. package/ButtonToolbar/styles/index.scss +9 -0
  22. package/CHANGELOG.md +20 -0
  23. package/Calendar/styles/_variables.scss +16 -0
  24. package/Calendar/styles/index.scss +673 -0
  25. package/Card/styles/index.scss +63 -0
  26. package/CardGroup/styles/index.scss +10 -0
  27. package/Carousel/styles/index.scss +204 -0
  28. package/CascadeTree/styles/_search.scss +39 -0
  29. package/CascadeTree/styles/index.scss +83 -0
  30. package/Cascader/styles/index.scss +5 -0
  31. package/Center/styles/index.scss +11 -0
  32. package/CheckPicker/styles/index.scss +23 -0
  33. package/CheckTree/styles/_variables.scss +5 -0
  34. package/CheckTree/styles/index.scss +121 -0
  35. package/CheckTreePicker/styles/index.scss +20 -0
  36. package/Checkbox/styles/_mixin.scss +5 -0
  37. package/Checkbox/styles/_variables.scss +4 -0
  38. package/Checkbox/styles/index.scss +158 -0
  39. package/CheckboxGroup/styles/index.scss +14 -0
  40. package/Col/styles/index.scss +2 -0
  41. package/Container/stories/styles.scss +23 -0
  42. package/Container/styles/index.scss +16 -0
  43. package/Content/styles/index.scss +6 -0
  44. package/DateInput/styles/index.scss +1 -0
  45. package/DatePicker/styles/_mixin.scss +10 -0
  46. package/DatePicker/styles/index.scss +171 -0
  47. package/DateRangeInput/styles/index.scss +1 -0
  48. package/DateRangePicker/styles/index.scss +151 -0
  49. package/Divider/styles/index.scss +85 -0
  50. package/Drawer/styles/_mixin.scss +23 -0
  51. package/Drawer/styles/_variables.scss +18 -0
  52. package/Drawer/styles/index.scss +244 -0
  53. package/Dropdown/styles/_mixin.scss +4 -0
  54. package/Dropdown/styles/_variables.scss +12 -0
  55. package/Dropdown/styles/index.scss +334 -0
  56. package/FlexboxGrid/styles/index.scss +82 -0
  57. package/Footer/styles/index.scss +5 -0
  58. package/Form/styles/index.scss +3 -0
  59. package/FormControl/styles/_variables.scss +4 -0
  60. package/FormControl/styles/index.scss +82 -0
  61. package/FormControlLabel/styles/index.scss +7 -0
  62. package/FormErrorMessage/styles/_animation.scss +43 -0
  63. package/FormErrorMessage/styles/_variables.scss +7 -0
  64. package/FormErrorMessage/styles/index.scss +146 -0
  65. package/FormGroup/styles/index.scss +75 -0
  66. package/FormHelpText/styles/index.scss +21 -0
  67. package/FormStack/styles/index.scss +15 -0
  68. package/Grid/styles/_columns.scss +23 -0
  69. package/Grid/styles/_mixin.scss +110 -0
  70. package/Grid/styles/_row.scss +44 -0
  71. package/Grid/styles/_variables.scss +6 -0
  72. package/Grid/styles/index.scss +115 -0
  73. package/Header/styles/index.scss +5 -0
  74. package/Heading/styles/_variables.scss +19 -0
  75. package/Heading/styles/index.scss +42 -0
  76. package/HeadingGroup/styles/index.scss +5 -0
  77. package/Highlight/styles/index.scss +9 -0
  78. package/IconButton/styles/index.scss +90 -0
  79. package/Image/styles/index.scss +36 -0
  80. package/InlineEdit/styles/index.scss +51 -0
  81. package/Input/styles/_mixin.scss +39 -0
  82. package/Input/styles/_variables.scss +27 -0
  83. package/Input/styles/index.scss +23 -0
  84. package/InputGroup/styles/index.scss +264 -0
  85. package/InputNumber/styles/index.scss +1 -0
  86. package/InputPicker/styles/_mixin.scss +7 -0
  87. package/InputPicker/styles/index.scss +64 -0
  88. package/Kbd/styles/_mixin.scss +24 -0
  89. package/Kbd/styles/_variables.scss +13 -0
  90. package/Kbd/styles/index.scss +21 -0
  91. package/Link/styles/index.scss +41 -0
  92. package/List/styles/index.scss +111 -0
  93. package/Loader/styles/_mixin.scss +37 -0
  94. package/Loader/styles/_variables.scss +19 -0
  95. package/Loader/styles/index.scss +120 -0
  96. package/Menu/styles/index.scss +109 -0
  97. package/Message/styles/index.scss +189 -0
  98. package/Modal/styles/_animation.scss +15 -0
  99. package/Modal/styles/_variables.scss +16 -0
  100. package/Modal/styles/index.scss +186 -0
  101. package/MultiCascadeTree/styles/index.scss +35 -0
  102. package/MultiCascader/styles/index.scss +3 -0
  103. package/Nav/styles/index.scss +383 -0
  104. package/Navbar/styles/index.scss +253 -0
  105. package/Notification/styles/index.scss +116 -0
  106. package/NumberInput/styles/_mixin.scss +11 -0
  107. package/NumberInput/styles/index.scss +78 -0
  108. package/Pagination/styles/_pagination-group.scss +52 -0
  109. package/Pagination/styles/index.scss +77 -0
  110. package/Panel/styles/index.scss +122 -0
  111. package/PanelGroup/styles/index.scss +34 -0
  112. package/PasswordInput/styles/index.scss +3 -0
  113. package/PasswordStrengthMeter/styles/index.scss +41 -0
  114. package/PinInput/styles/index.scss +93 -0
  115. package/Placeholder/styles/_mixin.scss +9 -0
  116. package/Placeholder/styles/index.scss +155 -0
  117. package/Popover/styles/index.scss +224 -0
  118. package/Popover/styles/mixins.scss +54 -0
  119. package/Progress/styles/_animation.scss +69 -0
  120. package/Progress/styles/_mixins.scss +6 -0
  121. package/Progress/styles/_progress-line.scss +343 -0
  122. package/Progress/styles/index.scss +3 -0
  123. package/ProgressCircle/styles/index.scss +2 -0
  124. package/ProgressCircle/styles/progress-circle.scss +49 -0
  125. package/Radio/styles/_mixin.scss +5 -0
  126. package/Radio/styles/_variables.scss +5 -0
  127. package/Radio/styles/index.scss +147 -0
  128. package/RadioGroup/styles/_variables.scss +10 -0
  129. package/RadioGroup/styles/index.scss +83 -0
  130. package/RadioTile/styles/index.scss +80 -0
  131. package/RadioTileGroup/styles/index.scss +1 -0
  132. package/RangeSlider/styles/index.scss +4 -0
  133. package/Rate/styles/index.scss +141 -0
  134. package/Row/styles/index.scss +2 -0
  135. package/SegmentedControl/styles/_mixin.scss +7 -0
  136. package/SegmentedControl/styles/_variables.scss +43 -0
  137. package/SegmentedControl/styles/index.scss +147 -0
  138. package/SelectPicker/styles/index.scss +44 -0
  139. package/Sidebar/styles/index.scss +17 -0
  140. package/Sidenav/styles/index.scss +635 -0
  141. package/Sidenav/styles/mixin.scss +23 -0
  142. package/Slider/styles/index.scss +298 -0
  143. package/Stack/styles/_variables.scss +11 -0
  144. package/Stack/styles/index.scss +79 -0
  145. package/Stat/styles/index.scss +126 -0
  146. package/StatGroup/styles/index.scss +10 -0
  147. package/Steps/styles/index.scss +222 -0
  148. package/Table/styles/index.scss +473 -0
  149. package/Table/styles/mixin.scss +8 -0
  150. package/Tabs/styles/index.scss +24 -0
  151. package/Tag/styles/_variables.scss +13 -0
  152. package/Tag/styles/index.scss +62 -0
  153. package/TagGroup/styles/index.scss +14 -0
  154. package/TagInput/styles/index.scss +5 -0
  155. package/TagPicker/styles/index.scss +141 -0
  156. package/Text/styles/index.scss +142 -0
  157. package/Text/styles/variables.scss +9 -0
  158. package/Textarea/styles/index.scss +9 -0
  159. package/TimePicker/styles/index.scss +1 -0
  160. package/TimeRangePicker/styles/index.scss +1 -0
  161. package/Timeline/stories/styles.scss +29 -0
  162. package/Timeline/styles/_mixin.scss +13 -0
  163. package/Timeline/styles/index.scss +187 -0
  164. package/Toggle/styles/index.scss +284 -0
  165. package/Tooltip/styles/index.scss +160 -0
  166. package/Tooltip/styles/mixins.scss +56 -0
  167. package/Tree/styles/_indent-line.scss +8 -0
  168. package/Tree/styles/_toggle.scss +32 -0
  169. package/Tree/styles/_variables.scss +8 -0
  170. package/Tree/styles/index.scss +184 -0
  171. package/TreePicker/styles/index.scss +16 -0
  172. package/Uploader/styles/_mixin.scss +11 -0
  173. package/Uploader/styles/index.scss +491 -0
  174. package/VisuallyHidden/styles/index.scss +11 -0
  175. package/cjs/Breadcrumb/BreadcrumbItem.js +12 -7
  176. package/cjs/CheckTree/CheckTree.js +3 -0
  177. package/cjs/CheckTree/CheckTreeView.js +7 -3
  178. package/cjs/CheckTree/hooks/useTreeCheckState.d.ts +1 -0
  179. package/cjs/CheckTree/hooks/useTreeCheckState.js +54 -3
  180. package/cjs/CheckTree/utils.d.ts +9 -2
  181. package/cjs/CheckTree/utils.js +70 -11
  182. package/cjs/CheckTreePicker/CheckTreePicker.js +1 -0
  183. package/cjs/Checkbox/Checkbox.js +2 -1
  184. package/cjs/Checkbox/hooks/useIndeterminateCheckbox.d.ts +19 -0
  185. package/cjs/Checkbox/hooks/useIndeterminateCheckbox.js +32 -0
  186. package/cjs/DateInput/DateInput.js +24 -0
  187. package/cjs/DateInput/hooks/useKeyboardInputEvent.d.ts +2 -1
  188. package/cjs/DateInput/hooks/useKeyboardInputEvent.js +14 -0
  189. package/cjs/DateRangeInput/DateRangeInput.js +24 -0
  190. package/cjs/Form/Form.js +5 -1
  191. package/cjs/Rate/Rate.d.ts +8 -0
  192. package/cjs/Rate/Rate.js +3 -1
  193. package/cjs/Tree/hooks/useFlattenTree.d.ts +4 -0
  194. package/cjs/Tree/hooks/useFlattenTree.js +22 -1
  195. package/cjs/Tree/hooks/useFocusTree.js +19 -1
  196. package/cjs/Tree/hooks/useVirtualizedTreeData.d.ts +1 -0
  197. package/cjs/Tree/hooks/useVirtualizedTreeData.js +5 -2
  198. package/cjs/Tree/utils/focusableTree.d.ts +8 -0
  199. package/cjs/Tree/utils/focusableTree.js +40 -2
  200. package/cjs/Tree/utils/index.d.ts +1 -1
  201. package/cjs/Tree/utils/index.js +3 -1
  202. package/cjs/internals/Picker/utils.d.ts +2 -0
  203. package/cjs/internals/Picker/utils.js +13 -1
  204. package/cjs/internals/StyledBox/StyledBox.d.ts +1 -1
  205. package/cjs/internals/StyledBox/StyledBox.js +2 -2
  206. package/dist/rsuite.js +34 -23
  207. package/dist/rsuite.js.map +1 -1
  208. package/dist/rsuite.min.js +1 -1
  209. package/dist/rsuite.min.js.map +1 -1
  210. package/esm/Breadcrumb/BreadcrumbItem.js +10 -5
  211. package/esm/CheckTree/CheckTree.js +3 -0
  212. package/esm/CheckTree/CheckTreeView.js +7 -3
  213. package/esm/CheckTree/hooks/useTreeCheckState.d.ts +1 -0
  214. package/esm/CheckTree/hooks/useTreeCheckState.js +55 -4
  215. package/esm/CheckTree/utils.d.ts +9 -2
  216. package/esm/CheckTree/utils.js +71 -12
  217. package/esm/CheckTreePicker/CheckTreePicker.js +1 -0
  218. package/esm/Checkbox/Checkbox.js +3 -2
  219. package/esm/Checkbox/hooks/useIndeterminateCheckbox.d.ts +19 -0
  220. package/esm/Checkbox/hooks/useIndeterminateCheckbox.js +29 -0
  221. package/esm/DateInput/DateInput.js +24 -0
  222. package/esm/DateInput/hooks/useKeyboardInputEvent.d.ts +2 -1
  223. package/esm/DateInput/hooks/useKeyboardInputEvent.js +14 -0
  224. package/esm/DateRangeInput/DateRangeInput.js +24 -0
  225. package/esm/Form/Form.js +5 -1
  226. package/esm/Rate/Rate.d.ts +8 -0
  227. package/esm/Rate/Rate.js +3 -1
  228. package/esm/Tree/hooks/useFlattenTree.d.ts +4 -0
  229. package/esm/Tree/hooks/useFlattenTree.js +22 -1
  230. package/esm/Tree/hooks/useFocusTree.js +20 -2
  231. package/esm/Tree/hooks/useVirtualizedTreeData.d.ts +1 -0
  232. package/esm/Tree/hooks/useVirtualizedTreeData.js +5 -2
  233. package/esm/Tree/utils/focusableTree.d.ts +8 -0
  234. package/esm/Tree/utils/focusableTree.js +36 -0
  235. package/esm/Tree/utils/index.d.ts +1 -1
  236. package/esm/Tree/utils/index.js +1 -1
  237. package/esm/internals/Picker/utils.d.ts +2 -0
  238. package/esm/internals/Picker/utils.js +13 -1
  239. package/esm/internals/StyledBox/StyledBox.d.ts +1 -1
  240. package/esm/internals/StyledBox/StyledBox.js +2 -2
  241. package/internals/Box/styles/index.scss +31 -0
  242. package/internals/Burger/styles/index.scss +72 -0
  243. package/internals/CloseButton/styles/index.scss +14 -0
  244. package/internals/Picker/styles/_mixin.scss +219 -0
  245. package/internals/Picker/styles/_variables.scss +9 -0
  246. package/internals/Picker/styles/index.scss +476 -0
  247. package/internals/Ripple/styles/_mixins.scss +10 -0
  248. package/internals/Ripple/styles/index.scss +40 -0
  249. package/internals/ScrollView/styles/index.scss +77 -0
  250. package/internals/SearchBox/styles/index.scss +7 -0
  251. package/package.json +4 -4
  252. package/styles/_base.scss +37 -0
  253. package/styles/_css-reset.scss +345 -0
  254. package/styles/_themes.scss +132 -0
  255. package/styles/_variables.scss +48 -0
  256. package/styles/color-modes/_dark.scss +458 -0
  257. package/styles/color-modes/_high-contrast.scss +469 -0
  258. package/styles/color-modes/_light.scss +475 -0
  259. package/styles/colors/_colors-base.scss +39 -0
  260. package/styles/colors/_dark.scss +114 -0
  261. package/styles/colors/_high-contrast.scss +114 -0
  262. package/styles/colors/_light.scss +115 -0
  263. package/styles/colors/_palette.scss +413 -0
  264. package/styles/components.scss +114 -0
  265. package/styles/index.scss +2 -0
  266. package/styles/mixins/_color-modes.scss +20 -0
  267. package/styles/mixins/_combobox.scss +6 -0
  268. package/styles/mixins/_hacks.scss +33 -0
  269. package/styles/mixins/_input.scss +30 -0
  270. package/styles/mixins/_listbox.scss +70 -0
  271. package/styles/mixins/_menu.scss +12 -0
  272. package/styles/mixins/_utilities.scss +130 -0
  273. package/toaster/styles/animation.scss +54 -0
  274. package/toaster/styles/index.scss +109 -0
  275. package/useToaster/styles/index.scss +1 -0
@@ -3,6 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import React from 'react';
4
4
  import SafeAnchor from "../internals/SafeAnchor/index.js";
5
5
  import Box from "../internals/Box/index.js";
6
+ import { extractBoxProps, omitBoxProps } from "../internals/Box/utils.js";
6
7
  import { forwardRef } from "../internals/utils/index.js";
7
8
  import { useStyles } from "../internals/hooks/index.js";
8
9
  /**
@@ -11,7 +12,7 @@ import { useStyles } from "../internals/hooks/index.js";
11
12
  */
12
13
  const BreadcrumbItem = forwardRef((props, ref) => {
13
14
  const {
14
- wrapperAs = 'li',
15
+ wrapperAs: Wrapper = 'li',
15
16
  href,
16
17
  as: Component = href ? SafeAnchor : 'span',
17
18
  classPrefix = 'breadcrumb-item',
@@ -30,17 +31,21 @@ const BreadcrumbItem = forwardRef((props, ref) => {
30
31
  withPrefix
31
32
  } = useStyles(classPrefix);
32
33
  const classes = merge(className, withPrefix());
34
+
35
+ // Separate BoxProps for wrapper and other props for inner component
36
+ const boxProps = extractBoxProps(rest);
37
+ const componentProps = omitBoxProps(rest);
33
38
  return /*#__PURE__*/React.createElement(Box, _extends({
34
- as: wrapperAs,
39
+ as: Wrapper,
35
40
  style: style,
36
41
  className: classes,
37
- ref: ref,
38
42
  "data-active": active
39
- }, rest), icon, active ? /*#__PURE__*/React.createElement("span", null, children) : /*#__PURE__*/React.createElement(Component, {
43
+ }, boxProps), icon, active ? /*#__PURE__*/React.createElement("span", null, children) : /*#__PURE__*/React.createElement(Component, _extends({
44
+ ref: ref,
40
45
  href: href,
41
46
  title: title,
42
47
  target: target
43
- }, children), separator);
48
+ }, componentProps), children), separator);
44
49
  });
45
50
  BreadcrumbItem.displayName = 'BreadcrumbItem';
46
51
  export default BreadcrumbItem;
@@ -24,6 +24,7 @@ const CheckTree = forwardRef((props, ref) => {
24
24
  defaultExpandAll = false,
25
25
  defaultExpandItemValues = [],
26
26
  uncheckableItemValues,
27
+ disabledItemValues,
27
28
  expandItemValues: controlledExpandItemValues,
28
29
  childrenKey = 'children',
29
30
  labelKey = 'label',
@@ -67,6 +68,7 @@ const CheckTree = forwardRef((props, ref) => {
67
68
  const flattenedNodes = useFlattenTree(treeData, {
68
69
  ...itemDataKeys,
69
70
  uncheckableItemValues,
71
+ disabledItemValues,
70
72
  multiple: true,
71
73
  cascade,
72
74
  value
@@ -96,6 +98,7 @@ const CheckTree = forwardRef((props, ref) => {
96
98
  loadingNodeValues: loadingNodeValues,
97
99
  flattenedNodes: flattenedNodes,
98
100
  uncheckableItemValues: uncheckableItemValues,
101
+ disabledItemValues: disabledItemValues,
99
102
  expandItemValues: expandItemValues,
100
103
  onChange: handleChange,
101
104
  onExpand: handleExpandTreeNode
@@ -79,7 +79,8 @@ const CheckTreeView = forwardRef((props, ref) => {
79
79
  } = useTreeCheckState({
80
80
  cascade,
81
81
  flattenedNodes,
82
- uncheckableItemValues
82
+ uncheckableItemValues,
83
+ disabledItemValues
83
84
  });
84
85
  const handleSearchCallback = (value, _data, event) => {
85
86
  onSearch === null || onSearch === void 0 || onSearch(value, event);
@@ -112,7 +113,8 @@ const CheckTreeView = forwardRef((props, ref) => {
112
113
  const transformation = useVirtualizedTreeData(flattenedNodes, filteredData, {
113
114
  cascade,
114
115
  expandItemValues,
115
- searchKeyword: keyword
116
+ searchKeyword: keyword,
117
+ disabledItemValues
116
118
  });
117
119
 
118
120
  /**
@@ -125,7 +127,9 @@ const CheckTreeView = forwardRef((props, ref) => {
125
127
  }
126
128
  return getFormattedTree(flattenedNodes, filteredData, {
127
129
  childrenKey,
128
- cascade
130
+ cascade,
131
+ disabledItemValues,
132
+ valueKey
129
133
  }).map(node => render === null || render === void 0 ? void 0 : render(node, 1)).filter(item => item);
130
134
  };
131
135
  const getTreeNodeProps = useTreeNodeProps({
@@ -3,6 +3,7 @@ interface Props {
3
3
  cascade?: boolean;
4
4
  flattenedNodes: TreeNodeMap;
5
5
  uncheckableItemValues: (string | number)[];
6
+ disabledItemValues?: (string | number)[];
6
7
  }
7
8
  declare function useTreeCheckState(props: Props): {
8
9
  getCheckedValues: (...args: any[]) => any;
@@ -4,12 +4,13 @@ import isNil from 'lodash/isNil';
4
4
  import cloneDeep from 'lodash/cloneDeep';
5
5
  import { useEventCallback } from "../../internals/hooks/index.js";
6
6
  import { useItemDataKeys } from "../../internals/Tree/TreeProvider.js";
7
- import { isEveryChildChecked } from "../utils.js";
7
+ import { isEveryChildChecked, getDisabledState } from "../utils.js";
8
8
  function useTreeCheckState(props) {
9
9
  const {
10
10
  cascade,
11
11
  flattenedNodes,
12
- uncheckableItemValues
12
+ uncheckableItemValues,
13
+ disabledItemValues = []
13
14
  } = props;
14
15
  const {
15
16
  valueKey,
@@ -24,7 +25,9 @@ function useTreeCheckState(props) {
24
25
  } else {
25
26
  if (isEveryChildChecked(currentNode, {
26
27
  nodes,
27
- childrenKey
28
+ childrenKey,
29
+ disabledItemValues,
30
+ valueKey
28
31
  })) {
29
32
  currentNode.check = true;
30
33
  currentNode.checkAll = true;
@@ -38,16 +41,57 @@ function useTreeCheckState(props) {
38
41
  }
39
42
  }
40
43
  });
44
+
45
+ /**
46
+ * Recursively checks if a node has any disabled descendants.
47
+ * This is used to determine if a parent node's checkAll state should be true.
48
+ * If any descendant is disabled, checkAll must be false because not all descendants can be checked.
49
+ * @param nodes - The flattened tree node map
50
+ * @param node - The node to check for disabled descendants
51
+ * @returns true if any descendant (at any depth) is disabled, false otherwise
52
+ */
53
+ const hasDisabledDescendant = useEventCallback((nodes, node) => {
54
+ if (!node[childrenKey] || !node[childrenKey].length) {
55
+ return false;
56
+ }
57
+ return node[childrenKey].some(child => {
58
+ const isChildDisabled = getDisabledState(nodes, child, {
59
+ disabledItemValues,
60
+ valueKey
61
+ });
62
+ if (isChildDisabled) {
63
+ return true;
64
+ }
65
+ // Recursively check descendants
66
+ return hasDisabledDescendant(nodes, child);
67
+ });
68
+ });
41
69
  const checkChildNode = useEventCallback((nodes, node, isChecked) => {
42
70
  const currentNode = node.refKey ? nodes[node.refKey] : null;
43
71
  if (!currentNode) {
44
72
  return;
45
73
  }
74
+
75
+ // Check if the current node is disabled
76
+ const isDisabled = getDisabledState(nodes, node, {
77
+ disabledItemValues,
78
+ valueKey
79
+ });
80
+
81
+ // Skip checking disabled nodes
82
+ if (isDisabled) {
83
+ return;
84
+ }
46
85
  currentNode.check = isChecked;
47
86
  if (!currentNode[childrenKey] || !currentNode[childrenKey].length || !cascade) {
48
87
  currentNode.checkAll = false;
49
88
  } else {
50
- currentNode.checkAll = isChecked;
89
+ // Check if any descendant (not just direct children) is disabled
90
+ const hasDisabledDesc = hasDisabledDescendant(nodes, currentNode);
91
+
92
+ // Only set checkAll to true if all descendants will be checked
93
+ // If there are any disabled descendants, checkAll should be false
94
+ currentNode.checkAll = isChecked && !hasDisabledDesc;
51
95
  currentNode[childrenKey].forEach(child => {
52
96
  checkChildNode(nodes, child, isChecked);
53
97
  });
@@ -60,6 +104,13 @@ function useTreeCheckState(props) {
60
104
  if (!isNil(currentNode.parent) && !isNil(currentNode.parent.refKey)) {
61
105
  const parentNode = nodes[currentNode.parent.refKey];
62
106
  if (currentNode.check) {
107
+ // Optimization: When a parent node is checked with checkAll=true, it represents
108
+ // the entire checked subtree. If the current node also has checkAll=true and its
109
+ // parent is checked, skip adding this node's value to avoid redundant representation.
110
+ // The parent's value already implies all descendants are checked.
111
+ if (currentNode.checkAll && parentNode.check) {
112
+ continue;
113
+ }
63
114
  if (!(parentNode !== null && parentNode !== void 0 && parentNode.checkAll)) {
64
115
  values.push(currentNode[valueKey]);
65
116
  } else if (parentNode !== null && parentNode !== void 0 && parentNode.uncheckable) {
@@ -3,15 +3,19 @@ import { CheckStateType } from '../internals/constants';
3
3
  import { TreeNode, TreeNodeMap } from '../internals/Tree/types';
4
4
  /**
5
5
  * Checks if every child of a given parent node is checked.
6
+ * Disabled children are ignored in this check.
6
7
  */
7
8
  export declare function isEveryChildChecked(parent: TreeNode, options: {
8
9
  nodes: TreeNodeMap;
9
10
  childrenKey: string;
11
+ disabledItemValues?: any[];
12
+ valueKey?: string;
10
13
  }): boolean;
11
14
  /**
12
15
  * Checks if any child node is checked.
16
+ * Disabled children are ignored in this check.
13
17
  */
14
- export declare function isSomeChildChecked(nodes: TreeNodeMap, parent: TreeNode, childrenKey: string): boolean;
18
+ export declare function isSomeChildChecked(nodes: TreeNodeMap, parent: TreeNode, childrenKey: string, disabledItemValues?: any[], valueKey?: string): boolean;
15
19
  /**
16
20
  * Checks if any node in the data has a grandchild.
17
21
  */
@@ -28,9 +32,10 @@ export declare function isEveryFirstLevelNodeUncheckable(nodes: TreeNodeMap, unc
28
32
  * Checks if a node is uncheckable.
29
33
  */
30
34
  export declare function isNodeUncheckable(node: any, props: Required<Pick<CheckTreeProps, 'uncheckableItemValues' | 'valueKey'>>): boolean;
31
- export declare function getFormattedTree(nodes: TreeNodeMap, data: any[], props: Required<Pick<CheckTreeProps, 'childrenKey' | 'cascade'>>): any[];
35
+ export declare function getFormattedTree(nodes: TreeNodeMap, data: any[], props: Required<Pick<CheckTreeProps, 'childrenKey' | 'cascade' | 'disabledItemValues' | 'valueKey'>>): any[];
32
36
  /**
33
37
  * Determines the disabled state of a tree node.
38
+ * If a parent node is disabled, all its children should also be disabled.
34
39
  */
35
40
  export declare function getDisabledState(nodes: TreeNodeMap, node: TreeNode, props: Required<Pick<CheckTreeProps, 'disabledItemValues' | 'valueKey'>>): boolean;
36
41
  /**
@@ -45,6 +50,8 @@ interface NodeCheckStateOptions {
45
50
  nodes: TreeNodeMap;
46
51
  cascade: boolean;
47
52
  childrenKey: string;
53
+ disabledItemValues?: any[];
54
+ valueKey?: string;
48
55
  }
49
56
  /**
50
57
  * Calculates the check state of a node in a check tree.
@@ -2,11 +2,13 @@
2
2
  import _isUndefined from "lodash/isUndefined";
3
3
  import _isNil from "lodash/isNil";
4
4
  import { CHECK_STATE } from "../internals/constants/index.js";
5
- import { attachParent } from "../internals/utils/index.js";
5
+ import { attachParent, shallowEqual } from "../internals/utils/index.js";
6
6
  import { formatNodeRefKey } from "../Tree/utils/index.js";
7
7
 
8
8
  /**
9
9
  * Retrieves the children of a given parent node from a flattened node map.
10
+ * Filters out uncheckable children.
11
+ * Note: Does NOT filter disabled children - disabled children are still considered in check state calculations
10
12
  */
11
13
  function getChildrenByFlattenNodes(nodes, parent) {
12
14
  if (!_isNil(parent.refKey) && _isNil(nodes[parent.refKey])) {
@@ -20,11 +22,14 @@ function getChildrenByFlattenNodes(nodes, parent) {
20
22
 
21
23
  /**
22
24
  * Checks if every child of a given parent node is checked.
25
+ * Disabled children are ignored in this check.
23
26
  */
24
27
  export function isEveryChildChecked(parent, options) {
25
28
  const {
26
29
  nodes,
27
- childrenKey
30
+ childrenKey,
31
+ disabledItemValues = [],
32
+ valueKey = 'value'
28
33
  } = options;
29
34
  if (_isNil(parent.refKey) || _isNil(nodes[parent.refKey])) {
30
35
  return false;
@@ -34,13 +39,32 @@ export function isEveryChildChecked(parent, options) {
34
39
  var _nodes$parent$refKey$;
35
40
  return (_nodes$parent$refKey$ = nodes[parent.refKey].check) !== null && _nodes$parent$refKey$ !== void 0 ? _nodes$parent$refKey$ : false;
36
41
  }
37
- return children.every(child => {
42
+
43
+ // Filter out disabled children
44
+ const enabledChildren = children.filter(child => {
45
+ const isDisabled = getDisabledState(nodes, child, {
46
+ disabledItemValues,
47
+ valueKey
48
+ });
49
+ return !isDisabled;
50
+ });
51
+
52
+ // If all children are disabled, return the parent's own check state
53
+ if (enabledChildren.length === 0) {
54
+ var _nodes$parent$refKey$2;
55
+ return (_nodes$parent$refKey$2 = nodes[parent.refKey].check) !== null && _nodes$parent$refKey$2 !== void 0 ? _nodes$parent$refKey$2 : false;
56
+ }
57
+
58
+ // Check if all enabled children are checked
59
+ return enabledChildren.every(child => {
38
60
  var _child$childrenKey;
39
61
  if ((child === null || child === void 0 || (_child$childrenKey = child[childrenKey]) === null || _child$childrenKey === void 0 ? void 0 : _child$childrenKey.length) > 0) {
40
62
  // fix: #3559
41
63
  return isEveryChildChecked(child, {
42
64
  nodes,
43
- childrenKey
65
+ childrenKey,
66
+ disabledItemValues,
67
+ valueKey
44
68
  });
45
69
  }
46
70
  return !_isNil(child.refKey) && nodes[child.refKey].check;
@@ -49,16 +73,25 @@ export function isEveryChildChecked(parent, options) {
49
73
 
50
74
  /**
51
75
  * Checks if any child node is checked.
76
+ * Disabled children are ignored in this check.
52
77
  */
53
- export function isSomeChildChecked(nodes, parent, childrenKey) {
78
+ export function isSomeChildChecked(nodes, parent, childrenKey, disabledItemValues = [], valueKey = 'value') {
54
79
  if (!_isNil(parent.refKey) && _isNil(nodes[parent.refKey])) {
55
80
  return false;
56
81
  }
57
82
  const children = getChildrenByFlattenNodes(nodes, parent);
58
83
  return children.some(child => {
59
84
  var _child$childrenKey2;
85
+ // Skip disabled children
86
+ const isDisabled = getDisabledState(nodes, child, {
87
+ disabledItemValues,
88
+ valueKey
89
+ });
90
+ if (isDisabled) {
91
+ return false; // Disabled children don't count as "some checked"
92
+ }
60
93
  if ((child === null || child === void 0 || (_child$childrenKey2 = child[childrenKey]) === null || _child$childrenKey2 === void 0 ? void 0 : _child$childrenKey2.length) > 0) {
61
- return isSomeChildChecked(nodes, child, childrenKey);
94
+ return isSomeChildChecked(nodes, child, childrenKey, disabledItemValues, valueKey);
62
95
  }
63
96
  return !_isNil(child.refKey) && nodes[child.refKey].check;
64
97
  });
@@ -122,7 +155,9 @@ export function isNodeUncheckable(node, props) {
122
155
  export function getFormattedTree(nodes, data, props) {
123
156
  const {
124
157
  childrenKey,
125
- cascade
158
+ cascade,
159
+ disabledItemValues,
160
+ valueKey
126
161
  } = props;
127
162
  return data.map(node => {
128
163
  const formatted = {
@@ -134,7 +169,9 @@ export function getFormattedTree(nodes, data, props) {
134
169
  const checkState = !_isUndefined(cascade) ? getNodeCheckState(curNode, {
135
170
  cascade,
136
171
  nodes,
137
- childrenKey
172
+ childrenKey,
173
+ disabledItemValues,
174
+ valueKey
138
175
  }) : undefined;
139
176
  formatted.check = curNode.check;
140
177
  formatted.uncheckable = curNode.uncheckable;
@@ -150,6 +187,7 @@ export function getFormattedTree(nodes, data, props) {
150
187
 
151
188
  /**
152
189
  * Determines the disabled state of a tree node.
190
+ * If a parent node is disabled, all its children should also be disabled.
153
191
  */
154
192
  export function getDisabledState(nodes, node, props) {
155
193
  const {
@@ -159,7 +197,24 @@ export function getDisabledState(nodes, node, props) {
159
197
  if (!_isNil(node.refKey) && _isNil(nodes[node.refKey])) {
160
198
  return false;
161
199
  }
162
- return disabledItemValues.some(value => node.refKey && nodes[node.refKey][valueKey] === value);
200
+
201
+ // Check if the current node is disabled
202
+ const isCurrentNodeDisabled = disabledItemValues.some(value => node.refKey && shallowEqual(nodes[node.refKey][valueKey], value));
203
+ if (isCurrentNodeDisabled) {
204
+ return true;
205
+ }
206
+
207
+ // Check if any parent node is disabled
208
+ let currentNode = node;
209
+ while (currentNode.parent) {
210
+ const parentNode = currentNode.parent;
211
+ const parentRefKey = parentNode.refKey;
212
+ if (!_isNil(parentRefKey) && !_isNil(nodes[parentRefKey]) && disabledItemValues.some(value => shallowEqual(nodes[parentRefKey][valueKey], value))) {
213
+ return true;
214
+ }
215
+ currentNode = parentNode;
216
+ }
217
+ return false;
163
218
  }
164
219
 
165
220
  /**
@@ -193,7 +248,9 @@ export function getNodeCheckState(node, options) {
193
248
  const {
194
249
  nodes,
195
250
  cascade,
196
- childrenKey
251
+ childrenKey,
252
+ disabledItemValues = [],
253
+ valueKey = 'value'
197
254
  } = options;
198
255
  if (node.refKey === undefined) {
199
256
  return CHECK_STATE.UNCHECK;
@@ -207,13 +264,15 @@ export function getNodeCheckState(node, options) {
207
264
  }
208
265
  if (isEveryChildChecked(node, {
209
266
  nodes,
210
- childrenKey
267
+ childrenKey,
268
+ disabledItemValues,
269
+ valueKey
211
270
  })) {
212
271
  nodes[node.refKey].checkAll = true;
213
272
  nodes[node.refKey].check = true;
214
273
  return CHECK_STATE.CHECK;
215
274
  }
216
- if (isSomeChildChecked(nodes, node, childrenKey)) {
275
+ if (isSomeChildChecked(nodes, node, childrenKey, disabledItemValues, valueKey)) {
217
276
  nodes[node.refKey].checkAll = false;
218
277
  return CHECK_STATE.INDETERMINATE;
219
278
  }
@@ -122,6 +122,7 @@ const CheckTreePicker = forwardRef((props, ref) => {
122
122
  const flattenedNodes = useFlattenTree(treeData, {
123
123
  ...itemDataKeys,
124
124
  uncheckableItemValues,
125
+ disabledItemValues,
125
126
  multiple: true,
126
127
  cascade,
127
128
  value
@@ -1,9 +1,10 @@
1
1
  'use client';
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- import React, { useContext, useMemo, useRef } from 'react';
3
+ import React, { useContext, useMemo } from 'react';
4
4
  import Box from "../internals/Box/index.js";
5
5
  import { useControlled, useStyles, useCustom, useEventCallback, useUniqueId } from "../internals/hooks/index.js";
6
6
  import { forwardRef, partitionHTMLProps, mergeRefs } from "../internals/utils/index.js";
7
+ import { useIndeterminateCheckbox } from "./hooks/useIndeterminateCheckbox.js";
7
8
  import { CheckboxGroupContext } from "../CheckboxGroup/index.js";
8
9
  /**
9
10
  * The Checkbox component is used for selecting multiple options from a set.
@@ -75,7 +76,7 @@ const Checkbox = forwardRef((props, ref) => {
75
76
  // In uncontrolled situations, use defaultChecked instead of checked
76
77
  htmlInputProps[controlled ? 'checked' : 'defaultChecked'] = checked;
77
78
  }
78
- const checkboxRef = useRef(null);
79
+ const checkboxRef = useIndeterminateCheckbox(indeterminate);
79
80
  const handleChange = useEventCallback(event => {
80
81
  const nextChecked = event.target.checked;
81
82
  if (disabled || readOnly) {
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * A hook that manages the indeterminate state of a checkbox input element.
4
+ *
5
+ * The indeterminate state is a visual and accessibility state that cannot be set via HTML attributes.
6
+ * It must be set via JavaScript on the DOM element itself. This is required for proper
7
+ * screen reader support, as assistive technologies rely on the native DOM property
8
+ * rather than ARIA attributes for native checkboxes.
9
+ *
10
+ * @param indeterminate - Whether the checkbox should be in an indeterminate state
11
+ * @returns A ref object to be attached to the checkbox input element
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const checkboxRef = useIndeterminateCheckbox(isIndeterminate);
16
+ * return <input type="checkbox" ref={checkboxRef} />;
17
+ * ```
18
+ */
19
+ export declare function useIndeterminateCheckbox(indeterminate?: boolean): React.MutableRefObject<HTMLInputElement | null>;
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+ import { useLayoutEffect, useRef } from 'react';
3
+
4
+ /**
5
+ * A hook that manages the indeterminate state of a checkbox input element.
6
+ *
7
+ * The indeterminate state is a visual and accessibility state that cannot be set via HTML attributes.
8
+ * It must be set via JavaScript on the DOM element itself. This is required for proper
9
+ * screen reader support, as assistive technologies rely on the native DOM property
10
+ * rather than ARIA attributes for native checkboxes.
11
+ *
12
+ * @param indeterminate - Whether the checkbox should be in an indeterminate state
13
+ * @returns A ref object to be attached to the checkbox input element
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const checkboxRef = useIndeterminateCheckbox(isIndeterminate);
18
+ * return <input type="checkbox" ref={checkboxRef} />;
19
+ * ```
20
+ */
21
+ export function useIndeterminateCheckbox(indeterminate) {
22
+ const ref = useRef(null);
23
+ useLayoutEffect(() => {
24
+ if (ref.current) {
25
+ ref.current.indeterminate = indeterminate !== null && indeterminate !== void 0 ? indeterminate : false;
26
+ }
27
+ }, [indeterminate]);
28
+ return ref;
29
+ }
@@ -169,6 +169,29 @@ const DateInput = forwardRef((props, ref) => {
169
169
  reset();
170
170
  }
171
171
  });
172
+ const onAmPmToggle = useEventCallback(event => {
173
+ const input = event.target;
174
+ const key = event.key.toLowerCase();
175
+
176
+ // Only handle 'a' or 'p' keys when the selected pattern is 'a' (AM/PM)
177
+ if (selectedState.selectedPattern === 'a' && (key === 'a' || key === 'p')) {
178
+ const currentHour = dateField.hour || 0;
179
+ const isAM = currentHour < 12;
180
+ const isPM = currentHour >= 12;
181
+
182
+ // Toggle AM/PM based on the key pressed
183
+ // 'a' key -> set to AM, 'p' key -> set to PM
184
+ if (key === 'a' && isPM || key === 'p' && isAM) {
185
+ const state = getInputSelectedState({
186
+ ...keyPressOptions,
187
+ input
188
+ });
189
+ setSelectedState(state);
190
+ setDateOffset('a', 1, date => handleChange(date, event));
191
+ setSelectionRange(state.selectionStart, state.selectionEnd);
192
+ }
193
+ }
194
+ });
172
195
  const handleClick = useEventCallback(event => {
173
196
  const input = event.target;
174
197
  const state = getInputSelectedState({
@@ -197,6 +220,7 @@ const DateInput = forwardRef((props, ref) => {
197
220
  onSegmentValueChange,
198
221
  onSegmentValueChangeWithNumericKeys,
199
222
  onSegmentValueRemove,
223
+ onAmPmToggle,
200
224
  onKeyDown
201
225
  });
202
226
  const [focused, focusEventProps] = useIsFocused({
@@ -4,7 +4,8 @@ interface KeyboardEventOptions {
4
4
  onSegmentValueChange?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
5
5
  onSegmentValueChangeWithNumericKeys?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
6
6
  onSegmentValueRemove?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
7
+ onAmPmToggle?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
7
8
  onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
8
9
  }
9
- export declare function useKeyboardInputEvent({ onSegmentChange, onSegmentValueChange, onSegmentValueChangeWithNumericKeys, onSegmentValueRemove, onKeyDown }: KeyboardEventOptions): (event: React.KeyboardEvent<HTMLInputElement>) => void;
10
+ export declare function useKeyboardInputEvent({ onSegmentChange, onSegmentValueChange, onSegmentValueChangeWithNumericKeys, onSegmentValueRemove, onAmPmToggle, onKeyDown }: KeyboardEventOptions): (event: React.KeyboardEvent<HTMLInputElement>) => void;
10
11
  export default useKeyboardInputEvent;
@@ -4,6 +4,7 @@ export function useKeyboardInputEvent({
4
4
  onSegmentValueChange,
5
5
  onSegmentValueChangeWithNumericKeys,
6
6
  onSegmentValueRemove,
7
+ onAmPmToggle,
7
8
  onKeyDown
8
9
  }) {
9
10
  return event => {
@@ -29,6 +30,19 @@ export function useKeyboardInputEvent({
29
30
  onSegmentValueChangeWithNumericKeys === null || onSegmentValueChangeWithNumericKeys === void 0 || onSegmentValueChangeWithNumericKeys(event);
30
31
  event.preventDefault();
31
32
  break;
33
+ case 'a':
34
+ case 'p':
35
+ case 'A':
36
+ case 'P':
37
+ // Determine whether the Ctrl or Command key is pressed, does not affect user copy and paste
38
+ if (event.ctrlKey || event.metaKey) {
39
+ break;
40
+ }
41
+
42
+ // Handle AM/PM toggle with 'a' or 'p' keys
43
+ onAmPmToggle === null || onAmPmToggle === void 0 || onAmPmToggle(event);
44
+ event.preventDefault();
45
+ break;
32
46
  case (_key$match2 = key.match(/[a-z]/)) === null || _key$match2 === void 0 ? void 0 : _key$match2[0]:
33
47
  // Determine whether the Ctrl or Command key is pressed, does not affect user copy and paste
34
48
  if (event.ctrlKey || event.metaKey) {
@@ -203,6 +203,29 @@ const DateRangeInput = /*#__PURE__*/React.forwardRef((props, ref) => {
203
203
  reset();
204
204
  }
205
205
  });
206
+ const onAmPmToggle = useEventCallback(event => {
207
+ const input = event.target;
208
+ const key = event.key.toLowerCase();
209
+
210
+ // Only handle 'a' or 'p' keys when the selected pattern is 'a' (AM/PM)
211
+ if (selectedState.selectedPattern === 'a' && (key === 'a' || key === 'p')) {
212
+ const currentHour = getActiveState().dateField.hour || 0;
213
+ const isAM = currentHour < 12;
214
+ const isPM = currentHour >= 12;
215
+
216
+ // Toggle AM/PM based on the key pressed
217
+ // 'a' key -> set to AM, 'p' key -> set to PM
218
+ if (key === 'a' && isPM || key === 'p' && isAM) {
219
+ const state = getInputSelectedState({
220
+ ...keyPressOptions,
221
+ input
222
+ });
223
+ setSelectedState(state);
224
+ getActiveState().setDateOffset('a', 1, date => handleChange(date, event));
225
+ setSelectionRange(state.selectionStart, state.selectionEnd);
226
+ }
227
+ }
228
+ });
206
229
  const handleClick = useEventCallback(event => {
207
230
  const input = event.target;
208
231
  if (input.selectionStart === null) {
@@ -242,6 +265,7 @@ const DateRangeInput = /*#__PURE__*/React.forwardRef((props, ref) => {
242
265
  onSegmentValueChange,
243
266
  onSegmentValueChangeWithNumericKeys,
244
267
  onSegmentValueRemove,
268
+ onAmPmToggle,
245
269
  onKeyDown
246
270
  });
247
271
  return /*#__PURE__*/React.createElement(Input, _extends({
package/esm/Form/Form.js CHANGED
@@ -105,7 +105,11 @@ const Form = forwardRef((props, ref) => {
105
105
  });
106
106
  const reset = useEventCallback(event => {
107
107
  resetErrors();
108
- onReset === null || onReset === void 0 || onReset(resetFormValue(), event);
108
+ const resetValue = resetFormValue();
109
+ if (resetValue) {
110
+ onChange === null || onChange === void 0 || onChange(resetValue);
111
+ }
112
+ onReset === null || onReset === void 0 || onReset(resetValue, event);
109
113
  });
110
114
  const handleSubmit = useEventCallback(event => {
111
115
  var _event$preventDefault, _event$stopPropagatio;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { StyledBoxProps } from '../internals/StyledBox';
3
3
  import type { Color, FormControlBaseProps, Size } from '../internals/types';
4
4
  export interface RateProps<T = number> extends Omit<StyledBoxProps, 'name'>, FormControlBaseProps<T> {
5
+ /** Element type to render as */
6
+ as?: React.ElementType;
5
7
  /** Whether to allow semi selection */
6
8
  allowHalf?: boolean;
7
9
  /** Custom character of rate */
@@ -16,6 +18,12 @@ export interface RateProps<T = number> extends Omit<StyledBoxProps, 'name'>, For
16
18
  color?: Color | React.CSSProperties['color'];
17
19
  /** Maximum rate */
18
20
  max?: number;
21
+ /**
22
+ * The name of the form control.
23
+ * Used for form integration and does not affect the internal component styling.
24
+ * @private Internal use only - extracted from props to prevent conflicts with StyledBox
25
+ */
26
+ name?: string;
19
27
  /** Vertical Rate half */
20
28
  vertical?: boolean;
21
29
  /** Render custom character */