rsuite 5.70.0 → 5.70.2
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.
- package/Breadcrumb/styles/index.css +16 -0
- package/Breadcrumb/styles/index.less +10 -0
- package/CHANGELOG.md +19 -0
- package/cjs/Breadcrumb/Breadcrumb.d.ts +14 -4
- package/cjs/Breadcrumb/Breadcrumb.js +30 -32
- package/cjs/Breadcrumb/BreadcrumbItem.d.ts +20 -0
- package/cjs/Breadcrumb/BreadcrumbItem.js +13 -17
- package/cjs/Button/Button.js +3 -3
- package/cjs/Calendar/TableRow.js +6 -2
- package/cjs/CustomProvider/CustomProvider.d.ts +60 -9
- package/cjs/Form/Form.js +1 -1
- package/cjs/Form/hooks/useFormValidate.js +20 -3
- package/cjs/Form/hooks/useSchemaModel.d.ts +1 -1
- package/cjs/Form/hooks/useSchemaModel.js +61 -8
- package/cjs/FormControl/hooks/useField.js +4 -0
- package/cjs/internals/types/index.d.ts +14 -0
- package/cjs/internals/utils/ReactChildren.d.ts +11 -0
- package/cjs/internals/utils/ReactChildren.js +22 -0
- package/cjs/locales/index.d.ts +4 -1
- package/dist/rsuite-no-reset-rtl.css +16 -0
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +16 -0
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +16 -0
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +16 -0
- package/dist/rsuite.js +10 -10
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Breadcrumb/Breadcrumb.d.ts +14 -4
- package/esm/Breadcrumb/Breadcrumb.js +32 -34
- package/esm/Breadcrumb/BreadcrumbItem.d.ts +20 -0
- package/esm/Breadcrumb/BreadcrumbItem.js +13 -17
- package/esm/Button/Button.js +4 -4
- package/esm/Calendar/TableRow.js +6 -2
- package/esm/CustomProvider/CustomProvider.d.ts +60 -9
- package/esm/Form/Form.js +1 -1
- package/esm/Form/hooks/useFormValidate.js +20 -3
- package/esm/Form/hooks/useSchemaModel.d.ts +1 -1
- package/esm/Form/hooks/useSchemaModel.js +62 -9
- package/esm/FormControl/hooks/useField.js +4 -0
- package/esm/internals/types/index.d.ts +14 -0
- package/esm/internals/utils/ReactChildren.d.ts +11 -0
- package/esm/internals/utils/ReactChildren.js +21 -0
- package/esm/locales/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -36,9 +36,25 @@
|
|
|
36
36
|
color: #717273;
|
|
37
37
|
color: var(--rs-text-secondary);
|
|
38
38
|
}
|
|
39
|
+
.rs-breadcrumb ol {
|
|
40
|
+
display: -webkit-box;
|
|
41
|
+
display: -ms-flexbox;
|
|
42
|
+
display: flex;
|
|
43
|
+
-ms-flex-wrap: wrap;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
list-style: none;
|
|
46
|
+
padding: 0;
|
|
47
|
+
margin: 0;
|
|
48
|
+
}
|
|
39
49
|
.rs-breadcrumb-item {
|
|
40
50
|
-webkit-transition: color 0.3s linear;
|
|
41
51
|
transition: color 0.3s linear;
|
|
52
|
+
display: -webkit-box;
|
|
53
|
+
display: -ms-flexbox;
|
|
54
|
+
display: flex;
|
|
55
|
+
-webkit-box-align: center;
|
|
56
|
+
-ms-flex-align: center;
|
|
57
|
+
align-items: center;
|
|
42
58
|
}
|
|
43
59
|
.rs-breadcrumb-item:focus {
|
|
44
60
|
outline: 0;
|
|
@@ -9,9 +9,19 @@
|
|
|
9
9
|
font-size: @breadcrumb-font-size;
|
|
10
10
|
color: var(--rs-text-secondary);
|
|
11
11
|
|
|
12
|
+
ol {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
list-style: none;
|
|
16
|
+
padding: 0;
|
|
17
|
+
margin: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
// If breadcrumbs has a ci
|
|
13
21
|
&-item {
|
|
14
22
|
transition: color 0.3s linear;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
15
25
|
|
|
16
26
|
&:focus {
|
|
17
27
|
.tab-focus();
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [5.70.2](https://github.com/rsuite/rsuite/compare/v5.70.1...v5.70.2) (2024-09-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Form:** fix the error message of the nested field not displayed when the form is submitted ([#3960](https://github.com/rsuite/rsuite/issues/3960)) ([384dd70](https://github.com/rsuite/rsuite/commit/384dd70b0477470da233217d46af77315ff7089d))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [5.70.1](https://github.com/rsuite/rsuite/compare/v5.70.0...v5.70.1) (2024-09-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **Breadcrumb:** fix the rendering exception of the child node separator ([#3948](https://github.com/rsuite/rsuite/issues/3948)) ([7d54cc9](https://github.com/rsuite/rsuite/commit/7d54cc97b05e9b17797ad275b6f02ce679869579))
|
|
16
|
+
* **Calendar:** fix the problem of displaying the first week of the year incorrectly ([#3951](https://github.com/rsuite/rsuite/issues/3951)) ([a2c6891](https://github.com/rsuite/rsuite/commit/a2c6891f76cc5e435eb1980f9176dbec21ac5735))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
1
20
|
# [5.70.0](https://github.com/rsuite/rsuite/compare/v5.69.0...v5.70.0) (2024-08-24)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -3,17 +3,27 @@ import BreadcrumbItem from './BreadcrumbItem';
|
|
|
3
3
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
4
4
|
import { BreadcrumbLocale } from '../locales';
|
|
5
5
|
export interface BreadcrumbProps extends WithAsProps {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* The separator between each breadcrumb item.
|
|
8
|
+
*/
|
|
7
9
|
separator?: React.ReactNode;
|
|
8
10
|
/**
|
|
9
11
|
* Set the maximum number of breadcrumbs to display.
|
|
10
12
|
* When there are more than the maximum number,
|
|
11
13
|
* only the first and last will be shown, with an ellipsis in between.
|
|
12
|
-
|
|
14
|
+
*/
|
|
13
15
|
maxItems?: number;
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The locale of the component.
|
|
18
|
+
*/
|
|
15
19
|
locale?: BreadcrumbLocale;
|
|
16
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The ellipsis element.
|
|
22
|
+
*/
|
|
23
|
+
ellipsis?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Callback function for clicking the ellipsis.
|
|
26
|
+
*/
|
|
17
27
|
onExpand?: (event: React.MouseEvent) => void;
|
|
18
28
|
}
|
|
19
29
|
export interface BreadcrumbComponent extends RsRefForwardingComponent<'ol', BreadcrumbProps> {
|
|
@@ -5,16 +5,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
|
-
var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));
|
|
9
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
11
|
var _hooks = require("../internals/hooks");
|
|
12
|
+
var _utils = require("../internals/utils");
|
|
13
13
|
var _BreadcrumbItem = _interopRequireDefault(require("./BreadcrumbItem"));
|
|
14
|
-
var
|
|
15
|
-
var _excluded = ["as", "className", "classPrefix", "children", "maxItems", "separator", "locale", "onExpand"];
|
|
14
|
+
var _excluded = ["as", "className", "classPrefix", "children", "ellipsis", "maxItems", "separator", "locale", "onExpand"];
|
|
16
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
var Separator = (0, _utils.createComponent)({
|
|
18
|
+
name: 'BreadcrumbSeparator',
|
|
19
|
+
componentAs: 'span',
|
|
20
|
+
'aria-hidden': true
|
|
21
|
+
});
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* The Breadcrumb component is used to indicate the current page location and navigate.
|
|
20
25
|
* @see https://rsuitejs.com/components/breadcrumb
|
|
@@ -26,6 +31,8 @@ var Breadcrumb = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
26
31
|
_props$classPrefix = props.classPrefix,
|
|
27
32
|
classPrefix = _props$classPrefix === void 0 ? 'breadcrumb' : _props$classPrefix,
|
|
28
33
|
children = props.children,
|
|
34
|
+
_props$ellipsis = props.ellipsis,
|
|
35
|
+
ellipsis = _props$ellipsis === void 0 ? '...' : _props$ellipsis,
|
|
29
36
|
_props$maxItems = props.maxItems,
|
|
30
37
|
maxItems = _props$maxItems === void 0 ? 5 : _props$maxItems,
|
|
31
38
|
_props$separator = props.separator,
|
|
@@ -35,62 +42,53 @@ var Breadcrumb = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
35
42
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
36
43
|
var _useClassNames = (0, _hooks.useClassNames)(classPrefix),
|
|
37
44
|
merge = _useClassNames.merge,
|
|
38
|
-
prefix = _useClassNames.prefix,
|
|
39
45
|
withClassPrefix = _useClassNames.withClassPrefix;
|
|
40
46
|
var _useState = (0, _react.useState)(true),
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
showEllipsis = _useState[0],
|
|
48
|
+
setShowEllipsis = _useState[1];
|
|
43
49
|
var _useCustom = (0, _hooks.useCustom)('Breadcrumb', overrideLocale),
|
|
44
50
|
locale = _useCustom.locale;
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
key: "breadcrumb-separator-" + key,
|
|
48
|
-
"aria-hidden": true,
|
|
49
|
-
className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["separator"])))
|
|
50
|
-
}, separator);
|
|
51
|
-
};
|
|
52
|
-
var handleClickEllipsis = (0, _react.useCallback)(function (event) {
|
|
53
|
-
setEllipsis(false);
|
|
51
|
+
var handleClickEllipsis = (0, _hooks.useEventCallback)(function (event) {
|
|
52
|
+
setShowEllipsis(false);
|
|
54
53
|
onExpand === null || onExpand === void 0 ? void 0 : onExpand(event);
|
|
55
|
-
}
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
54
|
+
});
|
|
55
|
+
var content = (0, _react.useMemo)(function () {
|
|
56
|
+
var count = _utils.ReactChildren.count(children);
|
|
57
|
+
var items = _utils.ReactChildren.mapCloneElement(children, function (item, index) {
|
|
58
|
+
var isLast = index === count - 1;
|
|
59
|
+
return (0, _extends2.default)({}, item.props, {
|
|
60
|
+
separator: isLast ? null : /*#__PURE__*/_react.default.createElement(Separator, null, separator)
|
|
61
|
+
});
|
|
64
62
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (count > maxItems && count > 2 && ellipsis) {
|
|
68
|
-
return [].concat(items.slice(0, 2), [[/*#__PURE__*/_react.default.createElement(_BreadcrumbItem.default, {
|
|
63
|
+
if (count > maxItems && count > 2 && showEllipsis) {
|
|
64
|
+
return [].concat(items.slice(0, 1), [[/*#__PURE__*/_react.default.createElement(_BreadcrumbItem.default, {
|
|
69
65
|
role: "button",
|
|
70
66
|
key: "ellipsis",
|
|
71
67
|
title: locale.expandText,
|
|
72
68
|
"aria-label": locale.expandText,
|
|
69
|
+
separator: /*#__PURE__*/_react.default.createElement(Separator, null, separator),
|
|
73
70
|
onClick: handleClickEllipsis
|
|
74
71
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
75
72
|
"aria-hidden": true
|
|
76
|
-
},
|
|
73
|
+
}, ellipsis))]], items.slice(items.length - 1, items.length));
|
|
77
74
|
}
|
|
78
75
|
return items;
|
|
79
|
-
};
|
|
76
|
+
}, [children, ellipsis, handleClickEllipsis, locale.expandText, maxItems, separator, showEllipsis]);
|
|
80
77
|
var classes = merge(className, withClassPrefix());
|
|
81
78
|
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
82
79
|
ref: ref,
|
|
83
80
|
className: classes
|
|
84
|
-
}),
|
|
81
|
+
}), /*#__PURE__*/_react.default.createElement("ol", null, content));
|
|
85
82
|
});
|
|
86
83
|
Breadcrumb.Item = _BreadcrumbItem.default;
|
|
87
84
|
Breadcrumb.displayName = 'Breadcrumb';
|
|
88
85
|
Breadcrumb.propTypes = {
|
|
89
|
-
separator: _propTypes.default.node,
|
|
90
86
|
as: _propTypes.default.elementType,
|
|
91
87
|
children: _propTypes.default.node,
|
|
92
88
|
className: _propTypes.default.string,
|
|
93
89
|
classPrefix: _propTypes.default.string,
|
|
90
|
+
ellipsis: _propTypes.default.node,
|
|
91
|
+
separator: _propTypes.default.node,
|
|
94
92
|
maxItems: _propTypes.default.number,
|
|
95
93
|
onExpand: _propTypes.default.func
|
|
96
94
|
};
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
3
3
|
export interface BreadcrumbItemProps extends WithAsProps<React.ElementType | string> {
|
|
4
|
+
/**
|
|
5
|
+
* The wrapper element of the BreadcrumbItem.
|
|
6
|
+
*/
|
|
7
|
+
wrapperAs?: React.ElementType;
|
|
8
|
+
/**
|
|
9
|
+
* The active state of the BreadcrumbItem.
|
|
10
|
+
*/
|
|
4
11
|
active?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The href attribute specifies the URL of the page the link goes to.
|
|
14
|
+
*/
|
|
5
15
|
href?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The title attribute specifies extra information about an element.
|
|
18
|
+
*/
|
|
6
19
|
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The target attribute specifies where to open the linked document.
|
|
22
|
+
*/
|
|
7
23
|
target?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The separator between each breadcrumb item.
|
|
26
|
+
*/
|
|
27
|
+
separator?: React.ReactNode;
|
|
8
28
|
}
|
|
9
29
|
/**
|
|
10
30
|
* The `<Breadcrumb.Item>` component is used to specify each section of the Breadcrumb.
|
|
@@ -10,15 +10,17 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _SafeAnchor = _interopRequireDefault(require("../SafeAnchor"));
|
|
12
12
|
var _hooks = require("../internals/hooks");
|
|
13
|
-
var _excluded = ["
|
|
13
|
+
var _excluded = ["wrapperAs", "href", "as", "classPrefix", "title", "target", "className", "style", "active", "children", "separator"];
|
|
14
14
|
/**
|
|
15
15
|
* The `<Breadcrumb.Item>` component is used to specify each section of the Breadcrumb.
|
|
16
16
|
* @see https://rsuitejs.com/components/breadcrumb
|
|
17
17
|
*/
|
|
18
18
|
var BreadcrumbItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
19
|
-
var _props$
|
|
20
|
-
|
|
19
|
+
var _props$wrapperAs = props.wrapperAs,
|
|
20
|
+
WrapperComponent = _props$wrapperAs === void 0 ? 'li' : _props$wrapperAs,
|
|
21
21
|
href = props.href,
|
|
22
|
+
_props$as = props.as,
|
|
23
|
+
Component = _props$as === void 0 ? href ? _SafeAnchor.default : 'span' : _props$as,
|
|
22
24
|
_props$classPrefix = props.classPrefix,
|
|
23
25
|
classPrefix = _props$classPrefix === void 0 ? 'breadcrumb-item' : _props$classPrefix,
|
|
24
26
|
title = props.title,
|
|
@@ -27,6 +29,7 @@ var BreadcrumbItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
27
29
|
style = props.style,
|
|
28
30
|
active = props.active,
|
|
29
31
|
children = props.children,
|
|
32
|
+
separator = props.separator,
|
|
30
33
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
31
34
|
var _useClassNames = (0, _hooks.useClassNames)(classPrefix),
|
|
32
35
|
merge = _useClassNames.merge,
|
|
@@ -34,22 +37,15 @@ var BreadcrumbItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
34
37
|
var classes = merge(className, withClassPrefix({
|
|
35
38
|
active: active
|
|
36
39
|
}));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
className: classes
|
|
43
|
-
}), children);
|
|
44
|
-
}
|
|
45
|
-
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(WrapperComponent, (0, _extends2.default)({
|
|
41
|
+
style: style,
|
|
42
|
+
className: classes,
|
|
43
|
+
ref: ref
|
|
44
|
+
}, rest), active ? /*#__PURE__*/_react.default.createElement("span", null, children) : /*#__PURE__*/_react.default.createElement(Component, {
|
|
46
45
|
href: href,
|
|
47
46
|
title: title,
|
|
48
|
-
target: target
|
|
49
|
-
|
|
50
|
-
style: style,
|
|
51
|
-
className: classes
|
|
52
|
-
}), children);
|
|
47
|
+
target: target
|
|
48
|
+
}, children), separator);
|
|
53
49
|
});
|
|
54
50
|
BreadcrumbItem.displayName = 'BreadcrumbItem';
|
|
55
51
|
BreadcrumbItem.propTypes = {
|
package/cjs/Button/Button.js
CHANGED
|
@@ -55,7 +55,7 @@ var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
55
55
|
loading: loading,
|
|
56
56
|
block: block
|
|
57
57
|
}));
|
|
58
|
-
var
|
|
58
|
+
var buttonContent = (0, _react.useMemo)(function () {
|
|
59
59
|
var spin = /*#__PURE__*/_react.default.createElement("span", {
|
|
60
60
|
className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["spin"])))
|
|
61
61
|
});
|
|
@@ -73,7 +73,7 @@ var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
73
73
|
"aria-disabled": disabled,
|
|
74
74
|
disabled: disabled,
|
|
75
75
|
className: classes
|
|
76
|
-
}),
|
|
76
|
+
}), buttonContent);
|
|
77
77
|
}
|
|
78
78
|
var Component = as || 'button';
|
|
79
79
|
var type = typeProp || (Component === 'button' ? 'button' : undefined);
|
|
@@ -85,7 +85,7 @@ var Button = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
85
85
|
disabled: disabled,
|
|
86
86
|
"aria-disabled": disabled,
|
|
87
87
|
className: classes
|
|
88
|
-
}),
|
|
88
|
+
}), buttonContent);
|
|
89
89
|
});
|
|
90
90
|
Button.displayName = 'Button';
|
|
91
91
|
Button.propTypes = {
|
package/cjs/Calendar/TableRow.js
CHANGED
|
@@ -16,6 +16,7 @@ var _excluded = ["as", "className", "classPrefix", "weekendDate", "rowIndex"];
|
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
18
|
var TableRow = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
19
|
+
var _locale$dateLocale$op, _locale$dateLocale;
|
|
19
20
|
var _props$as = props.as,
|
|
20
21
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
21
22
|
className = props.className,
|
|
@@ -100,10 +101,13 @@ var TableRow = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
100
101
|
return days;
|
|
101
102
|
};
|
|
102
103
|
var classes = merge(className, prefix('row'));
|
|
104
|
+
var _ref3 = (_locale$dateLocale$op = locale === null || locale === void 0 ? void 0 : (_locale$dateLocale = locale.dateLocale) === null || _locale$dateLocale === void 0 ? void 0 : _locale$dateLocale.options) !== null && _locale$dateLocale$op !== void 0 ? _locale$dateLocale$op : {},
|
|
105
|
+
firstWeekContainsDate = _ref3.firstWeekContainsDate,
|
|
106
|
+
weekStartsOn = _ref3.weekStartsOn;
|
|
103
107
|
var week = (0, _date.format)(weekendDate, isoWeek ? 'I' : 'w', {
|
|
104
108
|
locale: locale === null || locale === void 0 ? void 0 : locale.dateLocale,
|
|
105
|
-
firstWeekContainsDate:
|
|
106
|
-
weekStartsOn: weekStart
|
|
109
|
+
firstWeekContainsDate: firstWeekContainsDate,
|
|
110
|
+
weekStartsOn: weekStart || weekStartsOn
|
|
107
111
|
});
|
|
108
112
|
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
109
113
|
ref: ref,
|
|
@@ -1,18 +1,67 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { Locale as DateFnsLocale } from 'date-fns';
|
|
3
2
|
import { Locale } from '../locales';
|
|
4
3
|
import { ToastContainerInstance } from '../toaster/ToastContainer';
|
|
4
|
+
import type { Locale as DateFnsLocale } from 'date-fns';
|
|
5
|
+
import type { DateFns } from '../internals/types';
|
|
5
6
|
export interface FormatDateOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The locale object that contains the language and formatting rules for the date.
|
|
9
|
+
*/
|
|
6
10
|
locale?: DateFnsLocale;
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Defines which day of the week should be considered the start of the week.
|
|
13
|
+
*
|
|
14
|
+
* The value should be an integer from 0 to 6, where:
|
|
15
|
+
* - `0` represents Sunday,
|
|
16
|
+
* - `1` represents Monday,
|
|
17
|
+
* - `2` represents Tuesday,
|
|
18
|
+
* - `3` represents Wednesday,
|
|
19
|
+
* - `4` represents Thursday,
|
|
20
|
+
* - `5` represents Friday,
|
|
21
|
+
* - `6` represents Saturday.
|
|
22
|
+
*
|
|
23
|
+
* This option is important for functions that operate on weeks, such as calculating
|
|
24
|
+
* the start or end of a week, determining which week a date falls in, or generating
|
|
25
|
+
* calendar views. The default value varies depending on the locale, with Monday (`1`)
|
|
26
|
+
* being the default in most regions following ISO 8601, while Sunday (`0`) is often
|
|
27
|
+
* the default in regions like the United States.
|
|
28
|
+
*/
|
|
29
|
+
weekStartsOn?: DateFns.Day;
|
|
30
|
+
/**
|
|
31
|
+
* `firstWeekContainsDate` is used to determine which week is considered the first week of the year.
|
|
32
|
+
*
|
|
33
|
+
* This option specifies the minimum day of January that must be included in the first week.
|
|
34
|
+
*
|
|
35
|
+
* The value can be set to:
|
|
36
|
+
* - `1`: The first week of the year must include January 1st.
|
|
37
|
+
* - `4`: The first week of the year must include January 4th, which is the default according to ISO 8601.
|
|
38
|
+
*
|
|
39
|
+
* The choice between `1` and `4` typically depends on the regional or business conventions for week numbering.
|
|
40
|
+
*
|
|
41
|
+
* Please note that this option only accepts `1` (Sunday) or `4` (Thursday), aligning with common international standards.
|
|
42
|
+
*
|
|
43
|
+
* For more detailed information, please refer to https://en.wikipedia.org/wiki/Week#Week_numbering.
|
|
44
|
+
*/
|
|
45
|
+
firstWeekContainsDate?: DateFns.FirstWeekContainsDate;
|
|
46
|
+
/**
|
|
47
|
+
* If true, allows usage of the week-numbering year tokens `YY` and `YYYY`.
|
|
48
|
+
* See: https://date-fns.org/docs/Unicode-Tokens
|
|
49
|
+
**/
|
|
9
50
|
useAdditionalWeekYearTokens?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* If true, allows usage of the day of year tokens `D` and `DD`.
|
|
53
|
+
* See: https://date-fns.org/docs/Unicode-Tokens
|
|
54
|
+
*/
|
|
10
55
|
useAdditionalDayOfYearTokens?: boolean;
|
|
11
56
|
}
|
|
12
57
|
export interface CustomValue<T = Locale> {
|
|
13
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* The locale object that contains the language and formatting rules for the date.
|
|
60
|
+
*/
|
|
14
61
|
locale: T;
|
|
15
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Right-to-left text direction.
|
|
64
|
+
*/
|
|
16
65
|
rtl: boolean;
|
|
17
66
|
/**
|
|
18
67
|
* Return the formatted date string in the given format. The result may vary by locale.
|
|
@@ -26,7 +75,7 @@ export interface CustomValue<T = Locale> {
|
|
|
26
75
|
* return format(date, formatStr, { locale: eo });
|
|
27
76
|
* }
|
|
28
77
|
*
|
|
29
|
-
|
|
78
|
+
*/
|
|
30
79
|
formatDate: (date: Date | number, format: string, options?: FormatDateOptions) => string;
|
|
31
80
|
/**
|
|
32
81
|
* Return the date parsed from string using the given format string.
|
|
@@ -40,13 +89,16 @@ export interface CustomValue<T = Locale> {
|
|
|
40
89
|
* return parse(date, formatStr, new Date(), { locale: eo });
|
|
41
90
|
* }
|
|
42
91
|
*
|
|
43
|
-
|
|
92
|
+
*/
|
|
44
93
|
parseDate: (dateString: string, formatString: string, referenceDate?: Date | number, options?: FormatDateOptions) => Date;
|
|
45
94
|
/**
|
|
46
95
|
* A Map of toast containers
|
|
47
96
|
*/
|
|
48
97
|
toasters?: React.MutableRefObject<Map<string, ToastContainerInstance>>;
|
|
49
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* If true, the ripple effect is disabled.
|
|
100
|
+
* Affected components include: Button, Nav.Item, Pagination.
|
|
101
|
+
*/
|
|
50
102
|
disableRipple?: boolean;
|
|
51
103
|
}
|
|
52
104
|
export interface CustomProviderProps<T = Locale> extends Partial<CustomValue<T>> {
|
|
@@ -68,7 +120,6 @@ declare const CustomContext: React.Context<CustomProviderProps<{
|
|
|
68
120
|
} | undefined;
|
|
69
121
|
Plaintext?: {
|
|
70
122
|
unfilled: string;
|
|
71
|
-
/** Support right-to-left */
|
|
72
123
|
notSelected: string;
|
|
73
124
|
notUploaded: string;
|
|
74
125
|
} | undefined;
|
package/cjs/Form/Form.js
CHANGED
|
@@ -58,7 +58,7 @@ var Form = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
58
58
|
onError = props.onError,
|
|
59
59
|
onChange = props.onChange,
|
|
60
60
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
61
|
-
var _useSchemaModel = (0, _useSchemaModel2.default)(formModel),
|
|
61
|
+
var _useSchemaModel = (0, _useSchemaModel2.default)(formModel, nestedField),
|
|
62
62
|
getCombinedModel = _useSchemaModel.getCombinedModel,
|
|
63
63
|
pushFieldRule = _useSchemaModel.pushFieldRule,
|
|
64
64
|
removeFieldRule = _useSchemaModel.removeFieldRule;
|
|
@@ -37,12 +37,29 @@ function useFormValidate(formError, props) {
|
|
|
37
37
|
var formError = {};
|
|
38
38
|
var errorCount = 0;
|
|
39
39
|
var model = getCombinedModel();
|
|
40
|
-
|
|
41
|
-
var checkResult =
|
|
40
|
+
var checkField = function checkField(key, type, value, formErrorObj) {
|
|
41
|
+
var checkResult = type.check(value);
|
|
42
42
|
if (checkResult.hasError === true) {
|
|
43
43
|
errorCount += 1;
|
|
44
|
-
|
|
44
|
+
formErrorObj[key] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check nested object
|
|
48
|
+
if (type !== null && type !== void 0 && type.objectTypeSchemaSpec) {
|
|
49
|
+
Object.entries(type.objectTypeSchemaSpec).forEach(function (_ref) {
|
|
50
|
+
var nestedKey = _ref[0],
|
|
51
|
+
nestedType = _ref[1];
|
|
52
|
+
formErrorObj[key] = formErrorObj[key] || {
|
|
53
|
+
object: {}
|
|
54
|
+
};
|
|
55
|
+
checkField(nestedKey, nestedType, value === null || value === void 0 ? void 0 : value[nestedKey], formErrorObj[key].object);
|
|
56
|
+
});
|
|
45
57
|
}
|
|
58
|
+
};
|
|
59
|
+
Object.entries(model.getSchemaSpec()).forEach(function (_ref2) {
|
|
60
|
+
var key = _ref2[0],
|
|
61
|
+
type = _ref2[1];
|
|
62
|
+
checkField(key, type, formValue[key], formError);
|
|
46
63
|
});
|
|
47
64
|
setFormError(formError);
|
|
48
65
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
2
|
import type { CheckType, Schema } from 'schema-typed';
|
|
3
3
|
export type FieldRuleType = MutableRefObject<CheckType<unknown, any> | undefined>;
|
|
4
|
-
declare function useSchemaModel(formModel: Schema): {
|
|
4
|
+
declare function useSchemaModel(formModel: Schema, nestedField: boolean): {
|
|
5
5
|
getCombinedModel: () => Schema<any, string>;
|
|
6
6
|
pushFieldRule: (name: string, fieldRule: FieldRuleType) => void;
|
|
7
7
|
removeFieldRule: (name: string) => void;
|
|
@@ -5,7 +5,59 @@ exports.__esModule = true;
|
|
|
5
5
|
exports.default = void 0;
|
|
6
6
|
var _schemaTyped = require("schema-typed");
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Convert a flat schema object to a nested schema object
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```js
|
|
14
|
+
* const schema = {
|
|
15
|
+
* 'address.city': StringType().isRequired('City is required'),
|
|
16
|
+
* 'address.street': StringType().isRequired('Street is required')
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* const result = unflattenSchemaObject(schema);
|
|
20
|
+
*
|
|
21
|
+
* // result
|
|
22
|
+
* {
|
|
23
|
+
* address: ObjectType().shape({
|
|
24
|
+
* city: StringType().isRequired('City is required'),
|
|
25
|
+
* street: StringType().isRequired('Street is required')
|
|
26
|
+
* })
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function unflattenSchemaObject(schema) {
|
|
31
|
+
var result = {};
|
|
32
|
+
var $type = Symbol('schema-type');
|
|
33
|
+
Object.keys(schema).forEach(function (key) {
|
|
34
|
+
if (key.includes('.')) {
|
|
35
|
+
var keys = key.split('.');
|
|
36
|
+
var lastKey = keys.pop() || '';
|
|
37
|
+
var current = result;
|
|
38
|
+
keys.forEach(function (subKey) {
|
|
39
|
+
var _ref;
|
|
40
|
+
current[subKey] = current[subKey] || (_ref = {}, _ref[$type] = 'object-type', _ref);
|
|
41
|
+
current = current[subKey];
|
|
42
|
+
});
|
|
43
|
+
current[lastKey] = schema[key];
|
|
44
|
+
} else {
|
|
45
|
+
result[key] = schema[key];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
function convertToShape(obj) {
|
|
49
|
+
Object.keys(obj).forEach(function (key) {
|
|
50
|
+
var _obj$key;
|
|
51
|
+
if (((_obj$key = obj[key]) === null || _obj$key === void 0 ? void 0 : _obj$key[$type]) === 'object-type') {
|
|
52
|
+
delete obj[key][$type];
|
|
53
|
+
obj[key] = (0, _schemaTyped.ObjectType)().shape(convertToShape(obj[key]));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return obj;
|
|
57
|
+
}
|
|
58
|
+
return convertToShape(result);
|
|
59
|
+
}
|
|
60
|
+
function useSchemaModel(formModel, nestedField) {
|
|
9
61
|
var subRulesRef = (0, _react.useRef)([]);
|
|
10
62
|
var pushFieldRule = (0, _react.useCallback)(function (name, fieldRule) {
|
|
11
63
|
subRulesRef.current.push({
|
|
@@ -28,15 +80,16 @@ function useSchemaModel(formModel) {
|
|
|
28
80
|
if (realSubRules.length === 0) {
|
|
29
81
|
return formModel;
|
|
30
82
|
}
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
var name =
|
|
34
|
-
fieldRule =
|
|
35
|
-
return
|
|
83
|
+
var subRuleObject = realSubRules.map(function (_ref2) {
|
|
84
|
+
var _ref3;
|
|
85
|
+
var name = _ref2.name,
|
|
86
|
+
fieldRule = _ref2.fieldRule;
|
|
87
|
+
return _ref3 = {}, _ref3[name] = fieldRule.current, _ref3;
|
|
36
88
|
}).reduce(function (a, b) {
|
|
37
89
|
return Object.assign(a, b);
|
|
38
|
-
}, {})
|
|
39
|
-
|
|
90
|
+
}, {});
|
|
91
|
+
return _schemaTyped.SchemaModel.combine(formModel, (0, _schemaTyped.SchemaModel)(nestedField ? unflattenSchemaObject(subRuleObject) : subRuleObject));
|
|
92
|
+
}, [formModel, nestedField]);
|
|
40
93
|
return {
|
|
41
94
|
getCombinedModel: getCombinedModel,
|
|
42
95
|
pushFieldRule: pushFieldRule,
|
|
@@ -11,6 +11,10 @@ var _set = _interopRequireDefault(require("lodash/set"));
|
|
|
11
11
|
var _utils = require("../utils");
|
|
12
12
|
function getErrorMessage(error) {
|
|
13
13
|
var _error$array;
|
|
14
|
+
if (typeof error === 'string') {
|
|
15
|
+
return error;
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* When using some components as the field, such as TagInput, and using `ArrayType().of` as the validation rule,
|
|
16
20
|
* the error object won't contain the errorMessage directly. @see https://github.com/rsuite/rsuite/issues/3866
|
|
@@ -200,3 +200,17 @@ export type CursorPosition = {
|
|
|
200
200
|
clientTop: number;
|
|
201
201
|
clientLeft: number;
|
|
202
202
|
};
|
|
203
|
+
export declare namespace DateFns {
|
|
204
|
+
/**
|
|
205
|
+
* FirstWeekContainsDate is used to determine which week is the first week of the year, based on what day the January, 1 is in that week.
|
|
206
|
+
* The day in that week can only be 1 (Monday) or 4 (Thursday).
|
|
207
|
+
* Please see https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system for more information.
|
|
208
|
+
*/
|
|
209
|
+
type FirstWeekContainsDate = 1 | 4;
|
|
210
|
+
/**
|
|
211
|
+
* The day of the week type alias.
|
|
212
|
+
* Unlike the date (the number of days since the beginning of the month), which begins with 1 and is dynamic (can go up to 28, 30, or 31), the day starts with 0 and static (always ends at 6).
|
|
213
|
+
* Look at it as an index in an array where Sunday is the first element and Saturday is the last.
|
|
214
|
+
*/
|
|
215
|
+
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
216
|
+
}
|