rsuite 5.59.0 → 5.59.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 (82) hide show
  1. package/AvatarGroup/styles/index.css +2 -0
  2. package/AvatarGroup/styles/index.less +2 -0
  3. package/CHANGELOG.md +14 -0
  4. package/CheckPicker/styles/index.css +2 -0
  5. package/CheckTree/styles/index.css +2 -0
  6. package/CheckTreePicker/styles/index.css +2 -0
  7. package/Checkbox/styles/index.css +2 -0
  8. package/Checkbox/styles/index.less +2 -0
  9. package/MultiCascadeTree/styles/index.css +2 -0
  10. package/MultiCascader/styles/index.css +2 -0
  11. package/Placeholder/styles/index.css +42 -6
  12. package/Placeholder/styles/index.less +18 -9
  13. package/Placeholder/styles/mixin.less +7 -0
  14. package/Sidenav/styles/index.css +3 -0
  15. package/Sidenav/styles/index.less +4 -0
  16. package/TagInput/styles/index.css +2 -0
  17. package/TagPicker/styles/index.css +2 -0
  18. package/cjs/Avatar/Avatar.js +16 -8
  19. package/cjs/Avatar/useImage.js +0 -1
  20. package/cjs/AvatarGroup/AvatarGroup.d.ts +1 -0
  21. package/cjs/AvatarGroup/AvatarGroup.js +12 -12
  22. package/cjs/Checkbox/Checkbox.js +1 -1
  23. package/cjs/Form/Form.js +40 -56
  24. package/cjs/Form/FormContext.d.ts +1 -1
  25. package/cjs/Form/{useFormClassNames.d.ts → hooks/useFormClassNames.d.ts} +2 -2
  26. package/cjs/Form/{useFormClassNames.js → hooks/useFormClassNames.js} +2 -2
  27. package/cjs/Form/hooks/useFormError.d.ts +6 -0
  28. package/cjs/Form/hooks/useFormError.js +31 -0
  29. package/cjs/Form/hooks/useFormValue.d.ts +6 -0
  30. package/cjs/Form/hooks/useFormValue.js +31 -0
  31. package/cjs/Form/index.d.ts +1 -1
  32. package/cjs/Form/index.js +3 -9
  33. package/cjs/FormControl/FormControl.js +1 -1
  34. package/cjs/FormControl/useRegisterModel.d.ts +1 -1
  35. package/cjs/Placeholder/PlaceholderGraph.d.ts +13 -1
  36. package/cjs/Placeholder/PlaceholderGrid.d.ts +27 -1
  37. package/cjs/Placeholder/PlaceholderGrid.js +10 -13
  38. package/cjs/Placeholder/PlaceholderParagraph.d.ts +24 -1
  39. package/cjs/Placeholder/PlaceholderParagraph.js +13 -9
  40. package/dist/rsuite-no-reset-rtl.css +49 -6
  41. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  42. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  43. package/dist/rsuite-no-reset.css +49 -6
  44. package/dist/rsuite-no-reset.min.css +1 -1
  45. package/dist/rsuite-no-reset.min.css.map +1 -1
  46. package/dist/rsuite-rtl.css +49 -6
  47. package/dist/rsuite-rtl.min.css +1 -1
  48. package/dist/rsuite-rtl.min.css.map +1 -1
  49. package/dist/rsuite.css +49 -6
  50. package/dist/rsuite.js +98 -34
  51. package/dist/rsuite.js.map +1 -1
  52. package/dist/rsuite.min.css +1 -1
  53. package/dist/rsuite.min.css.map +1 -1
  54. package/dist/rsuite.min.js +1 -1
  55. package/dist/rsuite.min.js.map +1 -1
  56. package/esm/Avatar/Avatar.js +12 -4
  57. package/esm/Avatar/useImage.js +0 -1
  58. package/esm/AvatarGroup/AvatarGroup.d.ts +1 -0
  59. package/esm/AvatarGroup/AvatarGroup.js +12 -12
  60. package/esm/Checkbox/Checkbox.js +1 -1
  61. package/esm/Form/Form.js +40 -56
  62. package/esm/Form/FormContext.d.ts +1 -1
  63. package/esm/Form/{useFormClassNames.d.ts → hooks/useFormClassNames.d.ts} +2 -2
  64. package/esm/Form/{useFormClassNames.js → hooks/useFormClassNames.js} +2 -2
  65. package/esm/Form/hooks/useFormError.d.ts +6 -0
  66. package/esm/Form/hooks/useFormError.js +26 -0
  67. package/esm/Form/hooks/useFormValue.d.ts +6 -0
  68. package/esm/Form/hooks/useFormValue.js +26 -0
  69. package/esm/Form/index.d.ts +1 -1
  70. package/esm/Form/index.js +1 -1
  71. package/esm/FormControl/FormControl.js +1 -1
  72. package/esm/FormControl/useRegisterModel.d.ts +1 -1
  73. package/esm/Placeholder/PlaceholderGraph.d.ts +13 -1
  74. package/esm/Placeholder/PlaceholderGrid.d.ts +27 -1
  75. package/esm/Placeholder/PlaceholderGrid.js +10 -13
  76. package/esm/Placeholder/PlaceholderParagraph.d.ts +24 -1
  77. package/esm/Placeholder/PlaceholderParagraph.js +12 -8
  78. package/package.json +2 -2
  79. /package/cjs/Form/{useSchemaModel.d.ts → hooks/useSchemaModel.d.ts} +0 -0
  80. /package/cjs/Form/{useSchemaModel.js → hooks/useSchemaModel.js} +0 -0
  81. /package/esm/Form/{useSchemaModel.d.ts → hooks/useSchemaModel.d.ts} +0 -0
  82. /package/esm/Form/{useSchemaModel.js → hooks/useSchemaModel.js} +0 -0
@@ -5,7 +5,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
5
5
  var _templateObject, _templateObject2;
6
6
  import React, { useContext, useMemo } from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import { useClassNames } from '../utils';
8
+ import { useClassNames, useCustom, isIE } from '../utils';
9
9
  import { AvatarGroupContext } from '../AvatarGroup/AvatarGroup';
10
10
  import { oneOf } from '../internals/propTypes';
11
11
  import AvatarIcon from './AvatarIcon';
@@ -15,8 +15,10 @@ import useImage from './useImage';
15
15
  * @see https://rsuitejs.com/components/avatar
16
16
  */
17
17
  var Avatar = /*#__PURE__*/React.forwardRef(function (props, ref) {
18
+ var _extends2;
18
19
  var _useContext = useContext(AvatarGroupContext),
19
- groupSize = _useContext.size;
20
+ groupSize = _useContext.size,
21
+ spacing = _useContext.spacing;
20
22
  var _props$as = props.as,
21
23
  Component = _props$as === void 0 ? 'div' : _props$as,
22
24
  bordered = props.bordered,
@@ -32,9 +34,10 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (props, ref) {
32
34
  src = props.src,
33
35
  srcSet = props.srcSet,
34
36
  sizes = props.sizes,
37
+ style = props.style,
35
38
  imgProps = props.imgProps,
36
39
  onError = props.onError,
37
- rest = _objectWithoutPropertiesLoose(props, ["as", "bordered", "alt", "className", "children", "circle", "color", "classPrefix", "size", "src", "srcSet", "sizes", "imgProps", "onError"]);
40
+ rest = _objectWithoutPropertiesLoose(props, ["as", "bordered", "alt", "className", "children", "circle", "color", "classPrefix", "size", "src", "srcSet", "sizes", "style", "imgProps", "onError"]);
38
41
  var _useClassNames = useClassNames(classPrefix),
39
42
  withClassPrefix = _useClassNames.withClassPrefix,
40
43
  prefix = _useClassNames.prefix,
@@ -53,6 +56,8 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (props, ref) {
53
56
  onError: onError
54
57
  })),
55
58
  loaded = _useImage.loaded;
59
+ var _useCustom = useCustom('Avatar'),
60
+ rtl = _useCustom.rtl;
56
61
  var altComponent = useMemo(function () {
57
62
  if (alt) {
58
63
  return /*#__PURE__*/React.createElement("span", {
@@ -68,9 +73,12 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (props, ref) {
68
73
  var image = loaded ? /*#__PURE__*/React.createElement("img", _extends({}, imageProps, {
69
74
  className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["image"])))
70
75
  })) : placeholder;
76
+ var margin = rtl ? 'marginLeft' : 'marginRight';
77
+ var insertStyles = isIE() && spacing ? _extends((_extends2 = {}, _extends2[margin] = spacing, _extends2), style) : style;
71
78
  return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
72
79
  ref: ref,
73
- className: classes
80
+ className: classes,
81
+ style: insertStyles
74
82
  }), src ? image : placeholder);
75
83
  });
76
84
  Avatar.displayName = 'Avatar';
@@ -61,7 +61,6 @@ var useImage = function useImage(props) {
61
61
  useEffect(function () {
62
62
  return flush;
63
63
  }, []);
64
- console.log('status', status);
65
64
  return {
66
65
  loaded: status === 'loaded',
67
66
  status: status
@@ -18,6 +18,7 @@ export interface AvatarGroupProps extends WithAsProps {
18
18
  }
19
19
  export declare const AvatarGroupContext: React.Context<{
20
20
  size?: Size | undefined;
21
+ spacing?: number | undefined;
21
22
  }>;
22
23
  /**
23
24
  * The AvatarGroup component is used to represent a collection of avatars.
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import React, { useMemo } from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { useClassNames, useCustom } from '../utils';
6
+ import { useClassNames, isIE } from '../utils';
7
7
  import { oneOf } from '../internals/propTypes';
8
8
  export var AvatarGroupContext = /*#__PURE__*/React.createContext({});
9
9
 
@@ -21,9 +21,8 @@ var AvatarGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
21
21
  children = props.children,
22
22
  stack = props.stack,
23
23
  size = props.size,
24
- rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "spacing", "className", "children", "stack", "size"]);
25
- var _useCustom = useCustom('AvatarGroup'),
26
- rtl = _useCustom.rtl;
24
+ style = props.style,
25
+ rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "spacing", "className", "children", "stack", "size", "style"]);
27
26
  var _useClassNames = useClassNames(classPrefix),
28
27
  withClassPrefix = _useClassNames.withClassPrefix,
29
28
  merge = _useClassNames.merge;
@@ -35,17 +34,18 @@ var AvatarGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
35
34
  size: size
36
35
  };
37
36
  }, [size]);
38
- return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
37
+ var styles = isIE() ? style : _extends({}, style, {
38
+ gap: spacing
39
+ });
40
+ return /*#__PURE__*/React.createElement(Component, _extends({
41
+ role: "group"
42
+ }, rest, {
39
43
  ref: ref,
40
- className: classes
44
+ className: classes,
45
+ style: styles
41
46
  }), /*#__PURE__*/React.createElement(AvatarGroupContext.Provider, {
42
47
  value: contextValue
43
- }, spacing ? React.Children.map(children, function (child) {
44
- var _extends2;
45
- return /*#__PURE__*/React.cloneElement(child, {
46
- style: _extends((_extends2 = {}, _extends2[rtl ? 'marginLeft' : 'marginRight'] = spacing, _extends2), child.props.style)
47
- });
48
- }) : children));
48
+ }, children));
49
49
  });
50
50
  AvatarGroup.displayName = 'AvatarGroup';
51
51
  AvatarGroup.propTypes = {
@@ -131,7 +131,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
131
131
  })), /*#__PURE__*/React.createElement("span", {
132
132
  className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["inner"]))),
133
133
  "aria-hidden": true,
134
- role: "presentation"
134
+ "data-testid": "checkbox-control-inner"
135
135
  }));
136
136
  return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
137
137
  ref: ref,
package/esm/Form/Form.js CHANGED
@@ -12,10 +12,12 @@ import FormControlLabel from '../FormControlLabel';
12
12
  import FormErrorMessage from '../FormErrorMessage';
13
13
  import FormGroup from '../FormGroup';
14
14
  import FormHelpText from '../FormHelpText';
15
- import { useFormClassNames } from './useFormClassNames';
16
- import useSchemaModel from './useSchemaModel';
17
- import { useControlled, useEventCallback } from '../utils';
15
+ import { useEventCallback } from '../utils';
18
16
  import { oneOf } from '../internals/propTypes';
17
+ import useSchemaModel from './hooks/useSchemaModel';
18
+ import useFormError from './hooks/useFormError';
19
+ import useFormValue from './hooks/useFormValue';
20
+ import useFormClassNames from './hooks/useFormClassNames';
19
21
  /**
20
22
  * The `Form` component is a form interface for collecting and validating user input.
21
23
  * @see https://rsuitejs.com/components/form
@@ -29,8 +31,8 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
29
31
  errorFromContext = _props$errorFromConte === void 0 ? true : _props$errorFromConte,
30
32
  _props$formDefaultVal = props.formDefaultValue,
31
33
  formDefaultValue = _props$formDefaultVal === void 0 ? {} : _props$formDefaultVal,
32
- formValue = props.formValue,
33
- formError = props.formError,
34
+ formValueProp = props.formValue,
35
+ formErrorProp = props.formError,
34
36
  fluid = props.fluid,
35
37
  _props$nestedField = props.nestedField,
36
38
  nestedField = _props$nestedField === void 0 ? false : _props$nestedField,
@@ -61,29 +63,25 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
61
63
  plaintext: plaintext,
62
64
  disabled: disabled
63
65
  });
64
- var _useControlled = useControlled(formValue, formDefaultValue),
65
- realFormValue = _useControlled[0],
66
- setFormValue = _useControlled[1];
67
- var _useControlled2 = useControlled(formError, {}),
68
- realFormError = _useControlled2[0],
69
- setFormError = _useControlled2[1];
70
- var realFormValueRef = useRef(realFormValue);
71
- realFormValueRef.current = realFormValue;
72
- var realFormErrorRef = useRef(realFormError);
73
- realFormErrorRef.current = realFormError;
74
-
66
+ var _useFormValue = useFormValue(formValueProp, formDefaultValue),
67
+ formValue = _useFormValue.formValue,
68
+ setFormValue = _useFormValue.setFormValue,
69
+ onRemoveValue = _useFormValue.onRemoveValue;
70
+ var _useFormError = useFormError(formErrorProp),
71
+ formError = _useFormError.formError,
72
+ setFormError = _useFormError.setFormError,
73
+ onRemoveError = _useFormError.onRemoveError;
75
74
  /**
76
75
  * Validate the form data and return a boolean.
77
76
  * The error message after verification is returned in the callback.
78
77
  * @param callback
79
78
  */
80
79
  var check = useEventCallback(function (callback) {
81
- var formValue = realFormValue || {};
82
80
  var formError = {};
83
81
  var errorCount = 0;
84
82
  var model = getCombinedModel();
85
- Object.keys(model.spec).forEach(function (key) {
86
- var checkResult = model.checkForField(key, formValue);
83
+ Object.keys(model.getSchemaSpec()).forEach(function (key) {
84
+ var checkResult = model.checkForField(key, formValue || {});
87
85
  if (checkResult.hasError === true) {
88
86
  errorCount += 1;
89
87
  formError[key] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult;
@@ -106,15 +104,14 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
106
104
  */
107
105
  var checkForField = useEventCallback(function (fieldName, callback) {
108
106
  var _extends2;
109
- var formValue = realFormValue || {};
110
107
  var model = getCombinedModel();
111
- var checkResult = model.checkForField(fieldName, formValue);
112
- var formError = _extends({}, realFormError, (_extends2 = {}, _extends2[fieldName] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult, _extends2));
113
- setFormError(formError);
114
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
108
+ var checkResult = model.checkForField(fieldName, formValue || {});
109
+ var nextFormError = _extends({}, formError, (_extends2 = {}, _extends2[fieldName] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult, _extends2));
110
+ setFormError(nextFormError);
111
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
115
112
  callback === null || callback === void 0 ? void 0 : callback(checkResult);
116
113
  if (checkResult.hasError) {
117
- onError === null || onError === void 0 ? void 0 : onError(formError);
114
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
118
115
  }
119
116
  return !checkResult.hasError;
120
117
  });
@@ -123,13 +120,12 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
123
120
  * Check form data asynchronously and return a Promise
124
121
  */
125
122
  var checkAsync = useEventCallback(function () {
126
- var formValue = realFormValue || {};
127
123
  var promises = [];
128
124
  var keys = [];
129
125
  var model = getCombinedModel();
130
- Object.keys(model.spec).forEach(function (key) {
126
+ Object.keys(model.getSchemaSpec()).forEach(function (key) {
131
127
  keys.push(key);
132
- promises.push(model.checkForFieldAsync(key, formValue));
128
+ promises.push(model.checkForFieldAsync(key, formValue || {}));
133
129
  });
134
130
  return Promise.all(promises).then(function (values) {
135
131
  var formError = {};
@@ -157,15 +153,14 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
157
153
  * @param fieldName
158
154
  */
159
155
  var checkForFieldAsync = useEventCallback(function (fieldName) {
160
- var formValue = realFormValue || {};
161
156
  var model = getCombinedModel();
162
- return model.checkForFieldAsync(fieldName, formValue).then(function (checkResult) {
157
+ return model.checkForFieldAsync(fieldName, formValue || {}).then(function (checkResult) {
163
158
  var _extends3;
164
- var formError = _extends({}, realFormError, (_extends3 = {}, _extends3[fieldName] = checkResult.errorMessage, _extends3));
165
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
166
- setFormError(formError);
159
+ var nextFormError = _extends({}, formError, (_extends3 = {}, _extends3[fieldName] = checkResult.errorMessage, _extends3));
160
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
161
+ setFormError(nextFormError);
167
162
  if (checkResult.hasError) {
168
- onError === null || onError === void 0 ? void 0 : onError(formError);
163
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
169
164
  }
170
165
  return checkResult;
171
166
  });
@@ -174,7 +169,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
174
169
  setFormError({});
175
170
  });
176
171
  var cleanErrorForField = useEventCallback(function (fieldName) {
177
- setFormError(omit(realFormError, [fieldName]));
172
+ setFormError(omit(formError, [fieldName]));
178
173
  });
179
174
  var resetErrors = useEventCallback(function (formError) {
180
175
  if (formError === void 0) {
@@ -195,23 +190,12 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
195
190
  };
196
191
  });
197
192
  var removeFieldError = useEventCallback(function (name) {
198
- /**
199
- * when this function is called when the children component is unmount, it's an old render frame
200
- * so use Ref to get future error
201
- */
202
- var formError = omit(realFormErrorRef.current, [name]);
203
- realFormErrorRef.current = formError;
193
+ var formError = onRemoveError(name);
204
194
  setFormError(formError);
205
195
  onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
206
196
  });
207
197
  var removeFieldValue = useEventCallback(function (name) {
208
- /**
209
- * when this function is called when the children component is unmount, it's an old render frame
210
- * so use Ref to get future value
211
- */
212
- var formValue = omit(realFormValueRef.current, [name]);
213
- realFormValueRef.current = formValue;
214
- setFormValue(formValue);
198
+ var formValue = onRemoveValue(name);
215
199
  onChange === null || onChange === void 0 ? void 0 : onChange(formValue);
216
200
  });
217
201
  var handleSubmit = useEventCallback(function (event) {
@@ -225,10 +209,10 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
225
209
  });
226
210
  var handleFieldError = useEventCallback(function (name, errorMessage) {
227
211
  var _extends4;
228
- var formError = _extends({}, realFormError, (_extends4 = {}, _extends4[name] = errorMessage, _extends4));
229
- setFormError(formError);
230
- onError === null || onError === void 0 ? void 0 : onError(formError);
231
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
212
+ var nextFormError = _extends({}, formError, (_extends4 = {}, _extends4[name] = errorMessage, _extends4));
213
+ setFormError(nextFormError);
214
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
215
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
232
216
  });
233
217
  var handleFieldSuccess = useEventCallback(function (name) {
234
218
  removeFieldError(name);
@@ -241,7 +225,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
241
225
  return _extends({}, formValue, (_extends5 = {}, _extends5[fieldName] = fieldValue, _extends5));
242
226
  };
243
227
  var handleFieldChange = useEventCallback(function (name, value, event) {
244
- var nextFormValue = setFieldValue(realFormValue, name, value);
228
+ var nextFormValue = setFieldValue(formValue, name, value);
245
229
  setFormValue(nextFormValue);
246
230
  onChange === null || onChange === void 0 ? void 0 : onChange(nextFormValue, event);
247
231
  });
@@ -254,7 +238,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
254
238
  readOnly: readOnly,
255
239
  plaintext: plaintext,
256
240
  disabled: disabled,
257
- formError: realFormError,
241
+ formError: formError,
258
242
  nestedField: nestedField,
259
243
  removeFieldValue: removeFieldValue,
260
244
  removeFieldError: removeFieldError,
@@ -264,7 +248,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
264
248
  onFieldError: handleFieldError,
265
249
  onFieldSuccess: handleFieldSuccess
266
250
  };
267
- }, [getCombinedModel, checkTrigger, errorFromContext, readOnly, plaintext, disabled, realFormError, nestedField, removeFieldValue, removeFieldError, pushFieldRule, removeFieldRule, handleFieldChange, handleFieldError, handleFieldSuccess]);
251
+ }, [getCombinedModel, checkTrigger, errorFromContext, readOnly, plaintext, disabled, formError, nestedField, removeFieldValue, removeFieldError, pushFieldRule, removeFieldRule, handleFieldChange, handleFieldError, handleFieldSuccess]);
268
252
  return /*#__PURE__*/React.createElement("form", _extends({}, rest, {
269
253
  ref: rootRef,
270
254
  onSubmit: handleSubmit,
@@ -272,7 +256,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
272
256
  }), /*#__PURE__*/React.createElement(FormContext.Provider, {
273
257
  value: formContextValue
274
258
  }, /*#__PURE__*/React.createElement(FormValueContext.Provider, {
275
- value: realFormValue
259
+ value: formValue
276
260
  }, children)));
277
261
  });
278
262
  Form.Control = FormControl;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TypeAttributes } from '../@types/common';
3
3
  import type { Schema } from 'schema-typed';
4
- import type { FieldRuleType } from './useSchemaModel';
4
+ import type { FieldRuleType } from './hooks/useSchemaModel';
5
5
  interface TrulyFormContextValue<T = Record<string, any>, errorMsgType = any, E = {
6
6
  [P in keyof T]?: errorMsgType;
7
7
  }> {
@@ -1,5 +1,5 @@
1
- import type { FormProps } from './Form';
1
+ import type { FormProps } from '../Form';
2
2
  /**
3
3
  * Take <Form> props and return className for <Form> styles
4
4
  */
5
- export declare function useFormClassNames({ classPrefix, className, fluid, layout, readOnly, plaintext, disabled }: Pick<FormProps, 'classPrefix' | 'className' | 'fluid' | 'layout' | 'readOnly' | 'plaintext' | 'disabled'>): string;
5
+ export default function useFormClassNames({ classPrefix, className, fluid, layout, readOnly, plaintext, disabled }: Pick<FormProps, 'classPrefix' | 'className' | 'fluid' | 'layout' | 'readOnly' | 'plaintext' | 'disabled'>): string;
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import { useClassNames } from '../utils';
2
+ import { useClassNames } from '../../utils';
3
3
  /**
4
4
  * Take <Form> props and return className for <Form> styles
5
5
  */
6
- export function useFormClassNames(_ref) {
6
+ export default function useFormClassNames(_ref) {
7
7
  var _ref$classPrefix = _ref.classPrefix,
8
8
  classPrefix = _ref$classPrefix === void 0 ? 'form' : _ref$classPrefix,
9
9
  className = _ref.className,
@@ -0,0 +1,6 @@
1
+ /// <reference types="lodash" />
2
+ export default function useFormError(formError: any): {
3
+ formError: any;
4
+ setFormError: (value: any) => void;
5
+ onRemoveError: (name: string) => import("lodash").Omit<any, string>;
6
+ };
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { useRef, useCallback } from 'react';
3
+ import omit from 'lodash/omit';
4
+ import { useControlled } from '../../utils';
5
+ export default function useFormError(formError) {
6
+ var _useControlled = useControlled(formError, {}),
7
+ realFormError = _useControlled[0],
8
+ setFormError = _useControlled[1];
9
+ var realFormErrorRef = useRef(realFormError);
10
+ realFormErrorRef.current = realFormError;
11
+ var onRemoveError = useCallback(function (name) {
12
+ /**
13
+ * when this function is called when the children component is unmount,
14
+ * it's an old render frame so use Ref to get future error
15
+ */
16
+ var formError = omit(realFormErrorRef.current, [name]);
17
+ realFormErrorRef.current = formError;
18
+ setFormError(formError);
19
+ return formError;
20
+ }, [setFormError]);
21
+ return {
22
+ formError: realFormError,
23
+ setFormError: setFormError,
24
+ onRemoveError: onRemoveError
25
+ };
26
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="lodash" />
2
+ export default function useFormValue(controlledValue: any, formDefaultValue: any): {
3
+ formValue: any;
4
+ setFormValue: (value: any) => void;
5
+ onRemoveValue: (name: string) => import("lodash").Omit<any, string>;
6
+ };
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { useRef, useCallback } from 'react';
3
+ import omit from 'lodash/omit';
4
+ import { useControlled } from '../../utils';
5
+ export default function useFormValue(controlledValue, formDefaultValue) {
6
+ var _useControlled = useControlled(controlledValue, formDefaultValue),
7
+ formValue = _useControlled[0],
8
+ setFormValue = _useControlled[1];
9
+ var realFormValueRef = useRef(formValue);
10
+ realFormValueRef.current = formValue;
11
+ var onRemoveValue = useCallback(function (name) {
12
+ /**
13
+ * when this function is called when the children component is unmount,
14
+ * it's an old render frame so use Ref to get future value
15
+ */
16
+ var formValue = omit(realFormValueRef.current, [name]);
17
+ realFormValueRef.current = formValue;
18
+ setFormValue(formValue);
19
+ return formValue;
20
+ }, [setFormValue]);
21
+ return {
22
+ formValue: formValue,
23
+ setFormValue: setFormValue,
24
+ onRemoveValue: onRemoveValue
25
+ };
26
+ }
@@ -5,5 +5,5 @@ export type { FormErrorMessageProps } from '../FormErrorMessage';
5
5
  export type { FormControlLabelProps } from '../FormControlLabel';
6
6
  export type { FormHelpTextProps } from '../FormHelpText';
7
7
  export type { FormControlProps } from '../FormControl';
8
- export * from './useFormClassNames';
8
+ export { default as useFormClassNames } from './hooks/useFormClassNames';
9
9
  export default Form;
package/esm/Form/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client';
2
2
  import Form from './Form';
3
- export * from './useFormClassNames';
3
+ export { default as useFormClassNames } from './hooks/useFormClassNames';
4
4
  export default Form;
@@ -180,7 +180,7 @@ var FormControl = /*#__PURE__*/React.forwardRef(function (props, ref) {
180
180
  id: controlId ? controlId + "-error-message" : undefined,
181
181
  role: "alert",
182
182
  "aria-relevant": "all",
183
- show: !!messageNode,
183
+ show: fieldHasError,
184
184
  className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["message-wrapper"]))),
185
185
  placement: errorPlacement
186
186
  }, messageNode));
@@ -1,4 +1,4 @@
1
- import type { FieldRuleType } from '../Form/useSchemaModel';
1
+ import type { FieldRuleType } from '../Form/hooks/useSchemaModel';
2
2
  import type { CheckType } from 'schema-typed';
3
3
  declare function useRegisterModel(name: string, pushFieldRule: (n: string, r: FieldRuleType) => void, removeFieldRule: (n: string) => void, rule?: CheckType<unknown, any>): void;
4
4
  export default useRegisterModel;
@@ -1,8 +1,20 @@
1
1
  import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
2
2
  export interface PlaceholderGraphProps extends WithAsProps {
3
+ /**
4
+ * The height of the graph.
5
+ *
6
+ * @default 200
7
+ */
3
8
  height?: number;
9
+ /**
10
+ * The width of the graph.
11
+ *
12
+ * @default 100%
13
+ */
4
14
  width?: number;
5
- /** Placeholder status */
15
+ /**
16
+ * Placeholder status, display the loading state.
17
+ */
6
18
  active?: boolean;
7
19
  }
8
20
  /**
@@ -1,10 +1,36 @@
1
1
  import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
2
2
  export interface PlaceholderGridProps extends WithAsProps {
3
+ /**
4
+ * The number of rows.
5
+ *
6
+ * @default 5
7
+ */
3
8
  rows?: number;
9
+ /**
10
+ * The height of the row.
11
+ *
12
+ * @default 10
13
+ */
4
14
  rowHeight?: number;
15
+ /**
16
+ * @deprecated Use `rowSpacing` instead.
17
+ */
5
18
  rowMargin?: number;
19
+ /**
20
+ * The spacing between rows.
21
+ *
22
+ * @default 20
23
+ * @version 5.59.1
24
+ */
25
+ rowSpacing?: number;
26
+ /**
27
+ * The number of columns.
28
+ * @default 5
29
+ */
6
30
  columns?: number;
7
- /** Placeholder status */
31
+ /**
32
+ * Placeholder status, display the loading state.
33
+ */
8
34
  active?: boolean;
9
35
  }
10
36
  /**
@@ -1,6 +1,8 @@
1
1
  'use client';
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
3
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ var _templateObject;
4
6
  import React from 'react';
5
7
  import PropTypes from 'prop-types';
6
8
  import classNames from 'classnames';
@@ -23,8 +25,10 @@ var PlaceholderGrid = /*#__PURE__*/React.forwardRef(function (props, ref) {
23
25
  rowHeight = _props$rowHeight === void 0 ? 10 : _props$rowHeight,
24
26
  _props$rowMargin = props.rowMargin,
25
27
  rowMargin = _props$rowMargin === void 0 ? 20 : _props$rowMargin,
28
+ _props$rowSpacing = props.rowSpacing,
29
+ rowSpacing = _props$rowSpacing === void 0 ? rowMargin : _props$rowSpacing,
26
30
  active = props.active,
27
- rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "rows", "columns", "rowHeight", "rowMargin", "active"]);
31
+ rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "rows", "columns", "rowHeight", "rowMargin", "rowSpacing", "active"]);
28
32
  var _useClassNames = useClassNames(classPrefix),
29
33
  merge = _useClassNames.merge,
30
34
  prefix = _useClassNames.prefix,
@@ -33,23 +37,16 @@ var PlaceholderGrid = /*#__PURE__*/React.forwardRef(function (props, ref) {
33
37
  active: active
34
38
  }));
35
39
  var colItems = [];
36
- var firstRowItemWidth = Math.random() * 30 + 30;
37
- var itemWidth = firstRowItemWidth / 2;
38
40
  for (var i = 0; i < columns; i++) {
39
41
  var rowItems = [];
40
42
  for (var j = 0; j < rows; j++) {
41
- var widthPercent = Math.random() * 50 + 10; // when first column
42
- if (i > 0) {
43
- // when other columns
44
- widthPercent = j > 0 ? itemWidth : firstRowItemWidth;
45
- }
46
- rowItems.push( /*#__PURE__*/React.createElement("p", {
43
+ rowItems.push( /*#__PURE__*/React.createElement("div", {
47
44
  key: j,
48
45
  style: {
49
- width: widthPercent + "%",
50
46
  height: rowHeight,
51
- marginTop: j > 0 ? rowMargin : undefined
52
- }
47
+ marginTop: j > 0 ? rowSpacing : undefined
48
+ },
49
+ className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["row"])))
53
50
  }));
54
51
  }
55
52
  colItems.push( /*#__PURE__*/React.createElement("div", {
@@ -69,7 +66,7 @@ PlaceholderGrid.propTypes = {
69
66
  rows: PropTypes.number,
70
67
  columns: PropTypes.number,
71
68
  rowHeight: PropTypes.number,
72
- rowMargin: PropTypes.number,
69
+ rowSpacing: PropTypes.number,
73
70
  active: PropTypes.bool
74
71
  };
75
72
  export default PlaceholderGrid;
@@ -1,10 +1,33 @@
1
1
  import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
2
2
  export interface PlaceholderParagraphProps extends WithAsProps {
3
+ /**
4
+ * The number of rows.
5
+ * @default 2
6
+ */
3
7
  rows?: number;
8
+ /**
9
+ * The height of the row.
10
+ * @default 10
11
+ */
4
12
  rowHeight?: number;
13
+ /**
14
+ * @deprecated Use `rowSpacing` instead.
15
+ */
5
16
  rowMargin?: number;
17
+ /**
18
+ * The spacing between rows.
19
+ * @default 20
20
+ * @version 5.59.1
21
+ */
22
+ rowSpacing?: number;
23
+ /**
24
+ * The shape of the graph.
25
+ * @default false
26
+ */
6
27
  graph?: boolean | 'circle' | 'square' | 'image';
7
- /** Placeholder status */
28
+ /**
29
+ * Placeholder status, display the loading state.
30
+ */
8
31
  active?: boolean;
9
32
  }
10
33
  /**