@iabbb/bds-react 0.45.2 โ 0.46.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.
- package/Button/index.cjs +3 -1
- package/Button/index.cjs.map +1 -1
- package/CallToAction/index.cjs +3 -1
- package/CallToAction/index.cjs.map +1 -1
- package/ErrorMessage/ErrorMessage.d.ts +2 -0
- package/ErrorMessage/index.cjs +90 -0
- package/ErrorMessage/index.cjs.map +1 -0
- package/ErrorMessage/index.d.ts +1 -0
- package/ErrorMessage/index.mjs +67 -0
- package/ErrorMessage/index.mjs.map +1 -0
- package/ErrorMessage/package.json +7 -0
- package/ErrorSummary/ErrorSummary.d.ts +1 -2
- package/ErrorSummary/index.cjs +14 -9
- package/ErrorSummary/index.cjs.map +1 -1
- package/ErrorSummary/index.mjs +14 -9
- package/ErrorSummary/index.mjs.map +1 -1
- package/FieldCheckbox/FieldCheckbox.d.ts +6 -0
- package/FieldCheckbox/index.cjs +194 -0
- package/FieldCheckbox/index.cjs.map +1 -0
- package/FieldCheckbox/index.d.ts +1 -0
- package/FieldCheckbox/index.mjs +171 -0
- package/FieldCheckbox/index.mjs.map +1 -0
- package/FieldCheckbox/package.json +7 -0
- package/FieldRadio/FieldRadio.d.ts +5 -0
- package/FieldRadio/index.cjs +166 -0
- package/FieldRadio/index.cjs.map +1 -0
- package/FieldRadio/index.d.ts +1 -0
- package/FieldRadio/index.mjs +143 -0
- package/FieldRadio/index.mjs.map +1 -0
- package/FieldRadio/package.json +7 -0
- package/FieldTextInput/index.cjs +28 -14
- package/FieldTextInput/index.cjs.map +1 -1
- package/FieldTextInput/index.mjs +25 -13
- package/FieldTextInput/index.mjs.map +1 -1
- package/FieldTextarea/FieldTextarea.d.ts +9 -0
- package/FieldTextarea/index.cjs +120 -0
- package/FieldTextarea/index.cjs.map +1 -0
- package/FieldTextarea/index.d.ts +1 -0
- package/FieldTextarea/index.mjs +97 -0
- package/FieldTextarea/index.mjs.map +1 -0
- package/FieldTextarea/package.json +7 -0
- package/Fieldset/Fieldset.d.ts +9 -0
- package/Fieldset/index.cjs +119 -0
- package/Fieldset/index.cjs.map +1 -0
- package/Fieldset/index.d.ts +2 -0
- package/Fieldset/index.mjs +96 -0
- package/Fieldset/index.mjs.map +1 -0
- package/Fieldset/package.json +7 -0
- package/Pagination/index.cjs +3 -1
- package/Pagination/index.cjs.map +1 -1
- package/Typography/index.cjs +3 -1
- package/Typography/index.cjs.map +1 -1
- package/index.cjs +45 -28
- package/index.cjs.map +1 -1
- package/index.mjs +45 -28
- package/index.mjs.map +1 -1
- package/package.json +10 -10
package/Button/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var React = require('react');
|
|
4
6
|
|
|
5
7
|
function _interopNamespaceDefault(e) {
|
|
@@ -111,5 +113,5 @@ var Button = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
|
|
|
111
113
|
}, props), children);
|
|
112
114
|
});
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
exports.default = Button;
|
|
115
117
|
//# sourceMappingURL=index.cjs.map
|
package/Button/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1;\n\nexport interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n preventDoubleClick?: boolean;\n variant?: 'cancel' | 'featured' | 'quote' | 'reverse' | 'search' | 'standard' | 'unstyled';\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ children, className, onClick, preventDoubleClick = false, variant = 'standard', ...props }, ref) => {\n const debounceClicks = React.useRef(false);\n\n const handleClick: React.MouseEventHandler<HTMLButtonElement> = (event) => {\n // ๐ button is not configured to ignore double clicks\n if (!preventDoubleClick) {\n if (onClick) {\n onClick(event);\n }\n\n return;\n }\n\n // ๐ button has been clicked recently, and subsequent clicks are prevented\n if (debounceClicks.current) {\n event.preventDefault();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n\n // ๐ block from double clicks\n debounceClicks.current = true;\n\n // ๐ and remove the block after a given amount of seconds\n setTimeout(() => {\n debounceClicks.current = false;\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);\n };\n\n return (\n <button\n className={[variant === 'unstyled' ? 'bds-button-unstyled' : 'bds-button', className]\n .filter((x) => x)\n .join(' ')}\n data-type={variant !== 'standard' && variant !== 'unstyled' ? variant : null}\n onClick={handleClick}\n ref={ref}\n {...props}\n >\n {children}\n </button>\n );\n },\n);\n\nexport default Button;\n"],"names":["DEBOUNCE_TIMEOUT_IN_SECONDS","Button","React","forwardRef","_ref","ref","children","className","onClick","_ref$preventDoubleCli","preventDoubleClick","_ref$variant","variant","props","_objectWithoutProperties","_excluded","debounceClicks","useRef","handleClick","event","current","preventDefault","setTimeout","createElement","_extends","filter","x","join"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1;\n\nexport interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n preventDoubleClick?: boolean;\n variant?: 'cancel' | 'featured' | 'quote' | 'reverse' | 'search' | 'standard' | 'unstyled';\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ children, className, onClick, preventDoubleClick = false, variant = 'standard', ...props }, ref) => {\n const debounceClicks = React.useRef(false);\n\n const handleClick: React.MouseEventHandler<HTMLButtonElement> = (event) => {\n // ๐ button is not configured to ignore double clicks\n if (!preventDoubleClick) {\n if (onClick) {\n onClick(event);\n }\n\n return;\n }\n\n // ๐ button has been clicked recently, and subsequent clicks are prevented\n if (debounceClicks.current) {\n event.preventDefault();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n\n // ๐ block from double clicks\n debounceClicks.current = true;\n\n // ๐ and remove the block after a given amount of seconds\n setTimeout(() => {\n debounceClicks.current = false;\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);\n };\n\n return (\n <button\n className={[variant === 'unstyled' ? 'bds-button-unstyled' : 'bds-button', className]\n .filter((x) => x)\n .join(' ')}\n data-type={variant !== 'standard' && variant !== 'unstyled' ? variant : null}\n onClick={handleClick}\n ref={ref}\n {...props}\n >\n {children}\n </button>\n );\n },\n);\n\nexport default Button;\n"],"names":["DEBOUNCE_TIMEOUT_IN_SECONDS","Button","React","forwardRef","_ref","ref","children","className","onClick","_ref$preventDoubleCli","preventDoubleClick","_ref$variant","variant","props","_objectWithoutProperties","_excluded","debounceClicks","useRef","handleClick","event","current","preventDefault","setTimeout","createElement","_extends","filter","x","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,2BAA2B,GAAG,CAAC,CAAA;AAO/BC,IAAAA,MAAM,gBAAGC,gBAAK,CAACC,UAAU,CAC7B,UAAAC,IAAA,EAA+FC,GAAG,EAAK;AAAA,EAAA,IAApGC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAEC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IAAAC,qBAAA,GAAAL,IAAA,CAAEM,kBAAkB;AAAlBA,IAAAA,kBAAkB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,qBAAA;IAAAE,YAAA,GAAAP,IAAA,CAAEQ,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAG,KAAA,CAAA,GAAA,UAAU,GAAAA,YAAA;AAAKE,IAAAA,KAAK,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;AACzF,EAAA,IAA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
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var React = require('react');
|
|
4
6
|
|
|
5
7
|
function _interopNamespaceDefault(e) {
|
|
@@ -79,5 +81,5 @@ var CallToAction = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref)
|
|
|
79
81
|
}, props), children);
|
|
80
82
|
});
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
exports.default = CallToAction;
|
|
83
85
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/CallToAction/CallToAction.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport interface CallToActionProps extends React.ComponentPropsWithoutRef<'a'> {\n variant?: 'featured' | 'quote' | 'standard';\n}\n\nconst CallToAction = React.forwardRef<HTMLAnchorElement, CallToActionProps>(\n ({ children, className, variant = 'standard', ...props }, ref) => {\n return (\n <a\n className={['bds-cta', className].filter((x) => x).join(' ')}\n data-type={variant !== 'standard' ? variant : null}\n ref={ref}\n {...props}\n >\n {children}\n </a>\n );\n },\n);\n\nexport default CallToAction;\n"],"names":["CallToAction","React","forwardRef","_ref","ref","children","className","_ref$variant","variant","props","_objectWithoutProperties","_excluded","createElement","_extends","filter","x","join"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/CallToAction/CallToAction.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport interface CallToActionProps extends React.ComponentPropsWithoutRef<'a'> {\n variant?: 'featured' | 'quote' | 'standard';\n}\n\nconst CallToAction = React.forwardRef<HTMLAnchorElement, CallToActionProps>(\n ({ children, className, variant = 'standard', ...props }, ref) => {\n return (\n <a\n className={['bds-cta', className].filter((x) => x).join(' ')}\n data-type={variant !== 'standard' ? variant : null}\n ref={ref}\n {...props}\n >\n {children}\n </a>\n );\n },\n);\n\nexport default CallToAction;\n"],"names":["CallToAction","React","forwardRef","_ref","ref","children","className","_ref$variant","variant","props","_objectWithoutProperties","_excluded","createElement","_extends","filter","x","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMMA,IAAAA,YAAY,gBAAGC,gBAAK,CAACC,UAAU,CACnC,UAAAC,IAAA,EAA0DC,GAAG,EAAK;AAAA,EAAA,IAA/DC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAAC,YAAA,GAAAJ,IAAA,CAAEK,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAG,KAAA,CAAA,GAAA,UAAU,GAAAA,YAAA;AAAKE,IAAAA,KAAK,GAAAC,wBAAA,CAAAP,IAAA,EAAAQ,SAAA,CAAA,CAAA;AACpD,EAAA,oBACEV,gBAAA,CAAAW,aAAA,CAAA,GAAA,EAAAC,QAAA,CAAA;IACEP,SAAS,EAAE,CAAC,SAAS,EAAEA,SAAS,CAAC,CAACQ,MAAM,CAAC,UAACC,CAAC,EAAA;AAAA,MAAA,OAAKA,CAAC,CAAA;AAAA,KAAA,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AAC7D,IAAA,WAAA,EAAWR,OAAO,KAAK,UAAU,GAAGA,OAAO,GAAG,IAAK;AACnDJ,IAAAA,GAAG,EAAEA,GAAAA;GACDK,EAAAA,KAAK,CAERJ,EAAAA,QACA,CAAC,CAAA;AAER,CACF;;;;"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
function _extends() {
|
|
27
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
28
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
+
var source = arguments[i];
|
|
30
|
+
for (var key in source) {
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
32
|
+
target[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
38
|
+
return _extends.apply(this, arguments);
|
|
39
|
+
}
|
|
40
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
41
|
+
if (source == null) return {};
|
|
42
|
+
var target = {};
|
|
43
|
+
var sourceKeys = Object.keys(source);
|
|
44
|
+
var key, i;
|
|
45
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
46
|
+
key = sourceKeys[i];
|
|
47
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
48
|
+
target[key] = source[key];
|
|
49
|
+
}
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
function _objectWithoutProperties(source, excluded) {
|
|
53
|
+
if (source == null) return {};
|
|
54
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
55
|
+
var key, i;
|
|
56
|
+
if (Object.getOwnPropertySymbols) {
|
|
57
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
58
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
59
|
+
key = sourceSymbolKeys[i];
|
|
60
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
61
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var _excluded = ["className", "children"];
|
|
69
|
+
function ErrorMessage(_ref) {
|
|
70
|
+
var className = _ref.className,
|
|
71
|
+
children = _ref.children,
|
|
72
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
73
|
+
return /*#__PURE__*/React__namespace.createElement("span", _extends({
|
|
74
|
+
className: ['bds-error', className].filter(function (x) {
|
|
75
|
+
return x;
|
|
76
|
+
}).join(' ')
|
|
77
|
+
}, props), /*#__PURE__*/React__namespace.createElement("svg", {
|
|
78
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
79
|
+
viewBox: "0 0 512 512",
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
height: "1em",
|
|
82
|
+
width: "1em",
|
|
83
|
+
fill: "currentColor"
|
|
84
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
85
|
+
d: "M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z"
|
|
86
|
+
})), children);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.default = ErrorMessage;
|
|
90
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport default function ErrorMessage({ className, children, ...props }: React.ComponentPropsWithoutRef<'span'>) {\n return (\n <span className={['bds-error', className].filter((x) => x).join(' ')} {...props}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n {children}\n </span>\n );\n}\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEe,SAASA,YAAYA,CAAAC,IAAA,EAA4E;AAAA,EAAA,IAAzEC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;AAAKC,IAAAA,KAAK,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA,CAAA,CAAA;AAClE,EAAA,oBACEC,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAAC,QAAA,CAAA;IAAMP,SAAS,EAAE,CAAC,WAAW,EAAEA,SAAS,CAAC,CAACQ,MAAM,CAAC,UAACC,CAAC,EAAA;AAAA,MAAA,OAAKA,CAAC,CAAA;KAAC,CAAA,CAACC,IAAI,CAAC,GAAG,CAAA;AAAE,GAAA,EAAKR,KAAK,CAAA,eAC7EG,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACEK,IAAAA,KAAK,EAAC,4BAA4B;AAClCC,IAAAA,OAAO,EAAC,aAAa;AACrB,IAAA,aAAA,EAAY,MAAM;AAClBC,IAAAA,MAAM,EAAC,KAAK;AACZC,IAAAA,KAAK,EAAC,KAAK;AACXC,IAAAA,IAAI,EAAC,cAAA;GAELV,eAAAA,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMU,IAAAA,CAAC,EAAC,4UAAA;AAA4U,GAAE,CACnV,CAAC,EACLf,QACG,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ErrorMessage';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
function _extends() {
|
|
4
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
5
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
+
var source = arguments[i];
|
|
7
|
+
for (var key in source) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
+
target[key] = source[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
return _extends.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
18
|
+
if (source == null) return {};
|
|
19
|
+
var target = {};
|
|
20
|
+
var sourceKeys = Object.keys(source);
|
|
21
|
+
var key, i;
|
|
22
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
23
|
+
key = sourceKeys[i];
|
|
24
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function _objectWithoutProperties(source, excluded) {
|
|
30
|
+
if (source == null) return {};
|
|
31
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
32
|
+
var key, i;
|
|
33
|
+
if (Object.getOwnPropertySymbols) {
|
|
34
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
35
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
36
|
+
key = sourceSymbolKeys[i];
|
|
37
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
38
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
39
|
+
target[key] = source[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var _excluded = ["className", "children"];
|
|
46
|
+
function ErrorMessage(_ref) {
|
|
47
|
+
var className = _ref.className,
|
|
48
|
+
children = _ref.children,
|
|
49
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
51
|
+
className: ['bds-error', className].filter(function (x) {
|
|
52
|
+
return x;
|
|
53
|
+
}).join(' ')
|
|
54
|
+
}, props), /*#__PURE__*/React.createElement("svg", {
|
|
55
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
+
viewBox: "0 0 512 512",
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
height: "1em",
|
|
59
|
+
width: "1em",
|
|
60
|
+
fill: "currentColor"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
62
|
+
d: "M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z"
|
|
63
|
+
})), children);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { ErrorMessage as default };
|
|
67
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorMessage/ErrorMessage.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport default function ErrorMessage({ className, children, ...props }: React.ComponentPropsWithoutRef<'span'>) {\n return (\n <span className={['bds-error', className].filter((x) => x).join(' ')} {...props}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n {children}\n </span>\n );\n}\n"],"names":["ErrorMessage","_ref","className","children","props","_objectWithoutProperties","_excluded","React","createElement","_extends","filter","x","join","xmlns","viewBox","height","width","fill","d"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEe,SAASA,YAAYA,CAAAC,IAAA,EAA4E;AAAA,EAAA,IAAzEC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;AAAKC,IAAAA,KAAK,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA,CAAA,CAAA;AAClE,EAAA,oBACEC,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAAC,QAAA,CAAA;IAAMP,SAAS,EAAE,CAAC,WAAW,EAAEA,SAAS,CAAC,CAACQ,MAAM,CAAC,UAACC,CAAC,EAAA;AAAA,MAAA,OAAKA,CAAC,CAAA;KAAC,CAAA,CAACC,IAAI,CAAC,GAAG,CAAA;AAAE,GAAA,EAAKR,KAAK,CAAA,eAC7EG,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACEK,IAAAA,KAAK,EAAC,4BAA4B;AAClCC,IAAAA,OAAO,EAAC,aAAa;AACrB,IAAA,aAAA,EAAY,MAAM;AAClBC,IAAAA,MAAM,EAAC,KAAK;AACZC,IAAAA,KAAK,EAAC,KAAK;AACXC,IAAAA,IAAI,EAAC,cAAA;GAELV,eAAAA,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMU,IAAAA,CAAC,EAAC,4UAAA;AAA4U,GAAE,CACnV,CAAC,EACLf,QACG,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -11,5 +11,4 @@ export type ErrorSummaryProps = {
|
|
|
11
11
|
errors: Record<string, Array<string> | string> | null;
|
|
12
12
|
mapNameToId?: (name: string) => string;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
export default ErrorSummary;
|
|
14
|
+
export default function BdsErrorSummary({ errors, mapNameToId, ...props }: ErrorSummaryProps & React.ComponentPropsWithoutRef<'div'>): React.JSX.Element | null;
|
package/ErrorSummary/index.cjs
CHANGED
|
@@ -107,7 +107,7 @@ function getAssociatedLegendOrLabel(input) {
|
|
|
107
107
|
var _excluded = ["errors", "mapNameToId"];
|
|
108
108
|
var FormErrorKey = '_form';
|
|
109
109
|
var FINAL_FORM_ERROR = 'FINAL_FORM/form-error';
|
|
110
|
-
|
|
110
|
+
function BdsErrorSummary(_ref) {
|
|
111
111
|
var errors = _ref.errors,
|
|
112
112
|
_ref$mapNameToId = _ref.mapNameToId,
|
|
113
113
|
mapNameToId = _ref$mapNameToId === void 0 ? function (name) {
|
|
@@ -115,7 +115,13 @@ var ErrorSummary = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref)
|
|
|
115
115
|
} : _ref$mapNameToId,
|
|
116
116
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
117
117
|
var headingId = React__namespace.useId();
|
|
118
|
-
var
|
|
118
|
+
var groupRef = React__namespace.useRef(null);
|
|
119
|
+
React__namespace.useEffect(function () {
|
|
120
|
+
if (!errors || Object.keys(errors).length === 0) return;
|
|
121
|
+
if (!groupRef.current) return;
|
|
122
|
+
groupRef.current.focus();
|
|
123
|
+
}, [errors]);
|
|
124
|
+
if (!errors || Object.keys(errors).length === 0) return null;
|
|
119
125
|
var handleLinkClick = function handleLinkClick(e) {
|
|
120
126
|
var inputId = getFragmentFromUrl(e.currentTarget.href);
|
|
121
127
|
if (!inputId) {
|
|
@@ -137,11 +143,10 @@ var ErrorSummary = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref)
|
|
|
137
143
|
};
|
|
138
144
|
return /*#__PURE__*/React__namespace.createElement("bds-error-summary", _extends({
|
|
139
145
|
role: "group",
|
|
140
|
-
"aria-labelledby":
|
|
141
|
-
|
|
142
|
-
ref: ref,
|
|
146
|
+
"aria-labelledby": headingId,
|
|
147
|
+
ref: groupRef,
|
|
143
148
|
tabIndex: -1
|
|
144
|
-
}, props),
|
|
149
|
+
}, props), /*#__PURE__*/React__namespace.createElement("h2", {
|
|
145
150
|
className: "bds-h5",
|
|
146
151
|
id: headingId
|
|
147
152
|
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
@@ -177,9 +182,9 @@ var ErrorSummary = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref)
|
|
|
177
182
|
onClick: handleLinkClick
|
|
178
183
|
}, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
|
|
179
184
|
}));
|
|
180
|
-
})))
|
|
181
|
-
}
|
|
185
|
+
})));
|
|
186
|
+
}
|
|
182
187
|
|
|
183
188
|
exports.FormErrorKey = FormErrorKey;
|
|
184
|
-
exports.default =
|
|
189
|
+
exports.default = BdsErrorSummary;
|
|
185
190
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\n return url.includes('#') ? url.split('#').pop() : undefined;\n}\n\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\n const fieldset = input.closest('fieldset');\n\n if (fieldset) {\n const legends = fieldset.getElementsByTagName('legend');\n\n if (legends.length) {\n const candidateLegend = legends[0];\n\n // If the input type is radio or checkbox, always use the legend if there\n // is one.\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\n return candidateLegend;\n }\n\n // For other input types, only scroll to the fieldsetโs legend (instead of\n // the label associated with the input) if the input would end up in the\n // top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = candidateLegend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return candidateLegend;\n }\n }\n }\n }\n\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\n}\n","import * as React from 'react';\n\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\n }\n }\n}\n\nexport const FormErrorKey = '_form';\n\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\n\nexport type ErrorSummaryProps = {\n errors: Record<string, Array<string> | string> | null;\n mapNameToId?: (name: string) => string;\n};\n\nconst ErrorSummary = React.forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ errors, mapNameToId = (name) => name, ...props }, ref) => {\n const headingId = React.useId();\n\n const isEmpty = !errors || Object.keys(errors).length === 0;\n\n const handleLinkClick = (e) => {\n const inputId = getFragmentFromUrl(e.currentTarget.href);\n\n if (!inputId) {\n return;\n }\n\n const input = document.getElementById(inputId);\n\n if (!input) {\n return;\n }\n\n const legendOrLabel = getAssociatedLegendOrLabel(input);\n\n if (!legendOrLabel) {\n return;\n }\n\n e.preventDefault();\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n };\n\n return (\n <bds-error-summary\n role=\"group\"\n aria-labelledby={!isEmpty ? headingId : undefined}\n hidden={isEmpty ? true : undefined}\n ref={ref}\n tabIndex={-1}\n {...props}\n >\n {!isEmpty && (\n <>\n <h2 className=\"bds-h5\" id={headingId}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n Issue\n </h2>\n <ul>\n {Object.keys(errors).map((errorKey) => {\n const message = errors[errorKey];\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\n\n if (isFormError) {\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\n }\n\n const isArrayField = Array.isArray(message);\n\n const messages = isArrayField ? message : [message];\n\n return (\n <React.Fragment key={errorKey}>\n {messages.map((fieldMessage, index) => {\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\n\n return (\n <li key={inputId}>\n <a href={`#${inputId}`} onClick={handleLinkClick}>\n {fieldMessage}\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\n </a>\n </li>\n );\n })}\n </React.Fragment>\n );\n })}\n </ul>\n </>\n )}\n </bds-error-summary>\n );\n },\n);\n\nexport default ErrorSummary;\n"],"names":["getFragmentFromUrl","url","includes","split","pop","undefined","getAssociatedLegendOrLabel","input","_document$querySelect","fieldset","closest","legends","getElementsByTagName","length","candidateLegend","HTMLInputElement","type","legendTop","getBoundingClientRect","top","inputRect","height","window","innerHeight","inputBottom","document","querySelector","concat","getAttribute","FormErrorKey","FINAL_FORM_ERROR","ErrorSummary","React","forwardRef","_ref","ref","errors","_ref$mapNameToId","mapNameToId","name","props","_objectWithoutProperties","_excluded","headingId","useId","isEmpty","Object","keys","handleLinkClick","e","inputId","currentTarget","href","getElementById","legendOrLabel","preventDefault","scrollIntoView","focus","preventScroll","createElement","_extends","role","hidden","tabIndex","Fragment","className","id","xmlns","viewBox","width","fill","d","map","errorKey","message","isFormError","key","dangerouslySetInnerHTML","__html","isArrayField","Array","isArray","messages","fieldMessage","index","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,kBAAkBA,CAACC,GAAW,EAAE;AAC9C,EAAA,OAAOA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,EAAE,GAAGC,SAAS,CAAA;AAC7D,CAAA;AAEO,SAASC,0BAA0BA,CAACC,KAAkB,EAAE;AAAA,EAAA,IAAAC,qBAAA,CAAA;AAC7D,EAAA,IAAMC,QAAQ,GAAGF,KAAK,CAACG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,EAAA,IAAID,QAAQ,EAAE;AACZ,IAAA,IAAME,OAAO,GAAGF,QAAQ,CAACG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAEvD,IAAID,OAAO,CAAC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s","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\n return url.includes('#') ? url.split('#').pop() : undefined;\n}\n\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\n const fieldset = input.closest('fieldset');\n\n if (fieldset) {\n const legends = fieldset.getElementsByTagName('legend');\n\n if (legends.length) {\n const candidateLegend = legends[0];\n\n // If the input type is radio or checkbox, always use the legend if there\n // is one.\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\n return candidateLegend;\n }\n\n // For other input types, only scroll to the fieldsetโs legend (instead of\n // the label associated with the input) if the input would end up in the\n // top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = candidateLegend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return candidateLegend;\n }\n }\n }\n }\n\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\n}\n","import * as React from 'react';\n\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\n }\n }\n}\n\nexport const FormErrorKey = '_form';\n\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\n\nexport type ErrorSummaryProps = {\n errors: Record<string, Array<string> | string> | null;\n mapNameToId?: (name: string) => string;\n};\n\nexport default function BdsErrorSummary({\n errors,\n mapNameToId = (name) => name,\n ...props\n}: ErrorSummaryProps & React.ComponentPropsWithoutRef<'div'>) {\n const headingId = React.useId();\n const groupRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (!errors || Object.keys(errors).length === 0) return;\n if (!groupRef.current) return;\n\n groupRef.current.focus();\n }, [errors]);\n\n if (!errors || Object.keys(errors).length === 0) return null;\n\n const handleLinkClick = (e) => {\n const inputId = getFragmentFromUrl(e.currentTarget.href);\n\n if (!inputId) {\n return;\n }\n\n const input = document.getElementById(inputId);\n\n if (!input) {\n return;\n }\n\n const legendOrLabel = getAssociatedLegendOrLabel(input);\n\n if (!legendOrLabel) {\n return;\n }\n\n e.preventDefault();\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n };\n\n return (\n <bds-error-summary role=\"group\" aria-labelledby={headingId} ref={groupRef} tabIndex={-1} {...props}>\n <h2 className=\"bds-h5\" id={headingId}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n Issue\n </h2>\n <ul>\n {Object.keys(errors).map((errorKey) => {\n const message = errors[errorKey];\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\n\n if (isFormError) {\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\n }\n\n const isArrayField = Array.isArray(message);\n\n const messages = isArrayField ? message : [message];\n\n return (\n <React.Fragment key={errorKey}>\n {messages.map((fieldMessage, index) => {\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\n\n return (\n <li key={inputId}>\n <a href={`#${inputId}`} onClick={handleLinkClick}>\n {fieldMessage}\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\n </a>\n </li>\n );\n })}\n </React.Fragment>\n );\n })}\n </ul>\n </bds-error-summary>\n );\n}\n"],"names":["getFragmentFromUrl","url","includes","split","pop","undefined","getAssociatedLegendOrLabel","input","_document$querySelect","fieldset","closest","legends","getElementsByTagName","length","candidateLegend","HTMLInputElement","type","legendTop","getBoundingClientRect","top","inputRect","height","window","innerHeight","inputBottom","document","querySelector","concat","getAttribute","FormErrorKey","FINAL_FORM_ERROR","BdsErrorSummary","_ref","errors","_ref$mapNameToId","mapNameToId","name","props","_objectWithoutProperties","_excluded","headingId","React","useId","groupRef","useRef","useEffect","Object","keys","current","focus","handleLinkClick","e","inputId","currentTarget","href","getElementById","legendOrLabel","preventDefault","scrollIntoView","preventScroll","createElement","_extends","role","ref","tabIndex","className","id","xmlns","viewBox","width","fill","d","map","errorKey","message","isFormError","key","dangerouslySetInnerHTML","__html","isArrayField","Array","isArray","messages","Fragment","fieldMessage","index","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,kBAAkBA,CAACC,GAAW,EAAE;AAC9C,EAAA,OAAOA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,EAAE,GAAGC,SAAS,CAAA;AAC7D,CAAA;AAEO,SAASC,0BAA0BA,CAACC,KAAkB,EAAE;AAAA,EAAA,IAAAC,qBAAA,CAAA;AAC7D,EAAA,IAAMC,QAAQ,GAAGF,KAAK,CAACG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,EAAA,IAAID,QAAQ,EAAE;AACZ,IAAA,IAAME,OAAO,GAAGF,QAAQ,CAACG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAEvD,IAAID,OAAO,CAACE,MAA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,EAAA,GAAA,CAAA,GAAMR,SAChE,CACD,CAAC,CAAA;AAET,KAAC,CACa,CAAC,CAAA;GAEpB,CACC,CACa,CAAC,CAAA;AAExB;;;;;"}
|
package/ErrorSummary/index.mjs
CHANGED
|
@@ -84,7 +84,7 @@ function getAssociatedLegendOrLabel(input) {
|
|
|
84
84
|
var _excluded = ["errors", "mapNameToId"];
|
|
85
85
|
var FormErrorKey = '_form';
|
|
86
86
|
var FINAL_FORM_ERROR = 'FINAL_FORM/form-error';
|
|
87
|
-
|
|
87
|
+
function BdsErrorSummary(_ref) {
|
|
88
88
|
var errors = _ref.errors,
|
|
89
89
|
_ref$mapNameToId = _ref.mapNameToId,
|
|
90
90
|
mapNameToId = _ref$mapNameToId === void 0 ? function (name) {
|
|
@@ -92,7 +92,13 @@ var ErrorSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
92
92
|
} : _ref$mapNameToId,
|
|
93
93
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
94
94
|
var headingId = React.useId();
|
|
95
|
-
var
|
|
95
|
+
var groupRef = React.useRef(null);
|
|
96
|
+
React.useEffect(function () {
|
|
97
|
+
if (!errors || Object.keys(errors).length === 0) return;
|
|
98
|
+
if (!groupRef.current) return;
|
|
99
|
+
groupRef.current.focus();
|
|
100
|
+
}, [errors]);
|
|
101
|
+
if (!errors || Object.keys(errors).length === 0) return null;
|
|
96
102
|
var handleLinkClick = function handleLinkClick(e) {
|
|
97
103
|
var inputId = getFragmentFromUrl(e.currentTarget.href);
|
|
98
104
|
if (!inputId) {
|
|
@@ -114,11 +120,10 @@ var ErrorSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
114
120
|
};
|
|
115
121
|
return /*#__PURE__*/React.createElement("bds-error-summary", _extends({
|
|
116
122
|
role: "group",
|
|
117
|
-
"aria-labelledby":
|
|
118
|
-
|
|
119
|
-
ref: ref,
|
|
123
|
+
"aria-labelledby": headingId,
|
|
124
|
+
ref: groupRef,
|
|
120
125
|
tabIndex: -1
|
|
121
|
-
}, props),
|
|
126
|
+
}, props), /*#__PURE__*/React.createElement("h2", {
|
|
122
127
|
className: "bds-h5",
|
|
123
128
|
id: headingId
|
|
124
129
|
}, /*#__PURE__*/React.createElement("svg", {
|
|
@@ -154,8 +159,8 @@ var ErrorSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
154
159
|
onClick: handleLinkClick
|
|
155
160
|
}, fieldMessage, messages.length > 1 ? " (".concat(index + 1, " of ").concat(messages.length, ")") : undefined));
|
|
156
161
|
}));
|
|
157
|
-
})))
|
|
158
|
-
}
|
|
162
|
+
})));
|
|
163
|
+
}
|
|
159
164
|
|
|
160
|
-
export { FormErrorKey,
|
|
165
|
+
export { FormErrorKey, BdsErrorSummary as default };
|
|
161
166
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\n return url.includes('#') ? url.split('#').pop() : undefined;\n}\n\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\n const fieldset = input.closest('fieldset');\n\n if (fieldset) {\n const legends = fieldset.getElementsByTagName('legend');\n\n if (legends.length) {\n const candidateLegend = legends[0];\n\n // If the input type is radio or checkbox, always use the legend if there\n // is one.\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\n return candidateLegend;\n }\n\n // For other input types, only scroll to the fieldsetโs legend (instead of\n // the label associated with the input) if the input would end up in the\n // top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = candidateLegend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return candidateLegend;\n }\n }\n }\n }\n\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\n}\n","import * as React from 'react';\n\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\n }\n }\n}\n\nexport const FormErrorKey = '_form';\n\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\n\nexport type ErrorSummaryProps = {\n errors: Record<string, Array<string> | string> | null;\n mapNameToId?: (name: string) => string;\n};\n\nconst ErrorSummary = React.forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ errors, mapNameToId = (name) => name, ...props }, ref) => {\n const headingId = React.useId();\n\n const isEmpty = !errors || Object.keys(errors).length === 0;\n\n const handleLinkClick = (e) => {\n const inputId = getFragmentFromUrl(e.currentTarget.href);\n\n if (!inputId) {\n return;\n }\n\n const input = document.getElementById(inputId);\n\n if (!input) {\n return;\n }\n\n const legendOrLabel = getAssociatedLegendOrLabel(input);\n\n if (!legendOrLabel) {\n return;\n }\n\n e.preventDefault();\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n };\n\n return (\n <bds-error-summary\n role=\"group\"\n aria-labelledby={!isEmpty ? headingId : undefined}\n hidden={isEmpty ? true : undefined}\n ref={ref}\n tabIndex={-1}\n {...props}\n >\n {!isEmpty && (\n <>\n <h2 className=\"bds-h5\" id={headingId}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n Issue\n </h2>\n <ul>\n {Object.keys(errors).map((errorKey) => {\n const message = errors[errorKey];\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\n\n if (isFormError) {\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\n }\n\n const isArrayField = Array.isArray(message);\n\n const messages = isArrayField ? message : [message];\n\n return (\n <React.Fragment key={errorKey}>\n {messages.map((fieldMessage, index) => {\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\n\n return (\n <li key={inputId}>\n <a href={`#${inputId}`} onClick={handleLinkClick}>\n {fieldMessage}\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\n </a>\n </li>\n );\n })}\n </React.Fragment>\n );\n })}\n </ul>\n </>\n )}\n </bds-error-summary>\n );\n },\n);\n\nexport default ErrorSummary;\n"],"names":["getFragmentFromUrl","url","includes","split","pop","undefined","getAssociatedLegendOrLabel","input","_document$querySelect","fieldset","closest","legends","getElementsByTagName","length","candidateLegend","HTMLInputElement","type","legendTop","getBoundingClientRect","top","inputRect","height","window","innerHeight","inputBottom","document","querySelector","concat","getAttribute","FormErrorKey","FINAL_FORM_ERROR","ErrorSummary","React","forwardRef","_ref","ref","errors","_ref$mapNameToId","mapNameToId","name","props","_objectWithoutProperties","_excluded","headingId","useId","isEmpty","Object","keys","handleLinkClick","e","inputId","currentTarget","href","getElementById","legendOrLabel","preventDefault","scrollIntoView","focus","preventScroll","createElement","_extends","role","hidden","tabIndex","Fragment","className","id","xmlns","viewBox","width","fill","d","map","errorKey","message","isFormError","key","dangerouslySetInnerHTML","__html","isArrayField","Array","isArray","messages","fieldMessage","index","onClick"],"mappings":";;;;;;;;;;;;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A;OACPlB,eAAAA,KAAA,CAAA2B,aAAA,CAAA,GAAA,EAAA;AAAGP,QAAAA,IAAI,EAAAzB,GAAAA,CAAAA,MAAA,CAAMuB,OAAO,CAAG;AAACmC,QAAAA,OAAO,EAAErC,eAAAA;OAC9BmC,EAAAA,YAAY,EACZD,QAAQ,CAACrE,MAAM,GAAG,CAAC,GAAAc,IAAAA,CAAAA,MAAA,CAAQyD,KAAK,GAAG,CAAC,EAAA,MAAA,CAAA,CAAAzD,MAAA,CAAOuD,QAAQ,CAACrE,MAAM,EAAA,GAAA,CAAA,GAAMR,SAChE,CACD,CAAC,CAAA;AAET,KAAC,CACa,CAAC,CAAA;GAEpB,CACC,CACJ,CAEa,CAAC,CAAA;AAExB,CACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/ErrorSummary/utils.ts","../../src/ErrorSummary/ErrorSummary.tsx"],"sourcesContent":["export function getFragmentFromUrl(url: string) {\n return url.includes('#') ? url.split('#').pop() : undefined;\n}\n\nexport function getAssociatedLegendOrLabel(input: HTMLElement) {\n const fieldset = input.closest('fieldset');\n\n if (fieldset) {\n const legends = fieldset.getElementsByTagName('legend');\n\n if (legends.length) {\n const candidateLegend = legends[0];\n\n // If the input type is radio or checkbox, always use the legend if there\n // is one.\n if (input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio')) {\n return candidateLegend;\n }\n\n // For other input types, only scroll to the fieldsetโs legend (instead of\n // the label associated with the input) if the input would end up in the\n // top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = candidateLegend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return candidateLegend;\n }\n }\n }\n }\n\n return document.querySelector(`label[for='${input.getAttribute('id')}']`) ?? input.closest('label');\n}\n","import * as React from 'react';\n\nimport { getAssociatedLegendOrLabel, getFragmentFromUrl } from './utils';\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n 'bds-error-summary': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;\n }\n }\n}\n\nexport const FormErrorKey = '_form';\n\nconst FINAL_FORM_ERROR = 'FINAL_FORM/form-error';\n\nexport type ErrorSummaryProps = {\n errors: Record<string, Array<string> | string> | null;\n mapNameToId?: (name: string) => string;\n};\n\nexport default function BdsErrorSummary({\n errors,\n mapNameToId = (name) => name,\n ...props\n}: ErrorSummaryProps & React.ComponentPropsWithoutRef<'div'>) {\n const headingId = React.useId();\n const groupRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n if (!errors || Object.keys(errors).length === 0) return;\n if (!groupRef.current) return;\n\n groupRef.current.focus();\n }, [errors]);\n\n if (!errors || Object.keys(errors).length === 0) return null;\n\n const handleLinkClick = (e) => {\n const inputId = getFragmentFromUrl(e.currentTarget.href);\n\n if (!inputId) {\n return;\n }\n\n const input = document.getElementById(inputId);\n\n if (!input) {\n return;\n }\n\n const legendOrLabel = getAssociatedLegendOrLabel(input);\n\n if (!legendOrLabel) {\n return;\n }\n\n e.preventDefault();\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n };\n\n return (\n <bds-error-summary role=\"group\" aria-labelledby={headingId} ref={groupRef} tabIndex={-1} {...props}>\n <h2 className=\"bds-h5\" id={headingId}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 512 512\"\n aria-hidden=\"true\"\n height=\"1em\"\n width=\"1em\"\n fill=\"currentColor\"\n >\n <path d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z\" />\n </svg>\n Issue\n </h2>\n <ul>\n {Object.keys(errors).map((errorKey) => {\n const message = errors[errorKey];\n const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);\n\n if (isFormError) {\n return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;\n }\n\n const isArrayField = Array.isArray(message);\n\n const messages = isArrayField ? message : [message];\n\n return (\n <React.Fragment key={errorKey}>\n {messages.map((fieldMessage, index) => {\n const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;\n\n return (\n <li key={inputId}>\n <a href={`#${inputId}`} onClick={handleLinkClick}>\n {fieldMessage}\n {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}\n </a>\n </li>\n );\n })}\n </React.Fragment>\n );\n })}\n </ul>\n </bds-error-summary>\n );\n}\n"],"names":["getFragmentFromUrl","url","includes","split","pop","undefined","getAssociatedLegendOrLabel","input","_document$querySelect","fieldset","closest","legends","getElementsByTagName","length","candidateLegend","HTMLInputElement","type","legendTop","getBoundingClientRect","top","inputRect","height","window","innerHeight","inputBottom","document","querySelector","concat","getAttribute","FormErrorKey","FINAL_FORM_ERROR","BdsErrorSummary","_ref","errors","_ref$mapNameToId","mapNameToId","name","props","_objectWithoutProperties","_excluded","headingId","React","useId","groupRef","useRef","useEffect","Object","keys","current","focus","handleLinkClick","e","inputId","currentTarget","href","getElementById","legendOrLabel","preventDefault","scrollIntoView","preventScroll","createElement","_extends","role","ref","tabIndex","className","id","xmlns","viewBox","width","fill","d","map","errorKey","message","isFormError","key","dangerouslySetInnerHTML","__html","isArrayField","Array","isArray","messages","Fragment","fieldMessage","index","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,k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